use of com.hederahashgraph.api.proto.java.TokenAssociateTransactionBody in project hedera-services by hashgraph.
the class HapiTokenAssociate method opBodyDef.
@Override
protected Consumer<TransactionBody.Builder> opBodyDef(HapiApiSpec spec) throws Throwable {
var aId = TxnUtils.asId(account, spec);
TokenAssociateTransactionBody opBody = spec.txns().<TokenAssociateTransactionBody, TokenAssociateTransactionBody.Builder>body(TokenAssociateTransactionBody.class, b -> {
b.setAccount(aId);
b.addAllTokens(tokens.stream().map(lit -> TxnUtils.asTokenId(lit, spec)).collect(toList()));
});
return b -> b.setTokenAssociate(opBody);
}
use of com.hederahashgraph.api.proto.java.TokenAssociateTransactionBody in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListener method insertTokenAssociate.
private void insertTokenAssociate(RecordItem recordItem) {
if (entityProperties.getPersist().isTokens()) {
TokenAssociateTransactionBody transactionBody = recordItem.getTransactionBody().getTokenAssociate();
EntityId accountId = EntityId.of(transactionBody.getAccount());
long consensusTimestamp = recordItem.getConsensusTimestamp();
transactionBody.getTokensList().forEach(token -> {
EntityId tokenId = EntityId.of(token);
TokenAccount tokenAccount = getAssociatedTokenAccount(accountId, false, consensusTimestamp, tokenId);
entityListener.onTokenAccount(tokenAccount);
});
}
}
Aggregations