Exemple #1
0
    def completion(self, prefix, parsed_args, **kwargs):
        """
        complete the shell
        """
        if parsed_args.cmd is None:
            return self.supported_cmds
        # deploy contract
        if parsed_args.cmd[0] == "deploy":
            return CommandParser.get_contracts()

        # call and sendtx
        # warn(parsed_args)
        if parsed_args.cmd[0] == "call" or parsed_args.cmd[0] == "sendtx":
            # only list the contract name
            if len(parsed_args.cmd) == 1:
                return CommandParser.get_contracts()
            # list the contract address
            if len(parsed_args.cmd) == 2:
                return ContractNote.get_contract_addresses(parsed_args.cmd[1])
            # list functions
            if len(parsed_args.cmd) == 3:
                return CommandParser.get_functions_by_contract(parsed_args.cmd[1])

        # call showaccount
        if parsed_args.cmd[0] == "showaccount":
            return CommandParser.get_accounts()
        # registerCNS [contract_name] [contract_address] [contract_version]
        if parsed_args.cmd[0] == "registerCNS":
            # list contract name
            if len(parsed_args.cmd) == 1:
                return CommandParser.get_contracts()
            # list contract address
            if len(parsed_args.cmd) == 2:
                return ContractNote.get_contract_addresses(parsed_args.cmd[1])
        # queryCNSByName [contract_name]
        if parsed_args.cmd[0] == "queryCNSByName":
            # list contract name
            if len(parsed_args.cmd) == 1:
                return CommandParser.get_contracts()
        # queryCNSByNameAndVersion [contract_name] [contract_version]
        if parsed_args.cmd[0] == "queryCNSByNameAndVersion":
            if len(parsed_args.cmd) == 1:
                return CommandParser.get_contracts()
        # sysconfig
        if parsed_args.cmd[0] == "setSystemConfigByKey" or parsed_args.cmd[0] == "getSystemConfigByKey":
            return ["tx_count_limit", "tx_gas_limit"]
        return []
def list_address(contract_name):
    """
    get address according to contract_name
    """
    return ContractNote.get_contract_addresses(contract_name)
def getContractAddr(contractName):
    return ContractNote.get_contract_addresses(contractName)[0]