Search in sources :

Example 1 with TokenDissociateTransactionBody

use of com.hederahashgraph.api.proto.java.TokenDissociateTransactionBody in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListener method insertTokenDissociate.

private void insertTokenDissociate(RecordItem recordItem) {
    if (entityProperties.getPersist().isTokens()) {
        TokenDissociateTransactionBody tokenDissociateTransactionBody = recordItem.getTransactionBody().getTokenDissociate();
        EntityId accountId = EntityId.of(tokenDissociateTransactionBody.getAccount());
        long consensusTimestamp = recordItem.getConsensusTimestamp();
        tokenDissociateTransactionBody.getTokensList().forEach(token -> {
            EntityId tokenId = EntityId.of(token);
            TokenAccount tokenAccount = new TokenAccount(tokenId, accountId, consensusTimestamp);
            tokenAccount.setAssociated(false);
            entityListener.onTokenAccount(tokenAccount);
        });
    }
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId) TokenDissociateTransactionBody(com.hederahashgraph.api.proto.java.TokenDissociateTransactionBody) TokenAccount(com.hedera.mirror.common.domain.token.TokenAccount)

Example 2 with TokenDissociateTransactionBody

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

the class HapiTokenDissociate method opBodyDef.

@Override
protected Consumer<TransactionBody.Builder> opBodyDef(HapiApiSpec spec) throws Throwable {
    var aId = TxnUtils.asId(account, spec);
    TokenDissociateTransactionBody opBody = spec.txns().<TokenDissociateTransactionBody, TokenDissociateTransactionBody.Builder>body(TokenDissociateTransactionBody.class, b -> {
        b.setAccount(aId);
        b.addAllTokens(tokens.stream().map(lit -> TxnUtils.asTokenId(lit, spec)).collect(toList()));
    });
    return b -> b.setTokenDissociate(opBody);
}
Also used : Transaction(com.hederahashgraph.api.proto.java.Transaction) HapiTxnOp(com.hedera.services.bdd.spec.transactions.HapiTxnOp) TokenDissociateUsage(com.hedera.services.usage.token.TokenDissociateUsage) FeeData(com.hederahashgraph.api.proto.java.FeeData) MoreObjects(com.google.common.base.MoreObjects) Function(java.util.function.Function) ArrayList(java.util.ArrayList) 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) TxnUtils(com.hedera.services.bdd.spec.transactions.TxnUtils) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) HederaFunctionality(com.hederahashgraph.api.proto.java.HederaFunctionality) TxnUtils.suFrom(com.hedera.services.bdd.spec.transactions.TxnUtils.suFrom) TokenDissociateTransactionBody(com.hederahashgraph.api.proto.java.TokenDissociateTransactionBody) TransactionResponse(com.hederahashgraph.api.proto.java.TransactionResponse) SigValueObj(com.hederahashgraph.fee.SigValueObj) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) LogManager(org.apache.logging.log4j.LogManager) TokenDissociateTransactionBody(com.hederahashgraph.api.proto.java.TokenDissociateTransactionBody)

Aggregations

TokenDissociateTransactionBody (com.hederahashgraph.api.proto.java.TokenDissociateTransactionBody)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 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 TokenDissociateUsage (com.hedera.services.usage.token.TokenDissociateUsage)1 FeeData (com.hederahashgraph.api.proto.java.FeeData)1 HederaFunctionality (com.hederahashgraph.api.proto.java.HederaFunctionality)1 Key (com.hederahashgraph.api.proto.java.Key)1 Transaction (com.hederahashgraph.api.proto.java.Transaction)1 TransactionBody (com.hederahashgraph.api.proto.java.TransactionBody)1 TransactionResponse (com.hederahashgraph.api.proto.java.TransactionResponse)1 SigValueObj (com.hederahashgraph.fee.SigValueObj)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Consumer (java.util.function.Consumer)1 Function (java.util.function.Function)1