Compare commits

...

12 Commits

Author SHA1 Message Date
lash f66f93d867
Add generic initializationerror 2022-05-14 12:23:06 +00:00
lash 9f537ff569
Add state settings and config 2022-05-13 13:44:15 +00:00
lash e225b4e333
Conceal wait settings behind config check 2022-05-13 07:48:48 +00:00
lash 36bd98f3df
Upgrade confini 2022-05-12 18:42:54 +00:00
lash 5e6db69630
Update deps 2022-05-12 18:30:05 +00:00
lash 3a1a74c66b
Bump version 2022-05-12 18:21:49 +00:00
lash 7a13d25524
Add common value processing with aiee 2022-05-12 18:21:18 +00:00
lash f5ab76e81a
Move settings processing out of class scope 2022-05-12 13:49:23 +00:00
lash bfed5843b4
Fix nonsensical no-target handling 2022-05-12 13:21:22 +00:00
lash 4d04840e3d
Fix missing sign flag handling, default fee in chain config 2022-05-12 09:31:07 +00:00
lash 65830cebed
Correct type for 'unsafe' flag 2022-05-12 08:19:54 +00:00
lash 91d9654052
Add fields to block object 2022-05-12 08:06:14 +00:00
9 changed files with 89 additions and 28 deletions

View File

@ -1,3 +1,6 @@
- 0.3.0
* Implement arg handling from aiee
* Implement value argument handling from aiee
- 0.2.1
* Fix bug in wire format generation for tx
- 0.2.0

View File

@ -27,6 +27,10 @@ class Block(Src):
self.get_tx = self.tx_index_by_hash
self.tx = self.tx_by_index
self.fee_limit = 0
self.fee_cost = 0
self.parent_hash = None
super(Block, self).__init__(src=src)

View File

@ -50,12 +50,12 @@ class ArgFlag(BaseArgFlag):
self.add('env')
self.add('provider')
self.add('chain_spec')
self.add('target')
self.add('unsafe')
self.add('seq')
self.add('key_file')
self.add('fee')
self.add('nonce')
self.add('sign')
self.add('no_target')
self.add('exec')
self.add('wallet')
@ -67,13 +67,16 @@ class ArgFlag(BaseArgFlag):
self.add('fmt_wire')
self.add('fmt_rpc')
self.add('veryverbose')
self.add('path')
self.add('backend')
self.alias('std_base', 'verbose', 'config', 'raw', 'env', 'no_target')
self.alias('sign', 'key_file', 'send')
self.alias('std_base', 'verbose', 'config', 'raw', 'env', 'target')
self.alias('std_base_read', 'verbose', 'config', 'raw', 'env', 'provider', 'chain_spec', 'seq')
self.alias('std_read', 'std_base', 'provider', 'chain_spec', 'unsafe', 'seq', 'key_file', 'fee', 'no_target')
self.alias('std_write', 'provider', 'chain_spec', 'unsafe', 'seq', 'key_file', 'sign', 'no_target', 'wait', 'wait_all', 'send', 'rpc_auth')
self.alias('std_read', 'std_base', 'provider', 'chain_spec', 'unsafe', 'seq', 'sign', 'fee', 'target')
self.alias('std_write', 'verbose', 'config', 'raw', 'env', 'provider', 'chain_spec', 'unsafe', 'seq', 'key_file', 'sign', 'target', 'wait', 'wait_all', 'send', 'rpc_auth', 'nonce', 'fee')
self.alias('std_target', 'no_target', 'exec', 'wallet')
self.alias('state', 'backend', 'path')
class Arg(BaseArg):
@ -91,6 +94,12 @@ class Arg(BaseArg):
self.set_long('c', 'config')
self.add_long('dumpconfig', 'config', help='Output configuration and quit. Use with --raw to omit values and output schema only.')
self.add('a', 'wallet', dest='recipient', help='Recipient address')
self.set_long('a', 'recipient')
self.add('e', 'exec', dest='executable_address', help='Recipient address')
self.set_long('e', 'executable')
self.add('w', 'wait', typ=bool, help='Wait for the last transaction to be confirmed')
self.add('ww', 'wait', check=False, typ=bool, help='Wait for every transaction to be confirmed')
@ -102,7 +111,7 @@ class Arg(BaseArg):
self.add_long('rpc-timeout', 'provider', help='RPC autentication credential values')
self.add_long('rpc-proxy', 'provider', help='RPC autentication credential values')
self.add_long('height', 'no_target', default='latest', help='Block height to execute against')
self.add_long('height', 'target', default='latest', help='Block height to execute against')
self.add_long('rpc-auth', 'rpc_auth', help='RPC autentication scheme')
self.add_long('rpc-credentials', 'rpc_auth', help='RPC autentication credential values')
@ -110,13 +119,13 @@ class Arg(BaseArg):
self.add('i', 'chain_spec', help='Chain specification string')
self.set_long('i', 'chain-spec')
self.add('u', 'unsafe', help='Do not verify address checksums')
self.add('u', 'unsafe', typ=bool, help='Do not verify address checksums')
self.set_long('u', 'unsafe')
self.add_long('seq', 'seq', typ=bool, help='Use sequential rpc ids')
self.add('y', 'key_file', help='Keystore file to use for signing or address')
self.set_long('y', 'key-file')
self.set_long('y', 'key_file')
self.add_long('passphrase-file', 'key_file', help='Keystore file to use for signing or address')
self.add('s', 'send', typ=bool, help='Send to network')
@ -128,3 +137,7 @@ class Arg(BaseArg):
self.add_long('nonce', 'nonce', typ=int, help='override nonce')
self.add_long('fee-price', 'fee', typ=int, help='override fee price')
self.add_long('fee-limit', 'fee', typ=int, help='override fee limit')
self.add_long('state-path', 'path', help='Path to store state data under')
self.add_long('runtime-path', 'path', help='Path to store volatile data under')
self.add_long('backend', 'backend', help='Backend to use for data storage')

