WIP make token deploy work with cli export stage

This commit is contained in:
nolash
2021-10-11 21:18:51 +02:00
parent 41e41ad220
commit 39becba3b2
4 changed files with 40 additions and 17 deletions

View File

@@ -17,13 +17,17 @@ from chainlib.eth.contract import (
)
from chainlib.eth.gas import OverrideGasOracle
from chainlib.eth.nonce import RPCNonceOracle
from chainlib.eth.address import is_address
from chainlib.eth.address import (
is_address,
to_checksum_address,
)
from hexathon import add_0x
from eth_token_index import TokenUniqueSymbolIndex
from eth_address_declarator import Declarator
from eth_address_declarator.declarator import AddressDeclarator
# local imports
from .signer import parse_signer
from cic.ext.eth.rpc import parse_adapter
logg = logging.getLogger(__name__)
@@ -151,7 +155,7 @@ class CICEth:
code = self.token_details['code'] + enc.get()
logg.debug('resource {}'.format(self.resources))
signer_address = self.resources['token']['key_account']
signer_address = add_0x(to_checksum_address(self.resources['token']['key_account']))
nonce_oracle = None
if self.rpc != None:
nonce_oracle = RPCNonceOracle(signer_address, conn=self.rpc)
@@ -164,10 +168,9 @@ class CICEth:
r = None
if self.rpc != None:
r = self.rpc.do(o[1])
ro = receipt(r)
rr = self.rpc.do(ro)
rr = Tx.src_normalize(rr)
self.token_address = rr['contract_address']
o = self.rpc.wait(r)
o = Tx.src_normalize(o)
self.token_address = o['contract_address']
elif self.signer != None:
r = o[1]
@@ -261,5 +264,5 @@ class CICEth:
return self.token_address
def new(chain_spec, resources, proof, signer_hint=None):
return CICEth(chain_spec, resources, proof, signer=signer_hint)
def new(chain_spec, resources, proof, signer_hint=None, rpc=None):
return CICEth(chain_spec, resources, proof, signer=signer_hint, rpc=rpc)

View File

@@ -6,6 +6,8 @@ import logging
# external imports
from funga.eth.keystore.dict import DictKeystore
from funga.eth.signer import EIP155Signer
from chainlib.eth.cli import Rpc
from chainlib.cli import Wallet
# local imports
from cic.keystore import KeystoreDirectory
@@ -17,8 +19,9 @@ class EthKeystoreDirectory(DictKeystore, KeystoreDirectory):
pass
def parse_signer(signer_hint):
def parse_adapter(config, signer_hint):
keystore = None
if signer_hint == None:
logg.info('signer hint missing')
return None
@@ -27,7 +30,10 @@ def parse_signer(signer_hint):
logg.debug('signer hint is directory')
keystore = EthKeystoreDirectory()
keystore.process_dir(signer_hint)
signer = EIP155Signer(keystore)
return signer
w = Wallet(EIP155Signer, keystore=keystore)
signer = EIP155Signer(keystore)
rpc = Rpc(wallet=w)
rpc.connect_by_config(config)
return (rpc.conn, signer)