From 1655bca8902123e53ba645736c47583bf08cf765 Mon Sep 17 00:00:00 2001 From: "iteyelmp@gmail.com" Date: Fri, 13 Oct 2023 15:34:36 +0800 Subject: [PATCH 1/7] support new blob size --- contracts/ERC5018ForBlob.sol | 17 +++++--- contracts/examples/FlatDirectoryForBlob.sol | 47 +++++++++++++++++++++ 2 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 contracts/examples/FlatDirectoryForBlob.sol diff --git a/contracts/ERC5018ForBlob.sol b/contracts/ERC5018ForBlob.sol index 379f790..86dcc31 100644 --- a/contracts/ERC5018ForBlob.sol +++ b/contracts/ERC5018ForBlob.sol @@ -11,8 +11,6 @@ interface EthStorageContract { function remove(bytes32 key) external; - function size(bytes32 key) external view returns (uint256); - function hash(bytes32 key) external view returns (bytes24); function upfrontPayment() external view returns (uint256); @@ -20,9 +18,13 @@ interface EthStorageContract { contract ERC5018ForBlob is IERC5018ForBlob, Ownable { + uint32 BLOB_SIZE = 4096 * 32; + uint32 DECODE_BLOB_SIZE = 4096 * 31; + EthStorageContract public storageContract; mapping(bytes32 => bytes32[]) internal keyToChunk; + mapping(bytes32 => uint256) internal chunkSizes; function setEthStorageContract(address storageAddress) public onlyOwner { storageContract = EthStorageContract(storageAddress); @@ -36,8 +38,8 @@ contract ERC5018ForBlob is IERC5018ForBlob, Ownable { if (chunkId >= _countChunks(key)) { return (0, false); } - uint256 size_ = storageContract.size(keyToChunk[key][chunkId]); - return (size_, true); + bytes32 chunkKey = keyToChunk[key][chunkId]; + return (chunkSizes[chunkKey], true); } function _size(bytes32 key) internal view returns (uint256, uint256) { @@ -71,7 +73,7 @@ contract ERC5018ForBlob is IERC5018ForBlob, Ownable { return (new bytes(0), false); } - bytes memory data = new bytes(0); + bytes memory data; for (uint256 chunkId = 0; chunkId < chunkNum; chunkId++) { (bytes memory temp, bool state) = _getChunk(key, chunkId); if (!state) { @@ -123,11 +125,11 @@ contract ERC5018ForBlob is IERC5018ForBlob, Ownable { require(msg.value >= cost * length, "insufficient balance"); for (uint8 i = 0; i < length; i++) { - require(sizes[i] <= 4096 * 31, "invalid blob length"); + require(sizes[i] <= DECODE_BLOB_SIZE, "invalid chunk length"); _preparePut(key, chunkIds[i]); bytes32 chunkKey = keccak256(abi.encode(msg.sender, block.timestamp, chunkIds[i], i)); - storageContract.putBlob{value : cost}(chunkKey, i, sizes[i]); + storageContract.putBlob{value : cost}(chunkKey, i, BLOB_SIZE); if (chunkIds[i] < _countChunks(key)) { // replace keyToChunk[key][chunkIds[i]] = chunkKey; @@ -135,6 +137,7 @@ contract ERC5018ForBlob is IERC5018ForBlob, Ownable { // add keyToChunk[key].push(chunkKey); } + chunkSizes[chunkKey] = sizes[i]; } } diff --git a/contracts/examples/FlatDirectoryForBlob.sol b/contracts/examples/FlatDirectoryForBlob.sol new file mode 100644 index 0000000..46c162d --- /dev/null +++ b/contracts/examples/FlatDirectoryForBlob.sol @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.0; + +import "../ERC5018ForBlob.sol"; + +contract FlatDirectoryFroBlob is ERC5018ForBlob { + bytes public defaultFile = ""; + + function resolveMode() external pure virtual returns (bytes32) { + return "manual"; + } + + fallback(bytes calldata pathinfo) external returns (bytes memory) { + bytes memory content; + if (pathinfo.length == 0) { + // TODO: redirect to "/"? + return bytes(""); + } else if (pathinfo[0] != 0x2f) { + // Should not happen since manual mode will have prefix "/" like "/....." + return bytes("incorrect path"); + } + + if (pathinfo[pathinfo.length - 1] == 0x2f) { + (content, ) = read(bytes.concat(pathinfo[1:], defaultFile)); + } else { + (content, ) = read(pathinfo[1:]); + } + + returnBytesInplace(content); + } + + function returnBytesInplace(bytes memory content) internal pure { + // equal to return abi.encode(content) + uint256 size = content.length + 0x40; // pointer + size + size = (size + 0x20 + 0x1f) & ~uint256(0x1f); + assembly { + // (DATA CORRUPTION): the caller method must be "external returns (bytes)", cannot be public! + mstore(sub(content, 0x20), 0x20) + return(sub(content, 0x20), size) + } + } + + function setDefault(bytes memory _defaultFile) public onlyOwner virtual { + defaultFile = _defaultFile; + } +} From 26b9df564f86f91f35423cfe108e1858dc73120f Mon Sep 17 00:00:00 2001 From: "iteyelmp@gmail.com" Date: Mon, 16 Oct 2023 10:29:57 +0800 Subject: [PATCH 2/7] Optimize string concatenation --- contracts/ERC5018ForBlob.sol | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/contracts/ERC5018ForBlob.sol b/contracts/ERC5018ForBlob.sol index 86dcc31..bca2e75 100644 --- a/contracts/ERC5018ForBlob.sol +++ b/contracts/ERC5018ForBlob.sol @@ -68,21 +68,25 @@ contract ERC5018ForBlob is IERC5018ForBlob, Ownable { } function _get(bytes32 key) internal view returns (bytes memory, bool) { - (, uint256 chunkNum) = _size(key); + (uint256 fileSize, uint256 chunkNum) = _size(key); if (chunkNum == 0) { return (new bytes(0), false); } - bytes memory data; + bytes memory concatenatedData = new bytes(fileSize); + uint256 offset = 0; for (uint256 chunkId = 0; chunkId < chunkNum; chunkId++) { - (bytes memory temp, bool state) = _getChunk(key, chunkId); - if (!state) { - break; + bytes32 chunkKey = keyToChunk[key][chunkId]; + uint256 length = chunkSizes[chunkKey]; + bytes memory chunk = storageContract.get(chunkKey, 0, length); + + assembly { + returndatacopy(add(add(concatenatedData, offset), 0x20), 0x40, length) } - data = bytes.concat(data, temp); + offset += length; } - return (data, true); + return (concatenatedData, true); } function _removeChunk(bytes32 key, uint256 chunkId) internal returns (bool) { From 9b78907fddd827d4d26cc8c3e997d90136188604 Mon Sep 17 00:00:00 2001 From: "iteyelmp@gmail.com" Date: Mon, 16 Oct 2023 16:15:26 +0800 Subject: [PATCH 3/7] Optimize string concatenation --- contracts/ERC5018ForBlob.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/ERC5018ForBlob.sol b/contracts/ERC5018ForBlob.sol index bca2e75..6d00484 100644 --- a/contracts/ERC5018ForBlob.sol +++ b/contracts/ERC5018ForBlob.sol @@ -78,7 +78,7 @@ contract ERC5018ForBlob is IERC5018ForBlob, Ownable { for (uint256 chunkId = 0; chunkId < chunkNum; chunkId++) { bytes32 chunkKey = keyToChunk[key][chunkId]; uint256 length = chunkSizes[chunkKey]; - bytes memory chunk = storageContract.get(chunkKey, 0, length); + storageContract.get(chunkKey, 0, length); assembly { returndatacopy(add(add(concatenatedData, offset), 0x20), 0x40, length) From 81feab321ebe3277ced3271ccf2f715285117e07 Mon Sep 17 00:00:00 2001 From: "iteyelmp@gmail.com" Date: Tue, 17 Oct 2023 15:45:42 +0800 Subject: [PATCH 4/7] decode mode changed to dynamic --- contracts/ERC5018ForBlob.sol | 18 +++++++++--------- contracts/IERC5018ForBlob.sol | 4 ++-- contracts/examples/FlatDirectoryForBlob.sol | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/contracts/ERC5018ForBlob.sol b/contracts/ERC5018ForBlob.sol index 6d00484..529aff1 100644 --- a/contracts/ERC5018ForBlob.sol +++ b/contracts/ERC5018ForBlob.sol @@ -7,7 +7,7 @@ import "./IERC5018ForBlob.sol"; interface EthStorageContract { function putBlob(bytes32 key, uint256 blobIdx, uint256 length) external payable; - function get(bytes32 key, uint256 off, uint256 len) external view returns (bytes memory); + function get(bytes32 key, bool needDecode, uint256 off, uint256 len) external view returns (bytes memory); function remove(bytes32 key) external; @@ -57,17 +57,17 @@ contract ERC5018ForBlob is IERC5018ForBlob, Ownable { return (size_, chunkId_); } - function _getChunk(bytes32 key, uint256 chunkId) internal view returns (bytes memory, bool) { + function _getChunk(bytes32 key, bool needDecode, uint256 chunkId) internal view returns (bytes memory, bool) { (uint256 length,) = _chunkSize(key, chunkId); if (length < 1) { return (new bytes(0), false); } - bytes memory data = storageContract.get(keyToChunk[key][chunkId], 0, length); + bytes memory data = storageContract.get(keyToChunk[key][chunkId], needDecode, 0, length); return (data, true); } - function _get(bytes32 key) internal view returns (bytes memory, bool) { + function _get(bytes32 key, bool needDecode) internal view returns (bytes memory, bool) { (uint256 fileSize, uint256 chunkNum) = _size(key); if (chunkNum == 0) { return (new bytes(0), false); @@ -78,7 +78,7 @@ contract ERC5018ForBlob is IERC5018ForBlob, Ownable { for (uint256 chunkId = 0; chunkId < chunkNum; chunkId++) { bytes32 chunkKey = keyToChunk[key][chunkId]; uint256 length = chunkSizes[chunkKey]; - storageContract.get(chunkKey, 0, length); + storageContract.get(chunkKey, needDecode, 0, length); assembly { returndatacopy(add(add(concatenatedData, offset), 0x20), 0x40, length) @@ -148,8 +148,8 @@ contract ERC5018ForBlob is IERC5018ForBlob, Ownable { // interface methods - function read(bytes memory name) public view override returns (bytes memory, bool) { - return _get(keccak256(name)); + function read(bytes memory name, bool needDecode) public view override returns (bytes memory, bool) { + return _get(keccak256(name), needDecode); } function size(bytes memory name) public view override returns (uint256, uint256) { @@ -164,8 +164,8 @@ contract ERC5018ForBlob is IERC5018ForBlob, Ownable { return _countChunks(keccak256(name)); } - function readChunk(bytes memory name, uint256 chunkId) public view override returns (bytes memory, bool) { - return _getChunk(keccak256(name), chunkId); + function readChunk(bytes memory name, bool needDecode, uint256 chunkId) public view override returns (bytes memory, bool) { + return _getChunk(keccak256(name), needDecode, chunkId); } function chunkSize(bytes memory name, uint256 chunkId) public view override returns (uint256, bool) { diff --git a/contracts/IERC5018ForBlob.sol b/contracts/IERC5018ForBlob.sol index 58cbf28..998ccc2 100644 --- a/contracts/IERC5018ForBlob.sol +++ b/contracts/IERC5018ForBlob.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.0; interface IERC5018ForBlob { - function read(bytes memory name) external view returns (bytes memory, bool); + function read(bytes memory name, bool needDecode) external view returns (bytes memory, bool); // return (size, # of chunks) function size(bytes memory name) external view returns (uint256, uint256); @@ -12,7 +12,7 @@ interface IERC5018ForBlob { function countChunks(bytes memory name) external view returns (uint256); - function readChunk(bytes memory name, uint256 chunkId) external view returns (bytes memory, bool); + function readChunk(bytes memory name, bool needDecode, uint256 chunkId) external view returns (bytes memory, bool); function chunkSize(bytes memory name, uint256 chunkId) external view returns (uint256, bool); diff --git a/contracts/examples/FlatDirectoryForBlob.sol b/contracts/examples/FlatDirectoryForBlob.sol index 46c162d..7099cc5 100644 --- a/contracts/examples/FlatDirectoryForBlob.sol +++ b/contracts/examples/FlatDirectoryForBlob.sol @@ -22,9 +22,9 @@ contract FlatDirectoryFroBlob is ERC5018ForBlob { } if (pathinfo[pathinfo.length - 1] == 0x2f) { - (content, ) = read(bytes.concat(pathinfo[1:], defaultFile)); + (content,) = read(bytes.concat(pathinfo[1 :], defaultFile), true); } else { - (content, ) = read(pathinfo[1:]); + (content,) = read(pathinfo[1 :], true); } returnBytesInplace(content); @@ -37,7 +37,7 @@ contract FlatDirectoryFroBlob is ERC5018ForBlob { assembly { // (DATA CORRUPTION): the caller method must be "external returns (bytes)", cannot be public! mstore(sub(content, 0x20), 0x20) - return(sub(content, 0x20), size) + return (sub(content, 0x20), size) } } From 9edc4409cb4007ef25425a20aaef589f4121b0cf Mon Sep 17 00:00:00 2001 From: "iteyelmp@gmail.com" Date: Mon, 23 Oct 2023 18:28:04 +0800 Subject: [PATCH 5/7] change decode type --- contracts/ERC5018ForBlob.sol | 18 +++++++++--------- contracts/IERC5018ForBlob.sol | 9 +++++++-- contracts/examples/FlatDirectoryForBlob.sol | 4 ++-- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/contracts/ERC5018ForBlob.sol b/contracts/ERC5018ForBlob.sol index 529aff1..810618c 100644 --- a/contracts/ERC5018ForBlob.sol +++ b/contracts/ERC5018ForBlob.sol @@ -7,7 +7,7 @@ import "./IERC5018ForBlob.sol"; interface EthStorageContract { function putBlob(bytes32 key, uint256 blobIdx, uint256 length) external payable; - function get(bytes32 key, bool needDecode, uint256 off, uint256 len) external view returns (bytes memory); + function get(bytes32 key, DecodeType decodeType, uint256 off, uint256 len) external view returns (bytes memory); function remove(bytes32 key) external; @@ -57,17 +57,17 @@ contract ERC5018ForBlob is IERC5018ForBlob, Ownable { return (size_, chunkId_); } - function _getChunk(bytes32 key, bool needDecode, uint256 chunkId) internal view returns (bytes memory, bool) { + function _getChunk(bytes32 key, DecodeType decodeType, uint256 chunkId) internal view returns (bytes memory, bool) { (uint256 length,) = _chunkSize(key, chunkId); if (length < 1) { return (new bytes(0), false); } - bytes memory data = storageContract.get(keyToChunk[key][chunkId], needDecode, 0, length); + bytes memory data = storageContract.get(keyToChunk[key][chunkId], decodeType, 0, length); return (data, true); } - function _get(bytes32 key, bool needDecode) internal view returns (bytes memory, bool) { + function _get(bytes32 key, DecodeType decodeType) internal view returns (bytes memory, bool) { (uint256 fileSize, uint256 chunkNum) = _size(key); if (chunkNum == 0) { return (new bytes(0), false); @@ -78,7 +78,7 @@ contract ERC5018ForBlob is IERC5018ForBlob, Ownable { for (uint256 chunkId = 0; chunkId < chunkNum; chunkId++) { bytes32 chunkKey = keyToChunk[key][chunkId]; uint256 length = chunkSizes[chunkKey]; - storageContract.get(chunkKey, needDecode, 0, length); + storageContract.get(chunkKey, decodeType, 0, length); assembly { returndatacopy(add(add(concatenatedData, offset), 0x20), 0x40, length) @@ -148,8 +148,8 @@ contract ERC5018ForBlob is IERC5018ForBlob, Ownable { // interface methods - function read(bytes memory name, bool needDecode) public view override returns (bytes memory, bool) { - return _get(keccak256(name), needDecode); + function read(bytes memory name, DecodeType decodeType) public view override returns (bytes memory, bool) { + return _get(keccak256(name), decodeType); } function size(bytes memory name) public view override returns (uint256, uint256) { @@ -164,8 +164,8 @@ contract ERC5018ForBlob is IERC5018ForBlob, Ownable { return _countChunks(keccak256(name)); } - function readChunk(bytes memory name, bool needDecode, uint256 chunkId) public view override returns (bytes memory, bool) { - return _getChunk(keccak256(name), needDecode, chunkId); + function readChunk(bytes memory name, DecodeType decodeType, uint256 chunkId) public view override returns (bytes memory, bool) { + return _getChunk(keccak256(name), decodeType, chunkId); } function chunkSize(bytes memory name, uint256 chunkId) public view override returns (uint256, bool) { diff --git a/contracts/IERC5018ForBlob.sol b/contracts/IERC5018ForBlob.sol index 998ccc2..65d2582 100644 --- a/contracts/IERC5018ForBlob.sol +++ b/contracts/IERC5018ForBlob.sol @@ -1,9 +1,14 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; +enum DecodeType { + RawData, + PaddingPer31Bytes +} + interface IERC5018ForBlob { - function read(bytes memory name, bool needDecode) external view returns (bytes memory, bool); + function read(bytes memory name, DecodeType decodeType) external view returns (bytes memory, bool); // return (size, # of chunks) function size(bytes memory name) external view returns (uint256, uint256); @@ -12,7 +17,7 @@ interface IERC5018ForBlob { function countChunks(bytes memory name) external view returns (uint256); - function readChunk(bytes memory name, bool needDecode, uint256 chunkId) external view returns (bytes memory, bool); + function readChunk(bytes memory name, DecodeType decodeType, uint256 chunkId) external view returns (bytes memory, bool); function chunkSize(bytes memory name, uint256 chunkId) external view returns (uint256, bool); diff --git a/contracts/examples/FlatDirectoryForBlob.sol b/contracts/examples/FlatDirectoryForBlob.sol index 7099cc5..5d27c88 100644 --- a/contracts/examples/FlatDirectoryForBlob.sol +++ b/contracts/examples/FlatDirectoryForBlob.sol @@ -22,9 +22,9 @@ contract FlatDirectoryFroBlob is ERC5018ForBlob { } if (pathinfo[pathinfo.length - 1] == 0x2f) { - (content,) = read(bytes.concat(pathinfo[1 :], defaultFile), true); + (content,) = read(bytes.concat(pathinfo[1 :], defaultFile), DecodeType.PaddingPer31Bytes); } else { - (content,) = read(pathinfo[1 :], true); + (content,) = read(pathinfo[1 :], DecodeType.PaddingPer31Bytes); } returnBytesInplace(content); From 75980ed97fb2f8f5a89bbba879643ade2d047e9e Mon Sep 17 00:00:00 2001 From: "iteyelmp@gmail.com" Date: Wed, 22 Nov 2023 12:25:00 +0800 Subject: [PATCH 6/7] fix name error --- contracts/examples/FlatDirectoryForBlob.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/examples/FlatDirectoryForBlob.sol b/contracts/examples/FlatDirectoryForBlob.sol index 5d27c88..b463489 100644 --- a/contracts/examples/FlatDirectoryForBlob.sol +++ b/contracts/examples/FlatDirectoryForBlob.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.0; import "../ERC5018ForBlob.sol"; -contract FlatDirectoryFroBlob is ERC5018ForBlob { +contract FlatDirectoryForBlob is ERC5018ForBlob { bytes public defaultFile = ""; function resolveMode() external pure virtual returns (bytes32) { From 740f813fc8aea3c24644f22e2ae89e84085df1eb Mon Sep 17 00:00:00 2001 From: "iteyelmp@gmail.com" Date: Wed, 13 Dec 2023 12:15:06 +0800 Subject: [PATCH 7/7] change interface --- contracts/ERC5018ForBlob.sol | 23 +++++++++++++-------- contracts/IERC5018ForBlob.sol | 11 ++-------- contracts/examples/FlatDirectoryForBlob.sol | 4 ++-- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/contracts/ERC5018ForBlob.sol b/contracts/ERC5018ForBlob.sol index 810618c..7bcb49c 100644 --- a/contracts/ERC5018ForBlob.sol +++ b/contracts/ERC5018ForBlob.sol @@ -4,6 +4,11 @@ pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "./IERC5018ForBlob.sol"; +enum DecodeType { + RawData, + PaddingPer31Bytes +} + interface EthStorageContract { function putBlob(bytes32 key, uint256 blobIdx, uint256 length) external payable; @@ -57,17 +62,17 @@ contract ERC5018ForBlob is IERC5018ForBlob, Ownable { return (size_, chunkId_); } - function _getChunk(bytes32 key, DecodeType decodeType, uint256 chunkId) internal view returns (bytes memory, bool) { + function _getChunk(bytes32 key, uint256 chunkId) internal view returns (bytes memory, bool) { (uint256 length,) = _chunkSize(key, chunkId); if (length < 1) { return (new bytes(0), false); } - bytes memory data = storageContract.get(keyToChunk[key][chunkId], decodeType, 0, length); + bytes memory data = storageContract.get(keyToChunk[key][chunkId], DecodeType.PaddingPer31Bytes, 0, length); return (data, true); } - function _get(bytes32 key, DecodeType decodeType) internal view returns (bytes memory, bool) { + function _get(bytes32 key) internal view returns (bytes memory, bool) { (uint256 fileSize, uint256 chunkNum) = _size(key); if (chunkNum == 0) { return (new bytes(0), false); @@ -78,7 +83,7 @@ contract ERC5018ForBlob is IERC5018ForBlob, Ownable { for (uint256 chunkId = 0; chunkId < chunkNum; chunkId++) { bytes32 chunkKey = keyToChunk[key][chunkId]; uint256 length = chunkSizes[chunkKey]; - storageContract.get(chunkKey, decodeType, 0, length); + storageContract.get(chunkKey, DecodeType.PaddingPer31Bytes, 0, length); assembly { returndatacopy(add(add(concatenatedData, offset), 0x20), 0x40, length) @@ -148,8 +153,8 @@ contract ERC5018ForBlob is IERC5018ForBlob, Ownable { // interface methods - function read(bytes memory name, DecodeType decodeType) public view override returns (bytes memory, bool) { - return _get(keccak256(name), decodeType); + function read(bytes memory name) public view override returns (bytes memory, bool) { + return _get(keccak256(name)); } function size(bytes memory name) public view override returns (uint256, uint256) { @@ -164,8 +169,8 @@ contract ERC5018ForBlob is IERC5018ForBlob, Ownable { return _countChunks(keccak256(name)); } - function readChunk(bytes memory name, DecodeType decodeType, uint256 chunkId) public view override returns (bytes memory, bool) { - return _getChunk(keccak256(name), decodeType, chunkId); + function readChunk(bytes memory name, uint256 chunkId) public view override returns (bytes memory, bool) { + return _getChunk(keccak256(name), chunkId); } function chunkSize(bytes memory name, uint256 chunkId) public view override returns (uint256, bool) { @@ -202,7 +207,7 @@ contract ERC5018ForBlob is IERC5018ForBlob, Ownable { refund(); } - function upfrontPayment() external override view returns (uint256) { + function upfrontPayment() external view returns (uint256) { return storageContract.upfrontPayment(); } } diff --git a/contracts/IERC5018ForBlob.sol b/contracts/IERC5018ForBlob.sol index 65d2582..d63f7ae 100644 --- a/contracts/IERC5018ForBlob.sol +++ b/contracts/IERC5018ForBlob.sol @@ -1,14 +1,9 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -enum DecodeType { - RawData, - PaddingPer31Bytes -} - interface IERC5018ForBlob { - function read(bytes memory name, DecodeType decodeType) external view returns (bytes memory, bool); + function read(bytes memory name) external view returns (bytes memory, bool); // return (size, # of chunks) function size(bytes memory name) external view returns (uint256, uint256); @@ -17,7 +12,7 @@ interface IERC5018ForBlob { function countChunks(bytes memory name) external view returns (uint256); - function readChunk(bytes memory name, DecodeType decodeType, uint256 chunkId) external view returns (bytes memory, bool); + function readChunk(bytes memory name, uint256 chunkId) external view returns (bytes memory, bool); function chunkSize(bytes memory name, uint256 chunkId) external view returns (uint256, bool); @@ -32,6 +27,4 @@ interface IERC5018ForBlob { function getChunkHash(bytes memory name, uint256 chunkId) external view returns (bytes32); function writeChunk(bytes memory name, uint256[] memory chunkIds, uint256[] memory sizes) external payable; - - function upfrontPayment() external view returns (uint256); } diff --git a/contracts/examples/FlatDirectoryForBlob.sol b/contracts/examples/FlatDirectoryForBlob.sol index b463489..97447dc 100644 --- a/contracts/examples/FlatDirectoryForBlob.sol +++ b/contracts/examples/FlatDirectoryForBlob.sol @@ -22,9 +22,9 @@ contract FlatDirectoryForBlob is ERC5018ForBlob { } if (pathinfo[pathinfo.length - 1] == 0x2f) { - (content,) = read(bytes.concat(pathinfo[1 :], defaultFile), DecodeType.PaddingPer31Bytes); + (content,) = read(bytes.concat(pathinfo[1 :], defaultFile)); } else { - (content,) = read(pathinfo[1 :], DecodeType.PaddingPer31Bytes); + (content,) = read(pathinfo[1 :]); } returnBytesInplace(content);