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;
});
}
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());
}
}
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);
}
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());
}
}
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;
}
Aggregations