2022-03-01 08:01:56 +01:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
# standard import
|
|
|
|
import logging
|
|
|
|
|
2022-03-01 14:38:17 +01:00
|
|
|
from chainlib.cli.config import Config
|
2022-03-01 08:01:56 +01:00
|
|
|
|
|
|
|
# local imports
|
2022-03-01 14:38:17 +01:00
|
|
|
from cic.contract.contract import deploy_contract, generate_contract, load_contract
|
2022-03-01 08:01:56 +01:00
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
def process_args(argparser):
|
|
|
|
argparser.add_argument(
|
|
|
|
"--skip-gen", action="store_true", default=False, help="Skip Generation"
|
|
|
|
)
|
|
|
|
argparser.add_argument(
|
|
|
|
"--skip-deploy",
|
|
|
|
action="store_true",
|
|
|
|
help="Skip Deployment",
|
|
|
|
)
|
|
|
|
argparser.add_argument(
|
|
|
|
"--target",
|
|
|
|
default="eth",
|
|
|
|
help="Contract Target (eth)",
|
|
|
|
)
|
|
|
|
argparser.add_argument(
|
|
|
|
"path",
|
|
|
|
type=str,
|
|
|
|
help="Path to generate/use contract deployment info",
|
|
|
|
)
|
|
|
|
argparser.add_argument(
|
|
|
|
"-p",
|
|
|
|
type=str,
|
|
|
|
help="RPC Provider (http://localhost:8545)",
|
|
|
|
)
|
|
|
|
argparser.add_argument(
|
|
|
|
"-y",
|
|
|
|
type=str,
|
|
|
|
help="Wallet Keystore",
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def validate_args(_args):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
ExtraArgs = {"skip_gen": str, "skip_deploy": str, "target": str, "path": str, "p": str}
|
|
|
|
|
|
|
|
|
2022-03-01 14:38:17 +01:00
|
|
|
def execute(config: Config, eargs: ExtraArgs):
|
2022-03-01 08:01:56 +01:00
|
|
|
directory = eargs.path
|
|
|
|
target = eargs.target
|
|
|
|
skip_gen = eargs.skip_gen
|
|
|
|
skip_deploy = eargs.skip_deploy
|
2022-03-01 14:38:17 +01:00
|
|
|
wallet_keystore = eargs.y
|
2022-03-01 15:06:01 +01:00
|
|
|
if wallet_keystore:
|
|
|
|
config.add(wallet_keystore, "WALLET_KEY_FILE", exists_ok=True)
|
2022-03-01 08:01:56 +01:00
|
|
|
|
|
|
|
if not skip_gen:
|
2022-03-01 09:17:17 +01:00
|
|
|
contract = generate_contract(directory, [target], config, interactive=True)
|
2022-03-01 08:01:56 +01:00
|
|
|
else:
|
|
|
|
contract = load_contract(directory)
|
|
|
|
|
2022-03-01 09:17:17 +01:00
|
|
|
print(contract)
|
2022-03-01 08:01:56 +01:00
|
|
|
|
2022-03-07 10:25:45 +01:00
|
|
|
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")
|
|
|
|
|
2022-03-01 08:01:56 +01:00
|
|
|
if not skip_deploy:
|
2022-03-07 10:25:45 +01:00
|
|
|
ready_to_deploy = input("Are you ready to Deploy? (y/n): ")
|
2022-03-01 08:01:56 +01:00
|
|
|
if ready_to_deploy == "y":
|
2022-03-01 09:17:17 +01:00
|
|
|
deploy_contract(
|
2022-03-01 08:01:56 +01:00
|
|
|
config=config,
|
|
|
|
contract_directory=directory,
|
|
|
|
target=target,
|
|
|
|
)
|
|
|
|
print("Deployed")
|
|
|
|
else:
|
2022-03-07 10:25:45 +01:00
|
|
|
print("Skipping deployment")
|
2022-03-01 08:01:56 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
# execute()
|
|
|
|
print("Not Implemented")
|