use of com.hederahashgraph.api.proto.java.AccountID in project hedera-services by hashgraph.
the class TypedTokenStore method commitToken.
/**
* Persists the given token to the Swirlds state, inviting the injected {@link TransactionRecordService}
* to update the {@link com.hedera.services.state.submerkle.ExpirableTxnRecord} of the active transaction
* with these changes.
*
* @param token
* the token to save
*/
public void commitToken(Token token) {
final var mutableToken = tokens.getRef(token.getId().asGrpcToken());
mapModelChanges(token, mutableToken);
tokens.put(token.getId().asGrpcToken(), mutableToken);
if (token.hasMintedUniqueTokens()) {
persistMinted(token.mintedUniqueTokens());
}
if (token.hasRemovedUniqueTokens()) {
destroyRemoved(token.removedUniqueTokens());
}
/* Only needed during HTS refactor. Will be removed once all operations that
* refer to the knownTreasuries in-memory structure are refactored */
if (token.isDeleted()) {
final AccountID affectedTreasury = token.getTreasury().getId().asGrpcAccount();
final TokenID mutatedToken = token.getId().asGrpcToken();
delegate.removeKnownTreasuryForToken(affectedTreasury, mutatedToken);
}
sideEffectsTracker.trackTokenChanges(token);
}
use of com.hederahashgraph.api.proto.java.AccountID in project hedera-services by hashgraph.
the class GetAccountBalanceAnswerTest method answersWithAccountBalance.
@Test
void answersWithAccountBalance() {
AccountID id = asAccount(accountIdLit);
// given:
CryptoGetAccountBalanceQuery op = CryptoGetAccountBalanceQuery.newBuilder().setAccountID(id).build();
Query query = Query.newBuilder().setCryptogetAccountBalance(op).build();
// when:
Response response = subject.responseGiven(query, view, OK);
ResponseCodeEnum status = response.getCryptogetAccountBalance().getHeader().getNodeTransactionPrecheckCode();
long answer = response.getCryptogetAccountBalance().getBalance();
// expect:
assertTrue(response.getCryptogetAccountBalance().hasHeader(), "Missing response header!");
assertEquals(List.of(tokenBalanceWith(aToken, aBalance, 1), tokenBalanceWith(bToken, bBalance, 2), tokenBalanceWith(cToken, cBalance, 123), tokenBalanceWith(dToken, dBalance, 0)), response.getCryptogetAccountBalance().getTokenBalancesList());
assertEquals(OK, status);
assertEquals(balance, answer);
assertEquals(id, response.getCryptogetAccountBalance().getAccountID());
}
use of com.hederahashgraph.api.proto.java.AccountID in project hedera-services by hashgraph.
the class GetAccountBalanceAnswerTest method syntaxCheckValidatesIdIfPresent.
@Test
void syntaxCheckValidatesIdIfPresent() {
// setup:
AccountID id = asAccount(accountIdLit);
// given:
CryptoGetAccountBalanceQuery op = CryptoGetAccountBalanceQuery.newBuilder().setAccountID(id).build();
Query query = Query.newBuilder().setCryptogetAccountBalance(op).build();
// and:
given(optionValidator.queryableAccountStatus(id, accounts)).willReturn(ACCOUNT_DELETED);
// when:
ResponseCodeEnum status = subject.checkValidity(query, view);
// expect:
assertEquals(ACCOUNT_DELETED, status);
}
use of com.hederahashgraph.api.proto.java.AccountID in project hedera-services by hashgraph.
the class AccountInfoAsserts method solidityId.
public AccountInfoAsserts solidityId(String cid) {
registerProvider((spec, o) -> {
AccountID id = spec.registry().getAccountID(cid);
final var solidityId = HapiPropertySource.asHexedSolidityAddress(id);
assertEquals(solidityId, ((AccountInfo) o).getContractAccountID(), "Bad Solidity contract Id!");
});
return this;
}
use of com.hederahashgraph.api.proto.java.AccountID in project hedera-services by hashgraph.
the class UsableTxnId method submitOp.
@Override
protected boolean submitOp(HapiApiSpec spec) {
TransactionBody.Builder usable = TransactionBody.newBuilder();
spec.txns().defaultBodySpec().accept(usable);
if (payerId.isPresent()) {
String s = payerId.get();
AccountID id = TxnUtils.isIdLiteral(s) ? HapiPropertySource.asAccount(s) : spec.registry().getAccountID(s);
usable.setTransactionID(usable.getTransactionIDBuilder().setAccountID(id));
}
if (useScheduledInappropriately) {
usable.setTransactionID(usable.getTransactionIDBuilder().setScheduled(true));
}
spec.registry().saveTxnId(name, usable.build().getTransactionID());
return false;
}
Aggregations