Search in sources :

Example 36 with Query

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

the class HapiContractCallLocal method submitWith.

@Override
protected void submitWith(HapiApiSpec spec, Transaction payment) {
    Query query = getContractCallLocal(spec, payment, false);
    response = spec.clients().getScSvcStub(targetNodeFor(spec), useTls).contractCallLocalMethod(query);
    if (verboseLoggingOn) {
        log.info(spec.logPrefix() + this + " result = " + response.getContractCallLocal().getFunctionResult());
    }
    final var rawResult = response.getContractCallLocal().getFunctionResult().getContractCallResult();
    saveResultToEntry.ifPresent(s -> spec.registry().saveBytes(s, rawResult));
    if (typedResultsObs.isPresent()) {
        final var function = CallTransaction.Function.fromJsonInterface(abi);
        final var typedResult = function.decodeResult(rawResult.toByteArray());
        typedResultsObs.get().accept(typedResult);
    }
}
Also used : Query(com.hederahashgraph.api.proto.java.Query) ContractCallLocalQuery(com.hederahashgraph.api.proto.java.ContractCallLocalQuery)

Example 37 with Query

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

the class HapiGetContractBytecode method submitWith.

@Override
protected void submitWith(HapiApiSpec spec, Transaction payment) throws Throwable {
    Query query = getContractBytecodeQuery(spec, payment, false);
    response = spec.clients().getScSvcStub(targetNodeFor(spec), useTls).contractGetBytecode(query);
    final var code = response.getContractGetBytecodeResponse().getBytecode();
    saveResultToEntry.ifPresent(s -> spec.registry().saveBytes(s, code));
    bytecodeObs.ifPresent(obs -> obs.accept(code.toByteArray()));
}
Also used : Query(com.hederahashgraph.api.proto.java.Query) ContractGetBytecodeQuery(com.hederahashgraph.api.proto.java.ContractGetBytecodeQuery)

Example 38 with Query

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

the class HapiGetContractInfo method lookupCostWith.

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

Example 39 with Query

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

the class HapiGetContractRecords method submitWith.

@Override
protected void submitWith(HapiApiSpec spec, Transaction payment) throws Throwable {
    Query query = getContractRecordsQuery(spec, payment, false);
    response = spec.clients().getScSvcStub(targetNodeFor(spec), useTls).getTxRecordByContractID(query);
    List<TransactionRecord> records = response.getContractGetRecordsResponse().getRecordsList();
    if (verboseLoggingOn) {
        if (customLog.isPresent()) {
            customLog.get().accept(log, records);
        } else {
            log.info(records);
        }
    }
    if (snapshotDirPath.isPresent()) {
        saveSnapshots(spec, records);
    }
    if (saveRecordNum.isPresent()) {
        spec.registry().saveIntValue(saveRecordNum.get(), records.size());
    }
    if (expectationsDirPath.isPresent()) {
        checkExpectations(spec, records);
    }
}
Also used : ContractGetRecordsQuery(com.hederahashgraph.api.proto.java.ContractGetRecordsQuery) Query(com.hederahashgraph.api.proto.java.Query) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord)

Example 40 with Query

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

the class HapiGetContractRecords method lookupCostWith.

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

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