Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 40 additions & 4 deletions contracts/impls/core/customs/WitnetRequestBoardBypassV20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,25 @@ abstract contract WitnetOracleV20
function specs() virtual external view returns (bytes4);
}

interface IWitOracleQueriableConsumer {
/// Method to be called from the WitOracle contract as soon as the given Witnet `queryId` gets reported.
/// @dev It should revert if called from an address different to the WitOracle instance being used by consumer.
/// @param queryId The unique identifier of the Witnet query being reported.
/// @param queryResult Abi-encoded Witnet.DataResult containing the CBOR-encoded query's result, and metadata.
function reportWitOracleQueryResult(
uint256 queryId,
bytes calldata queryResult
) external;
}

/// @title Witnet Request Board bypass implementation to V2.0
/// @author The Witnet Foundation
contract WitnetRequestBoardBypassV20
is
IWitnetConsumer,
IWitnetOracleEvents,
IWitnetRequestBoardEvents,
IWitOracleQueriableConsumer,
WitnetUpgradableBase,
WitnetOracleV07,
WitnetBoardDataACLs
Expand Down Expand Up @@ -101,9 +113,8 @@ contract WitnetRequestBoardBypassV20
{
legacy = _legacy;
require(
address(_surrogate).code.length > 0
&& _surrogate.specs() == type(IWitnetOracle).interfaceId,
"WitnetRequestBoardBypassV20: uncompliant WitnetOracle"
address(_surrogate).code.length > 0,
"WitnetRequestBoardBypassV20: missing surrogate"
);
surrogate = _surrogate;
require(
Expand Down Expand Up @@ -199,7 +210,32 @@ contract WitnetRequestBoardBypassV20


// ================================================================================================================
// --- Implementation of 'IWitnetConsumer' ------------------------------------------------------------------------
// --- Implementation of 'IWitOracleQueriableConsumer' (V3.x) -----------------------------------------------------

/// Method to be called from the WitOracle contract as soon as the given Witnet `queryId` gets reported.
/// @dev It should revert if called from an address different to the WitOracle instance being used by consumer.
/// @param _witnetQueryId The unique identifier of the Witnet query being reported.
/// @param _witnetQueryResultBytes Abi-encoded Witnet.DataResult containing the CBOR-encoded query's result, and metadata.
function reportWitOracleQueryResult(
uint256 _witnetQueryId,
bytes calldata _witnetQueryResultBytes
)
external override
onlySurrogate
{
_witnetQueryId += __storage().numQueries;
WitnetV2.DataResult memory _queryResult = abi.decode(_witnetQueryResultBytes, (WitnetV2.DataResult));
require(
_statusOf(_witnetQueryId) == Witnet.QueryStatus.Posted,
"WitnetRequestBoardBypassV20: not in Posted status"
);
__storage().queries[_witnetQueryId].response.cborBytes = _queryResult.value.buffer.data;
emit PostedResult(_witnetQueryId, msg.sender);
}


// ================================================================================================================
// --- Implementation of 'IWitnetConsumer' (V2.x) -----------------------------------------------------------------

/// @notice Method to be called from the WitnetOracle contract as soon as the given Witnet `queryId`
/// @notice gets reported, if reported with no errors.
Expand Down
9 changes: 9 additions & 0 deletions contracts/libs/WitnetV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ library WitnetV2 {
uint64 witnessingFeeNanoWit;
}

/// Data struct containing the Witnet-provided result to a Data Request.
struct DataResult {
Witnet.ResultErrorCodes status;
Witnet.RadonDataTypes dataType;
bytes32 drTxHash;
uint256 finality;
uint64 timestamp;
WitnetCBOR.CBOR value;
}

/// ===============================================================================================================
/// --- 'WitnetV2.RadonSLA' helper methods ------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion migrations/scripts/5_WitnetRequestBoard.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const WitnetErrorsLib = artifacts.require("WitnetErrorsLib")
const WitnetRequestFactory = artifacts.require("WitnetRequestFactory")
const WitnetRequestBoard = artifacts.require("WitnetRequestBoard")

module.exports = async function (deployer, network, [, from, reporter]) {
module.exports = async function (deployer, network, [,, from, reporter]) {
const isDryRun = network === "test" || network.split("-")[1] === "fork" || network.split("-")[0] === "develop"
const ecosystem = utils.getRealmNetworkFromArgs()[0]
network = network.split("-")[0]
Expand Down
2 changes: 1 addition & 1 deletion migrations/witnet.addresses.json
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
"WitnetBytecodesImplementation": "0x79c27c0555C95DBfd38e97023c3257376aaa154d",
"WitnetRequestFactory": "0xA9DE27b01Eaa3702dafF488d47b1328413C64Ee1",
"WitnetRequestFactoryImplementation": "0xBfe1c2091A70FF1a2731B7eeF13b8227CAB81C28",
"WitnetRequestBoardImplementation": "0xB68c0127e74dC705d18162621035f9782b23D609",
"WitnetRequestBoardImplementation": "0x1561b551f1399e368AE14BBB33A1bD81F57a6B85",
"WitnetRequestBoardTrustableDefault": "0x6020665A4F6dcEFfBDb9655C8bF904C51CB94951"
}
},
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "witnet-solidity-bridge",
"version": "0.7.19",
"version": "0.7.20",
"description": "Witnet Solidity Bridge contracts for EVM-compatible chains",
"main": "",
"scripts": {
Expand Down Expand Up @@ -64,6 +64,7 @@
"truffle": "~5.11.5",
"truffle-assertions": "0.9.2",
"truffle-flattener": "~1.6.0",
"truffle-plugin-verify": "^0.6.7"
"truffle-plugin-verify": "^0.6.7",
"web3": "^4.16.0"
}
}
Loading
Loading