diff --git a/nucypher/blockchain/eth/actors.py b/nucypher/blockchain/eth/actors.py index 343cad251..68ddaefdc 100644 --- a/nucypher/blockchain/eth/actors.py +++ b/nucypher/blockchain/eth/actors.py @@ -218,7 +218,7 @@ class DeployerActor(NucypherTokenActor): return Deployer @staticmethod - def __collect_deployment_secret(deployer) -> str: + def collect_deployment_secret(deployer) -> str: secret = click.prompt(f'Enter {deployer.contract_name} Deployment Secret', hide_input=True, confirmation_prompt=True) @@ -227,7 +227,7 @@ class DeployerActor(NucypherTokenActor): def collect_deployment_secrets(self) -> dict: secrets = dict() for deployer in self.upgradeable_deployer_classes: - secrets[deployer.contract_name] = self.__collect_deployment_secret(deployer) + secrets[deployer.contract_name] = self.collect_deployment_secret(deployer) return secrets def deploy_contract(self, diff --git a/nucypher/blockchain/eth/interfaces.py b/nucypher/blockchain/eth/interfaces.py index 26abb8073..202ab96e1 100644 --- a/nucypher/blockchain/eth/interfaces.py +++ b/nucypher/blockchain/eth/interfaces.py @@ -455,6 +455,7 @@ class BlockchainInterface: class BlockchainDeployerInterface(BlockchainInterface): + TIMEOUT = 600 # seconds _contract_factory = Contract class NoDeployerAddress(RuntimeError): diff --git a/nucypher/cli/deploy.py b/nucypher/cli/deploy.py index 84fe509ce..4423d3d1b 100644 --- a/nucypher/cli/deploy.py +++ b/nucypher/cli/deploy.py @@ -171,6 +171,31 @@ def deploy(action, elif action == "contracts": + # + # Deploy Single Contract + # + + if contract_name: + try: + contract_deployer = deployer.deployers[contract_name] + except KeyError: + message = f"No such contract {contract_name}. Available contracts are {deployer.deployers.keys()}" + click.secho(message, fg='red', bold=True) + raise click.Abort() + else: + click.secho(f"Deploying {contract_name}") + if contract_deployer._upgradeable: + secret = deployer.collect_deployment_secret(deployer=contract_deployer) + receipts, agent = deployer.deploy_contract(contract_name=contract_name, plaintext_secret=secret) + else: + receipts, agent = deployer.deploy_contract(contract_name=contract_name) + paint_contract_deployment(contract_name=contract_name, + contract_address=agent.contract_address, + receipts=receipts) + if ETH_NODE: + ETH_NODE.stop() + return + registry_filepath = deployer.blockchain.registry.filepath if os.path.isfile(registry_filepath): click.secho(f"\nThere is an existing contract registry at {registry_filepath}.\n" @@ -179,30 +204,6 @@ def deploy(action, click.confirm(f"Confirm deletion of contract registry '{registry_filepath}'?", abort=True) os.remove(registry_filepath) - # - # Deploy Single Contract - # - - if contract_name: - deployment_secret = click.prompt(f"Enter deployment secret for {contract_name}", confirmation_prompt=True) - - try: - deployer.deployers[contract_name] - except KeyError: - message = f"No such contract {contract_name}. Available contracts are {deployer.deployers.keys()}" - click.secho(message, fg='red', bold=True) - raise click.Abort() - else: - # Deploy single contract - receipts, agent = deployer.deploy_contract(contract_name=contract_name, - plaintext_secret=deployment_secret) - paint_contract_deployment(contract_name=contract_name, - contract_address=agent.contract_address, - receipts=receipts) - if ETH_NODE: - ETH_NODE.stop() - return - # # Stage Deployment #