Skip to content

Commit

Permalink
Merge pull request #10 from ethstorage/opblob
Browse files Browse the repository at this point in the history
support optimism blob
  • Loading branch information
iteyelmp authored Aug 30, 2024
2 parents ebeb30b + c728155 commit 7f446f3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
7 changes: 4 additions & 3 deletions contracts/BlobStorageManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import "@openzeppelin/contracts/access/Ownable.sol";

enum DecodeType {
RawData,
PaddingPer31Bytes
PaddingPer31Bytes,
OptimismCompact
}

interface IEthStorageContract {
Expand Down Expand Up @@ -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);
}

Expand All @@ -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)
Expand Down
9 changes: 8 additions & 1 deletion contracts/ERC5018.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -20,6 +21,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)];
}
Expand Down
13 changes: 13 additions & 0 deletions contracts/ISemver.sol
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 7f446f3

Please sign in to comment.