fix(ext): allow loading chain_spec from config
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-03-01 13:48:58 +03:00
parent 7ccdde481b
commit 1d4b0512ad
2 changed files with 22 additions and 18 deletions

View File

@@ -1,6 +1,6 @@
# external imports
from cic_eth_registry import CICRegistry
from chainlib.eth.connection import RPCConnection
from cic_eth_registry import CICRegistry
def extension_start(network, *args, **kwargs):
@@ -9,22 +9,26 @@ def extension_start(network, *args, **kwargs):
:param network: Network object to read and write settings from
:type network: cic.network.Network
"""
CICRegistry.address = kwargs['registry_address']
key_account_address = kwargs['key_account_address'] or ''
CICRegistry.address = kwargs.get("registry_address")
key_account_address = kwargs.get("key_account_address")
RPCConnection.register_location(
kwargs.get("rpc_provider"), kwargs.get("chain_spec")
)
conn = RPCConnection.connect(kwargs.get("chain_spec"))
RPCConnection.register_location(kwargs['rpc_provider'], kwargs['chain_spec'])
conn = RPCConnection.connect(kwargs['chain_spec'])
registry = CICRegistry(kwargs.get("chain_spec"), conn)
registry = CICRegistry(kwargs['chain_spec'], conn)
address_declarator = registry.by_name("AddressDeclarator")
network.resource_set(
"eth", "address_declarator", address_declarator, key_account=key_account_address
)
address_declarator = registry.by_name('AddressDeclarator')
network.resource_set('eth', 'address_declarator', address_declarator, key_account=key_account_address)
token_index = registry.by_name("TokenRegistry")
network.resource_set(
"eth", "token_index", token_index, key_account=key_account_address
)
token_index = registry.by_name('TokenRegistry')
network.resource_set('eth', 'token_index', token_index, key_account=key_account_address)
network.resource_set("eth", "token", None, key_account=key_account_address)
network.resource_set('eth', 'token', None, key_account=key_account_address)
network.set('eth', kwargs['chain_spec'])
network.set("eth", kwargs["chain_spec"])
network.save()