mirror of https://github.com/nucypher/nucypher.git
Base CLI entry point for contract upgrading
parent
322137675a
commit
3538f2403d
|
@ -34,6 +34,7 @@ from nucypher.config.constants import DEFAULT_CONFIG_ROOT
|
||||||
@click.argument('action')
|
@click.argument('action')
|
||||||
@click.option('--force', is_flag=True)
|
@click.option('--force', is_flag=True)
|
||||||
@click.option('--poa', help="Inject POA middleware", is_flag=True)
|
@click.option('--poa', help="Inject POA middleware", is_flag=True)
|
||||||
|
@click.option('--upgrade', help="Upgrade an already deployed contract", is_flag=True)
|
||||||
@click.option('--no-compile', help="Disables solidity contract compilation", is_flag=True)
|
@click.option('--no-compile', help="Disables solidity contract compilation", is_flag=True)
|
||||||
@click.option('--provider-uri', help="Blockchain provider's URI", type=click.STRING)
|
@click.option('--provider-uri', help="Blockchain provider's URI", type=click.STRING)
|
||||||
@click.option('--config-root', help="Custom configuration directory", type=click.Path())
|
@click.option('--config-root', help="Custom configuration directory", type=click.Path())
|
||||||
|
@ -49,6 +50,7 @@ from nucypher.config.constants import DEFAULT_CONFIG_ROOT
|
||||||
def deploy(click_config,
|
def deploy(click_config,
|
||||||
action,
|
action,
|
||||||
poa,
|
poa,
|
||||||
|
upgrade,
|
||||||
provider_uri,
|
provider_uri,
|
||||||
deployer_address,
|
deployer_address,
|
||||||
contract_name,
|
contract_name,
|
||||||
|
@ -88,33 +90,24 @@ def deploy(click_config,
|
||||||
click.confirm("Deployer Address is {} - Continue?".format(deployer_address), abort=True)
|
click.confirm("Deployer Address is {} - Continue?".format(deployer_address), abort=True)
|
||||||
deployer = Deployer(blockchain=blockchain, deployer_address=deployer_address)
|
deployer = Deployer(blockchain=blockchain, deployer_address=deployer_address)
|
||||||
|
|
||||||
# The Big Three
|
|
||||||
if action == "contracts":
|
|
||||||
secrets = click_config.collect_deployment_secrets()
|
|
||||||
|
|
||||||
# Track tx hashes, and new agents
|
#
|
||||||
__deployment_transactions = dict()
|
# Upgrade
|
||||||
__deployment_agents = dict()
|
#
|
||||||
|
|
||||||
if force:
|
if upgrade:
|
||||||
deployer.blockchain.interface.registry._destroy()
|
if not contract_name:
|
||||||
|
raise click.BadArgumentUsage(message="--contract-name is required when using --upgrade")
|
||||||
|
existing_secret = click.prompt('Enter existing contract upgrade secret', hide_input=True, confirmation_prompt=True)
|
||||||
|
new_secret = click.prompt('Enter new contract upgrade secret', hide_input=True, confirmation_prompt=True)
|
||||||
|
deployer.upgrade_contract(contract_name=contract_name, existing_secret=existing_secret, new_plaintext_secret=new_secret)
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
|
||||||
txhashes, agents = deployer.deploy_network_contracts(miner_secret=bytes(secrets.miner_secret, encoding='utf-8'),
|
|
||||||
policy_secret=bytes(secrets.policy_secret, encoding='utf-8'),
|
|
||||||
adjudicator_secret=bytes(secrets.mining_adjudicator_secret, encoding='utf-8'))
|
|
||||||
except BlockchainInterface.InterfaceError:
|
|
||||||
raise # TODO: Handle registry management here (contract may already exist)
|
|
||||||
else:
|
|
||||||
__deployment_transactions.update(txhashes)
|
|
||||||
|
|
||||||
# User Escrow Proxy
|
|
||||||
deployer.deploy_escrow_proxy(secret=bytes(secrets.escrow_proxy_secret, encoding='utf-8'))
|
|
||||||
click.secho("Deployed!", fg='green', bold=True)
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Deploy Single Contract
|
# Deploy Single Contract
|
||||||
#
|
#
|
||||||
|
|
||||||
if contract_name:
|
if contract_name:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -126,11 +119,37 @@ def deploy(click_config,
|
||||||
else:
|
else:
|
||||||
_txs, _agent = deployer_func()
|
_txs, _agent = deployer_func()
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
# The Big Three
|
||||||
|
if action == "contracts":
|
||||||
|
|
||||||
|
secrets = click_config.collect_deployment_secrets()
|
||||||
|
|
||||||
|
# Track tx hashes, and new agents
|
||||||
|
__deployment_transactions = dict()
|
||||||
|
__deployment_agents = dict()
|
||||||
|
|
||||||
|
if force:
|
||||||
|
deployer.blockchain.interface.registry._destroy()
|
||||||
|
|
||||||
|
try:
|
||||||
|
txhashes, deployers = deployer.deploy_network_contracts(miner_secret=secrets.miner_secret,
|
||||||
|
policy_secret=secrets.policy_secret,
|
||||||
|
adjudicator_secret=secrets.mining_adjudicator_secret,
|
||||||
|
user_escrow_proxy_secret=secrets.escrow_proxy_secret)
|
||||||
|
except BlockchainInterface.InterfaceError:
|
||||||
|
raise # TODO: Handle registry management here (contract may already exist)
|
||||||
|
else:
|
||||||
|
__deployment_transactions.update(txhashes)
|
||||||
|
|
||||||
|
click.secho("Deployed!", fg='green', bold=True)
|
||||||
|
|
||||||
registry_outfile = deployer.blockchain.interface.registry.filepath
|
registry_outfile = deployer.blockchain.interface.registry.filepath
|
||||||
click.secho('\nDeployment Transaction Hashes for {}'.format(registry_outfile), bold=True, fg='blue')
|
click.secho('\nDeployment Transaction Hashes for {}'.format(registry_outfile), bold=True, fg='blue')
|
||||||
for contract_name, transactions in __deployment_transactions.items():
|
for contract_name, transactions in __deployment_transactions.items():
|
||||||
|
|
||||||
heading = '\n{} ({})'.format(contract_name, agents[contract_name].contract_address)
|
heading = '\n{} ({})'.format(contract_name, deployers[contract_name].contract_address)
|
||||||
click.secho(heading, bold=True)
|
click.secho(heading, bold=True)
|
||||||
click.echo('*'*(42+3+len(contract_name)))
|
click.echo('*'*(42+3+len(contract_name)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue