def setup_parser(subparsers: Any) -> Any:
    parser = cli_shared.add_group_subparser(
        subparsers, "tx", "Create and broadcast Transactions")
    subparsers = parser.add_subparsers()

    sub = cli_shared.add_command_subparser(subparsers, "tx", "new",
                                           "Create a new transaction")
    _add_common_arguments(sub)
    cli_shared.add_outfile_arg(sub, what="signed transaction, hash")
    cli_shared.add_broadcast_args(sub, relay=True)
    cli_shared.add_proxy_arg(sub)
    sub.set_defaults(func=create_transaction)

    sub = cli_shared.add_command_subparser(
        subparsers, "tx", "send", "Send a previously saved transaction")
    cli_shared.add_infile_arg(sub, what="a previously saved transaction")
    cli_shared.add_outfile_arg(sub, what="the hash")
    cli_shared.add_proxy_arg(sub)
    sub.set_defaults(func=send_transaction)

    sub = cli_shared.add_command_subparser(subparsers, "tx", "get",
                                           "Get a transaction")
    sub.add_argument("--hash", required=True, help="the hash")
    sub.add_argument("--sender", required=False, help="the sender address")
    sub.add_argument("--with-results",
                     action="store_true",
                     help="will also return the results of transaction")
    cli_shared.add_proxy_arg(sub)
    cli_shared.add_omit_fields_arg(sub)
    sub.set_defaults(func=get_transaction)

    parser.epilog = cli_shared.build_group_epilog(subparsers)
    return subparsers
Exemple #2
0
def setup_parser(subparsers: Any) -> Any:
    parser = cli_shared.add_group_subparser(
        subparsers, "account",
        "Get Account data (nonce, balance) from the Network")
    subparsers = parser.add_subparsers()

    sub = cli_shared.add_command_subparser(
        subparsers, "account", "get",
        "Query account details (nonce, balance etc.)")
    cli_shared.add_proxy_arg(sub)
    _add_address_arg(sub)
    mutex = sub.add_mutually_exclusive_group()
    mutex.add_argument("--balance",
                       action="store_true",
                       help="whether to only fetch the balance")
    mutex.add_argument("--nonce",
                       action="store_true",
                       help="whether to only fetch the nonce")
    mutex.add_argument("--username",
                       action="store_true",
                       help="whether to only fetch the username")
    cli_shared.add_omit_fields_arg(sub)
    sub.set_defaults(func=get_account)

    sub = cli_shared.add_command_subparser(subparsers, "account",
                                           "get-transactions",
                                           "Query account transactions")
    cli_shared.add_proxy_arg(sub)
    cli_shared.add_outfile_arg(sub)
    _add_address_arg(sub)
    sub.set_defaults(func=get_account_transactions)

    parser.epilog = cli_shared.build_group_epilog(subparsers)
    return subparsers
