use of com.hedera.mirror.common.domain.token.Nft in project hedera-mirror-node by hashgraph.
the class BatchUpserterTest method getNft.
private Nft getNft(String tokenId, long serialNumber, String accountId, Long createdTimestamp, long modifiedTimeStamp, String metadata, Boolean deleted) {
Nft nft = new Nft();
nft.setAccountId(accountId == null ? null : EntityId.of(accountId, EntityType.ACCOUNT));
nft.setCreatedTimestamp(createdTimestamp);
nft.setDeleted(deleted);
nft.setId(new NftId(serialNumber, EntityId.of(tokenId, TOKEN)));
nft.setMetadata(metadata == null ? null : metadata.getBytes(StandardCharsets.UTF_8));
nft.setModifiedTimestamp(modifiedTimeStamp);
return nft;
}
use of com.hedera.mirror.common.domain.token.Nft in project hedera-mirror-node by hashgraph.
the class NftRepositoryTest method updateAccountId.
@Test
void updateAccountId() {
Nft savedNft = nftRepository.save(nft("0.0.3", 2, 2));
EntityId accountId = EntityId.of("0.0.10", EntityType.ACCOUNT);
nftRepository.transferNftOwnership(savedNft.getId(), accountId, 3L);
savedNft.setAccountId(accountId);
savedNft.setModifiedTimestamp(3L);
assertThat(nftRepository.findById(savedNft.getId())).contains(savedNft);
}
use of com.hedera.mirror.common.domain.token.Nft 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);
}
use of com.hedera.mirror.common.domain.token.Nft in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListener method transferNftOwnership.
private void transferNftOwnership(long modifiedTimeStamp, long serialNumber, EntityId tokenId, EntityId receiverId) {
Nft nft = new Nft(serialNumber, tokenId);
nft.setAccountId(receiverId);
nft.setModifiedTimestamp(modifiedTimeStamp);
entityListener.onNft(nft);
}
use of com.hedera.mirror.common.domain.token.Nft in project hedera-mirror-node by hashgraph.
the class SupportDeletedTokenDissociateMigrationTest method nft.
private Nft nft(EntityId accountId, long createdTimestamp, boolean deleted, long modifiedTimestamp, long serialNumber, EntityId tokenId) {
Nft nft = new Nft(serialNumber, tokenId);
nft.setAccountId(accountId);
nft.setCreatedTimestamp(createdTimestamp);
nft.setDeleted(deleted);
nft.setMetadata(new byte[] { 1 });
nft.setModifiedTimestamp(modifiedTimestamp);
return nft;
}
Aggregations