Add customizable writers, configs, chain spec in network

This commit is contained in:
nolash
2021-10-11 17:39:01 +02:00
parent 23567905a1
commit 8451285d0d
19 changed files with 159 additions and 61 deletions

View File

@@ -22,14 +22,32 @@ def validate_args(args):
pass
def init_writers_from_config(config):
w = {
'meta': None,
'attachment': None,
'proof': None,
}
for v in w.keys():
k = 'CIC_CORE_{}_WRITER'.format(v.upper())
(d, c) = config.get(k).rsplit('.', maxsplit=1)
m = importlib.import_module(d)
o = getattr(m, c)
w[v] = o
return w
def execute(config, eargs):
modname = 'cic.ext.{}'.format(eargs.target)
cmd_mod = importlib.import_module(modname)
writers = init_writers_from_config(config)
ct = Token(path=eargs.directory)
cm = Meta(path=eargs.directory)
ca = Attachment(path=eargs.directory)
cp = Proof(path=eargs.directory, attachments=ca)
cm = Meta(path=eargs.directory, writer=writers['meta'])
ca = Attachment(path=eargs.directory, writer=writers['attachment'])
cp = Proof(path=eargs.directory, attachments=ca, writer=writers['proof'])
cn = Network(path=eargs.directory)
ct.load()
@@ -38,6 +56,7 @@ def execute(config, eargs):
ca.load()
cn.load()
ref = cn.reference(eargs.target)
ref = cn.resource(eargs.target)
chain_spec = cn.chain_spec(eargs.target)
logg.debug('found reference {} for target {}'.format(ref, eargs.target))
getattr(cmd_mod, 'new')(ref, cp, signer_hint=eargs.signer)
getattr(cmd_mod, 'new')(chain_spec, ref, cp, signer_hint=eargs.signer)

View File

@@ -13,7 +13,7 @@ logg = logging.getLogger(__name__)
def process_args(argparser):
argparser.add_argument('--target', action='append', type=str, help='initialize network specification file with target')
argparser.add_argument('--target', action='append', type=str, default=[], help='initialize network specification file with target')
argparser.add_argument('--name', type=str, help='token name')
argparser.add_argument('--symbol', type=str, help='token symbol')
argparser.add_argument('--precision', type=str, help='token unit precision')