From f9336f267aa0a26693ae124a41fc85e06d43eb9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=BA=C3=B1ez?= Date: Sun, 28 Jul 2019 00:53:23 +0200 Subject: [PATCH] Slightly more informative and comfortable deployment of contracts --- nucypher/blockchain/eth/actors.py | 16 +++++++++++----- nucypher/cli/deploy.py | 6 +++++- nucypher/cli/painting.py | 1 - 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/nucypher/blockchain/eth/actors.py b/nucypher/blockchain/eth/actors.py index 4dcb22ed2..1d0748ff1 100644 --- a/nucypher/blockchain/eth/actors.py +++ b/nucypher/blockchain/eth/actors.py @@ -269,7 +269,8 @@ class DeployerActor(NucypherTokenActor): return user_escrow_deployer def deploy_network_contracts(self, - secrets: dict, interactive: bool = True, + secrets: dict, + interactive: bool = True, emitter: StdoutEmitter = None) -> dict: """ @@ -286,6 +287,9 @@ class DeployerActor(NucypherTokenActor): gas_limit = None # TODO: Gas management # NuCypherToken + if emitter: + emitter.echo(f"\nDeploying {NUCYPHER_TOKEN_CONTRACT_NAME} ...") + token_receipts, token_deployer = self.deploy_contract(contract_name=NUCYPHER_TOKEN_CONTRACT_NAME, gas_limit=gas_limit) @@ -296,10 +300,14 @@ class DeployerActor(NucypherTokenActor): emitter=emitter) deployment_receipts[NUCYPHER_TOKEN_CONTRACT_NAME] = token_receipts - if interactive: - click.pause(info="Press any key to continue") for contract_deployer in self.upgradeable_deployer_classes: + if interactive: + click.pause(info="Press any key to continue") + + if emitter: + emitter.echo(f"\nDeploying {contract_deployer.contract_name} ...") + receipts, deployer = self.deploy_contract(contract_name=contract_deployer.contract_name, plaintext_secret=secrets[contract_deployer.contract_name], gas_limit=gas_limit) @@ -310,8 +318,6 @@ class DeployerActor(NucypherTokenActor): contract_address=deployer.contract_address, emitter=emitter) deployment_receipts[contract_deployer.contract_name] = receipts - if interactive: - click.pause(info="Press any key to continue") return deployment_receipts diff --git a/nucypher/cli/deploy.py b/nucypher/cli/deploy.py index 01f6f6d5c..8431a4964 100644 --- a/nucypher/cli/deploy.py +++ b/nucypher/cli/deploy.py @@ -132,7 +132,9 @@ def deploy(action, # Verify Address & collect password if not deployer_address: - deployer_address = select_client_account(emitter=emitter, blockchain=blockchain) + prompt = "Select deployer account" + deployer_address = select_client_account(emitter=emitter, blockchain=blockchain, prompt=prompt) + if not force: click.confirm("Selected {} - Continue?".format(deployer_address), abort=True) @@ -166,6 +168,8 @@ def deploy(action, return # Exit elif action == 'rollback': + if not contract_name: + raise click.BadArgumentUsage(message="--contract-name is required when using --rollback") existing_secret = click.prompt('Enter existing contract upgrade secret', hide_input=True) new_secret = click.prompt('Enter new contract upgrade secret', hide_input=True, confirmation_prompt=True) DEPLOYER.rollback_contract(contract_name=contract_name, diff --git a/nucypher/cli/painting.py b/nucypher/cli/painting.py index e4ea523e6..cd7bfaafb 100644 --- a/nucypher/cli/painting.py +++ b/nucypher/cli/painting.py @@ -337,4 +337,3 @@ def paint_deployment_delay(emitter, delay: int = 3) -> None: for i in range(delay)[::-1]: emitter.echo(f"{i}...", color='yellow') time.sleep(1) - emitter.echo(f"Deploying...", bold=True)