use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerTokenTest method tokenWipeNftMissingNft.
@Test
void tokenWipeNftMissingNft() {
createAndAssociateToken(TOKEN_ID, NON_FUNGIBLE_UNIQUE, SYMBOL, CREATE_TIMESTAMP, ASSOCIATE_TIMESTAMP, PAYER2, false, false, false, 0);
long wipeTimestamp = 15L;
TokenTransferList wipeTransfer = nftTransfer(TOKEN_ID, DEFAULT_ACCOUNT_ID, RECEIVER, List.of(SERIAL_NUMBER_1));
Transaction transaction = tokenWipeTransaction(TOKEN_ID, NON_FUNGIBLE_UNIQUE, 0, List.of(SERIAL_NUMBER_1));
insertAndParseTransaction(wipeTimestamp, transaction, builder -> {
builder.addTokenTransferLists(wipeTransfer);
});
// Verify
assertThat(nftTransferRepository.count()).isEqualTo(1L);
assertNftTransferInRepository(wipeTimestamp, SERIAL_NUMBER_1, TOKEN_ID, null, RECEIVER);
assertTokenInRepository(TOKEN_ID, true, CREATE_TIMESTAMP, wipeTimestamp, SYMBOL, 0);
assertNftInRepository(TOKEN_ID, 1L, false, wipeTimestamp, wipeTimestamp, METADATA.getBytes(), EntityId.of(PAYER), true);
}
use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerTokenTest method tokenSupplyMintNftsPrecompile.
private void tokenSupplyMintNftsPrecompile(long timestamp) {
// given
createAndAssociateToken(TOKEN_ID, NON_FUNGIBLE_UNIQUE, SYMBOL, CREATE_TIMESTAMP, ASSOCIATE_TIMESTAMP, PAYER2, false, false, false, 0);
TokenTransferList mintTransfer = nftTransfer(TOKEN_ID, PAYER, DEFAULT_ACCOUNT_ID, SERIAL_NUMBER_LIST);
Transaction transaction = tokenSupplyTransaction(TOKEN_ID, NON_FUNGIBLE_UNIQUE, true, 0, SERIAL_NUMBER_LIST);
// when
AtomicReference<ContractFunctionResult> contractFunctionResultAtomic = new AtomicReference<>();
insertAndParseTransaction(timestamp, transaction, builder -> {
builder.getReceiptBuilder().setNewTotalSupply(SERIAL_NUMBER_LIST.size()).addAllSerialNumbers(SERIAL_NUMBER_LIST);
builder.addTokenTransferLists(mintTransfer);
buildContractFunctionResult(builder.getContractCallResultBuilder());
contractFunctionResultAtomic.set(builder.getContractCallResult());
});
// then
assertThat(nftTransferRepository.count()).isEqualTo(2L);
assertNftTransferInRepository(timestamp, SERIAL_NUMBER_2, TOKEN_ID, PAYER, null);
assertNftTransferInRepository(timestamp, SERIAL_NUMBER_1, TOKEN_ID, PAYER, null);
assertTokenInRepository(TOKEN_ID, true, CREATE_TIMESTAMP, timestamp, SYMBOL, 2);
assertNftInRepository(TOKEN_ID, SERIAL_NUMBER_1, true, timestamp, timestamp, METADATA.getBytes(), EntityId.of(PAYER), false);
assertNftInRepository(TOKEN_ID, SERIAL_NUMBER_2, true, timestamp, timestamp, METADATA.getBytes(), EntityId.of(PAYER), false);
assertContractResult(timestamp, contractFunctionResultAtomic.get());
}
use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerTokenTest method tokenWipeWithMissingToken.
@Test
void tokenWipeWithMissingToken() {
Transaction transaction = tokenWipeTransaction(TOKEN_ID, FUNGIBLE_COMMON, 100L, null);
insertAndParseTransaction(10L, transaction);
assertTokenInRepository(TOKEN_ID, false, CREATE_TIMESTAMP, ASSOCIATE_TIMESTAMP, SYMBOL, INITIAL_SUPPLY);
}
use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerTokenTest method nftTransfersHaveCorrectIsApprovalValue.
@ParameterizedTest
@MethodSource("nftTransfersHaveCorrectIsApprovalValueArgumentProvider")
void nftTransfersHaveCorrectIsApprovalValue(boolean isApproval1, boolean isApproval2) {
createAndAssociateToken(TOKEN_ID, NON_FUNGIBLE_UNIQUE, SYMBOL, CREATE_TIMESTAMP, ASSOCIATE_TIMESTAMP, PAYER2, false, false, false, 0);
// mint transfer / transaction 1
long mintTimestamp1 = 20L;
TokenTransferList mintTransfer1 = nftTransfer(TOKEN_ID, RECEIVER, DEFAULT_ACCOUNT_ID, List.of(SERIAL_NUMBER_1));
Transaction mintTransaction1 = tokenSupplyTransaction(TOKEN_ID, NON_FUNGIBLE_UNIQUE, true, 0, List.of(SERIAL_NUMBER_1));
insertAndParseTransaction(mintTimestamp1, mintTransaction1, builder -> {
builder.getReceiptBuilder().setNewTotalSupply(1L).addSerialNumbers(SERIAL_NUMBER_1);
builder.addTokenTransferLists(mintTransfer1);
});
// mint transfer / transaction 2
long mintTimestamp2 = 30L;
TokenTransferList mintTransfer2 = nftTransfer(TOKEN_ID, RECEIVER, DEFAULT_ACCOUNT_ID, List.of(SERIAL_NUMBER_2));
Transaction mintTransaction2 = tokenSupplyTransaction(TOKEN_ID, NON_FUNGIBLE_UNIQUE, true, 0, List.of(SERIAL_NUMBER_2));
insertAndParseTransaction(mintTimestamp2, mintTransaction2, builder -> {
builder.getReceiptBuilder().setNewTotalSupply(2L).addSerialNumbers(SERIAL_NUMBER_2);
builder.addTokenTransferLists(mintTransfer2);
});
// token transfer
Transaction transaction = buildTransaction(builder -> {
// NFT transfer list 1
TokenTransferList transferList1 = TokenTransferList.newBuilder().setToken(TOKEN_ID).addNftTransfers(NftTransfer.newBuilder().setReceiverAccountID(RECEIVER).setSenderAccountID(PAYER).setSerialNumber(SERIAL_NUMBER_1).setIsApproval(isApproval1).build()).build();
// NFT transfer list 2
TokenTransferList transferList2 = TokenTransferList.newBuilder().setToken(TOKEN_ID).addNftTransfers(NftTransfer.newBuilder().setReceiverAccountID(RECEIVER).setSenderAccountID(PAYER).setSerialNumber(SERIAL_NUMBER_2).setIsApproval(isApproval2).build()).build();
builder.getCryptoTransferBuilder().addTokenTransfers(transferList1).addTokenTransfers(transferList2);
});
long transferTimestamp = 40L;
insertAndParseTransaction(transferTimestamp, transaction, builder -> {
// NFT transfer list 1
TokenTransferList transferList1 = TokenTransferList.newBuilder().setToken(TOKEN_ID).addNftTransfers(NftTransfer.newBuilder().setReceiverAccountID(RECEIVER).setSenderAccountID(PAYER).setSerialNumber(SERIAL_NUMBER_1).build()).build();
// NFT transfer list 2
TokenTransferList transferList2 = TokenTransferList.newBuilder().setToken(TOKEN_ID).addNftTransfers(NftTransfer.newBuilder().setReceiverAccountID(RECEIVER).setSenderAccountID(PAYER).setSerialNumber(SERIAL_NUMBER_2).build()).build();
builder.addAllTokenTransferLists(List.of(transferList1, transferList2));
});
assertThat(nftTransferRepository.count()).isEqualTo(4L);
assertNftTransferInRepository(mintTimestamp1, SERIAL_NUMBER_1, TOKEN_ID, RECEIVER, null);
assertNftTransferInRepository(mintTimestamp2, SERIAL_NUMBER_2, TOKEN_ID, RECEIVER, null);
assertNftTransferInRepository(transferTimestamp, 1L, TOKEN_ID, RECEIVER, PAYER, isApproval1);
assertNftTransferInRepository(transferTimestamp, 2L, TOKEN_ID, RECEIVER, PAYER, isApproval2);
assertNftInRepository(TOKEN_ID, SERIAL_NUMBER_1, true, mintTimestamp1, transferTimestamp, METADATA.getBytes(), EntityId.of(RECEIVER), false);
assertNftInRepository(TOKEN_ID, SERIAL_NUMBER_2, true, mintTimestamp2, transferTimestamp, METADATA.getBytes(), EntityId.of(RECEIVER), false);
}
use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerTokenTest method tokenDissociateDeletedFungibleToken.
@Test
void tokenDissociateDeletedFungibleToken() {
// given
createAndAssociateToken(TOKEN_ID, FUNGIBLE_COMMON, SYMBOL, CREATE_TIMESTAMP, ASSOCIATE_TIMESTAMP, PAYER2, false, false, false, INITIAL_SUPPLY);
long tokenDeleteTimestamp = 15L;
Transaction deleteTransaction = tokenDeleteTransaction(TOKEN_ID);
insertAndParseTransaction(tokenDeleteTimestamp, deleteTransaction);
// when
Transaction dissociateTransaction = tokenDissociate(List.of(TOKEN_ID), PAYER2);
long dissociateTimeStamp = 20L;
TokenTransferList dissociateTransfer = tokenTransfer(TOKEN_ID, PAYER2, -10);
insertAndParseTransaction(dissociateTimeStamp, dissociateTransaction, builder -> builder.addTokenTransferLists(dissociateTransfer));
// then
assertTokenInRepository(TOKEN_ID, true, CREATE_TIMESTAMP, dissociateTimeStamp, SYMBOL, INITIAL_SUPPLY - 10);
var expected = domainBuilder.tokenTransfer().customize(t -> t.amount(-10).id(new TokenTransfer.Id(dissociateTimeStamp, EntityId.of(TOKEN_ID), EntityId.of(PAYER2))).isApproval(false).payerAccountId(EntityId.of(PAYER)).tokenDissociate(false)).get();
assertThat(tokenTransferRepository.findById(expected.getId())).get().isEqualTo(expected);
}
Aggregations