def setup_parser(subparsers: Any) -> Any:
    parser = cli_shared.add_group_subparser(
        subparsers, "staking-provider", "Create New Delegation Contract "
        "and some more staking-provider related "
        "options")
    subparsers = parser.add_subparsers()

    # create new delegation contract
    sub = cli_shared.add_command_subparser(
        subparsers, "staking-provider", "create-new-delegation-contract",
        "Create a new delegation system smart contract, transferred value must be"
        "greater than baseIssuingCost + min deposit value")
    _add_common_arguments(sub)
    sub.add_argument("--total-delegation-cap",
                     required=True,
                     help="the total delegation contract capacity")
    sub.add_argument("--service-fee",
                     required=True,
                     help="the delegation contract service fee")
    sub.set_defaults(func=do_create_delegation_contract)

    # get contract address
    sub = cli_shared.add_command_subparser(
        subparsers, "staking-provider", "get-contract-address",
        "Get create contract address by transaction hash")
    sub.add_argument("--create-tx-hash", required=True, help="the hash")
    sub.add_argument("--sender", required=False, help="the sender address")
    cli_shared.add_proxy_arg(sub)
    cli_shared.add_omit_fields_arg(sub)
    sub.set_defaults(func=get_contract_address_by_deploy_tx_hash)

    # add a new node
    sub = cli_shared.add_command_subparser(
        subparsers, "staking-provider", "add-nodes",
        "Add new nodes must be called by the contract owner")
    sub.add_argument("--validators-file",
                     required=True,
                     help="a JSON file describing the Nodes")
    sub.add_argument("--delegation-contract",
                     required=True,
                     help="address of the delegation contract")
    _add_common_arguments(sub)
    sub.set_defaults(func=add_new_nodes)

    # remove nodes
    sub = cli_shared.add_command_subparser(
        subparsers, "staking-provider", "remove-nodes",
        "Remove nodes must be called by the contract owner")
    sub.add_argument("--bls-keys",
                     required=True,
                     help="a list with the bls keys of the nodes")
    sub.add_argument("--delegation-contract",
                     required=True,
                     help="address of the delegation contract")
    _add_common_arguments(sub)
    sub.set_defaults(func=remove_nodes)

    # stake nodes
    sub = cli_shared.add_command_subparser(
        subparsers, "staking-provider", "stake-nodes",
        "Stake nodes must be called by the contract owner")
    sub.add_argument("--bls-keys",
                     required=True,
                     help="a list with the bls keys of the nodes")
    sub.add_argument("--delegation-contract",
                     required=True,
                     help="address of the delegation contract")
    _add_common_arguments(sub)
    sub.set_defaults(func=stake_nodes)

    # unbond nodes
    sub = cli_shared.add_command_subparser(
        subparsers, "staking-provider", "unbond-nodes",
        "Unbond nodes must be called by the contract owner")
    sub.add_argument("--bls-keys",
                     required=True,
                     help="a list with the bls keys of the nodes")
    sub.add_argument("--delegation-contract",
                     required=True,
                     help="address of the delegation contract")
    _add_common_arguments(sub)
    sub.set_defaults(func=unbond_nodes)

    # unstake nodes
    sub = cli_shared.add_command_subparser(
        subparsers, "staking-provider", "unstake-nodes",
        "Unstake nodes must be called by the contract owner")
    sub.add_argument("--bls-keys",
                     required=True,
                     help="a list with the bls keys of the nodes")
    sub.add_argument("--delegation-contract",
                     required=True,
                     help="address of the delegation contract")
    _add_common_arguments(sub)
    sub.set_defaults(func=unstake_nodes)

    # unjail nodes
    sub = cli_shared.add_command_subparser(
        subparsers, "staking-provider", "unjail-nodes",
        "Unjail nodes must be called by the contract owner")
    sub.add_argument("--bls-keys",
                     required=True,
                     help="a list with the bls keys of the nodes")
    sub.add_argument("--delegation-contract",
                     required=True,
                     help="address of the delegation contract")
    _add_common_arguments(sub)
    sub.set_defaults(func=unjail_nodes)

    # change service fee
    sub = cli_shared.add_command_subparser(
        subparsers, "staking-provider", "change-service-fee",
        "Change service fee must be called by the contract owner")
    sub.add_argument("--service-fee",
                     required=True,
                     help="new service fee value")
    sub.add_argument("--delegation-contract",
                     required=True,
                     help="address of the delegation contract")
    _add_common_arguments(sub)
    sub.set_defaults(func=change_service_fee)

    # modify total delegation cap
    sub = cli_shared.add_command_subparser(
        subparsers, "staking-provider", "modify-delegation-cap",
        "Modify delegation cap must be called by the contract owner")
    sub.add_argument("--delegation-cap",
                     required=True,
                     help="new delegation contract capacity")
    sub.add_argument("--delegation-contract",
                     required=True,
                     help="address of the delegation contract")
    _add_common_arguments(sub)
    sub.set_defaults(func=modify_delegation_cap)

    # set automatic activation
    sub = cli_shared.add_command_subparser(
        subparsers, "staking-provider", "automatic-activation",
        "Automatic activation must be called by the contract owner")

    sub.add_argument("--set",
                     action="store_true",
                     required=not (utils.is_arg_present("--unset", sys.argv)),
                     help="set automatic activation True")
    sub.add_argument("--unset",
                     action="store_true",
                     required=not (utils.is_arg_present("--set", sys.argv)),
                     help="set automatic activation False")

    sub.add_argument("--delegation-contract",
                     required=True,
                     help="address of the delegation contract")
    _add_common_arguments(sub)
    sub.set_defaults(func=automatic_activation)