Skip to content

Commit

Permalink
refactor: internal library
Browse files Browse the repository at this point in the history
  • Loading branch information
0xJabberwock committed Nov 21, 2024
1 parent 819e5fe commit ddd64a7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
2 changes: 0 additions & 2 deletions solidity/contracts/Oracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import {OracleAccessController} from './access/OracleAccessController.sol';
import {OracleTypehash} from './utils/OracleTypehash.sol';

contract Oracle is IOracle, OracleAccessController {
using ValidatorLib for *;

/// @inheritdoc IOracle
mapping(bytes32 _requestId => uint256 _finalizedAt) public finalizedAt;

Expand Down
32 changes: 16 additions & 16 deletions solidity/libraries/ValidatorLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ library ValidatorLib {
* @param _request The request to compute the id for
* @return _id The id the request
*/
function _getId(IOracle.Request calldata _request) public pure returns (bytes32 _id) {
function _getId(IOracle.Request memory _request) internal pure returns (bytes32 _id) {
_id = keccak256(abi.encode(_request));
}

Expand All @@ -30,7 +30,7 @@ library ValidatorLib {
* @param _response The response to compute the id for
* @return _id The id the response
*/
function _getId(IOracle.Response calldata _response) public pure returns (bytes32 _id) {
function _getId(IOracle.Response memory _response) internal pure returns (bytes32 _id) {
_id = keccak256(abi.encode(_response));
}

Expand All @@ -40,7 +40,7 @@ library ValidatorLib {
* @param _dispute The dispute to compute the id for
* @return _id The id the dispute
*/
function _getId(IOracle.Dispute calldata _dispute) public pure returns (bytes32 _id) {
function _getId(IOracle.Dispute memory _dispute) internal pure returns (bytes32 _id) {
_id = keccak256(abi.encode(_dispute));
}

Expand All @@ -52,9 +52,9 @@ library ValidatorLib {
* @return _responseId The id the response
*/
function _validateResponse(
IOracle.Request calldata _request,
IOracle.Response calldata _response
) public pure returns (bytes32 _responseId) {
IOracle.Request memory _request,
IOracle.Response memory _response
) internal pure returns (bytes32 _responseId) {
bytes32 _requestId = _getId(_request);
_responseId = _getId(_response);

Expand All @@ -69,9 +69,9 @@ library ValidatorLib {
* @return _disputeId The id the dispute
*/
function _validateDispute(
IOracle.Request calldata _request,
IOracle.Dispute calldata _dispute
) public pure returns (bytes32 _disputeId) {
IOracle.Request memory _request,
IOracle.Dispute memory _dispute
) internal pure returns (bytes32 _disputeId) {
bytes32 _requestId = _getId(_request);
_disputeId = _getId(_dispute);

Expand All @@ -86,9 +86,9 @@ library ValidatorLib {
* @return _disputeId The id the dispute
*/
function _validateDispute(
IOracle.Response calldata _response,
IOracle.Dispute calldata _dispute
) public pure returns (bytes32 _disputeId) {
IOracle.Response memory _response,
IOracle.Dispute memory _dispute
) internal pure returns (bytes32 _disputeId) {
bytes32 _responseId = _getId(_response);
_disputeId = _getId(_dispute);

Expand All @@ -105,10 +105,10 @@ library ValidatorLib {
* @return _disputeId The id the dispute
*/
function _validateResponseAndDispute(
IOracle.Request calldata _request,
IOracle.Response calldata _response,
IOracle.Dispute calldata _dispute
) public pure returns (bytes32 _responseId, bytes32 _disputeId) {
IOracle.Request memory _request,
IOracle.Response memory _response,
IOracle.Dispute memory _dispute
) internal pure returns (bytes32 _responseId, bytes32 _disputeId) {
bytes32 _requestId = _getId(_request);
_responseId = _getId(_response);
_disputeId = _getId(_dispute);
Expand Down

0 comments on commit ddd64a7

Please sign in to comment.