erc20-faucet

ERC20 token faucet
Log | Files | Refs

commit a091ea58797897d56c366ac25f2d0bb2b6fa1c9c
parent 60c42fd52e5d3cb4d44aaf9b24e17033bd8ad23b
Author: nolash <dev@holbrook.no>
Date:   Wed, 23 Dec 2020 19:15:24 +0100

Make accounts index optional

Diffstat:
Mpython/CHANGELOG | 2++
Mpython/erc20_single_shot_faucet/data/ERC20SingleShotFaucet.bin | 4++--
Mpython/erc20_single_shot_faucet/data/ERC20SingleShotFaucet.json | 2+-
Mpython/erc20_single_shot_faucet/data/ERC20SingleShotFaucetStorage.bin | 4++--
Mpython/erc20_single_shot_faucet/data/ERC20SingleShotFaucetStorage.json | 2+-
Mpython/erc20_single_shot_faucet/runnable/deploy.py | 7++++++-
Mpython/setup.cfg | 2+-
Mpython/tests/test_app.py | 1+
Mpython/tests/test_contract.py | 24++++++++++++++++++++++++
Msolidity/ERC20SingleShotFaucet.bin | 4++--
Msolidity/ERC20SingleShotFaucet.json | 2+-
Msolidity/ERC20SingleShotFaucet.sol | 19+++++++++++++++++--
Msolidity/ERC20SingleShotFaucetStorage.bin | 4++--
Msolidity/ERC20SingleShotFaucetStorage.json | 2+-
Msolidity/ERC20SingleShotFaucetStorage.sol | 2+-
Dsolidity/IERC20SingleShotFaucet.json | 0
Dsolidity/IERC20SingleShotFaucetStorage.json | 1-
Dsolidity/IERC20SingleShotFaucetStorage.sol | 10----------
Msolidity/Makefile | 6+++---
19 files changed, 67 insertions(+), 31 deletions(-)

