|
|
|
@ -1,27 +1,12 @@
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
# standard import
|
|
|
|
|
import importlib
|
|
|
|
|
import json
|
|
|
|
|
import logging
|
|
|
|
|
import os
|
|
|
|
|
from typing import TYPE_CHECKING, List
|
|
|
|
|
|
|
|
|
|
import requests
|
|
|
|
|
|
|
|
|
|
# external imports
|
|
|
|
|
from chainlib.chain import ChainSpec
|
|
|
|
|
from chainlib.cli.config import Config
|
|
|
|
|
|
|
|
|
|
# local imports
|
|
|
|
|
from cic.contract.components.proof import Proof
|
|
|
|
|
from cic.contract.components.attachment import Attachment
|
|
|
|
|
from cic.contract.components.meta import Meta
|
|
|
|
|
from cic.contract.network import Network
|
|
|
|
|
from cic.contract.components.token import Token
|
|
|
|
|
from cic.contract.contract import generate_contract, load_contract, deploy_contract
|
|
|
|
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
|
from chainlib.cli.config import Config
|
|
|
|
|
from cic.contract.contract import deploy_contract, generate_contract, load_contract
|
|
|
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
@ -61,72 +46,17 @@ def validate_args(_args):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_options(config: Config, eargs):
|
|
|
|
|
# Defaults
|
|
|
|
|
default_contract_registry = config.get(
|
|
|
|
|
"CIC_REGISTRY_ADDRESS"
|
|
|
|
|
) # Comes from /home/will/grassroots/cic-staff-installer/var/cic-staff-client/CIC_REGISTRY_ADDRESS
|
|
|
|
|
default_key_account = config.get("AUTH_KEY")
|
|
|
|
|
# https://meta.grassrootseconomics.net
|
|
|
|
|
# https://auth.grassrootseconomics.net Authenticated Meta
|
|
|
|
|
|
|
|
|
|
default_metadata_endpoint = config.get("META_URL")
|
|
|
|
|
# Keyring folder needs to be dumped out as a private key file from $HOME/.config/cic/staff-client/.gnupg
|
|
|
|
|
default_wallet_keyfile = eargs.y or config.get(
|
|
|
|
|
"WALLET_KEY_FILE"
|
|
|
|
|
) # Show possible wallet keys
|
|
|
|
|
|
|
|
|
|
# Should be an input???
|
|
|
|
|
default_wallet_passphrase = config.get("WALLET_PASSPHRASE", "merman")
|
|
|
|
|
default_chain_spec = config.get("CHAIN_SPEC")
|
|
|
|
|
default_rpc_provider = config.get("RPC_PROVIDER")
|
|
|
|
|
|
|
|
|
|
contract_registry = (
|
|
|
|
|
input(f"Enter Contract Registry ({default_contract_registry}): ")
|
|
|
|
|
or default_contract_registry
|
|
|
|
|
)
|
|
|
|
|
rpc_provider = (
|
|
|
|
|
input(f"Enter RPC Provider ({default_rpc_provider}): ") or default_rpc_provider
|
|
|
|
|
)
|
|
|
|
|
chain_spec = ChainSpec.from_chain_str(
|
|
|
|
|
(input(f"Enter ChainSpec ({default_chain_spec}): ") or default_chain_spec)
|
|
|
|
|
)
|
|
|
|
|
key_account = (
|
|
|
|
|
input(f"Enter KeyAccount ({default_key_account}): ") or default_key_account
|
|
|
|
|
)
|
|
|
|
|
metadata_endpoint = (
|
|
|
|
|
input(f"Enter Metadata Endpoint ({default_metadata_endpoint}): ")
|
|
|
|
|
or default_metadata_endpoint
|
|
|
|
|
)
|
|
|
|
|
auth_passphrase = config.get("AUTH_PASSPHRASE")
|
|
|
|
|
auth_keyfile_path = config.get("AUTH_KEYFILE_PATH")
|
|
|
|
|
auth_db_path = config.get("AUTH_DB_PATH")
|
|
|
|
|
|
|
|
|
|
options = [
|
|
|
|
|
auth_db_path,
|
|
|
|
|
auth_keyfile_path,
|
|
|
|
|
auth_passphrase,
|
|
|
|
|
contract_registry,
|
|
|
|
|
key_account,
|
|
|
|
|
chain_spec,
|
|
|
|
|
rpc_provider,
|
|
|
|
|
metadata_endpoint,
|
|
|
|
|
default_wallet_keyfile,
|
|
|
|
|
default_wallet_passphrase,
|
|
|
|
|
]
|
|
|
|
|
print(options)
|
|
|
|
|
return options
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ExtraArgs = {"skip_gen": str, "skip_deploy": str, "target": str, "path": str, "p": str}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def execute(config, eargs: ExtraArgs):
|
|
|
|
|
def execute(config: Config, eargs: ExtraArgs):
|
|
|
|
|
print(f"eargs: {eargs}")
|
|
|
|
|
directory = eargs.path
|
|
|
|
|
target = eargs.target
|
|
|
|
|
skip_gen = eargs.skip_gen
|
|
|
|
|
skip_deploy = eargs.skip_deploy
|
|
|
|
|
wallet_keystore = eargs.y
|
|
|
|
|
config.add(wallet_keystore, "WALLET_KEY_FILE", exists_ok=True)
|
|
|
|
|
|
|
|
|
|
if not skip_gen:
|
|
|
|
|
contract = generate_contract(directory, [target], config, interactive=True)
|
|
|
|
|