UNPKG

witnet-solidity-bridge

Version:

Witnet Solidity Bridge contracts for EVM-compatible chains

903 lines 219 kB
{ "contractName": "OVM_GasPriceOracle", "abi": [ { "inputs": [ { "internalType": "bytes", "name": "_data", "type": "bytes" } ], "name": "getL1Fee", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" } ], "stateMutability": "view", "type": "function" } ], "metadata": "{\"compiler\":{\"version\":\"0.8.25+commit.b61c2a91\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"name\":\"getL1Fee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"project:/contracts/core/customs/WitnetOracleTrustableOvm2.sol\":\"OVM_GasPriceOracle\"},\"evmVersion\":\"paris\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\":{\"keccak256\":\"0x631188737069917d2f909d29ce62c4d48611d326686ba6683e26b72a23bfac0b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://7a61054ae84cd6c4d04c0c4450ba1d6de41e27e0a2c4f1bcdf58f796b401c609\",\"dweb:/ipfs/QmUvtdp7X1mRVyC3CsHrtPbgoqWaXHp3S1ZR24tpAQYJWM\"]},\"@openzeppelin/contracts/access/Ownable.sol\":{\"keccak256\":\"0xff6d0bb2e285473e5311d9d3caacb525ae3538a80758c10649a4d61029b017bb\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://8ed324d3920bb545059d66ab97d43e43ee85fd3bd52e03e401f020afb0b120f6\",\"dweb:/ipfs/QmfEckWLmZkDDcoWrkEvMWhms66xwTLff9DDhegYpvHo1a\"]},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"keccak256\":\"0xe06a3f08a987af6ad2e1c1e774405d4fe08f1694b67517438b467cecf0da0ef7\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://df6f0c459663c9858b6cba2cda1d14a7d05a985bed6d2de72bd8e78c25ee79db\",\"dweb:/ipfs/QmeTTxZ7qVk9rjEv2R4CpCwdf8UMCcRqDNMvzNxHc3Fnn9\"]},\"@openzeppelin/contracts/utils/Context.sol\":{\"keccak256\":\"0x493033a8d1b176a037b2cc6a04dad01a5c157722049bbecf632ca876224dd4b2\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://6a708e8a5bdb1011c2c381c9a5cfd8a9a956d7d0a9dc1bd8bcdaf52f76ef2f12\",\"dweb:/ipfs/Qmax9WHBnVsZP46ZxEMNRQpLQnrdE4dK8LehML1Py8FowF\"]},\"@openzeppelin/contracts/utils/ReentrancyGuard.sol\":{\"keccak256\":\"0x11a5a79827df29e915a12740caf62fe21ebe27c08c9ae3e09abe9ee3ba3866d3\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://3cf0c69ab827e3251db9ee6a50647d62c90ba580a4d7bbff21f2bea39e7b2f4a\",\"dweb:/ipfs/QmZiKwtKU1SBX4RGfQtY7PZfiapbbu6SZ9vizGQD9UHjRA\"]},\"@openzeppelin/contracts/utils/introspection/ERC165.sol\":{\"keccak256\":\"0xddce8e17e3d3f9ed818b4f4c4478a8262aab8b11ed322f1bf5ed705bb4bd97fa\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://8084aa71a4cc7d2980972412a88fe4f114869faea3fefa5436431644eb5c0287\",\"dweb:/ipfs/Qmbqfs5dRdPvHVKY8kTaeyc65NdqXRQwRK7h9s5UJEhD1p\"]},\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"keccak256\":\"0x79796192ec90263f21b464d5bc90b777a525971d3de8232be80d9c4f9fb353b8\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://f6fda447a62815e8064f47eff0dd1cf58d9207ad69b5d32280f8d7ed1d1e4621\",\"dweb:/ipfs/QmfDRc7pxfaXB2Dh9np5Uf29Na3pQ7tafRS684wd3GLjVL\"]},\"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/core/WitnetProxy.sol\":{\"keccak256\":\"0x2b2f56fc69bf0e01f6f1062202d1682cd394fa3b3d9ff2f8f833ab51c9e866cc\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://8017f76a71e4a52a5a5e249081c92510bac5b91f03f727e66ff4406238521337\",\"dweb:/ipfs/QmdWcPAL3MGtxGdpX5CMfgzz4YzxYEeCiFRoGHVCr8rLEL\"]},\"project:/contracts/core/WitnetUpgradableBase.sol\":{\"keccak256\":\"0x9cea47781e0005266e14fadf8d1ee565d0814d4d51b30dced11bdee37b663060\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://fb1f843f53c693f4b5a8f32249ac2eb93095671b99c90aa7c6d335eb7153e827\",\"dweb:/ipfs/QmSLvVGCcg2FZVWPB82yVb57SFixkuDm2BqjvgzJpnYfZp\"]},\"project:/contracts/core/customs/WitnetOracleTrustableOvm2.sol\":{\"keccak256\":\"0x6eb35438e7e1e29128f03124fc79f3b23a59f3af10564582497673ae55627cab\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://cc5947567cfc98ce0f98f985a4beb27ad569c90ba779bcfd2c50d67795d00423\",\"dweb:/ipfs/QmTiX4XjojsL4dfoiUUWbmFCZWseCCR1eiKsswbvRGNELE\"]},\"project:/contracts/core/defaults/WitnetOracleTrustableBase.sol\":{\"keccak256\":\"0xeb14d9ac86e9983b41cc3a307acd4e6546c9c3f790234ca1c208aa4c189a27df\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://73c7f71f22a0cf9e70681641b131ba42233c6bd03c4170d5ac153153de206c04\",\"dweb:/ipfs/QmPMKe45EGWbUoDPTF2Y8VDZ8Q3eEfbJFHt8DW9Y5x6NYn\"]},\"project:/contracts/core/defaults/WitnetOracleTrustableDefault.sol\":{\"keccak256\":\"0x3e4ce76102aef381af61296fb19e5fa1e36682cb13f0c21b882b590b06efc218\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://ae39d2d0043a5b073177eb94f876dda7a2531d99f01162852d513dee36a7465e\",\"dweb:/ipfs/QmdGnCi4m478KEUdFv5w9Zqmmdc1SgmYB6KeRtbW4MC41P\"]},\"project:/contracts/data/WitnetOracleDataLib.sol\":{\"keccak256\":\"0x03c8b61605f0c5324047aa99c896fe189933e3e9a59b070b9b3ea6141f7db960\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://cedd0416337f718a44bbbaf53efa99ba490f7de1e6ab45f6bdf29e03082aa29d\",\"dweb:/ipfs/Qmb8RUaZEFX5CvE1VTYpTrm1EhM62gAUcZ4dGt3w39gZBA\"]},\"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/IWitnetOracleReporter.sol\":{\"keccak256\":\"0xf4726c5c522b99ce01c2c870c259ebb8dc1563a25df3d715ed78cff89a8bb122\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://11d4d7205c416fc2927856c2ab64a7d2d5374900c6ad41320f512a0f2e17f215\",\"dweb:/ipfs/QmW8gmJ5rkd4K7ahPQ6KuCQ5wdnhoZJTpSL5iPkZcg2dAe\"]},\"project:/contracts/interfaces/IWitnetRequestBoardAdminACLs.sol\":{\"keccak256\":\"0xf7dccb4e47d281ce229a9dc219fb2b30dea26f6ad80225f21c75b103d5ab1230\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://814f304ff435f64bbcac9ac512ca636c3245f522f87285909c9a9e0ec6dc5368\",\"dweb:/ipfs/QmXtmoYRgm2iXQmLUmVoRz8d5PNqrZXid4SgX4BoDs8rcm\"]},\"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/WitnetErrorsLib.sol\":{\"keccak256\":\"0x6cc28a70034f65099ec7e69d03a6c9cb643a77032c0e6d76532b77b036ef8436\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://44eff62b48c4daf5606fae9b04dca6201af4336909d5966c2a2503c866b9efb0\",\"dweb:/ipfs/QmSc4qNo2ymtCevvgDKESYuVi1JD7PCWbMKfDoEhNwj4aS\"]},\"project:/contracts/libs/WitnetV2.sol\":{\"keccak256\":\"0xb276a6da373bfbe9cd942dd7e59979cda898215d1e36ab3df95a6d6cc6ff770f\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://bc4890876b9bc64f501ccdd48408bb63724865cb2ce8d2057f6b318540adce7c\",\"dweb:/ipfs/QmPMHPdbCsKBavhiLcaDgQ9EjNSvwwzv8TKffotcCv1ctP\"]},\"project:/contracts/patterns/Initializable.sol\":{\"keccak256\":\"0xaac470e87f361cf15d68d1618d6eb7d4913885d33ccc39c797841a9591d44296\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://ef3760b2039feda8715d4bd9f8de8e3885f25573d12ba92f52d626ba880a08bf\",\"dweb:/ipfs/QmP2mfHPBKkjTAKft95sPDb4PBsjfmAwc47Kdcv3xYSf3g\"]},\"project:/contracts/patterns/Ownable.sol\":{\"keccak256\":\"0x494bda32f9a218d9c33ea82112129c0933ab52f57eabfbf0d14a8742a3370800\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://6c4cf04ebb052fed9d15cf93ff4523955ee311aa4425ee85f0e80b4489c94e76\",\"dweb:/ipfs/QmfMf4WD7woTaQSTbJxxoan2aXSeY7ovY5NoipSBw5rMPK\"]},\"project:/contracts/patterns/Ownable2Step.sol\":{\"keccak256\":\"0x7033d8133957a291cf9b8be30bfc4b95e6414a20995911d1b5df8ea149580604\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://e20a079adc224113306392d27e0cf202c6c4a7678c4705fd3bbbca99c1e9b816\",\"dweb:/ipfs/QmWrFv2SbSokhrWhwL94sW5x1HyT7rX5f4Scowe4bWHHqu\"]},\"project:/contracts/patterns/Payable.sol\":{\"keccak256\":\"0x83401b23b1c144561e674e86738e0d907c8fa15d90d79254415b3f5f215035c9\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://e031f9a24c7030cd2d160a64a581fd3a69a06d7dc71bcf704b48f391c3d63fc6\",\"dweb:/ipfs/QmVpX6PdfgPGJZp3W5H4CGqVUqmNx9ttb4V5cz3YgBTypQ\"]},\"project:/contracts/patterns/Proxiable.sol\":{\"keccak256\":\"0x86032205378fed9ed2bf155eed8ce4bdbb13b7f5960850c6d50954a38b61a3d8\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://f89978eda4244a13f42a6092a94ac829bb3e38c92d77d4978b9f32894b187a63\",\"dweb:/ipfs/Qmbc1XaFCvLm3Sxvh7tP29Ug32jBGy3avsCqBGAptxs765\"]},\"project:/contracts/patterns/ReentrancyGuard.sol\":{\"keccak256\":\"0x1470caf4bd78b79f706e28a8a85c95a6e13ec33eda04275e5da84464130831e6\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://c974fb4dc29718a84f9ab5fa3f8c25c7f889050a38445e16c3ead5ff9d4b4bab\",\"dweb:/ipfs/QmbuGjkSjngbTZMRPijL9p56fP9cK5jMnWsFmvYAQj3qAY\"]},\"project:/contracts/patterns/Upgradeable.sol\":{\"keccak256\":\"0xbeb025c71f037acb1a668174eb6930631bf397129beb825f2660e5d8cf19614f\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://fe6ce4dcd500093ae069d35b91829ccb471e1ca33ed0851fb053fbfe76c78aba\",\"dweb:/ipfs/QmT7huvCFS6bHDxt7HhEogJmyvYNbeb6dFTJudsVSX6nEs\"]}},\"version\":1}", "bytecode": "0x", "deployedBytecode": "0x", "immutableReferences": {}, "generatedSources": [], "deployedGeneratedSources": [], "sourceMap": "", "deployedSourceMap": "", "source": "// SPDX-License-Identifier: MIT\r\n\r\n/* solhint-disable var-name-mixedcase */\r\n\r\npragma solidity >=0.7.0 <0.9.0;\r\npragma experimental ABIEncoderV2;\r\n\r\nimport \"../defaults/WitnetOracleTrustableDefault.sol\";\r\n\r\n// solhint-disable-next-line\r\ninterface OVM_GasPriceOracle {\r\n function getL1Fee(bytes calldata _data) external view returns (uint256);\r\n}\r\n\r\n/// @title Witnet Request Board \"trustable\" implementation contract.\r\n/// @notice Contract to bridge requests to Witnet Decentralized Oracle Network.\r\n/// @dev This contract enables posting requests that Witnet bridges will insert into the Witnet network.\r\n/// The result of the requests will be posted back to this contract by the bridge nodes too.\r\n/// @author The Witnet Foundation\r\ncontract WitnetOracleTrustableOvm2\r\n is \r\n WitnetOracleTrustableDefault\r\n{\r\n using WitnetV2 for WitnetV2.RadonSLA;\r\n\r\n function class() virtual override public view returns (string memory) {\r\n return type(WitnetOracleTrustableOvm2).name;\r\n }\r\n\r\n constructor(\r\n WitnetRequestFactory _factory,\r\n WitnetRequestBytecodes _registry,\r\n bool _upgradable,\r\n bytes32 _versionTag,\r\n uint256 _reportResultGasBase,\r\n uint256 _reportResultWithCallbackGasBase,\r\n uint256 _reportResultWithCallbackRevertGasBase,\r\n uint256 _sstoreFromZeroGas\r\n )\r\n WitnetOracleTrustableDefault(\r\n _factory,\r\n _registry,\r\n _upgradable,\r\n _versionTag,\r\n _reportResultGasBase,\r\n _reportResultWithCallbackGasBase,\r\n _reportResultWithCallbackRevertGasBase,\r\n _sstoreFromZeroGas\r\n )\r\n {\r\n __gasPriceOracleL1 = OVM_GasPriceOracle(0x420000000000000000000000000000000000000F);\r\n }\r\n\r\n OVM_GasPriceOracle immutable internal __gasPriceOracleL1;\r\n\r\n function _getCurrentL1Fee(uint16 _resultMaxSize) virtual internal view returns (uint256) {\r\n return __gasPriceOracleL1.getL1Fee(\r\n abi.encodePacked(\r\n hex\"06eb2c42000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000ffffffffff00000000000000000000000000000000000000000000000000000000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000ff\",\r\n _resultMaxBuffer(_resultMaxSize)\r\n )\r\n );\r\n }\r\n\r\n function _resultMaxBuffer(uint16 _resultMaxSize) private pure returns (bytes memory) {\r\n unchecked {\r\n uint256[] memory _buffer = new uint256[](_resultMaxSize / 32);\r\n for (uint _ix = 0; _ix < _buffer.length; _ix ++) {\r\n _buffer[_ix] = type(uint256).max;\r\n }\r\n return abi.encodePacked(\r\n _buffer,\r\n uint256((1 << (_resultMaxSize % 32)) - 1)\r\n );\r\n }\r\n }\r\n\r\n // ================================================================================================================\r\n // --- Overrides 'IWitnetOracle' ----------------------------------------------------------------------------\r\n\r\n /// @notice Estimate the minimum reward required for posting a data request.\r\n /// @dev Underestimates if the size of returned data is greater than `_resultMaxSize`. \r\n /// @param _gasPrice Expected gas price to pay upon posting the data request.\r\n /// @param _resultMaxSize Maximum expected size of returned data (in bytes).\r\n function estimateBaseFee(uint256 _gasPrice, uint16 _resultMaxSize)\r\n public view \r\n virtual override\r\n returns (uint256)\r\n {\r\n return _getCurrentL1Fee(_resultMaxSize) + WitnetOracleTrustableDefault.estimateBaseFee(_gasPrice, _resultMaxSize);\r\n }\r\n\r\n /// @notice Estimate the minimum reward required for posting a data request with a callback.\r\n /// @param _gasPrice Expected gas price to pay upon posting the data request.\r\n /// @param _callbackGasLimit Maximum gas to be spent when reporting the data request result.\r\n function estimateBaseFeeWithCallback(uint256 _gasPrice, uint24 _callbackGasLimit)\r\n public view\r\n virtual override\r\n returns (uint256)\r\n {\r\n return _getCurrentL1Fee(32) + WitnetOracleTrustableDefault.estimateBaseFeeWithCallback(_gasPrice, _callbackGasLimit);\r\n }\r\n\r\n // ================================================================================================================\r\n // --- Overrides 'IWitnetOracleReporter' --------------------------------------------------------------------------\r\n\r\n /// @notice Estimates the actual earnings (or loss), in WEI, that a reporter would get by reporting result to given query,\r\n /// @notice based on the gas price of the calling transaction. Data requesters should consider upgrading the reward on \r\n /// @notice queries providing no actual earnings.\r\n function estimateReportEarnings(\r\n uint256[] calldata _witnetQueryIds, \r\n bytes calldata _reportTxMsgData,\r\n uint256 _reportTxGasPrice, \r\n uint256 _nanoWitPrice\r\n )\r\n external view\r\n virtual override\r\n returns (uint256 _revenues, uint256 _expenses)\r\n {\r\n for (uint _ix = 0; _ix < _witnetQueryIds.length; _ix ++) {\r\n if (WitnetOracleDataLib.seekQueryStatus(_witnetQueryIds[_ix]) == WitnetV2.QueryStatus.Posted) {\r\n WitnetV2.Request storage __request = WitnetOracleDataLib.seekQueryRequest(_witnetQueryIds[_ix]);\r\n if (__request.gasCallback > 0) {\r\n _expenses += WitnetOracleTrustableDefault.estimateBaseFeeWithCallback(\r\n _reportTxGasPrice, \r\n __request.gasCallback\r\n );\r\n } else {\r\n if (__request.witnetRAD != bytes32(0)) {\r\n _expenses += WitnetOracleTrustableDefault.estimateBaseFee(\r\n _reportTxGasPrice, \r\n registry.lookupRadonRequestResultMaxSize(__request.witnetRAD)\r\n );\r\n } else {\r\n // todo: improve profit estimation accuracy if reporting on deleted query\r\n _expenses += WitnetOracleTrustableDefault.estimateBaseFee(\r\n _reportTxGasPrice, \r\n uint16(0)\r\n ); \r\n }\r\n }\r\n _expenses += __request.witnetSLA.nanoWitTotalFee() * _nanoWitPrice;\r\n _revenues += __request.evmReward;\r\n }\r\n }\r\n _expenses += __gasPriceOracleL1.getL1Fee(_reportTxMsgData);\r\n }\r\n}\r\n", "sourcePath": "C:\\Users\\guill\\github\\witnet\\witnet-solidity-bridge\\contracts\\core\\customs\\WitnetOracleTrustableOvm2.sol", "ast": { "absolutePath": "project:/contracts/core/customs/WitnetOracleTrustableOvm2.sol", "exportedSymbols": { "Context": [ 509 ], "ERC165": [ 602 ], "IERC165": [ 614 ], "IERC20": [ 479 ], "IWitnetConsumer": [ 12829 ], "IWitnetOracle": [ 13265 ], "IWitnetOracleEvents": [ 13315 ], "IWitnetOracleReporter": [ 13398 ], "IWitnetRequestBoardAdminACLs": [ 13758 ], "IWitnetRequestBytecodes": [ 13979 ], "IWitnetRequestFactory": [ 14002 ], "Initializable": [ 253 ], "OVM_GasPriceOracle": [ 4333 ], "Ownable": [ 401 ], "Ownable2Step": [ 24094 ], "Payable": [ 24145 ], "Proxiable": [ 24189 ], "ReentrancyGuard": [ 578 ], "Upgradeable": [ 24304 ], "Witnet": [ 17557 ], "WitnetBuffer": [ 19191 ], "WitnetCBOR": [ 20734 ], "WitnetErrorsLib": [ 23206 ], "WitnetOracle": [ 749 ], "WitnetOracleDataLib": [ 12396 ], "WitnetOracleTrustableBase": [ 6817 ], "WitnetOracleTrustableDefault": [ 7013 ], "WitnetOracleTrustableOvm2": [ 4645 ], "WitnetProxy": [ 3700 ], "WitnetRequestBytecodes": [ 849 ], "WitnetRequestFactory": [ 880 ], "WitnetUpgradableBase": [ 3887 ], "WitnetV2": [ 23640 ] }, "id": 4646, "license": "MIT", "nodeType": "SourceUnit", "nodes": [ { "id": 4323, "literals": [ "solidity", ">=", "0.7", ".0", "<", "0.9", ".0" ], "nodeType": "PragmaDirective", "src": "79:31:32" }, { "id": 4324, "literals": [ "experimental", "ABIEncoderV2" ], "nodeType": "PragmaDirective", "src": "112:33:32" }, { "absolutePath": "project:/contracts/core/defaults/WitnetOracleTrustableDefault.sol", "file": "../defaults/WitnetOracleTrustableDefault.sol", "id": 4325, "nameLocation": "-1:-1:-1", "nodeType": "ImportDirective", "scope": 4646, "sourceUnit": 7014, "src": "149:54:32", "symbolAliases": [], "unitAlias": "" }, { "abstract": false, "baseContracts": [], "canonicalName": "OVM_GasPriceOracle", "contractDependencies": [], "contractKind": "interface", "fullyImplemented": false, "id": 4333, "linearizedBaseContracts": [ 4333 ], "name": "OVM_GasPriceOracle", "nameLocation": "247:18:32", "nodeType": "ContractDefinition", "nodes": [ { "functionSelector": "49948e0e", "id": 4332, "implemented": false, "kind": "function", "modifiers": [], "name": "getL1Fee", "nameLocation": "282:8:32", "nodeType": "FunctionDefinition", "parameters": { "id": 4328, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 4327, "mutability": "mutable", "name": "_data", "nameLocation": "306:5:32", "nodeType": "VariableDeclaration", "scope": 4332, "src": "291:20:32", "stateVariable": false, "storageLocation": "calldata", "typeDescriptions": { "typeIdentifier": "t_bytes_calldata_ptr", "typeString": "bytes" }, "typeName": { "id": 4326, "name": "bytes", "nodeType": "ElementaryTypeName", "src": "291:5:32", "typeDescriptions": { "typeIdentifier": "t_bytes_storage_ptr", "typeString": "bytes" } }, "visibility": "internal" } ], "src": "290:22:32" }, "returnParameters": { "id": 4331, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 4330, "mutability": "mutable", "name": "", "nameLocation": "-1:-1:-1", "nodeType": "VariableDeclaration", "scope": 4332, "src": "336:7:32", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 4329, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "336:7:32", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "visibility": "internal" } ], "src": "335:9:32" }, "scope": 4333, "src": "273:72:32", "stateMutability": "view", "virtual": false, "visibility": "external" } ], "scope": 4646, "src": "237:111:32", "usedErrors": [], "usedEvents": [] }, { "abstract": false, "baseContracts": [ { "baseName": { "id": 4335, "name": "WitnetOracleTrustableDefault", "nameLocations": [ "791:28:32" ], "nodeType": "IdentifierPath", "referencedDeclaration": 7013, "src": "791:28:32" }, "id": 4336, "nodeType": "InheritanceSpecifier", "src": "791:28:32" } ], "canonicalName": "WitnetOracleTrustableOvm2", "contractDependencies": [], "contractKind": "contract", "documentation": { "id": 4334, "nodeType": "StructuredDocumentation", "src": "352:386:32", "text": "@title Witnet Request Board \"trustable\" implementation contract.\n @notice Contract to bridge requests to Witnet Decentralized Oracle Network.\n @dev This contract enables posting requests that Witnet bridges will insert into the Witnet network.\n The result of the requests will be posted back to this contract by the bridge nodes too.\n @author The Witnet Foundation" }, "fullyImplemented": true, "id": 4645, "linearizedBaseContracts": [ 4645, 7013, 6817, 24145, 13758, 13398, 749, 13315, 13265, 3887, 578, 24304, 24189, 253, 24094, 401, 509 ], "name": "WitnetOracleTrustableOvm2", "nameLocation": "747:25:32", "nodeType": "ContractDefinition", "nodes": [ { "global": false, "id": 4340, "libraryName": { "id": 4337, "name": "WitnetV2", "nameLocations": [ "834:8:32" ], "nodeType": "IdentifierPath", "referencedDeclaration": 23640, "src": "834:8:32" }, "nodeType": "UsingForDirective", "src": "828:37:32", "typeName": { "id": 4339, "nodeType": "UserDefinedTypeName", "pathNode": { "id": 4338, "name": "WitnetV2.RadonSLA", "nameLocations": [ "847:8:32", "856:8:32" ], "nodeType": "IdentifierPath", "referencedDeclaration": 23503, "src": "847:17:32" }, "referencedDeclaration": 23503, "src": "847:17:32", "typeDescriptions": { "typeIdentifier": "t_struct$_RadonSLA_$23503_storage_ptr", "typeString": "struct WitnetV2.RadonSLA" } } }, { "baseFunctions": [ 6836 ], "body": { "id": 4351, "nodeType": "Block", "src": "943:62:32", "statements": [ { "expression": { "expression": { "arguments": [ { "id": 4347, "name": "WitnetOracleTrustableOvm2", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4645, "src": "966:25:32", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_WitnetOracleTrustableOvm2_$4645_$", "typeString": "type(contract WitnetOracleTrustableOvm2)" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_type$_t_contract$_WitnetOracleTrustableOvm2_$4645_$", "typeString": "type(contract WitnetOracleTrustableOvm2)" } ], "id": 4346, "name": "type", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4294967269, "src": "961:4:32", "typeDescriptions": { "typeIdentifier": "t_function_metatype_pure$__$returns$__$", "typeString": "function () pure" } }, "id": 4348, "isConstant": false, "isLValue": false, "isPure": true, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], "names": [], "nodeType": "FunctionCall", "src": "961:31:32", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_magic_meta_type_t_contract$_WitnetOracleTrustableOvm2_$4645", "typeString": "type(contract WitnetOracleTrustableOvm2)" } }, "id": 4349, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "memberLocation": "993:4:32", "memberName": "name", "nodeType": "MemberAccess", "src": "961:36:32", "typeDescriptions": { "typeIdentifier": "t_string_memory_ptr", "typeString": "string memory" } }, "functionReturnParameters": 4345, "id": 4350, "nodeType": "Return", "src": "954:43:32" } ] }, "functionSelector": "bff852fa", "id": 4352, "implemented": true, "kind": "function", "modifiers": [], "name": "class", "nameLocation": "882:5:32", "nodeType": "FunctionDefinition", "overrides": { "id": 4342, "nodeType": "OverrideSpecifier", "overrides": [], "src": "898:8:32" }, "parameters": { "id": 4341, "nodeType": "ParameterList", "parameters": [], "src": "887:2:32" }, "returnParameters": { "id": 4345, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 4344, "mutability": "mutable", "name": "", "nameLocation": "-1:-1:-1", "nodeType": "VariableDeclaration", "scope": 4352, "src": "928:13:32", "stateVariable": false, "storageLocation": "memory", "typeDescriptions": { "typeIdentifier": "t_string_memory_ptr", "typeString": "string" }, "typeName": { "id": 4343, "name": "string", "nodeType": "ElementaryTypeName", "src": "928:6:32", "typeDescriptions": { "typeIdentifier": "t_string_storage_ptr", "typeString": "string" } }, "visibility": "internal" } ], "src": "927:15:32" }, "scope": 4645, "src": "873:132:32", "stateMutability": "view", "virtual": true, "visibility": "public" }, { "body": { "id": 4389, "nodeType": "Block", "src": "1713:102:32", "statements": [ { "expression": { "id": 4387, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "id": 4383, "name": "__gasPriceOracleL1", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4393, "src": "1724:18:32", "typeDescriptions": { "typeIdentifier": "t_contract$_OVM_GasPriceOracle_$4333", "typeString": "contract OVM_GasPriceOracle" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": { "arguments": [ { "hexValue": "307834323030303030303030303030303030303030303030303030303030303030303030303030303046", "id": 4385, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1764:42:32", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "value": "0x420000000000000000000000000000000000000F" } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address", "typeString": "address" } ], "id": 4384, "name": "OVM_GasPriceOracle", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4333, "src": "1745:18:32", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_OVM_GasPriceOracle_$4333_$", "typeString": "type(contract OVM_GasPriceOracle)" } }, "id": 4386, "isConstant": false, "isLValue": false, "isPure": true, "kind": "typeConversion", "lValueRequested": false, "nameLocations": [], "names": [], "nodeType": "FunctionCall", "src": "1745:62:32", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_contract$_OVM_GasPriceOracle_$4333", "typeString": "contract OVM_GasPriceOracle" } }, "src": "1724:83:32", "typeDescriptions": { "typeIdentifier": "t_contract$_OVM_GasPriceOracle_$4333", "typeString": "contract OVM_GasPriceOracle" } }, "id": 4388, "nodeType": "ExpressionStatement", "src": "1724:83:32" } ] }, "id": 4390, "implemented": true, "kind": "constructor", "modifiers": [ { "arguments": [ { "id": 4373, "name": "_factory", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4355, "src": "1444:8:32", "typeDescriptions": { "typeIdentifier": "t_contract$_WitnetRequestFactory_$880", "typeString": "contract WitnetRequestFactory" } }, { "id": 4374, "name": "_registry", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4358, "src": "1467:9:32", "typeDescriptions": { "typeIdentifier": "t_contract$_WitnetRequestBytecodes_$849", "typeString": "contract WitnetRequestBytecodes" } }, { "id": 4375, "name": "_upgradable", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4360, "src": "1491:11:32", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, { "id": 4376, "name": "_versionTag", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4362, "src": "1517:11:32", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, { "id": 4377, "name": "_reportResultGasBase", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4364, "src": "1543:20:32", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, { "id": 4378, "name": "_reportResultWithCallbackGasBase", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4366, "src": "1578:32:32", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, { "id": 4379, "name": "_reportResultWithCallbackRevertGasBase", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4368, "src": "1625:38:32", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, { "id": 4380, "name": "_sstoreFromZeroGas", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4370, "src": "1678:18:32", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } ], "id": 4381, "kind": "baseConstructorSpecifier", "modifierName": { "id": 4372, "name": "WitnetOracleTrustableDefault", "nameLocations": [ "1401:28:32" ], "nodeType": "IdentifierPath", "referencedDeclaration": 7013, "src": "1401:28:32" }, "nodeType": "ModifierInvocation", "src": "1401:306:32" } ], "name": "", "nameLocation": "-1:-1:-1", "nodeType": "FunctionDefinition", "parameters": { "id": 4371, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 4355, "mutability": "mutable", "name": "_factory", "nameLocation": "1060:8:32", "nodeType": "VariableDeclaration", "scope": 4390, "src": "1039:29:32", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_contract$_WitnetRequestFactory_$880", "typeString": "contract WitnetRequestFactory" }, "typeName": { "id": 4354, "nodeType": "UserDefinedTypeName", "pathNode": { "id": 4353, "name": "WitnetRequestFactory", "nameLocations": [ "1039:20:32" ], "nodeType": "IdentifierPath", "referencedDeclaration": 880, "src": "1039:20:32" }, "referencedDeclaration": 880, "src": "1039:20:32", "typeDescriptions": { "typeIdentifier": "t_contract$_WitnetRequestFactory_$880", "typeString": "contract WitnetRequestFactory" } }, "visibility": "internal" }, { "constant": false, "id": 4358, "mutability": "mutable", "name": "_registry", "nameLocation": "1106:9:32", "nodeType": "VariableDeclaration", "scope": 4390, "src": "1083:32:32", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_contract$_WitnetRequestBytecodes_$849", "typeString": "contract WitnetRequestBytecodes" }, "typeName": { "id": 4357, "nodeType": "UserDefinedTypeName", "pathNode": { "id": 4356, "name": "WitnetRequestBytecodes", "nameLocations": [ "1083:22:32" ], "nodeType": "IdentifierPath", "referencedDeclaration": 849, "src": "1083:22:32" }, "referencedDeclaration": 849, "src": "1083:22:32", "typeDescriptions": { "typeIdentifier": "t_contract$_WitnetRequestBytecodes_$849", "typeString": "contract WitnetRequestBytecodes" } }, "visibility": "internal" }, { "constant": false, "id": 4360, "mutability": "mutable", "name": "_upgradable", "nameLocation": "1135:11:32", "nodeType": "VariableDeclaration", "scope": 4390, "src": "1130:16:32", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" }, "typeName": { "id": 4359, "name": "bool", "nodeType": "ElementaryTypeName", "src": "1130:4:32", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "visibility": "internal" }, { "constant": false, "id": 4362, "mutability": "mutable", "name": "_versionTag", "nameLocation": "1169:11:32", "nodeType": "VariableDeclaration", "scope": 4390, "src": "1161:19:32", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" }, "typeName": { "id": 4361, "name": "bytes32", "nodeType": "ElementaryTypeName", "src": "1161:7:32", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, "visibility": "internal" }, { "constant": false, "id": 4364, "mutability": "mutable", "name": "_reportResultGasBase", "nameLocation": "1203:20:32", "nodeType": "VariableDeclaration", "scope": 4390, "src": "1195:28:32", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 4363, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1195:7:32", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "visibility": "internal" }, { "constant": false, "id": 4366, "mutability": "mutable", "name": "_reportResultWithCallbackGasBase", "nameLocation": "1246:32:32", "nodeType": "VariableDeclaration", "scope": 4390, "src": "1238:40:32", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 4365, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1