diff --git a/solidity/contracts/Module.sol b/solidity/contracts/Module.sol index be016f0..fe1eb34 100644 --- a/solidity/contracts/Module.sol +++ b/solidity/contracts/Module.sol @@ -73,27 +73,63 @@ abstract contract Module is IModule { ) internal pure returns (bytes32 _responseId) { bytes32 _requestId = _getId(_request); _responseId = _getId(_response); + if (_response.requestId != _requestId) revert Module_InvalidResponseBody(); } /** - * @notice Validates the correctness of a request-response-dispute triplet + * @notice Validates the correctness of a request-dispute pair * * @param _request The request to compute the id for - * @param _response The response to compute the id for * @param _dispute The dispute to compute the id for * @return _disputeId The id the dispute */ function _validateDispute( IOracle.Request calldata _request, - IOracle.Response calldata _response, IOracle.Dispute calldata _dispute ) internal pure returns (bytes32 _disputeId) { bytes32 _requestId = _getId(_request); + _disputeId = _getId(_dispute); + + if (_dispute.requestId != _requestId) revert Module_InvalidDisputeBody(); + } + + /** + * @notice Validates the correctness of a response-dispute pair + * + * @param _response The response to compute the id for + * @param _dispute The dispute to compute the id for + * @return _disputeId The id the dispute + */ + function _validateDispute( + IOracle.Response calldata _response, + IOracle.Dispute calldata _dispute + ) internal pure returns (bytes32 _disputeId) { bytes32 _responseId = _getId(_response); _disputeId = _getId(_dispute); - if (_dispute.requestId != _requestId || _dispute.responseId != _responseId) revert Module_InvalidDisputeBody(); + if (_dispute.responseId != _responseId) revert Module_InvalidDisputeBody(); + } + + /** + * @notice Validates the correctness of a request-response-dispute triplet + * + * @param _request The request to compute the id for + * @param _response The response to compute the id for + * @param _dispute The dispute to compute the id for + * @return _responseId The id the response + * @return _disputeId The id the dispute + */ + function _validateResponseAndDispute( + IOracle.Request calldata _request, + IOracle.Response calldata _response, + IOracle.Dispute calldata _dispute + ) internal pure returns (bytes32 _responseId, bytes32 _disputeId) { + bytes32 _requestId = _getId(_request); + _responseId = _getId(_response); + _disputeId = _getId(_dispute); + if (_response.requestId != _requestId) revert Module_InvalidResponseBody(); + if (_dispute.requestId != _requestId || _dispute.responseId != _responseId) revert Module_InvalidDisputeBody(); } }