Search in sources :

Example 1 with CryptoGetInfoQuery

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

the class GetAccountInfoAnswer method responseGiven.

@Override
public Response responseGiven(final Query query, final StateView view, final ResponseCodeEnum validity, final long cost) {
    final CryptoGetInfoQuery op = query.getCryptoGetInfo();
    CryptoGetInfoResponse.Builder response = CryptoGetInfoResponse.newBuilder();
    final ResponseType type = op.getHeader().getResponseType();
    if (validity != OK) {
        response.setHeader(header(validity, type, cost));
    } else {
        if (type == COST_ANSWER) {
            response.setHeader(costAnswerHeader(OK, cost));
        } else {
            AccountID id = op.getAccountID();
            var optionalInfo = view.infoForAccount(id, aliasManager);
            if (optionalInfo.isPresent()) {
                response.setHeader(answerOnlyHeader(OK));
                response.setAccountInfo(optionalInfo.get());
            } else {
                response.setHeader(answerOnlyHeader(FAIL_INVALID));
            }
        }
    }
    return Response.newBuilder().setCryptoGetInfo(response).build();
}
Also used : CryptoGetInfoResponse(com.hederahashgraph.api.proto.java.CryptoGetInfoResponse) AccountID(com.hederahashgraph.api.proto.java.AccountID) CryptoGetInfoQuery(com.hederahashgraph.api.proto.java.CryptoGetInfoQuery) ResponseType(com.hederahashgraph.api.proto.java.ResponseType)

Example 2 with CryptoGetInfoQuery

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

the class HapiGetAccountInfo method getAccountInfoQuery.

private Query getAccountInfoQuery(HapiApiSpec spec, Transaction payment, boolean costOnly) {
    AccountID target;
    if (referenceType == ReferenceType.ALIAS_KEY_NAME) {
        target = AccountID.newBuilder().setAlias(spec.registry().getKey(aliasKeySource).toByteString()).build();
    } else {
        target = TxnUtils.asId(account, spec);
    }
    CryptoGetInfoQuery query = CryptoGetInfoQuery.newBuilder().setHeader(costOnly ? answerCostHeader(payment) : answerHeader(payment)).setAccountID(target).build();
    return Query.newBuilder().setCryptoGetInfo(query).build();
}
Also used : AccountID(com.hederahashgraph.api.proto.java.AccountID) CryptoGetInfoQuery(com.hederahashgraph.api.proto.java.CryptoGetInfoQuery)

Aggregations

AccountID (com.hederahashgraph.api.proto.java.AccountID)2 CryptoGetInfoQuery (com.hederahashgraph.api.proto.java.CryptoGetInfoQuery)2 CryptoGetInfoResponse (com.hederahashgraph.api.proto.java.CryptoGetInfoResponse)1 ResponseType (com.hederahashgraph.api.proto.java.ResponseType)1