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);
}
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);
}
}
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);
}
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()));
}
}
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);
}
Aggregations