View File

@ -85,36 +85,40 @@ def process_config(config, arg, args, flags):
f.close()
config.censor('PASSPHRASE', 'WALLET')
if arg.match('backend', flags):
args_override['STATE_BACKEND'] = getattr(args, 'backend')
if arg.match('path', flags):
args_override['STATE_PATH'] = getattr(args, 'state_path')
config.dict_override(args_override, 'cli args', allow_empty=True)
if arg.match('provider', flags):
if arg.match('no_target', flags, negate=True):
if arg.match('target', flags):
config.add(getattr(args, 'height'), '_HEIGHT')
if arg.match('unsafe', flags):
config.add(getattr(args, 'u'), '_UNSAFE')
if arg.match('sign', flags):
config.add(getattr(args, 's'), '_RPC_SEND')
if arg.match('fee', flags):
config.add(getattr(args, 'fee_price'), '_FEE_PRICE')
fee_limit = getattr(args, 'fee_limit')
if fee_limit == None:
fee_limit = default_fee_limit
if fee_limit == None:
fee_limit = cls.default_fee_limit
fee_limit = int(config.get('CHAIN_MIN_FEE'))
config.add(fee_limit, '_FEE_LIMIT')
if arg.match('nonce', flags):
config.add(getattr(args, 'nonce'), '_NONCE')
config.add(getattr(args, 's'), '_RPC_SEND')
if args.ww:
config.add(True, '_WAIT_ALL')
config.add(True, '_WAIT')
elif args.w:
config.add(True, '_WAIT')
if arg.match('wait', flags):
if args.ww:
config.add(True, '_WAIT_ALL')
config.add(True, '_WAIT')
elif args.w:
config.add(True, '_WAIT')
if arg.match('seq', flags):
config.add(getattr(args, 'seq'), '_SEQ')
@ -129,4 +133,5 @@ def process_config(config, arg, args, flags):
config.add(getattr(args, 'rpc_auth'), 'RPC_AUTH')
config.add(getattr(args, 'rpc_credentials'), 'RPC_CREDENTIALS')
return config

View File

@ -10,7 +10,14 @@ proxy =
[chain]
spec =
min_fee = 0
max_fee = 0
[wallet]
key_file =
passphrase =
[state]
path =
runtime_path =
backend =

View File

@ -11,13 +11,18 @@ class JSONRPCException(RPCException):
pass
class InitializationError(Exception):
"""Base error for errors occurring while processing settings
"""
pass
class ExecutionError(Exception):
"""Base error for transaction execution failures
"""
pass
class SignerMissingException(Exception):
class SignerMissingException(InitializationError):
"""Raised when attempting to retrieve a signer when none has been added
"""

View File

@ -1,3 +1,6 @@
# external imports
from aiee.numbers import postfix_to_int
# local imports
from .chain import ChainSpec
@ -9,12 +12,8 @@ class ChainSettings:
self.get = self.o.get
def process_common(self, config):
self.o['CHAIN_SPEC'] = ChainSpec.from_chain_str(config.get('CHAIN_SPEC'))
def process(self, config):
self.process_common(config)
def set(self, k, v):
self.o[k] = v
def __str__(self):
@ -24,3 +23,27 @@ class ChainSettings:
for k in ks:
s += '{}: {}\n'.format(k, self.o.get(k))
return s
def process_settings_common(settings, config):
chain_spec = ChainSpec.from_chain_str(config.get('CHAIN_SPEC'))
settings.set('CHAIN_SPEC', chain_spec)
return settings
def process_settings_value(settings, config):
value = None
try:
value = config.get('_VALUE')
except KeyError:
return settings
value = postfix_to_int(config.get('_VALUE'))
settings.set('VALUE', value)
return settings
def process_settings(settings, config):
settings = process_settings_common(settings, config)
settings = process_settings_value(settings, config)
return settings

View File

@ -1,4 +1,5 @@
funga~=0.5.2
pysha3==1.0.2
hexathon~=0.1.7
confini~=0.6.0
confini~=0.6.1
aiee~=0.3.1

View File

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