Search in sources :

Example 1 with ContractGetInfoQuery

use of com.hederahashgraph.api.proto.java.ContractGetInfoQuery in project hedera-services by hashgraph.

the class HapiGetContractInfo method getContractInfoQuery.

private Query getContractInfoQuery(HapiApiSpec spec, Transaction payment, boolean costOnly) {
    ContractGetInfoQuery contractGetInfo;
    if (getPredefinedId) {
        var contractID = readContractID(spec);
        if (contractID != null) {
            contractGetInfo = ContractGetInfoQuery.newBuilder().setHeader(costOnly ? answerCostHeader(payment) : answerHeader(payment)).setContractID(contractID).build();
        } else {
            log.error("Couldn't read contractID from saved file");
            return null;
        }
    } else {
        final var builder = ContractGetInfoQuery.newBuilder().setHeader(costOnly ? answerCostHeader(payment) : answerHeader(payment));
        if (contract.length() == 40) {
            builder.setContractID(ContractID.newBuilder().setEvmAddress(ByteString.copyFrom(CommonUtils.unhex(contract))));
        } else {
            builder.setContractID(asContractId(contract, spec));
        }
        contractGetInfo = builder.build();
    }
    return Query.newBuilder().setContractGetInfo(contractGetInfo).build();
}
Also used : ContractGetInfoQuery(com.hederahashgraph.api.proto.java.ContractGetInfoQuery)

Aggregations

ContractGetInfoQuery (com.hederahashgraph.api.proto.java.ContractGetInfoQuery)1