diff --git a/contracts/identitytreestore/IdentityTreeStore.sol b/contracts/identitytreestore/IdentityTreeStore.sol index 34bd4dd5..65002641 100644 --- a/contracts/identitytreestore/IdentityTreeStore.sol +++ b/contracts/identitytreestore/IdentityTreeStore.sol @@ -32,22 +32,15 @@ contract IdentityTreeStore is using ReverseHashLib for ReverseHashLib.Data; /// @custom:storage-location erc7201:iden3.storage.IdentityTreeStore.ReverseHashLibData - struct ReverseHashLibDataStorage { - ReverseHashLib.Data _data; - } // keccak256(abi.encode(uint256(keccak256("iden3.storage.IdentityTreeStore.ReverseHashLibData")) - 1)) & // ~bytes32(uint256(0xff)); - bytes32 private constant ReverseHashLibDataStorageLocation = + bytes32 private constant REVERSE_HASH_LIB_DATA_STORAGE_LOCATION = 0x0f7e3bdc6cc0e880d509aa1f6b8d1a88e5fcb7274e18dfba772424a36fe9b400; - function _getReverseHashLibDataStorage() - private - pure - returns (ReverseHashLibDataStorage storage $) - { + function _getReverseHashLibDataStorage() private pure returns (ReverseHashLib.Data storage $) { assembly { - $.slot := ReverseHashLibDataStorageLocation + $.slot := REVERSE_HASH_LIB_DATA_STORAGE_LOCATION } } @@ -57,18 +50,18 @@ contract IdentityTreeStore is } // keccak256(abi.encode(uint256(keccak256("iden3.storage.IdentityTreeStore.Main")) - 1)) & ~bytes32(uint256(0xff)); - bytes32 private constant MainStorageLocation = + bytes32 private constant MAIN_STORAGE_LOCATION = 0x95ca427007e091a13a7ccfcb233b8a2ed19d987330a248c445b1b483a35bb800; function _getMainStorage() private pure returns (MainStorage storage $) { assembly { - $.slot := MainStorageLocation + $.slot := MAIN_STORAGE_LOCATION } } function initialize(address state) public initializer { _getMainStorage()._state = IState(state); - _getReverseHashLibDataStorage()._data.hashFunction = _hashFunc; + _getReverseHashLibDataStorage().hashFunction = _hashFunc; } /** @@ -76,7 +69,7 @@ contract IdentityTreeStore is * @param nodes An array of nodes */ function saveNodes(uint256[][] memory nodes) external { - return _getReverseHashLibDataStorage()._data.savePreimages(nodes); + return _getReverseHashLibDataStorage().savePreimages(nodes); } /** @@ -85,7 +78,7 @@ contract IdentityTreeStore is * @return The node */ function getNode(uint256 key) public view returns (uint256[] memory) { - uint256[] memory preim = _getReverseHashLibDataStorage()._data.getPreimage(key); + uint256[] memory preim = _getReverseHashLibDataStorage().getPreimage(key); require(preim.length > 0, "Node not found"); return preim; } @@ -160,10 +153,10 @@ contract IdentityTreeStore is uint256 nextNodeHash = root; uint256[] memory children; - ReverseHashLibDataStorage storage $ = _getReverseHashLibDataStorage(); + ReverseHashLib.Data storage $ = _getReverseHashLibDataStorage(); for (uint256 i = 0; i <= MAX_SMT_DEPTH; i++) { - children = $._data.hashesToPreimages[nextNodeHash]; + children = $.hashesToPreimages[nextNodeHash]; NodeType nodeType = _nodeType(children); if (nodeType == NodeType.Empty) {