Search in sources :

Example 11 with TokenID

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

the class TokenUpdateTransactionHandlerTest method updateTransactionSuccessful.

@Test
void updateTransactionSuccessful() {
    RecordItem recordItem = recordItemBuilder.tokenUpdate().build();
    var tokenId = EntityId.of(recordItem.getTransactionBody().getTokenUpdate().getToken());
    var timestamp = recordItem.getConsensusTimestamp();
    var transaction = domainBuilder.transaction().customize(t -> t.consensusTimestamp(timestamp).entityId(tokenId)).get();
    when(entityIdService.lookup(any(AccountID.class))).thenReturn(EntityIdEndec.decode(10, EntityType.ACCOUNT));
    transactionHandler.updateTransaction(transaction, recordItem);
    assertTokenUpdate(timestamp, tokenId, id -> assertEquals(10L, id));
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) PartialDataAction(com.hedera.mirror.importer.parser.PartialDataAction) EntityId(com.hedera.mirror.common.domain.entity.EntityId) Mock(org.mockito.Mock) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) EnumSource(org.junit.jupiter.params.provider.EnumSource) Duration(com.hederahashgraph.api.proto.java.Duration) NftTransfer(com.hederahashgraph.api.proto.java.NftTransfer) EntityType(com.hedera.mirror.common.domain.entity.EntityType) TokenTransferList(com.hederahashgraph.api.proto.java.TokenTransferList) Mockito.verifyNoInteractions(org.mockito.Mockito.verifyNoInteractions) RecordParserProperties(com.hedera.mirror.importer.parser.record.RecordParserProperties) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) AliasNotFoundException(com.hedera.mirror.importer.exception.AliasNotFoundException) AccountID(com.hederahashgraph.api.proto.java.AccountID) Timestamp(com.hederahashgraph.api.proto.java.Timestamp) NftRepository(com.hedera.mirror.importer.repository.NftRepository) DomainUtils(com.hedera.mirror.common.util.DomainUtils) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) TokenUpdateTransactionBody(com.hederahashgraph.api.proto.java.TokenUpdateTransactionBody) EntityIdEndec(com.hedera.mirror.common.domain.entity.EntityIdEndec) Range(com.google.common.collect.Range) Mockito.when(org.mockito.Mockito.when) AbstractEntity(com.hedera.mirror.common.domain.entity.AbstractEntity) Mockito.verify(org.mockito.Mockito.verify) Entity(com.hedera.mirror.common.domain.entity.Entity) Consumer(java.util.function.Consumer) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) TokenID(com.hederahashgraph.api.proto.java.TokenID) Assertions(org.junit.jupiter.api.Assertions) NftTransferId(com.hedera.mirror.common.domain.token.NftTransferId) ACCOUNT(com.hedera.mirror.common.domain.entity.EntityType.ACCOUNT) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) Transaction(com.hedera.mirror.common.domain.transaction.Transaction) AccountID(com.hederahashgraph.api.proto.java.AccountID) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 12 with TokenID

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

the class EntityRecordItemListener method insertTokenTransfers.

private void insertTokenTransfers(RecordItem recordItem) {
    if (!entityProperties.getPersist().isTokens()) {
        return;
    }
    long consensusTimestamp = recordItem.getConsensusTimestamp();
    TransactionBody body = recordItem.getTransactionBody();
    boolean isTokenDissociate = body.hasTokenDissociate();
    recordItem.getRecord().getTokenTransferListsList().forEach(tokenTransferList -> {
        TokenID tokenId = tokenTransferList.getToken();
        EntityId entityTokenId = EntityId.of(tokenId);
        EntityId payerAccountId = recordItem.getPayerAccountId();
        insertFungibleTokenTransfers(consensusTimestamp, body, isTokenDissociate, tokenId, entityTokenId, payerAccountId, tokenTransferList.getTransfersList());
        insertNonFungibleTokenTransfers(consensusTimestamp, body, tokenId, entityTokenId, payerAccountId, tokenTransferList.getNftTransfersList());
    });
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId) TokenUnpauseTransactionBody(com.hederahashgraph.api.proto.java.TokenUnpauseTransactionBody) TokenRevokeKycTransactionBody(com.hederahashgraph.api.proto.java.TokenRevokeKycTransactionBody) FileAppendTransactionBody(com.hederahashgraph.api.proto.java.FileAppendTransactionBody) TokenPauseTransactionBody(com.hederahashgraph.api.proto.java.TokenPauseTransactionBody) TokenFeeScheduleUpdateTransactionBody(com.hederahashgraph.api.proto.java.TokenFeeScheduleUpdateTransactionBody) ConsensusSubmitMessageTransactionBody(com.hederahashgraph.api.proto.java.ConsensusSubmitMessageTransactionBody) TokenMintTransactionBody(com.hederahashgraph.api.proto.java.TokenMintTransactionBody) TokenAssociateTransactionBody(com.hederahashgraph.api.proto.java.TokenAssociateTransactionBody) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) FileUpdateTransactionBody(com.hederahashgraph.api.proto.java.FileUpdateTransactionBody) TokenGrantKycTransactionBody(com.hederahashgraph.api.proto.java.TokenGrantKycTransactionBody) TokenUpdateTransactionBody(com.hederahashgraph.api.proto.java.TokenUpdateTransactionBody) TokenCreateTransactionBody(com.hederahashgraph.api.proto.java.TokenCreateTransactionBody) TokenUnfreezeAccountTransactionBody(com.hederahashgraph.api.proto.java.TokenUnfreezeAccountTransactionBody) TokenWipeAccountTransactionBody(com.hederahashgraph.api.proto.java.TokenWipeAccountTransactionBody) TokenDissociateTransactionBody(com.hederahashgraph.api.proto.java.TokenDissociateTransactionBody) TokenBurnTransactionBody(com.hederahashgraph.api.proto.java.TokenBurnTransactionBody) TokenFreezeAccountTransactionBody(com.hederahashgraph.api.proto.java.TokenFreezeAccountTransactionBody) CryptoAddLiveHashTransactionBody(com.hederahashgraph.api.proto.java.CryptoAddLiveHashTransactionBody) TokenID(com.hederahashgraph.api.proto.java.TokenID)

