cic-internal-integration/apps/cic-eth/cic_eth/runnable/resend.py

45 lines
1.2 KiB
Python
Raw Normal View History

2021-02-08 22:39:50 +01:00
# standard imports
import logging
import argparse
import re
import os
# third-party imports
2021-04-02 15:16:27 +02:00
from chainlib.chain import ChainSpec
from chainlib.eth.connection import EthHTTPConnection
2021-02-08 22:39:50 +01:00
# local imports
import cic_eth.cli
from cic_eth.api.admin import AdminApi
2021-02-08 22:39:50 +01:00
logging.basicConfig(level=logging.WARNING)
logg = logging.getLogger()
arg_flags = cic_eth.cli.argflag_std_base
local_arg_flags = cic_eth.cli.argflag_local_taskcallback
argparser = cic_eth.cli.ArgumentParser(arg_flags)
argparser.add_argument('--unlock', action='store_true', help='Unlock account after resend')
argparser.add_positional('tx_hash', type=str, help='Transaction hash')
argparser.process_local_flags(local_arg_flags)
extra_args = {
'unlock': None,
'tx_hash': None,
}
2021-02-08 22:39:50 +01:00
args = argparser.parse_args()
config = cic_eth.cli.Config.from_args(args, arg_flags, local_arg_flags, extra_args=extra_args)
2021-02-08 22:39:50 +01:00
chain_spec = ChainSpec.from_chain_str(config.get('CHAIN_SPEC'))
2021-02-08 22:39:50 +01:00
celery_app = cic_eth.cli.CeleryApp.from_config(config)
2021-02-08 22:39:50 +01:00
def main():
api = AdminApi(None)
tx_details = api.tx(chain_spec, config.get('_TX_HASH'))
2021-04-02 15:16:27 +02:00
t = api.resend(args.tx_hash, chain_spec, unlock=config.get('_UNLOCK'))
print(t.get_leaf())
2021-02-08 22:39:50 +01:00
if __name__ == '__main__':
main()