Implement rpc dialect arg setting

This commit is contained in:
nolash 2021-08-26 17:08:45 +02:00
parent 9db62c2964
commit a2c71c87d1
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
5 changed files with 26 additions and 0 deletions

View File

@ -137,6 +137,7 @@ class ArgumentParser(argparse.ArgumentParser):
self.add_argument('--env-prefix', default=env.get('CONFINI_ENV_PREFIX'), dest='env_prefix', type=str, help='environment prefix for variables to overwrite configuration')
if arg_flags & Flag.PROVIDER:
self.add_argument('-p', '--provider', dest='p', type=str, help='RPC HTTP(S) provider url')
self.add_argument('--rpc-dialect', dest='rpc_dialect', type=str, help='RPC HTTP(S) backend dialect')
self.add_argument('--height', default='latest', help='Block height to execute against')
if arg_flags & Flag.CHAIN_SPEC:
self.add_argument('-i', '--chain-spec', dest='i', type=str, help='Chain specification string')

View File

@ -159,6 +159,7 @@ class Config(confini.Config):
if arg_flags & Flag.PROVIDER:
args_override['RPC_HTTP_PROVIDER'] = getattr(args, 'p')
args_override['RPC_DIALECT'] = getattr(args, 'rpc_dialect')
if arg_flags & Flag.CHAIN_SPEC:
args_override['CHAIN_SPEC'] = getattr(args, 'i')
if arg_flags & Flag.KEY_FILE:

View File

@ -29,6 +29,7 @@ class Rpc:
self.wallet = wallet
self.nonce_oracle = None
self.fee_oracle = None
self.error_parser = None
def connect_by_config(self, config):

View File

@ -3,6 +3,7 @@ http_provider =
http_authentication =
http_username =
http_password =
dialect = default
[chain]
spec =

View File

@ -20,3 +20,25 @@ class ExecutionError(Exception):
class SignerMissingException(Exception):
"""Raised when attempting to retrieve a signer when none has been added
"""
class RPCNonceException(RPCException):
"""RPC error for invalid nonce in transaction
"""
class DefaultErrorParser:
"""Base class for parsing RPC error repsonses
"""
def translate(self, error):
"""Interface method called by unspeficied rpc when encountering an error
This class method should be overriden to provide more fine-grained context for both general and implementation specific errors.
:param error: RPC error response object
:type error: dict
:rtype: chainlib.error.JSONRPCException
:returns: Descriptiv JSONRPCException
"""
return RPCException('default parser code {}'.format(error))