chainlib-eth

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

commit 05d3357318ee30c2c22f500457071445b9394418
parent 85e5359e7ce3a167e400bb0300c809df0f97dfe1
Author: lash <dev@holbrook.no>
Date:   Thu, 12 May 2022 13:53:33 +0000

Add settings module, implement for balance tool

Diffstat:
Mchainlib/eth/runnable/gas.py | 27+++++++++++----------------
Mchainlib/eth/settings.py | 10++++++++++
2 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/chainlib/eth/runnable/gas.py b/chainlib/eth/runnable/gas.py @@ -14,17 +14,18 @@ from hexathon import ( add_0x, strip_0x, ) - -# local imports -from chainlib.eth.address import to_checksum_address -from chainlib.eth.connection import EthHTTPConnection +from chainlib.settings import ChainSettings from chainlib.jsonrpc import ( JSONRPCRequest, IntSequenceGenerator, ) +from chainlib.chain import ChainSpec + +# local imports +from chainlib.eth.address import to_checksum_address +from chainlib.eth.connection import EthHTTPConnection from chainlib.eth.gas import Gas from chainlib.eth.gas import balance as gas_balance -from chainlib.chain import ChainSpec from chainlib.eth.runnable.util import decode_for_puny_humans from chainlib.eth.address import ( is_same_address, @@ -69,13 +70,8 @@ config = process_config(config, arg, args, flags) config = process_config_local(config, arg, args, flags) logg.debug('config loaded:\n{}'.format(config)) -wallet = chainlib.eth.cli.Wallet() -wallet.from_config(config) - -rpc = chainlib.eth.cli.Rpc(wallet=wallet) -conn = rpc.connect_by_config(config) - -chain_spec = ChainSpec.from_chain_str(config.get('CHAIN_SPEC')) +settings = ChainSettings() +settings = settings.process_settings(settings, config) value = config.get('_AMOUNT') @@ -94,10 +90,9 @@ def balance(address, id_generator): def main(): - signer = rpc.get_signer() - signer_address = rpc.get_sender_address() - - g = Gas(chain_spec, signer=signer, gas_oracle=rpc.get_gas_oracle(), nonce_oracle=rpc.get_nonce_oracle()) + g = Gas( + settings.get('CHAIN_SPEC'), + signer=settings.get('SIGNER'), gas_oracle=rpc.get_gas_oracle(), nonce_oracle=rpc.get_nonce_oracle()) recipient = to_checksum_address(config.get('_RECIPIENT')) if not config.true('_UNSAFE') and not is_checksum_address(recipient): diff --git a/chainlib/eth/settings.py b/chainlib/eth/settings.py @@ -11,6 +11,7 @@ def process_settings_rpc(settings, config): try: settings.set('SIGNER', rpc.get_signer()) + settings.set('SENDER_ADDRESS', rpc.get_sender_address()) except AttributeError: pass @@ -35,6 +36,15 @@ def process_settings_wallet(settings, config): return settings +def process_settings_chain(settings, config): + gas_oracle = rpc.get_gas_oracle() + settings.set('GAS_ORACLE', gas_oracle) + + nonce_oracle = rpc.get_nonce_oracle() + settings.set('NONCE_ORACLE', nonce_oracle) + return settings + + def process_settings(settings, config): settings = base_process_settings(settings, config) settings = process_settings_wallet(settings, config)