Flags cleanup, remove persistent wallet

This commit is contained in:
lash 2022-02-24 10:35:52 +00:00
parent 9419fbb77b
commit fcd78b5ca8
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
8 changed files with 49 additions and 22 deletions

View File

@ -1,5 +1,11 @@
- 0.0.23
* Configuration variable descriptions
* Arg flags to names listing method
* New flags preset for reads without wallet
* Remove pesistent wallet arg flag bug
* Rename arg flag reset to flag_reset
- 0.0.22
* Add man page generator script
* Man page generator script
- 0.0.21
* Log rpc reply before json parse
- 0.0.20

View File

@ -1 +1 @@
include *requirements.txt LICENSE chainlib/data/config/*
include *requirements.txt LICENSE chainlib/data/config/* chainlib/data/env/*

View File

@ -3,7 +3,8 @@ from .base import (
argflag_std_read,
argflag_std_write,
argflag_std_base,
reset,
argflag_std_base_read,
flag_reset,
)
from .arg import ArgumentParser
from .config import Config

View File

@ -203,8 +203,9 @@ class ArgumentParser(argparse.ArgumentParser):
if arg_flags & (Flag.SIGN | Flag.FEE):
self.add_argument('--fee-price', dest='fee_price', type=int, help='override fee price')
self.add_argument('--fee-limit', dest='fee_limit', type=int, help='override fee limit')
if arg_flags & argflag_std_target == 0:
arg_flags |= Flag.WALLET
# wtf?
#if arg_flags & argflag_std_target == 0:
# arg_flags |= Flag.WALLET
if arg_flags & Flag.EXEC:
self.add_argument('-e', self.long_args['-e'], dest=self.arg_dest['-e'], type=str, help='contract address')
if arg_flags & Flag.WALLET:

View File

@ -33,14 +33,32 @@ class Flag(enum.IntEnum):
SEND = 262144
# rpc extras - nibble 6
RPC_AUTH = 1048576
# upper bound
MAX = 1048576
argflag_std_read = 0x23ff
argflag_std_write = 0xff31ff
argflag_std_write = 0x1731ff
argflag_std_base = 0x200f
argflag_std_base_read = 0xbf
argflag_std_target = 0x00e000
argflag_all = 0xffffff
argflag_all = 0x17f7ff
def reset(flags, v):
def flag_reset(flags, v):
mask = ~(argflag_all & v)
r = flags & mask
return r
def flag_names(flags):
flags_debug = []
i = Flag.MAX
while True:
if flags & i > 0:
v = Flag(i)
flags_debug.append(v.name)
i >>= 1
if i == 0:
break
flags_debug.reverse()
return flags_debug

View File

@ -132,6 +132,7 @@ class DocGenerator:
def process_arg(self):
if self.arg_flags & Flag.VERBOSE:
o = DocEntry('--no-logs')
o.set_groff('Turn of logging completely. Negates \\fB-v\\fP and \\fB-vv\\fP')
@ -145,7 +146,6 @@ class DocGenerator:
o.set_groff('Very verbose. Show logs with debugging information.')
self.docs['vv'] = o
if self.arg_flags & Flag.CONFIG:
o = DocEntry('-c', '--config', argvalue='config_dir')
o.set_groff('Load configuration files from given directory. All files with an .ini extension will be loaded, of which all must contain valid ini file data.')
@ -244,7 +244,6 @@ class DocGenerator:
o.set_groff('Produce output most optimized for machines.')
self.docs['raw'] = o
if self.arg_flags & (Flag.SIGN | Flag.NONCE):
o = DocEntry('--nonce')
o.set_groff('Explicitly set nonce to use for transaction.')
@ -260,9 +259,10 @@ class DocGenerator:
o.set_groff('Set the limit of execution units for the transaction. If used with \\fB-s\\fP this may incur actual network token cost. If \\fB--fee-price\\fP is not explicitly set, the price \\fImay\\fP be retrieved from the network, and multiplied with this value to define the cost.')
self.docs['feelimit'] = o
# TODO: this manipulation should be DRYd
if self.arg_flags & argflag_std_target == 0:
self.arg_flags |= Flag.WALLET
# # TODO: this manipulation should be DRYd
# if self.arg_flags & argflag_std_target == 0:
# self.arg_flags |= Flag.WALLET
if self.arg_flags & Flag.EXEC:

View File

@ -14,9 +14,12 @@ from chainlib.cli.man import (
DocGenerator,
apply_groff,
)
from chainlib.cli.base import argflag_std_base
from chainlib.cli.base import (
argflag_std_base,
flag_names,
)
from chainlib.cli.arg import ArgumentParser as ChainlibArgumentParser
from chainlib.eth.cli.config import Config
from chainlib.cli.config import Config
logging.basicConfig(level=logging.WARNING)
@ -88,20 +91,18 @@ args = argparser.parse_args(sys.argv[1:])
if args.v:
logg.setLevel(logging.DEBUG)
b = bytes.fromhex(strip_0x(args.b))
flags = int.from_bytes(b, byteorder='little')
flags = int.from_bytes(b, byteorder='big')
flags_debug= flag_names(flags)
logg.debug('apply arg flags {}: {}'.format(flags, ', '.join(flags_debug)))
#empty_args = ChainlibArgumentParser(flags).parse_args([])
#config = Config.from_args(empty_args, arg_flags=flags)
#g = DocGenerator(flags, config)
g = DocGenerator(flags)
toolname = args.n
if toolname == None:
parts = os.path.splitext(os.path.basename(args.header_file))
toolname = parts[0]
g.process()
if args.overrides_file != None:

View File

@ -3,7 +3,7 @@ name=chainlib
license=WTFPL2
author_email=dev@holbrook.no
description=Generic blockchain access library and tooling
version=0.0.22
version=0.0.23
url=https://gitlab.com/chaintools/chainlib
author=Louis Holbrook