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