Add receipt wait to runnables

This commit is contained in:
nolash 2021-03-22 18:13:59 +01:00
parent d502b13e20
commit 861a9b032a
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
3 changed files with 20 additions and 32 deletions

View File

@ -1,4 +1,4 @@
"""Deploys giftable token, and optionally gifts a set amount to all accounts in wallet """Deploys giftable token
.. moduleauthor:: Louis Holbrook <dev@holbrook.no> .. moduleauthor:: Louis Holbrook <dev@holbrook.no>
.. pgp:: 0826EDA1702D1E87C6E2875121D2E7BB88C2A746 .. 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('--decimals', default=18, type=int, help='Token decimals')
argparser.add_argument('-v', action='store_true', help='Be verbose') argparser.add_argument('-v', action='store_true', help='Be verbose')
argparser.add_argument('-vv', action='store_true', help='Be more 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() args = argparser.parse_args()
if args.vv: 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) 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) (tx_hash_hex, o) = c.constructor(signer_address, token_name, token_symbol, token_decimals)
rpc.do(o) 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: 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) print(address)
else:
sys.exit(0) print(tx_hash_hex)
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -90,17 +90,14 @@ def main():
c = GiftableToken(signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle, chain_id=chain_id) 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) (tx_hash_hex, o) = c.mint_to(token_address, signer_address, recipient_address, token_value)
rpc.do(o) rpc.do(o)
o = receipt(tx_hash_hex) if block_last:
r = rpc.do(o) r = rpc.wait(tx_hash_hex)
if r['status'] == 0: if r['status'] == 0:
sys.stderr.write('EVM revert. Wish I had more to tell you') sys.stderr.write('EVM revert. Wish I had more to tell you')
sys.exit(1) sys.exit(1)
logg.info('mint to {} tx {}'.format(recipient_address, tx_hash_hex)) logg.info('mint to {} tx {}'.format(recipient_address, tx_hash_hex))
if block_last:
helper.wait_for()
print(tx_hash_hex) print(tx_hash_hex)
sys.exit(0) sys.exit(0)

View File

@ -86,21 +86,16 @@ def main():
c = GiftableToken(signer=signer, gas_oracle=gas_oracle, nonce_oracle=nonce_oracle, chain_id=chain_id) 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) (tx_hash_hex, o) = c.add_minter(token_address, signer_address, minter_address)
rpc.do(o) rpc.do(o)
o = receipt(tx_hash_hex) if block_last:
r = rpc.do(o) r = rpc.wait(tx_hash_hex)
if r['status'] == 0: if r['status'] == 0:
sys.stderr.write('EVM revert. Wish I had more to tell you') sys.stderr.write('EVM revert. Wish I had more to tell you')
sys.exit(1) sys.exit(1)
logg.info('add minter {} to {} tx {}'.format(minter_address, token_address, tx_hash_hex)) logg.info('add minter {} to {} tx {}'.format(minter_address, token_address, tx_hash_hex))
if block_last:
rpc.wait(o)
print(tx_hash_hex) print(tx_hash_hex)
sys.exit(0)
if __name__ == '__main__': if __name__ == '__main__':
main() main()