chainlib-eth

Ethereum implementation of the chainlib interface
Log | Files | Refs | README | LICENSE

commit d70dfc3f036c29006b80e04fd25216f6a1258c5a
parent c060222638bc7dfceb8be0c78e65ad1ef359d7ba
Author: lash <dev@holbrook.no>
Date:   Thu, 12 May 2022 11:10:47 +0000

Rehabilitate decode tool

Diffstat:
Mchainlib/eth/runnable/decode.py | 31+++++++++++++++++++++++++++----
Mchainlib/eth/runnable/get.py | 3++-
2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/chainlib/eth/runnable/decode.py b/chainlib/eth/runnable/decode.py @@ -14,7 +14,19 @@ from chainlib.eth.tx import unpack from chainlib.chain import ChainSpec # local imports +import chainlib.eth.cli from chainlib.eth.runnable.util import decode_for_puny_humans +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 + logging.basicConfig(level=logging.WARNING) logg = logging.getLogger() @@ -22,11 +34,22 @@ logg = logging.getLogger() script_dir = os.path.dirname(os.path.realpath(__file__)) config_dir = os.path.join(script_dir, '..', 'data', 'config') -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') + +arg_flags = ArgFlag() +arg = Arg(arg_flags) +flags = arg_flags.VERBOSE | arg_flags.CHAIN_SPEC | arg_flags.RAW | arg_flags.ENV + +argparser = chainlib.eth.cli.ArgumentParser() +argparser = process_args(argparser, arg, flags) +argparser.add_argument('tx_data', type=str, help='Transaction data to decode') args = argparser.parse_args() -config = chainlib.eth.cli.Config.from_args(args, arg_flags, default_config_dir=config_dir) + +logg = process_log(args, logg) + +config = Config() +config = process_config(config, arg, args, flags) +logg.debug('config loaded:\n{}'.format(config)) + chain_spec = ChainSpec.from_chain_str(config.get('CHAIN_SPEC')) diff --git a/chainlib/eth/runnable/get.py b/chainlib/eth/runnable/get.py @@ -58,11 +58,12 @@ logg = logging.getLogger() script_dir = os.path.dirname(os.path.realpath(__file__)) config_dir = os.path.join(script_dir, '..', 'data', 'config') -argparser = chainlib.eth.cli.ArgumentParser() arg_flags = ArgFlag() arg = Arg(arg_flags) flags = arg_flags.STD_BASE_READ flags = arg_flags.less(flags, arg_flags.CHAIN_SPEC) + +argparser = chainlib.eth.cli.ArgumentParser() argparser = process_args(argparser, arg, flags) argparser.add_argument('item', type=str, help='Address or transaction to retrieve data for') args = argparser.parse_args()