示例#1
0
def state_command():
    """
    Provide commands for working with state.
    """
    pass


@click.option('--address',
              required=True,
              type=str,
              help=STATE_ACCOUNT_ADDRESS_ARGUMENT_HELP_MESSAGE)
@click.option('--node-url',
              required=False,
              type=str,
              help=NODE_URL_ARGUMENT_HELP_MESSAGE,
              default=default_node_url())
@state_command.command('get')
def get_state(address, node_url):
    """
    Get a state by its address.
    """
    arguments, errors = GetStateForm().load({
        'address': address,
        'node_url': node_url,
    })

    if errors:
        print_errors(errors=errors)
        sys.exit(FAILED_EXIT_FROM_COMMAND_CODE)

    address = arguments.get('address')
示例#2
0
    default_node_url,
    print_errors,
    print_result,
)


@click.group('account', chain=True)
def account_commands():
    """
    Provide commands for working with account.
    """
    pass


@click.option('--address', type=str, required=True, help=ACCOUNT_ADDRESS_ARGUMENT_HELP_MESSAGE)
@click.option('--node-url', type=str, required=False, help=NODE_URL_ARGUMENT_HELP_MESSAGE, default=default_node_url())
@account_commands.command('get-balance')
def get_balance(address, node_url):
    """
    Get balance of the account by its address.
    """
    arguments, errors = GetAccountBalanceForm().load({
        'address': address,
        'node_url': node_url,
    })

    if errors:
        print_errors(errors=errors)
        sys.exit(FAILED_EXIT_FROM_COMMAND_CODE)

    address = arguments.get('address')