2021-06-28 07:48:36 +02:00
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
# standard imports
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
import json
|
|
|
|
import argparse
|
|
|
|
import logging
|
|
|
|
import select
|
|
|
|
|
|
|
|
# external imports
|
2021-08-21 09:27:40 +02:00
|
|
|
import chainlib.eth.cli
|
2021-06-28 07:48:36 +02:00
|
|
|
from chainlib.eth.tx import unpack
|
|
|
|
from chainlib.chain import ChainSpec
|
|
|
|
|
|
|
|
# local imports
|
|
|
|
from chainlib.eth.runnable.util import decode_for_puny_humans
|
|
|
|
|
|
|
|
logging.basicConfig(level=logging.WARNING)
|
|
|
|
logg = logging.getLogger()
|
|
|
|
|
2021-08-21 09:27:40 +02:00
|
|
|
script_dir = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
config_dir = os.path.join(script_dir, '..', 'data', 'config')
|
2021-06-28 07:48:36 +02:00
|
|
|
|
2021-08-21 09:27:40 +02:00
|
|
|
arg_flags = chainlib.eth.cli.Flag.VERBOSE | chainlib.eth.cli.Flag.CHAIN_SPEC | chainlib.eth.cli.Flag.ENV_PREFIX | chainlib.eth.cli.Flag.RAW
|
|
|
|
argparser = chainlib.eth.cli.ArgumentParser(arg_flags)
|
|
|
|
argparser.add_positional('tx_data', type=str, help='Transaction data to decode')
|
2021-06-28 07:48:36 +02:00
|
|
|
args = argparser.parse_args()
|
2021-08-21 09:27:40 +02:00
|
|
|
config = chainlib.eth.cli.Config.from_args(args, arg_flags, default_config_dir=config_dir)
|
2021-06-28 07:48:36 +02:00
|
|
|
|
2021-08-21 09:27:40 +02:00
|
|
|
chain_spec = ChainSpec.from_chain_str(config.get('CHAIN_SPEC'))
|
2021-06-28 07:48:36 +02:00
|
|
|
|
|
|
|
def main():
|
2021-08-21 09:27:40 +02:00
|
|
|
decode_for_puny_humans(args.tx_data, chain_spec, sys.stdout)
|
2021-06-28 07:48:36 +02:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|