Search in sources :

Example 16 with TokenAccount

use of com.hedera.mirror.common.domain.token.TokenAccount in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListener method insertTokenAccountUnfreeze.

private void insertTokenAccountUnfreeze(RecordItem recordItem) {
    if (entityProperties.getPersist().isTokens()) {
        TokenUnfreezeAccountTransactionBody tokenUnfreezeAccountTransactionBody = recordItem.getTransactionBody().getTokenUnfreeze();
        EntityId tokenId = EntityId.of(tokenUnfreezeAccountTransactionBody.getToken());
        EntityId accountId = EntityId.of(tokenUnfreezeAccountTransactionBody.getAccount());
        long consensusTimestamp = recordItem.getConsensusTimestamp();
        TokenAccount tokenAccount = new TokenAccount(tokenId, accountId, consensusTimestamp);
        tokenAccount.setFreezeStatus(TokenFreezeStatusEnum.UNFROZEN);
        entityListener.onTokenAccount(tokenAccount);
    }
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId) TokenUnfreezeAccountTransactionBody(com.hederahashgraph.api.proto.java.TokenUnfreezeAccountTransactionBody) TokenAccount(com.hedera.mirror.common.domain.token.TokenAccount)

Example 17 with TokenAccount

use of com.hedera.mirror.common.domain.token.TokenAccount 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 18 with TokenAccount

use of com.hedera.mirror.common.domain.token.TokenAccount in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListener method getAssociatedTokenAccount.

private TokenAccount getAssociatedTokenAccount(EntityId accountId, boolean automaticAssociation, long consensusTimestamp, TokenFreezeStatusEnum freezeStatus, TokenKycStatusEnum kycStatus, EntityId tokenId) {
    TokenAccount tokenAccount = new TokenAccount(tokenId, accountId, consensusTimestamp);
    tokenAccount.setAssociated(true);
    tokenAccount.setAutomaticAssociation(automaticAssociation);
    tokenAccount.setCreatedTimestamp(consensusTimestamp);
    tokenAccount.setFreezeStatus(freezeStatus);
    tokenAccount.setKycStatus(kycStatus);
    return tokenAccount;
}
Also used : TokenAccount(com.hedera.mirror.common.domain.token.TokenAccount)

Example 19 with TokenAccount

use of com.hedera.mirror.common.domain.token.TokenAccount in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListener method insertTokenAccountFreezeBody.

private void insertTokenAccountFreezeBody(RecordItem recordItem) {
    if (entityProperties.getPersist().isTokens()) {
        TokenFreezeAccountTransactionBody transactionBody = recordItem.getTransactionBody().getTokenFreeze();
        EntityId tokenId = EntityId.of(transactionBody.getToken());
        EntityId accountId = EntityId.of(transactionBody.getAccount());
        TokenAccount tokenAccount = new TokenAccount(tokenId, accountId, recordItem.getConsensusTimestamp());
        tokenAccount.setFreezeStatus(TokenFreezeStatusEnum.FROZEN);
        entityListener.onTokenAccount(tokenAccount);
    }
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId) TokenAccount(com.hedera.mirror.common.domain.token.TokenAccount) TokenFreezeAccountTransactionBody(com.hederahashgraph.api.proto.java.TokenFreezeAccountTransactionBody)

Example 20 with TokenAccount

use of com.hedera.mirror.common.domain.token.TokenAccount in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListener method insertTokenAccountGrantKyc.

private void insertTokenAccountGrantKyc(RecordItem recordItem) {
    if (entityProperties.getPersist().isTokens()) {
        TokenGrantKycTransactionBody transactionBody = recordItem.getTransactionBody().getTokenGrantKyc();
        EntityId tokenId = EntityId.of(transactionBody.getToken());
        EntityId accountId = EntityId.of(transactionBody.getAccount());
        TokenAccount tokenAccount = new TokenAccount(tokenId, accountId, recordItem.getConsensusTimestamp());
        tokenAccount.setKycStatus(TokenKycStatusEnum.GRANTED);
        entityListener.onTokenAccount(tokenAccount);
    }
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId) TokenAccount(com.hedera.mirror.common.domain.token.TokenAccount) TokenGrantKycTransactionBody(com.hederahashgraph.api.proto.java.TokenGrantKycTransactionBody)

Aggregations

TokenAccount (com.hedera.mirror.common.domain.token.TokenAccount)27 EntityId (com.hedera.mirror.common.domain.entity.EntityId)18 Test (org.junit.jupiter.api.Test)10 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)9 Token (com.hedera.mirror.common.domain.token.Token)8 IntegrationTest (com.hedera.mirror.importer.IntegrationTest)8 Transaction (com.hederahashgraph.api.proto.java.Transaction)2 ArrayList (java.util.ArrayList)2 ByteString (com.google.protobuf.ByteString)1 Entity (com.hedera.mirror.common.domain.entity.Entity)1 TokenAccountKey (com.hedera.mirror.common.domain.token.TokenAccountKey)1 TokenFreezeStatusEnum (com.hedera.mirror.common.domain.token.TokenFreezeStatusEnum)1 TokenId (com.hedera.mirror.common.domain.token.TokenId)1 TokenKycStatusEnum (com.hedera.mirror.common.domain.token.TokenKycStatusEnum)1 TokenPauseStatusEnum (com.hedera.mirror.common.domain.token.TokenPauseStatusEnum)1 TokenTransfer (com.hedera.mirror.common.domain.token.TokenTransfer)1 Transaction (com.hedera.mirror.common.domain.transaction.Transaction)1 AccountID (com.hederahashgraph.api.proto.java.AccountID)1 ContractFunctionResult (com.hederahashgraph.api.proto.java.ContractFunctionResult)1 TokenAssociateTransactionBody (com.hederahashgraph.api.proto.java.TokenAssociateTransactionBody)1