-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
The UniversalNFTCore
contract in @zetachain/standard-contracts
doesn't follow the ERC7201 namespaced storage pattern, which can lead to storage slot conflicts and upgrade compatibility issues in proxy-based upgradeable contracts.
Refactor the storage layout to use ERC7201 namespaced storage pattern:
abstract contract UniversalNFTCore is
ERC721Upgradeable,
ERC721URIStorageUpgradeable,
OwnableUpgradeable,
UniversalNFTEvents
{
/// @custom:storage-location erc7201:zetachain.storage.UniversalNFTCore
struct UniversalNFTCoreStorage {
/// @dev Address of the EVM gateway contract
GatewayEVM gateway;
/// @dev The address of the Universal NFT contract on ZetaChain
address universal;
/// @dev The amount of gas used when making cross-chain transfers
uint256 gasLimitAmount;
}
// keccak256(abi.encode(uint256(keccak256("zetachain.storage.UniversalNFTCore")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant UniversalNFTCoreStorageLocation = 0x...;
function _getUniversalNFTCoreStorage() private pure returns (UniversalNFTCoreStorage storage $) {
assembly {
$.slot := UniversalNFTCoreStorageLocation
}
}
// Update all getter functions to use the storage struct
function gateway() public view returns (GatewayEVM) {
UniversalNFTCoreStorage storage $ = _getUniversalNFTCoreStorage();
return $.gateway;
}
function universal() public view returns (address) {
UniversalNFTCoreStorage storage $ = _getUniversalNFTCoreStorage();
return $.universal;
}
function gasLimitAmount() public view returns (uint256) {
UniversalNFTCoreStorage storage $ = _getUniversalNFTCoreStorage();
return $.gasLimitAmount;
}
// Update all setter functions accordingly...
}
Metadata
Metadata
Assignees
Labels
No labels