WIP make token deploy work with cli export stage
This commit is contained in:
parent
41e41ad220
commit
39becba3b2
@ -19,6 +19,7 @@ logg = logging.getLogger(__name__)
|
|||||||
def process_args(argparser):
|
def process_args(argparser):
|
||||||
argparser.add_argument('-d', '--directory', type=str, dest='directory', default='.', help='directory')
|
argparser.add_argument('-d', '--directory', type=str, dest='directory', default='.', help='directory')
|
||||||
argparser.add_argument('-y', '--signer', type=str, dest='y', help='target-specific signer to use for export')
|
argparser.add_argument('-y', '--signer', type=str, dest='y', help='target-specific signer to use for export')
|
||||||
|
argparser.add_argument('-p', type=str, help='RPC endpoint')
|
||||||
argparser.add_argument('target', type=str, help='target network type')
|
argparser.add_argument('target', type=str, help='target network type')
|
||||||
|
|
||||||
|
|
||||||
@ -61,12 +62,21 @@ def execute(config, eargs):
|
|||||||
ca.load()
|
ca.load()
|
||||||
cn.load()
|
cn.load()
|
||||||
|
|
||||||
signer = cmd_mod.parse_signer(eargs.y)
|
chain_spec = None
|
||||||
|
try:
|
||||||
|
chain_spec = config.get('CHAIN_SPEC')
|
||||||
|
except KeyError:
|
||||||
|
chain_spec = cn.chain_spec
|
||||||
|
config.add(chain_spec, 'CHAIN_SPEC', exists_ok=True)
|
||||||
|
logg.debug('CHAIN_SPEC config set to {}'.format(str(chain_spec)))
|
||||||
|
|
||||||
|
#signer = cmd_mod.parse_signer(eargs.y)
|
||||||
|
(rpc, signer) = cmd_mod.parse_adapter(config, eargs.y)
|
||||||
|
|
||||||
ref = cn.resource(eargs.target)
|
ref = cn.resource(eargs.target)
|
||||||
chain_spec = cn.chain_spec(eargs.target)
|
chain_spec = cn.chain_spec(eargs.target)
|
||||||
logg.debug('found reference {} chain spec {} for target {}'.format(ref['contents'], chain_spec, eargs.target))
|
logg.debug('found reference {} chain spec {} for target {}'.format(ref['contents'], chain_spec, eargs.target))
|
||||||
c = getattr(cmd_mod, 'new')(chain_spec, ref['contents'], cp, signer_hint=signer)
|
c = getattr(cmd_mod, 'new')(chain_spec, ref['contents'], cp, signer_hint=signer, rpc=rpc)
|
||||||
c.apply_token(ct)
|
c.apply_token(ct)
|
||||||
|
|
||||||
p = Processor(proof=cp, attachment=ca, metadata=cm, extensions=[eargs.target])
|
p = Processor(proof=cp, attachment=ca, metadata=cm, extensions=[eargs.target])
|
||||||
|
@ -17,13 +17,17 @@ from chainlib.eth.contract import (
|
|||||||
)
|
)
|
||||||
from chainlib.eth.gas import OverrideGasOracle
|
from chainlib.eth.gas import OverrideGasOracle
|
||||||
from chainlib.eth.nonce import RPCNonceOracle
|
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_token_index import TokenUniqueSymbolIndex
|
||||||
from eth_address_declarator import Declarator
|
from eth_address_declarator import Declarator
|
||||||
from eth_address_declarator.declarator import AddressDeclarator
|
from eth_address_declarator.declarator import AddressDeclarator
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
from .signer import parse_signer
|
from cic.ext.eth.rpc import parse_adapter
|
||||||
|
|
||||||
logg = logging.getLogger(__name__)
|
logg = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -151,7 +155,7 @@ class CICEth:
|
|||||||
code = self.token_details['code'] + enc.get()
|
code = self.token_details['code'] + enc.get()
|
||||||
|
|
||||||
logg.debug('resource {}'.format(self.resources))
|
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
|
nonce_oracle = None
|
||||||
if self.rpc != None:
|
if self.rpc != None:
|
||||||
nonce_oracle = RPCNonceOracle(signer_address, conn=self.rpc)
|
nonce_oracle = RPCNonceOracle(signer_address, conn=self.rpc)
|
||||||
@ -164,10 +168,9 @@ class CICEth:
|
|||||||
r = None
|
r = None
|
||||||
if self.rpc != None:
|
if self.rpc != None:
|
||||||
r = self.rpc.do(o[1])
|
r = self.rpc.do(o[1])
|
||||||
ro = receipt(r)
|
o = self.rpc.wait(r)
|
||||||
rr = self.rpc.do(ro)
|
o = Tx.src_normalize(o)
|
||||||
rr = Tx.src_normalize(rr)
|
self.token_address = o['contract_address']
|
||||||
self.token_address = rr['contract_address']
|
|
||||||
elif self.signer != None:
|
elif self.signer != None:
|
||||||
r = o[1]
|
r = o[1]
|
||||||
|
|
||||||
@ -261,5 +264,5 @@ class CICEth:
|
|||||||
return self.token_address
|
return self.token_address
|
||||||
|
|
||||||
|
|
||||||
def new(chain_spec, resources, proof, signer_hint=None):
|
def new(chain_spec, resources, proof, signer_hint=None, rpc=None):
|
||||||
return CICEth(chain_spec, resources, proof, signer=signer_hint)
|
return CICEth(chain_spec, resources, proof, signer=signer_hint, rpc=rpc)
|
||||||
|
@ -6,6 +6,8 @@ import logging
|
|||||||
# external imports
|
# external imports
|
||||||
from funga.eth.keystore.dict import DictKeystore
|
from funga.eth.keystore.dict import DictKeystore
|
||||||
from funga.eth.signer import EIP155Signer
|
from funga.eth.signer import EIP155Signer
|
||||||
|
from chainlib.eth.cli import Rpc
|
||||||
|
from chainlib.cli import Wallet
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
from cic.keystore import KeystoreDirectory
|
from cic.keystore import KeystoreDirectory
|
||||||
@ -17,8 +19,9 @@ class EthKeystoreDirectory(DictKeystore, KeystoreDirectory):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def parse_signer(signer_hint):
|
def parse_adapter(config, signer_hint):
|
||||||
|
|
||||||
|
keystore = None
|
||||||
if signer_hint == None:
|
if signer_hint == None:
|
||||||
logg.info('signer hint missing')
|
logg.info('signer hint missing')
|
||||||
return None
|
return None
|
||||||
@ -27,7 +30,10 @@ def parse_signer(signer_hint):
|
|||||||
logg.debug('signer hint is directory')
|
logg.debug('signer hint is directory')
|
||||||
keystore = EthKeystoreDirectory()
|
keystore = EthKeystoreDirectory()
|
||||||
keystore.process_dir(signer_hint)
|
keystore.process_dir(signer_hint)
|
||||||
|
|
||||||
|
w = Wallet(EIP155Signer, keystore=keystore)
|
||||||
signer = EIP155Signer(keystore)
|
signer = EIP155Signer(keystore)
|
||||||
|
rpc = Rpc(wallet=w)
|
||||||
|
rpc.connect_by_config(config)
|
||||||
|
|
||||||
return signer
|
return (rpc.conn, signer)
|
||||||
|
|
@ -19,7 +19,8 @@ data_dir = os.path.join(script_dir, '..', 'data')
|
|||||||
base_config_dir = os.path.join(data_dir, 'config')
|
base_config_dir = os.path.join(data_dir, 'config')
|
||||||
schema_dir = os.path.join(script_dir, '..', 'schema')
|
schema_dir = os.path.join(script_dir, '..', 'schema')
|
||||||
|
|
||||||
argparser = chainlib.cli.ArgumentParser(env=os.environ, description='CIC cli tool for generating and publishing tokens')
|
arg_flags = chainlib.cli.argflag_std_read | chainlib.cli.Flag.SEQ
|
||||||
|
argparser = chainlib.cli.ArgumentParser(env=os.environ, arg_flags=arg_flags, description='CIC cli tool for generating and publishing tokens')
|
||||||
|
|
||||||
sub = argparser.add_subparsers()
|
sub = argparser.add_subparsers()
|
||||||
sub.dest = 'command'
|
sub.dest = 'command'
|
||||||
@ -31,7 +32,6 @@ sub_export = sub.add_parser('export', help='export cic data directory state to a
|
|||||||
cmd_export.process_args(sub_export)
|
cmd_export.process_args(sub_export)
|
||||||
|
|
||||||
args = argparser.parse_args(sys.argv[1:])
|
args = argparser.parse_args(sys.argv[1:])
|
||||||
config = chainlib.cli.Config.from_args(args, base_config_dir=base_config_dir)
|
|
||||||
|
|
||||||
if args.command == None:
|
if args.command == None:
|
||||||
logg.critical('Subcommand missing')
|
logg.critical('Subcommand missing')
|
||||||
@ -41,6 +41,10 @@ modname = 'cic.cmd.{}'.format(args.command)
|
|||||||
logg.debug('using module {}'.format(modname))
|
logg.debug('using module {}'.format(modname))
|
||||||
cmd_mod = importlib.import_module(modname)
|
cmd_mod = importlib.import_module(modname)
|
||||||
|
|
||||||
|
extra_args = {
|
||||||
|
'p': 'RPC_PROVIDER',
|
||||||
|
}
|
||||||
|
config = chainlib.cli.Config.from_args(args, arg_flags=arg_flags, base_config_dir=base_config_dir, extra_args=extra_args)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
#try:
|
#try:
|
||||||
|
Loading…
Reference in New Issue
Block a user