feat: add interactive deployment and switch to poetry #2

Merged
williamluke merged 19 commits from lum/easy-token-deployment into master 2022-03-16 06:37:49 +01:00
7 changed files with 65 additions and 35 deletions
Showing only changes of commit 264abf4138 - Show all commits

View File

@ -10,10 +10,10 @@ from cic_types.ext.metadata.signer import Signer as MetadataSigner
# local imports
from cic.contract.processor import ContractProcessor
from cic.contract.components.proof import Proof
from cic.contract.components.proof import Proof
from cic.contract.components.attachment import Attachment
from cic.contract.components.meta import Meta
from cic.contract.components.network import Network
from cic.contract.network import Network
from cic.contract.components.token import Token
from cic.writers import HTTPWriter, KeyedWriterFactory, MetadataWriter

View File

@ -3,16 +3,21 @@ import importlib
# external imports
from chainlib.chain import ChainSpec
# local imports
from cic.contract.components.network import Network
from cic.contract.network import Network
def process_args(argparser):
argparser.add_argument('--registry', required=True, type=str, help='contract registry address')
argparser.add_argument('-d', '--directory', type=str, dest='directory', default='.', help='directory')
argparser.add_argument('-p', type=str, help='RPC endpoint')
argparser.add_argument('-i', type=str, help='chain spec string')
argparser.add_argument('target', help='target to initialize')
argparser.add_argument(
"--registry", required=True, type=str, help="contract registry address"
)
argparser.add_argument(
"-d", "--directory", type=str, dest="directory", default=".", help="directory"
)
argparser.add_argument("-p", type=str, help="RPC endpoint")
argparser.add_argument("-i", type=str, help="chain spec string")
argparser.add_argument("target", help="target to initialize")
def validate_args(args):
@ -23,8 +28,11 @@ def execute(config, eargs):
cn = Network(eargs.directory, targets=eargs.target)
cn.load()
chain_spec = ChainSpec.from_chain_str(eargs.i)
m = importlib.import_module(f'cic.ext.{eargs.target}.start')
m.extension_start(cn, registry_address=eargs.registry, chain_spec=chain_spec, rpc_provider=config.get('RPC_PROVIDER'))
m = importlib.import_module(f"cic.ext.{eargs.target}.start")
m.extension_start(
cn,
registry_address=eargs.registry,
chain_spec=chain_spec,
rpc_provider=config.get("RPC_PROVIDER"),
)

View File

@ -6,18 +6,24 @@ import os
from cic.contract.components.proof import Proof
from cic.contract.components.meta import Meta
from cic.contract.components.attachment import Attachment
from cic.contract.components.network import Network
from cic.contract.network import Network
from cic.contract.components.token import Token
logg = logging.getLogger(__name__)
def process_args(argparser):
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')
argparser.add_argument('directory', help='directory to initialize')
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")
argparser.add_argument("directory", help="directory to initialize")
def validate_args(args):
@ -25,11 +31,13 @@ def validate_args(args):
def execute(config, eargs):
logg.info('initializing in {}'.format(eargs.directory))
logg.info("initializing in {}".format(eargs.directory))
os.makedirs(eargs.directory)
ct = Token(eargs.directory, name=eargs.name, symbol=eargs.symbol, precision=eargs.precision)
ct = Token(
eargs.directory, name=eargs.name, symbol=eargs.symbol, precision=eargs.precision
)
cp = Proof(eargs.directory)
cm = Meta(eargs.directory)
ca = Attachment(eargs.directory)

View File

@ -2,13 +2,20 @@
from cic.contract.components.proof import Proof
from cic.contract.components.meta import Meta
from cic.contract.components.attachment import Attachment
from cic.contract.components.network import Network
from cic.contract.network import Network
from cic.contract.components.token import Token
def process_args(argparser):
argparser.add_argument('-f', '--file', type=str, help='add file')
argparser.add_argument('-d', '--directory', type=str, dest='directory', default='.', help='cic data directory')
argparser.add_argument("-f", "--file", type=str, help="add file")
argparser.add_argument(
"-d",
"--directory",
type=str,
dest="directory",
default=".",
help="cic data directory",
)
def validate_args(args):
@ -28,8 +35,12 @@ def execute(config, eargs):
ca.load()
cn.load()
print("""[cic.header]
version = {}\n""".format(cp.version()))
print(
"""[cic.header]
version = {}\n""".format(
cp.version()
)
)
print("[cic.token]\n{}".format(ct))
print("[cic.proof]\n{}".format(cp))
print("[cic.meta]\n{}".format(cm))

View File

@ -16,7 +16,7 @@ from chainlib.chain import ChainSpec
from cic.contract.components.proof import Proof
from cic.contract.components.attachment import Attachment
from cic.contract.components.meta import Meta
from cic.contract.components.network import Network
from cic.contract.network import Network
from cic.contract.components.token import Token
from cic.contract.contract import generate_contract, load_contract, deploy_contract
@ -61,7 +61,6 @@ def validate_args(_args):
pass
def get_options(config: Config, eargs):
# Defaults
default_contract_registry = config.get(

View File

@ -11,11 +11,12 @@ from cic_types.ext.metadata import MetadataRequestsHandler
from cic_types.ext.metadata.signer import Signer as MetadataSigner
from chainlib.cli.config import Config
from chainlib.chain import ChainSpec
# Local Modules
from cic.contract.processor import ContractProcessor
from cic.contract.components.attachment import Attachment
from cic.contract.components.meta import Meta
from cic.contract.components.network import Network
from cic.contract.network import Network
from cic.contract.components.proof import Proof
from cic.contract.components.token import Token
from cic.contract.helpers import init_writers_from_config
@ -103,12 +104,14 @@ def generate_contract(
network = Network(directory, targets=targets)
network.start()
log.debug(f"""Populating infomation from network:
log.debug(
f"""Populating infomation from network:
CIC_REGISTRY_ADDRESS: {config.get("CIC_REGISTRY_ADDRESS")}
CHAIN_SPEC: {config.get("CHAIN_SPEC")}
RPC_PROVIDER: {config.get("RPC_PROVIDER")}
AUTH_KEY: {config.get("AUTH_KEY")}
""")
"""
)
for target in targets:
m = importlib.import_module(f"cic.ext.{target}.start")
m.extension_start(
@ -116,7 +119,9 @@ def generate_contract(
registry_address=config.get("CIC_REGISTRY_ADDRESS"),
chain_spec=ChainSpec.from_chain_str(config.get("CHAIN_SPEC")),
rpc_provider=config.get("RPC_PROVIDER"),
key_account_address=config.get("AUTH_KEY"), # TODO this should come from the wallet keystore
key_account_address=config.get(
"AUTH_KEY"
), # TODO this should come from the wallet keystore
)
network.load()

View File

@ -1,11 +1,10 @@
# standard imports
import os
import json
import logging
import os
# external imports
from chainlib.chain import ChainSpec
# local imports
from cic.contract.base import Data, data_dir