commit c060222638bc7dfceb8be0c78e65ad1ef359d7ba
parent e16cc956e0d9c39a4a7242f4234d974aac02fec2
Author: lash <dev@holbrook.no>
Date: Thu, 12 May 2022 09:29:10 +0000
Rehabilitate gas cli tool on new chainlib
Diffstat:
4 files changed, 37 insertions(+), 16 deletions(-)
diff --git a/chainlib/eth/data/config/config.ini b/chainlib/eth/data/config/config.ini
@@ -10,7 +10,10 @@ proxy =
[chain]
spec = evm:berlin:1:ethereum
+min_fee = 21000
+max_fee = 8000000
[wallet]
key_file =
passphrase =
+
diff --git a/chainlib/eth/runnable/balance.py b/chainlib/eth/runnable/balance.py
@@ -40,10 +40,11 @@ logg = logging.getLogger()
script_dir = os.path.dirname(os.path.realpath(__file__))
-argparser = chainlib.eth.cli.ArgumentParser()
arg_flags = ArgFlag()
arg = Arg(arg_flags)
flags = arg_flags.STD_READ
+
+argparser = chainlib.eth.cli.ArgumentParser()
argparser = process_args(argparser, arg, flags)
argparser.add_argument('address', type=str, help='Ethereum address of recipient')
diff --git a/chainlib/eth/runnable/count.py b/chainlib/eth/runnable/count.py
@@ -29,7 +29,6 @@ from funga.eth.keystore.dict import DictKeystore
from funga.eth.signer import EIP155Signer
from hexathon import add_0x
-logging.basicConfig(level=logging.WARNING)
logg = logging.getLogger()
script_dir = os.path.dirname(os.path.realpath(__file__))
diff --git a/chainlib/eth/runnable/gas.py b/chainlib/eth/runnable/gas.py
@@ -31,24 +31,43 @@ from chainlib.eth.address import (
is_checksum_address,
)
import chainlib.eth.cli
+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()
-arg_flags = chainlib.eth.cli.argflag_std_write | chainlib.eth.cli.Flag.WALLET
-argparser = chainlib.eth.cli.ArgumentParser(arg_flags)
+
+def process_config_local(config, arg, args, flags):
+ config.add(args.data, '_DATA', False)
+ config.add(args.amount, '_AMOUNT', False)
+ return config
+
+
+arg_flags = ArgFlag()
+arg = Arg(arg_flags)
+flags = arg_flags.STD_WRITE | arg_flags.WALLET
+
+argparser = chainlib.eth.cli.ArgumentParser()
+argparser = process_args(argparser, arg, flags)
argparser.add_argument('--data', type=str, help='Transaction data')
-argparser.add_positional('amount', type=int, help='Token amount to send')
+argparser.add_argument('amount', type=int, help='Token amount to send')
args = argparser.parse_args()
-extra_args = {
- 'data': None,
- 'amount': None,
- }
-#config = chainlib.eth.cli.Config.from_args(args, arg_flags, extra_args=extra_args, default_config_dir=config_dir)
-config = chainlib.eth.cli.Config.from_args(args, arg_flags, extra_args=extra_args)
-block_all = args.ww
-block_last = args.w or block_all
+logg = process_log(args, logg)
+logg.debug('flags {} {} {}'.format(flags, arg_flags.SEQ, flags & arg_flags.SEQ))
+
+config = Config()
+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)
@@ -98,7 +117,7 @@ def main():
if send:
conn.do(o)
- if block_last:
+ if config.true('_WAIT'):
r = conn.wait(tx_hash_hex)
if logg.isEnabledFor(logging.DEBUG):
sender_balance = balance(add_0x(signer_address), rpc.id_generator)
@@ -110,7 +129,6 @@ def main():
sys.exit(1)
print(tx_hash_hex)
else:
- #if logg.isEnabledFor(logging.INFO):
if config.true('_RAW'):
print(o['params'][0])
else: