Touches to nucypher-deploy

pull/1327/head
David Núñez 2019-09-13 21:57:30 +02:00
parent 137db286ee
commit aed5d14bee
4 changed files with 23 additions and 17 deletions

View File

@ -396,6 +396,11 @@ class ContractAdministrator(NucypherTokenActor):
if interactive:
click.confirm("Continue with the allocation process?", abort=True)
total_to_allocate = NU.from_nunits(sum(allocation['amount'] for allocation in allocations))
balance = ContractAgency.get_agent(NucypherTokenAgent, self.registry).get_balance(self.deployer_address)
if balance < total_to_allocate:
raise ValueError(f"Not enough tokens to allocate. We need at least {total_to_allocate}.")
allocation_receipts, failed, allocated = dict(), list(), list()
total_deployment_transactions = len(allocations) * 4

View File

@ -52,10 +52,10 @@ from nucypher.config.constants import DEFAULT_CONFIG_ROOT
@click.option('--deployer-address', help="Deployer's checksum address", type=EIP55_CHECKSUM_ADDRESS)
@click.option('--retarget', '-d', help="Retarget a contract's proxy.", is_flag=True)
@click.option('--target-address', help="Recipient's checksum address for token or ownership transference.", type=EIP55_CHECKSUM_ADDRESS)
@click.option('--registry-infile', help="Input path for contract registry file", type=EXISTING_READABLE_FILE)
@click.option('--value', help="Amount of tokens to transfer in the smallest denomination", type=click.INT)
@click.option('--dev', '-d', help="Forcibly use the development registry filepath.", is_flag=True)
@click.option('--bare', help="Deploy a contract *only* without any additional operations.", is_flag=True)
@click.option('--registry-infile', help="Input path for contract registry file", type=EXISTING_READABLE_FILE)
@click.option('--registry-outfile', help="Output path for contract registry file", type=click.Path(file_okay=True))
@click.option('--allocation-infile', help="Input path for token allocation JSON file", type=EXISTING_READABLE_FILE)
@click.option('--allocation-outfile', help="Output path for token allocation JSON file", type=click.Path(exists=False, file_okay=True))
@ -84,12 +84,12 @@ def deploy(action,
\b
Actions
-----------------------------------------------------------------------------
contracts Compile and deploy contracts.
allocations Deploy pre-allocation contracts.
upgrade Upgrade NuCypher existing proxy contract deployments.
rollback Rollback a proxy contract's target.
inspect Echo owner information and bare contract metadata.
transfer-tokens Transfer tokens from a contract to another address using the owner's address.
contracts Compile and deploy contracts.
upgrade Upgrade existing proxy contract deployments.
rollback Rollback a proxy contract's target.
allocations Deploy pre-allocation contracts.
transfer-tokens Transfer tokens from contract's owner address to another address
transfer-ownership Transfer ownership of contracts to another address.
"""
@ -143,14 +143,7 @@ def deploy(action,
else:
deployer_interface = BlockchainInterfaceFactory.get_interface(provider_uri=provider_uri)
if action == "inspect":
if registry_infile:
registry = LocalContractRegistry(filepath=registry_infile)
else:
registry = InMemoryContractRegistry.from_latest_publication()
administrator = ContractAdministrator(registry=registry, deployer_address=deployer_address)
paint_deployer_contract_inspection(emitter=emitter, administrator=administrator)
return # Exit
deployer_interface.connect()
#
# Establish Registry
@ -161,6 +154,15 @@ def deploy(action,
registry_outfile=registry_outfile,
dev=dev)
#
# Actions that don't require authentication
#
if action == "inspect":
administrator = ContractAdministrator(registry=local_registry, deployer_address=deployer_address)
paint_deployer_contract_inspection(emitter=emitter, administrator=administrator)
return # Exit
#
# Make Authenticated Deployment Actor
#

View File

@ -247,7 +247,7 @@ Registry ................ {administrator.registry.filepath}
* Standard Deployments
=====================================================================
NucypherToken ........... {token_agent.contract_address}
{token_agent.contract_name} ........... {token_agent.contract_address}
~ Ethers ............ {Web3.fromWei(blockchain.client.get_balance(token_agent.contract_address), 'ether')} ETH
~ Tokens ............ {NU.from_nunits(token_agent.get_balance(token_agent.contract_address))}"""
emitter.echo(contract_payload)
@ -307,7 +307,7 @@ NucypherToken ........... {token_agent.contract_address}
bare=True) # acquire agency for the dispatcher itself.
user_escrow_payload = f"""
UserEscrowProxy .......... {bare_contract.address}
{user_escrow_proxy_agent.contract_name} .......... {bare_contract.address}
~ LibraryLinker ...... {linker_deployer.contract.address}
~ Owner .......... {linker_deployer.contract.functions.owner().call()}
~ Target ......... {linker_deployer.contract.functions.target().call()}"""

View File

@ -112,7 +112,6 @@ def test_nucypher_deploy_contracts(click_runner,
assert PolicyManagerAgent(registry=registry)
# This agent wasn't instantiated before, so we have to supply the blockchain
blockchain = staking_agent.blockchain
assert AdjudicatorAgent(registry=registry)