Ejemplo n.º 1
0
def paint_deployer_contract_inspection(emitter, registry,
                                       deployer_address) -> None:

    blockchain = BlockchainInterfaceFactory.get_interface()

    sep = '-' * 45
    emitter.echo(sep)

    provider_info = f"""

* Web3 Provider
====================================================================

Provider URI ............. {blockchain.provider_uri}
Registry  ................ {registry.filepath}

* Standard Deployments
=====================================================================
"""
    emitter.echo(provider_info)

    try:
        token_agent = ContractAgency.get_agent(NucypherTokenAgent,
                                               registry=registry)
        token_contract_info = f"""

{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))}"""
    except BaseContractRegistry.UnknownContract:
        message = f"\n{NucypherTokenAgent.contract_name} is not enrolled in {registry.filepath}"
        emitter.echo(message, color='yellow')
        emitter.echo(sep, nl=False)
    else:
        emitter.echo(token_contract_info)

    banner = """
* Proxy-Contract Deployments
====================================================================="""
    emitter.echo(banner)

    from nucypher.blockchain.eth.actors import ContractAdministrator
    for contract_deployer_class in ContractAdministrator.dispatched_upgradeable_deployer_classes:
        try:
            bare_contract = blockchain.get_contract_by_name(
                contract_name=contract_deployer_class.contract_name,
                proxy_name=DispatcherDeployer.contract_name,
                registry=registry,
                use_proxy_address=False)

            dispatcher_deployer = DispatcherDeployer(
                registry=registry,
                target_contract=bare_contract,
                deployer_address=deployer_address,
                bare=True)  # acquire agency for the dispatcher itself.

            agent = contract_deployer_class.agency(registry=registry,
                                                   contract=bare_contract)

            proxy_payload = f"""
{agent.contract_name} .... {bare_contract.address}
    ~ Owner .............. {bare_contract.functions.owner().call()}
    ~ Ethers ............. {Web3.fromWei(blockchain.client.get_balance(bare_contract.address), 'ether')} ETH
    ~ Tokens ............. {NU.from_nunits(token_agent.get_balance(bare_contract.address))}
    ~ Dispatcher ......... {dispatcher_deployer.contract_address}
        ~ Owner .......... {dispatcher_deployer.contract.functions.owner().call()}
        ~ Target ......... {dispatcher_deployer.contract.functions.target().call()}
        ~ Ethers ......... {Web3.fromWei(blockchain.client.get_balance(dispatcher_deployer.contract_address), 'ether')} ETH
        ~ Tokens ......... {NU.from_nunits(token_agent.get_balance(dispatcher_deployer.contract_address))}"""
            emitter.echo(proxy_payload)
            emitter.echo(sep, nl=False)

        except BaseContractRegistry.UnknownContract:
            message = f"\n{contract_deployer_class.contract_name} is not enrolled in {registry.filepath}"
            emitter.echo(message, color='yellow')
            emitter.echo(sep, nl=False)

    try:

        #
        # StakingInterface
        #

        staking_interface_agent = PreallocationEscrowAgent.StakingInterfaceAgent(
            registry=registry)
        bare_contract = blockchain.get_contract_by_name(
            contract_name=staking_interface_agent.contract_name,
            proxy_name=StakingInterfaceRouterDeployer.contract_name,
            use_proxy_address=False,
            registry=registry)

        router_deployer = StakingInterfaceRouterDeployer(
            registry=registry,
            target_contract=bare_contract,
            deployer_address=deployer_address,
            bare=True)  # acquire agency for the dispatcher itself.

        preallocation_escrow_payload = f"""
{staking_interface_agent.contract_name} ......... {bare_contract.address}
  ~ Ethers ............... {Web3.fromWei(blockchain.client.get_balance(bare_contract.address), 'ether')} ETH
  ~ Tokens ............... {NU.from_nunits(token_agent.get_balance(bare_contract.address))}
  ~ StakingInterfaceRouter {router_deployer.contract.address}
        ~ Owner .......... {router_deployer.contract.functions.owner().call()}
        ~ Target ......... {router_deployer.contract.functions.target().call()}
        ~ Ethers ......... {Web3.fromWei(blockchain.client.get_balance(router_deployer.contract_address), 'ether')} ETH
        ~ Tokens ......... {NU.from_nunits(token_agent.get_balance(router_deployer.contract_address))}"""
        emitter.echo(preallocation_escrow_payload)
        emitter.echo(sep)

    except BaseContractRegistry.UnknownContract:
        message = f"\nStakingInterface is not enrolled in {registry.filepath}"
        emitter.echo(message, color='yellow')

    try:

        policy_agent = ContractAgency.get_agent(PolicyManagerAgent,
                                                registry=registry)
        paint_fee_rate_range(emitter, policy_agent)
        emitter.echo(sep, nl=False)

    except BaseContractRegistry.UnknownContract:
        message = f"\n{PolicyManagerDeployer.contract_name} is not enrolled in {registry.filepath}"
        emitter.echo(message, color='yellow')
        emitter.echo(sep, nl=False)
