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.option('--force', 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('--provider-uri', help="Blockchain provider's URI", type=click.STRING)
|
||||
@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,
|
||||
action,
|
||||
poa,
|
||||
upgrade,
|
||||
provider_uri,
|
||||
deployer_address,
|
||||
contract_name,
|
||||
|
@ -88,8 +90,40 @@ def deploy(click_config,
|
|||
click.confirm("Deployer Address is {} - Continue?".format(deployer_address), abort=True)
|
||||
deployer = Deployer(blockchain=blockchain, deployer_address=deployer_address)
|
||||
|
||||
|
||||
#
|
||||
# Upgrade
|
||||
#
|
||||
|
||||
if upgrade:
|
||||
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
|
||||
|
||||
|
||||
#
|
||||
# Deploy Single Contract
|
||||
#
|
||||
|
||||
if contract_name:
|
||||
|
||||
try:
|
||||
deployer_func = deployer.deployers[contract_name]
|
||||
except KeyError:
|
||||
message = "No such contract {}. Available contracts are {}".format(contract_name, deployer.deployers.keys())
|
||||
click.secho(message, fg='red', bold=True)
|
||||
raise click.Abort()
|
||||
else:
|
||||
_txs, _agent = deployer_func()
|
||||
|
||||
return
|
||||
|
||||
# The Big Three
|
||||
if action == "contracts":
|
||||
|
||||
secrets = click_config.collect_deployment_secrets()
|
||||
|
||||
# Track tx hashes, and new agents
|
||||
|
@ -100,37 +134,22 @@ def deploy(click_config,
|
|||
deployer.blockchain.interface.registry._destroy()
|
||||
|
||||
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'))
|
||||
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)
|
||||
|
||||
# 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
|
||||
#
|
||||
if contract_name:
|
||||
|
||||
try:
|
||||
deployer_func = deployer.deployers[contract_name]
|
||||
except KeyError:
|
||||
message = "No such contract {}. Available contracts are {}".format(contract_name, deployer.deployers.keys())
|
||||
click.secho(message, fg='red', bold=True)
|
||||
raise click.Abort()
|
||||
else:
|
||||
_txs, _agent = deployer_func()
|
||||
|
||||
registry_outfile = deployer.blockchain.interface.registry.filepath
|
||||
click.secho('\nDeployment Transaction Hashes for {}'.format(registry_outfile), bold=True, fg='blue')
|
||||
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.echo('*'*(42+3+len(contract_name)))
|
||||
|
||||
|
|
Loading…
Reference in New Issue