UNPKG

witnet-solidity-bridge

Version:

Witnet Solidity Bridge contracts for EVM-compatible chains

1,049 lines (1,048 loc) 86.1 kB
{ "contractName": "WitnetConsumer", "abi": [ { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "uint256", "name": "id", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "evmReward", "type": "uint256" }, { "components": [ { "internalType": "uint8", "name": "committeeSize", "type": "uint8" }, { "internalType": "uint64", "name": "witnessingFeeNanoWit", "type": "uint64" } ], "indexed": false, "internalType": "struct WitnetV2.RadonSLA", "name": "witnetSLA", "type": "tuple" } ], "name": "WitnetQuery", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "uint256", "name": "id", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "evmGasPrice", "type": "uint256" } ], "name": "WitnetQueryResponse", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "uint256", "name": "id", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "evmGasPrice", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "evmCallbackGas", "type": "uint256" } ], "name": "WitnetQueryResponseDelivered", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "uint256", "name": "id", "type": "uint256" }, { "indexed": false, "internalType": "bytes", "name": "resultCborBytes", "type": "bytes" }, { "indexed": false, "internalType": "uint256", "name": "evmGasPrice", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "evmCallbackActualGas", "type": "uint256" }, { "indexed": false, "internalType": "string", "name": "evmCallbackRevertReason", "type": "string" } ], "name": "WitnetQueryResponseDeliveryFailed", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "uint256", "name": "id", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "evmReward", "type": "uint256" } ], "name": "WitnetQueryRewardUpgraded", "type": "event" }, { "inputs": [ { "internalType": "uint256", "name": "witnetQueryId", "type": "uint256" }, { "internalType": "uint64", "name": "witnetResultTimestamp", "type": "uint64" }, { "internalType": "bytes32", "name": "witnetResultTallyHash", "type": "bytes32" }, { "internalType": "uint256", "name": "witnetEvmFinalityBlock", "type": "uint256" }, { "internalType": "enum Witnet.ResultErrorCodes", "name": "errorCode", "type": "uint8" }, { "components": [ { "components": [ { "internalType": "bytes", "name": "data", "type": "bytes" }, { "internalType": "uint256", "name": "cursor", "type": "uint256" } ], "internalType": "struct WitnetBuffer.Buffer", "name": "buffer", "type": "tuple" }, { "internalType": "uint8", "name": "initialByte", "type": "uint8" }, { "internalType": "uint8", "name": "majorType", "type": "uint8" }, { "internalType": "uint8", "name": "additionalInformation", "type": "uint8" }, { "internalType": "uint64", "name": "len", "type": "uint64" }, { "internalType": "uint64", "name": "tag", "type": "uint64" } ], "internalType": "struct WitnetCBOR.CBOR", "name": "errorArgs", "type": "tuple" } ], "name": "reportWitnetQueryError", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "internalType": "uint256", "name": "witnetQueryId", "type": "uint256" }, { "internalType": "uint64", "name": "witnetResultTimestamp", "type": "uint64" }, { "internalType": "bytes32", "name": "witnetResultTallyHash", "type": "bytes32" }, { "internalType": "uint256", "name": "witnetEvmFinalityBlock", "type": "uint256" }, { "components": [ { "components": [ { "internalType": "bytes", "name": "data", "type": "bytes" }, { "internalType": "uint256", "name": "cursor", "type": "uint256" } ], "internalType": "struct WitnetBuffer.Buffer", "name": "buffer", "type": "tuple" }, { "internalType": "uint8", "name": "initialByte", "type": "uint8" }, { "internalType": "uint8", "name": "majorType", "type": "uint8" }, { "internalType": "uint8", "name": "additionalInformation", "type": "uint8" }, { "internalType": "uint64", "name": "len", "type": "uint64" }, { "internalType": "uint64", "name": "tag", "type": "uint64" } ], "internalType": "struct WitnetCBOR.CBOR", "name": "witnetResultCborValue", "type": "tuple" } ], "name": "reportWitnetQueryResult", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "witnet", "outputs": [ { "internalType": "contract WitnetOracle", "name": "", "type": "address" } ], "stateMutability": "view", "type": "function" }, { "inputs": [ { "internalType": "address", "name": "_from", "type": "address" } ], "name": "reportableFrom", "outputs": [ { "internalType": "bool", "name": "", "type": "bool" } ], "stateMutability": "view", "type": "function" } ], "metadata": "{\"compiler\":{\"version\":\"0.8.25+commit.b61c2a91\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"evmReward\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint8\",\"name\":\"committeeSize\",\"type\":\"uint8\"},{\"internalType\":\"uint64\",\"name\":\"witnessingFeeNanoWit\",\"type\":\"uint64\"}],\"indexed\":false,\"internalType\":\"struct WitnetV2.RadonSLA\",\"name\":\"witnetSLA\",\"type\":\"tuple\"}],\"name\":\"WitnetQuery\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"evmGasPrice\",\"type\":\"uint256\"}],\"name\":\"WitnetQueryResponse\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"evmGasPrice\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"evmCallbackGas\",\"type\":\"uint256\"}],\"name\":\"WitnetQueryResponseDelivered\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"resultCborBytes\",\"type\":\"bytes\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"evmGasPrice\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"evmCallbackActualGas\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"evmCallbackRevertReason\",\"type\":\"string\"}],\"name\":\"WitnetQueryResponseDeliveryFailed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"id\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"evmReward\",\"type\":\"uint256\"}],\"name\":\"WitnetQueryRewardUpgraded\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"witnetQueryId\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"witnetResultTimestamp\",\"type\":\"uint64\"},{\"internalType\":\"bytes32\",\"name\":\"witnetResultTallyHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"witnetEvmFinalityBlock\",\"type\":\"uint256\"},{\"internalType\":\"enum Witnet.ResultErrorCodes\",\"name\":\"errorCode\",\"type\":\"uint8\"},{\"components\":[{\"components\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"cursor\",\"type\":\"uint256\"}],\"internalType\":\"struct WitnetBuffer.Buffer\",\"name\":\"buffer\",\"type\":\"tuple\"},{\"internalType\":\"uint8\",\"name\":\"initialByte\",\"type\":\"uint8\"},{\"internalType\":\"uint8\",\"name\":\"majorType\",\"type\":\"uint8\"},{\"internalType\":\"uint8\",\"name\":\"additionalInformation\",\"type\":\"uint8\"},{\"internalType\":\"uint64\",\"name\":\"len\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"tag\",\"type\":\"uint64\"}],\"internalType\":\"struct WitnetCBOR.CBOR\",\"name\":\"errorArgs\",\"type\":\"tuple\"}],\"name\":\"reportWitnetQueryError\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"witnetQueryId\",\"type\":\"uint256\"},{\"internalType\":\"uint64\",\"name\":\"witnetResultTimestamp\",\"type\":\"uint64\"},{\"internalType\":\"bytes32\",\"name\":\"witnetResultTallyHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"witnetEvmFinalityBlock\",\"type\":\"uint256\"},{\"components\":[{\"components\":[{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"cursor\",\"type\":\"uint256\"}],\"internalType\":\"struct WitnetBuffer.Buffer\",\"name\":\"buffer\",\"type\":\"tuple\"},{\"internalType\":\"uint8\",\"name\":\"initialByte\",\"type\":\"uint8\"},{\"internalType\":\"uint8\",\"name\":\"majorType\",\"type\":\"uint8\"},{\"internalType\":\"uint8\",\"name\":\"additionalInformation\",\"type\":\"uint8\"},{\"internalType\":\"uint64\",\"name\":\"len\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"tag\",\"type\":\"uint64\"}],\"internalType\":\"struct WitnetCBOR.CBOR\",\"name\":\"witnetResultCborValue\",\"type\":\"tuple\"}],\"name\":\"reportWitnetQueryResult\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_from\",\"type\":\"address\"}],\"name\":\"reportableFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"witnet\",\"outputs\":[{\"internalType\":\"contract WitnetOracle\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{\"constructor\":{\"params\":{\"_callbackGasLimit\":\"Maximum gas to be spent by the IWitnetConsumer's callback methods.\"}},\"reportWitnetQueryError(uint256,uint64,bytes32,uint256,uint8,((bytes,uint256),uint8,uint8,uint8,uint64,uint64))\":{\"details\":\"It should revert if called from any other address different to the WitnetOracle being usedby the WitnetConsumer contract. \",\"params\":{\"errorArgs\":\"Error arguments, if any. An empty buffer is to be passed if no error arguments apply.\",\"errorCode\":\"The error code enum identifying the error produced during resolution on the Witnet blockchain.\",\"witnetEvmFinalityBlock\":\"EVM block at which the provided data can be considered to be final.\",\"witnetQueryId\":\"The unique identifier of the Witnet query being reported.\",\"witnetResultTallyHash\":\"Hash of the commit/reveal witnessing act that took place in the Witnet blockahin.\",\"witnetResultTimestamp\":\"Timestamp at which the reported value was captured by the Witnet blockchain. \"}},\"reportWitnetQueryResult(uint256,uint64,bytes32,uint256,((bytes,uint256),uint8,uint8,uint8,uint64,uint64))\":{\"details\":\"It should revert if called from any other address different to the WitnetOracle being usedby the WitnetConsumer contract. \",\"params\":{\"witnetEvmFinalityBlock\":\"EVM block at which the provided data can be considered to be final.\",\"witnetQueryId\":\"The unique identifier of the Witnet query being reported.\",\"witnetResultCborValue\":\"The CBOR-encoded resulting value of the Witnet query being reported.\",\"witnetResultTallyHash\":\"Hash of the commit/reveal witnessing act that took place in the Witnet blockahin.\",\"witnetResultTimestamp\":\"Timestamp at which the reported value was captured by the Witnet blockchain. \"}}},\"stateVariables\":{\"__witnetCallbackGasLimit\":{\"details\":\"Maximum gas to be spent by the IWitnetConsumer's callback methods. \"}},\"version\":1},\"userdoc\":{\"events\":{\"WitnetQuery(uint256,uint256,(uint8,uint64))\":{\"notice\":\"Emitted every time a new query containing some verified data request is posted to the WRB.\"},\"WitnetQueryResponse(uint256,uint256)\":{\"notice\":\"Emitted when a query with no callback gets reported into the WRB.\"},\"WitnetQueryResponseDelivered(uint256,uint256,uint256)\":{\"notice\":\"Emitted when a query with a callback gets successfully reported into the WRB.\"},\"WitnetQueryResponseDeliveryFailed(uint256,bytes,uint256,uint256,string)\":{\"notice\":\"Emitted when a query with a callback cannot get reported into the WRB.\"},\"WitnetQueryRewardUpgraded(uint256,uint256)\":{\"notice\":\"Emitted when the reward of some not-yet reported query is upgraded.\"}},\"kind\":\"user\",\"methods\":{\"reportWitnetQueryError(uint256,uint64,bytes32,uint256,uint8,((bytes,uint256),uint8,uint8,uint8,uint64,uint64))\":{\"notice\":\"Method to be called from the WitnetOracle contract as soon as the given Witnet `queryId`gets reported, if reported WITH errors.\"},\"reportWitnetQueryResult(uint256,uint64,bytes32,uint256,((bytes,uint256),uint8,uint8,uint8,uint64,uint64))\":{\"notice\":\"Method to be called from the WitnetOracle contract as soon as the given Witnet `queryId`gets reported, if reported with no errors.\"},\"reportableFrom(address)\":{\"notice\":\"=============================================================================================================== --- Base implementation of IWitnetConsumer --------------------------------------------------------------------\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"project:/contracts/apps/WitnetConsumer.sol\":\"WitnetConsumer\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"project:/contracts/WitnetOracle.sol\":{\"keccak256\":\"0x84ef8d2ebcba273e4bc23a5ee414a1213df55d1b4e496197a146031fea3a4874\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://c4a6e31964ed08c4c9dfe5279b4ffe9eeba6e759f15901e080e174e98e96a7f5\",\"dweb:/ipfs/QmTghzVFf2EHnfnHejgFGRBjanXYcstK9ftVaYmHWJfk8w\"]},\"project:/contracts/WitnetRequestBytecodes.sol\":{\"keccak256\":\"0x2a79d919dd79c0e3f857e6bee08368ad0b463188aced4a52de29270ed0f5f3d2\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://290d6013ee9f75fedbbb7726527a637ea2ae7a5da0ad118ecc43b298846f0bb0\",\"dweb:/ipfs/QmU8AZtPyctrrvxdmH297p595ZMS6DgcD6djSFKNxAqYMs\"]},\"project:/contracts/WitnetRequestFactory.sol\":{\"keccak256\":\"0x3c66f27d7c1db0e662c37d98005c4cbd871ceb75e97079d7bf673fb75d59c858\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://52adb318b870d0825718125e94fdbdd0e968ced09926420e2543b0ca4c6eb579\",\"dweb:/ipfs/QmYack87Q2UTfQb8KLLEPFBrMJgN2o6PaPqPNSc95McPVH\"]},\"project:/contracts/apps/UsingWitnet.sol\":{\"keccak256\":\"0x3fe6f2f1162bd1c128fb6aad2db81eaa1fdf04b5d15a5eeadf3e44bc81e2d4ef\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://927de4c99298ede8a240305bfd8e9daa5c79a32ed68cef19ece9b7f5bb37860b\",\"dweb:/ipfs/QmeZEbXpCTHegD6H7cVDipyXLYHUE4e3C66XojzYk8CpE4\"]},\"project:/contracts/apps/WitnetConsumer.sol\":{\"keccak256\":\"0xf1bb9a975c8bae03b99feb014e0dfb95640a20cc4a5e5a3037374db687a1e339\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://6d6f1708356b2093c6b649f80e47c7a8ddaa07e66c31d32b4f439a8a6d07b209\",\"dweb:/ipfs/Qmd7fFXCaheGUqPfdZ6xv8dAVwUH7DzweE8squCRJ2NrAh\"]},\"project:/contracts/interfaces/IWitnetConsumer.sol\":{\"keccak256\":\"0xf90fbcf0a59428c0ac13a3903214656060a95175adfdef8c11a7e16675b849e0\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://c2606640d3f343051ea18dfb8e136dfdb73ceecd8016c82ddb73d67ad39a30e0\",\"dweb:/ipfs/QmTADVW4M8pge6pGfenFAauEDk4yZEy78o5ksZiKGwP3DT\"]},\"project:/contracts/interfaces/IWitnetOracle.sol\":{\"keccak256\":\"0x5dbb04fce5e05675325232a735c46617378982b48dac2138aca0c6cc95e6e4d5\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://7447a70455478239500e16aebe5dce6676dc86307d22f662761d8e9f7c5d1276\",\"dweb:/ipfs/QmVkvA4Mt6G1JXxE8ebxKGAjT1WvNbp5QMKg9sUKdrJjhv\"]},\"project:/contracts/interfaces/IWitnetOracleEvents.sol\":{\"keccak256\":\"0x0442f474f253dc1f6bd6a4f153c3adb2abe5f6f0f24c76d1baf666185e61e659\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://535e8efcfc5693669d9bd2b6f62e6fc65aca19b7de355a27152e4362b410540d\",\"dweb:/ipfs/QmVZRXgku1cZewhoucebaiBKAyUjF2dmEzYrzGvjPzbwN9\"]},\"project:/contracts/interfaces/IWitnetRequestBytecodes.sol\":{\"keccak256\":\"0x8da168bee9a78442216965976b1f29087f760f37dcb09337283242599ed1cbca\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://e120623262ee0559913bdae56c0a7921147dfe08ada7ea81061b14e2fc38c5e1\",\"dweb:/ipfs/Qmbxe8XRrH6ZjJHiR6YYzcZV1jnSWwo9iBYz5r6GJ6To5G\"]},\"project:/contracts/interfaces/IWitnetRequestFactory.sol\":{\"keccak256\":\"0x3b19ec4a976745ba2646e7e1886d647ef30ad678460a712c93bbfb4405b57f1f\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://fa759ae15b7d4da622a81d50933474910959ac490d8b63ea2e7ed8608859a9c9\",\"dweb:/ipfs/QmRckCu7eBBP5fn9ff6djs7VbdhFc7sxYb2yqDr4go66jV\"]},\"project:/contracts/libs/Witnet.sol\":{\"keccak256\":\"0x65a87375dd79d63a83fb454b7199b6c999bd59c50b3b59d521c5c4d45a7d3cc3\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://ca865b681d810c2fc5c3672ea6343c3bdf6fd71764ab824d25994744dc85866b\",\"dweb:/ipfs/QmPGcP3xGTNZfsQ9GSKdujNLRVs8dWDdubyUko1rbQqJNv\"]},\"project:/contracts/libs/WitnetBuffer.sol\":{\"keccak256\":\"0xa14570492eb5a313ddbacae0185c850ec99c67211eb33989a5e21d31bf06a150\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://e83c11edb49cab6a767c0b685825bc22ece0d3d2897e0d54fe1923df5cc76ba5\",\"dweb:/ipfs/QmdLDgCc3tnKbgRrXwfNzsg6uUDirNmjvBB8V3iMmnD69a\"]},\"project:/contracts/libs/WitnetCBOR.sol\":{\"keccak256\":\"0xb346547ff731163beea2c657c52675cdf7936691d566a76a045577cf9c34ade0\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://6d4b5b6424a033584b41f1204d635db98fda9ca9bd2a614c9d82539a3e4e6529\",\"dweb:/ipfs/QmW6Qy3wWpzHSECYaCPaf9LWGfPqWDKVoP2kPSNNQu7LMQ\"]},\"project:/contracts/libs/WitnetV2.sol\":{\"keccak256\":\"0xb276a6da373bfbe9cd942dd7e59979cda898215d1e36ab3df95a6d6cc6ff770f\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://bc4890876b9bc64f501ccdd48408bb63724865cb2ce8d2057f6b318540adce7c\",\"dweb:/ipfs/QmPMHPdbCsKBavhiLcaDgQ9EjNSvwwzv8TKffotcCv1ctP\"]}},\"version\":1}", "bytecode": "0x", "deployedBytecode": "0x", "immutableReferences": {}, "generatedSources": [], "deployedGeneratedSources": [], "sourceMap": "", "deployedSourceMap": "", "source": "// SPDX-License-Identifier: MIT\r\npragma solidity ^0.8.0;\r\n\r\nimport \"./UsingWitnet.sol\";\r\nimport \"../interfaces/IWitnetConsumer.sol\";\r\n\r\nabstract contract WitnetConsumer\r\n is\r\n IWitnetConsumer,\r\n UsingWitnet\r\n{ \r\n /// @dev Maximum gas to be spent by the IWitnetConsumer's callback methods. \r\n uint24 internal immutable __witnetCallbackGasLimit;\r\n \r\n modifier onlyFromWitnet {\r\n require(msg.sender == address(__witnet), \"WitnetConsumer: unauthorized\");\r\n _;\r\n }\r\n\r\n /// @param _callbackGasLimit Maximum gas to be spent by the IWitnetConsumer's callback methods.\r\n constructor (uint24 _callbackGasLimit) {\r\n __witnetCallbackGasLimit = _callbackGasLimit;\r\n }\r\n\r\n \r\n /// ===============================================================================================================\r\n /// --- Base implementation of IWitnetConsumer --------------------------------------------------------------------\r\n\r\n function reportableFrom(address _from) virtual override external view returns (bool) {\r\n return _from == address(__witnet);\r\n }\r\n\r\n\r\n /// ===============================================================================================================\r\n /// --- WitnetConsumer virtual methods ----------------------------------------------------------------------------\r\n\r\n function _witnetEstimateEvmReward() virtual internal view returns (uint256) {\r\n return (\r\n (100 + __witnetBaseFeeOverheadPercentage)\r\n * __witnet.estimateBaseFeeWithCallback(\r\n tx.gasprice,\r\n __witnetCallbackGasLimit\r\n )\r\n ) / 100;\r\n }\r\n \r\n function _witnetEstimateEvmReward(uint16)\r\n virtual override internal view\r\n returns (uint256)\r\n {\r\n return _witnetEstimateEvmReward();\r\n }\r\n\r\n\r\n /// @notice Estimate the minimum reward required for posting a data request, using `tx.gasprice` as a reference.\r\n /// @dev Underestimates if the size of returned data is greater than `_resultMaxSize`. \r\n /// @param _callbackGasLimit Maximum gas to be spent when reporting the data request result.\r\n function _witnetEstimateEvmRewardWithCallback(uint24 _callbackGasLimit)\r\n virtual internal view\r\n returns (uint256)\r\n {\r\n return (\r\n (100 + __witnetBaseFeeOverheadPercentage)\r\n * __witnet.estimateBaseFeeWithCallback(\r\n tx.gasprice, \r\n _callbackGasLimit\r\n )\r\n ) / 100;\r\n }\r\n}\r\n", "sourcePath": "C:\\Users\\guill\\github\\witnet\\witnet-solidity-bridge\\contracts\\apps\\WitnetConsumer.sol", "ast": { "absolutePath": "project:/contracts/apps/WitnetConsumer.sol", "exportedSymbols": { "IWitnetConsumer": [ 12829 ], "IWitnetOracle": [ 13265 ], "IWitnetOracleEvents": [ 13315 ], "IWitnetRequestBytecodes": [ 13979 ], "IWitnetRequestFactory": [ 14002 ], "UsingWitnet": [ 1157 ], "Witnet": [ 17557 ], "WitnetBuffer": [ 19191 ], "WitnetCBOR": [ 20734 ], "WitnetConsumer": [ 1566 ], "WitnetOracle": [ 749 ], "WitnetRequestBytecodes": [ 849 ], "WitnetRequestFactory": [ 880 ], "WitnetV2": [ 23640 ] }, "id": 1567, "license": "MIT", "nodeType": "SourceUnit", "nodes": [ { "id": 1455, "literals": [ "solidity", "^", "0.8", ".0" ], "nodeType": "PragmaDirective", "src": "33:23:20" }, { "absolutePath": "project:/contracts/apps/UsingWitnet.sol", "file": "./UsingWitnet.sol", "id": 1456, "nameLocation": "-1:-1:-1", "nodeType": "ImportDirective", "scope": 1567, "sourceUnit": 1158, "src": "60:27:20", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "project:/contracts/interfaces/IWitnetConsumer.sol", "file": "../interfaces/IWitnetConsumer.sol", "id": 1457, "nameLocation": "-1:-1:-1", "nodeType": "ImportDirective", "scope": 1567, "sourceUnit": 12830, "src": "89:43:20", "symbolAliases": [], "unitAlias": "" }, { "abstract": true, "baseContracts": [ { "baseName": { "id": 1458, "name": "IWitnetConsumer", "nameLocations": [ "186:15:20" ], "nodeType": "IdentifierPath", "referencedDeclaration": 12829, "src": "186:15:20" }, "id": 1459, "nodeType": "InheritanceSpecifier", "src": "186:15:20" }, { "baseName": { "id": 1460, "name": "UsingWitnet", "nameLocations": [ "212:11:20" ], "nodeType": "IdentifierPath", "referencedDeclaration": 1157, "src": "212:11:20" }, "id": 1461, "nodeType": "InheritanceSpecifier", "src": "212:11:20" } ], "canonicalName": "WitnetConsumer", "contractDependencies": [], "contractKind": "contract", "fullyImplemented": false, "id": 1566, "linearizedBaseContracts": [ 1566, 1157, 13315, 12829 ], "name": "WitnetConsumer", "nameLocation": "154:14:20", "nodeType": "ContractDefinition", "nodes": [ { "constant": false, "documentation": { "id": 1462, "nodeType": "StructuredDocumentation", "src": "233:77:20", "text": "@dev Maximum gas to be spent by the IWitnetConsumer's callback methods. " }, "id": 1464, "mutability": "immutable", "name": "__witnetCallbackGasLimit", "nameLocation": "342:24:20", "nodeType": "VariableDeclaration", "scope": 1566, "src": "316:50:20", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint24", "typeString": "uint24" }, "typeName": { "id": 1463, "name": "uint24", "nodeType": "ElementaryTypeName", "src": "316:6:20", "typeDescriptions": { "typeIdentifier": "t_uint24", "typeString": "uint24" } }, "visibility": "internal" }, { "body": { "id": 1478, "nodeType": "Block", "src": "401:103:20", "statements": [ { "expression": { "arguments": [ { "commonType": { "typeIdentifier": "t_address", "typeString": "address" }, "id": 1473, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "expression": { "id": 1467, "name": "msg", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4294967281, "src": "420:3:20", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" } }, "id": 1468, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberLocation": "424:6:20", "memberName": "sender", "nodeType": "MemberAccess", "src": "420:10:20", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "nodeType": "BinaryOperation", "operator": "==", "rightExpression": { "arguments": [ { "id": 1471, "name": "__witnet", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1016, "src": "442:8:20", "typeDescriptions": { "typeIdentifier": "t_contract$_WitnetOracle_$749", "typeString": "contract WitnetOracle" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_contract$_WitnetOracle_$749", "typeString": "contract WitnetOracle" } ], "id": 1470, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "434:7:20", "typeDescriptions": { "typeIdentifier": "t_type$_t_address_$", "typeString": "type(address)" }, "typeName": { "id": 1469, "name": "address", "nodeType": "ElementaryTypeName", "src": "434:7:20", "typeDescriptions": {} } }, "id": 1472, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "nameLocations": [], "names": [], "nodeType": "FunctionCall", "src": "434:17:20", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "src": "420:31:20", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, { "hexValue": "5769746e6574436f6e73756d65723a20756e617574686f72697a6564", "id": 1474, "isConstant": false, "isLValue": false, "isPure": true, "kind": "string", "lValueRequested": false, "nodeType": "Literal", "src": "453:30:20", "typeDescriptions": { "typeIdentifier": "t_stringliteral_d87ae0814afdd1a6abd9537944be2a952d6358fa17f8e71f8618ed038810dd22", "typeString": "literal_string \"WitnetConsumer: unauthorized\"" }, "value": "WitnetConsumer: unauthorized" } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bool", "typeString": "bool" }, { "typeIdentifier": "t_stringliteral_d87ae0814afdd1a6abd9537944be2a952d6358fa17f8e71f8618ed038810dd22", "typeString": "literal_string \"WitnetConsumer: unauthorized\"" } ], "id": 1466, "name": "require", "nodeType": "Identifier", "overloadedDeclarations": [ 4294967278, 4294967278 ], "referencedDeclaration": 4294967278, "src": "412:7:20", "typeDescriptions": { "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", "typeString": "function (bool,string memory) pure" } }, "id": 1475, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], "names": [], "nodeType": "FunctionCall", "src": "412:72:20", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } }, "id": 1476, "nodeType": "ExpressionStatement", "src": "412:72:20" }, { "id": 1477, "nodeType": "PlaceholderStatement", "src": "495:1:20" } ] }, "id": 1479, "name": "onlyFromWitnet", "nameLocation": "386:14:20", "nodeType": "ModifierDefinition", "parameters": { "id": 1465, "nodeType": "ParameterList", "parameters": [], "src": "401:0:20" }, "src": "377:127:20", "virtual": false, "visibility": "internal" }, { "body": { "id": 1489, "nodeType": "Block", "src": "652:63:20", "statements": [ { "expression": { "id": 1487, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "id": 1485, "name": "__witnetCallbackGasLimit", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1464, "src": "663:24:20", "typeDescriptions": { "typeIdentifier": "t_uint24", "typeString": "uint24" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": { "id": 1486, "name": "_callbackGasLimit", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1482, "src": "690:17:20", "typeDescriptions": { "typeIdentifier": "t_uint24", "typeString": "uint24" } }, "src": "663:44:20", "typeDescriptions": { "typeIdentifier": "t_uint24", "typeString": "uint24" } }, "id": 1488, "nodeType": "ExpressionStatement", "src": "663:44:20" } ] }, "documentation": { "id": 1480, "nodeType": "StructuredDocumentation", "src": "512:95:20", "text": "@param _callbackGasLimit Maximum gas to be spent by the IWitnetConsumer's callback methods." }, "id": 1490, "implemented": true, "kind": "constructor", "modifiers": [], "name": "", "nameLocation": "-1:-1:-1", "nodeType": "FunctionDefinition", "parameters": { "id": 1483, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 1482, "mutability": "mutable", "name": "_callbackGasLimit", "nameLocation": "633:17:20", "nodeType": "VariableDeclaration", "scope": 1490, "src": "626:24:20", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint24", "typeString": "uint24" }, "typeName": { "id": 1481, "name": "uint24", "nodeType": "ElementaryTypeName", "src": "626:6:20", "typeDescriptions": { "typeIdentifier": "t_uint24", "typeString": "uint24" } }, "visibility": "internal" } ], "src": "625:26:20" }, "returnParameters": { "id": 1484, "nodeType": "ParameterList", "parameters": [], "src": "652:0:20" }, "scope": 1566, "src": "613:102:20", "stateMutability": "nonpayable", "virtual": false, "visibility": "internal" }, { "baseFunctions": [ 12828 ], "body": { "id": 1506, "nodeType": "Block", "src": "1058:52:20", "statements": [ { "expression": { "commonType": { "typeIdentifier": "t_address", "typeString": "address" }, "id": 1504, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "id": 1499, "name": "_from", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1493, "src": "1076:5:20", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "nodeType": "BinaryOperation", "operator": "==", "rightExpression": { "arguments": [ { "id": 1502, "name": "__witnet", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 1016, "src": "1093:8:20", "typeDescriptions": { "typeIdentifier": "t_contract$_WitnetOracle_$749", "typeString": "contract WitnetOracle" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_contract$_WitnetOracle_$749", "typeString": "contract WitnetOracle" } ], "id": 1501, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "1085:7:20", "typeDescriptions": { "typeIdentifier": "t_type$_t_address_$", "typeString": "type(address)" }, "typeName": { "id": 1500, "name": "address", "nodeType": "ElementaryTypeName", "src": "1085:7:20", "typeDescriptions": {} } }, "id": 1503, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "nameLocations": [], "names": [], "nodeType": "FunctionCall", "src": "1085:17:20", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "src": "1076:26:20", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "functionReturnParameters": 1498, "id": 1505, "nodeType": "Return", "src": "1069:33:20" } ] }, "documentation": { "id": 1491, "nodeType": "StructuredDocumentation", "src": "729:238:20", "text": "===============================================================================================================\n --- Base implementation of IWitnetConsumer --------------------------------------------------------------------" }, "functionSelector": "47a10e56", "id": 1507, "implemented": true, "kind": "function", "modifiers": [], "name": "reportableFrom", "nameLocation": "982:14:20", "nodeType": "FunctionDefinition", "overrides": { "id": 1495, "nodeType": "OverrideSpecifier", "overrides": [], "src": "1020:8:20" }, "parameters": { "id": 1494, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 1493, "mutability": "mutable", "name": "_from", "nameLocation": "1005:5:20", "nodeType": "VariableDeclaration", "scope": 1507, "src": "997:13:20", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 1492, "name": "address", "nodeType": "ElementaryTypeName", "src": "997:7:20", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "visibility": "internal" } ], "src": "996:15:20" }, "returnParameters": { "id": 1498, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 1497, "mutability": "mutable", "name": "", "nameLocation": "-1:-1:-1", "nodeType": "VariableDeclaration", "scope": 1507, "src": "1052:4:20", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" }, "typeName": { "id": 1496, "name": "bool", "nodeType": "ElementaryTypeName", "src": "1052:4:20", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "visibility": "internal" } ], "src": "1051:6:20" }, "scope": 1566, "src": "973:137:20", "stateMutability": "view", "virtual": true, "visibility": "external" }, { "body": { "id": 1528, "nodeType": "Block", "src": "1440:255:20", "statements": [ { "expression": { "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 1526, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "components": [ { "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 1523, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "components": [ { "commonType": { "typeIdentifier": "t_uint16", "typeString": "uint16" },