From e4c548df4757fd2c879b30f9bb841e6a77773ba7 Mon Sep 17 00:00:00 2001 From: iteye Date: Wed, 28 Aug 2024 12:12:45 +0800 Subject: [PATCH 1/3] support optimism blob --- contracts/BlobStorageManager.sol | 7 ++++--- contracts/ERC5018.sol | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/contracts/BlobStorageManager.sol b/contracts/BlobStorageManager.sol index 657da22..cd2db25 100644 --- a/contracts/BlobStorageManager.sol +++ b/contracts/BlobStorageManager.sol @@ -5,7 +5,8 @@ import "@openzeppelin/contracts/access/Ownable.sol"; enum DecodeType { RawData, - PaddingPer31Bytes + PaddingPer31Bytes, + OptimismCompact } interface IEthStorageContract { @@ -84,7 +85,7 @@ contract BlobStorageManager is Ownable { return (new bytes(0), false); } - bytes memory data = storageContract.get(keyToChunks[key][chunkId], DecodeType.PaddingPer31Bytes, 0, length); + bytes memory data = storageContract.get(keyToChunks[key][chunkId], DecodeType.OptimismCompact, 0, length); return (data, true); } @@ -99,7 +100,7 @@ contract BlobStorageManager is Ownable { for (uint256 chunkId = 0; chunkId < chunkNum; chunkId++) { bytes32 chunkKey = keyToChunks[key][chunkId]; uint256 length = storageContract.size(chunkKey); - storageContract.get(chunkKey, DecodeType.PaddingPer31Bytes, 0, length); + storageContract.get(chunkKey, DecodeType.OptimismCompact, 0, length); assembly { returndatacopy(add(add(concatenatedData, offset), 0x20), 0x40, length) diff --git a/contracts/ERC5018.sol b/contracts/ERC5018.sol index 4b2b90e..d6ec6f8 100644 --- a/contracts/ERC5018.sol +++ b/contracts/ERC5018.sol @@ -7,6 +7,8 @@ import "./BlobStorageManager.sol"; contract ERC5018 is IERC5018, LargeStorageManager, BlobStorageManager { + string public constant version = "1.0.0"; + enum StorageMode { Uninitialized, OnChain, From e091dc256d16a2d3e22f7accefe6a47ec6190386 Mon Sep 17 00:00:00 2001 From: iteye Date: Wed, 28 Aug 2024 18:04:22 +0800 Subject: [PATCH 2/3] change version --- contracts/ERC5018.sol | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/contracts/ERC5018.sol b/contracts/ERC5018.sol index d6ec6f8..859080b 100644 --- a/contracts/ERC5018.sol +++ b/contracts/ERC5018.sol @@ -7,8 +7,6 @@ import "./BlobStorageManager.sol"; contract ERC5018 is IERC5018, LargeStorageManager, BlobStorageManager { - string public constant version = "1.0.0"; - enum StorageMode { Uninitialized, OnChain, @@ -22,6 +20,12 @@ contract ERC5018 is IERC5018, LargeStorageManager, BlobStorageManager { address storageAddress ) LargeStorageManager(slotLimit) BlobStorageManager(maxChunkSize, storageAddress) {} + /// @notice Semantic version. + /// @custom:semver 1.0.0 + function version() public pure virtual returns (string memory) { + return "1.0.0"; + } + function getStorageMode(bytes memory name) public view returns (StorageMode) { return storageModes[keccak256(name)]; } From c7281556518cce9a6067daa7346bcebbe2b4c9fe Mon Sep 17 00:00:00 2001 From: iteye Date: Wed, 28 Aug 2024 19:09:51 +0800 Subject: [PATCH 3/3] add ISemver.sol --- contracts/ERC5018.sol | 3 ++- contracts/ISemver.sol | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 contracts/ISemver.sol diff --git a/contracts/ERC5018.sol b/contracts/ERC5018.sol index 859080b..881d4f6 100644 --- a/contracts/ERC5018.sol +++ b/contracts/ERC5018.sol @@ -4,8 +4,9 @@ pragma solidity ^0.8.0; import "./IERC5018.sol"; import "./LargeStorageManager.sol"; import "./BlobStorageManager.sol"; +import "./ISemver.sol"; -contract ERC5018 is IERC5018, LargeStorageManager, BlobStorageManager { +contract ERC5018 is LargeStorageManager, BlobStorageManager, IERC5018, ISemver { enum StorageMode { Uninitialized, diff --git a/contracts/ISemver.sol b/contracts/ISemver.sol new file mode 100644 index 0000000..22a5dde --- /dev/null +++ b/contracts/ISemver.sol @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +/// @title ISemver +/// @notice ISemver is a simple contract for ensuring that contracts are +/// versioned using semantic versioning. +interface ISemver { + /// @notice Getter for the semantic version of the contract. This is not + /// meant to be used onchain but instead meant to be used by offchain + /// tooling. + /// @return Semver contract version as a string. + function version() external view returns (string memory); +}