Search in sources :

Example 1 with TokenAssociateTransactionBody

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);
}
Also used : Transaction(com.hederahashgraph.api.proto.java.Transaction) TokenAssociateTransactionBody(com.hederahashgraph.api.proto.java.TokenAssociateTransactionBody) HapiTxnOp(com.hedera.services.bdd.spec.transactions.HapiTxnOp) Function(java.util.function.Function) ArrayList(java.util.ArrayList) QueryVerbs.getContractInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getContractInfo) QueryVerbs.getAccountInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountInfo) TxnUtils(com.hedera.services.bdd.spec.transactions.TxnUtils) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) TransactionResponse(com.hederahashgraph.api.proto.java.TransactionResponse) MoreObjects(com.google.common.base.MoreObjects) HapiPropertySource(com.hedera.services.bdd.spec.HapiPropertySource) SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS) HapiGetAccountInfo(com.hedera.services.bdd.spec.queries.crypto.HapiGetAccountInfo) Consumer(java.util.function.Consumer) Key(com.hederahashgraph.api.proto.java.Key) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Logger(org.apache.logging.log4j.Logger) HederaFunctionality(com.hederahashgraph.api.proto.java.HederaFunctionality) Optional(java.util.Optional) TxnUtils.suFrom(com.hedera.services.bdd.spec.transactions.TxnUtils.suFrom) FeeCalculator(com.hedera.services.bdd.spec.fees.FeeCalculator) HapiGetContractInfo(com.hedera.services.bdd.spec.queries.contract.HapiGetContractInfo) TokenAssociateUsage(com.hedera.services.usage.token.TokenAssociateUsage) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) LogManager(org.apache.logging.log4j.LogManager) TokenAssociateTransactionBody(com.hederahashgraph.api.proto.java.TokenAssociateTransactionBody)

Example 2 with TokenAssociateTransactionBody

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);
        });
    }
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId) TokenAccount(com.hedera.mirror.common.domain.token.TokenAccount) TokenAssociateTransactionBody(com.hederahashgraph.api.proto.java.TokenAssociateTransactionBody)

Aggregations

TokenAssociateTransactionBody (com.hederahashgraph.api.proto.java.TokenAssociateTransactionBody)2 MoreObjects (com.google.common.base.MoreObjects)1 EntityId (com.hedera.mirror.common.domain.entity.EntityId)1 TokenAccount (com.hedera.mirror.common.domain.token.TokenAccount)1 HapiApiSpec (com.hedera.services.bdd.spec.HapiApiSpec)1 HapiPropertySource (com.hedera.services.bdd.spec.HapiPropertySource)1 FeeCalculator (com.hedera.services.bdd.spec.fees.FeeCalculator)1 QueryVerbs.getAccountInfo (com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountInfo)1 QueryVerbs.getContractInfo (com.hedera.services.bdd.spec.queries.QueryVerbs.getContractInfo)1 HapiGetContractInfo (com.hedera.services.bdd.spec.queries.contract.HapiGetContractInfo)1 HapiGetAccountInfo (com.hedera.services.bdd.spec.queries.crypto.HapiGetAccountInfo)1 HapiTxnOp (com.hedera.services.bdd.spec.transactions.HapiTxnOp)1 TxnUtils (com.hedera.services.bdd.spec.transactions.TxnUtils)1 TxnUtils.suFrom (com.hedera.services.bdd.spec.transactions.TxnUtils.suFrom)1 TokenAssociateUsage (com.hedera.services.usage.token.TokenAssociateUsage)1 HederaFunctionality (com.hederahashgraph.api.proto.java.HederaFunctionality)1 Key (com.hederahashgraph.api.proto.java.Key)1 SUCCESS (com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS)1 Transaction (com.hederahashgraph.api.proto.java.Transaction)1 TransactionBody (com.hederahashgraph.api.proto.java.TransactionBody)1