UNPKG

@gnosis.pm/hg-contracts

Version:

Collection of smart contracts for the Gnosis prediction market platform

889 lines 35.9 kB
{ "contractName": "ERC1155TokenReceiver", "abi": [ { "constant": true, "inputs": [ { "name": "interfaceId", "type": "bytes4" } ], "name": "supportsInterface", "outputs": [ { "name": "", "type": "bool" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [ { "name": "operator", "type": "address" }, { "name": "from", "type": "address" }, { "name": "ids", "type": "uint256[]" }, { "name": "values", "type": "uint256[]" }, { "name": "data", "type": "bytes" } ], "name": "onERC1155BatchReceived", "outputs": [ { "name": "", "type": "bytes4" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "operator", "type": "address" }, { "name": "from", "type": "address" }, { "name": "id", "type": "uint256" }, { "name": "value", "type": "uint256" }, { "name": "data", "type": "bytes" } ], "name": "onERC1155Received", "outputs": [ { "name": "", "type": "bytes4" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "payable": false, "stateMutability": "nonpayable", "type": "constructor" } ], "bytecode": "0x", "deployedBytecode": "0x", "sourceMap": "", "deployedSourceMap": "", "source": "pragma solidity ^0.5.0;\n\nimport \"./IERC1155TokenReceiver.sol\";\nimport \"openzeppelin-solidity/contracts/introspection/ERC165.sol\";\n\ncontract ERC1155TokenReceiver is ERC165, IERC1155TokenReceiver {\n constructor() public {\n _registerInterface(\n ERC1155TokenReceiver(0).onERC1155Received.selector ^\n ERC1155TokenReceiver(0).onERC1155BatchReceived.selector\n );\n }\n}\n", "sourcePath": "/home/alan/src/github.com/gnosis/hg-contracts/contracts/ERC1155/ERC1155TokenReceiver.sol", "ast": { "absolutePath": "/home/alan/src/github.com/gnosis/hg-contracts/contracts/ERC1155/ERC1155TokenReceiver.sol", "exportedSymbols": { "ERC1155TokenReceiver": [ 629 ] }, "id": 630, "nodeType": "SourceUnit", "nodes": [ { "id": 604, "literals": [ "solidity", "^", "0.5", ".0" ], "nodeType": "PragmaDirective", "src": "0:23:1" }, { "absolutePath": "/home/alan/src/github.com/gnosis/hg-contracts/contracts/ERC1155/IERC1155TokenReceiver.sol", "file": "./IERC1155TokenReceiver.sol", "id": 605, "nodeType": "ImportDirective", "scope": 630, "sourceUnit": 779, "src": "25:37:1", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "openzeppelin-solidity/contracts/introspection/ERC165.sol", "file": "openzeppelin-solidity/contracts/introspection/ERC165.sol", "id": 606, "nodeType": "ImportDirective", "scope": 630, "sourceUnit": 2550, "src": "63:66:1", "symbolAliases": [], "unitAlias": "" }, { "baseContracts": [ { "arguments": null, "baseName": { "contractScope": null, "id": 607, "name": "ERC165", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 2549, "src": "164:6:1", "typeDescriptions": { "typeIdentifier": "t_contract$_ERC165_$2549", "typeString": "contract ERC165" } }, "id": 608, "nodeType": "InheritanceSpecifier", "src": "164:6:1" }, { "arguments": null, "baseName": { "contractScope": null, "id": 609, "name": "IERC1155TokenReceiver", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 778, "src": "172:21:1", "typeDescriptions": { "typeIdentifier": "t_contract$_IERC1155TokenReceiver_$778", "typeString": "contract IERC1155TokenReceiver" } }, "id": 610, "nodeType": "InheritanceSpecifier", "src": "172:21:1" } ], "contractDependencies": [ 778, 2549, 2559 ], "contractKind": "contract", "documentation": null, "fullyImplemented": false, "id": 629, "linearizedBaseContracts": [ 629, 778, 2549, 2559 ], "name": "ERC1155TokenReceiver", "nodeType": "ContractDefinition", "nodes": [ { "body": { "id": 627, "nodeType": "Block", "src": "221:179:1", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "commonType": { "typeIdentifier": "t_bytes4", "typeString": "bytes4" }, "id": 624, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "expression": { "argumentTypes": null, "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "hexValue": "30", "id": 615, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "284:1:1", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" } ], "id": 614, "name": "ERC1155TokenReceiver", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 629, "src": "263:20:1", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_ERC1155TokenReceiver_$629_$", "typeString": "type(contract ERC1155TokenReceiver)" } }, "id": 616, "isConstant": false, "isLValue": false, "isPure": true, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "263:23:1", "typeDescriptions": { "typeIdentifier": "t_contract$_ERC1155TokenReceiver_$629", "typeString": "contract ERC1155TokenReceiver" } }, "id": 617, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "onERC1155Received", "nodeType": "MemberAccess", "referencedDeclaration": 760, "src": "263:41:1", "typeDescriptions": { "typeIdentifier": "t_function_external_nonpayable$_t_address_$_t_address_$_t_uint256_$_t_uint256_$_t_bytes_memory_ptr_$returns$_t_bytes4_$", "typeString": "function (address,address,uint256,uint256,bytes memory) external returns (bytes4)" } }, "id": 618, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "selector", "nodeType": "MemberAccess", "referencedDeclaration": null, "src": "263:50:1", "typeDescriptions": { "typeIdentifier": "t_bytes4", "typeString": "bytes4" } }, "nodeType": "BinaryOperation", "operator": "^", "rightExpression": { "argumentTypes": null, "expression": { "argumentTypes": null, "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "hexValue": "30", "id": 620, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "349:1:1", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" } ], "id": 619, "name": "ERC1155TokenReceiver", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 629, "src": "328:20:1", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_ERC1155TokenReceiver_$629_$", "typeString": "type(contract ERC1155TokenReceiver)" } }, "id": 621, "isConstant": false, "isLValue": false, "isPure": true, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "328:23:1", "typeDescriptions": { "typeIdentifier": "t_contract$_ERC1155TokenReceiver_$629", "typeString": "contract ERC1155TokenReceiver" } }, "id": 622, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "onERC1155BatchReceived", "nodeType": "MemberAccess", "referencedDeclaration": 777, "src": "328:46:1", "typeDescriptions": { "typeIdentifier": "t_function_external_nonpayable$_t_address_$_t_address_$_t_array$_t_uint256_$dyn_memory_ptr_$_t_array$_t_uint256_$dyn_memory_ptr_$_t_bytes_memory_ptr_$returns$_t_bytes4_$", "typeString": "function (address,address,uint256[] memory,uint256[] memory,bytes memory) external returns (bytes4)" } }, "id": 623, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "selector", "nodeType": "MemberAccess", "referencedDeclaration": null, "src": "328:55:1", "typeDescriptions": { "typeIdentifier": "t_bytes4", "typeString": "bytes4" } }, "src": "263:120:1", "typeDescriptions": { "typeIdentifier": "t_bytes4", "typeString": "bytes4" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bytes4", "typeString": "bytes4" } ], "id": 613, "name": "_registerInterface", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 2548, "src": "231:18:1", "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$_t_bytes4_$returns$__$", "typeString": "function (bytes4)" } }, "id": 625, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "231:162:1", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } }, "id": 626, "nodeType": "ExpressionStatement", "src": "231:162:1" } ] }, "documentation": null, "id": 628, "implemented": true, "kind": "constructor", "modifiers": [], "name": "", "nodeType": "FunctionDefinition", "parameters": { "id": 611, "nodeType": "ParameterList", "parameters": [], "src": "211:2:1" }, "returnParameters": { "id": 612, "nodeType": "ParameterList", "parameters": [], "src": "221:0:1" }, "scope": 629, "src": "200:200:1", "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" } ], "scope": 630, "src": "131:271:1" } ], "src": "0:403:1" }, "legacyAST": { "absolutePath": "/home/alan/src/github.com/gnosis/hg-contracts/contracts/ERC1155/ERC1155TokenReceiver.sol", "exportedSymbols": { "ERC1155TokenReceiver": [ 629 ] }, "id": 630, "nodeType": "SourceUnit", "nodes": [ { "id": 604, "literals": [ "solidity", "^", "0.5", ".0" ], "nodeType": "PragmaDirective", "src": "0:23:1" }, { "absolutePath": "/home/alan/src/github.com/gnosis/hg-contracts/contracts/ERC1155/IERC1155TokenReceiver.sol", "file": "./IERC1155TokenReceiver.sol", "id": 605, "nodeType": "ImportDirective", "scope": 630, "sourceUnit": 779, "src": "25:37:1", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "openzeppelin-solidity/contracts/introspection/ERC165.sol", "file": "openzeppelin-solidity/contracts/introspection/ERC165.sol", "id": 606, "nodeType": "ImportDirective", "scope": 630, "sourceUnit": 2550, "src": "63:66:1", "symbolAliases": [], "unitAlias": "" }, { "baseContracts": [ { "arguments": null, "baseName": { "contractScope": null, "id": 607, "name": "ERC165", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 2549, "src": "164:6:1", "typeDescriptions": { "typeIdentifier": "t_contract$_ERC165_$2549", "typeString": "contract ERC165" } }, "id": 608, "nodeType": "InheritanceSpecifier", "src": "164:6:1" }, { "arguments": null, "baseName": { "contractScope": null, "id": 609, "name": "IERC1155TokenReceiver", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 778, "src": "172:21:1", "typeDescriptions": { "typeIdentifier": "t_contract$_IERC1155TokenReceiver_$778", "typeString": "contract IERC1155TokenReceiver" } }, "id": 610, "nodeType": "InheritanceSpecifier", "src": "172:21:1" } ], "contractDependencies": [ 778, 2549, 2559 ], "contractKind": "contract", "documentation": null, "fullyImplemented": false, "id": 629, "linearizedBaseContracts": [ 629, 778, 2549, 2559 ], "name": "ERC1155TokenReceiver", "nodeType": "ContractDefinition", "nodes": [ { "body": { "id": 627, "nodeType": "Block", "src": "221:179:1", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "commonType": { "typeIdentifier": "t_bytes4", "typeString": "bytes4" }, "id": 624, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "expression": { "argumentTypes": null, "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "hexValue": "30", "id": 615, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "284:1:1", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" } ], "id": 614, "name": "ERC1155TokenReceiver", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 629, "src": "263:20:1", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_ERC1155TokenReceiver_$629_$", "typeString": "type(contract ERC1155TokenReceiver)" } }, "id": 616, "isConstant": false, "isLValue": false, "isPure": true, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "263:23:1", "typeDescriptions": { "typeIdentifier": "t_contract$_ERC1155TokenReceiver_$629", "typeString": "contract ERC1155TokenReceiver" } }, "id": 617, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "onERC1155Received", "nodeType": "MemberAccess", "referencedDeclaration": 760, "src": "263:41:1", "typeDescriptions": { "typeIdentifier": "t_function_external_nonpayable$_t_address_$_t_address_$_t_uint256_$_t_uint256_$_t_bytes_memory_ptr_$returns$_t_bytes4_$", "typeString": "function (address,address,uint256,uint256,bytes memory) external returns (bytes4)" } }, "id": 618, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "selector", "nodeType": "MemberAccess", "referencedDeclaration": null, "src": "263:50:1", "typeDescriptions": { "typeIdentifier": "t_bytes4", "typeString": "bytes4" } }, "nodeType": "BinaryOperation", "operator": "^", "rightExpression": { "argumentTypes": null, "expression": { "argumentTypes": null, "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "hexValue": "30", "id": 620, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "349:1:1", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" } ], "id": 619, "name": "ERC1155TokenReceiver", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 629, "src": "328:20:1", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_ERC1155TokenReceiver_$629_$", "typeString": "type(contract ERC1155TokenReceiver)" } }, "id": 621, "isConstant": false, "isLValue": false, "isPure": true, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "328:23:1", "typeDescriptions": { "typeIdentifier": "t_contract$_ERC1155TokenReceiver_$629", "typeString": "contract ERC1155TokenReceiver" } }, "id": 622, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "onERC1155BatchReceived", "nodeType": "MemberAccess", "referencedDeclaration": 777, "src": "328:46:1", "typeDescriptions": { "typeIdentifier": "t_function_external_nonpayable$_t_address_$_t_address_$_t_array$_t_uint256_$dyn_memory_ptr_$_t_array$_t_uint256_$dyn_memory_ptr_$_t_bytes_memory_ptr_$returns$_t_bytes4_$", "typeString": "function (address,address,uint256[] memory,uint256[] memory,bytes memory) external returns (bytes4)" } }, "id": 623, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "selector", "nodeType": "MemberAccess", "referencedDeclaration": null, "src": "328:55:1", "typeDescriptions": { "typeIdentifier": "t_bytes4", "typeString": "bytes4" } }, "src": "263:120:1", "typeDescriptions": { "typeIdentifier": "t_bytes4", "typeString": "bytes4" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bytes4", "typeString": "bytes4" } ], "id": 613, "name": "_registerInterface", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 2548, "src": "231:18:1", "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$_t_bytes4_$returns$__$", "typeString": "function (bytes4)" } }, "id": 625, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "231:162:1", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } }, "id": 626, "nodeType": "ExpressionStatement", "src": "231:162:1" } ] }, "documentation": null, "id": 628, "implemented": true, "kind": "constructor", "modifiers": [], "name": "", "nodeType": "FunctionDefinition", "parameters": { "id": 611, "nodeType": "ParameterList", "parameters": [], "src": "211:2:1" }, "returnParameters": { "id": 612, "nodeType": "ParameterList", "parameters": [], "src": "221:0:1" }, "scope": 629, "src": "200:200:1", "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" } ], "scope": 630, "src": "131:271:1" } ], "src": "0:403:1" }, "compiler": { "name": "solc", "version": "0.5.1+commit.c8a2cb62.Emscripten.clang" }, "networks": {}, "schemaVersion": "3.0.3", "updatedAt": "2019-06-08T17:32:19.208Z", "devdoc": { "methods": { "onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)": { "details": "Handles the receipt of a multiple ERC1155 token types. This function is called at the end of a `safeBatchTransferFrom` after the balances have been updated. To accept the transfer(s), this must return `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))` (i.e. 0xbc197c81, or its own function selector).", "params": { "data": "Additional data with no specified format", "from": "The address which previously owned the token", "ids": "An array containing ids of each token being transferred (order and length must match values array)", "operator": "The address which initiated the batch transfer (i.e. msg.sender)", "values": "An array containing amounts of each token being transferred (order and length must match ids array)" }, "return": "`bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))` if transfer is allowed" }, "onERC1155Received(address,address,uint256,uint256,bytes)": { "details": "Handles the receipt of a single ERC1155 token type. This function is called at the end of a `safeTransferFrom` after the balance has been updated. To accept the transfer, this must return `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))` (i.e. 0xf23a6e61, or its own function selector).", "params": { "data": "Additional data with no specified format", "from": "The address which previously owned the token", "id": "The ID of the token being transferred", "operator": "The address which initiated the transfer (i.e. msg.sender)", "value": "The amount of tokens being transferred" }, "return": "`bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))` if transfer is allowed" }, "supportsInterface(bytes4)": { "details": "See `IERC165.supportsInterface`. * Time complexity O(1), guaranteed to always use less than 30 000 gas." } } }, "userdoc": { "methods": {} } }