Search in sources :

Example 96 with Query

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

the class HapiGetTxnRecord method lookupCostWith.

@Override
protected long lookupCostWith(HapiApiSpec spec, Transaction payment) throws Throwable {
    Query query = getRecordQuery(spec, payment, true);
    Response response = spec.clients().getCryptoSvcStub(targetNodeFor(spec), useTls).getTxRecordByTxID(query);
    return costFrom(response);
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) TransactionGetRecordQuery(com.hederahashgraph.api.proto.java.TransactionGetRecordQuery) Query(com.hederahashgraph.api.proto.java.Query)

Example 97 with Query

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

the class HapiGetTxnRecord method submitWith.

@Override
protected void submitWith(HapiApiSpec spec, Transaction payment) throws InvalidProtocolBufferException {
    Query query = getRecordQuery(spec, payment, false);
    response = spec.clients().getCryptoSvcStub(targetNodeFor(spec), useTls).getTxRecordByTxID(query);
    final TransactionRecord record = response.getTransactionGetRecord().getTransactionRecord();
    if (contractResultAbi != null) {
        exposeRequestedEventsFrom(record);
    }
    observer.ifPresent(obs -> obs.accept(record));
    childRecords = response.getTransactionGetRecord().getChildTransactionRecordsList();
    childRecordsCount.ifPresent(count -> assertEquals(count, childRecords.size()));
    for (var rec : childRecords) {
        spec.registry().saveAccountId(rec.getAlias().toStringUtf8(), rec.getReceipt().getAccountID());
        spec.registry().saveKey(rec.getAlias().toStringUtf8(), Key.parseFrom(rec.getAlias()));
        log.info(spec.logPrefix() + "  Saving alias {} to registry for Account ID {}", rec.getAlias().toStringUtf8(), rec.getReceipt().getAccountID());
    }
    if (verboseLoggingOn) {
        if (format.isPresent()) {
            format.get().accept(record, log);
        } else {
            var fee = record.getTransactionFee();
            var rates = spec.ratesProvider();
            var priceInUsd = sdec(rates.toUsdWithActiveRates(fee), 5);
            log.info(spec.logPrefix() + "Record (charged ${}): {}", priceInUsd, record);
            log.info(spec.logPrefix() + "  And {} child record{}: {}", childRecords.size(), childRecords.size() > 1 ? "s" : "", childRecords);
            log.info("Duplicates: {}", response.getTransactionGetRecord().getDuplicateTransactionRecordsList());
        }
    }
    if (response.getTransactionGetRecord().getHeader().getNodeTransactionPrecheckCode() == OK) {
        priceConsumer.ifPresent(pc -> pc.accept(record.getTransactionFee()));
        debitsConsumer.ifPresent(dc -> dc.accept(asDebits(record.getTransferList())));
    }
    if (registryEntry.isPresent()) {
        spec.registry().saveContractList(registryEntry.get() + "CreateResult", record.getContractCreateResult().getCreatedContractIDsList());
        spec.registry().saveContractList(registryEntry.get() + "CallResult", record.getContractCallResult().getCreatedContractIDsList());
    }
    if (saveTxnRecordToRegistry.isPresent()) {
        spec.registry().saveTransactionRecord(saveTxnRecordToRegistry.get(), record);
    }
}
Also used : TransactionGetRecordQuery(com.hederahashgraph.api.proto.java.TransactionGetRecordQuery) Query(com.hederahashgraph.api.proto.java.Query) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord)

Example 98 with Query

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

the class HapiGetScheduleInfo method lookupCostWith.

@Override
protected long lookupCostWith(HapiApiSpec spec, Transaction payment) throws Throwable {
    Query query = getScheduleInfoQuery(spec, payment, true);
    Response response = spec.clients().getScheduleSvcStub(targetNodeFor(spec), useTls).getScheduleInfo(query);
    return costFrom(response);
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) Query(com.hederahashgraph.api.proto.java.Query) ScheduleGetInfoQuery(com.hederahashgraph.api.proto.java.ScheduleGetInfoQuery)

Example 99 with Query

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

the class HapiGetExecTime method submitWith.

@Override
protected void submitWith(HapiApiSpec spec, Transaction payment) {
    Query query = getExecTimesQuery(spec, payment, false);
    response = spec.clients().getNetworkSvcStub(targetNodeFor(spec), useTls).getExecutionTime(query);
    timesResponse = response.getNetworkGetExecutionTime();
    if (verboseLoggingOn) {
        log.info("Exec times :: {}", asReadable(timesResponse.getExecutionTimesList()));
    }
}
Also used : Query(com.hederahashgraph.api.proto.java.Query) NetworkGetExecutionTimeQuery(com.hederahashgraph.api.proto.java.NetworkGetExecutionTimeQuery)

Example 100 with Query

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

the class GetContractInfoAnswerTest method allowsQueryingDeletedContracts.

@Test
void allowsQueryingDeletedContracts() throws Throwable {
    Query query = validQuery(COST_ANSWER, fee, target);
    given(optionValidator.queryableContractStatus(asContract(target), contracts)).willReturn(CONTRACT_DELETED);
    given(view.contracts()).willReturn(contracts);
    ResponseCodeEnum validity = subject.checkValidity(query, view);
    assertEquals(OK, validity);
}
Also used : ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) Query(com.hederahashgraph.api.proto.java.Query) ContractGetInfoQuery(com.hederahashgraph.api.proto.java.ContractGetInfoQuery) Test(org.junit.jupiter.api.Test)

Aggregations

Query (com.hederahashgraph.api.proto.java.Query)152 Test (org.junit.jupiter.api.Test)108 Response (com.hederahashgraph.api.proto.java.Response)95 ResponseCodeEnum (com.hederahashgraph.api.proto.java.ResponseCodeEnum)24 ContractCallLocalQuery (com.hederahashgraph.api.proto.java.ContractCallLocalQuery)13 TokenGetNftInfoQuery (com.hederahashgraph.api.proto.java.TokenGetNftInfoQuery)13 ContractGetInfoQuery (com.hederahashgraph.api.proto.java.ContractGetInfoQuery)11 ByteString (com.google.protobuf.ByteString)10 ConsensusGetTopicInfoQuery (com.hederahashgraph.api.proto.java.ConsensusGetTopicInfoQuery)10 ScheduleGetInfoQuery (com.hederahashgraph.api.proto.java.ScheduleGetInfoQuery)10 TokenGetInfoQuery (com.hederahashgraph.api.proto.java.TokenGetInfoQuery)10 CryptoGetAccountBalanceQuery (com.hederahashgraph.api.proto.java.CryptoGetAccountBalanceQuery)9 CryptoGetInfoQuery (com.hederahashgraph.api.proto.java.CryptoGetInfoQuery)9 FileGetInfoQuery (com.hederahashgraph.api.proto.java.FileGetInfoQuery)8 NetworkGetExecutionTimeQuery (com.hederahashgraph.api.proto.java.NetworkGetExecutionTimeQuery)8 HashMap (java.util.HashMap)8 ContractCallLocalResponse (com.hederahashgraph.api.proto.java.ContractCallLocalResponse)7 ContractGetBytecodeQuery (com.hederahashgraph.api.proto.java.ContractGetBytecodeQuery)7 FileGetContentsQuery (com.hederahashgraph.api.proto.java.FileGetContentsQuery)7 FileGetInfoResponse (com.hederahashgraph.api.proto.java.FileGetInfoResponse)7