Implement chain spec parsing in executable

This commit is contained in:
nolash 2021-02-19 14:57:08 +01:00
parent b59d4b3c43
commit fbfa7493f6
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
3 changed files with 9 additions and 5 deletions

View File

@ -17,6 +17,7 @@ import logging
# third-party imports # third-party imports
from chainlib.eth.tx import unpack from chainlib.eth.tx import unpack
from chainlib.chain import ChainSpec
logging.basicConfig(level=logging.WARNING) logging.basicConfig(level=logging.WARNING)
@ -34,7 +35,8 @@ args = argparser.parse_args()
if args.v: if args.v:
logg.setLevel(logging.DEBUG) 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(): def main():

View File

@ -38,6 +38,7 @@ from chainlib.eth.gas import (
GasTxFactory, GasTxFactory,
) )
from chainlib.eth.gas import balance as gas_balance from chainlib.eth.gas import balance as gas_balance
from chainlib.chain import ChainSpec
logging.basicConfig(level=logging.WARNING) logging.basicConfig(level=logging.WARNING)
logg = logging.getLogger() logg = logging.getLogger()
@ -106,8 +107,8 @@ else:
gas_oracle = DefaultGasOracle(conn) gas_oracle = DefaultGasOracle(conn)
chain_pair = args.i.split(':') chain_spec = ChainSpec.from_chain_str(args.i)
chain_id = int(chain_pair[1]) chain_id = chain_spec.network_id()
value = args.amount value = args.amount

View File

@ -30,6 +30,7 @@ from chainlib.eth.rpc import jsonrpc_template
from chainlib.eth.nonce import DefaultNonceOracle from chainlib.eth.nonce import DefaultNonceOracle
from chainlib.eth.gas import DefaultGasOracle from chainlib.eth.gas import DefaultGasOracle
from chainlib.eth.erc20 import ERC20TxFactory from chainlib.eth.erc20 import ERC20TxFactory
from chainlib.chain import ChainSpec
logging.basicConfig(level=logging.WARNING) logging.basicConfig(level=logging.WARNING)
@ -85,8 +86,8 @@ conn = HTTPConnection(args.p)
nonce_oracle = DefaultNonceOracle(signer_address, conn) nonce_oracle = DefaultNonceOracle(signer_address, conn)
gas_oracle = DefaultGasOracle(conn) gas_oracle = DefaultGasOracle(conn)
chain_pair = args.i.split(':') chain_spec = ChainSpec.from_chain_str(args.i)
chain_id = int(chain_pair[1]) chain_id = chain_spec.network_id()
value = args.amount value = args.amount