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):
|
||||
print(f"eargs: {eargs}")
|
||||
directory = eargs.path
|
||||
target = eargs.target
|
||||
skip_gen = eargs.skip_gen
|
||||
@ -66,8 +65,12 @@ def execute(config: Config, eargs: ExtraArgs):
|
||||
|
||||
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:
|
||||
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":
|
||||
deploy_contract(
|
||||
config=config,
|
||||
@ -76,7 +79,7 @@ def execute(config: Config, eargs: ExtraArgs):
|
||||
)
|
||||
print("Deployed")
|
||||
else:
|
||||
print("Not deploying")
|
||||
print("Skipping deployment")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -3,25 +3,25 @@ import importlib
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
from typing import List, TYPE_CHECKING
|
||||
from typing import TYPE_CHECKING, List
|
||||
|
||||
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
|
||||
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.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__)
|
||||
|
||||
@ -45,12 +45,12 @@ class Contract:
|
||||
|
||||
def __str__(self):
|
||||
s = ""
|
||||
s += f"[cic.header]\nversion = {self.proof.version()}\n"
|
||||
s += f"[cic.token]\n{self.token}"
|
||||
s += f"[cic.proof]\n{self.proof}"
|
||||
s += f"[cic.meta]\n{self.meta}"
|
||||
s += f"[cic.attachment]\n{self.attachment}"
|
||||
s += f"[cic.network]\n{self.network}"
|
||||
s += f"\n[cic.header]\nversion = {self.proof.version()}\n\n"
|
||||
s += f"[cic.token]\n{self.token}\n"
|
||||
s += f"[cic.proof]\n{self.proof}\n"
|
||||
s += f"[cic.meta]\n{self.meta}\n"
|
||||
s += f"[cic.attachment]\n{self.attachment}\n"
|
||||
s += f"[cic.network]\n{self.network}\n"
|
||||
return s
|
||||
|
||||
|
||||
@ -76,10 +76,10 @@ def generate_contract(
|
||||
) -> Contract:
|
||||
if os.path.exists(directory):
|
||||
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":
|
||||
print("Trying to load existing contract")
|
||||
log.debug("Trying to load existing contract")
|
||||
return load_contract(directory)
|
||||
else:
|
||||
print(f"Deleted {directory}")
|
||||
@ -117,16 +117,20 @@ def generate_contract(
|
||||
cmd_mod = importlib.import_module(modname)
|
||||
signer_hint = config.get("WALLET_KEY_FILE")
|
||||
keys = cmd_mod.list_keys(config, signer_hint)
|
||||
for idx, key in enumerate(keys):
|
||||
print(f"{idx} - {key} ")
|
||||
selecting_key = True
|
||||
while selecting_key:
|
||||
idx = int(input("Select key: "))
|
||||
if keys[idx] is not None:
|
||||
key_account_address = keys[idx]
|
||||
selecting_key = False
|
||||
else:
|
||||
print("Invalid key, try again")
|
||||
if len(keys) > 1:
|
||||
print(f"More than one key found, please select one:")
|
||||
for idx, key in enumerate(keys):
|
||||
print(f"{idx} - {key} ")
|
||||
selecting_key = True
|
||||
while selecting_key:
|
||||
idx = int(input("Select key: "))
|
||||
if keys[idx] is not None:
|
||||
key_account_address = keys[idx]
|
||||
selecting_key = False
|
||||
else:
|
||||
print("Invalid key, try again")
|
||||
else:
|
||||
key_account_address = keys[0]
|
||||
|
||||
m = importlib.import_module(f"cic.ext.{target}.start")
|
||||
m.extension_start(
|
||||
@ -134,7 +138,7 @@ 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=key_account_address
|
||||
key_account_address=key_account_address,
|
||||
)
|
||||
network.load()
|
||||
|
||||
@ -197,7 +201,6 @@ def deploy_contract(
|
||||
chain_spec = cn.chain_spec
|
||||
config.add(chain_spec, "CHAIN_SPEC", exists_ok=True)
|
||||
log.debug(f"using CHAIN_SPEC: {str(chain_spec)} from network")
|
||||
print(chain_spec)
|
||||
|
||||
signer_hint = config.get("WALLET_KEY_FILE")
|
||||
(rpc, signer) = cmd_mod.parse_adapter(config, signer_hint)
|
||||
|
@ -132,10 +132,12 @@ class Network(Data):
|
||||
def __str__(self):
|
||||
s = ''
|
||||
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():
|
||||
content_value = self.resources[resource]['contents'][content_key]
|
||||
if content_value is None:
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user