chore: clean up
This commit is contained in:
parent
1a769205ea
commit
0dc25002f6
@ -50,7 +50,6 @@ ExtraArgs = {"skip_gen": str, "skip_deploy": str, "target": str, "path": str, "p
|
|||||||
|
|
||||||
|
|
||||||
def execute(config: Config, eargs: ExtraArgs):
|
def execute(config: Config, eargs: ExtraArgs):
|
||||||
print(f"eargs: {eargs}")
|
|
||||||
directory = eargs.path
|
directory = eargs.path
|
||||||
target = eargs.target
|
target = eargs.target
|
||||||
skip_gen = eargs.skip_gen
|
skip_gen = eargs.skip_gen
|
||||||
@ -66,8 +65,12 @@ def execute(config: Config, eargs: ExtraArgs):
|
|||||||
|
|
||||||
print(contract)
|
print(contract)
|
||||||
|
|
||||||
|
print(f"Meta: {config.get('META_URL')}")
|
||||||
|
print(f"ChainSpec: {config.get('CHAIN_SPEC', contract.network.chain_spec(target))}")
|
||||||
|
print(f"RPC: {config.get('RPC_PROVIDER')}\n")
|
||||||
|
|
||||||
if not skip_deploy:
|
if not skip_deploy:
|
||||||
ready_to_deploy = input("Ready to deploy? (y/n): ")
|
ready_to_deploy = input("Are you ready to Deploy? (y/n): ")
|
||||||
if ready_to_deploy == "y":
|
if ready_to_deploy == "y":
|
||||||
deploy_contract(
|
deploy_contract(
|
||||||
config=config,
|
config=config,
|
||||||
@ -76,7 +79,7 @@ def execute(config: Config, eargs: ExtraArgs):
|
|||||||
)
|
)
|
||||||
print("Deployed")
|
print("Deployed")
|
||||||
else:
|
else:
|
||||||
print("Not deploying")
|
print("Skipping deployment")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -3,25 +3,25 @@ import importlib
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from typing import List, TYPE_CHECKING
|
from typing import TYPE_CHECKING, List
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
from chainlib.chain import ChainSpec
|
||||||
|
from chainlib.cli.config import Config
|
||||||
|
from cic.contract.components.attachment import Attachment
|
||||||
|
from cic.contract.components.meta import Meta
|
||||||
|
from cic.contract.components.proof import Proof
|
||||||
|
from cic.contract.components.token import Token
|
||||||
|
from cic.contract.helpers import init_writers_from_config
|
||||||
|
from cic.contract.network import Network
|
||||||
|
|
||||||
|
# Local Modules
|
||||||
|
from cic.contract.processor import ContractProcessor
|
||||||
|
from cic.writers import HTTPWriter, KeyedWriterFactory, MetadataWriter, OutputWriter
|
||||||
|
|
||||||
# external imports
|
# external imports
|
||||||
from cic_types.ext.metadata import MetadataRequestsHandler
|
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.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.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
|
|
||||||
from cic.writers import HTTPWriter, KeyedWriterFactory, OutputWriter, MetadataWriter
|
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -45,12 +45,12 @@ class Contract:
|
|||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
s = ""
|
s = ""
|
||||||
s += f"[cic.header]\nversion = {self.proof.version()}\n"
|
s += f"\n[cic.header]\nversion = {self.proof.version()}\n\n"
|
||||||
s += f"[cic.token]\n{self.token}"
|
s += f"[cic.token]\n{self.token}\n"
|
||||||
s += f"[cic.proof]\n{self.proof}"
|
s += f"[cic.proof]\n{self.proof}\n"
|
||||||
s += f"[cic.meta]\n{self.meta}"
|
s += f"[cic.meta]\n{self.meta}\n"
|
||||||
s += f"[cic.attachment]\n{self.attachment}"
|
s += f"[cic.attachment]\n{self.attachment}\n"
|
||||||
s += f"[cic.network]\n{self.network}"
|
s += f"[cic.network]\n{self.network}\n"
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
||||||
@ -76,10 +76,10 @@ def generate_contract(
|
|||||||
) -> Contract:
|
) -> Contract:
|
||||||
if os.path.exists(directory):
|
if os.path.exists(directory):
|
||||||
contine = input(
|
contine = input(
|
||||||
"Directory already exists, Would you like to delete it? (y/n): "
|
f"Directory {directory} already exists, Would you like to delete it? (y/n): "
|
||||||
)
|
)
|
||||||
if contine.lower() != "y":
|
if contine.lower() != "y":
|
||||||
print("Trying to load existing contract")
|
log.debug("Trying to load existing contract")
|
||||||
return load_contract(directory)
|
return load_contract(directory)
|
||||||
else:
|
else:
|
||||||
print(f"Deleted {directory}")
|
print(f"Deleted {directory}")
|
||||||
@ -117,6 +117,8 @@ def generate_contract(
|
|||||||
cmd_mod = importlib.import_module(modname)
|
cmd_mod = importlib.import_module(modname)
|
||||||
signer_hint = config.get("WALLET_KEY_FILE")
|
signer_hint = config.get("WALLET_KEY_FILE")
|
||||||
keys = cmd_mod.list_keys(config, signer_hint)
|
keys = cmd_mod.list_keys(config, signer_hint)
|
||||||
|
if len(keys) > 1:
|
||||||
|
print(f"More than one key found, please select one:")
|
||||||
for idx, key in enumerate(keys):
|
for idx, key in enumerate(keys):
|
||||||
print(f"{idx} - {key} ")
|
print(f"{idx} - {key} ")
|
||||||
selecting_key = True
|
selecting_key = True
|
||||||
@ -127,6 +129,8 @@ def generate_contract(
|
|||||||
selecting_key = False
|
selecting_key = False
|
||||||
else:
|
else:
|
||||||
print("Invalid key, try again")
|
print("Invalid key, try again")
|
||||||
|
else:
|
||||||
|
key_account_address = keys[0]
|
||||||
|
|
||||||
m = importlib.import_module(f"cic.ext.{target}.start")
|
m = importlib.import_module(f"cic.ext.{target}.start")
|
||||||
m.extension_start(
|
m.extension_start(
|
||||||
@ -134,7 +138,7 @@ 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=key_account_address
|
key_account_address=key_account_address,
|
||||||
)
|
)
|
||||||
network.load()
|
network.load()
|
||||||
|
|
||||||
@ -197,7 +201,6 @@ def deploy_contract(
|
|||||||
chain_spec = cn.chain_spec
|
chain_spec = cn.chain_spec
|
||||||
config.add(chain_spec, "CHAIN_SPEC", exists_ok=True)
|
config.add(chain_spec, "CHAIN_SPEC", exists_ok=True)
|
||||||
log.debug(f"using CHAIN_SPEC: {str(chain_spec)} from network")
|
log.debug(f"using CHAIN_SPEC: {str(chain_spec)} from network")
|
||||||
print(chain_spec)
|
|
||||||
|
|
||||||
signer_hint = config.get("WALLET_KEY_FILE")
|
signer_hint = config.get("WALLET_KEY_FILE")
|
||||||
(rpc, signer) = cmd_mod.parse_adapter(config, signer_hint)
|
(rpc, signer) = cmd_mod.parse_adapter(config, signer_hint)
|
||||||
|
@ -132,10 +132,12 @@ class Network(Data):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
s = ''
|
s = ''
|
||||||
for resource in self.resources.keys():
|
for resource in self.resources.keys():
|
||||||
|
chainspec = ChainSpec.from_dict(self.resources[resource]['chain_spec'])
|
||||||
|
s += f'{resource}.chain_spec: {str(chainspec)}\n'
|
||||||
for content_key in self.resources[resource]['contents'].keys():
|
for content_key in self.resources[resource]['contents'].keys():
|
||||||
content_value = self.resources[resource]['contents'][content_key]
|
content_value = self.resources[resource]['contents'][content_key]
|
||||||
if content_value is None:
|
if content_value is None:
|
||||||
content_value = ''
|
content_value = ''
|
||||||
s += f'{resource}.{content_key} = {content_value}\n'
|
s += f'{resource}.contents.{content_key} = {json.dumps(content_value, indent=4, sort_keys=True)}\n'
|
||||||
|
|
||||||
return s
|
return s
|
||||||
|
Loading…
Reference in New Issue
Block a user