Search in sources :

Example 6 with NftTransfer

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

the class SupportDeletedTokenDissociateMigrationTest method findAllNftTransfers.

private List<NftTransfer> findAllNftTransfers() {
    return jdbcOperations.query("select * from nft_transfer", (rs, rowNum) -> {
        var receiver = rs.getLong("receiver_account_id");
        var sender = rs.getLong("sender_account_id");
        NftTransfer nftTransfer = new NftTransfer();
        nftTransfer.setId(new NftTransferId(rs.getLong("consensus_timestamp"), rs.getLong("serial_number"), EntityIdEndec.decode(rs.getLong("token_id"), TOKEN)));
        nftTransfer.setReceiverAccountId(receiver == 0 ? null : EntityIdEndec.decode(receiver, ACCOUNT));
        nftTransfer.setSenderAccountId(sender == 0 ? null : EntityIdEndec.decode(sender, ACCOUNT));
        return nftTransfer;
    });
}
Also used : NftTransfer(com.hedera.mirror.common.domain.token.NftTransfer) NftTransferId(com.hedera.mirror.common.domain.token.NftTransferId)

Example 7 with NftTransfer

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

the class SupportDeletedTokenDissociateMigrationTest method persistNftTransfers.

private void persistNftTransfers(List<NftTransfer> nftTransfers) {
    for (NftTransfer nftTransfer : nftTransfers) {
        var id = nftTransfer.getId();
        jdbcOperations.update("insert into nft_transfer (consensus_timestamp, receiver_account_id, sender_account_id, " + "serial_number, token_id)" + " values (?,?,?,?,?)", id.getConsensusTimestamp(), nftTransfer.getReceiverAccountId().getId(), nftTransfer.getSenderAccountId().getId(), id.getSerialNumber(), id.getTokenId().getId());
    }
}
Also used : NftTransfer(com.hedera.mirror.common.domain.token.NftTransfer)

Example 8 with NftTransfer

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

the class NftRepositoryTest method updateTreasury.

@Test
void updateTreasury() {
    long consensusTimestamp = 6L;
    EntityId newAccountId = EntityId.of("0.0.2", EntityType.ACCOUNT);
    Nft nft1 = nft("0.0.100", 1, 1);
    Nft nft2 = nft("0.0.100", 2, 2);
    Nft nft3 = nft("0.0.100", 3, 3);
    // Not updated since wrong token
    Nft nft4 = nft("0.0.101", 1, 4);
    // Not updated since wrong account
    Nft nft5 = nft("0.0.100", 4, 5);
    nft5.setAccountId(newAccountId);
    nftRepository.saveAll(List.of(nft1, nft2, nft3, nft4, nft5));
    EntityId tokenId = nft1.getId().getTokenId();
    EntityId previousAccountId = nft1.getAccountId();
    nftRepository.updateTreasury(tokenId.getId(), previousAccountId.getId(), newAccountId.getId(), consensusTimestamp, EntityId.of("0.0.200", EntityType.ACCOUNT).getId(), false);
    assertAccountUpdated(nft1, newAccountId);
    assertAccountUpdated(nft2, newAccountId);
    assertAccountUpdated(nft3, newAccountId);
    assertThat(nftRepository.findById(nft4.getId())).get().isEqualTo(nft4);
    assertThat(nftRepository.findById(nft5.getId())).get().isEqualTo(nft5);
    IterableAssert<NftTransfer> nftTransfers = assertThat(nftTransferRepository.findAll()).hasSize(3);
    nftTransfers.extracting(NftTransfer::getReceiverAccountId).containsOnly(newAccountId);
    nftTransfers.extracting(NftTransfer::getSenderAccountId).containsOnly(previousAccountId);
    nftTransfers.extracting(n -> n.getId().getTokenId()).containsOnly(tokenId);
    nftTransfers.extracting(n -> n.getId().getConsensusTimestamp()).containsOnly(consensusTimestamp);
    nftTransfers.extracting(n -> n.getId().getSerialNumber()).containsExactlyInAnyOrder(1L, 2L, 3L);
    nftTransfers.extracting(NftTransfer::getIsApproval).containsExactlyInAnyOrder(false, false, false);
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId) Test(org.junit.jupiter.api.Test) NftId(com.hedera.mirror.common.domain.token.NftId) IterableAssert(org.assertj.core.api.IterableAssert) List(java.util.List) Nft(com.hedera.mirror.common.domain.token.Nft) EntityId(com.hedera.mirror.common.domain.entity.EntityId) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) NftTransfer(com.hedera.mirror.common.domain.token.NftTransfer) Resource(javax.annotation.Resource) AbstractObjectAssert(org.assertj.core.api.AbstractObjectAssert) EntityType(com.hedera.mirror.common.domain.entity.EntityType) NftTransfer(com.hedera.mirror.common.domain.token.NftTransfer) Nft(com.hedera.mirror.common.domain.token.Nft) Test(org.junit.jupiter.api.Test)

