erc20-transfer-authorization

Simple approval escrow for ERC20 spending
Log | Files | Refs

commit 3d66c6abc9cf4420348521bc63a5e7d22c7c75e4
parent 11e43333adfda43fe7e10b5883f3750d4966f858
Author: nolash <dev@holbrook.no>
Date:   Mon, 12 Apr 2021 16:21:37 +0200

Add settable price, nonce, optional send

Diffstat:
Mpython/erc20_transfer_authorization/runnable/deploy.py | 56+++++++++++++++++++++++++++++++++++++++-----------------
Mpython/requirements.txt | 4++--
Mpython/setup.cfg | 2+-
3 files changed, 42 insertions(+), 20 deletions(-)

diff --git a/python/erc20_transfer_authorization/runnable/deploy.py b/python/erc20_transfer_authorization/runnable/deploy.py @@ -16,8 +16,14 @@ import logging from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer from crypto_dev_signer.keystore.dict import DictKeystore from chainlib.chain import ChainSpec -from chainlib.eth.nonce import RPCNonceOracle -from chainlib.eth.gas import RPCGasOracle +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 @@ -39,6 +45,9 @@ argparser.add_argument('-a', '--signer-address', dest='a', type=str, help='Signe 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('-d', action='store_true', help='Dump RPC calls to terminal and do not send') +argparser.add_argument('--gas-price', type=int, dest='gas_price', help='Override gas price') +argparser.add_argument('--nonce', type=int, help='Override transaction nonce') 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') args = argparser.parse_args() @@ -69,27 +78,40 @@ signer = EIP155Signer(keystore) chain_spec = ChainSpec.from_chain_str(args.i) rpc = EthHTTPConnection(args.p) -nonce_oracle = RPCNonceOracle(signer_address, rpc) -gas_oracle = RPCGasOracle(rpc, code_callback=TransferAuthorization.gas) +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=TransferAuthorization.gas) +else: + gas_oracle = RPCGasOracle(rpc, code_callback=TransferAuthorization.gas) + +dummy = args.d def main(): c = TransferAuthorization(chain_spec, signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle) (tx_hash_hex, o) = c.constructor(signer_address) - rpc.do(o) - if block_last: - 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'] - - print(address) - else: + if dummy: print(tx_hash_hex) - - sys.exit(0) + print(o) + else: + rpc.do(o) + if block_last: + 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'] + + print(address) + else: + print(tx_hash_hex) if __name__ == '__main__': diff --git a/python/requirements.txt b/python/requirements.txt @@ -1,3 +1,3 @@ confini~=0.3.6rc3 -crypto-dev-signer~=0.4.14a17 -chainlib~=0.0.2a1 +crypto-dev-signer~=0.4.14b1 +chainlib~=0.0.2a8 diff --git a/python/setup.cfg b/python/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = erc20-transfer-authorization -version = 0.3.1a3 +version = 0.3.1a4 description = Simple approval escrow for ERC20 spend approval author = Louis Holbrook author_email = dev@holbrook.no