hardlydifficult-ethereum-contracts
Version:
A collection of reusable contracts and Javascript helpers for Ethereum.
977 lines • 95.4 kB
JSON
{
"contractName": "ApproveAndCall",
"abi": [
{
"constant": false,
"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": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
}
],
"metadata": "{\"compiler\":{\"version\":\"0.5.17+commit.d19bba13\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"constant\":false,\"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\":[],\"payable\":false,\"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\":{\"/home/circleci/repo/contracts/tokens/ERC20/ApproveAndCall.sol\":\"ApproveAndCall\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":true,\"runs\":2000000},\"remappings\":[]},\"sources\":{\"/home/circleci/repo/contracts/proxies/CallContract.sol\":{\"keccak256\":\"0x5b891896d85a8937da32acd5af2d4b2d3fd8f5fbae639540d54ed972d05304b4\",\"urls\":[\"bzz-raw://982e6db3cc9a612ab3ecd4a404ed15255429e857ebf0bb96b404dedb83313dc1\",\"dweb:/ipfs/Qmeh7ezyMrD4q62edq1oLdR93NuTr8GYwE4XKE62T125Mt\"]},\"/home/circleci/repo/contracts/tokens/ERC20/ApproveAndCall.sol\":{\"keccak256\":\"0xcb38adf4a5902a0500b1d9f525dcad2bb2db98b4c207122b34db9c7f4dda0ee1\",\"urls\":[\"bzz-raw://9fcdc775615ee13eea82f79c3031c15bf4ebc4864f19ccd5a59d0f2b110aa1cb\",\"dweb:/ipfs/QmWCNB5AoCBSPuryBm9CakKPbMUJQJDp4veoBLDL4PKsmq\"]},\"@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol\":{\"keccak256\":\"0xe5bb0f57cff3e299f360052ba50f1ea0fff046df2be070b6943e0e3c3fdad8a9\",\"urls\":[\"bzz-raw://59fd025151435da35faa8093a5c7a17de02de9d08ad27275c5cdf05050820d91\",\"dweb:/ipfs/QmQMvwEcPhoRXzbXyrdoeRtvLoifUW9Qh7Luho7bmUPRkc\"]}},\"version\":1}",
"bytecode": "0x608060405234801561001057600080fd5b5061047e806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063e6fb99ea14610030575b600080fd5b6101026004803603608081101561004657600080fd5b73ffffffffffffffffffffffffffffffffffffffff823581169260208101359260408201359092169181019060808101606082013564010000000081111561008d57600080fd5b82018360208201111561009f57600080fd5b803590602001918460018302840111640100000000831117156100c157600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610104945050505050565b005b604080517f23b872dd00000000000000000000000000000000000000000000000000000000815233600482015230602482015260448101859052905173ffffffffffffffffffffffffffffffffffffffff8616916323b872dd9160648083019260209291908290030181600087803b15801561017f57600080fd5b505af1158015610193573d6000803e3d6000fd5b505050506040513d60208110156101a957600080fd5b5050604080517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301526024820186905291519186169163095ea7b3916044808201926020929091908290030181600087803b15801561022457600080fd5b505af1158015610238573d6000803e3d6000fd5b505050506040513d602081101561024e57600080fd5b50610279905073ffffffffffffffffffffffffffffffffffffffff831682600063ffffffff6103c616565b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905160009173ffffffffffffffffffffffffffffffffffffffff8716916370a0823191602480820192602092909190829003018186803b1580156102e957600080fd5b505afa1580156102fd573d6000803e3d6000fd5b505050506040513d602081101561031357600080fd5b5051905080156103bf57604080517fa9059cbb00000000000000000000000000000000000000000000000000000000815233600482015260248101839052905173ffffffffffffffffffffffffffffffffffffffff87169163a9059cbb9160448083019260209291908290030181600087803b15801561039257600080fd5b505af11580156103a6573d6000803e3d6000fd5b505050506040513d60208110156103bc57600080fd5b50505b5050505050565b600080600084516020860185885af190508061044357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f494e5445524e414c5f434f4e54524143545f43414c4c5f4641494c4544000000604482015290519081900360640190fd5b5050505056fea265627a7a72315820c007b331ad04a466a35967e80cbc1525458d62d0bf4b2bb316e34a1b36e70dc164736f6c63430005110032",
"deployedBytecode": "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063e6fb99ea14610030575b600080fd5b6101026004803603608081101561004657600080fd5b73ffffffffffffffffffffffffffffffffffffffff823581169260208101359260408201359092169181019060808101606082013564010000000081111561008d57600080fd5b82018360208201111561009f57600080fd5b803590602001918460018302840111640100000000831117156100c157600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610104945050505050565b005b604080517f23b872dd00000000000000000000000000000000000000000000000000000000815233600482015230602482015260448101859052905173ffffffffffffffffffffffffffffffffffffffff8616916323b872dd9160648083019260209291908290030181600087803b15801561017f57600080fd5b505af1158015610193573d6000803e3d6000fd5b505050506040513d60208110156101a957600080fd5b5050604080517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301526024820186905291519186169163095ea7b3916044808201926020929091908290030181600087803b15801561022457600080fd5b505af1158015610238573d6000803e3d6000fd5b505050506040513d602081101561024e57600080fd5b50610279905073ffffffffffffffffffffffffffffffffffffffff831682600063ffffffff6103c616565b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905160009173ffffffffffffffffffffffffffffffffffffffff8716916370a0823191602480820192602092909190829003018186803b1580156102e957600080fd5b505afa1580156102fd573d6000803e3d6000fd5b505050506040513d602081101561031357600080fd5b5051905080156103bf57604080517fa9059cbb00000000000000000000000000000000000000000000000000000000815233600482015260248101839052905173ffffffffffffffffffffffffffffffffffffffff87169163a9059cbb9160448083019260209291908290030181600087803b15801561039257600080fd5b505af11580156103a6573d6000803e3d6000fd5b505050506040513d60208110156103bc57600080fd5b50505b5050505050565b600080600084516020860185885af190508061044357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f494e5445524e414c5f434f4e54524143545f43414c4c5f4641494c4544000000604482015290519081900360640190fd5b5050505056fea265627a7a72315820c007b331ad04a466a35967e80cbc1525458d62d0bf4b2bb316e34a1b36e70dc164736f6c63430005110032",
"sourceMap": "300:725:21:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;300:725:21;;;;;;;",
"deployedSourceMap": "300:725:21:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;300:725:21;;;;;;;;;;;;;;;;;;;363:660;;;;;;13:3:-1;8;5:12;2:2;;;30:1;27;20:12;2:2;363:660:21;;;;;;;;;;;;;;;;;;;;;;;;;;;;;21:11:-1;5:28;;2:2;;;46:1;43;36:12;2:2;363:660:21;;35:9:-1;28:4;12:14;8:25;5:40;2:2;;;58:1;55;48:12;2:2;363:660:21;;;;;;100:9:-1;95:1;81:12;77:20;67:8;63:35;60:50;39:11;25:12;22:29;11:107;8:2;;;131:1;128;121:12;8:2;363:660:21;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;30:3:-1;22:6;14;1:33;99:1;81:16;;74:27;;;;-1:-1;363:660:21;;-1:-1:-1;363:660:21;;-1:-1:-1;;;;;363:660:21:i;:::-;;;553:63;;;;;;581:10;553:63;;;;601:4;553:63;;;;;;;;;;;;:27;;;;;;:63;;;;;;;;;;;;;;-1:-1:-1;553:27:21;:63;;;5:2:-1;;;;30:1;27;20:12;5:2;553:63:21;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;553:63:21;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;;669:42:21;;;;;;:22;:42;;;;;;;;;;;;;;;:22;;;;;;:42;;;;;553:63;;669:42;;;;;;;;-1:-1:-1;669:22:21;:42;;;5:2:-1;;;;30:1;27;20:12;5:2;669:42:21;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;669:42:21;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;717:29:21;;-1:-1:-1;717:15:21;;;733:9;744:1;717:29;:15;:29;:::i;:::-;865:39;;;;;;898:4;865:39;;;;;;850:12;;865:24;;;;;;:39;;;;;;;;;;;;;;;:24;:39;;;5:2:-1;;;;30:1;27;20:12;5:2;865:39:21;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;865:39:21;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;865:39:21;;-1:-1:-1;913:11:21;;910:109;;968:44;;;;;;992:10;968:44;;;;;;;;;;;;:23;;;;;;:44;;;;;;;;;;;;;;-1:-1:-1;968:23:21;:44;;;5:2:-1;;;;30:1;27;20:12;5:2;968:44:21;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;968:44:21;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;;910:109:21;363:660;;;;;:::o;398:479:7:-;505:11;786:1;757;717:9;711:16;665:2;654:9;650:18;631:9;612;599:3;585:228;575:238;;832:6;824:48;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;398:479;;;;:::o",
"source": "pragma solidity ^0.5.0;\n\nimport '@openzeppelin/contracts-ethereum-package/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": "/home/circleci/repo/contracts/tokens/ERC20/ApproveAndCall.sol",
"exportedSymbols": {
"ApproveAndCall": [
1815
]
},
"id": 1816,
"nodeType": "SourceUnit",
"nodes": [
{
"id": 1745,
"literals": [
"solidity",
"^",
"0.5",
".0"
],
"nodeType": "PragmaDirective",
"src": "0:23:21"
},
{
"absolutePath": "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol",
"file": "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol",
"id": 1746,
"nodeType": "ImportDirective",
"scope": 1816,
"sourceUnit": 2180,
"src": "25:83:21",
"symbolAliases": [],
"unitAlias": ""
},
{
"absolutePath": "/home/circleci/repo/contracts/proxies/CallContract.sol",
"file": "../../proxies/CallContract.sol",
"id": 1747,
"nodeType": "ImportDirective",
"scope": 1816,
"sourceUnit": 1330,
"src": "109:40:21",
"symbolAliases": [],
"unitAlias": ""
},
{
"baseContracts": [],
"contractDependencies": [],
"contractKind": "contract",
"documentation": "@title Approve this contract to spend your ERC-20 tokens, and then\nyou can call various contracts without an additional approval step.",
"fullyImplemented": true,
"id": 1815,
"linearizedBaseContracts": [
1815
],
"name": "ApproveAndCall",
"nodeType": "ContractDefinition",
"nodes": [
{
"id": 1750,
"libraryName": {
"contractScope": null,
"id": 1748,
"name": "CallContract",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 1329,
"src": "334:12:21",
"typeDescriptions": {
"typeIdentifier": "t_contract$_CallContract_$1329",
"typeString": "library CallContract"
}
},
"nodeType": "UsingForDirective",
"src": "328:31:21",
"typeName": {
"id": 1749,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "351:7:21",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
}
},
{
"body": {
"id": 1813,
"nodeType": "Block",
"src": "489:534:21",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 1765,
"name": "msg",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2263,
"src": "581:3:21",
"typeDescriptions": {
"typeIdentifier": "t_magic_message",
"typeString": "msg"
}
},
"id": 1766,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "sender",
"nodeType": "MemberAccess",
"referencedDeclaration": null,
"src": "581:10:21",
"typeDescriptions": {
"typeIdentifier": "t_address_payable",
"typeString": "address payable"
}
},
{
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 1768,
"name": "this",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2331,
"src": "601:4:21",
"typeDescriptions": {
"typeIdentifier": "t_contract$_ApproveAndCall_$1815",
"typeString": "contract ApproveAndCall"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_contract$_ApproveAndCall_$1815",
"typeString": "contract ApproveAndCall"
}
],
"id": 1767,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "ElementaryTypeNameExpression",
"src": "593:7:21",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_address_$",
"typeString": "type(address)"
},
"typeName": "address"
},
"id": 1769,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "593:13:21",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
{
"argumentTypes": null,
"id": 1770,
"name": "_amount",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1754,
"src": "608:7:21",
"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": 1762,
"name": "_token",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1752,
"src": "560:6:21",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_address",
"typeString": "address"
}
],
"id": 1761,
"name": "IERC20",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2179,
"src": "553:6:21",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_contract$_IERC20_$2179_$",
"typeString": "type(contract IERC20)"
}
},
"id": 1763,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "553:14:21",
"typeDescriptions": {
"typeIdentifier": "t_contract$_IERC20_$2179",
"typeString": "contract IERC20"
}
},
"id": 1764,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "transferFrom",
"nodeType": "MemberAccess",
"referencedDeclaration": 2162,
"src": "553:27:21",
"typeDescriptions": {
"typeIdentifier": "t_function_external_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$_t_bool_$",
"typeString": "function (address,address,uint256) external returns (bool)"
}
},
"id": 1771,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "553:63:21",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"id": 1772,
"nodeType": "ExpressionStatement",
"src": "553:63:21"
},
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 1777,
"name": "_contract",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1756,
"src": "692:9:21",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
{
"argumentTypes": null,
"id": 1778,
"name": "_amount",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1754,
"src": "703:7:21",
"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": 1774,
"name": "_token",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1752,
"src": "676:6:21",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_address",
"typeString": "address"
}
],
"id": 1773,
"name": "IERC20",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2179,
"src": "669:6:21",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_contract$_IERC20_$2179_$",
"typeString": "type(contract IERC20)"
}
},
"id": 1775,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "669:14:21",
"typeDescriptions": {
"typeIdentifier": "t_contract$_IERC20_$2179",
"typeString": "contract IERC20"
}
},
"id": 1776,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "approve",
"nodeType": "MemberAccess",
"referencedDeclaration": 2151,
"src": "669:22:21",
"typeDescriptions": {
"typeIdentifier": "t_function_external_nonpayable$_t_address_$_t_uint256_$returns$_t_bool_$",
"typeString": "function (address,uint256) external returns (bool)"
}
},
"id": 1779,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "669:42:21",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"id": 1780,
"nodeType": "ExpressionStatement",
"src": "669:42:21"
},
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 1784,
"name": "_callData",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1758,
"src": "733:9:21",
"typeDescriptions": {
"typeIdentifier": "t_bytes_memory_ptr",
"typeString": "bytes memory"
}
},
{
"argumentTypes": null,
"hexValue": "30",
"id": 1785,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "744:1:21",
"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": 1781,
"name": "_contract",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1756,
"src": "717:9:21",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"id": 1783,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "_call",
"nodeType": "MemberAccess",
"referencedDeclaration": 1305,
"src": "717:15:21",
"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": 1786,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "717:29:21",
"typeDescriptions": {
"typeIdentifier": "t_tuple$__$",
"typeString": "tuple()"
}
},
"id": 1787,
"nodeType": "ExpressionStatement",
"src": "717:29:21"
},
{
"assignments": [
1789
],
"declarations": [
{
"constant": false,
"id": 1789,
"name": "balance",
"nodeType": "VariableDeclaration",
"scope": 1813,
"src": "850:12:21",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 1788,
"name": "uint",
"nodeType": "ElementaryTypeName",
"src": "850:4:21",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"id": 1798,
"initialValue": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 1795,
"name": "this",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2331,
"src": "898:4:21",
"typeDescriptions": {
"typeIdentifier": "t_contract$_ApproveAndCall_$1815",
"typeString": "contract ApproveAndCall"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_contract$_ApproveAndCall_$1815",
"typeString": "contract ApproveAndCall"
}
],
"id": 1794,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"nodeType": "ElementaryTypeNameExpression",
"src": "890:7:21",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_address_$",
"typeString": "type(address)"
},
"typeName": "address"
},
"id": 1796,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "890:13:21",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_address",
"typeString": "address"
}
],
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"id": 1791,
"name": "_token",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1752,
"src": "872:6:21",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_address",
"typeString": "address"
}
],
"id": 1790,
"name": "IERC20",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2179,
"src": "865:6:21",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_contract$_IERC20_$2179_$",
"typeString": "type(contract IERC20)"
}
},
"id": 1792,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "865:14:21",
"typeDescriptions": {
"typeIdentifier": "t_contract$_IERC20_$2179",
"typeString": "contract IERC20"
}
},
"id": 1793,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "balanceOf",
"nodeType": "MemberAccess",
"referencedDeclaration": 2124,
"src": "865:24:21",
"typeDescriptions": {
"typeIdentifier": "t_function_external_view$_t_address_$returns$_t_uint256_$",
"typeString": "function (address) view external returns (uint256)"
}
},
"id": 1797,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "865:39:21",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "VariableDeclarationStatement",
"src": "850:54:21"
},
{
"condition": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 1801,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"id": 1799,
"name": "balance",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1789,
"src": "913:7:21",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": ">",
"rightExpression": {
"argumentTypes": null,
"hexValue": "30",
"id": 1800,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "923:1:21",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_0_by_1",
"typeString": "int_const 0"
},
"value": "0"
},
"src": "913:11:21",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"falseBody": null,
"id": 1812,
"nodeType": "IfStatement",
"src": "910:109:21",
"trueBody": {
"id": 1811,
"nodeType": "Block",
"src": "930:89:21",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 1806,
"name": "msg",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2263,
"src": "992:3:21",
"typeDescriptions": {
"typeIdentifier": "t_magic_message",
"typeString": "msg"
}
},
"id": 1807,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "sender",
"nodeType": "MemberAccess",
"referencedDeclaration": null,
"src": "992:10:21",
"typeDescriptions": {
"typeIdentifier": "t_address_payable",
"typeString": "address payable"
}
},
{
"argumentTypes": null,
"id": 1808,
"name": "balance",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1789,
"src": "1004:7:21",
"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": 1803,
"name": "_token",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1752,
"src": "975:6:21",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_address",
"typeString": "address"
}
],
"id": 1802,
"name": "IERC20",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 2179,
"src": "968:6:21",
"typeDescriptions": {
"typeIdentifier": "t_type$_t_contract$_IERC20_$2179_$",
"typeString": "type(contract IERC20)"
}
},
"id": 1804,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "typeConversion",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "968:14:21",
"typeDescriptions": {
"typeIdentifier": "t_contract$_IERC20_$2179",
"typeString": "contract IERC20"
}
},
"id": 1805,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "transfer",
"nodeType": "MemberAccess",
"referencedDeclaration": 2133,
"src": "968:23:21",
"typeDescriptions": {
"typeIdentifier": "t_function_external_nonpayable$_t_address_$_t_uint256_$returns$_t_bool_$",
"typeString": "function (address,uint256) external returns (bool)"
}
},
"id": 1809,
"isConstant": false,
"isLValue": false,
"isPure": false,
"kind": "functionCall",
"lValueRequested": false,
"names": [],
"nodeType": "FunctionCall",
"src": "968:44:21",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"id": 1810,
"nodeType": "ExpressionStatement",
"src": "968:44:21"
}
]
}
}
]
},
"documentation": null,
"id": 1814,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "approveAndCall",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 1759,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 1752,
"name": "_token",
"nodeType": "VariableDeclaration",
"scope": 1814,
"src": "392:14:21",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 1751,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "392:7:21",
"stateMutability": "nonpayable",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 1754,
"name": "_amount",
"nodeType": "VariableDeclaration",
"scope": 1814,
"src": "412:12:21",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 1753,
"name": "uint",
"nodeType": "ElementaryTypeName",
"src": "412:4:21",
"typeDescriptions": {
"typeIdenti