diff --git a/package.json b/package.json index b239e41..cd28c71 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,6 @@ "package.json": "sort-package-json" }, "dependencies": { - "@0xsequence/sstore2": "https://github.com/0xsequence/sstore2", "@defi-wonderland/solidity-utils": "0.0.0-3e9c8e8b", "@openzeppelin/contracts": "^4.9.3", "ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0", diff --git a/solidity/contracts/Oracle.sol b/solidity/contracts/Oracle.sol index e6795c6..f2f02cc 100644 --- a/solidity/contracts/Oracle.sol +++ b/solidity/contracts/Oracle.sol @@ -1,16 +1,14 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.19; -import {SSTORE2} from '@0xsequence/sstore2/contracts/SSTORE2.sol'; import {IOracle} from '../interfaces/IOracle.sol'; import {EnumerableSet} from '@openzeppelin/contracts/utils/structs/EnumerableSet.sol'; contract Oracle is IOracle { using EnumerableSet for EnumerableSet.Bytes32Set; - // mapping(bytes32 _requestId => bytes32 _requestHash) internal _requestHashes; - mapping(bytes32 _requestId => address _pointer) internal _sstore2Pointers; - mapping(bytes32 _requestId => address _pointer) internal _sstoreDataPointers; + mapping(bytes32 _requestId => bytes32 _requestHash) internal _requestHashes; + mapping(bytes32 _requestId => HashedRequest _hashedRequest) internal _hashedRequests; /// @inheritdoc IOracle mapping(bytes32 _responseId => bytes32 _disputeId) public disputeOf; @@ -451,59 +449,37 @@ contract Oracle is IOracle { */ function _createRequest(NewRequest calldata _request) internal returns (bytes32 _requestId) { uint256 _requestNonce = totalRequestCount++; - // bytes32 _requestHash = keccak256( - // abi.encodePacked( - // _requestNonce, - // _request.requestModule, - // _request.responseModule, - // _request.disputeModule, - // _request.resolutionModule, - // _request.finalityModule - // ) - // ); - - _requestId = keccak256(abi.encodePacked(msg.sender, address(this), _requestNonce)); - _requestIds[_requestNonce] = _requestId; - // _requestHashes[_requestId] = _requestHash; - _sstoreDataPointers[_requestId] = SSTORE2.write( - abi.encodePacked( - keccak256(_request.requestModuleData), - keccak256(_request.responseModuleData), - keccak256(_request.disputeModuleData), - keccak256(_request.resolutionModuleData), - keccak256(_request.finalityModuleData) - ) - ); - _sstore2Pointers[_requestId] = SSTORE2.write( + bytes32 _requestHash = keccak256( abi.encodePacked( + _requestNonce, _request.requestModule, _request.responseModule, _request.disputeModule, _request.resolutionModule, - _request.finalityModule, - msg.sender, - _requestNonce, - block.timestamp + _request.finalityModule ) ); + _requestId = keccak256(abi.encodePacked(msg.sender, address(this), _requestNonce)); + _requestIds[_requestNonce] = _requestId; + _requestHashes[_requestId] = _requestHash; + + Request memory _storedRequest = Request({ + ipfsHash: _request.ipfsHash, + requestModule: _request.requestModule, + responseModule: _request.responseModule, + disputeModule: _request.disputeModule, + resolutionModule: _request.resolutionModule, + finalityModule: _request.finalityModule, + requester: msg.sender, + nonce: uint96(_requestNonce), + createdAt: uint128(block.timestamp), + finalizedAt: 0 + }); - // Request memory _storedRequest = Request({ - // ipfsHash: _request.ipfsHash, - // requestModule: _request.requestModule, - // responseModule: _request.responseModule, - // disputeModule: _request.disputeModule, - // resolutionModule: _request.resolutionModule, - // finalityModule: _request.finalityModule, - // requester: msg.sender, - // nonce: uint96(_requestNonce), - // createdAt: uint128(block.timestamp), - // finalizedAt: 0 - // }); - - // _requests[_requestId] = _storedRequest; + _requests[_requestId] = _storedRequest; _participants[_requestId] = abi.encodePacked(_participants[_requestId], msg.sender); - emit RequestCreated(_requestId, _sstore2Pointers[_requestId], msg.sender, block.timestamp); + emit RequestCreated(_requestId, _requestHash, msg.sender, block.timestamp); } /** diff --git a/solidity/interfaces/IOracle.sol b/solidity/interfaces/IOracle.sol index ea89745..115d1bd 100644 --- a/solidity/interfaces/IOracle.sol +++ b/solidity/interfaces/IOracle.sol @@ -22,7 +22,7 @@ interface IOracle { * @param _requester The address of the user who created the request */ event RequestCreated( - bytes32 indexed _requestId, address _pointer, address indexed _requester, uint256 indexed _blockNumber + bytes32 indexed _requestId, bytes32 _requestHash, address indexed _requester, uint256 indexed _blockNumber ); /** diff --git a/yarn.lock b/yarn.lock index 85fbfb8..a5a064f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,19 +2,6 @@ # yarn lockfile v1 -"@0xsequence/create3@https://github.com/0xsequence/create3.git": - version "3.0.0" - resolved "https://github.com/0xsequence/create3.git#acc4703a21ec1d71dc2a99db088c4b1f467530fd" - dependencies: - csv-writer "^1.6.0" - -"@0xsequence/sstore2@https://github.com/0xsequence/sstore2": - version "1.1.0" - resolved "https://github.com/0xsequence/sstore2#0a28fe61b6e81de9a05b462a24b9f4ba8c70d5b7" - dependencies: - "@0xsequence/create3" "https://github.com/0xsequence/create3.git" - csv-writer "^1.6.0" - "@babel/code-frame@^7.0.0": version "7.21.4" resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.21.4.tgz#d0fa9e4413aca81f2b23b9442797bda1826edb39" @@ -1007,11 +994,6 @@ cross-spawn@^7.0.3: shebang-command "^2.0.0" which "^2.0.1" -csv-writer@^1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/csv-writer/-/csv-writer-1.6.0.tgz#d0cea44b6b4d7d3baa2ecc6f3f7209233514bcf9" - integrity sha512-NOx7YDFWEsM/fTRAJjRpPp8t+MKRVvniAg9wQlUKx20MFrPs73WLJhFf5iteqrxNYnsy924K3Iroh3yNHeYd2g== - dargs@^7.0.0: version "7.0.0" resolved "https://registry.yarnpkg.com/dargs/-/dargs-7.0.0.tgz#04015c41de0bcb69ec84050f3d9be0caf8d6d5cc"