From 861a9b032afaa14b645da0838b7ade1c16dd1ae8 Mon Sep 17 00:00:00 2001 From: nolash Date: Mon, 22 Mar 2021 18:13:59 +0100 Subject: [PATCH] Add receipt wait to runnables --- .../giftable_erc20_token/runnable/deploy.py | 24 ++++++++----------- python/giftable_erc20_token/runnable/gift.py | 13 ++++------ .../runnable/{add.py => minter.py} | 15 ++++-------- 3 files changed, 20 insertions(+), 32 deletions(-) rename python/giftable_erc20_token/runnable/{add.py => minter.py} (94%) diff --git a/python/giftable_erc20_token/runnable/deploy.py b/python/giftable_erc20_token/runnable/deploy.py index 5f4c8b0..46677dc 100644 --- a/python/giftable_erc20_token/runnable/deploy.py +++ b/python/giftable_erc20_token/runnable/deploy.py @@ -1,4 +1,4 @@ -"""Deploys giftable token, and optionally gifts a set amount to all accounts in wallet +"""Deploys giftable token .. moduleauthor:: Louis Holbrook .. pgp:: 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 @@ -48,7 +48,6 @@ argparser.add_argument('--symbol', default='GFT', type=str, help='Token symbol') argparser.add_argument('--decimals', default=18, type=int, help='Token decimals') argparser.add_argument('-v', action='store_true', help='Be verbose') argparser.add_argument('-vv', action='store_true', help='Be more verbose') -argparser.add_argument('amount', type=int, help='Initial token supply (will be owned by contract creator)') args = argparser.parse_args() if args.vv: @@ -91,20 +90,17 @@ def main(): c = GiftableToken(signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle, chain_id=chain_id) (tx_hash_hex, o) = c.constructor(signer_address, token_name, token_symbol, token_decimals) rpc.do(o) - o = receipt(tx_hash_hex) - r = rpc.do(o) - 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) + 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) - - sys.exit(0) + print(address) + else: + print(tx_hash_hex) if __name__ == '__main__': diff --git a/python/giftable_erc20_token/runnable/gift.py b/python/giftable_erc20_token/runnable/gift.py index eaa4729..2a3f6c4 100644 --- a/python/giftable_erc20_token/runnable/gift.py +++ b/python/giftable_erc20_token/runnable/gift.py @@ -90,17 +90,14 @@ def main(): c = GiftableToken(signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle, chain_id=chain_id) (tx_hash_hex, o) = c.mint_to(token_address, signer_address, recipient_address, token_value) rpc.do(o) - o = receipt(tx_hash_hex) - r = rpc.do(o) - if r['status'] == 0: - sys.stderr.write('EVM revert. Wish I had more to tell you') - sys.exit(1) + if block_last: + r = rpc.wait(tx_hash_hex) + if r['status'] == 0: + sys.stderr.write('EVM revert. Wish I had more to tell you') + sys.exit(1) logg.info('mint to {} tx {}'.format(recipient_address, tx_hash_hex)) - if block_last: - helper.wait_for() - print(tx_hash_hex) sys.exit(0) diff --git a/python/giftable_erc20_token/runnable/add.py b/python/giftable_erc20_token/runnable/minter.py similarity index 94% rename from python/giftable_erc20_token/runnable/add.py rename to python/giftable_erc20_token/runnable/minter.py index 7b777f4..4443786 100644 --- a/python/giftable_erc20_token/runnable/add.py +++ b/python/giftable_erc20_token/runnable/minter.py @@ -86,21 +86,16 @@ def main(): c = GiftableToken(signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle, chain_id=chain_id) (tx_hash_hex, o) = c.add_minter(token_address, signer_address, minter_address) rpc.do(o) - o = receipt(tx_hash_hex) - r = rpc.do(o) - if r['status'] == 0: - sys.stderr.write('EVM revert. Wish I had more to tell you') - sys.exit(1) + if block_last: + r = rpc.wait(tx_hash_hex) + if r['status'] == 0: + sys.stderr.write('EVM revert. Wish I had more to tell you') + sys.exit(1) logg.info('add minter {} to {} tx {}'.format(minter_address, token_address, tx_hash_hex)) - if block_last: - rpc.wait(o) - print(tx_hash_hex) - sys.exit(0) - if __name__ == '__main__': main()