Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/access/AccessControl/AccessControlFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ contract AccessControlFacet {

/**
* @notice storage struct for the AccessControl.
* @custom:storage-location erc8042:compose.accesscontrol
*/
struct AccessControlStorage {
mapping(address account => mapping(bytes32 role => bool hasRole)) hasRole;
Expand Down
4 changes: 2 additions & 2 deletions src/access/AccessControlPausable/AccessControlPausableMod.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ bytes32 constant ACCESS_CONTROL_STORAGE_POSITION = keccak256("compose.accesscont
*/
bytes32 constant PAUSABLE_STORAGE_POSITION = keccak256("compose.accesscontrol.pausable");

/*
/**
* @notice Storage struct for AccessControl (reused struct definition).
* @dev Must match the struct definition in AccessControlFacet.
* @custom:storage-location erc8042:compose.accesscontrol
Expand All @@ -52,7 +52,7 @@ struct AccessControlStorage {
mapping(bytes32 role => bytes32 adminRole) adminRole;
}

/*
/**
* @notice Storage struct for AccessControlPausable.
* @custom:storage-location erc8042:compose.accesscontrol.pausable
*/
Expand Down
4 changes: 2 additions & 2 deletions src/access/AccessControlTemporal/AccessControlTemporalMod.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ bytes32 constant ACCESS_CONTROL_STORAGE_POSITION = keccak256("compose.accesscont
*/
bytes32 constant TEMPORAL_STORAGE_POSITION = keccak256("compose.accesscontrol.temporal");

/*
/**
* @notice Storage struct for AccessControl (reused struct definition).
* @dev Must match the struct definition in AccessControlFacet.
* @custom:storage-location erc8042:compose.accesscontrol
Expand All @@ -58,7 +58,7 @@ struct AccessControlStorage {
mapping(bytes32 role => bytes32 adminRole) adminRole;
}

/*
/**
* @notice Storage struct for AccessControlTemporal.
* @custom:storage-location erc8042:compose.accesscontrol.temporal
*/
Expand Down
4 changes: 2 additions & 2 deletions src/access/Owner/OwnerFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ contract OwnerFacet {
*/
error OwnerUnauthorizedAccount();

bytes32 constant STORAGE_POSITION = keccak256("compose.owner");
bytes32 constant STORAGE_POSITION = keccak256("erc173.owner");

/**
* @custom:storage-location erc8042:compose.owner
* @custom:storage-location erc8042:erc173.owner
*/
struct OwnerStorage {
address owner;
Expand Down
4 changes: 2 additions & 2 deletions src/access/Owner/OwnerMod.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ error OwnerUnauthorizedAccount();
*/
error OwnerAlreadyRenounced();

bytes32 constant STORAGE_POSITION = keccak256("compose.owner");
bytes32 constant STORAGE_POSITION = keccak256("erc173.owner");

/**
* @custom:storage-location erc8042:compose.owner
* @custom:storage-location erc8042:erc173.owner
*/
struct OwnerStorage {
address owner;
Expand Down
8 changes: 4 additions & 4 deletions src/access/OwnerTwoSteps/OwnerTwoStepsFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ contract OwnerTwoStepsFacet {
*/
error OwnerUnauthorizedAccount();

bytes32 constant OWNER_STORAGE_POSITION = keccak256("compose.owner");
bytes32 constant OWNER_STORAGE_POSITION = keccak256("erc173.owner");

/**
* @custom:storage-location erc8042:compose.owner
* @custom:storage-location erc8042:erc173.owner
*/
struct OwnerStorage {
address owner;
Expand All @@ -45,10 +45,10 @@ contract OwnerTwoStepsFacet {
}
}

bytes32 constant PENDING_OWNER_STORAGE_POSITION = keccak256("compose.owner.pending");
bytes32 constant PENDING_OWNER_STORAGE_POSITION = keccak256("erc173.owner.pending");

/**
* @custom:storage-location erc8042:compose.owner.pending
* @custom:storage-location erc8042:erc173.owner.pending
*/
struct PendingOwnerStorage {
address pendingOwner;
Expand Down
8 changes: 4 additions & 4 deletions src/access/OwnerTwoSteps/OwnerTwoStepsMod.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ error OwnerUnauthorizedAccount();
*/
error OwnerAlreadyRenounced();

bytes32 constant OWNER_STORAGE_POSITION = keccak256("compose.owner");
bytes32 constant OWNER_STORAGE_POSITION = keccak256("erc173.owner");

/**
* @custom:storage-location erc8042:compose.owner
* @custom:storage-location erc8042:erc173.owner
*/
struct OwnerStorage {
address owner;
Expand All @@ -49,10 +49,10 @@ function getOwnerStorage() pure returns (OwnerStorage storage s) {
}
}

bytes32 constant PENDING_OWNER_STORAGE_POSITION = keccak256("compose.owner.pending");
bytes32 constant PENDING_OWNER_STORAGE_POSITION = keccak256("erc173.owner.pending");

/**
* @custom:storage-location erc8042:compose.owner.pending
* @custom:storage-location erc8042:erc173.owner.pending
*/
struct PendingOwnerStorage {
address pendingOwner;
Expand Down
2 changes: 1 addition & 1 deletion src/diamond/DiamondMod.sol
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function importSelectors(address _facet) view returns (bytes memory selectors) {
}
}

// Validate ABI offset == 0x20 for a single dynamic return
/* Validate ABI offset == 0x20 for a single dynamic return */
uint256 offset;
assembly ("memory-safe") {
offset := mload(add(data, 0x20))
Expand Down
4 changes: 2 additions & 2 deletions src/diamond/DiamondUpgradeFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ contract DiamondUpgradeFacet {
}

/**
* @custom:storage-location erc8042:erc8109.diamond
* @custom:storage-location erc8042:erc8153.diamond
*/
struct DiamondStorage {
mapping(bytes4 functionSelector => FacetNode) facetNodes;
Expand Down Expand Up @@ -228,7 +228,7 @@ contract DiamondUpgradeFacet {
}
}

// Validate ABI offset == 0x20 for a single dynamic return
/* Validate ABI offset == 0x20 for a single dynamic return */
uint256 offset;
assembly ("memory-safe") {
offset := mload(add(data, 0x20))
Expand Down
2 changes: 1 addition & 1 deletion src/diamond/DiamondUpgradeMod.sol
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ function importSelectors(address _facet) view returns (bytes memory selectors) {
}
}

// Validate ABI offset == 0x20 for a single dynamic return
/* Validate ABI offset == 0x20 for a single dynamic return */
uint256 offset;
assembly ("memory-safe") {
offset := mload(add(data, 0x20))
Expand Down
4 changes: 2 additions & 2 deletions src/interfaceDetection/ERC165/ERC165Facet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ contract ERC165Facet {
* @notice Storage slot identifier for ERC-165 interface detection
* @dev Defined using keccak256 hash following ERC-8042 standard
*/
bytes32 constant STORAGE_POSITION = keccak256("compose.erc165");
bytes32 constant STORAGE_POSITION = keccak256("erc165");

/**
* @notice ERC-165 storage layout using the ERC-8042 standard
* @custom:storage-location erc8042:compose.erc165
* @custom:storage-location erc8042:erc165
*/
struct ERC165Storage {
/**
Expand Down
4 changes: 2 additions & 2 deletions src/interfaceDetection/ERC165/ERC165Mod.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ pragma solidity >=0.8.30;
/*
* Storage slot identifier, defined using keccak256 hash of the library diamond storage identifier.
*/
bytes32 constant STORAGE_POSITION = keccak256("compose.erc165");
bytes32 constant STORAGE_POSITION = keccak256("erc165");

/*
* @notice ERC-165 storage layout using the ERC-8042 standard.
* @custom:storage-location erc8042:compose.erc165
* @custom:storage-location erc8042:erc165
*/
struct ERC165Storage {
/*
Expand Down
2 changes: 1 addition & 1 deletion src/token/ERC1155/ERC1155DataFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ contract ERC1155DataFacet {

/**
* @dev ERC-8042 compliant storage struct for ERC-1155 token data.
* @custom:storage-location erc8042:compose.erc1155
* @custom:storage-location erc8042:erc1155
*/
struct ERC1155Storage {
mapping(uint256 id => mapping(address account => uint256 balance)) balanceOf;
Expand Down
4 changes: 2 additions & 2 deletions src/token/ERC1155/ERC1155Facet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ interface IERC1155Receiver {
*
* For developers creating custom facets that need to interact with ERC-1155 storage (e.g., custom minting logic),
* use the LibERC1155 library which provides helper functions to access this facet's storage.
* This facet does NOT depend on LibERC1155 - both access the same storage at keccak256("compose.erc1155").
* This facet does NOT depend on LibERC1155 - both access the same storage at keccak256("erc1155").
*/
contract ERC1155Facet {
/**
Expand Down Expand Up @@ -156,7 +156,7 @@ contract ERC1155Facet {

/**
* @dev ERC-8042 compliant storage struct for ERC-1155 token data.
* @custom:storage-location erc8042:compose.erc1155
* @custom:storage-location erc8042:erc1155
*/
struct ERC1155Storage {
mapping(uint256 id => mapping(address account => uint256 balance)) balanceOf;
Expand Down
4 changes: 2 additions & 2 deletions src/token/ERC1155/ERC1155Mod.sol
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ event URI(string _value, uint256 indexed _id);
/**
* @dev Storage position determined by the keccak256 hash of the diamond storage identifier.
*/
bytes32 constant STORAGE_POSITION = keccak256("compose.erc1155");
bytes32 constant STORAGE_POSITION = keccak256("erc1155");

/**
* @dev ERC-8042 compliant storage struct for ERC-1155 token data.
* @custom:storage-location erc8042:compose.erc1155
* @custom:storage-location erc8042:erc1155
*/
struct ERC1155Storage {
mapping(uint256 id => mapping(address account => uint256 balance)) balanceOf;
Expand Down
1 change: 1 addition & 0 deletions src/token/ERC20/Bridgeable/ERC20BridgeableFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ contract ERC20BridgeableFacet {

/**
* @notice storage struct for the AccessControl.
* @custom:storage-location erc8042:compose.accesscontrol
*/
struct AccessControlStorage {
mapping(address account => mapping(bytes32 role => bool hasRole)) hasRole;
Expand Down
3 changes: 2 additions & 1 deletion src/token/ERC20/Bridgeable/ERC20BridgeableMod.sol
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ function getERC20Storage() pure returns (ERC20Storage storage s) {
*/
bytes32 constant ACCESS_STORAGE_POSITION = keccak256("compose.accesscontrol");

/*
/**
* @notice storage struct for the AccessControl.
* @custom:storage-location erc8042:compose.accesscontrol
*/
struct AccessControlStorage {
mapping(address account => mapping(bytes32 role => bool hasRole)) hasRole;
Expand Down
2 changes: 1 addition & 1 deletion src/token/ERC20/Burn/ERC20BurnMod.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ event Transfer(address indexed _from, address indexed _to, uint256 _value);
*/
bytes32 constant STORAGE_POSITION = keccak256("erc20");

/*
/**
* @notice ERC-20 storage layout using the ERC-8042 standard.
* @custom:storage-location erc8042:erc20
*/
Expand Down
2 changes: 1 addition & 1 deletion src/token/ERC20/Data/ERC20DataFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ contract ERC20DataFacet {

/**
* @dev ERC-8042 compliant storage struct for ERC20 token data.
* @custom:storage-location erc8042:erc20.transfer
* @custom:storage-location erc8042:erc20
*/
struct ERC20Storage {
mapping(address owner => uint256 balance) balanceOf;
Expand Down
4 changes: 2 additions & 2 deletions src/token/ERC6909/ERC6909/ERC6909Facet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ contract ERC6909Facet {
/**
* @dev Storage position determined by the keccak256 hash of the diamond storage identifier.
*/
bytes32 constant STORAGE_POSITION = keccak256("compose.erc6909");
bytes32 constant STORAGE_POSITION = keccak256("erc6909");

/**
* @custom:storage-location erc8042:compose.erc6909
* @custom:storage-location erc8042:erc6909
*/
struct ERC6909Storage {
mapping(address owner => mapping(uint256 id => uint256 amount)) balanceOf;
Expand Down
4 changes: 2 additions & 2 deletions src/token/ERC6909/ERC6909/ERC6909Mod.sol
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ event Approval(address indexed _owner, address indexed _spender, uint256 indexed
/**
* @dev Storage position determined by the keccak256 hash of the diamond storage identifier.
*/
bytes32 constant STORAGE_POSITION = keccak256("compose.erc6909");
bytes32 constant STORAGE_POSITION = keccak256("erc6909");

/**
* @custom:storage-location erc8042:compose.erc6909
* @custom:storage-location erc8042:erc6909
*/
struct ERC6909Storage {
mapping(address owner => mapping(uint256 id => uint256 amount)) balanceOf;
Expand Down
2 changes: 1 addition & 1 deletion src/token/ERC721/Burn/ERC721BurnFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ contract ERC721BurnFacet {
bytes32 constant STORAGE_POSITION = keccak256("erc721");

/**
* @custom:storage-location erc8042:compose.erc721
* @custom:storage-location erc8042:erc721
*/
struct ERC721Storage {
mapping(uint256 tokenId => address owner) ownerOf;
Expand Down
4 changes: 2 additions & 2 deletions src/token/ERC721/Burn/ERC721BurnMod.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ event Transfer(address indexed _from, address indexed _to, uint256 indexed _toke
*/
bytes32 constant STORAGE_POSITION = keccak256("erc721");

/*
* @custom:storage-location erc8042:erc721
/**
* @notice Storage layout for ERC-721 token management.
* @dev Defines ownership, balances, approvals, and operator mappings per ERC-721 standard.
* @custom:storage-location erc8042:erc721
*/
struct ERC721Storage {
mapping(uint256 tokenId => address owner) ownerOf;
Expand Down
2 changes: 1 addition & 1 deletion src/token/ERC721/Metadata/ERC721MetadataFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ contract ERC721MetadataFacet {
bytes32 constant STORAGE_POSITION = keccak256("erc721.metadata");

/**
* @custom:storage-location erc8042:erc721
* @custom:storage-location erc8042:erc721.metadata
*/
struct ERC721MetadataStorage {
string name;
Expand Down
2 changes: 1 addition & 1 deletion src/token/ERC721/Metadata/ERC721MetadataMod.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ error ERC721InvalidOwner(address _owner);
bytes32 constant STORAGE_POSITION = keccak256("erc721.metadata");

/**
* @custom:storage-location erc8042:erc721
* @custom:storage-location erc8042:erc721.metadata
*/
struct ERC721MetadataStorage {
string name;
Expand Down
4 changes: 2 additions & 2 deletions src/token/ERC721/Transfer/ERC721TransferMod.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ event Transfer(address indexed _from, address indexed _to, uint256 indexed _toke
*/
bytes32 constant STORAGE_POSITION = keccak256("erc721");

/*
* @custom:storage-location erc8042:erc721
/**
* @notice Storage layout for ERC-721 token management.
* @dev Defines ownership, balances, approvals, and operator mappings per ERC-721 standard.
* @custom:storage-location erc8042:erc721
*/
struct ERC721Storage {
mapping(uint256 tokenId => address owner) ownerOf;
Expand Down
4 changes: 2 additions & 2 deletions src/token/Royalty/RoyaltyFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ contract RoyaltyFacet {
/**
* @notice Storage slot identifier for royalty storage.
*/
bytes32 constant STORAGE_POSITION = keccak256("compose.erc2981");
bytes32 constant STORAGE_POSITION = keccak256("erc2981");

/**
* @dev The denominator with which to interpret royalty fees as a percentage of sale price.
Expand All @@ -36,7 +36,7 @@ contract RoyaltyFacet {
}

/**
* @custom:storage-location erc8042:compose.erc2981
* @custom:storage-location erc8042:erc2981
*/
struct RoyaltyStorage {
RoyaltyInfo defaultRoyaltyInfo;
Expand Down
4 changes: 2 additions & 2 deletions src/token/Royalty/RoyaltyMod.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ error ERC2981InvalidTokenRoyalty(uint256 _tokenId, uint256 _numerator, uint256 _
*/
error ERC2981InvalidTokenRoyaltyReceiver(uint256 _tokenId, address _receiver);

bytes32 constant STORAGE_POSITION = keccak256("compose.erc2981");
bytes32 constant STORAGE_POSITION = keccak256("erc2981");

/**
* @dev The denominator with which to interpret royalty fees as a percentage of sale price.
Expand All @@ -62,7 +62,7 @@ struct RoyaltyInfo {
}

/**
* @custom:storage-location erc8042:compose.erc2981
* @custom:storage-location erc8042:erc2981
*/
struct RoyaltyStorage {
RoyaltyInfo defaultRoyaltyInfo;
Expand Down
7 changes: 7 additions & 0 deletions website/docs/contribution/code-style-guide.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ Follow the [Solidity feature ban](/docs/design/banned-solidity-features).
delete balances[_owner];
```

### Storage Position Conventions

Diamond storage slots (and the matching `@custom:storage-location erc8042:...` annotations on structs) follow:

- **ERC standards:** Use the `erc` prefix and the standard number or name (e.g. `erc20`, `erc721`, `erc1155`, `erc165`, `erc2981`, `erc6909`, `erc173.owner`, `erc8153.diamond`). Sub-features use a dot (e.g. `erc20.metadata`, `erc721.enumerable`).
- **Custom / Compose features:** Use the `compose.` prefix (e.g. `compose.accesscontrol`, `compose.accesscontrol.pausable`, `compose.accesscontrol.temporal`).

### Avoid Assembly
- Avoid using assembly if you can. If you can't and you access memory, do it [safely](https://docs.soliditylang.org/en/latest/assembly.html#memory-safety), and use `assembly ("memory-safe")`.
`"memory safe"` tells the Solidity compiler that memory is being used safely so it should not disable optimizations.
Expand Down
Loading