Ejemplo n.º 2
0
def paint_deployer_contract_inspection(emitter, administrator) -> None:

    blockchain = BlockchainInterfaceFactory.get_interface()
    token_agent = ContractAgency.get_agent(NucypherTokenAgent,
                                           registry=administrator.registry)

    sep = '-' * 45
    emitter.echo(sep)

    contract_payload = f"""

* Web3 Provider
====================================================================

Provider URI ............. {blockchain.provider_uri}
Registry  ................ {administrator.registry.filepath}

* Standard Deployments
=====================================================================

NucypherToken ........... {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)

    banner = """
* Proxy-Contract Deployments
====================================================================="""
    emitter.echo(banner)

    for contract_deployer_class in administrator.dispatched_upgradeable_deployer_classes:
        try:
            bare_contract = blockchain.get_contract_by_name(
                name=contract_deployer_class.contract_name,
                proxy_name=DispatcherDeployer.contract_name,
                registry=administrator.registry,
                use_proxy_address=False)

            dispatcher_deployer = DispatcherDeployer(
                registry=administrator.registry,
                target_contract=bare_contract,
                deployer_address=administrator.deployer_address,
                bare=True)  # acquire agency for the dispatcher itself.

            agent = contract_deployer_class.agency(
                registry=administrator.registry, contract=bare_contract)

            proxy_payload = f"""
{agent.contract_name} .... {bare_contract.address}
    ~ Owner .............. {bare_contract.functions.owner().call()}
    ~ Ethers ............. {Web3.fromWei(blockchain.client.get_balance(dispatcher_deployer.contract_address), 'ether')} ETH
    ~ Tokens ............. {NU.from_nunits(token_agent.get_balance(dispatcher_deployer.contract_address))}
    ~ Dispatcher ......... {dispatcher_deployer.contract_address}
        ~ Owner .......... {dispatcher_deployer.contract.functions.owner().call()}
        ~ Target ......... {dispatcher_deployer.contract.functions.target().call()}
        ~ Ethers ......... {Web3.fromWei(blockchain.client.get_balance(dispatcher_deployer.contract_address), 'ether')} ETH
        ~ Tokens ......... {NU.from_nunits(token_agent.get_balance(dispatcher_deployer.contract_address))}"""
            emitter.echo(proxy_payload)
            emitter.echo(sep, nl=False)

        except BaseContractRegistry.UnknownContract:
            message = f"\n{contract_deployer_class.contract_name} is not enrolled in {administrator.registry.filepath}"
            emitter.echo(message, color='yellow')
            emitter.echo(sep, nl=False)

    try:

        #
        # UserEscrowProxy
        #

        user_escrow_proxy_agent = UserEscrowAgent.UserEscrowProxyAgent(
            registry=administrator.registry)
        bare_contract = blockchain.get_contract_by_name(
            name=user_escrow_proxy_agent.contract_name,
            proxy_name=LibraryLinkerDeployer.contract_name,
            use_proxy_address=False,
            registry=administrator.registry)

        linker_deployer = LibraryLinkerDeployer(
            registry=administrator.registry,
            target_contract=bare_contract,
            deployer_address=administrator.deployer_address,
            bare=True)  # acquire agency for the dispatcher itself.

        user_escrow_payload = f"""
UserEscrowProxy .......... {bare_contract.address}
    ~ LibraryLinker ...... {linker_deployer.contract.address}
        ~ Owner .......... {linker_deployer.contract.functions.owner().call()}
        ~ Target ......... {linker_deployer.contract.functions.target().call()}"""
        emitter.echo(user_escrow_payload)
        emitter.echo(sep)

    except BaseContractRegistry.UnknownContract:
        message = f"\nUserEscrowProxy is not enrolled in {administrator.registry.filepath}"
        emitter.echo(message, color='yellow')

    return