UNPKG

witnet-solidity-bridge

Version:

Witnet Solidity Bridge contracts for EVM-compatible chains

1,008 lines 56.9 kB
{ "contractName": "UsingWitRandomness", "abi": [ { "inputs": [], "name": "WIT_RANDOMNESS", "outputs": [ { "internalType": "contract WitRandomness", "name": "", "type": "address" } ], "stateMutability": "view", "type": "function" } ], "metadata": "{\"compiler\":{\"version\":\"0.8.30+commit.73712a01\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"WIT_RANDOMNESS\",\"outputs\":[{\"internalType\":\"contract WitRandomness\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"project:/contracts/mockups/UsingWitRandomness.sol\":\"UsingWitRandomness\"},\"evmVersion\":\"prague\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"project:/contracts/WitRandomness.sol\":{\"keccak256\":\"0x7accd2d28e3ad04761104048b775576ba5efc212eae4dc2dfe006506d95fb137\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://4daf83555177f9eb9278963a9873c2aaed1b28ad2ba27300b57f3fa195a265bc\",\"dweb:/ipfs/QmRWmasNnkFYfYy563TnGBVFgriNbV57KHTerPZLFYyU1J\"]},\"project:/contracts/interfaces/IWitAppliance.sol\":{\"keccak256\":\"0xd207ca54a1049445a3d99eea497d9b34c6dbdd44d771eee825e4c031bd2f447e\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://f81de32d868ff2881ed6fe97cc897e40b4b11d23cbe53a0e23cf3e68f9c0f0a3\",\"dweb:/ipfs/QmeeXmzmK5MAzt7Hf5DB2L81efKtTzZg9VbQ8sUiTqEk5c\"]},\"project:/contracts/interfaces/IWitOracleQueriable.sol\":{\"keccak256\":\"0xdb0da1e377a35a7d620f43cb583a876750a52d91da2b888f48042483ad9c4910\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://edfcdf3e96ec3c5de7438f82e3d5a1dc9af9eb29080044213dccb26ff978354c\",\"dweb:/ipfs/Qmap2FzSysh2fug88eortbsTM7itFygRzKc9HfV43ePMik\"]},\"project:/contracts/interfaces/IWitOracleQueriableConsumer.sol\":{\"keccak256\":\"0xe8143d2387d674022f453b57652998f53cbe4c21fe35e59421428142355c8ebf\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://6e6c3e3d3e7168a3fb75b1eca23d078d5240e5b02dac8a449d1ddf79256a34d8\",\"dweb:/ipfs/QmbGk4tQzTogTBVYiT8t3Gqtk6qDs5nyp9Z53GryTjKAm5\"]},\"project:/contracts/interfaces/IWitRandomness.sol\":{\"keccak256\":\"0x349b27a7ecb4ca22f87d4ab13714a010668a7014d9c37fdb91caa407981b889a\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://a53b9c8d63c973bb98790ef3305fbc24debaa2dadad1b48b82ffdbfce73e08b6\",\"dweb:/ipfs/QmSue9dMNK1V5ChooMBTtccmpx2JoiyktqTP1Ng6bSuUGx\"]},\"project:/contracts/interfaces/IWitRandomnessAdmin.sol\":{\"keccak256\":\"0xb5b9b2375509f03db5b1e198089f4b0cf4e4ebbd31a2a7b5d2480a743bebbcd2\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://0cade769eec375a3ec1cd4d376be54ee48a0e18786543f6ee396c0debfa4c04c\",\"dweb:/ipfs/QmY7AucsWp54PZVgMFjrJRt1n1DKCXb84ZXzTXnRZULYXF\"]},\"project:/contracts/interfaces/IWitRandomnessConsumer.sol\":{\"keccak256\":\"0x8006c81ac34c0797d31606164e6e0c6a7e97f0ba0f5228505bbc3d4fbcf16cdd\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://8cc71c0afed6dd296a808513b3119840490f76fb884ad35729669201446348bf\",\"dweb:/ipfs/QmQLs5jg8nugFgNu5psvGaCsMC6X1YoD6qV5nt7Gf5iAuk\"]},\"project:/contracts/interfaces/IWitRandomnessEvents.sol\":{\"keccak256\":\"0x005a56891f103c78ce015fbbcb9cf96f64e3810a70cd20dcdcce2963186788fc\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://6365a0bb99b2ac7990b74b33a4df7b045702362baf11998f8345f1a2530c29ae\",\"dweb:/ipfs/QmY2d5m2E7JwFT4EFzbrXZkiL4sSTowmosMHjSE3fTAwXf\"]},\"project:/contracts/interfaces/IWitRandomnessTypes.sol\":{\"keccak256\":\"0x52d825bf6bd6a2515116f993e939108f5412f5a05e304893ba81e9fcbfce4e09\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://60b3db141539544afc2701a873570a7b78639090e36b4bb7a57ae0d0dddeb9f4\",\"dweb:/ipfs/QmTWkwYdF4QMTeCFVcYNi9pWi3PwVeK29xgp946z8xtuiN\"]},\"project:/contracts/libs/Bech32.sol\":{\"keccak256\":\"0x14618323a0efe7586c20906a2e9cee7ad63baa976ff231c57f7f2d7d3707fb8b\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://a19f05fe84047a7a6d3d6fc39972b432e6e536aa70472386a9d7a6d9aab64a64\",\"dweb:/ipfs/QmcHwUY66yjiotRH4Q3kbRvSzcHyLQ1yHL3KbtQKiMhtZE\"]},\"project:/contracts/libs/Secp256k1.sol\":{\"keccak256\":\"0xbe686002da5004ff39dd70709f3820eba2afe9323ae9cb894009c161e4b1a666\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://18fab91775216de0707cea9ad285b10be09127461a13432fea358bf9cb2a0c2e\",\"dweb:/ipfs/QmeRUGsgstnM4hxM9hpkBf3L6cE5btirEaowcMxmuw3utj\"]},\"project:/contracts/libs/Witnet.sol\":{\"keccak256\":\"0x1d446c3e534e40e676d1763bfb2897fadfac8afed904ab757843d7d6770b0a6c\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://338fb1073f17d64e8d31bfe492d9475ce906788ee08e6489ce30413f91dc1328\",\"dweb:/ipfs/QmPe5QX2AGTnQFjse1Xttq4ZYWwYAiXoySb5VUui3PqPhk\"]},\"project:/contracts/libs/WitnetBuffer.sol\":{\"keccak256\":\"0x8e07aebe2954ab3e6f2d8eceedb12db7cf915c1f3e8630f4fa9999cecb1c78ec\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://ed6c54cc901183d61546e8fd15bd5ea8ef238ebc915642946071d435dd7481ea\",\"dweb:/ipfs/Qmcaqta7YjUSBbBUGqoh44bsCS6UqqoyHjBuz4qnKBShXM\"]},\"project:/contracts/libs/WitnetCBOR.sol\":{\"keccak256\":\"0xd99308373575cc10fb7f2ceb0f6a8625f3911275c1fa27811fae498d98d03d97\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://b4909a999d7b660a2dc54ca957b6eccfa523e2765fc4d6a2574dee7d5cd67b43\",\"dweb:/ipfs/QmWGQT4KDcfSFe1hcHVoWx6E4PhYMaod5iLpJCWBEeShzh\"]},\"project:/contracts/mockups/UsingWitRandomness.sol\":{\"keccak256\":\"0xa6035eef5679a471685b3e6426bfeb1c58d8aac1f37b3f35ec7d303b7986f698\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://99bda6627cb461d9674152b4b9d818c0c7032b2e095e603fc541b69759e72e80\",\"dweb:/ipfs/QmaAZQYBpYtwVNhtFvgPfseCuk8eVyBbieWhGS3R2tgYTs\"]}},\"version\":1}", "bytecode": "0x", "deployedBytecode": "0x", "immutableReferences": {}, "generatedSources": [], "deployedGeneratedSources": [], "sourceMap": "", "deployedSourceMap": "", "source": "// SPDX-License-Identifier: MIT\r\n\r\npragma solidity >=0.8.0 <0.9.0;\r\n\r\nimport {\r\n Witnet, \r\n WitRandomness, \r\n IWitRandomness\r\n} from \"../WitRandomness.sol\";\r\n\r\nabstract contract UsingWitRandomness {\r\n WitRandomness immutable public WIT_RANDOMNESS;\r\n \r\n constructor (address randomizer) {\r\n assert(\r\n randomizer.code.length > 0\r\n && WitRandomness(randomizer).specs() == type(IWitRandomness).interfaceId\r\n );\r\n WIT_RANDOMNESS = WitRandomness(randomizer); \r\n }\r\n\r\n /// Retrieves the result of keccak256-hashing the specified block number with the randomness value \r\n /// generated by the Witnet blockchain in response to the first non-failing randomize request solved \r\n /// after such block number.\r\n ///\r\n /// @dev Reverts if:\r\n /// i. no `randomize()` was queried on the `WIT_RANDOMNESS` contract for neither the specified block, nor afterwards.\r\n /// ii. the first non-failing `randomize()` request found on or after the specified block is not solved yet.\r\n /// iii. all `randomize()` requests that took place on or after the specified block were solved with errors.\r\n function _fetchRandomnessAfter(uint256 _blockNumber) virtual internal view returns (bytes32) {\r\n return keccak256(\r\n abi.encode(\r\n WIT_RANDOMNESS.fetchRandomnessAfter(_blockNumber),\r\n address(this)\r\n )\r\n );\r\n }\r\n\r\n /// Generates a pseudo-random number uniformly distributed within the range [0 .. _faces), \r\n /// by using the specified `_nonce` and `_seed`.\r\n /// @dev Fails under same conditions as `_fetchRandomnessAfter(uint256)` does.\r\n function _rollTheDice(uint64 _faces, uint256 _nonce, bytes32 _seed) internal pure returns (uint64) {\r\n return Witnet.randomUniformUint64(\r\n _faces,\r\n _nonce,\r\n _seed\r\n );\r\n }\r\n}\r\n", "sourcePath": "C:\\Users\\guill\\github\\guidiaz\\witnet-solidity-bridge\\contracts\\mockups\\UsingWitRandomness.sol", "ast": { "absolutePath": "project:/contracts/mockups/UsingWitRandomness.sol", "exportedSymbols": { "IWitRandomness": [ 28351 ], "UsingWitRandomness": [ 44462 ], "WitRandomness": [ 879 ], "Witnet": [ 40741 ] }, "id": 44463, "license": "MIT", "nodeType": "SourceUnit", "nodes": [ { "id": 44380, "literals": [ "solidity", ">=", "0.8", ".0", "<", "0.9", ".0" ], "nodeType": "PragmaDirective", "src": "35:31:121" }, { "absolutePath": "project:/contracts/WitRandomness.sol", "file": "../WitRandomness.sol", "id": 44384, "nameLocation": "-1:-1:-1", "nodeType": "ImportDirective", "scope": 44463, "sourceUnit": 880, "src": "70:95:121", "symbolAliases": [ { "foreign": { "id": 44381, "name": "Witnet", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 40741, "src": "84:6:121", "typeDescriptions": {} }, "nameLocation": "-1:-1:-1" }, { "foreign": { "id": 44382, "name": "WitRandomness", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 879, "src": "98:13:121", "typeDescriptions": {} }, "nameLocation": "-1:-1:-1" }, { "foreign": { "id": 44383, "name": "IWitRandomness", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 28351, "src": "119:14:121", "typeDescriptions": {} }, "nameLocation": "-1:-1:-1" } ], "unitAlias": "" }, { "abstract": true, "baseContracts": [], "canonicalName": "UsingWitRandomness", "contractDependencies": [], "contractKind": "contract", "fullyImplemented": true, "id": 44462, "linearizedBaseContracts": [ 44462 ], "name": "UsingWitRandomness", "nameLocation": "187:18:121", "nodeType": "ContractDefinition", "nodes": [ { "constant": false, "functionSelector": "ccac9949", "id": 44387, "mutability": "immutable", "name": "WIT_RANDOMNESS", "nameLocation": "244:14:121", "nodeType": "VariableDeclaration", "scope": 44462, "src": "213:45:121", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_contract$_WitRandomness_$879", "typeString": "contract WitRandomness" }, "typeName": { "id": 44386, "nodeType": "UserDefinedTypeName", "pathNode": { "id": 44385, "name": "WitRandomness", "nameLocations": [ "213:13:121" ], "nodeType": "IdentifierPath", "referencedDeclaration": 879, "src": "213:13:121" }, "referencedDeclaration": 879, "src": "213:13:121", "typeDescriptions": { "typeIdentifier": "t_contract$_WitRandomness_$879", "typeString": "contract WitRandomness" } }, "visibility": "public" }, { "body": { "id": 44417, "nodeType": "Block", "src": "304:224:121", "statements": [ { "expression": { "arguments": [ { "commonType": { "typeIdentifier": "t_bool", "typeString": "bool" }, "id": 44408, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 44397, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "expression": { "expression": { "id": 44393, "name": "randomizer", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 44389, "src": "336:10:121", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "id": 44394, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberLocation": "347:4:121", "memberName": "code", "nodeType": "MemberAccess", "src": "336:15:121", "typeDescriptions": { "typeIdentifier": "t_bytes_memory_ptr", "typeString": "bytes memory" } }, "id": 44395, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberLocation": "352:6:121", "memberName": "length", "nodeType": "MemberAccess", "src": "336:22:121", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": ">", "rightExpression": { "hexValue": "30", "id": 44396, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "361:1:121", "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" }, "src": "336:26:121", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "nodeType": "BinaryOperation", "operator": "&&", "rightExpression": { "commonType": { "typeIdentifier": "t_bytes4", "typeString": "bytes4" }, "id": 44407, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "arguments": [], "expression": { "argumentTypes": [], "expression": { "arguments": [ { "id": 44399, "name": "randomizer", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 44389, "src": "397:10:121", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address", "typeString": "address" } ], "id": 44398, "name": "WitRandomness", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 879, "src": "383:13:121", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_WitRandomness_$879_$", "typeString": "type(contract WitRandomness)" } }, "id": 44400, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "nameLocations": [], "names": [], "nodeType": "FunctionCall", "src": "383:25:121", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_contract$_WitRandomness_$879", "typeString": "contract WitRandomness" } }, "id": 44401, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberLocation": "409:5:121", "memberName": "specs", "nodeType": "MemberAccess", "referencedDeclaration": 878, "src": "383:31:121", "typeDescriptions": { "typeIdentifier": "t_function_external_pure$__$returns$_t_bytes4_$", "typeString": "function () pure external returns (bytes4)" } }, "id": 44402, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], "names": [], "nodeType": "FunctionCall", "src": "383:33:121", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_bytes4", "typeString": "bytes4" } }, "nodeType": "BinaryOperation", "operator": "==", "rightExpression": { "expression": { "arguments": [ { "id": 44404, "name": "IWitRandomness", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 28351, "src": "425:14:121", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_IWitRandomness_$28351_$", "typeString": "type(contract IWitRandomness)" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_type$_t_contract$_IWitRandomness_$28351_$", "typeString": "type(contract IWitRandomness)" } ], "id": 44403, "name": "type", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4294967269, "src": "420:4:121", "typeDescriptions": { "typeIdentifier": "t_function_metatype_pure$__$returns$__$", "typeString": "function () pure" } }, "id": 44405, "isConstant": false, "isLValue": false, "isPure": true, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], "names": [], "nodeType": "FunctionCall", "src": "420:20:121", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_magic_meta_type_t_contract$_IWitRandomness_$28351", "typeString": "type(contract IWitRandomness)" } }, "id": 44406, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "memberLocation": "441:11:121", "memberName": "interfaceId", "nodeType": "MemberAccess", "src": "420:32:121", "typeDescriptions": { "typeIdentifier": "t_bytes4", "typeString": "bytes4" } }, "src": "383:69:121", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "src": "336:116:121", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bool", "typeString": "bool" } ], "id": 44392, "name": "assert", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4294967293, "src": "315:6:121", "typeDescriptions": { "typeIdentifier": "t_function_assert_pure$_t_bool_$returns$__$", "typeString": "function (bool) pure" } }, "id": 44409, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], "names": [], "nodeType": "FunctionCall", "src": "315:148:121", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } }, "id": 44410, "nodeType": "ExpressionStatement", "src": "315:148:121" }, { "expression": { "id": 44415, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "id": 44411, "name": "WIT_RANDOMNESS", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 44387, "src": "474:14:121", "typeDescriptions": { "typeIdentifier": "t_contract$_WitRandomness_$879", "typeString": "contract WitRandomness" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": { "arguments": [ { "id": 44413, "name": "randomizer", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 44389, "src": "505:10:121", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address", "typeString": "address" } ], "id": 44412, "name": "WitRandomness", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 879, "src": "491:13:121", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_WitRandomness_$879_$", "typeString": "type(contract WitRandomness)" } }, "id": 44414, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "nameLocations": [], "names": [], "nodeType": "FunctionCall", "src": "491:25:121", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_contract$_WitRandomness_$879", "typeString": "contract WitRandomness" } }, "src": "474:42:121", "typeDescriptions": { "typeIdentifier": "t_contract$_WitRandomness_$879", "typeString": "contract WitRandomness" } }, "id": 44416, "nodeType": "ExpressionStatement", "src": "474:42:121" } ] }, "id": 44418, "implemented": true, "kind": "constructor", "modifiers": [], "name": "", "nameLocation": "-1:-1:-1", "nodeType": "FunctionDefinition", "parameters": { "id": 44390, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 44389, "mutability": "mutable", "name": "randomizer", "nameLocation": "292:10:121", "nodeType": "VariableDeclaration", "scope": 44418, "src": "284:18:121", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 44388, "name": "address", "nodeType": "ElementaryTypeName", "src": "284:7:121", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "visibility": "internal" } ], "src": "283:20:121" }, "returnParameters": { "id": 44391, "nodeType": "ParameterList", "parameters": [], "src": "304:0:121" }, "scope": 44462, "src": "271:257:121", "stateMutability": "nonpayable", "virtual": false, "visibility": "internal" }, { "body": { "id": 44440, "nodeType": "Block", "src": "1273:186:121", "statements": [ { "expression": { "arguments": [ { "arguments": [ { "arguments": [ { "id": 44431, "name": "_blockNumber", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 44421, "src": "1380:12:121", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint256", "typeString": "uint256" } ], "expression": { "id": 44429, "name": "WIT_RANDOMNESS", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 44387, "src": "1344:14:121", "typeDescriptions": { "typeIdentifier": "t_contract$_WitRandomness_$879", "typeString": "contract WitRandomness" } }, "id": 44430, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberLocation": "1359:20:121", "memberName": "fetchRandomnessAfter", "nodeType": "MemberAccess", "referencedDeclaration": 28212, "src": "1344:35:121", "typeDescriptions": { "typeIdentifier": "t_function_external_view$_t_uint256_$returns$_t_bytes32_$", "typeString": "function (uint256) view external returns (bytes32)" } }, "id": 44432, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], "names": [], "nodeType": "FunctionCall", "src": "1344:49:121", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, { "arguments": [ { "id": 44435, "name": "this", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4294967268, "src": "1420:4:121", "typeDescriptions": { "typeIdentifier": "t_contract$_UsingWitRandomness_$44462", "typeString": "contract UsingWitRandomness" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_contract$_UsingWitRandomness_$44462", "typeString": "contract UsingWitRandomness" } ], "id": 44434, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "1412:7:121", "typeDescriptions": { "typeIdentifier": "t_type$_t_address_$", "typeString": "type(address)" }, "typeName": { "id": 44433, "name": "address", "nodeType": "ElementaryTypeName", "src": "1412:7:121", "typeDescriptions": {} } }, "id": 44436, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "nameLocations": [], "names": [], "nodeType": "FunctionCall", "src": "1412:13:121", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bytes32", "typeString": "bytes32" }, { "typeIdentifier": "t_address", "typeString": "address" } ], "expression": { "id": 44427, "name": "abi", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4294967295, "src": "1315:3:121", "typeDescriptions": { "typeIdentifier": "t_magic_abi", "typeString": "abi" } }, "id": 44428, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "memberLocation": "1319:6:121", "memberName": "encode", "nodeType": "MemberAccess", "src": "1315:10:121", "typeDescriptions": { "typeIdentifier": "t_function_abiencode_pure$__$returns$_t_bytes_memory_ptr_$", "typeString": "function () pure returns (bytes memory)" } }, "id": 44437, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], "names": [], "nodeType": "FunctionCall", "src": "1315:125:121", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_bytes_memory_ptr", "typeString": "bytes memory" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bytes_memory_ptr", "typeString": "bytes memory" } ], "id": 44426, "name": "keccak256", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4294967288, "src": "1291:9:121", "typeDescriptions": { "typeIdentifier": "t_function_keccak256_pure$_t_bytes_memory_ptr_$returns$_t_bytes32_$", "typeString": "function (bytes memory) pure returns (bytes32)" } }, "id": 44438, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "nameLocations": [], "names": [], "nodeType": "FunctionCall", "src": "1291:160:121", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, "functionReturnParameters": 44425, "id": 44439, "nodeType": "Return", "src": "1284:167:121" } ] }, "documentation": { "id": 44419, "nodeType": "StructuredDocumentation", "src": "536:638:121", "text": "Retrieves the result of keccak256-hashing the specified block number with the randomness value \n generated by the Witnet blockchain in response to the first non-failing randomize request solved \n after such block number.\n @dev Reverts if:\n i. no `randomize()` was queried on the `WIT_RANDOMNESS` contract for neither the specified block, nor afterwards.\n ii. the first non-failing `randomize()` request found on or after the specified block is not solved yet.\n iii. all `randomize()` requests that took place on or after the specified block were solved with errors." }, "id": 44441, "implemented": true, "kind": "function", "modifiers": [], "name": "_fetchRandomnessAfter", "nameLocation": "1189:21:121", "nodeType": "FunctionDefinition", "parameters": { "id": 44422, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 44421, "mutability": "mutable", "name": "_blockNumber", "nameLocation": "1219:12:121", "nodeType": "VariableDeclaration", "scope": 44441, "src": "1211:20:121", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 44420, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1211:7:121", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "visibility": "internal" } ], "src": "1210:22:121" }, "returnParameters": { "id": 44425, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 44424, "mutability": "mutable", "name": "", "nameLocation": "-1:-1:-1", "nodeType": "VariableDeclaration", "scope": 44441, "src": "1264:7:121", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" }, "typeName": { "id": 44423, "name": "bytes32", "nodeType": "ElementaryTypeName", "src": "1264:7:121", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } }, "visibility": "internal" } ], "src": "1263:9:121" }, "scope": 44462, "src": "1180:279:121", "stateMutability": "view", "virtual": true, "visibility": "internal" }, { "body": { "id": 44460, "nodeType": "Block", "src": "1801:125:121", "statements": [ { "expression": { "arguments": [ { "id": 44455, "name": "_faces", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 44444, "src": "1860:6:121", "typeDescriptions": { "typeIdentifier": "t_uint64", "typeString": "uint64" } }, { "id": 44456, "name": "_nonce", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 44446, "src": "1881:6:121", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, { "id": 44457, "name": "_seed", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 44448, "src": "1902:5:121", "typeDescriptions": { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint64", "typeString": "uint64" }, { "typeIdentifier": "t_uint256", "typeString": "uint256" }, { "typeIdentifier": "t_bytes32", "typeString": "bytes32" } ], "expression": { "id": 44453, "name": "Witnet", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 40741, "src": "1819:6:121", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_Witnet_$40741_$", "typeString": "type(library Witnet)" } }, "id": 44454, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberLocation": "1826:19:121", "memberName": "randomUniformUint64", "nodeType": "MemberAccess", "referencedDeclaration": 40300, "src": "1819:26:121", "typeDescriptions": { "typeIdentifier": "t_function_intern