UNPKG

hardlydifficult-eth

Version:

A collection of reusable contracts and Javascript helpers for Ethereum.

996 lines (995 loc) 104 kB
{ "contractName": "ApproveAndCall", "abi": [ { "inputs": [ { "internalType": "address", "name": "_token", "type": "address" }, { "internalType": "uint256", "name": "_amount", "type": "uint256" }, { "internalType": "address", "name": "_contract", "type": "address" }, { "internalType": "bytes", "name": "_callData", "type": "bytes" } ], "name": "approveAndCall", "outputs": [], "stateMutability": "nonpayable", "type": "function" } ], "metadata": "{\"compiler\":{\"version\":\"0.6.10+commit.00c0fcaf\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_contract\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"_callData\",\"type\":\"bytes\"}],\"name\":\"approveAndCall\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"methods\":{},\"title\":\"Approve this contract to spend your ERC-20 tokens, and then you can call various contracts without an additional approval step.\"},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"project:/contracts/tokens/ERC20/ApproveAndCall.sol\":\"ApproveAndCall\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":2000000},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"keccak256\":\"0x5f02220344881ce43204ae4a6281145a67bc52c2bb1290a791857df3d19d78f5\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://24427744bd3e6cb73c17010119af12a318289c0253a4d9acb8576c9fb3797b08\",\"dweb:/ipfs/QmTLDqpKRBuxGxRAmjgXt9AkXyACW3MtKzi7PYjm5iMfGC\"]},\"project:/contracts/proxies/CallContract.sol\":{\"keccak256\":\"0xb30b0e77e31fd3e37b3a2028fb4ebcf7789d4225feb011b921b8a25447a09b68\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://ee3c46722099a245797c4116382ba9fbdc338274d4ed440e97d15ff761611efa\",\"dweb:/ipfs/QmU2Zb2vmGeEjPoa6ZbCVGgjw2ogdnuKQeRCSoiv7SK4ro\"]},\"project:/contracts/tokens/ERC20/ApproveAndCall.sol\":{\"keccak256\":\"0x589ab3b6e81bbe37fb897cea42a81a1c2ed41605bcdd4d23611913820f23c251\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://d3169775f52fa383b75971647c5aaccd71c2632be64515578fac1e39e72663fc\",\"dweb:/ipfs/QmQiqszcdor8aDg7vURP1eeYkA8k2C3T3GBGRidwsQae4G\"]}},\"version\":1}", "bytecode": "0x608060405234801561001057600080fd5b5061047f806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063e6fb99ea14610030575b600080fd5b6101026004803603608081101561004657600080fd5b73ffffffffffffffffffffffffffffffffffffffff823581169260208101359260408201359092169181019060808101606082013564010000000081111561008d57600080fd5b82018360208201111561009f57600080fd5b803590602001918460018302840111640100000000831117156100c157600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610104945050505050565b005b604080517f23b872dd00000000000000000000000000000000000000000000000000000000815233600482015230602482015260448101859052905173ffffffffffffffffffffffffffffffffffffffff8616916323b872dd9160648083019260209291908290030181600087803b15801561017f57600080fd5b505af1158015610193573d6000803e3d6000fd5b505050506040513d60208110156101a957600080fd5b5050604080517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301526024820186905291519186169163095ea7b3916044808201926020929091908290030181600087803b15801561022457600080fd5b505af1158015610238573d6000803e3d6000fd5b505050506040513d602081101561024e57600080fd5b50610279905073ffffffffffffffffffffffffffffffffffffffff831682600063ffffffff6103c616565b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905160009173ffffffffffffffffffffffffffffffffffffffff8716916370a0823191602480820192602092909190829003018186803b1580156102e957600080fd5b505afa1580156102fd573d6000803e3d6000fd5b505050506040513d602081101561031357600080fd5b5051905080156103bf57604080517fa9059cbb00000000000000000000000000000000000000000000000000000000815233600482015260248101839052905173ffffffffffffffffffffffffffffffffffffffff87169163a9059cbb9160448083019260209291908290030181600087803b15801561039257600080fd5b505af11580156103a6573d6000803e3d6000fd5b505050506040513d60208110156103bc57600080fd5b50505b5050505050565b600080600084516020860185885af190508061044357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f494e5445524e414c5f434f4e54524143545f43414c4c5f4641494c4544000000604482015290519081900360640190fd5b5050505056fea26469706673582212202d09d0da65aea64af27f43f17ab033cb40e5cf6beffcd8e05c7f0212fdd3a53064736f6c634300060a0033", "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063e6fb99ea14610030575b600080fd5b6101026004803603608081101561004657600080fd5b73ffffffffffffffffffffffffffffffffffffffff823581169260208101359260408201359092169181019060808101606082013564010000000081111561008d57600080fd5b82018360208201111561009f57600080fd5b803590602001918460018302840111640100000000831117156100c157600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610104945050505050565b005b604080517f23b872dd00000000000000000000000000000000000000000000000000000000815233600482015230602482015260448101859052905173ffffffffffffffffffffffffffffffffffffffff8616916323b872dd9160648083019260209291908290030181600087803b15801561017f57600080fd5b505af1158015610193573d6000803e3d6000fd5b505050506040513d60208110156101a957600080fd5b5050604080517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301526024820186905291519186169163095ea7b3916044808201926020929091908290030181600087803b15801561022457600080fd5b505af1158015610238573d6000803e3d6000fd5b505050506040513d602081101561024e57600080fd5b50610279905073ffffffffffffffffffffffffffffffffffffffff831682600063ffffffff6103c616565b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905160009173ffffffffffffffffffffffffffffffffffffffff8716916370a0823191602480820192602092909190829003018186803b1580156102e957600080fd5b505afa1580156102fd573d6000803e3d6000fd5b505050506040513d602081101561031357600080fd5b5051905080156103bf57604080517fa9059cbb00000000000000000000000000000000000000000000000000000000815233600482015260248101839052905173ffffffffffffffffffffffffffffffffffffffff87169163a9059cbb9160448083019260209291908290030181600087803b15801561039257600080fd5b505af11580156103a6573d6000803e3d6000fd5b505050506040513d60208110156103bc57600080fd5b50505b5050505050565b600080600084516020860185885af190508061044357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f494e5445524e414c5f434f4e54524143545f43414c4c5f4641494c4544000000604482015290519081900360640190fd5b5050505056fea26469706673582212202d09d0da65aea64af27f43f17ab033cb40e5cf6beffcd8e05c7f0212fdd3a53064736f6c634300060a0033", "immutableReferences": {}, "sourceMap": "305:725:30:-:0;;;;;;;;;;;;;;;;;;;", "deployedSourceMap": "305:725:30:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;368:660;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;368:660:30;;-1:-1:-1;368:660:30;;-1:-1:-1;;;;;368:660:30:i;:::-;;;558:63;;;;;;586:10;558:63;;;;606:4;558:63;;;;;;;;;;;;:27;;;;;;:63;;;;;;;;;;;;;;-1:-1:-1;558:27:30;:63;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;674:42:30;;;;;;:22;:42;;;;;;;;;;;;;;;:22;;;;;;:42;;;;;558:63;;674:42;;;;;;;;-1:-1:-1;674:22:30;:42;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;722:29:30;;-1:-1:-1;722:15:30;;;738:9;749:1;722:29;:15;:29;:::i;:::-;870:39;;;;;;903:4;870:39;;;;;;855:12;;870:24;;;;;;:39;;;;;;;;;;;;;;;:24;:39;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;870:39:30;;-1:-1:-1;918:11:30;;915:109;;973:44;;;;;;997:10;973:44;;;;;;;;;;;;:23;;;;;;:44;;;;;;;;;;;;;;-1:-1:-1;973:23:30;:44;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;915:109:30;368:660;;;;;:::o;430:481:17:-;537:11;820:1;791;751:9;745:16;699:2;688:9;684:18;665:9;646;631:5;617:230;607:240;;866:6;858:48;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;430:481;;;;:::o", "source": "// SPDX-License-Identifier: MIT\npragma solidity ^0.6.0;\n\nimport '@openzeppelin/contracts/token/ERC20/IERC20.sol';\nimport '../../proxies/CallContract.sol';\n\n/**\n * @title Approve this contract to spend your ERC-20 tokens, and then\n * you can call various contracts without an additional approval step.\n */\ncontract ApproveAndCall\n{\n using CallContract for address;\n\n function approveAndCall(\n address _token,\n uint _amount,\n address _contract,\n bytes memory _callData\n ) public\n {\n // First move tokens from the user into this contract\n IERC20(_token).transferFrom(msg.sender, address(this), _amount);\n\n // Approve spending and call the contract\n IERC20(_token).approve(_contract, _amount);\n _contract._call(_callData, 0);\n\n // Check for any unspent tokens, this is only applicable if the _contract is not predictable\n uint balance = IERC20(_token).balanceOf(address(this));\n if(balance > 0)\n {\n // Refund the remainder\n IERC20(_token).transfer(msg.sender, balance);\n }\n }\n}\n", "sourcePath": "/home/circleci/repo/contracts/tokens/ERC20/ApproveAndCall.sol", "ast": { "absolutePath": "project:/contracts/tokens/ERC20/ApproveAndCall.sol", "exportedSymbols": { "ApproveAndCall": [ 4188 ] }, "id": 4189, "license": "MIT", "nodeType": "SourceUnit", "nodes": [ { "id": 4115, "literals": [ "solidity", "^", "0.6", ".0" ], "nodeType": "PragmaDirective", "src": "32:23:30" }, { "absolutePath": "@openzeppelin/contracts/token/ERC20/IERC20.sol", "file": "@openzeppelin/contracts/token/ERC20/IERC20.sol", "id": 4116, "nodeType": "ImportDirective", "scope": 4189, "sourceUnit": 433, "src": "57:56:30", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "project:/contracts/proxies/CallContract.sol", "file": "../../proxies/CallContract.sol", "id": 4117, "nodeType": "ImportDirective", "scope": 4189, "sourceUnit": 3731, "src": "114:40:30", "symbolAliases": [], "unitAlias": "" }, { "abstract": false, "baseContracts": [], "contractDependencies": [], "contractKind": "contract", "documentation": { "id": 4118, "nodeType": "StructuredDocumentation", "src": "156:148:30", "text": " @title Approve this contract to spend your ERC-20 tokens, and then\n you can call various contracts without an additional approval step." }, "fullyImplemented": true, "id": 4188, "linearizedBaseContracts": [ 4188 ], "name": "ApproveAndCall", "nodeType": "ContractDefinition", "nodes": [ { "id": 4121, "libraryName": { "contractScope": null, "id": 4119, "name": "CallContract", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 3730, "src": "339:12:30", "typeDescriptions": { "typeIdentifier": "t_contract$_CallContract_$3730", "typeString": "library CallContract" } }, "nodeType": "UsingForDirective", "src": "333:31:30", "typeName": { "id": 4120, "name": "address", "nodeType": "ElementaryTypeName", "src": "356:7:30", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } }, { "body": { "id": 4186, "nodeType": "Block", "src": "494:534:30", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "expression": { "argumentTypes": null, "id": 4136, "name": "msg", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": -15, "src": "586:3:30", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" } }, "id": 4137, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, "src": "586:10:30", "typeDescriptions": { "typeIdentifier": "t_address_payable", "typeString": "address payable" } }, { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 4140, "name": "this", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": -28, "src": "606:4:30", "typeDescriptions": { "typeIdentifier": "t_contract$_ApproveAndCall_$4188", "typeString": "contract ApproveAndCall" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_contract$_ApproveAndCall_$4188", "typeString": "contract ApproveAndCall" } ], "id": 4139, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "598:7:30", "typeDescriptions": { "typeIdentifier": "t_type$_t_address_$", "typeString": "type(address)" }, "typeName": { "id": 4138, "name": "address", "nodeType": "ElementaryTypeName", "src": "598:7:30", "typeDescriptions": { "typeIdentifier": null, "typeString": null } } }, "id": 4141, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "598:13:30", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, { "argumentTypes": null, "id": 4142, "name": "_amount", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4125, "src": "613:7:30", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address_payable", "typeString": "address payable" }, { "typeIdentifier": "t_address", "typeString": "address" }, { "typeIdentifier": "t_uint256", "typeString": "uint256" } ], "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 4133, "name": "_token", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4123, "src": "565:6:30", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address", "typeString": "address" } ], "id": 4132, "name": "IERC20", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 432, "src": "558:6:30", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_IERC20_$432_$", "typeString": "type(contract IERC20)" } }, "id": 4134, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "558:14:30", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_contract$_IERC20_$432", "typeString": "contract IERC20" } }, "id": 4135, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "transferFrom", "nodeType": "MemberAccess", "referencedDeclaration": 413, "src": "558:27:30", "typeDescriptions": { "typeIdentifier": "t_function_external_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$_t_bool_$", "typeString": "function (address,address,uint256) external returns (bool)" } }, "id": 4143, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "558:63:30", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "id": 4144, "nodeType": "ExpressionStatement", "src": "558:63:30" }, { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 4149, "name": "_contract", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4127, "src": "697:9:30", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, { "argumentTypes": null, "id": 4150, "name": "_amount", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4125, "src": "708:7:30", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address", "typeString": "address" }, { "typeIdentifier": "t_uint256", "typeString": "uint256" } ], "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 4146, "name": "_token", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4123, "src": "681:6:30", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address", "typeString": "address" } ], "id": 4145, "name": "IERC20", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 432, "src": "674:6:30", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_IERC20_$432_$", "typeString": "type(contract IERC20)" } }, "id": 4147, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "674:14:30", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_contract$_IERC20_$432", "typeString": "contract IERC20" } }, "id": 4148, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "approve", "nodeType": "MemberAccess", "referencedDeclaration": 401, "src": "674:22:30", "typeDescriptions": { "typeIdentifier": "t_function_external_nonpayable$_t_address_$_t_uint256_$returns$_t_bool_$", "typeString": "function (address,uint256) external returns (bool)" } }, "id": 4151, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "674:42:30", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "id": 4152, "nodeType": "ExpressionStatement", "src": "674:42:30" }, { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 4156, "name": "_callData", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4129, "src": "738:9:30", "typeDescriptions": { "typeIdentifier": "t_bytes_memory_ptr", "typeString": "bytes memory" } }, { "argumentTypes": null, "hexValue": "30", "id": 4157, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "749:1:30", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bytes_memory_ptr", "typeString": "bytes memory" }, { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" } ], "expression": { "argumentTypes": null, "id": 4153, "name": "_contract", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4127, "src": "722:9:30", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } }, "id": 4155, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "_call", "nodeType": "MemberAccess", "referencedDeclaration": 3706, "src": "722:15:30", "typeDescriptions": { "typeIdentifier": "t_function_internal_nonpayable$_t_address_$_t_bytes_memory_ptr_$_t_uint256_$returns$__$bound_to$_t_address_$", "typeString": "function (address,bytes memory,uint256)" } }, "id": 4158, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "722:29:30", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } }, "id": 4159, "nodeType": "ExpressionStatement", "src": "722:29:30" }, { "assignments": [ 4161 ], "declarations": [ { "constant": false, "id": 4161, "mutability": "mutable", "name": "balance", "nodeType": "VariableDeclaration", "overrides": null, "scope": 4186, "src": "855:12:30", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 4160, "name": "uint", "nodeType": "ElementaryTypeName", "src": "855:4:30", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" } ], "id": 4171, "initialValue": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 4168, "name": "this", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": -28, "src": "903:4:30", "typeDescriptions": { "typeIdentifier": "t_contract$_ApproveAndCall_$4188", "typeString": "contract ApproveAndCall" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_contract$_ApproveAndCall_$4188", "typeString": "contract ApproveAndCall" } ], "id": 4167, "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "nodeType": "ElementaryTypeNameExpression", "src": "895:7:30", "typeDescriptions": { "typeIdentifier": "t_type$_t_address_$", "typeString": "type(address)" }, "typeName": { "id": 4166, "name": "address", "nodeType": "ElementaryTypeName", "src": "895:7:30", "typeDescriptions": { "typeIdentifier": null, "typeString": null } } }, "id": 4169, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "895:13:30", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address", "typeString": "address" } ], "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 4163, "name": "_token", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4123, "src": "877:6:30", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address", "typeString": "address" } ], "id": 4162, "name": "IERC20", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 432, "src": "870:6:30", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_IERC20_$432_$", "typeString": "type(contract IERC20)" } }, "id": 4164, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "870:14:30", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_contract$_IERC20_$432", "typeString": "contract IERC20" } }, "id": 4165, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "balanceOf", "nodeType": "MemberAccess", "referencedDeclaration": 371, "src": "870:24:30", "typeDescriptions": { "typeIdentifier": "t_function_external_view$_t_address_$returns$_t_uint256_$", "typeString": "function (address) view external returns (uint256)" } }, "id": 4170, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "870:39:30", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "VariableDeclarationStatement", "src": "855:54:30" }, { "condition": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 4174, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 4172, "name": "balance", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4161, "src": "918:7:30", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": ">", "rightExpression": { "argumentTypes": null, "hexValue": "30", "id": 4173, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "928:1:30", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" }, "src": "918:11:30", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "falseBody": null, "id": 4185, "nodeType": "IfStatement", "src": "915:109:30", "trueBody": { "id": 4184, "nodeType": "Block", "src": "935:89:30", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "expression": { "argumentTypes": null, "id": 4179, "name": "msg", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": -15, "src": "997:3:30", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" } }, "id": 4180, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, "src": "997:10:30", "typeDescriptions": { "typeIdentifier": "t_address_payable", "typeString": "address payable" } }, { "argumentTypes": null, "id": 4181, "name": "balance", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4161, "src": "1009:7:30", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address_payable", "typeString": "address payable" }, { "typeIdentifier": "t_uint256", "typeString": "uint256" } ], "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 4176, "name": "_token", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 4123, "src": "980:6:30", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_address", "typeString": "address" } ], "id": 4175, "name": "IERC20", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 432, "src": "973:6:30", "typeDescriptions": { "typeIdentifier": "t_type$_t_contract$_IERC20_$432_$", "typeString": "type(contract IERC20)" } }, "id": 4177, "isConstant": false, "isLValue": false, "isPure": false, "kind": "typeConversion", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "973:14:30", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_contract$_IERC20_$432", "typeString": "contract IERC20" } }, "id": 4178, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "transfer", "nodeType": "MemberAccess", "referencedDeclaration": 381, "src": "973:23:30", "typeDescriptions": { "typeIdentifier": "t_function_external_nonpayable$_t_address_$_t_uint256_$returns$_t_bool_$", "typeString": "function (address,uint256) external returns (bool)" } }, "id": 4182, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "973:44:30", "tryCall": false, "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "id": 4183, "nodeType": "ExpressionStatement", "src": "973:44:30" } ] } } ] }, "documentation": null, "functionSelector": "e6fb99ea", "id": 4187, "implemented": true, "kind": "function", "modifiers": [], "name": "approveAndCall", "nodeType": "FunctionDefinition", "overrides": null, "parameters": { "id": 4130, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 4123, "mutability": "mutable", "name": "_token", "nodeType": "VariableDeclaration", "overrides": null, "scope": 4187, "src": "397:14:30", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" }, "typeName": { "id": 4122, "name": "address", "nodeType": "ElementaryTypeName", "src": "397:7:30", "stateMutability": "nonpayable", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } },