diff --git a/packages/contracts/abi/ERC20.json b/packages/contracts/abi/ERC20.json new file mode 100644 index 0000000..43bd340 --- /dev/null +++ b/packages/contracts/abi/ERC20.json @@ -0,0 +1,230 @@ +{ + "contractName": "ERC20", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "from", + "type": "address" + }, + { + "indexed": true, + "name": "to", + "type": "address" + }, + { + "indexed": false, + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "owner", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "owner", + "type": "address" + }, + { + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "to", + "type": "address" + }, + { + "name": "value", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "spender", + "type": "address" + }, + { + "name": "value", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "from", + "type": "address" + }, + { + "name": "to", + "type": "address" + }, + { + "name": "value", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "spender", + "type": "address" + }, + { + "name": "addedValue", + "type": "uint256" + } + ], + "name": "increaseAllowance", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "spender", + "type": "address" + }, + { + "name": "subtractedValue", + "type": "uint256" + } + ], + "name": "decreaseAllowance", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x608060405234801561001057600080fd5b506105dd806100206000396000f3fe608060405234801561001057600080fd5b50600436106100a5576000357c01000000000000000000000000000000000000000000000000000000009004806370a082311161007857806370a0823114610166578063a457c2d71461018c578063a9059cbb146101b8578063dd62ed3e146101e4576100a5565b8063095ea7b3146100aa57806318160ddd146100ea57806323b872dd14610104578063395093511461013a575b600080fd5b6100d6600480360360408110156100c057600080fd5b50600160a060020a038135169060200135610212565b604080519115158252519081900360200190f35b6100f2610290565b60408051918252519081900360200190f35b6100d66004803603606081101561011a57600080fd5b50600160a060020a03813581169160208101359091169060400135610296565b6100d66004803603604081101561015057600080fd5b50600160a060020a03813516906020013561035f565b6100f26004803603602081101561017c57600080fd5b5035600160a060020a031661040f565b6100d6600480360360408110156101a257600080fd5b50600160a060020a03813516906020013561042a565b6100d6600480360360408110156101ce57600080fd5b50600160a060020a038135169060200135610475565b6100f2600480360360408110156101fa57600080fd5b50600160a060020a038135811691602001351661048b565b6000600160a060020a038316151561022957600080fd5b336000818152600160209081526040808320600160a060020a03881680855290835292819020869055805186815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a350600192915050565b60025490565b600160a060020a03831660009081526001602090815260408083203384529091528120546102ca908363ffffffff6104b616565b600160a060020a03851660009081526001602090815260408083203384529091529020556102f98484846104cb565b600160a060020a0384166000818152600160209081526040808320338085529083529281902054815190815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060019392505050565b6000600160a060020a038316151561037657600080fd5b336000908152600160209081526040808320600160a060020a03871684529091529020546103aa908363ffffffff61059816565b336000818152600160209081526040808320600160a060020a0389168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a350600192915050565b600160a060020a031660009081526020819052604090205490565b6000600160a060020a038316151561044157600080fd5b336000908152600160209081526040808320600160a060020a03871684529091529020546103aa908363ffffffff6104b616565b60006104823384846104cb565b50600192915050565b600160a060020a03918216600090815260016020908152604080832093909416825291909152205490565b6000828211156104c557600080fd5b50900390565b600160a060020a03821615156104e057600080fd5b600160a060020a038316600090815260208190526040902054610509908263ffffffff6104b616565b600160a060020a03808516600090815260208190526040808220939093559084168152205461053e908263ffffffff61059816565b600160a060020a038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b6000828201838110156105aa57600080fd5b939250505056fea165627a7a72305820722c0187518ce2856a424bdba350d5a263c8f98fcb19cb4cc161372bc3b794c90029", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100a5576000357c01000000000000000000000000000000000000000000000000000000009004806370a082311161007857806370a0823114610166578063a457c2d71461018c578063a9059cbb146101b8578063dd62ed3e146101e4576100a5565b8063095ea7b3146100aa57806318160ddd146100ea57806323b872dd14610104578063395093511461013a575b600080fd5b6100d6600480360360408110156100c057600080fd5b50600160a060020a038135169060200135610212565b604080519115158252519081900360200190f35b6100f2610290565b60408051918252519081900360200190f35b6100d66004803603606081101561011a57600080fd5b50600160a060020a03813581169160208101359091169060400135610296565b6100d66004803603604081101561015057600080fd5b50600160a060020a03813516906020013561035f565b6100f26004803603602081101561017c57600080fd5b5035600160a060020a031661040f565b6100d6600480360360408110156101a257600080fd5b50600160a060020a03813516906020013561042a565b6100d6600480360360408110156101ce57600080fd5b50600160a060020a038135169060200135610475565b6100f2600480360360408110156101fa57600080fd5b50600160a060020a038135811691602001351661048b565b6000600160a060020a038316151561022957600080fd5b336000818152600160209081526040808320600160a060020a03881680855290835292819020869055805186815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a350600192915050565b60025490565b600160a060020a03831660009081526001602090815260408083203384529091528120546102ca908363ffffffff6104b616565b600160a060020a03851660009081526001602090815260408083203384529091529020556102f98484846104cb565b600160a060020a0384166000818152600160209081526040808320338085529083529281902054815190815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060019392505050565b6000600160a060020a038316151561037657600080fd5b336000908152600160209081526040808320600160a060020a03871684529091529020546103aa908363ffffffff61059816565b336000818152600160209081526040808320600160a060020a0389168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a350600192915050565b600160a060020a031660009081526020819052604090205490565b6000600160a060020a038316151561044157600080fd5b336000908152600160209081526040808320600160a060020a03871684529091529020546103aa908363ffffffff6104b616565b60006104823384846104cb565b50600192915050565b600160a060020a03918216600090815260016020908152604080832093909416825291909152205490565b6000828211156104c557600080fd5b50900390565b600160a060020a03821615156104e057600080fd5b600160a060020a038316600090815260208190526040902054610509908263ffffffff6104b616565b600160a060020a03808516600090815260208190526040808220939093559084168152205461053e908263ffffffff61059816565b600160a060020a038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b6000828201838110156105aa57600080fd5b939250505056fea165627a7a72305820722c0187518ce2856a424bdba350d5a263c8f98fcb19cb4cc161372bc3b794c90029", + "compiler": { + "name": "solc", + "version": "0.5.4+commit.9549d8ff.Emscripten.clang" + } +} diff --git a/packages/contracts/abi/ERC20Mock.json b/packages/contracts/abi/ERC20Mock.json new file mode 100644 index 0000000..c8705b0 --- /dev/null +++ b/packages/contracts/abi/ERC20Mock.json @@ -0,0 +1,389 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "ERC20Mock", + "sourceName": "contracts/mocks/ERC20Mock.sol", + "abi": [ + { + "inputs": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "internalType": "address", + "name": "initialAccount", + "type": "address" + }, + { + "internalType": "uint256", + "name": "initialBalance", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "approveInternal", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "subtractedValue", + "type": "uint256" + } + ], + "name": "decreaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "addedValue", + "type": "uint256" + } + ], + "name": "increaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transferInternal", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x608060405260405162001fc138038062001fc1833981810160405281019062000029919062000335565b8383816003908051906020019062000043929190620001e5565b5080600490805190602001906200005c929190620001e5565b5050506200007182826200007b60201b60201c565b50505050620006a5565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415620000ee576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620000e59062000426565b60405180910390fd5b6200010260008383620001e060201b60201c565b8060026000828254620001169190620004dd565b92505081905550806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546200016d9190620004dd565b925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051620001d4919062000448565b60405180910390a35050565b505050565b828054620001f390620005ae565b90600052602060002090601f01602090048101928262000217576000855562000263565b82601f106200023257805160ff191683800117855562000263565b8280016001018555821562000263579182015b828111156200026257825182559160200191906001019062000245565b5b50905062000272919062000276565b5090565b5b808211156200029157600081600090555060010162000277565b5090565b6000620002ac620002a68462000499565b62000465565b905082815260208101848484011115620002c557600080fd5b620002d284828562000578565b509392505050565b600081519050620002eb8162000671565b92915050565b600082601f8301126200030357600080fd5b81516200031584826020860162000295565b91505092915050565b6000815190506200032f816200068b565b92915050565b600080600080608085870312156200034c57600080fd5b600085015167ffffffffffffffff8111156200036757600080fd5b6200037587828801620002f1565b945050602085015167ffffffffffffffff8111156200039357600080fd5b620003a187828801620002f1565b9350506040620003b487828801620002da565b9250506060620003c7878288016200031e565b91505092959194509250565b6000620003e2601f83620004cc565b91507f45524332303a206d696e7420746f20746865207a65726f2061646472657373006000830152602082019050919050565b62000420816200056e565b82525050565b600060208201905081810360008301526200044181620003d3565b9050919050565b60006020820190506200045f600083018462000415565b92915050565b6000604051905081810181811067ffffffffffffffff821117156200048f576200048e62000642565b5b8060405250919050565b600067ffffffffffffffff821115620004b757620004b662000642565b5b601f19601f8301169050602081019050919050565b600082825260208201905092915050565b6000620004ea826200056e565b9150620004f7836200056e565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156200052f576200052e620005e4565b5b828201905092915050565b600062000547826200054e565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60005b83811015620005985780820151818401526020810190506200057b565b83811115620005a8576000848401525b50505050565b60006002820490506001821680620005c757607f821691505b60208210811415620005de57620005dd62000613565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6200067c816200053a565b81146200068857600080fd5b50565b62000696816200056e565b8114620006a257600080fd5b50565b61190c80620006b56000396000f3fe608060405234801561001057600080fd5b50600436106100f55760003560e01c806340c10f19116100975780639dc29fac116100665780639dc29fac14610286578063a457c2d7146102a2578063a9059cbb146102d2578063dd62ed3e14610302576100f5565b806340c10f191461020057806356189cb41461021c57806370a082311461023857806395d89b4114610268576100f5565b8063222f5be0116100d3578063222f5be01461016657806323b872dd14610182578063313ce567146101b257806339509351146101d0576100f5565b806306fdde03146100fa578063095ea7b31461011857806318160ddd14610148575b600080fd5b610102610332565b60405161010f9190611541565b60405180910390f35b610132600480360381019061012d91906110ae565b6103c4565b60405161013f9190611526565b60405180910390f35b6101506103e2565b60405161015d91906116a3565b60405180910390f35b610180600480360381019061017b919061105f565b6103ec565b005b61019c6004803603810190610197919061105f565b6103fc565b6040516101a99190611526565b60405180910390f35b6101ba6104fd565b6040516101c791906116be565b60405180910390f35b6101ea60048036038101906101e591906110ae565b610506565b6040516101f79190611526565b60405180910390f35b61021a600480360381019061021591906110ae565b6105b2565b005b6102366004803603810190610231919061105f565b6105c0565b005b610252600480360381019061024d9190610ffa565b6105d0565b60405161025f91906116a3565b60405180910390f35b610270610618565b60405161027d9190611541565b60405180910390f35b6102a0600480360381019061029b91906110ae565b6106aa565b005b6102bc60048036038101906102b791906110ae565b6106b8565b6040516102c99190611526565b60405180910390f35b6102ec60048036038101906102e791906110ae565b6107ac565b6040516102f99190611526565b60405180910390f35b61031c60048036038101906103179190611023565b6107ca565b60405161032991906116a3565b60405180910390f35b60606003805461034190611807565b80601f016020809104026020016040519081016040528092919081815260200182805461036d90611807565b80156103ba5780601f1061038f576101008083540402835291602001916103ba565b820191906000526020600020905b81548152906001019060200180831161039d57829003601f168201915b5050505050905090565b60006103d86103d1610851565b8484610859565b6001905092915050565b6000600254905090565b6103f7838383610a24565b505050565b6000610409848484610a24565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610454610851565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050828110156104d4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104cb906115e3565b60405180910390fd5b6104f1856104e0610851565b85846104ec919061174b565b610859565b60019150509392505050565b60006012905090565b60006105a8610513610851565b848460016000610521610851565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546105a391906116f5565b610859565b6001905092915050565b6105bc8282610ca3565b5050565b6105cb838383610859565b505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60606004805461062790611807565b80601f016020809104026020016040519081016040528092919081815260200182805461065390611807565b80156106a05780601f10610675576101008083540402835291602001916106a0565b820191906000526020600020905b81548152906001019060200180831161068357829003601f168201915b5050505050905090565b6106b48282610df7565b5050565b600080600160006106c7610851565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610784576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161077b90611663565b60405180910390fd5b6107a161078f610851565b85858461079c919061174b565b610859565b600191505092915050565b60006107c06107b9610851565b8484610a24565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156108c9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108c090611643565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610939576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610930906115a3565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92583604051610a1791906116a3565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610a94576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a8b90611623565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610b04576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610afb90611563565b60405180910390fd5b610b0f838383610fcb565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610b95576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b8c906115c3565b60405180910390fd5b8181610ba1919061174b565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610c3191906116f5565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610c9591906116a3565b60405180910390a350505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d13576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d0a90611683565b60405180910390fd5b610d1f60008383610fcb565b8060026000828254610d3191906116f5565b92505081905550806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610d8691906116f5565b925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051610deb91906116a3565b60405180910390a35050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610e67576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e5e90611603565b60405180910390fd5b610e7382600083610fcb565b60008060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610ef9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ef090611583565b60405180910390fd5b8181610f05919061174b565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508160026000828254610f59919061174b565b92505081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610fbe91906116a3565b60405180910390a3505050565b505050565b600081359050610fdf816118a8565b92915050565b600081359050610ff4816118bf565b92915050565b60006020828403121561100c57600080fd5b600061101a84828501610fd0565b91505092915050565b6000806040838503121561103657600080fd5b600061104485828601610fd0565b925050602061105585828601610fd0565b9150509250929050565b60008060006060848603121561107457600080fd5b600061108286828701610fd0565b935050602061109386828701610fd0565b92505060406110a486828701610fe5565b9150509250925092565b600080604083850312156110c157600080fd5b60006110cf85828601610fd0565b92505060206110e085828601610fe5565b9150509250929050565b6110f381611791565b82525050565b6000611104826116d9565b61110e81856116e4565b935061111e8185602086016117d4565b61112781611897565b840191505092915050565b600061113f6023836116e4565b91507f45524332303a207472616e7366657220746f20746865207a65726f206164647260008301527f65737300000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006111a56022836116e4565b91507f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60008301527f63650000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061120b6022836116e4565b91507f45524332303a20617070726f766520746f20746865207a65726f20616464726560008301527f73730000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006112716026836116e4565b91507f45524332303a207472616e7366657220616d6f756e742065786365656473206260008301527f616c616e636500000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006112d76028836116e4565b91507f45524332303a207472616e7366657220616d6f756e742065786365656473206160008301527f6c6c6f77616e63650000000000000000000000000000000000000000000000006020830152604082019050919050565b600061133d6021836116e4565b91507f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360008301527f73000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006113a36025836116e4565b91507f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008301527f64726573730000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006114096024836116e4565b91507f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008301527f72657373000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061146f6025836116e4565b91507f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008301527f207a65726f0000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006114d5601f836116e4565b91507f45524332303a206d696e7420746f20746865207a65726f2061646472657373006000830152602082019050919050565b611511816117bd565b82525050565b611520816117c7565b82525050565b600060208201905061153b60008301846110ea565b92915050565b6000602082019050818103600083015261155b81846110f9565b905092915050565b6000602082019050818103600083015261157c81611132565b9050919050565b6000602082019050818103600083015261159c81611198565b9050919050565b600060208201905081810360008301526115bc816111fe565b9050919050565b600060208201905081810360008301526115dc81611264565b9050919050565b600060208201905081810360008301526115fc816112ca565b9050919050565b6000602082019050818103600083015261161c81611330565b9050919050565b6000602082019050818103600083015261163c81611396565b9050919050565b6000602082019050818103600083015261165c816113fc565b9050919050565b6000602082019050818103600083015261167c81611462565b9050919050565b6000602082019050818103600083015261169c816114c8565b9050919050565b60006020820190506116b86000830184611508565b92915050565b60006020820190506116d36000830184611517565b92915050565b600081519050919050565b600082825260208201905092915050565b6000611700826117bd565b915061170b836117bd565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156117405761173f611839565b5b828201905092915050565b6000611756826117bd565b9150611761836117bd565b92508282101561177457611773611839565b5b828203905092915050565b600061178a8261179d565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b838110156117f25780820151818401526020810190506117d7565b83811115611801576000848401525b50505050565b6000600282049050600182168061181f57607f821691505b6020821081141561183357611832611868565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b6118b18161177f565b81146118bc57600080fd5b50565b6118c8816117bd565b81146118d357600080fd5b5056fea26469706673582212201e41f70221ac8d0f18c73be33898dbdedd64ac077893da38d712d65fe6638d1864736f6c63430008000033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100f55760003560e01c806340c10f19116100975780639dc29fac116100665780639dc29fac14610286578063a457c2d7146102a2578063a9059cbb146102d2578063dd62ed3e14610302576100f5565b806340c10f191461020057806356189cb41461021c57806370a082311461023857806395d89b4114610268576100f5565b8063222f5be0116100d3578063222f5be01461016657806323b872dd14610182578063313ce567146101b257806339509351146101d0576100f5565b806306fdde03146100fa578063095ea7b31461011857806318160ddd14610148575b600080fd5b610102610332565b60405161010f9190611541565b60405180910390f35b610132600480360381019061012d91906110ae565b6103c4565b60405161013f9190611526565b60405180910390f35b6101506103e2565b60405161015d91906116a3565b60405180910390f35b610180600480360381019061017b919061105f565b6103ec565b005b61019c6004803603810190610197919061105f565b6103fc565b6040516101a99190611526565b60405180910390f35b6101ba6104fd565b6040516101c791906116be565b60405180910390f35b6101ea60048036038101906101e591906110ae565b610506565b6040516101f79190611526565b60405180910390f35b61021a600480360381019061021591906110ae565b6105b2565b005b6102366004803603810190610231919061105f565b6105c0565b005b610252600480360381019061024d9190610ffa565b6105d0565b60405161025f91906116a3565b60405180910390f35b610270610618565b60405161027d9190611541565b60405180910390f35b6102a0600480360381019061029b91906110ae565b6106aa565b005b6102bc60048036038101906102b791906110ae565b6106b8565b6040516102c99190611526565b60405180910390f35b6102ec60048036038101906102e791906110ae565b6107ac565b6040516102f99190611526565b60405180910390f35b61031c60048036038101906103179190611023565b6107ca565b60405161032991906116a3565b60405180910390f35b60606003805461034190611807565b80601f016020809104026020016040519081016040528092919081815260200182805461036d90611807565b80156103ba5780601f1061038f576101008083540402835291602001916103ba565b820191906000526020600020905b81548152906001019060200180831161039d57829003601f168201915b5050505050905090565b60006103d86103d1610851565b8484610859565b6001905092915050565b6000600254905090565b6103f7838383610a24565b505050565b6000610409848484610a24565b6000600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610454610851565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050828110156104d4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104cb906115e3565b60405180910390fd5b6104f1856104e0610851565b85846104ec919061174b565b610859565b60019150509392505050565b60006012905090565b60006105a8610513610851565b848460016000610521610851565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546105a391906116f5565b610859565b6001905092915050565b6105bc8282610ca3565b5050565b6105cb838383610859565b505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60606004805461062790611807565b80601f016020809104026020016040519081016040528092919081815260200182805461065390611807565b80156106a05780601f10610675576101008083540402835291602001916106a0565b820191906000526020600020905b81548152906001019060200180831161068357829003601f168201915b5050505050905090565b6106b48282610df7565b5050565b600080600160006106c7610851565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610784576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161077b90611663565b60405180910390fd5b6107a161078f610851565b85858461079c919061174b565b610859565b600191505092915050565b60006107c06107b9610851565b8484610a24565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614156108c9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108c090611643565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610939576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610930906115a3565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92583604051610a1791906116a3565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610a94576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a8b90611623565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610b04576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610afb90611563565b60405180910390fd5b610b0f838383610fcb565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610b95576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b8c906115c3565b60405180910390fd5b8181610ba1919061174b565b6000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610c3191906116f5565b925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610c9591906116a3565b60405180910390a350505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d13576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d0a90611683565b60405180910390fd5b610d1f60008383610fcb565b8060026000828254610d3191906116f5565b92505081905550806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610d8691906116f5565b925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051610deb91906116a3565b60405180910390a35050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610e67576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e5e90611603565b60405180910390fd5b610e7382600083610fcb565b60008060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610ef9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ef090611583565b60405180910390fd5b8181610f05919061174b565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508160026000828254610f59919061174b565b92505081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610fbe91906116a3565b60405180910390a3505050565b505050565b600081359050610fdf816118a8565b92915050565b600081359050610ff4816118bf565b92915050565b60006020828403121561100c57600080fd5b600061101a84828501610fd0565b91505092915050565b6000806040838503121561103657600080fd5b600061104485828601610fd0565b925050602061105585828601610fd0565b9150509250929050565b60008060006060848603121561107457600080fd5b600061108286828701610fd0565b935050602061109386828701610fd0565b92505060406110a486828701610fe5565b9150509250925092565b600080604083850312156110c157600080fd5b60006110cf85828601610fd0565b92505060206110e085828601610fe5565b9150509250929050565b6110f381611791565b82525050565b6000611104826116d9565b61110e81856116e4565b935061111e8185602086016117d4565b61112781611897565b840191505092915050565b600061113f6023836116e4565b91507f45524332303a207472616e7366657220746f20746865207a65726f206164647260008301527f65737300000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006111a56022836116e4565b91507f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60008301527f63650000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061120b6022836116e4565b91507f45524332303a20617070726f766520746f20746865207a65726f20616464726560008301527f73730000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006112716026836116e4565b91507f45524332303a207472616e7366657220616d6f756e742065786365656473206260008301527f616c616e636500000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006112d76028836116e4565b91507f45524332303a207472616e7366657220616d6f756e742065786365656473206160008301527f6c6c6f77616e63650000000000000000000000000000000000000000000000006020830152604082019050919050565b600061133d6021836116e4565b91507f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360008301527f73000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006113a36025836116e4565b91507f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008301527f64726573730000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006114096024836116e4565b91507f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008301527f72657373000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b600061146f6025836116e4565b91507f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008301527f207a65726f0000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006114d5601f836116e4565b91507f45524332303a206d696e7420746f20746865207a65726f2061646472657373006000830152602082019050919050565b611511816117bd565b82525050565b611520816117c7565b82525050565b600060208201905061153b60008301846110ea565b92915050565b6000602082019050818103600083015261155b81846110f9565b905092915050565b6000602082019050818103600083015261157c81611132565b9050919050565b6000602082019050818103600083015261159c81611198565b9050919050565b600060208201905081810360008301526115bc816111fe565b9050919050565b600060208201905081810360008301526115dc81611264565b9050919050565b600060208201905081810360008301526115fc816112ca565b9050919050565b6000602082019050818103600083015261161c81611330565b9050919050565b6000602082019050818103600083015261163c81611396565b9050919050565b6000602082019050818103600083015261165c816113fc565b9050919050565b6000602082019050818103600083015261167c81611462565b9050919050565b6000602082019050818103600083015261169c816114c8565b9050919050565b60006020820190506116b86000830184611508565b92915050565b60006020820190506116d36000830184611517565b92915050565b600081519050919050565b600082825260208201905092915050565b6000611700826117bd565b915061170b836117bd565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156117405761173f611839565b5b828201905092915050565b6000611756826117bd565b9150611761836117bd565b92508282101561177457611773611839565b5b828203905092915050565b600061178a8261179d565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b60005b838110156117f25780820151818401526020810190506117d7565b83811115611801576000848401525b50505050565b6000600282049050600182168061181f57607f821691505b6020821081141561183357611832611868565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b6000601f19601f8301169050919050565b6118b18161177f565b81146118bc57600080fd5b50565b6118c8816117bd565b81146118d357600080fd5b5056fea26469706673582212201e41f70221ac8d0f18c73be33898dbdedd64ac077893da38d712d65fe6638d1864736f6c63430008000033", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/packages/contracts/abi/MultiCall.json b/packages/contracts/abi/MultiCall.json new file mode 100644 index 0000000..c144cef --- /dev/null +++ b/packages/contracts/abi/MultiCall.json @@ -0,0 +1,145 @@ +{ + "abi": [ + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + } + ], + "internalType": "struct Multicall.Call[]", + "name": "calls", + "type": "tuple[]" + } + ], + "name": "aggregate", + "outputs": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + }, + { + "internalType": "bytes[]", + "name": "returnData", + "type": "bytes[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + } + ], + "name": "getBlockHash", + "outputs": [ + { + "internalType": "bytes32", + "name": "blockHash", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentBlockCoinbase", + "outputs": [ + { + "internalType": "address", + "name": "coinbase", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentBlockDifficulty", + "outputs": [ + { + "internalType": "uint256", + "name": "difficulty", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentBlockGasLimit", + "outputs": [ + { + "internalType": "uint256", + "name": "gaslimit", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentBlockTimestamp", + "outputs": [ + { + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "addr", + "type": "address" + } + ], + "name": "getEthBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getLastBlockHash", + "outputs": [ + { + "internalType": "bytes32", + "name": "blockHash", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "bytecode": "608060405234801561001057600080fd5b5061066e806100206000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c806372425d9d1161005b57806372425d9d146100e757806386d516e8146100ef578063a8b0574e146100f7578063ee82ac5e1461010c57610088565b80630f28c97d1461008d578063252dba42146100ab57806327e86d6e146100cc5780634d2301cc146100d4575b600080fd5b61009561011f565b6040516100a2919061051e565b60405180910390f35b6100be6100b93660046103b6565b610123565b6040516100a292919061052c565b610095610231565b6100956100e2366004610390565b61023a565b610095610247565b61009561024b565b6100ff61024f565b6040516100a2919061050a565b61009561011a3660046103eb565b610253565b4290565b60006060439150825160405190808252806020026020018201604052801561015f57816020015b606081526020019060019003908161014a5790505b50905060005b835181101561022b576000606085838151811061017e57fe5b6020026020010151600001516001600160a01b031686848151811061019f57fe5b6020026020010151602001516040516101b891906104fe565b6000604051808303816000865af19150503d80600081146101f5576040519150601f19603f3d011682016040523d82523d6000602084013e6101fa565b606091505b50915091508161020957600080fd5b8084848151811061021657fe5b60209081029190910101525050600101610165565b50915091565b60001943014090565b6001600160a01b03163190565b4490565b4590565b4190565b4090565b600061026382356105d4565b9392505050565b600082601f83011261027b57600080fd5b813561028e61028982610573565b61054c565b81815260209384019390925082018360005b838110156102cc57813586016102b68882610325565b84525060209283019291909101906001016102a0565b5050505092915050565b600082601f8301126102e757600080fd5b81356102f561028982610594565b9150808252602083016020830185838301111561031157600080fd5b61031c8382846105ee565b50505092915050565b60006040828403121561033757600080fd5b610341604061054c565b9050600061034f8484610257565b825250602082013567ffffffffffffffff81111561036c57600080fd5b610378848285016102d6565b60208301525092915050565b600061026382356105df565b6000602082840312156103a257600080fd5b60006103ae8484610257565b949350505050565b6000602082840312156103c857600080fd5b813567ffffffffffffffff8111156103df57600080fd5b6103ae8482850161026a565b6000602082840312156103fd57600080fd5b60006103ae8484610384565b60006102638383610497565b61041e816105d4565b82525050565b600061042f826105c2565b61043981856105c6565b93508360208202850161044b856105bc565b60005b84811015610482578383038852610466838351610409565b9250610471826105bc565b60209890980197915060010161044e565b50909695505050505050565b61041e816105df565b60006104a2826105c2565b6104ac81856105c6565b93506104bc8185602086016105fa565b6104c58161062a565b9093019392505050565b60006104da826105c2565b6104e481856105cf565b93506104f48185602086016105fa565b9290920192915050565b600061026382846104cf565b602081016105188284610415565b92915050565b60208101610518828461048e565b6040810161053a828561048e565b81810360208301526103ae8184610424565b60405181810167ffffffffffffffff8111828210171561056b57600080fd5b604052919050565b600067ffffffffffffffff82111561058a57600080fd5b5060209081020190565b600067ffffffffffffffff8211156105ab57600080fd5b506020601f91909101601f19160190565b60200190565b5190565b90815260200190565b919050565b6000610518826105e2565b90565b6001600160a01b031690565b82818337506000910152565b60005b838110156106155781810151838201526020016105fd565b83811115610624576000848401525b50505050565b601f01601f19169056fea265627a7a72305820978cd44d5ce226bebdf172bdf24918753b9e111e3803cb6249d3ca2860b7a47f6c6578706572696d656e74616cf50037" +} + diff --git a/packages/contracts/abi/index.ts b/packages/contracts/abi/index.ts index ea20c15..bdcb399 100644 --- a/packages/contracts/abi/index.ts +++ b/packages/contracts/abi/index.ts @@ -1,4 +1,7 @@ import VotingContract from './../build/VotingContract.json' import Directory from './../build/Directory.json' +import ERC20 from './ERC20.json' +import ERC20Mock from './ERC20Mock.json' +import MultiCall from './MultiCall.json' -export { VotingContract, Directory } \ No newline at end of file +export { VotingContract, Directory, ERC20, MultiCall, ERC20Mock } diff --git a/packages/contracts/contracts/VotingContract.sol b/packages/contracts/contracts/VotingContract.sol index c3f4e75..c98e3dd 100644 --- a/packages/contracts/contracts/VotingContract.sol +++ b/packages/contracts/contracts/VotingContract.sol @@ -1,5 +1,6 @@ pragma solidity ^0.8.5; +import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import '@openzeppelin/contracts/utils/cryptography/ECDSA.sol'; import '@openzeppelin/contracts/utils/math/SafeMath.sol'; import './Directory.sol'; @@ -33,6 +34,7 @@ contract VotingContract { address public owner; Directory public directory; + IERC20 public token; uint256 private latestVoting = 1; mapping(uint256 => VotingRoom) public votingRoomMap; @@ -41,8 +43,9 @@ contract VotingContract { uint256[] public activeVotingRooms; mapping(uint256 => uint256) private indexOfActiveVotingRooms; - constructor() { + constructor(IERC20 _address) { owner = msg.sender; + token = _address; } function setDirectory(Directory _address) public { @@ -94,6 +97,7 @@ contract VotingContract { if (voteType == VoteType.ADD) { require(!directory.isCommunityInDirectory(publicKey), 'Community already in directory'); } + require(token.balanceOf(msg.sender) >= voteAmount, 'not enough token'); VotingRoom storage newVotingRoom = votingRoomMap[latestVoting]; newVotingRoom.startBlock = block.number; newVotingRoom.endAt = block.timestamp.add(VOTING_LENGTH); @@ -140,6 +144,9 @@ contract VotingContract { emit VotingRoomFinalized(roomId, community, passed, votingRoomMap[roomId].voteType); } + event VoteCast(uint256 roomId, address voter); + event NotEnoughToken(uint256 roomId, address voter); + struct SignedVote { address voter; uint256 roomIdAndType; @@ -147,7 +154,6 @@ contract VotingContract { bytes32 r; bytes32 vs; } - event VoteCast(uint256 roomId, address voter); function castVotes(SignedVote[] calldata votes) public { for (uint256 i = 0; i < votes.length; i++) { @@ -162,14 +168,18 @@ contract VotingContract { VotingRoom storage room = votingRoomMap[roomId]; require(room.endAt > block.timestamp, 'vote closed'); if (room.voted[vote.voter] == false) { - if (vote.roomIdAndType & 1 == 1) { - room.totalVotesFor = room.totalVotesFor.add(vote.sntAmount); + if (token.balanceOf(vote.voter) >= vote.sntAmount) { + if (vote.roomIdAndType & 1 == 1) { + room.totalVotesFor = room.totalVotesFor.add(vote.sntAmount); + } else { + room.totalVotesAgainst = room.totalVotesAgainst.add(vote.sntAmount); + } + room.voters.push(vote.voter); + room.voted[vote.voter] = true; + emit VoteCast(roomId, vote.voter); } else { - room.totalVotesAgainst = room.totalVotesAgainst.add(vote.sntAmount); + emit NotEnoughToken(roomId, vote.voter); } - room.voters.push(vote.voter); - room.voted[vote.voter] = true; - emit VoteCast(roomId, vote.voter); } } } diff --git a/packages/contracts/deploy/deploy.ts b/packages/contracts/deploy/deploy.ts index a5829b5..2255f90 100644 --- a/packages/contracts/deploy/deploy.ts +++ b/packages/contracts/deploy/deploy.ts @@ -1,8 +1,6 @@ import { ethers } from 'ethers' import { deployContract } from 'ethereum-waffle' -import MockContract from '../build/MockContract.json' -import Directory from '../build/Directory.json' -import MultiCall from '../build/MultiCall.json' +import { VotingContract, Directory } from '../abi' const deploy = async () => { const providerName = process.env.ETHEREUM_PROVIDER @@ -14,14 +12,13 @@ const deploy = async () => { const provider = ethers.getDefaultProvider(process.env.ETHEREUM_PROVIDER) const wallet = new ethers.Wallet(privateKey, provider) - const mockContract = await deployContract(wallet, MockContract) - console.log(`Voting contract deployed with address: ${mockContract.address}`) + const votingContract = await deployContract(wallet, VotingContract,[process.env.ETHEREUM_TOKEN_ADDRESS]) + console.log(`Voting contract deployed with address: ${votingContract.address}`) - const directoryContract = await deployContract(wallet,Directory,[mockContract.address]) - await mockContract.setDirectory(directoryContract.address) + const directoryContract = await deployContract(wallet,Directory,[votingContract.address]) + await votingContract.setDirectory(directoryContract.address) console.log(`Directory contract deployed with address: ${directoryContract.address}`) - const multiCall = await deployContract(wallet, MultiCall) - console.log(`MultiCall deployed with address: ${multiCall.address}`) + } } diff --git a/packages/contracts/deploy/deployTestnet.ts b/packages/contracts/deploy/deployTestnet.ts new file mode 100644 index 0000000..275ee09 --- /dev/null +++ b/packages/contracts/deploy/deployTestnet.ts @@ -0,0 +1,33 @@ +import { BigNumber, ethers } from 'ethers' +import { deployContract } from 'ethereum-waffle' +import {VotingContract, Directory, MultiCall, ERC20Mock} from '../abi' + +const deploy = async () => { + const providerName = process.env.ETHEREUM_PROVIDER + const privateKey = process.env.ETHEREUM_PRIVATE_KEY + console.log(privateKey) + + if (privateKey && providerName) { + console.log(`deploying on ${providerName}`) + const provider = ethers.getDefaultProvider(process.env.ETHEREUM_PROVIDER) + const wallet = new ethers.Wallet(privateKey, provider) + + const ercArgs = ['MSNT', 'Mock SNT', wallet.address, BigNumber.from('0x33B2E3C9FD0803CE8000000')] + const erc20 = await deployContract(wallet,ERC20Mock,ercArgs) + console.log(`ERC20 Token deployed with address: ${erc20.address}`) + + const votingContract = await deployContract(wallet, VotingContract,[erc20.address]) + console.log(`Voting contract deployed with address: ${votingContract.address}`) + + const directoryContract = await deployContract(wallet,Directory,[votingContract.address]) + await votingContract.setDirectory(directoryContract.address) + console.log(`Directory contract deployed with address: ${directoryContract.address}`) + + const multiCall = await deployContract(wallet, MultiCall) + console.log(`MultiCall deployed with address: ${multiCall.address}`) + + } +} + +deploy() + diff --git a/packages/contracts/test/1.votingContract.test.ts b/packages/contracts/test/1.votingContract.test.ts index 1394222..1bd30cf 100644 --- a/packages/contracts/test/1.votingContract.test.ts +++ b/packages/contracts/test/1.votingContract.test.ts @@ -1,7 +1,6 @@ import { expect, use } from 'chai' import { loadFixture, deployContract, MockProvider, solidity } from 'ethereum-waffle' -import VotingContract from '../build/VotingContract.json' -import Directory from '../build/Directory.json' +import { VotingContract, Directory, ERC20Mock } from '../abi' import { utils, BigNumber, Wallet, Contract } from 'ethers' use(solidity) @@ -72,13 +71,17 @@ const voteAndFinalize = async ( describe('Contract', () => { async function fixture([alice, firstAddress, secondAddress]: any[], provider: any) { - const contract = await deployContract(alice, VotingContract) + const erc20 = await deployContract(alice, ERC20Mock, ['MSNT', 'Mock SNT', alice.address, 100000]) + await erc20.transfer(firstAddress.address, 10000) + await erc20.transfer(secondAddress.address, 10000) + const contract = await deployContract(alice, VotingContract, [erc20.address]) const directory = await deployContract(alice, Directory, [contract.address]) await contract.setDirectory(directory.address) await provider.send('evm_mine', [Math.floor(Date.now() / 1000)]) return { contract, directory, alice, firstAddress, secondAddress, provider } } loadFixture(fixture) + it('deploys properly', async () => { const { contract, directory } = await loadFixture(fixture) expect(await contract.directory()).to.eq(directory.address) @@ -94,10 +97,10 @@ describe('Contract', () => { describe('initialization', () => { it('initializes', async () => { const { contract, firstAddress, secondAddress } = await loadFixture(fixture) - expect(await contract.initializeVotingRoom(1, firstAddress.address, BigNumber.from(100))) + await expect(await contract.initializeVotingRoom(1, firstAddress.address, BigNumber.from(100))) .to.emit(contract, 'VotingRoomStarted') .withArgs(1, firstAddress.address) - expect(await contract.initializeVotingRoom(1, secondAddress.address, BigNumber.from(100))) + await expect(await contract.initializeVotingRoom(1, secondAddress.address, BigNumber.from(100))) .to.emit(contract, 'VotingRoomStarted') .withArgs(2, secondAddress.address) await expect(contract.initializeVotingRoom(1, secondAddress.address, BigNumber.from(100))).to.be.revertedWith( @@ -105,6 +108,13 @@ describe('Contract', () => { ) }) + it('not enough token', async () => { + const { contract } = await loadFixture(fixture) + await expect( + contract.initializeVotingRoom(1, '0xAcdd71e5Ef3Ab3356d62da78A941aAc08a18CF2b', BigNumber.from(10000000000000)) + ).to.be.revertedWith('not enough token') + }) + describe('directory interaction', () => { it('remove missing', async () => { const { contract } = await loadFixture(fixture) @@ -169,7 +179,7 @@ describe('Contract', () => { BigNumber.from(1), ]) await provider.send('evm_mine', [Math.floor(Date.now() / 1000 + 2000)]) - expect(await contract.finalizeVotingRoom(1)) + await expect(await contract.finalizeVotingRoom(1)) .to.emit(contract, 'VotingRoomFinalized') .withArgs(1, firstAddress.address, true, 1) expect((await contract.votingRoomMap(1)).slice(2)).to.deep.eq([ @@ -184,7 +194,7 @@ describe('Contract', () => { describe('directory interaction', () => { it('add community', async () => { - const { contract, directory, alice, provider, firstAddress } = await loadFixture(fixture) + const { contract, directory, provider, firstAddress } = await loadFixture(fixture) await contract.initializeVotingRoom(1, '0xAcdd71e5Ef3Ab3356d62da78A941aAc08a18CF2b', BigNumber.from(100)) await voteAndFinalize(1, 1, firstAddress, contract, provider) expect((await contract.votingRoomMap(1)).slice(2)).to.deep.eq([ @@ -199,7 +209,7 @@ describe('Contract', () => { }) it('remove community', async () => { - const { contract, directory, alice, provider, firstAddress } = await loadFixture(fixture) + const { contract, directory, provider, firstAddress } = await loadFixture(fixture) await contract.initializeVotingRoom(1, '0xAcdd71e5Ef3Ab3356d62da78A941aAc08a18CF2b', BigNumber.from(100)) await voteAndFinalize(1, 1, firstAddress, contract, provider) @@ -211,7 +221,7 @@ describe('Contract', () => { }) it('failed add vote', async () => { - const { contract, directory, alice, provider, firstAddress } = await loadFixture(fixture) + const { contract, directory, provider, firstAddress } = await loadFixture(fixture) await contract.initializeVotingRoom(1, '0xAcdd71e5Ef3Ab3356d62da78A941aAc08a18CF2b', BigNumber.from(100)) await voteAndFinalize(1, 0, firstAddress, contract, provider) @@ -219,7 +229,7 @@ describe('Contract', () => { }) it('failed remove vote', async () => { - const { contract, directory, alice, provider, firstAddress } = await loadFixture(fixture) + const { contract, directory, provider, firstAddress } = await loadFixture(fixture) await contract.initializeVotingRoom(1, '0xAcdd71e5Ef3Ab3356d62da78A941aAc08a18CF2b', BigNumber.from(100)) await voteAndFinalize(1, 1, firstAddress, contract, provider) @@ -284,6 +294,34 @@ describe('Contract', () => { expect(await contract.listRoomVoters(1)).to.deep.eq([alice.address, secondAddress.address]) }) + it('not enough tokens', async () => { + const { contract, firstAddress } = await loadFixture(fixture) + await contract.initializeVotingRoom(1, '0xabA1eF51ef4aE360a9e8C9aD2d787330B602eb24', BigNumber.from(100)) + + const types = ['address', 'uint256', 'uint256'] + const message = [firstAddress.address, BigNumber.from(1).mul(2).add(1), BigNumber.from(100000000000)] + + const signedMessage = [...message] + const signature = utils.splitSignature( + await firstAddress.signMessage(utils.arrayify(utils.solidityPack(types, message))) + ) + signedMessage.push(signature.r) + signedMessage.push(signature._vs) + + await expect(await contract.castVotes([signedMessage])) + .to.emit(contract, 'NotEnoughToken') + .withArgs(1, firstAddress.address) + + await expect((await contract.votingRoomMap(1)).slice(2)).to.deep.eq([ + 1, + false, + '0xabA1eF51ef4aE360a9e8C9aD2d787330B602eb24', + BigNumber.from(100), + BigNumber.from(0), + BigNumber.from(1), + ]) + }) + it('success', async () => { const { contract, alice, firstAddress, secondAddress } = await loadFixture(fixture) const { signedMessages } = await getSignedMessages(alice, firstAddress, secondAddress)