Skip to content

Commit

Permalink
chore: let WRB and WPF return legacy RadonSLAs
Browse files Browse the repository at this point in the history
  • Loading branch information
guidiaz committed Feb 13, 2024
1 parent 44ecab0 commit 2040fc1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
4 changes: 2 additions & 2 deletions contracts/core/defaults/WitnetRequestBoardTrustableBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,12 @@ abstract contract WitnetRequestBoardTrustableBase
function getQueryRequest(uint256 _witnetQueryId)
external view
override
returns (bytes32, WitnetV2.RadonSLA memory)
returns (bytes32, Witnet.RadonSLA memory)
{
WitnetV2.Request storage __request = __seekQueryRequest(_witnetQueryId);
return (
__request.RAD == bytes32(0) ? registry.hashOf(__request.bytecode) : __request.RAD,
WitnetV2.toRadonSLA(__request.SLA)
WitnetV2.toRadonSLA(__request.SLA).toV1()
);
}

Expand Down
4 changes: 2 additions & 2 deletions contracts/interfaces/V2/IWitnetFeeds.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ interface IWitnetFeeds {
function registry() external view returns (WitnetBytecodes);
function witnet() external view returns (WitnetRequestBoard);

function defaultRadonSLA() external view returns (WitnetV2.RadonSLA memory);
function defaultRadonSLA() external view returns (Witnet.RadonSLA memory);
function estimateUpdateBaseFee(uint256 evmGasPrice) external view returns (uint);

function latestResponse(bytes4 feedId) external view returns (WitnetV2.Response memory);
function latestResult(bytes4 feedId) external view returns (Witnet.Result memory);

function latestUpdateQueryId(bytes4 feedId) external view returns (uint256);
function latestUpdateRequest(bytes4 feedId) external view returns (bytes32, WitnetV2.RadonSLA memory);
function latestUpdateRequest(bytes4 feedId) external view returns (bytes32, Witnet.RadonSLA memory);
function latestUpdateResponse(bytes4 feedId) external view returns (WitnetV2.Response memory);
function latestUpdateResultError(bytes4 feedId) external view returns (Witnet.ResultError memory);
function latestUpdateResultStatus(bytes4 feedId) external view returns (WitnetV2.ResultStatus);
Expand Down
2 changes: 1 addition & 1 deletion contracts/interfaces/V2/IWitnetRequestBoard.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ interface IWitnetRequestBoard {

/// @notice Retrieves the RAD hash and SLA parameters of the given query.
/// @param queryId The unique query identifier.
function getQueryRequest(uint256 queryId) external view returns (bytes32, WitnetV2.RadonSLA memory);
function getQueryRequest(uint256 queryId) external view returns (bytes32, Witnet.RadonSLA memory);

/// @notice Retrieves the whole `Witnet.Response` record referred to a previously posted Witnet Data Request.
/// @param queryId The unique query identifier.
Expand Down
14 changes: 14 additions & 0 deletions contracts/libs/WitnetV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,20 @@ library WitnetV2 {
/// ===============================================================================================================
/// --- 'WitnetV2.RadonSLA' helper methods ------------------------------------------------------------------------

function toV1(RadonSLA memory self)
internal pure
returns (Witnet.RadonSLA memory)
{
uint64 _witnessReward = self.witnessingWitTotalReward / (self.witnessingCommitteeSize + 3);
return Witnet.RadonSLA({
numWitnesses: self.witnessingCommitteeSize,
minConsensusPercentage: 51,
witnessReward: _witnessReward,
witnessCollateral: _witnessReward * 100,
minerCommitRevealFee: _witnessReward * 3
});
}

function equalOrGreaterThan(RadonSLA memory a, RadonSLA memory b)
internal pure returns (bool)
{
Expand Down

0 comments on commit 2040fc1

Please sign in to comment.