-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
77e9130
commit c15c1af
Showing
10 changed files
with
214 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import {IOracle} from '../interfaces/IOracle.sol'; | ||
|
||
/** | ||
* @title IDEncoder | ||
* @notice Library for encoding IDs of requests, responses and disputes | ||
*/ | ||
library IDEncoder { | ||
bytes32 private constant _REQUEST_TYPEHASH = keccak256( | ||
'IOracle.Request(uint96 nonce,address requester,address requestModule,address responseModule,address disputeModule,address resolutionModule,address finalityModule,bytes requestModuleData,bytes responseModuleData,bytes disputeModuleData,bytes resolutionModuleData,bytes finalityModuleData)' | ||
); | ||
|
||
bytes32 private constant _RESPONSE_TYPEHASH = | ||
keccak256('IOracle.Response(address proposer,bytes32 requestId,bytes response)'); | ||
|
||
bytes32 private constant _DISPUTE_TYPEHASH = | ||
keccak256('IOracle.Dispute(address disputer,address proposer,bytes32 responseId,bytes32 requestId)'); | ||
|
||
/** | ||
* @notice Computes the ID of a given request | ||
* | ||
* @param _request The request to compute the ID for | ||
* @return _id The ID the request | ||
*/ | ||
function getId(IOracle.Request memory _request) internal pure returns (bytes32 _id) { | ||
_id = keccak256(abi.encode(_REQUEST_TYPEHASH, _request)); | ||
} | ||
|
||
/** | ||
* @notice Computes the ID of a given response | ||
* | ||
* @param _response The response to compute the ID for | ||
* @return _id The ID the response | ||
*/ | ||
function getId(IOracle.Response memory _response) internal pure returns (bytes32 _id) { | ||
_id = keccak256(abi.encode(_RESPONSE_TYPEHASH, _response)); | ||
} | ||
|
||
/** | ||
* @notice Computes the ID of a given dispute | ||
* | ||
* @param _dispute The dispute to compute the ID for | ||
* @return _id The ID the dispute | ||
*/ | ||
function getId(IOracle.Dispute memory _dispute) internal pure returns (bytes32 _id) { | ||
_id = keccak256(abi.encode(_DISPUTE_TYPEHASH, _dispute)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.