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
def _add_common_arguments(sub: Any): cli_shared.add_proxy_arg(sub) cli_shared.add_wallet_args(sub) cli_shared.add_tx_args(sub, with_receiver=False, with_data=False, with_estimate_gas=True) cli_shared.add_broadcast_args(sub, relay=False) cli_shared.add_outfile_arg(sub, what="signed transaction, hash")
def setup_parser(subparsers: Any) -> Any: parser = cli_shared.add_group_subparser( subparsers, "dns", "Operations related to the Domain Name Service") subparsers = parser.add_subparsers() sub = cli_shared.add_command_subparser( subparsers, "dns", "register", "Send a register transaction to the appropriate DNS contract from given user and with given name" ) cli_shared.add_outfile_arg(sub) cli_shared.add_broadcast_args(sub, relay=True) cli_shared.add_wallet_args(sub) cli_shared.add_proxy_arg(sub) cli_shared.add_tx_args(sub, with_receiver=False, with_data=False) sub.add_argument("--name", help="the name to register") sub.set_defaults(func=register) sub = cli_shared.add_command_subparser(subparsers, "dns", "resolve", "Find the address for a name") _add_name_arg(sub) cli_shared.add_proxy_arg(sub) sub.set_defaults(func=dns_resolve) sub = cli_shared.add_command_subparser( subparsers, "dns", "validate-name", "Asks one of the DNS contracts to validate a name. Can be useful before registering it." ) _add_name_arg(sub) sub.add_argument( "--shard-id", default=0, help="shard id of the contract to call (default: %(default)s)") cli_shared.add_proxy_arg(sub) sub.set_defaults(func=dns_validate_name) sub = cli_shared.add_command_subparser( subparsers, "dns", "name-hash", "The hash of a name, as computed by a DNS smart contract") _add_name_arg(sub) sub.set_defaults(func=get_name_hash) sub = cli_shared.add_command_subparser( subparsers, "dns", "registration-cost", "Gets the registration cost from a DNS smart contract, by default the one with shard id 0." ) sub.add_argument( "--shard-id", default=0, help="shard id of the contract to call (default: %(default)s)") cli_shared.add_proxy_arg(sub) sub.set_defaults(func=get_registration_cost) sub = cli_shared.add_command_subparser( subparsers, "dns", "version", "Asks the contract for its version") sub.add_argument( "--shard-id", default=0, help="shard id of the contract to call (default: %(default)s)") sub.add_argument( "--all", action="store_true", default=False, help= "prints a list of all DNS contracts and their current versions (default: %(default)s)" ) cli_shared.add_proxy_arg(sub) sub.set_defaults(func=get_version) sub = cli_shared.add_command_subparser( subparsers, "dns", "dns-addresses", "Lists all 256 DNS contract addresses") sub.set_defaults(func=print_dns_addresses_table) sub = cli_shared.add_command_subparser( subparsers, "dns", "dns-address-for-name", "DNS contract address (bech32) that corresponds to a name") _add_name_arg(sub) sub.set_defaults(func=get_dns_address_for_name) sub = cli_shared.add_command_subparser( subparsers, "dns", "dns-address-for-name-hex", "DNS contract address (hex) that corresponds to a name") _add_name_arg(sub) sub.set_defaults(func=get_dns_address_for_name_hex) parser.epilog = cli_shared.build_group_epilog(subparsers) return subparsers
def setup_parser(subparsers: Any) -> Any: parser = cli_shared.add_group_subparser( subparsers, "contract", "Build, deploy and interact with Smart Contracts") subparsers = parser.add_subparsers() sub = cli_shared.add_command_subparser( subparsers, "contract", "new", "Create a new Smart Contract project based on a template.") sub.add_argument("name") sub.add_argument("--template", required=True, help="the template to use") sub.add_argument( "--directory", type=str, default=os.getcwd(), help= "🗀 the parent directory of the project (default: current directory)" ) sub.set_defaults(func=create) sub = cli_shared.add_command_subparser( subparsers, "contract", "templates", "List the available Smart Contract templates.") sub.set_defaults(func=list_templates) sub = cli_shared.add_command_subparser( subparsers, "contract", "build", "Build a Smart Contract project using the appropriate buildchain.") _add_project_arg(sub) sub.add_argument("--debug", action="store_true", default=False, help="set debug flag (default: %(default)s)") sub.add_argument( "--no-optimization", action="store_true", default=False, help="bypass optimizations (for clang) (default: %(default)s)") sub.add_argument("--cargo-target-dir", type=str, help="for rust projects, forward the parameter to Cargo") sub.add_argument( "--wasm-symbols", action="store_true", default=False, help= "for rust projects, does not strip the symbols from the wasm output. Useful for analysing the bytecode. Creates larger wasm files. Avoid in production (default: %(default)s)" ) sub.add_argument( "--wasm-name", type=str, help= "for rust projects, optionally specify the name of the wasm bytecode output file" ) sub.set_defaults(func=build) sub = cli_shared.add_command_subparser(subparsers, "contract", "clean", "Clean a Smart Contract project.") _add_project_arg(sub) sub.set_defaults(func=clean) sub = cli_shared.add_command_subparser(subparsers, "contract", "test", "Run Mandos tests.") _add_project_arg(sub) sub.add_argument( "--directory", default="mandos", help="🗀 the directory containing the tests (default: %(default)s)") sub.add_argument("--wildcard", required=False, help="wildcard to match only specific test files") sub.set_defaults(func=run_tests) sub = cli_shared.add_command_subparser(subparsers, "contract", "deploy", "Deploy a Smart Contract.") _add_project_or_bytecode_arg(sub) _add_metadata_arg(sub) cli_shared.add_outfile_arg(sub) cli_shared.add_wallet_args(sub) cli_shared.add_proxy_arg(sub) cli_shared.add_tx_args(sub, with_receiver=False, with_data=False) _add_arguments_arg(sub) cli_shared.add_broadcast_args(sub) sub.set_defaults(func=deploy) sub = cli_shared.add_command_subparser( subparsers, "contract", "call", "Interact with a Smart Contract (execute function).") _add_contract_arg(sub) cli_shared.add_outfile_arg(sub) cli_shared.add_wallet_args(sub) cli_shared.add_proxy_arg(sub) cli_shared.add_tx_args(sub, with_receiver=False, with_data=False) _add_function_arg(sub) _add_arguments_arg(sub) sub.add_argument( "--wait-result", action="store_true", default=False, help= "signal to wait for the transaction result - only valid if --send is set" ) sub.add_argument("--timeout", default=100, help="max num of seconds to wait for result" " - only valid if --wait-result is set") cli_shared.add_broadcast_args(sub, relay=True) sub.set_defaults(func=call) sub = cli_shared.add_command_subparser( subparsers, "contract", "upgrade", "Upgrade a previously-deployed Smart Contract") _add_contract_arg(sub) cli_shared.add_outfile_arg(sub) _add_project_or_bytecode_arg(sub) _add_metadata_arg(sub) cli_shared.add_wallet_args(sub) cli_shared.add_proxy_arg(sub) cli_shared.add_tx_args(sub, with_receiver=False, with_data=False) _add_arguments_arg(sub) cli_shared.add_broadcast_args(sub) sub.set_defaults(func=upgrade) sub = cli_shared.add_command_subparser( subparsers, "contract", "query", "Query a Smart Contract (call a pure function)") _add_contract_arg(sub) cli_shared.add_proxy_arg(sub) _add_function_arg(sub) _add_arguments_arg(sub) sub.set_defaults(func=query) parser.epilog = cli_shared.build_group_epilog(subparsers) return subparsers
def setup_parser(subparsers: Any) -> Any: parser = cli_shared.add_group_subparser(subparsers, "contract", "Build, deploy and interact with Smart Contracts") subparsers = parser.add_subparsers() sub = cli_shared.add_command_subparser(subparsers, "contract", "new", "Create a new Smart Contract project based on a template.") sub.add_argument("name") sub.add_argument("--template", required=True, help="the template to use") sub.add_argument("--directory", type=str, default=os.getcwd(), help="🗀 the parent directory of the project (default: current directory)") sub.set_defaults(func=create) sub = cli_shared.add_command_subparser(subparsers, "contract", "templates", "List the available Smart Contract templates.") sub.set_defaults(func=list_templates) sub = cli_shared.add_command_subparser(subparsers, "contract", "build", "Build a Smart Contract project using the appropriate buildchain.") _add_project_arg(sub) sub.add_argument("--debug", action="store_true", default=False, help="set debug flag (default: %(default)s)") sub.add_argument("--no-optimization", action="store_true", default=False, help="bypass optimizations (for clang) (default: %(default)s)") sub.set_defaults(func=build) sub = cli_shared.add_command_subparser(subparsers, "contract", "clean", "Clean a Smart Contract project.") _add_project_arg(sub) sub.set_defaults(func=clean) sub = cli_shared.add_command_subparser(subparsers, "contract", "test", "Run Mandos tests.") _add_project_arg(sub) sub.add_argument("--directory", default="mandos", help="🗀 the directory containing the tests (default: %(default)s)") sub.add_argument("--wildcard", required=False, help="wildcard to match only specific test files") sub.set_defaults(func=run_tests) sub = cli_shared.add_command_subparser(subparsers, "contract", "deploy", "Deploy a Smart Contract.") _add_project_or_bytecode_arg(sub) _add_metadata_arg(sub) cli_shared.add_outfile_arg(sub) cli_shared.add_wallet_args(sub) cli_shared.add_proxy_arg(sub) cli_shared.add_tx_args(sub, with_receiver=False, with_data=False) _add_arguments_arg(sub) cli_shared.add_broadcast_args(sub) sub.set_defaults(func=deploy) sub = cli_shared.add_command_subparser(subparsers, "contract", "call", "Interact with a Smart Contract (execute function).") _add_contract_arg(sub) cli_shared.add_outfile_arg(sub) cli_shared.add_wallet_args(sub) cli_shared.add_proxy_arg(sub) cli_shared.add_tx_args(sub, with_receiver=False, with_data=False) _add_function_arg(sub) _add_arguments_arg(sub) cli_shared.add_broadcast_args(sub) sub.set_defaults(func=call) sub = cli_shared.add_command_subparser(subparsers, "contract", "upgrade", "Upgrade a previously-deployed Smart Contract") _add_contract_arg(sub) cli_shared.add_outfile_arg(sub) _add_project_or_bytecode_arg(sub) _add_metadata_arg(sub) cli_shared.add_wallet_args(sub) cli_shared.add_proxy_arg(sub) cli_shared.add_tx_args(sub, with_receiver=False, with_data=False) _add_arguments_arg(sub) cli_shared.add_broadcast_args(sub) sub.set_defaults(func=upgrade) sub = cli_shared.add_command_subparser(subparsers, "contract", "query", "Query a Smart Contract (call a pure function)") _add_contract_arg(sub) cli_shared.add_proxy_arg(sub) _add_function_arg(sub) _add_arguments_arg(sub) sub.set_defaults(func=query) parser.epilog = cli_shared.build_group_epilog(subparsers) return subparsers