Example 9 with NftTransfer

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

the class TransferTransactionPayerMigrationTest method persistNftTransfers.

private void persistNftTransfers(List<NftTransfer> nftTransfers) {
    for (NftTransfer nftTransfer : nftTransfers) {
        var id = nftTransfer.getId();
        jdbcOperations.update("insert into nft_transfer (consensus_timestamp, receiver_account_id, sender_account_id, " + "serial_number, token_id)" + " values (?,?,?,?,?)", id.getConsensusTimestamp(), nftTransfer.getReceiverAccountId().getId(), nftTransfer.getSenderAccountId().getId(), id.getSerialNumber(), id.getTokenId().getId());
    }
}
Also used : NftTransfer(com.hedera.mirror.common.domain.token.NftTransfer)

Example 10 with NftTransfer

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

the class BatchUpserterTest method getNftTransfer.

private NftTransfer getNftTransfer(EntityId tokenId, EntityId senderAccountId, long serialNumber, long consensusTimestamp) {
    NftTransfer nftTransfer = new NftTransfer();
    nftTransfer.setId(new NftTransferId(consensusTimestamp, serialNumber, tokenId));
    nftTransfer.setIsApproval(false);
    nftTransfer.setSenderAccountId(senderAccountId);
    return nftTransfer;
}
Also used : NftTransfer(com.hedera.mirror.common.domain.token.NftTransfer) NftTransferId(com.hedera.mirror.common.domain.token.NftTransferId)

Aggregations

NftTransfer (com.hedera.mirror.common.domain.token.NftTransfer)14 NftTransferId (com.hedera.mirror.common.domain.token.NftTransferId)8 Test (org.junit.jupiter.api.Test)8 IntegrationTest (com.hedera.mirror.importer.IntegrationTest)4 EntityId (com.hedera.mirror.common.domain.entity.EntityId)3 EntityType (com.hedera.mirror.common.domain.entity.EntityType)3 Nft (com.hedera.mirror.common.domain.token.Nft)3 NftId (com.hedera.mirror.common.domain.token.NftId)3 List (java.util.List)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 ByteString (com.google.protobuf.ByteString)2 DomainBuilder (com.hedera.mirror.common.domain.DomainBuilder)2 Contract (com.hedera.mirror.common.domain.contract.Contract)2 CryptoAllowance (com.hedera.mirror.common.domain.entity.CryptoAllowance)2 Entity (com.hedera.mirror.common.domain.entity.Entity)2 ACCOUNT (com.hedera.mirror.common.domain.entity.EntityType.ACCOUNT)2 TOKEN (com.hedera.mirror.common.domain.entity.EntityType.TOKEN)2 NftAllowance (com.hedera.mirror.common.domain.entity.NftAllowance)2 TokenAllowance (com.hedera.mirror.common.domain.entity.TokenAllowance)2