import click import sys import os import json from utility import get_command_usage, cust_print, g_dict_dir_config, connect_node @click.command(cls=get_command_usage("account")) @click.option('-d', '--address', required=True, help='wallet address.') @click.option('-c', '--config', default="", help='The configuration file specifying the IP and port of the ' 'transaction to be sent. If it is configured in the global configuration network file, IP and prot ' 'can be obtained by specifying the name in the configuration. If the network configuration is not ' 'filled in.') def balance(address, config): if 42 != len(address): cust_print("Wrong address parameter: --address {}".format(address), fg='r') sys.exit(1) hrp = address[:3] # 节点配置文件 if "" == config: config = os.path.join(g_dict_dir_config["conf_dir"], "node_config.json") if not os.path.exists(config): cust_print("The node profile exists:{}, please check it.".format(config), fg='r') sys.exit(1) try: with open(config, 'r') as f: rpcAddress = json.load(f)['rpcAddress'] except: cust_print('{} data is incorrect format!!!'.format(config))
import click import sys import json from utility import get_command_usage, get_eth_obj, cust_print @click.command(cls=get_command_usage("hedge")) @click.option( '-a', '--address', required=True, help="Release locked position to account address,only account address") @click.option( '-c', '--config', default="", help='The configuration file specifying the IP and port of the ' 'transaction to be sent. If it is configured in the global configuration network file, IP and prot ' 'can be obtained by specifying the name in the configuration. If the network configuration is not ' 'filled in.') @click.option('-f', '--fromaddress', default="", help="fromaddress") def GetRestrictingInfo(address, config, fromaddress): """ this is hedge submodule GetRestrictingInfo command. """ try: fromaddress = None if fromaddress.replace(" ", "") == "" else fromaddress ppos = get_eth_obj(config, 'ppos') result = ppos.getRestrictingInfo(address, fromaddress) cust_print('{}'.format(json.dumps(result['Ret'], indent=2)), fg='g')
import click import os import rlp import sys from utility import get_command_usage, cust_print, read_json_file, g_dict_dir_config, get_eth_obj, write_csv, \ write_QRCode, get_time_stamp from common import verify_password, un_sign_data, check_dir_exits @click.command(cls=get_command_usage("government")) @click.option('-p', '--param', required=True, default="", help='The transaction parameter json string, or the ' 'transaction parameter json file path.') @click.option('-d', '--address', required=True, default="", help='Send the transaction address or name.json') @click.option( '-o', '--offline', is_flag=True, default=False, help= 'Offline transaction or offline transaction offline not input is the default ' 'for online transaction, and a two-dimensional code picture is generated and ' 'placed on the desktop, providing ATON offline scanning code signature.') @click.option(
typ, benifit_address, node_id, external_id, node_name, website, details, amount, program_version, \ program_version_sign, bls_pubkey, bls_proof, _, reward_per, _ = args benifit_address = bech32_address_bytes(hrp)(benifit_address) if program_version_sign[:2] == '0x': program_version_sign = program_version_sign[2:] data = HexBytes(rlp.encode([rlp.encode(int(1000)), rlp.encode(typ), rlp.encode(benifit_address), rlp.encode(bytes.fromhex(node_id)), rlp.encode(external_id), rlp.encode(node_name), rlp.encode(website), rlp.encode(details), rlp.encode(amount), rlp.encode(reward_per), rlp.encode(program_version), rlp.encode(bytes.fromhex(program_version_sign)), rlp.encode(bytes.fromhex(bls_pubkey)), rlp.encode(bytes.fromhex(bls_proof))])).hex() return data @click.command(cls=get_command_usage("staking")) @click.option('-f', '--file', help='The file is save params.') @click.option('-d', '--address', help='wallet address.') @click.option('-t', '--template', is_flag=True, default=False, help='View the create staking parameter template. It is ' 'not effective to coexist with other parameters.') @click.option('-c', '--config', default="", help='The configuration file specifying the IP and port of the ' 'transaction to be sent. If it is configured in the global configuration network file, IP and prot ' 'can be obtained by specifying the name in the configuration. If the network configuration is not ' 'filled in.') @click.option('-o', '--offline', is_flag=True, default=False, help='Offline transaction or offline transaction offline not input is the default ' 'for online transaction, and a two-dimensional code picture is generated and ' 'placed on the desktop, providing ATON offline scanning code signature.') @click.option('-s', '--style', default="", help='This parameter is used to determine the type of file to be signed') def create(file, address, template, config, offline, style):
def versionToNum(strVersion): if strVersion == "": return 0 info_list = strVersion.split(".") if 3 != len(info_list): return 0 major = int(info_list[0]) minor = int(info_list[1]) patch = int(info_list[2]) return major << 16 | minor << 8 | patch @click.command(cls=get_command_usage("node")) def check(): """ this is node submodule check command. """ platon_cfg_path = os.path.join(g_dict_dir_config["conf_dir"], 'platon.cfg') platon_cfg = get_local_platon_cfg(platon_cfg_path) url = "http://{}:{}".format(platon_cfg["rpcaddr"], platon_cfg["rpcport"]) cust_print("connect node: {}".format(url), fg='g') hrp = platon_cfg["hrp"] cust_print("get hrp:{} from platon_cfg file: {}".format( hrp, platon_cfg_path), fg='g') # get platon version on chain try:
import click import json import sys from utility import get_command_usage, cust_print, get_eth_obj @click.command(cls=get_command_usage("delegate")) @click.option('-d', '--address', required=True, help='The height of the block when the pledge is initiated') @click.option( '-c', '--config', default="", help='The configuration file specifying the IP and port of the ' 'transaction to be sent. If it is configured in the global configuration network file, IP and prot ' 'can be obtained by specifying the name in the configuration. If the network configuration is not ' 'filled in.') @click.option('-f', '--fromaddress', default="", help="fromaddress") def getRelatedListByDelAddress(address, config, fromaddress): """ this is delegate submodule getRelatedListByDelAddr command. """ try: ppos = get_eth_obj(config, 'ppos') fromaddress = None if fromaddress.replace(" ", "") == "" else fromaddress result = ppos.getRelatedListByDelAddr(address, fromaddress) for obj in result['Ret']: cust_print('{}'.format(json.dumps(obj, indent=2)), fg='g')
import click from utility import get_command_usage, get_eth_obj, cust_print @click.command(cls=get_command_usage("query")) @click.option('-c', '--config', default="", help='The configuration file specifying the IP and port of the ' 'transaction to be sent. If it is configured in the global configuration network file, IP and prot ' 'can be obtained by specifying the name in the configuration. If the network configuration is not ' 'filled in.') def blockNumber(config): """ this is query submodule get blockNumber command. """ platon = get_eth_obj(config) block_number = platon.blockNumber cust_print('{}'.format(block_number), fg='g')
import os import sys import ast import click from utility import get_command_usage, g_dict_dir_config, cust_print, send_transaction, get_eth_obj @click.command(cls=get_command_usage("tx")) @click.option('-d', '--data', required=True, help='The transaction signature data.') @click.option( '-c', '--config', default="", help='The configuration file specifying the IP and port of the ' 'transaction to be sent. If it is configured in the global configuration network file, IP and prot ' 'can be obtained by specifying the name in the configuration. If the network configuration is not ' 'filled in.') def send_offline(data, config): """ this is tx submodule send_offline command. """ signed_tx_dir = g_dict_dir_config["signed_tx_dir"] abspath = os.path.join(signed_tx_dir, data) if not os.path.isfile(abspath): cust_print('{} not exists,please check!'.format(abspath), fg='r') sys.exit(1) try: with open(abspath, 'r') as f:
help='是否是搭建私链?(默认:否).') @click.option( '-h', '--hrp', 'hrp', required=True, default='lat', type=click.Choice(['atp', 'atx', 'lat', 'lax']), help= 'Address prefix, \'atp/atx\' Are the main network and test network addresses of Alaya network ' 'respectively; ' '\'lat/lax\' Are the primary and test network addresses of PlatON network respectively.' ) @click.option('-c', '--config', default="", help="genesis block config.") @click.command(help="Initialize the PlatON CLI tool.", cls=get_command_usage("init", False)) def init(withnode, private_chain, hrp, config): if withnode: init_node(hrp, private_chain, config) else: # init cli cust_print("start init platon cli...", fg='g') ip = "" rpc_port = "" chainId = 100 if 'atp' == hrp: chainId = 201018 elif 'atx' == hrp: chainId = 201030