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
|
2022-05-12 17:19:16 +02:00
|
|
|
from chainlib.settings import ChainSettings
|
2021-06-28 07:48:36 +02:00
|
|
|
from chainlib.chain import ChainSpec
|
|
|
|
|
|
|
|
# local imports
|
2022-05-12 13:10:47 +02:00
|
|
|
import chainlib.eth.cli
|
2021-06-28 07:48:36 +02:00
|
|
|
from chainlib.eth.runnable.util import decode_for_puny_humans
|
2022-05-12 13:10:47 +02:00
|
|
|
from chainlib.eth.cli.arg import (
|
|
|
|
Arg,
|
|
|
|
ArgFlag,
|
|
|
|
process_args,
|
|
|
|
)
|
|
|
|
from chainlib.eth.cli.config import (
|
|
|
|
Config,
|
|
|
|
process_config,
|
|
|
|
)
|
|
|
|
from chainlib.eth.cli.log import process_log
|
2022-05-12 17:19:16 +02:00
|
|
|
from chainlib.eth.settings import process_settings
|
2022-05-12 13:10:47 +02:00
|
|
|
|
2021-06-28 07:48:36 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
2022-05-12 13:10:47 +02:00
|
|
|
|
2022-05-12 17:19:16 +02:00
|
|
|
def process_config_local(config, arg, args, flags):
|
|
|
|
config.add(args.tx_data, '_TX_DATA', False)
|
|
|
|
return config
|
|
|
|
|
|
|
|
|
2022-05-12 13:10:47 +02:00
|
|
|
arg_flags = ArgFlag()
|
|
|
|
arg = Arg(arg_flags)
|
2022-05-12 17:19:16 +02:00
|
|
|
flags = arg_flags.VERBOSE | arg_flags.CHAIN_SPEC | arg_flags.RAW | arg_flags.ENV | arg_flags.SEQ
|
2022-05-12 13:10:47 +02:00
|
|
|
|
|
|
|
argparser = chainlib.eth.cli.ArgumentParser()
|
|
|
|
argparser = process_args(argparser, arg, flags)
|
|
|
|
argparser.add_argument('tx_data', type=str, help='Transaction data to decode')
|
2021-06-28 07:48:36 +02:00
|
|
|
args = argparser.parse_args()
|
2022-05-12 13:10:47 +02:00
|
|
|
|
|
|
|
logg = process_log(args, logg)
|
|
|
|
|
|
|
|
config = Config()
|
|
|
|
config = process_config(config, arg, args, flags)
|
2022-05-12 17:19:16 +02:00
|
|
|
config = process_config_local(config, arg, args, flags)
|
2022-05-12 13:10:47 +02:00
|
|
|
logg.debug('config loaded:\n{}'.format(config))
|
|
|
|
|
2022-05-12 17:19:16 +02:00
|
|
|
settings = ChainSettings()
|
|
|
|
settings = process_settings(settings, config)
|
|
|
|
logg.debug('settings loaded:\n{}'.format(settings))
|
2021-06-28 07:48:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2022-05-12 17:19:16 +02:00
|
|
|
decode_for_puny_humans(
|
|
|
|
config.get('_TX_DATA'),
|
|
|
|
settings.get('CHAIN_SPEC'),
|
|
|
|
sys.stdout,
|
|
|
|
)
|
2021-06-28 07:48:36 +02:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|