chainlib

Generic blockchain access library and tooling
Log | Files | Refs | README | LICENSE

commit fbfa7493f6bc1d0280dd457438abf7f88168646b
parent b59d4b3c43e7607cef768dcd2cfc4d35a2c3e751
Author: nolash <dev@holbrook.no>
Date:   Fri, 19 Feb 2021 14:57:08 +0100

Implement chain spec parsing in executable

Diffstat:
Mchainlib/eth/runnable/decode.py | 4+++-
Mchainlib/eth/runnable/gas.py | 5+++--
Mchainlib/eth/runnable/transfer.py | 5+++--
3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/chainlib/eth/runnable/decode.py b/chainlib/eth/runnable/decode.py @@ -17,6 +17,7 @@ import logging # third-party imports from chainlib.eth.tx import unpack +from chainlib.chain import ChainSpec logging.basicConfig(level=logging.WARNING) @@ -34,7 +35,8 @@ args = argparser.parse_args() if args.v: logg.setLevel(logging.DEBUG) -(chain_name, chain_id) = args.i.split(':') +chain_spec = ChainSpec.from_chain_str(args.i) +chain_id = chain_spec.network_id() def main(): diff --git a/chainlib/eth/runnable/gas.py b/chainlib/eth/runnable/gas.py @@ -38,6 +38,7 @@ from chainlib.eth.gas import ( GasTxFactory, ) from chainlib.eth.gas import balance as gas_balance +from chainlib.chain import ChainSpec logging.basicConfig(level=logging.WARNING) logg = logging.getLogger() @@ -106,8 +107,8 @@ else: gas_oracle = DefaultGasOracle(conn) -chain_pair = args.i.split(':') -chain_id = int(chain_pair[1]) +chain_spec = ChainSpec.from_chain_str(args.i) +chain_id = chain_spec.network_id() value = args.amount diff --git a/chainlib/eth/runnable/transfer.py b/chainlib/eth/runnable/transfer.py @@ -30,6 +30,7 @@ from chainlib.eth.rpc import jsonrpc_template from chainlib.eth.nonce import DefaultNonceOracle from chainlib.eth.gas import DefaultGasOracle from chainlib.eth.erc20 import ERC20TxFactory +from chainlib.chain import ChainSpec logging.basicConfig(level=logging.WARNING) @@ -85,8 +86,8 @@ conn = HTTPConnection(args.p) nonce_oracle = DefaultNonceOracle(signer_address, conn) gas_oracle = DefaultGasOracle(conn) -chain_pair = args.i.split(':') -chain_id = int(chain_pair[1]) +chain_spec = ChainSpec.from_chain_str(args.i) +chain_id = chain_spec.network_id() value = args.amount