diff --git a/python/CHANGELOG b/python/CHANGELOG @@ -1,3 +1,5 @@ +- 0.1.0 + * Add account index backend for verification of user - 0.0.4 * Fix owner flag processing typo - 0.0.3 diff --git a/python/erc20_single_shot_faucet/data/ERC20SingleShotFaucet.bin b/python/erc20_single_shot_faucet/data/ERC20SingleShotFaucet.bin @@ -1 +1 @@ -608060405234801561001057600080fd5b50604051610c9c380380610c9c8339818101604052606081101561003357600080fd5b810190808051604051939291908464010000000082111561005357600080fd5b8382019150602082018581111561006957600080fd5b825186602082028301116401000000008211171561008657600080fd5b8083526020830192505050908051906020019060200280838360005b838110156100bd5780820151818401526020810190506100a2565b505050509050016040526020018051906020019092919080519060200190929190505050336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060018060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060005b83518110156101fb57600180600086848151811061019557fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550808060010191505061017b565b5080600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505050610a0c806102906000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c8063271f88b41461005157806363e4bff414610095578063aa8c217c146100ef578063fc0c546a1461010d575b600080fd5b61007d6004803603602081101561006757600080fd5b8101908080359060200190929190505050610141565b60405180821515815260200191505060405180910390f35b6100d7600480360360208110156100ab57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506101a9565b60405180821515815260200191505060405180910390f35b6100f76109aa565b6040518082815260200191505060405180910390f35b6101156109b0565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661019957600080fd5b8160028190555060019050919050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561026b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600a8152602001807f4552525f4143434553530000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60006060600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1684604051602401808273ffffffffffffffffffffffffffffffffffffffff1681526020019150506040516020818303038152906040527f3ef25013000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040518082805190602001908083835b6020831061037f578051825260208201915060208101905060208303925061035c565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146103e1576040519150601f19603f3d011682016040523d82523d6000602084013e6103e6565b606091505b5091509150600060f81b81601f815181106103fd57fe5b602001015160f81c60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161461049d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f4552525f4143434f554e545f555345440000000000000000000000000000000081525060200191505060405180910390fd5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1684604051602401808273ffffffffffffffffffffffffffffffffffffffff1681526020019150506040516020818303038152906040527f0a3b0a4f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040518082805190602001908083835b602083106105ad578051825260208201915060208101905060208303925061058a565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d806000811461060f576040519150601f19603f3d011682016040523d82523d6000602084013e610614565b606091505b50809250819350505081610690576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600d8152602001807f4552525f4d41524b5f4641494c0000000000000000000000000000000000000081525060200191505060405180910390fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1684600254604051602401808373ffffffffffffffffffffffffffffffffffffffff168152602001828152602001925050506040516020818303038152906040527fa9059cbb000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040518082805190602001908083835b602083106107aa5780518252602082019150602081019050602083039250610787565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d806000811461080c576040519150601f19603f3d011682016040523d82523d6000602084013e610811565b606091505b5080925081935050508161091657600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f2a56a00a5c532c49314f19361f71cdca8a5d10fdcb42c3fa52800d13419d60706002546040518082815260200191505060405180910390a36040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600c8152602001807f4552525f5452414e53464552000000000000000000000000000000000000000081525060200191505060405180910390fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f45c201a59ac545000ead84f30b2db67da23353aa1d58ac522c48505412143ffa6002546040518082815260200191505060405180910390a3600192505050919050565b60025481565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168156fea2646970667358221220e0ede5e1243ce6ed0050846f23e33c21137442c6974e275c31336ae811e44c3064736f6c63430007050033 -\ No newline at end of file +60806040523480156200001157600080fd5b506040516200137738038062001377833981810160405281019062000037919062000310565b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060018060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060005b8451811015620001895760018060008784815181106200011a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080620001809062000436565b915050620000d1565b5081600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555082600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505050620004fc565b60006200026e6200026884620003c9565b62000395565b905080838252602082019050828560208602820111156200028e57600080fd5b60005b85811015620002c25781620002a78882620002cc565b84526020840193506020830192505060018101905062000291565b5050509392505050565b600081519050620002dd81620004e2565b92915050565b600082601f830112620002f557600080fd5b81516200030784826020860162000257565b91505092915050565b600080600080608085870312156200032757600080fd5b600085015167ffffffffffffffff8111156200034257600080fd5b6200035087828801620002e3565b94505060206200036387828801620002cc565b93505060406200037687828801620002cc565b92505060606200038987828801620002cc565b91505092959194509250565b6000604051905081810181811067ffffffffffffffff82111715620003bf57620003be620004b3565b5b8060405250919050565b600067ffffffffffffffff821115620003e757620003e6620004b3565b5b602082029050602081019050919050565b600062000405826200040c565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600062000443826200042c565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141562000479576200047862000484565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b620004ed81620003f8565b8114620004f957600080fd5b50565b610e6b806200050c6000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c8063271f88b41461005c57806363e4bff41461008c578063aa8c217c146100bc578063de82efb4146100da578063fc0c546a146100f8575b600080fd5b61007660048036038101906100719190610a6d565b610116565b6040516100839190610c8f565b60405180910390f35b6100a660048036038101906100a19190610a44565b61017e565b6040516100b39190610c8f565b60405180910390f35b6100c46109de565b6040516100d19190610d4a565b60405180910390f35b6100e26109e4565b6040516100ef9190610c8f565b60405180910390f35b6101006109f4565b60405161010d9190610c4b565b60405180910390f35b6000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661016e57600080fd5b8160028190555060019050919050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561020d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161020490610cca565b60405180910390fd5b60006060600073ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461043457600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16846040516024016102b19190610c4b565b6040516020818303038152906040527f3ef25013000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161033b9190610c34565b6000604051808303816000865af19150503d8060008114610378576040519150601f19603f3d011682016040523d82523d6000602084013e61037d565b606091505b508092508193505050600060f81b81601f815181106103c5577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602001015160f81c60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161415610433576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042a90610caa565b60405180910390fd5b5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168460405160240161047e9190610c4b565b6040516020818303038152906040527f3ef25013000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516105089190610c34565b6000604051808303816000865af19150503d8060008114610545576040519150601f19603f3d011682016040523d82523d6000602084013e61054a565b606091505b508092508193505050600060f81b81601f81518110610592577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602001015160f81c60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916146105ff576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105f690610d2a565b60405180910390fd5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16846040516024016106499190610c4b565b6040516020818303038152906040527f0a3b0a4f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516106d39190610c34565b6000604051808303816000865af19150503d8060008114610710576040519150601f19603f3d011682016040523d82523d6000602084013e610715565b606091505b5080925081935050508161075e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161075590610d0a565b60405180910390fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16846002546040516024016107ac929190610c66565b6040516020818303038152906040527fa9059cbb000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516108369190610c34565b6000604051808303816000865af19150503d8060008114610873576040519150601f19603f3d011682016040523d82523d6000602084013e610878565b606091505b5080925081935050508161094a57600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f2a56a00a5c532c49314f19361f71cdca8a5d10fdcb42c3fa52800d13419d60706002546040516109079190610d4a565b60405180910390a36040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161094190610cea565b60405180910390fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f45c201a59ac545000ead84f30b2db67da23353aa1d58ac522c48505412143ffa6002546040516109cb9190610d4a565b60405180910390a3600192505050919050565b60025481565b60006109ef3361017e565b905090565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600081359050610a2981610e07565b92915050565b600081359050610a3e81610e1e565b92915050565b600060208284031215610a5657600080fd5b6000610a6484828501610a1a565b91505092915050565b600060208284031215610a7f57600080fd5b6000610a8d84828501610a2f565b91505092915050565b610a9f81610d8c565b82525050565b610aae81610d9e565b82525050565b6000610abf82610d65565b610ac98185610d70565b9350610ad9818560208601610dd4565b80840191505092915050565b6000610af2601883610d7b565b91507f4552525f4143434f554e545f4e4f545f494e5f494e44455800000000000000006000830152602082019050919050565b6000610b32600a83610d7b565b91507f4552525f414343455353000000000000000000000000000000000000000000006000830152602082019050919050565b6000610b72600c83610d7b565b91507f4552525f5452414e5346455200000000000000000000000000000000000000006000830152602082019050919050565b6000610bb2600d83610d7b565b91507f4552525f4d41524b5f4641494c000000000000000000000000000000000000006000830152602082019050919050565b6000610bf2601083610d7b565b91507f4552525f4143434f554e545f55534544000000000000000000000000000000006000830152602082019050919050565b610c2e81610dca565b82525050565b6000610c408284610ab4565b915081905092915050565b6000602082019050610c606000830184610a96565b92915050565b6000604082019050610c7b6000830185610a96565b610c886020830184610c25565b9392505050565b6000602082019050610ca46000830184610aa5565b92915050565b60006020820190508181036000830152610cc381610ae5565b9050919050565b60006020820190508181036000830152610ce381610b25565b9050919050565b60006020820190508181036000830152610d0381610b65565b9050919050565b60006020820190508181036000830152610d2381610ba5565b9050919050565b60006020820190508181036000830152610d4381610be5565b9050919050565b6000602082019050610d5f6000830184610c25565b92915050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b6000610d9782610daa565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60005b83811015610df2578082015181840152602081019050610dd7565b83811115610e01576000848401525b50505050565b610e1081610d8c565b8114610e1b57600080fd5b50565b610e2781610dca565b8114610e3257600080fd5b5056fea26469706673582212204e2aa7962fa1a8b087c473c1b55b4176c808a1fee1b7a281257718c4d337985464736f6c63430008000033 +\ No newline at end of file diff --git a/python/erc20_single_shot_faucet/data/ERC20SingleShotFaucet.json b/python/erc20_single_shot_faucet/data/ERC20SingleShotFaucet.json @@ -1 +1 @@ -[{"inputs":[{"internalType":"address[]","name":"_overriders","type":"address[]"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_store","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_recipient","type":"address"},{"indexed":true,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"FaucetFail","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_recipient","type":"address"},{"indexed":true,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"FaucetUsed","type":"event"},{"inputs":[],"name":"amount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"}],"name":"giveTo","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"setAmount","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}] +[{"inputs":[{"internalType":"address[]","name":"_overriders","type":"address[]"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_store","type":"address"},{"internalType":"address","name":"_accountsIndex","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_recipient","type":"address"},{"indexed":true,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"FaucetFail","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_recipient","type":"address"},{"indexed":true,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"FaucetUsed","type":"event"},{"inputs":[],"name":"amount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gimme","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"}],"name":"giveTo","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"setAmount","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}] diff --git a/python/erc20_single_shot_faucet/data/ERC20SingleShotFaucetStorage.bin b/python/erc20_single_shot_faucet/data/ERC20SingleShotFaucetStorage.bin @@ -1 +1 @@ -608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061043b806100606000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80630a3b0a4f1461005c5780633ef25013146100b657806354974421146101105780637ff2f06314610130578063f2fde38b1461018a575b600080fd5b61009e6004803603602081101561007257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506101e4565b60405180821515815260200191505060405180910390f35b6100f8600480360360208110156100cc57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610247565b60405180821515815260200191505060405180910390f35b61011861029d565b60405180821515815260200191505060405180910390f35b6101726004803603602081101561014657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610340565b60405180821515815260200191505060405180910390f35b6101cc600480360360208110156101a057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610360565b60405180821515815260200191505060405180910390f35b60006001600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146102f957600080fd5b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001905090565b60026020528060005260406000206000915054906101000a900460ff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146103bb57600080fd5b81600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001905091905056fea26469706673582212205b3eda4b095c971ea514b2dd58564f6feedf18b3d8af79ff49ad853cb56067bb64736f6c63430007050033 -\ No newline at end of file +608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061044e806100606000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80630a3b0a4f1461005c5780633ef250131461008c57806379ba5097146100bc5780637ff2f063146100da578063f2fde38b1461010a575b600080fd5b61007660048036038101906100719190610370565b61013a565b60405161008391906103a8565b60405180910390f35b6100a660048036038101906100a19190610370565b61019d565b6040516100b391906103a8565b60405180910390f35b6100c46101f3565b6040516100d191906103a8565b60405180910390f35b6100f460048036038101906100ef9190610370565b610296565b60405161010191906103a8565b60405180910390f35b610124600480360381019061011f9190610370565b6102b6565b60405161013191906103a8565b60405180910390f35b60006001600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461024f57600080fd5b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001905090565b60026020528060005260406000206000915054906101000a900460ff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461031157600080fd5b81600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019050919050565b60008135905061036a81610401565b92915050565b60006020828403121561038257600080fd5b60006103908482850161035b565b91505092915050565b6103a2816103d5565b82525050565b60006020820190506103bd6000830184610399565b92915050565b60006103ce826103e1565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b61040a816103c3565b811461041557600080fd5b5056fea264697066735822122089d9d92d0f952459388e88c1e7d529a3f3153b399bf5949f24ff8ff0258880ca64736f6c63430008000033 +\ No newline at end of file diff --git a/python/erc20_single_shot_faucet/data/ERC20SingleShotFaucetStorage.json b/python/erc20_single_shot_faucet/data/ERC20SingleShotFaucetStorage.json @@ -1 +1 @@ -[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"add","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"completeOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"have","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_new_owner","type":"address"}],"name":"transferOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"used_accounts","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}] +[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"acceptOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"add","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"have","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_new_owner","type":"address"}],"name":"transferOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"used_accounts","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}] diff --git a/python/erc20_single_shot_faucet/runnable/deploy.py b/python/erc20_single_shot_faucet/runnable/deploy.py @@ -29,6 +29,7 @@ argparser.add_argument('-p', '--provider', dest='p', default='http://localhost:8 argparser.add_argument('-a', '--approvers', dest='a', action='append', type=str, help='Approver account to add') argparser.add_argument('-o', '--owner', dest='o', type=str, help='Owner account (provider must have private key)') argparser.add_argument('-t', '--token-address', dest='t', required=True, type=str, help='Token to add faucet for') +argparser.add_argument('-i', '--account-index-address', dest='i', required=False, type=str, help='Accounts index to verify requesting address against (if not specified, any address may use the faucet') argparser.add_argument('--abi-dir', dest='abi_dir', type=str, default=data_dir, help='Directory containing bytecode and abi (default: {})'.format(data_dir)) argparser.add_argument('-v', action='store_true', help='Be verbose') args = argparser.parse_args() @@ -73,7 +74,11 @@ def main(): approvers.append(a) logg.info('add approver {}'.format(a)) - tx_hash = c.constructor(approvers, token_address, store_address).transact() + accounts_index_address = '0x0000000000000000000000000000000000000000' + if args.i != None: + accounts_index_address = args.i + + tx_hash = c.constructor(approvers, token_address, store_address, accounts_index_address).transact() rcpt = w3.eth.getTransactionReceipt(tx_hash) address = rcpt.contractAddress print(address) diff --git a/python/setup.cfg b/python/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = erc20-single-shot-faucet -version = 0.0.4 +version = 0.1.0 description = ERC20 token faucet that can be used once per account author = Louis Holbrook author_email = dev@holbrook.no diff --git a/python/tests/test_app.py b/python/tests/test_app.py @@ -89,6 +89,7 @@ class Test(unittest.TestCase): ], self.address_token, self.address_storage, + '0x0000000000000000000000000000000000000000', ).transact({'from': self.w3.eth.accounts[0]}) r = self.w3.eth.getTransactionReceipt(tx_hash) diff --git a/python/tests/test_contract.py b/python/tests/test_contract.py @@ -46,6 +46,11 @@ class Test(unittest.TestCase): self.address_storage = r.contractAddress + # create mock external accounts index + c = self.w3.eth.contract(abi=self.abi_storage, bytecode=bytecode) + tx_hash = c.constructor().transact({'from': self.w3.eth.accounts[0]}) + r = self.w3.eth.getTransactionReceipt(tx_hash) + self.address_index = r.contractAddress # create token f = open(os.path.join(testdir, '../erc20_single_shot_faucet/data/GiftableToken.bin'), 'r') @@ -87,6 +92,7 @@ class Test(unittest.TestCase): ], self.address_token, self.address_storage, + self.address_index, ).transact({'from': self.w3.eth.accounts[0]}) r = self.w3.eth.getTransactionReceipt(tx_hash) @@ -109,9 +115,25 @@ class Test(unittest.TestCase): c.functions.setAmount(30).transact({'from': self.w3.eth.accounts[3]}) + def test_gimme(self): + c = self.w3.eth.contract(abi=self.abi_faucet, address=self.address_faucet) + c.functions.setAmount(10).transact({'from': self.w3.eth.accounts[2]}) + + with self.assertRaises(Exception): + c.functions.gimme().transact({'from': self.w3.eth.accounts[3]}) + + ci = self.w3.eth.contract(abi=self.abi_storage, address=self.address_index) + ci.functions.add(self.w3.eth.accounts[3]).transact() + c.functions.gimme().transact({'from': self.w3.eth.accounts[3]}) + + def test_giveto(self): c = self.w3.eth.contract(abi=self.abi_faucet, address=self.address_faucet) + ci = self.w3.eth.contract(abi=self.abi_storage, address=self.address_index) + ci.functions.add(self.w3.eth.accounts[3]).transact() + c.functions.setAmount(10).transact({'from': self.w3.eth.accounts[2]}) + #with self.assertRaises(Exception): c.functions.giveTo(self.w3.eth.accounts[3]).transact({'from': self.w3.eth.accounts[1]}) t = self.w3.eth.contract(abi=self.abi_token, address=self.address_token) @@ -122,10 +144,12 @@ class Test(unittest.TestCase): c.functions.giveTo(self.w3.eth.accounts[3]).transact({'from': self.w3.eth.accounts[1]}) c.functions.setAmount(50).transact({'from': self.w3.eth.accounts[1]}) + ci.functions.add(self.w3.eth.accounts[4]).transact() c.functions.giveTo(self.w3.eth.accounts[4]).transact({'from': self.w3.eth.accounts[1]}) self.assertEqual(t.functions.balanceOf(self.w3.eth.accounts[4]).call(), 50); self.assertEqual(t.functions.balanceOf(self.address_faucet).call(), 40); + ci.functions.add(self.w3.eth.accounts[5]).transact() with self.assertRaises(Exception): c.functions.giveTo(self.w3.eth.accounts[5]).transact({'from': self.w3.eth.accounts[1]}) self.assertEqual(t.functions.balanceOf(self.w3.eth.accounts[5]).call(), 0); diff --git a/solidity/ERC20SingleShotFaucet.bin b/solidity/ERC20SingleShotFaucet.bin @@ -1 +1 @@ -608060405234801561001057600080fd5b50604051610c9c380380610c9c8339818101604052606081101561003357600080fd5b810190808051604051939291908464010000000082111561005357600080fd5b8382019150602082018581111561006957600080fd5b825186602082028301116401000000008211171561008657600080fd5b8083526020830192505050908051906020019060200280838360005b838110156100bd5780820151818401526020810190506100a2565b505050509050016040526020018051906020019092919080519060200190929190505050336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060018060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060005b83518110156101fb57600180600086848151811061019557fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550808060010191505061017b565b5080600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505050610a0c806102906000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c8063271f88b41461005157806363e4bff414610095578063aa8c217c146100ef578063fc0c546a1461010d575b600080fd5b61007d6004803603602081101561006757600080fd5b8101908080359060200190929190505050610141565b60405180821515815260200191505060405180910390f35b6100d7600480360360208110156100ab57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506101a9565b60405180821515815260200191505060405180910390f35b6100f76109aa565b6040518082815260200191505060405180910390f35b6101156109b0565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661019957600080fd5b8160028190555060019050919050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561026b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600a8152602001807f4552525f4143434553530000000000000000000000000000000000000000000081525060200191505060405180910390fd5b60006060600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1684604051602401808273ffffffffffffffffffffffffffffffffffffffff1681526020019150506040516020818303038152906040527f3ef25013000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040518082805190602001908083835b6020831061037f578051825260208201915060208101905060208303925061035c565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146103e1576040519150601f19603f3d011682016040523d82523d6000602084013e6103e6565b606091505b5091509150600060f81b81601f815181106103fd57fe5b602001015160f81c60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161461049d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260108152602001807f4552525f4143434f554e545f555345440000000000000000000000000000000081525060200191505060405180910390fd5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1684604051602401808273ffffffffffffffffffffffffffffffffffffffff1681526020019150506040516020818303038152906040527f0a3b0a4f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040518082805190602001908083835b602083106105ad578051825260208201915060208101905060208303925061058a565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d806000811461060f576040519150601f19603f3d011682016040523d82523d6000602084013e610614565b606091505b50809250819350505081610690576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600d8152602001807f4552525f4d41524b5f4641494c0000000000000000000000000000000000000081525060200191505060405180910390fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1684600254604051602401808373ffffffffffffffffffffffffffffffffffffffff168152602001828152602001925050506040516020818303038152906040527fa9059cbb000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040518082805190602001908083835b602083106107aa5780518252602082019150602081019050602083039250610787565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d806000811461080c576040519150601f19603f3d011682016040523d82523d6000602084013e610811565b606091505b5080925081935050508161091657600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f2a56a00a5c532c49314f19361f71cdca8a5d10fdcb42c3fa52800d13419d60706002546040518082815260200191505060405180910390a36040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600c8152602001807f4552525f5452414e53464552000000000000000000000000000000000000000081525060200191505060405180910390fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f45c201a59ac545000ead84f30b2db67da23353aa1d58ac522c48505412143ffa6002546040518082815260200191505060405180910390a3600192505050919050565b60025481565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168156fea2646970667358221220e0ede5e1243ce6ed0050846f23e33c21137442c6974e275c31336ae811e44c3064736f6c63430007050033 -\ No newline at end of file +60806040523480156200001157600080fd5b506040516200137738038062001377833981810160405281019062000037919062000310565b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060018060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060005b8451811015620001895760018060008784815181106200011a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080620001809062000436565b915050620000d1565b5081600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555082600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050505050620004fc565b60006200026e6200026884620003c9565b62000395565b905080838252602082019050828560208602820111156200028e57600080fd5b60005b85811015620002c25781620002a78882620002cc565b84526020840193506020830192505060018101905062000291565b5050509392505050565b600081519050620002dd81620004e2565b92915050565b600082601f830112620002f557600080fd5b81516200030784826020860162000257565b91505092915050565b600080600080608085870312156200032757600080fd5b600085015167ffffffffffffffff8111156200034257600080fd5b6200035087828801620002e3565b94505060206200036387828801620002cc565b93505060406200037687828801620002cc565b92505060606200038987828801620002cc565b91505092959194509250565b6000604051905081810181811067ffffffffffffffff82111715620003bf57620003be620004b3565b5b8060405250919050565b600067ffffffffffffffff821115620003e757620003e6620004b3565b5b602082029050602081019050919050565b600062000405826200040c565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600062000443826200042c565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141562000479576200047862000484565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b620004ed81620003f8565b8114620004f957600080fd5b50565b610e6b806200050c6000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c8063271f88b41461005c57806363e4bff41461008c578063aa8c217c146100bc578063de82efb4146100da578063fc0c546a146100f8575b600080fd5b61007660048036038101906100719190610a6d565b610116565b6040516100839190610c8f565b60405180910390f35b6100a660048036038101906100a19190610a44565b61017e565b6040516100b39190610c8f565b60405180910390f35b6100c46109de565b6040516100d19190610d4a565b60405180910390f35b6100e26109e4565b6040516100ef9190610c8f565b60405180910390f35b6101006109f4565b60405161010d9190610c4b565b60405180910390f35b6000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661016e57600080fd5b8160028190555060019050919050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561020d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161020490610cca565b60405180910390fd5b60006060600073ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461043457600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16846040516024016102b19190610c4b565b6040516020818303038152906040527f3ef25013000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161033b9190610c34565b6000604051808303816000865af19150503d8060008114610378576040519150601f19603f3d011682016040523d82523d6000602084013e61037d565b606091505b508092508193505050600060f81b81601f815181106103c5577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602001015160f81c60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161415610433576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161042a90610caa565b60405180910390fd5b5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168460405160240161047e9190610c4b565b6040516020818303038152906040527f3ef25013000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516105089190610c34565b6000604051808303816000865af19150503d8060008114610545576040519150601f19603f3d011682016040523d82523d6000602084013e61054a565b606091505b508092508193505050600060f81b81601f81518110610592577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602001015160f81c60f81b7effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916146105ff576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105f690610d2a565b60405180910390fd5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16846040516024016106499190610c4b565b6040516020818303038152906040527f0a3b0a4f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516106d39190610c34565b6000604051808303816000865af19150503d8060008114610710576040519150601f19603f3d011682016040523d82523d6000602084013e610715565b606091505b5080925081935050508161075e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161075590610d0a565b60405180910390fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16846002546040516024016107ac929190610c66565b6040516020818303038152906040527fa9059cbb000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516108369190610c34565b6000604051808303816000865af19150503d8060008114610873576040519150601f19603f3d011682016040523d82523d6000602084013e610878565b606091505b5080925081935050508161094a57600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f2a56a00a5c532c49314f19361f71cdca8a5d10fdcb42c3fa52800d13419d60706002546040516109079190610d4a565b60405180910390a36040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161094190610cea565b60405180910390fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f45c201a59ac545000ead84f30b2db67da23353aa1d58ac522c48505412143ffa6002546040516109cb9190610d4a565b60405180910390a3600192505050919050565b60025481565b60006109ef3361017e565b905090565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600081359050610a2981610e07565b92915050565b600081359050610a3e81610e1e565b92915050565b600060208284031215610a5657600080fd5b6000610a6484828501610a1a565b91505092915050565b600060208284031215610a7f57600080fd5b6000610a8d84828501610a2f565b91505092915050565b610a9f81610d8c565b82525050565b610aae81610d9e565b82525050565b6000610abf82610d65565b610ac98185610d70565b9350610ad9818560208601610dd4565b80840191505092915050565b6000610af2601883610d7b565b91507f4552525f4143434f554e545f4e4f545f494e5f494e44455800000000000000006000830152602082019050919050565b6000610b32600a83610d7b565b91507f4552525f414343455353000000000000000000000000000000000000000000006000830152602082019050919050565b6000610b72600c83610d7b565b91507f4552525f5452414e5346455200000000000000000000000000000000000000006000830152602082019050919050565b6000610bb2600d83610d7b565b91507f4552525f4d41524b5f4641494c000000000000000000000000000000000000006000830152602082019050919050565b6000610bf2601083610d7b565b91507f4552525f4143434f554e545f55534544000000000000000000000000000000006000830152602082019050919050565b610c2e81610dca565b82525050565b6000610c408284610ab4565b915081905092915050565b6000602082019050610c606000830184610a96565b92915050565b6000604082019050610c7b6000830185610a96565b610c886020830184610c25565b9392505050565b6000602082019050610ca46000830184610aa5565b92915050565b60006020820190508181036000830152610cc381610ae5565b9050919050565b60006020820190508181036000830152610ce381610b25565b9050919050565b60006020820190508181036000830152610d0381610b65565b9050919050565b60006020820190508181036000830152610d2381610ba5565b9050919050565b60006020820190508181036000830152610d4381610be5565b9050919050565b6000602082019050610d5f6000830184610c25565b92915050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b6000610d9782610daa565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60005b83811015610df2578082015181840152602081019050610dd7565b83811115610e01576000848401525b50505050565b610e1081610d8c565b8114610e1b57600080fd5b50565b610e2781610dca565b8114610e3257600080fd5b5056fea26469706673582212204e2aa7962fa1a8b087c473c1b55b4176c808a1fee1b7a281257718c4d337985464736f6c63430008000033 +\ No newline at end of file diff --git a/solidity/ERC20SingleShotFaucet.json b/solidity/ERC20SingleShotFaucet.json @@ -1 +1 @@ -[{"inputs":[{"internalType":"address[]","name":"_overriders","type":"address[]"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_store","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_recipient","type":"address"},{"indexed":true,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"FaucetFail","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_recipient","type":"address"},{"indexed":true,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"FaucetUsed","type":"event"},{"inputs":[],"name":"amount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"}],"name":"giveTo","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"setAmount","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}] +[{"inputs":[{"internalType":"address[]","name":"_overriders","type":"address[]"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_store","type":"address"},{"internalType":"address","name":"_accountsIndex","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_recipient","type":"address"},{"indexed":true,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"FaucetFail","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_recipient","type":"address"},{"indexed":true,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"FaucetUsed","type":"event"},{"inputs":[],"name":"amount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gimme","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"}],"name":"giveTo","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"setAmount","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}] diff --git a/solidity/ERC20SingleShotFaucet.sol b/solidity/ERC20SingleShotFaucet.sol @@ -9,11 +9,12 @@ contract SingleShotFaucet { uint256 public amount; address public token; address store; + address accountsIndex; event FaucetUsed(address indexed _recipient, address indexed _token, uint256 _value); event FaucetFail(address indexed _recipient, address indexed _token, uint256 _value); - constructor(address[] memory _overriders, address _token, address _store) public { + constructor(address[] memory _overriders, address _token, address _store, address _accountsIndex) { owner = msg.sender; overriders[msg.sender] = true; for (uint i = 0; i < _overriders.length; i++) { @@ -21,6 +22,7 @@ contract SingleShotFaucet { } store = _store; token = _token; + accountsIndex = _accountsIndex; } function setAmount(uint256 _amount) public returns (bool) { @@ -29,9 +31,22 @@ contract SingleShotFaucet { return true; } + function gimme() public returns (bool) { + return giveTo(msg.sender); + } + function giveTo(address _recipient) public returns (bool) { require(!overriders[_recipient], 'ERR_ACCESS'); - (bool _ok, bytes memory _result) = store.call(abi.encodeWithSignature("have(address)", _recipient)); + + bool _ok; + bytes memory _result; + + if (accountsIndex != address(0)) { + (_ok, _result) = accountsIndex.call(abi.encodeWithSignature("have(address)", _recipient)); + require(_result[31] != 0, 'ERR_ACCOUNT_NOT_IN_INDEX'); + } + + (_ok, _result) = store.call(abi.encodeWithSignature("have(address)", _recipient)); require(_result[31] == 0, 'ERR_ACCOUNT_USED'); // less conversion than: // require(abi.decode(_result, (bool)) == false, 'ERR_ACCOUNT_USED'); diff --git a/solidity/ERC20SingleShotFaucetStorage.bin b/solidity/ERC20SingleShotFaucetStorage.bin @@ -1 +1 @@ -608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061043b806100606000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80630a3b0a4f1461005c5780633ef25013146100b657806354974421146101105780637ff2f06314610130578063f2fde38b1461018a575b600080fd5b61009e6004803603602081101561007257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506101e4565b60405180821515815260200191505060405180910390f35b6100f8600480360360208110156100cc57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610247565b60405180821515815260200191505060405180910390f35b61011861029d565b60405180821515815260200191505060405180910390f35b6101726004803603602081101561014657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610340565b60405180821515815260200191505060405180910390f35b6101cc600480360360208110156101a057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610360565b60405180821515815260200191505060405180910390f35b60006001600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146102f957600080fd5b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001905090565b60026020528060005260406000206000915054906101000a900460ff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146103bb57600080fd5b81600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001905091905056fea26469706673582212205b3eda4b095c971ea514b2dd58564f6feedf18b3d8af79ff49ad853cb56067bb64736f6c63430007050033 -\ No newline at end of file +608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061044e806100606000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c80630a3b0a4f1461005c5780633ef250131461008c57806379ba5097146100bc5780637ff2f063146100da578063f2fde38b1461010a575b600080fd5b61007660048036038101906100719190610370565b61013a565b60405161008391906103a8565b60405180910390f35b6100a660048036038101906100a19190610370565b61019d565b6040516100b391906103a8565b60405180910390f35b6100c46101f3565b6040516100d191906103a8565b60405180910390f35b6100f460048036038101906100ef9190610370565b610296565b60405161010191906103a8565b60405180910390f35b610124600480360381019061011f9190610370565b6102b6565b60405161013191906103a8565b60405180910390f35b60006001600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060019050919050565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461024f57600080fd5b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001905090565b60026020528060005260406000206000915054906101000a900460ff1681565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461031157600080fd5b81600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060019050919050565b60008135905061036a81610401565b92915050565b60006020828403121561038257600080fd5b60006103908482850161035b565b91505092915050565b6103a2816103d5565b82525050565b60006020820190506103bd6000830184610399565b92915050565b60006103ce826103e1565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b61040a816103c3565b811461041557600080fd5b5056fea264697066735822122089d9d92d0f952459388e88c1e7d529a3f3153b399bf5949f24ff8ff0258880ca64736f6c63430008000033 +\ No newline at end of file diff --git a/solidity/ERC20SingleShotFaucetStorage.json b/solidity/ERC20SingleShotFaucetStorage.json @@ -1 +1 @@ -[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"add","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"completeOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"have","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_new_owner","type":"address"}],"name":"transferOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"used_accounts","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}] +[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"acceptOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"add","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"have","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_new_owner","type":"address"}],"name":"transferOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"used_accounts","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}] diff --git a/solidity/ERC20SingleShotFaucetStorage.sol b/solidity/ERC20SingleShotFaucetStorage.sol @@ -8,7 +8,7 @@ contract SingleShotFaucetStorage { mapping (address => bool) public used_accounts; - constructor() public { + constructor() { owner = msg.sender; } diff --git a/solidity/IERC20SingleShotFaucet.json b/solidity/IERC20SingleShotFaucet.json diff --git a/solidity/IERC20SingleShotFaucetStorage.json b/solidity/IERC20SingleShotFaucetStorage.json @@ -1 +0,0 @@ -[{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"add","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"completeOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"have","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"transferOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}] diff --git a/solidity/IERC20SingleShotFaucetStorage.sol b/solidity/IERC20SingleShotFaucetStorage.sol @@ -1,10 +0,0 @@ -pragma solidity >=0.6.21; - -// SPDX-License-Identifier: GPL-3.0-or-later - -interface ISingleShotFaucetStorage { - function transferOwnership(address) external returns(bool); - function completeOwnership() external returns(bool); - function add(address) external returns(bool); - function have(address) external returns(bool); -} diff --git a/solidity/Makefile b/solidity/Makefile @@ -1,11 +1,11 @@ all: solc --bin ERC20SingleShotFaucetStorage.sol | awk 'NR>3' > ERC20SingleShotFaucetStorage.bin truncate -s -1 ERC20SingleShotFaucetStorage.bin - solc --abi ERC20SingleShotFaucetStorage.sol | awk 'NR>3' > ERC20SingleShotFaucetStorage.abi.json + solc --abi ERC20SingleShotFaucetStorage.sol | awk 'NR>3' > ERC20SingleShotFaucetStorage.json solc --bin ERC20SingleShotFaucet.sol | awk 'NR>3' > ERC20SingleShotFaucet.bin truncate -s -1 ERC20SingleShotFaucet.bin - solc --abi ERC20SingleShotFaucet.sol | awk 'NR==4' > ERC20SingleShotFaucet.abi.json - solc --abi IERC20SingleShotFaucetStorage.sol | awk 'NR>3' > IERC20SingleShotFaucetStorage.abi.json + solc --abi ERC20SingleShotFaucet.sol | awk 'NR==4' > ERC20SingleShotFaucet.json + #solc --abi IERC20SingleShotFaucetStorage.sol | awk 'NR>3' > IERC20SingleShotFaucetStorage.abi.json install: all cp -v *{json,bin} ../python/erc20_single_shot_faucet/data/