2021-10-06 07:44:53 +02:00
|
|
|
# standard imports
|
|
|
|
import os
|
|
|
|
|
|
|
|
# external imports
|
2022-05-12 07:30:33 +02:00
|
|
|
from chainlib.cli.config import (
|
|
|
|
Config as BaseConfig,
|
|
|
|
process_config as base_process_config,
|
|
|
|
)
|
|
|
|
|
2021-10-06 07:44:53 +02:00
|
|
|
|
|
|
|
script_dir = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
data_dir = os.path.join(script_dir, '..')
|
|
|
|
|
|
|
|
|
|
|
|
class Config(BaseConfig):
|
|
|
|
"""Convenience constructor to set Ethereum defaults for the chainlib cli config object
|
|
|
|
"""
|
|
|
|
default_base_config_dir = os.path.join(data_dir, 'data', 'config')
|
|
|
|
default_fee_limit = 21000
|
|
|
|
|
|
|
|
|
2022-05-12 07:30:33 +02:00
|
|
|
def process_config(config, arg, args, flags):
|
|
|
|
config = base_process_config(config, arg, args, flags)
|
|
|
|
if arg.match('provider', flags):
|
|
|
|
|
|
|
|
if not bool(config.get('RPC_DIALECT')):
|
2021-10-06 07:44:53 +02:00
|
|
|
config.add('default', 'RPC_DIALECT', exists_ok=True)
|
|
|
|
elif config.get('RPC_DIALECT') not in [
|
|
|
|
'openethereum',
|
|
|
|
'default',
|
|
|
|
]:
|
|
|
|
raise ValueError('unknown rpc dialect {}'.format(config.get('RPC_DIALECT')))
|
|
|
|
|
2022-05-12 07:30:33 +02:00
|
|
|
return config
|