erc20-faucet

ERC20 token faucet
Log | Files | Refs

commit d9b2665318fc2189d85cdabe0a337688e5d9aedb
parent 026ca30dcd7d51be29c9d14da36d2d61c06b8284
Author: nolash <dev@holbrook.no>
Date:   Fri, 30 Jul 2021 14:06:26 +0200

Implement chainlib cli util

Diffstat:
Mpython/erc20_faucet/data/ERC20Faucet.bin | 4++--
Mpython/erc20_faucet/data/ERC20FaucetStorage.bin | 4++--
Mpython/erc20_faucet/interface.py | 12+++++++-----
Mpython/erc20_faucet/runnable/deploy.py | 190++++++++++++++++++++++++++++++++++++-------------------------------------------
Apython/erc20_faucet/runnable/gift.py | 91+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mpython/erc20_faucet/runnable/list.py | 76++++++++++++++++++++++++++++++++++++++--------------------------------------
Mpython/setup.cfg | 2+-
Msolidity/ERC20Faucet.sol | 5++++-
8 files changed, 232 insertions(+), 152 deletions(-)

diff --git a/python/erc20_faucet/data/ERC20Faucet.bin b/python/erc20_faucet/data/ERC20Faucet.bin @@ -1 +1 @@ -60806040523480156200001157600080fd5b506040516200169d3803806200169d833981810160405281019062000037919062000337565b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060018060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060005b8451811015620001895760018060008784815181106200011a577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080620001809062000488565b915050620000d1565b5081600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555082600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600681905550505050506200055f565b6000620002956200028f84620003e5565b620003bc565b90508083825260208201905082856020860282011115620002b557600080fd5b60005b85811015620002e95781620002ce8882620002f3565b845260208401935060208301925050600181019050620002b8565b5050509392505050565b600081519050620003048162000545565b92915050565b600082601f8301126200031c57600080fd5b81516200032e8482602086016200027e565b91505092915050565b600080600080608085870312156200034e57600080fd5b600085015167ffffffffffffffff8111156200036957600080fd5b62000377878288016200030a565b94505060206200038a87828801620002f3565b93505060406200039d87828801620002f3565b9250506060620003b087828801620002f3565b91505092959194509250565b6000620003c8620003db565b9050620003d6828262000452565b919050565b6000604051905090565b600067ffffffffffffffff82111562000403576200040262000505565b5b602082029050602081019050919050565b6000620004218262000428565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6200045d8262000534565b810181811067ffffffffffffffff821117156200047f576200047e62000505565b5b80604052505050565b6000620004958262000448565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415620004cb57620004ca620004d6565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b620005508162000414565b81146200055c57600080fd5b50565b61112e806200056f6000396000f3fe608060405234801561001057600080fd5b506004361061007f576000357c010000000000000000000000000000000000000000000000000000000090048063271f88b41461008457806363e4bff4146100b4578063aa8c217c146100e4578063b222e0c214610102578063eec7faa114610132578063fc0c546a14610150575b600080fd5b61009e60048036038101906100999190610cf4565b61016e565b6040516100ab9190610e85565b60405180910390f35b6100ce60048036038101906100c99190610ccb565b61020d565b6040516100db9190610e85565b60405180910390f35b6100ec610b29565b6040516100f99190610f40565b60405180910390f35b61011c60048036038101906101179190610ccb565b610b2f565b6040516101299190610f40565b60405180910390f35b61013a610c71565b6040516101479190610f40565b60405180910390f35b610158610c7b565b6040516101659190610e41565b60405180910390f35b6000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166101c657600080fd5b816002819055507f748f1cf617bdc8ef4fcd1cb516dc05cedf269e8dcad82183846d57eeec4bba5e826040516101fc9190610f40565b60405180910390a160019050919050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561029c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161029390610ec0565b60405180910390fd5b60006060600073ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461052157600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16846040516024016103409190610e41565b6040516020818303038152906040527f3ef25013000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516103ca9190610e2a565b6000604051808303816000865af19150503d8060008114610407576040519150601f19603f3d011682016040523d82523d6000602084013e61040c565b606091505b50809250819350505060007f01000000000000000000000000000000000000000000000000000000000000000281601f81518110610473577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161415610520576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161051790610ea0565b60405180910390fd5b5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168460405160240161056b9190610e41565b6040516020818303038152906040527f3ef25013000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516105f59190610e2a565b6000604051808303816000865af19150503d8060008114610632576040519150601f19603f3d011682016040523d82523d6000602084013e610637565b606091505b50809250819350505060007f01000000000000000000000000000000000000000000000000000000000000000281601f8151811061069e577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161461074a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161074190610f20565b60405180910390fd5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16846040516024016107949190610e41565b6040516020818303038152906040527f0a3b0a4f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161081e9190610e2a565b6000604051808303816000865af19150503d806000811461085b576040519150601f19603f3d011682016040523d82523d6000602084013e610860565b606091505b508092508193505050816108a9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108a090610f00565b60405180910390fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16846002546040516024016108f7929190610e5c565b6040516020818303038152906040527fa9059cbb000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516109819190610e2a565b6000604051808303816000865af19150503d80600081146109be576040519150601f19603f3d011682016040523d82523d6000602084013e6109c3565b606091505b50809250819350505081610a9557600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f2a56a00a5c532c49314f19361f71cdca8a5d10fdcb42c3fa52800d13419d6070600254604051610a529190610f40565b60405180910390a36040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a8c90610ee0565b60405180910390fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f45c201a59ac545000ead84f30b2db67da23353aa1d58ac522c48505412143ffa600254604051610b169190610f40565b60405180910390a3600192505050919050565b60025481565b6000806060600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1684604051602401610b7e9190610e41565b6040516020818303038152906040527f3ef25013000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610c089190610e2a565b6000604051808303816000865af19150503d8060008114610c45576040519150601f19603f3d011682016040523d82523d6000602084013e610c4a565b606091505b5080925081935050508115610c655760065492505050610c6c565b6000925050505b919050565b6000600254905090565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600081359050610cb0816110ca565b92915050565b600081359050610cc5816110e1565b92915050565b600060208284031215610cdd57600080fd5b6000610ceb84828501610ca1565b91505092915050565b600060208284031215610d0657600080fd5b6000610d1484828501610cb6565b91505092915050565b610d2681610f82565b82525050565b610d3581610f94565b82525050565b6000610d4682610f5b565b610d508185610f66565b9350610d60818560208601610fca565b80840191505092915050565b6000610d79601883610f71565b9150610d8482610ffd565b602082019050919050565b6000610d9c600a83610f71565b9150610da782611026565b602082019050919050565b6000610dbf600c83610f71565b9150610dca8261104f565b602082019050919050565b6000610de2600d83610f71565b9150610ded82611078565b602082019050919050565b6000610e05601083610f71565b9150610e10826110a1565b602082019050919050565b610e2481610fc0565b82525050565b6000610e368284610d3b565b915081905092915050565b6000602082019050610e566000830184610d1d565b92915050565b6000604082019050610e716000830185610d1d565b610e7e6020830184610e1b565b9392505050565b6000602082019050610e9a6000830184610d2c565b92915050565b60006020820190508181036000830152610eb981610d6c565b9050919050565b60006020820190508181036000830152610ed981610d8f565b9050919050565b60006020820190508181036000830152610ef981610db2565b9050919050565b60006020820190508181036000830152610f1981610dd5565b9050919050565b60006020820190508181036000830152610f3981610df8565b9050919050565b6000602082019050610f556000830184610e1b565b92915050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b6000610f8d82610fa0565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60005b83811015610fe8578082015181840152602081019050610fcd565b83811115610ff7576000848401525b50505050565b7f4552525f4143434f554e545f4e4f545f494e5f494e4445580000000000000000600082015250565b7f4552525f41434345535300000000000000000000000000000000000000000000600082015250565b7f4552525f5452414e534645520000000000000000000000000000000000000000600082015250565b7f4552525f4d41524b5f4641494c00000000000000000000000000000000000000600082015250565b7f4552525f4143434f554e545f5553454400000000000000000000000000000000600082015250565b6110d381610f82565b81146110de57600080fd5b50565b6110ea81610fc0565b81146110f557600080fd5b5056fea26469706673582212201f985ab901d8feafa4592bd72d71bd6a1e9e0b376930c202b22457d5c7b14c8764736f6c63430008030033 -\ No newline at end of file +60806040523480156200001157600080fd5b50604051620018143803806200181483398181016040528101906200003791906200031f565b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060018060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060005b845181101562000165576001806000878481518110620000f657620000f5620004f9565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555080806200015c906200047c565b915050620000d1565b5081600460006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555082600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6006819055505050505062000596565b6000620002716200026b84620003d9565b620003b0565b905080838252602082019050828560208602820111156200029757620002966200055c565b5b60005b85811015620002cb5781620002b08882620002d5565b8452602084019350602083019250506001810190506200029a565b5050509392505050565b600081519050620002e6816200057c565b92915050565b600082601f83011262000304576200030362000557565b5b8151620003168482602086016200025a565b91505092915050565b600080600080608085870312156200033c576200033b62000566565b5b600085015167ffffffffffffffff8111156200035d576200035c62000561565b5b6200036b87828801620002ec565b94505060206200037e87828801620002d5565b93505060406200039187828801620002d5565b9250506060620003a487828801620002d5565b91505092959194509250565b6000620003bc620003cf565b9050620003ca828262000446565b919050565b6000604051905090565b600067ffffffffffffffff821115620003f757620003f662000528565b5b602082029050602081019050919050565b600062000415826200041c565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b62000451826200056b565b810181811067ffffffffffffffff8211171562000473576200047262000528565b5b80604052505050565b600062000489826200043c565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415620004bf57620004be620004ca565b5b600182019050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b620005878162000408565b81146200059357600080fd5b50565b61126e80620005a66000396000f3fe608060405234801561001057600080fd5b506004361061007f576000357c010000000000000000000000000000000000000000000000000000000090048063271f88b41461008457806363e4bff4146100b4578063aa8c217c146100e4578063b222e0c214610102578063eec7faa114610132578063fc0c546a14610150575b600080fd5b61009e60048036038101906100999190610d90565b61016e565b6040516100ab9190610f48565b60405180910390f35b6100ce60048036038101906100c99190610d63565b61020d565b6040516100db9190610f48565b60405180910390f35b6100ec610add565b6040516100f99190611023565b60405180910390f35b61011c60048036038101906101179190610d63565b610ae3565b6040516101299190611023565b60405180910390f35b61013a610d09565b6040516101479190611023565b60405180910390f35b610158610d13565b6040516101659190610f04565b60405180910390f35b6000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166101c657600080fd5b816002819055507f748f1cf617bdc8ef4fcd1cb516dc05cedf269e8dcad82183846d57eeec4bba5e826040516101fc9190611023565b60405180910390a160019050919050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561029c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161029390610f83565b60405180910390fd5b60006060600073ffffffffffffffffffffffffffffffffffffffff16600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146104fb57600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16846040516024016103409190610f04565b6040516020818303038152906040527f3ef25013000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516103ca9190610eed565b6000604051808303816000865af19150503d8060008114610407576040519150601f19603f3d011682016040523d82523d6000602084013e61040c565b606091505b50809250819350505060007f01000000000000000000000000000000000000000000000000000000000000000281601f8151811061044d5761044c6110e0565b5b60200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156104fa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104f190610f63565b60405180910390fd5b5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16846040516024016105459190610f04565b6040516020818303038152906040527f3ef25013000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516105cf9190610eed565b6000604051808303816000865af19150503d806000811461060c576040519150601f19603f3d011682016040523d82523d6000602084013e610611565b606091505b50809250819350505060007f01000000000000000000000000000000000000000000000000000000000000000281601f81518110610652576106516110e0565b5b60200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916146106fe576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106f590611003565b60405180910390fd5b600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16846040516024016107489190610f04565b6040516020818303038152906040527f0a3b0a4f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516107d29190610eed565b6000604051808303816000865af19150503d806000811461080f576040519150601f19603f3d011682016040523d82523d6000602084013e610814565b606091505b5080925081935050508161085d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161085490610fc3565b60405180910390fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16846002546040516024016108ab929190610f1f565b6040516020818303038152906040527fa9059cbb000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516109359190610eed565b6000604051808303816000865af19150503d8060008114610972576040519150601f19603f3d011682016040523d82523d6000602084013e610977565b606091505b50809250819350505081610a4957600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f2a56a00a5c532c49314f19361f71cdca8a5d10fdcb42c3fa52800d13419d6070600254604051610a069190611023565b60405180910390a36040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a4090610fa3565b60405180910390fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f45c201a59ac545000ead84f30b2db67da23353aa1d58ac522c48505412143ffa600254604051610aca9190611023565b60405180910390a3600192505050919050565b60025481565b6000806060600460009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1684604051602401610b329190610f04565b6040516020818303038152906040527f3ef25013000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610bbc9190610eed565b6000604051808303816000865af19150503d8060008114610bf9576040519150601f19603f3d011682016040523d82523d6000602084013e610bfe565b606091505b50809250819350505081610c47576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c3e90610fe3565b60405180910390fd5b60017f01000000000000000000000000000000000000000000000000000000000000000281601f81518110610c7f57610c7e6110e0565b5b60200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161415610cfd5760065492505050610d04565b6000925050505b919050565b6000600254905090565b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600081359050610d488161120a565b92915050565b600081359050610d5d81611221565b92915050565b600060208284031215610d7957610d7861110f565b5b6000610d8784828501610d39565b91505092915050565b600060208284031215610da657610da561110f565b5b6000610db484828501610d4e565b91505092915050565b610dc681611065565b82525050565b610dd581611077565b82525050565b6000610de68261103e565b610df08185611049565b9350610e008185602086016110ad565b80840191505092915050565b6000610e19601883611054565b9150610e2482611114565b602082019050919050565b6000610e3c600a83611054565b9150610e478261113d565b602082019050919050565b6000610e5f600c83611054565b9150610e6a82611166565b602082019050919050565b6000610e82600d83611054565b9150610e8d8261118f565b602082019050919050565b6000610ea5600e83611054565b9150610eb0826111b8565b602082019050919050565b6000610ec8601083611054565b9150610ed3826111e1565b602082019050919050565b610ee7816110a3565b82525050565b6000610ef98284610ddb565b915081905092915050565b6000602082019050610f196000830184610dbd565b92915050565b6000604082019050610f346000830185610dbd565b610f416020830184610ede565b9392505050565b6000602082019050610f5d6000830184610dcc565b92915050565b60006020820190508181036000830152610f7c81610e0c565b9050919050565b60006020820190508181036000830152610f9c81610e2f565b9050919050565b60006020820190508181036000830152610fbc81610e52565b9050919050565b60006020820190508181036000830152610fdc81610e75565b9050919050565b60006020820190508181036000830152610ffc81610e98565b9050919050565b6000602082019050818103600083015261101c81610ebb565b9050919050565b60006020820190506110386000830184610ede565b92915050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b600061107082611083565b9050919050565b60008115159050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b60005b838110156110cb5780820151818401526020810190506110b0565b838111156110da576000848401525b50505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600080fd5b7f4552525f4143434f554e545f4e4f545f494e5f494e4445580000000000000000600082015250565b7f4552525f41434345535300000000000000000000000000000000000000000000600082015250565b7f4552525f5452414e534645520000000000000000000000000000000000000000600082015250565b7f4552525f4d41524b5f4641494c00000000000000000000000000000000000000600082015250565b7f4552525f53544f52455f4641494c000000000000000000000000000000000000600082015250565b7f4552525f4143434f554e545f5553454400000000000000000000000000000000600082015250565b61121381611065565b811461121e57600080fd5b50565b61122a816110a3565b811461123557600080fd5b5056fea264697066735822122005aad6a96e51197bb508fbcebfdef727d4b5a18b7d660419f43d9fbee48ec16064736f6c63430008060033 +\ No newline at end of file diff --git a/python/erc20_faucet/data/ERC20FaucetStorage.bin b/python/erc20_faucet/data/ERC20FaucetStorage.bin @@ -1 +1 @@ -608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600360009080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600260008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610915806101096000396000f3fe608060405234801561001057600080fd5b50600436106100a5576000357c01000000000000000000000000000000000000000000000000000000009004806379ba50971161007857806379ba50971461016a5780638da5cb5b14610188578063e2095c07146101a6578063f2fde38b146101d6576100a5565b806301ffc9a7146100aa5780630a3b0a4f146100da5780633ef250131461010a578063764b07e71461013a575b600080fd5b6100c460048036038101906100bf9190610756565b6101f2565b6040516100d191906107f0565b60405180910390f35b6100f460048036038101906100ef919061072d565b61034a565b60405161010191906107f0565b60405180910390f35b610124600480360381019061011f919061072d565b61044a565b60405161013191906107f0565b60405180910390f35b610154600480360381019061014f919061072d565b610495565b604051610161919061080b565b60405180910390f35b6101726104ad565b60405161017f91906107f0565b60405180910390f35b6101906105ef565b60405161019d91906107d5565b60405180910390f35b6101c060048036038101906101bb919061077f565b610613565b6040516101cd91906107d5565b60405180910390f35b6101f060048036038101906101eb919061072d565b610652565b005b600063cbdb05c77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156102475760019050610345565b6301ffc9a77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916141561029a5760019050610345565b639493f8b27c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156102ed5760019050610345565b6337a47be47c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156103405760019050610345565b600090505b919050565b60008060038054905090506003839080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550808373ffffffffffffffffffffffffffffffffffffffff167f9cc987676e7d63379f176ea50df0ae8d2d9d1141d1231d4ce15b5965f73c943060405160405180910390a36001915050919050565b600080600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054119050919050565b60026020528060005260406000206000915090505481565b60008060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461052d57600080fd5b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600191505090565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6003818154811061062357600080fd5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146106aa57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000813590506106fd8161089a565b92915050565b600081359050610712816108b1565b92915050565b600081359050610727816108c8565b92915050565b60006020828403121561073f57600080fd5b600061074d848285016106ee565b91505092915050565b60006020828403121561076857600080fd5b600061077684828501610703565b91505092915050565b60006020828403121561079157600080fd5b600061079f84828501610718565b91505092915050565b6107b181610826565b82525050565b6107c081610838565b82525050565b6107cf81610890565b82525050565b60006020820190506107ea60008301846107a8565b92915050565b600060208201905061080560008301846107b7565b92915050565b600060208201905061082060008301846107c6565b92915050565b600061083182610870565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b6108a381610826565b81146108ae57600080fd5b50565b6108ba81610844565b81146108c557600080fd5b50565b6108d181610890565b81146108dc57600080fd5b5056fea264697066735822122015d2235935738af4845d274294be7115812c52b811daf7c18f5655f4c01b0ec664736f6c63430008030033 -\ No newline at end of file +608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600360009080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600260008073ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610926806101096000396000f3fe608060405234801561001057600080fd5b50600436106100a5576000357c01000000000000000000000000000000000000000000000000000000009004806379ba50971161007857806379ba50971461016a5780638da5cb5b14610188578063e2095c07146101a6578063f2fde38b146101d6576100a5565b806301ffc9a7146100aa5780630a3b0a4f146100da5780633ef250131461010a578063764b07e71461013a575b600080fd5b6100c460048036038101906100bf919061075a565b6101f2565b6040516100d191906107fc565b60405180910390f35b6100f460048036038101906100ef919061072d565b61034a565b60405161010191906107fc565b60405180910390f35b610124600480360381019061011f919061072d565b61044a565b60405161013191906107fc565b60405180910390f35b610154600480360381019061014f919061072d565b610495565b6040516101619190610817565b60405180910390f35b6101726104ad565b60405161017f91906107fc565b60405180910390f35b6101906105ef565b60405161019d91906107e1565b60405180910390f35b6101c060048036038101906101bb9190610787565b610613565b6040516101cd91906107e1565b60405180910390f35b6101f060048036038101906101eb919061072d565b610652565b005b600063cbdb05c77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156102475760019050610345565b6301ffc9a77c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916141561029a5760019050610345565b639493f8b27c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156102ed5760019050610345565b6337a47be47c010000000000000000000000000000000000000000000000000000000002827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614156103405760019050610345565b600090505b919050565b60008060038054905090506003839080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550808373ffffffffffffffffffffffffffffffffffffffff167f9cc987676e7d63379f176ea50df0ae8d2d9d1141d1231d4ce15b5965f73c943060405160405180910390a36001915050919050565b600080600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054119050919050565b60026020528060005260406000206000915090505481565b60008060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461052d57600080fd5b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3600191505090565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6003818154811061062357600080fd5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146106aa57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000813590506106fd816108ab565b92915050565b600081359050610712816108c2565b92915050565b600081359050610727816108d9565b92915050565b600060208284031215610743576107426108a6565b5b6000610751848285016106ee565b91505092915050565b6000602082840312156107705761076f6108a6565b5b600061077e84828501610703565b91505092915050565b60006020828403121561079d5761079c6108a6565b5b60006107ab84828501610718565b91505092915050565b6107bd81610832565b82525050565b6107cc81610844565b82525050565b6107db8161089c565b82525050565b60006020820190506107f660008301846107b4565b92915050565b600060208201905061081160008301846107c3565b92915050565b600060208201905061082c60008301846107d2565b92915050565b600061083d8261087c565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600080fd5b6108b481610832565b81146108bf57600080fd5b50565b6108cb81610850565b81146108d657600080fd5b50565b6108e28161089c565b81146108ed57600080fd5b5056fea26469706673582212202cc4968566df96a0025d12942f5630d0ff06f44c5f2ce3980df95cac4c743a6464736f6c63430008060033 +\ No newline at end of file diff --git a/python/erc20_faucet/interface.py b/python/erc20_faucet/interface.py @@ -17,6 +17,7 @@ from chainlib.eth.tx import ( ) from chainlib.jsonrpc import JSONRPCRequest from chainlib.eth.error import RequestMismatchException +from chainlib.eth.jsonrpc import to_blockheight_param from hexathon import ( add_0x, strip_0x, @@ -137,7 +138,7 @@ class Faucet(TxFactory): return r == 0 - def token(self, contract_address, sender_address=ZERO_ADDRESS, id_generator=None): + def token(self, contract_address, sender_address=ZERO_ADDRESS, height=None, id_generator=None): j = JSONRPCRequest(id_generator) o = j.template() o['method'] = 'eth_call' @@ -147,6 +148,8 @@ class Faucet(TxFactory): tx = self.template(sender_address, contract_address) tx = self.set_code(tx, data) o['params'].append(self.normalize(tx)) + height = to_blockheight_param(height) + o['params'].append(height) o = j.finalize(o) return o @@ -156,7 +159,7 @@ class Faucet(TxFactory): return abi_decode_single(ABIContractType.ADDRESS, v) - def token_amount(self, contract_address, block_height=None, sender_address=ZERO_ADDRESS, id_generator=None): + def token_amount(self, contract_address, height=None, sender_address=ZERO_ADDRESS, id_generator=None): j = JSONRPCRequest(id_generator) o = j.template() o['method'] = 'eth_call' @@ -166,9 +169,8 @@ class Faucet(TxFactory): tx = self.template(sender_address, contract_address) tx = self.set_code(tx, data) o['params'].append(self.normalize(tx)) - - if block_height != None: - o['params'].append(block_height) + height = to_blockheight_param(height) + o['params'].append(height) o = j.finalize(o) return o diff --git a/python/erc20_faucet/runnable/deploy.py b/python/erc20_faucet/runnable/deploy.py @@ -13,24 +13,19 @@ import argparse import logging # external imports -from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer -from crypto_dev_signer.keystore.dict import DictKeystore +import chainlib.eth.cli from chainlib.chain import ChainSpec -from chainlib.eth.nonce import ( - RPCNonceOracle, - OverrideNonceOracle, - ) -from chainlib.eth.gas import ( - RPCGasOracle, - OverrideGasOracle, - ) from chainlib.eth.connection import EthHTTPConnection from chainlib.eth.tx import ( receipt, TxFactory, ) from chainlib.eth.constant import ZERO_ADDRESS -from erc20_faucet.faucet import SingleShotFaucet +from chainlib.eth.address import to_checksum_address +from hexathon import ( + add_0x, + strip_0x, + ) # local imports from erc20_faucet.faucet import SingleShotFaucet @@ -38,108 +33,97 @@ from erc20_faucet.faucet import SingleShotFaucet logging.basicConfig(level=logging.WARNING) logg = logging.getLogger() -script_dir = os.path.dirname(__file__) -data_dir = os.path.join(script_dir, '..', 'data') - -default_eth_provider = os.environ.get('ETH_PROVIDER', 'http://localhost:8545') - -argparser = argparse.ArgumentParser() -argparser.add_argument('-p', '--provider', dest='p', default=default_eth_provider, type=str, help='RPC provider url (http only)') -argparser.add_argument('-w', action='store_true', help='Wait for the last transaction to be confirmed') -argparser.add_argument('-ww', action='store_true', help='Wait for every transaction to be confirmed') -argparser.add_argument('-i', '--chain-spec', dest='i', type=str, default='evm:ethereum:1', help='Chain specification string') -argparser.add_argument('-y', '--key-file', dest='y', type=str, help='Ethereum keystore file to use for signing') -argparser.add_argument('-v', action='store_true', help='Be verbose') -argparser.add_argument('-vv', action='store_true', help='Be more verbose') -argparser.add_argument('--gas-price', type=int, dest='gas_price', help='Override gas price') -argparser.add_argument('-d', action='store_true', help='Dump RPC calls to terminal and do not send') -argparser.add_argument('--nonce', type=int, help='Override transaction nonce') -argparser.add_argument('--overrider-address', type=str, dest='overrider_address', help='Overrider address') -argparser.add_argument('--env-prefix', default=os.environ.get('CONFINI_ENV_PREFIX'), dest='env_prefix', type=str, help='environment prefix for variables to overwrite configuration') -argparser.add_argument('--account-index-address', type=str, dest='account_index_address', help='Account index contract address') +arg_flags = chainlib.eth.cli.argflag_std_write +argparser = chainlib.eth.cli.ArgumentParser(arg_flags) +argparser.add_argument('--overrider-address', type=str, dest='overrider_address', default=ZERO_ADDRESS, help='Overrider address') +argparser.add_argument('--account-index-address', type=str, dest='account_index_address', default=ZERO_ADDRESS, help='Account index contract address') +argparser.add_argument('--store-address', type=str, dest='store_address', help='Faucet store address') argparser.add_argument('token_address', type=str, help='Mintable token address') args = argparser.parse_args() -if args.vv: - logg.setLevel(logging.DEBUG) -elif args.v: - logg.setLevel(logging.INFO) - -block_last = args.w -block_all = args.ww - -passphrase_env = 'ETH_PASSPHRASE' -if args.env_prefix != None: - passphrase_env = args.env_prefix + '_' + passphrase_env -passphrase = os.environ.get(passphrase_env) -if passphrase == None: - logg.warning('no passphrase given') - passphrase='' - -signer_address = None -keystore = DictKeystore() -if args.y != None: - logg.debug('loading keystore file {}'.format(args.y)) - signer_address = keystore.import_keystore_file(args.y, password=passphrase) - logg.debug('now have key for signer address {}'.format(signer_address)) -signer = EIP155Signer(keystore) - -chain_spec = ChainSpec.from_chain_str(args.i) - -rpc = EthHTTPConnection(args.p) -nonce_oracle = None -if args.nonce != None: - nonce_oracle = OverrideNonceOracle(signer_address, args.nonce) -else: - nonce_oracle = RPCNonceOracle(signer_address, rpc) - -gas_oracle = None -if args.gas_price !=None: - gas_oracle = OverrideGasOracle(price=args.gas_price, conn=rpc, code_callback=SingleShotFaucet.gas) -else: - gas_oracle = RPCGasOracle(rpc, code_callback=SingleShotFaucet.gas) - -dummy = args.d - -token_address = args.token_address -overrider_address = signer_address -if args.overrider_address != None: - overrider_address = args.overrider_address -account_index_address = args.account_index_address -if account_index_address == None: - account_index_address = ZERO_ADDRESS +extra_args = { + 'overrider_address': None, + 'account_index_address': None, + 'store_address': None, + 'token_address': None, + } +config = chainlib.eth.cli.Config.from_args(args, arg_flags, extra_args=extra_args, default_fee_limit=SingleShotFaucet.gas()) + +wallet = chainlib.eth.cli.Wallet() +wallet.from_config(config) + +rpc = chainlib.eth.cli.Rpc(wallet=wallet) +conn = rpc.connect_by_config(config) + +chain_spec = ChainSpec.from_chain_str(config.get('CHAIN_SPEC')) +args = argparser.parse_args() def main(): + signer = rpc.get_signer() + signer_address = rpc.get_sender_address() + + gas_oracle = rpc.get_gas_oracle() + nonce_oracle = rpc.get_nonce_oracle() + c = SingleShotFaucet(chain_spec, signer=signer, nonce_oracle=nonce_oracle, gas_oracle=gas_oracle) - (tx_hash_hex, o) = c.store_constructor(signer_address) - if dummy: - print(tx_hash_hex) - print(o) - else: - rpc.do(o) - r = rpc.wait(tx_hash_hex) - if r['status'] == 0: - sys.stderr.write('EVM revert while deploying contract. Wish I had more to tell you') - sys.exit(1) - # TODO: pass through translator for keys (evm tester uses underscore instead of camelcase) - store_address = r['contractAddress'] - logg.info('deployed faucet store on {}'.format(store_address)) + store_address = None + try: + store_address = to_checksum_address(config.get('_STORE_ADDRESS')) + if not config.true('_UNSAFE') and store_address != add_0x(config.get('_STORE_ADDRESS')): + raise ValueError('invalid checksum address for store') + logg.debug('using store address {}'.format(store_address)) + except TypeError: + pass + + account_index_address = to_checksum_address(config.get('_ACCOUNT_INDEX_ADDRESS')) + if not config.true('_UNSAFE') and account_index_address != add_0x(config.get('_ACCOUNT_INDEX_ADDRESS')): + raise ValueError('invalid checksum address for account index address') + + token_address = None + try: + token_address = to_checksum_address(config.get('_TOKEN_ADDRESS')) + if not config.true('_UNSAFE') and token_address != add_0x(config.get('_TOKEN_ADDRESS')): + raise ValueError('invalid checksum address for token address') + except TypeError: + pass + + overrider_address = to_checksum_address(config.get('_OVERRIDER_ADDRESS')) + if not config.true('_UNSAFE') and overrider_address != add_0x(config.get('_OVERRIDER_ADDRESS')): + raise ValueError('invalid checksum address for overrider address') + + + if store_address == None: + (tx_hash_hex, o) = c.store_constructor(signer_address) + if not config.get('_WAIT'): + print(o) + else: + conn.do(o) + r = conn.wait(tx_hash_hex) + if r['status'] == 0: + sys.stderr.write('EVM revert while deploying contract. Wish I had more to tell you') + sys.exit(1) + # TODO: pass through translator for keys (evm tester uses underscore instead of camelcase) + store_address = r['contractAddress'] + logg.info('deployed faucet store on {}'.format(store_address)) + print(store_address) + + if store_address != None: c = SingleShotFaucet(chain_spec, signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle) (tx_hash_hex, o) = c.constructor(signer_address, token_address, store_address, account_index_address, [overrider_address]) - rpc.do(o) - r = rpc.wait(tx_hash_hex) - if r['status'] == 0: - sys.stderr.write('EVM revert while deploying contract. Wish I had more to tell you') - sys.exit(1) - # TODO: pass through translator for keys (evm tester uses underscore instead of camelcase) - address = r['contractAddress'] - - if block_last: - rpc.wait(tx_hash_hex) - - print(address) + conn.do(o) + if config.get('_WAIT'): + r = conn.wait(tx_hash_hex) + if r['status'] == 0: + sys.stderr.write('EVM revert while deploying contract. Wish I had more to tell you') + sys.exit(1) + # TODO: pass through translator for keys (evm tester uses underscore instead of camelcase) + address = r['contractAddress'] + + print(address) + else: + print(tx_hash_hex) if __name__ == '__main__': diff --git a/python/erc20_faucet/runnable/gift.py b/python/erc20_faucet/runnable/gift.py @@ -0,0 +1,91 @@ +"""Set identifier value on contract registry + +.. moduleauthor:: Louis Holbrook <dev@holbrook.no> +.. pgp:: 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 + +""" + +# standard imports +import sys +import os +import json +import argparse +import logging + +# external imports +import chainlib.eth.cli +from chainlib.chain import ChainSpec +from chainlib.eth.connection import EthHTTPConnection +from chainlib.eth.tx import receipt +from chainlib.eth.constant import ZERO_CONTENT +from chainlib.eth.address import to_checksum_address +from hexathon import ( + add_0x, + strip_0x, + ) + +# local imports +from erc20_faucet import Faucet +from erc20_faucet.faucet import SingleShotFaucet + +logging.basicConfig(level=logging.WARNING) +logg = logging.getLogger() + +arg_flags = chainlib.eth.cli.argflag_std_write | chainlib.eth.cli.Flag.EXEC +argparser = chainlib.eth.cli.ArgumentParser(arg_flags) +argparser.add_positional('address', type=str, help='Contract address to invoke faucet for') +args = argparser.parse_args() + +extra_args = { + 'address': None, + } +config = chainlib.eth.cli.Config.from_args(args, arg_flags, extra_args=extra_args, default_fee_limit=SingleShotFaucet.gas()) + +wallet = chainlib.eth.cli.Wallet() +wallet.from_config(config) + +rpc = chainlib.eth.cli.Rpc(wallet=wallet) +conn = rpc.connect_by_config(config) + +chain_spec = ChainSpec.from_chain_str(config.get('CHAIN_SPEC')) + + +def main(): + + signer = rpc.get_signer() + signer_address = rpc.get_sender_address() + + gas_oracle = rpc.get_gas_oracle() + nonce_oracle = rpc.get_nonce_oracle() + + c = Faucet(chain_spec, signer=signer, nonce_oracle=nonce_oracle, gas_oracle=gas_oracle) + + faucet_address = to_checksum_address(config.get('_EXEC_ADDRESS')) + if not config.true('_UNSAFE') and faucet_address != add_0x(config.get('_EXEC_ADDRESS')): + raise ValueError('invalid checksum address for faucet') + + address = config.get('_ADDRESS') + if address == None: + address = signer_address + else: + address = to_checksum_address(address) + if not config.true('_UNSAFE') and address != add_0x(config.get('_EXEC_ADDRESS')): + raise ValueError('invalid checksum address for faucet') + + (tx_hash_hex, o) = c.give_to(faucet_address, signer_address, address) + + if config.get('_RPC_SEND'): + conn.do(o) + if config.get('_WAIT'): + r = conn.wait(tx_hash_hex) + if r['status'] == 0: + sys.stderr.write('EVM revert while deploying contract. Wish I had more to tell you') + sys.exit(1) + + print(tx_hash_hex) + else: + print(o) + + +if __name__ == '__main__': + main() diff --git a/python/erc20_faucet/runnable/list.py b/python/erc20_faucet/runnable/list.py @@ -13,69 +13,69 @@ import argparse import logging # external imports -from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer -from crypto_dev_signer.keystore.dict import DictKeystore +import chainlib.eth.cli from chainlib.chain import ChainSpec -from chainlib.eth.nonce import RPCNonceOracle -from chainlib.eth.gas import RPCGasOracle from chainlib.eth.connection import EthHTTPConnection from chainlib.eth.tx import receipt from chainlib.eth.constant import ZERO_CONTENT from chainlib.error import JSONRPCException +from chainlib.eth.address import to_checksum_address +from hexathon import ( + add_0x, + strip_0x, + ) # local imports from erc20_faucet import Faucet +from erc20_faucet.faucet import SingleShotFaucet logging.basicConfig(level=logging.WARNING) logg = logging.getLogger() -script_dir = os.path.dirname(__file__) -data_dir = os.path.join(script_dir, '..', 'data') -default_format = 'terminal' - -argparser = argparse.ArgumentParser() -argparser.add_argument('-p', '--provider', dest='p', default='http://localhost:8545', type=str, help='RPC provider url (http only)') -argparser.add_argument('-i', '--chain-spec', dest='i', type=str, default='evm:ethereum:1', help='Chain specification string') -argparser.add_argument('-a', '--contract-address', dest='a', required=True, type=str, help='Faucet store contract address') -argparser.add_argument('-f', '--format', dest='f', type=str, default=default_format, help='Output format [human, brief]') -argparser.add_argument('-v', action='store_true', help='Be verbose') -argparser.add_argument('-vv', action='store_true', help='Be more verbose') -argparser.add_argument('--env-prefix', default=os.environ.get('CONFINI_ENV_PREFIX'), dest='env_prefix', type=str, help='environment prefix for variables to overwrite configuration') -argparser.add_argument('address', type=str, help='Address to check faucet usage for') +arg_flags = chainlib.eth.cli.argflag_std_write | chainlib.eth.cli.Flag.EXEC +argparser = chainlib.eth.cli.ArgumentParser(arg_flags) +argparser.add_positional('address', required=False, type=str, help='Check only whether given address has been used') args = argparser.parse_args() -if args.vv: - logg.setLevel(logging.DEBUG) -elif args.v: - logg.setLevel(logging.INFO) +extra_args = { + 'address': None, + } +config = chainlib.eth.cli.Config.from_args(args, arg_flags, extra_args=extra_args, default_fee_limit=SingleShotFaucet.gas()) + +wallet = chainlib.eth.cli.Wallet() +wallet.from_config(config) -chain_spec = ChainSpec.from_chain_str(args.i) +rpc = chainlib.eth.cli.Rpc(wallet=wallet) +conn = rpc.connect_by_config(config) -rpc = EthHTTPConnection(args.p) -faucet_store_address = args.a -address = args.address -fmt = args.f +chain_spec = ChainSpec.from_chain_str(config.get('CHAIN_SPEC')) -def out_element(e, fmt=default_format, w=sys.stdout): - logg.debug('format {}'.format(fmt)) - if fmt == 'brief': - w.write(str(e[1]) + '\n') - else: - w.write('{} {}\n'.format(e[0], e[1])) +def out_element(e, conn, w=sys.stdout): + w.write(str(e[1]) + '\n') -def element(ifc, address, fmt=default_format, w=sys.stdout): - o = ifc.usable_for(faucet_store_address, address) - r = rpc.do(o) - have = ifc.parse_usable_for(r) - out_element((address, have), fmt, w) +def element(ifc, conn, faucet_address, address, w=sys.stdout): + o = ifc.usable_for(faucet_address, address) + r = conn.do(o) + usable = ifc.parse_usable_for(r) + if usable: + out_element((0, address), conn, w) def main(): + faucet_address = to_checksum_address(config.get('_EXEC_ADDRESS')) + if not config.true('_UNSAFE') and faucet_address != add_0x(config.get('_EXEC_ADDRESS')): + raise ValueError('invalid checksum address for faucet') + + address = to_checksum_address(config.get('_EXEC_ADDRESS')) + if not config.true('_UNSAFE') and address != add_0x(config.get('_EXEC_ADDRESS')): + raise ValueError('invalid checksum address for faucet') + + c = Faucet(chain_spec) - element(c, address, fmt=fmt, w=sys.stdout) + element(c, conn, faucet_address, address, w=sys.stdout) if __name__ == '__main__': diff --git a/python/setup.cfg b/python/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = erc20-faucet -version = 0.2.4a1 +version = 0.3.1a1 description = ERC20 token faucet author = Louis Holbrook author_email = dev@holbrook.no diff --git a/solidity/ERC20Faucet.sol b/solidity/ERC20Faucet.sol @@ -69,7 +69,10 @@ contract SingleShotFaucet { bytes memory _result; (_ok, _result) = store.call(abi.encodeWithSignature("have(address)", _recipient)); - if (_ok) { + + require(_ok, 'ERR_STORE_FAIL'); + + if (_result[31] == 0x01) { return cooldownDisabled; } else { return 0;