chore: move network out of contact components
This commit is contained in:
parent
be5d988fa4
commit
264abf4138
@ -10,10 +10,10 @@ from cic_types.ext.metadata.signer import Signer as MetadataSigner
|
|||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
from cic.contract.processor import ContractProcessor
|
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.attachment import Attachment
|
||||||
from cic.contract.components.meta import Meta
|
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.components.token import Token
|
||||||
from cic.writers import HTTPWriter, KeyedWriterFactory, MetadataWriter
|
from cic.writers import HTTPWriter, KeyedWriterFactory, MetadataWriter
|
||||||
|
|
||||||
|
@ -3,16 +3,21 @@ import importlib
|
|||||||
|
|
||||||
# external imports
|
# external imports
|
||||||
from chainlib.chain import ChainSpec
|
from chainlib.chain import ChainSpec
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
from cic.contract.components.network import Network
|
from cic.contract.network import Network
|
||||||
|
|
||||||
|
|
||||||
def process_args(argparser):
|
def process_args(argparser):
|
||||||
argparser.add_argument('--registry', required=True, type=str, help='contract registry address')
|
argparser.add_argument(
|
||||||
argparser.add_argument('-d', '--directory', type=str, dest='directory', default='.', help='directory')
|
"--registry", required=True, type=str, help="contract registry address"
|
||||||
argparser.add_argument('-p', type=str, help='RPC endpoint')
|
)
|
||||||
argparser.add_argument('-i', type=str, help='chain spec string')
|
argparser.add_argument(
|
||||||
argparser.add_argument('target', help='target to initialize')
|
"-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):
|
def validate_args(args):
|
||||||
@ -23,8 +28,11 @@ def execute(config, eargs):
|
|||||||
cn = Network(eargs.directory, targets=eargs.target)
|
cn = Network(eargs.directory, targets=eargs.target)
|
||||||
cn.load()
|
cn.load()
|
||||||
|
|
||||||
|
|
||||||
chain_spec = ChainSpec.from_chain_str(eargs.i)
|
chain_spec = ChainSpec.from_chain_str(eargs.i)
|
||||||
m = importlib.import_module(f'cic.ext.{eargs.target}.start')
|
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.extension_start(
|
||||||
|
cn,
|
||||||
|
registry_address=eargs.registry,
|
||||||
|
chain_spec=chain_spec,
|
||||||
|
rpc_provider=config.get("RPC_PROVIDER"),
|
||||||
|
)
|
||||||
|
@ -6,18 +6,24 @@ import os
|
|||||||
from cic.contract.components.proof import Proof
|
from cic.contract.components.proof import Proof
|
||||||
from cic.contract.components.meta import Meta
|
from cic.contract.components.meta import Meta
|
||||||
from cic.contract.components.attachment import Attachment
|
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
|
from cic.contract.components.token import Token
|
||||||
|
|
||||||
logg = logging.getLogger(__name__)
|
logg = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def process_args(argparser):
|
def process_args(argparser):
|
||||||
argparser.add_argument('--target', action='append', type=str, default=[], help='initialize network specification file with target')
|
argparser.add_argument(
|
||||||
argparser.add_argument('--name', type=str, help='token name')
|
"--target",
|
||||||
argparser.add_argument('--symbol', type=str, help='token symbol')
|
action="append",
|
||||||
argparser.add_argument('--precision', type=str, help='token unit precision')
|
type=str,
|
||||||
argparser.add_argument('directory', help='directory to initialize')
|
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):
|
def validate_args(args):
|
||||||
@ -25,11 +31,13 @@ def validate_args(args):
|
|||||||
|
|
||||||
|
|
||||||
def execute(config, eargs):
|
def execute(config, eargs):
|
||||||
logg.info('initializing in {}'.format(eargs.directory))
|
logg.info("initializing in {}".format(eargs.directory))
|
||||||
|
|
||||||
os.makedirs(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)
|
cp = Proof(eargs.directory)
|
||||||
cm = Meta(eargs.directory)
|
cm = Meta(eargs.directory)
|
||||||
ca = Attachment(eargs.directory)
|
ca = Attachment(eargs.directory)
|
||||||
|
@ -2,13 +2,20 @@
|
|||||||
from cic.contract.components.proof import Proof
|
from cic.contract.components.proof import Proof
|
||||||
from cic.contract.components.meta import Meta
|
from cic.contract.components.meta import Meta
|
||||||
from cic.contract.components.attachment import Attachment
|
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
|
from cic.contract.components.token import Token
|
||||||
|
|
||||||
|
|
||||||
def process_args(argparser):
|
def process_args(argparser):
|
||||||
argparser.add_argument('-f', '--file', type=str, help='add file')
|
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(
|
||||||
|
"-d",
|
||||||
|
"--directory",
|
||||||
|
type=str,
|
||||||
|
dest="directory",
|
||||||
|
default=".",
|
||||||
|
help="cic data directory",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def validate_args(args):
|
def validate_args(args):
|
||||||
@ -28,8 +35,12 @@ def execute(config, eargs):
|
|||||||
ca.load()
|
ca.load()
|
||||||
cn.load()
|
cn.load()
|
||||||
|
|
||||||
print("""[cic.header]
|
print(
|
||||||
version = {}\n""".format(cp.version()))
|
"""[cic.header]
|
||||||
|
version = {}\n""".format(
|
||||||
|
cp.version()
|
||||||
|
)
|
||||||
|
)
|
||||||
print("[cic.token]\n{}".format(ct))
|
print("[cic.token]\n{}".format(ct))
|
||||||
print("[cic.proof]\n{}".format(cp))
|
print("[cic.proof]\n{}".format(cp))
|
||||||
print("[cic.meta]\n{}".format(cm))
|
print("[cic.meta]\n{}".format(cm))
|
||||||
|
@ -16,7 +16,7 @@ from chainlib.chain import ChainSpec
|
|||||||
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.attachment import Attachment
|
||||||
from cic.contract.components.meta import Meta
|
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.components.token import Token
|
||||||
from cic.contract.contract import generate_contract, load_contract, deploy_contract
|
from cic.contract.contract import generate_contract, load_contract, deploy_contract
|
||||||
|
|
||||||
@ -61,7 +61,6 @@ def validate_args(_args):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_options(config: Config, eargs):
|
def get_options(config: Config, eargs):
|
||||||
# Defaults
|
# Defaults
|
||||||
default_contract_registry = config.get(
|
default_contract_registry = config.get(
|
||||||
|
@ -11,11 +11,12 @@ from cic_types.ext.metadata import MetadataRequestsHandler
|
|||||||
from cic_types.ext.metadata.signer import Signer as MetadataSigner
|
from cic_types.ext.metadata.signer import Signer as MetadataSigner
|
||||||
from chainlib.cli.config import Config
|
from chainlib.cli.config import Config
|
||||||
from chainlib.chain import ChainSpec
|
from chainlib.chain import ChainSpec
|
||||||
|
|
||||||
# Local Modules
|
# Local Modules
|
||||||
from cic.contract.processor import ContractProcessor
|
from cic.contract.processor import ContractProcessor
|
||||||
from cic.contract.components.attachment import Attachment
|
from cic.contract.components.attachment import Attachment
|
||||||
from cic.contract.components.meta import Meta
|
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.proof import Proof
|
||||||
from cic.contract.components.token import Token
|
from cic.contract.components.token import Token
|
||||||
from cic.contract.helpers import init_writers_from_config
|
from cic.contract.helpers import init_writers_from_config
|
||||||
@ -103,12 +104,14 @@ def generate_contract(
|
|||||||
network = Network(directory, targets=targets)
|
network = Network(directory, targets=targets)
|
||||||
network.start()
|
network.start()
|
||||||
|
|
||||||
log.debug(f"""Populating infomation from network:
|
log.debug(
|
||||||
|
f"""Populating infomation from network:
|
||||||
CIC_REGISTRY_ADDRESS: {config.get("CIC_REGISTRY_ADDRESS")}
|
CIC_REGISTRY_ADDRESS: {config.get("CIC_REGISTRY_ADDRESS")}
|
||||||
CHAIN_SPEC: {config.get("CHAIN_SPEC")}
|
CHAIN_SPEC: {config.get("CHAIN_SPEC")}
|
||||||
RPC_PROVIDER: {config.get("RPC_PROVIDER")}
|
RPC_PROVIDER: {config.get("RPC_PROVIDER")}
|
||||||
AUTH_KEY: {config.get("AUTH_KEY")}
|
AUTH_KEY: {config.get("AUTH_KEY")}
|
||||||
""")
|
"""
|
||||||
|
)
|
||||||
for target in targets:
|
for target in targets:
|
||||||
m = importlib.import_module(f"cic.ext.{target}.start")
|
m = importlib.import_module(f"cic.ext.{target}.start")
|
||||||
m.extension_start(
|
m.extension_start(
|
||||||
@ -116,7 +119,9 @@ def generate_contract(
|
|||||||
registry_address=config.get("CIC_REGISTRY_ADDRESS"),
|
registry_address=config.get("CIC_REGISTRY_ADDRESS"),
|
||||||
chain_spec=ChainSpec.from_chain_str(config.get("CHAIN_SPEC")),
|
chain_spec=ChainSpec.from_chain_str(config.get("CHAIN_SPEC")),
|
||||||
rpc_provider=config.get("RPC_PROVIDER"),
|
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()
|
network.load()
|
||||||
|
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
# standard imports
|
# standard imports
|
||||||
import os
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
|
||||||
# external imports
|
# external imports
|
||||||
from chainlib.chain import ChainSpec
|
from chainlib.chain import ChainSpec
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
from cic.contract.base import Data, data_dir
|
from cic.contract.base import Data, data_dir
|
||||||
|
|
Loading…
Reference in New Issue
Block a user