Example 13 with TokenID

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

the class AccountBalanceLineParserV2 method parseTokenBalanceList.

private List<TokenBalance> parseTokenBalanceList(String tokenBalancesProtoString, long consensusTimestamp, EntityId accountId) throws InvalidProtocolBufferException {
    List<com.hederahashgraph.api.proto.java.TokenBalance> tokenBalanceProtoList = TokenBalances.parseFrom(Base64.decodeBase64(tokenBalancesProtoString)).getTokenBalancesList();
    List<TokenBalance> tokenBalances = new ArrayList<>();
    for (com.hederahashgraph.api.proto.java.TokenBalance tokenBalanceProto : tokenBalanceProtoList) {
        TokenID tokenId = tokenBalanceProto.getTokenId();
        TokenBalance tokenBalance = new TokenBalance(tokenBalanceProto.getBalance(), new TokenBalance.Id(consensusTimestamp, accountId, EntityId.of(tokenId)));
        tokenBalances.add(tokenBalance);
    }
    return tokenBalances;
}
Also used : ArrayList(java.util.ArrayList) TokenBalance(com.hedera.mirror.common.domain.balance.TokenBalance) TokenID(com.hederahashgraph.api.proto.java.TokenID)

Example 14 with TokenID

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

the class SignedStateBalancesExporter method addTokenBalances.

private void addTokenBalances(AccountID id, MerkleAccount account, SingleAccountBalances.Builder sabBuilder, MerkleMap<EntityNum, MerkleToken> tokens, MerkleMap<EntityNumPair, MerkleTokenRelStatus> tokenAssociations) {
    var accountTokens = account.tokens();
    for (TokenID tokenId : accountTokens.asTokenIds()) {
        var token = tokens.get(fromTokenId(tokenId));
        if (token != null) {
            var relationship = tokenAssociations.get(fromAccountTokenRel(id, tokenId));
            sabBuilder.addTokenUnitBalances(tb(tokenId, relationship.getBalance()));
        }
    }
}
Also used : TokenID(com.hederahashgraph.api.proto.java.TokenID)

Example 15 with TokenID

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

the class NftIdTest method gettersWork.

@Test
void gettersWork() {
    // given:
    final var subject = new NftId(shard, realm, num, serialNo);
    TokenID expectedTokenId = TokenID.newBuilder().setShardNum(shard).setRealmNum(realm).setTokenNum(num).build();
    assertEquals(shard, subject.shard());
    assertEquals(realm, subject.realm());
    assertEquals(num, subject.num());
    assertEquals(serialNo, subject.serialNo());
    assertEquals(expectedTokenId, subject.tokenId());
}
Also used : TokenID(com.hederahashgraph.api.proto.java.TokenID) Test(org.junit.jupiter.api.Test)

Aggregations

TokenID (com.hederahashgraph.api.proto.java.TokenID)24 AccountID (com.hederahashgraph.api.proto.java.AccountID)11 Test (org.junit.jupiter.api.Test)9 TokenTransferList (com.hederahashgraph.api.proto.java.TokenTransferList)7 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 ResponseCodeEnum (com.hederahashgraph.api.proto.java.ResponseCodeEnum)5 TokenUpdateTransactionBody (com.hederahashgraph.api.proto.java.TokenUpdateTransactionBody)5 TransactionBody (com.hederahashgraph.api.proto.java.TransactionBody)5 ByteString (com.google.protobuf.ByteString)4 AbstractEntity (com.hedera.mirror.common.domain.entity.AbstractEntity)4 EntityId (com.hedera.mirror.common.domain.entity.EntityId)4 RecordItem (com.hedera.mirror.common.domain.transaction.RecordItem)4 Transaction (com.hedera.mirror.common.domain.transaction.Transaction)4 TransactionRecord (com.hederahashgraph.api.proto.java.TransactionRecord)4 Range (com.google.common.collect.Range)3 Entity (com.hedera.mirror.common.domain.entity.Entity)3 EntityIdEndec (com.hedera.mirror.common.domain.entity.EntityIdEndec)3 EntityType (com.hedera.mirror.common.domain.entity.EntityType)3 ACCOUNT (com.hedera.mirror.common.domain.entity.EntityType.ACCOUNT)3 NftTransferId (com.hedera.mirror.common.domain.token.NftTransferId)3