2022-05-12 15:49:42 +02:00
|
|
|
# external imports
|
|
|
|
from chainlib.settings import process_settings as base_process_settings
|
2022-05-12 16:08:36 +02:00
|
|
|
from hexathon import add_0x
|
2022-05-12 15:49:42 +02:00
|
|
|
|
|
|
|
# local imports
|
|
|
|
import chainlib.eth.cli
|
|
|
|
|
|
|
|
|
|
|
|
def process_settings_rpc(settings, config):
|
2022-05-12 16:08:36 +02:00
|
|
|
rpc = chainlib.eth.cli.Rpc(settings.get('WALLET'))
|
2022-05-12 15:49:42 +02:00
|
|
|
conn = rpc.connect_by_config(config)
|
|
|
|
|
|
|
|
try:
|
|
|
|
settings.set('SIGNER', rpc.get_signer())
|
2022-05-12 16:08:36 +02:00
|
|
|
sender_address = rpc.get_sender_address()
|
|
|
|
settings.set('SENDER_ADDRESS', add_0x(sender_address))
|
2022-05-12 15:49:42 +02:00
|
|
|
except AttributeError:
|
|
|
|
pass
|
|
|
|
|
2022-05-12 16:08:36 +02:00
|
|
|
gas_oracle = rpc.get_gas_oracle()
|
|
|
|
settings.set('GAS_ORACLE', gas_oracle)
|
|
|
|
|
|
|
|
nonce_oracle = rpc.get_nonce_oracle()
|
|
|
|
settings.set('NONCE_ORACLE', nonce_oracle)
|
|
|
|
|
2022-05-12 15:49:42 +02:00
|
|
|
settings.set('CONN', conn)
|
|
|
|
settings.set('RPC_ID_GENERATOR', rpc.id_generator)
|
2022-05-12 16:08:36 +02:00
|
|
|
settings.set('RPC_SEND', config.true('_RPC_SEND'))
|
2022-05-12 15:49:42 +02:00
|
|
|
return settings
|
|
|
|
|
|
|
|
|
|
|
|
def process_settings_wallet(settings, config):
|
|
|
|
wallet = chainlib.eth.cli.Wallet()
|
|
|
|
wallet.from_config(config)
|
|
|
|
|
|
|
|
try:
|
|
|
|
recipient = config.get('_RECIPIENT')
|
|
|
|
except KeyError:
|
|
|
|
return settings
|
|
|
|
|
|
|
|
if wallet.get_signer_address() == None and recipient != None:
|
|
|
|
recipient = wallet.from_address(recipient)
|
|
|
|
|
2022-05-12 16:08:36 +02:00
|
|
|
settings.set('WALLET', wallet)
|
|
|
|
settings.set('RECIPIENT', add_0x(recipient))
|
2022-05-12 15:49:42 +02:00
|
|
|
return settings
|
|
|
|
|
|
|
|
|
|
|
|
def process_settings(settings, config):
|
|
|
|
settings = base_process_settings(settings, config)
|
|
|
|
settings = process_settings_wallet(settings, config)
|
|
|
|
settings = process_settings_rpc(settings, config)
|
|
|
|
return settings
|