-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(store): add NatSpec to Store utils (#1648)
Co-authored-by: alvarius <[email protected]>
- Loading branch information
Showing
5 changed files
with
84 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,43 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.21; | ||
|
||
/** | ||
* @title Shared Constants for EVM and Schema Handling | ||
* @dev This file provides constants for better handling of EVM and Schema related functionalities. | ||
*/ | ||
|
||
/* Shared constants */ | ||
|
||
// Total byte length of an EVM word | ||
/// @dev Represents the total byte length of an EVM word. | ||
uint256 constant WORD_SIZE = 32; | ||
// Index of the last byte in an EVM word | ||
|
||
/// @dev Represents the index of the last byte in an EVM word. | ||
uint256 constant WORD_LAST_INDEX = 31; | ||
// Conversion for bit shifting | ||
|
||
/// @dev Represents the conversion constant from byte to bits. | ||
uint256 constant BYTE_TO_BITS = 8; | ||
|
||
// Schema's capacity | ||
/// @dev Represents the maximum number of fields a Schema can handle. | ||
uint256 constant MAX_TOTAL_FIELDS = 28; | ||
// FieldLayout's capacity | ||
|
||
/// @dev Represents the maximum number of static fields in a FieldLayout. | ||
uint256 constant MAX_STATIC_FIELDS = 28; | ||
// PackedCounter's capacity | ||
|
||
/// @dev Represents the maximum number of dynamic fields that can be packed in a PackedCounter. | ||
uint256 constant MAX_DYNAMIC_FIELDS = 5; | ||
|
||
// FieldLayout and Schema have the same offsets for metadata | ||
/** | ||
* @title LayoutOffsets Library | ||
* @notice This library provides constant offsets for FieldLayout and Schema metadata. | ||
* @dev FieldLayout and Schema utilize the same offset values for metadata. | ||
*/ | ||
library LayoutOffsets { | ||
/// @notice Represents the total length offset within the EVM word. | ||
uint256 internal constant TOTAL_LENGTH = (WORD_SIZE - 2) * BYTE_TO_BITS; | ||
|
||
/// @notice Represents the number of static fields offset within the EVM word. | ||
uint256 internal constant NUM_STATIC_FIELDS = (WORD_SIZE - 2 - 1) * BYTE_TO_BITS; | ||
|
||
/// @notice Represents the number of dynamic fields offset within the EVM word. | ||
uint256 internal constant NUM_DYNAMIC_FIELDS = (WORD_SIZE - 2 - 1 - 1) * BYTE_TO_BITS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.21; | ||
|
||
/** | ||
* @title Resource Identifiers | ||
* @notice Constants representing unique identifiers for different resource types. | ||
* @dev These identifiers can be used to distinguish between various resource types. | ||
*/ | ||
|
||
/// @dev Identifier for a resource table. | ||
bytes2 constant RESOURCE_TABLE = "tb"; | ||
|
||
/// @dev Identifier for an offchain resource table. | ||
bytes2 constant RESOURCE_OFFCHAIN_TABLE = "ot"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.21; | ||
|
||
/** | ||
* @title Store Versioning | ||
* @notice Contains a constant representing the version of the store. | ||
*/ | ||
|
||
/// @dev Identifier for the current store version. | ||
bytes32 constant STORE_VERSION = "1.0.0-unaudited"; |