Exemplo n.º 1
0
def locked_tokens(general_config, registry_options, periods):
    """
    Display a graph of the number of locked tokens over time.
    """
    emitter = _setup_emitter(general_config)
    registry = registry_options.get_registry(emitter, general_config.debug)
    staking_agent = ContractAgency.get_agent(StakingEscrowAgent, registry=registry)
    paint_locked_tokens_status(emitter=emitter, agent=staking_agent, periods=periods)
Exemplo n.º 2
0
def locked_tokens(click_config,

                  # Common Options
                  provider_uri, geth, poa, light, registry_filepath,

                  # Other
                  periods):
    """
    Display a graph of the number of locked tokens over time.
    """
    # Init
    emitter = _setup_emitter(click_config)
    staking_agent = _get_staking_agent(click_config, emitter, geth, poa, light, provider_uri, registry_filepath)

    paint_locked_tokens_status(emitter=emitter, agent=staking_agent, periods=periods)
Exemplo n.º 3
0
def status(click_config, action, provider_uri, sync, geth, poa, periods, staking_address, registry_filepath):
    """
    Echo a snapshot of live NuCypher Network metadata.

    \b
    Actions
    -------------------------------------------------
    network        Overall information of the NuCypher Network
    stakers        Show relevant information about stakers
    locked-tokens  Display a graph of evolution of locked tokens

    """

    emitter = click_config.emitter
    click.clear()
    emitter.banner(NU_BANNER)

    #
    # Connect to Blockchain
    #

    try:
        ETH_NODE = None
        if geth:
            ETH_NODE = get_provider_process()

        # Note: For test compatibility.
        if not BlockchainInterfaceFactory.is_interface_initialized(provider_uri=provider_uri):
            BlockchainInterfaceFactory.initialize_interface(provider_uri=provider_uri,
                                                            provider_process=ETH_NODE,
                                                            poa=poa,
                                                            sync=False,
                                                            show_sync_progress=False)

        blockchain = BlockchainInterfaceFactory.get_interface(provider_uri=provider_uri)

        emitter.echo(message="Reading Latest Chaindata...")
        blockchain.connect()
    except Exception as e:
        if click_config.debug:
            raise
        click.secho(str(e), bold=True, fg='red')
        raise click.Abort

    if registry_filepath:
        registry = LocalContractRegistry(filepath=registry_filepath)
    else:
        registry = InMemoryContractRegistry.from_latest_publication()

    staking_agent = ContractAgency.get_agent(StakingEscrowAgent, registry=registry)

    if action == 'network':
        paint_contract_status(registry, emitter=emitter)
        return  # Exit

    elif action == 'stakers':
        stakers = [staking_address] if staking_address else staking_agent.get_stakers()
        paint_stakers(emitter=emitter, stakers=stakers, agent=staking_agent)
        return  # Exit

    elif action == 'locked-tokens':
        paint_locked_tokens_status(emitter=emitter, agent=staking_agent, periods=periods)
        return  # Exit

    else:
        ctx = click.get_current_context()
        raise click.UsageError(message=f"Unknown action '{action}'.", ctx=ctx)