use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerPerformanceCryptoTest method getCreateAccountRecordItem.
private RecordItem getCreateAccountRecordItem(int accountNum) throws Exception {
Transaction createTransaction = cryptoCreateTransaction();
TransactionBody createTransactionBody = getTransactionBody(createTransaction);
TransactionRecord createRecord = transactionRecord(createTransactionBody, ResponseCodeEnum.SUCCESS.getNumber(), accountNum);
return new RecordItem(createTransaction, createRecord);
}
use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerPerformanceCryptoTest method getUpdateAccountRecordItem.
private RecordItem getUpdateAccountRecordItem(int accountNum) throws Exception {
Transaction updateTransaction = cryptoUpdateTransaction(AccountID.newBuilder().setShardNum(0).setRealmNum(0).setAccountNum(accountNum).build());
TransactionBody updateTransactionBody = getTransactionBody(updateTransaction);
TransactionRecord createRecord = transactionRecord(updateTransactionBody, ResponseCodeEnum.SUCCESS.getNumber(), accountNum);
return new RecordItem(updateTransaction, createRecord);
}
use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerScheduleTest method insertScheduleCreateTransaction.
private void insertScheduleCreateTransaction(long createdTimestamp, AccountID payer, ScheduleID scheduleID) {
Transaction createTransaction = scheduleCreateTransaction(payer);
TransactionBody createTransactionBody = getTransactionBody(createTransaction);
var createTransactionRecord = createTransactionRecord(createdTimestamp, scheduleID, createTransactionBody, SUCCESS, false);
parseRecordItemAndCommit(new RecordItem(createTransaction, createTransactionRecord));
}
use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerScheduleTest method insertScheduledTransaction.
private void insertScheduledTransaction(long signTimestamp, ScheduleID scheduleID, ResponseCodeEnum responseCodeEnum) {
Transaction scheduledTransaction = scheduledTransaction();
TransactionBody scheduledTransactionBody = getTransactionBody(scheduledTransaction);
var scheduledTransactionRecord = createTransactionRecord(signTimestamp, scheduleID, scheduledTransactionBody, responseCodeEnum, true);
parseRecordItemAndCommit(new RecordItem(scheduledTransaction, scheduledTransactionRecord));
}
use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerTokenTest method nftTransfer.
@Test
void nftTransfer() {
createAndAssociateToken(TOKEN_ID, NON_FUNGIBLE_UNIQUE, SYMBOL, CREATE_TIMESTAMP, ASSOCIATE_TIMESTAMP, PAYER2, false, false, false, 0);
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);
});
// approve allowance for nft 1
long approveAllowanceTimestamp = 25L;
var cryptoApproveAllowanceTransaction = buildTransaction(b -> b.getCryptoApproveAllowanceBuilder().addNftAllowances(NftAllowance.newBuilder().setOwner(PAYER).setTokenId(TOKEN_ID).addSerialNumbers(SERIAL_NUMBER_1).setSpender(SPENDER)));
insertAndParseTransaction(approveAllowanceTimestamp, cryptoApproveAllowanceTransaction);
var expectedNft1 = Nft.builder().id(new NftId(SERIAL_NUMBER_1, EntityId.of(TOKEN_ID))).accountId(EntityId.of(PAYER)).createdTimestamp(mintTimestamp1).deleted(false).metadata(METADATA.getBytes()).modifiedTimestamp(approveAllowanceTimestamp).spender(EntityId.of(SPENDER)).build();
assertThat(nftRepository.findById(expectedNft1.getId())).get().isEqualTo(expectedNft1);
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));
// Verify
insertAndParseTransaction(mintTimestamp2, mintTransaction2, builder -> {
builder.getReceiptBuilder().setNewTotalSupply(2L).addSerialNumbers(SERIAL_NUMBER_2);
builder.addTokenTransferLists(mintTransfer2);
});
// token transfer
Transaction transaction = tokenTransferTransaction();
TokenTransferList transferList1 = TokenTransferList.newBuilder().setToken(TOKEN_ID).addNftTransfers(NftTransfer.newBuilder().setReceiverAccountID(RECEIVER).setSenderAccountID(PAYER).setSerialNumber(SERIAL_NUMBER_1).build()).build();
TokenTransferList transferList2 = TokenTransferList.newBuilder().setToken(TOKEN_ID).addNftTransfers(NftTransfer.newBuilder().setReceiverAccountID(RECEIVER).setSenderAccountID(PAYER).setSerialNumber(SERIAL_NUMBER_2).build()).build();
long transferTimestamp = 40L;
insertAndParseTransaction(transferTimestamp, transaction, builder -> {
builder.addAllTokenTransferLists(List.of(transferList1, transferList2));
});
expectedNft1.setAccountId(EntityId.of(RECEIVER));
expectedNft1.setModifiedTimestamp(transferTimestamp);
expectedNft1.setSpender(null);
var expectedNft2 = Nft.builder().id(new NftId(SERIAL_NUMBER_2, EntityId.of(TOKEN_ID))).accountId(EntityId.of(RECEIVER)).createdTimestamp(mintTimestamp2).deleted(false).metadata(METADATA.getBytes()).modifiedTimestamp(transferTimestamp).build();
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);
assertNftTransferInRepository(transferTimestamp, 2L, TOKEN_ID, RECEIVER, PAYER);
assertThat(nftRepository.findAll()).containsExactlyInAnyOrder(expectedNft1, expectedNft2);
}
Aggregations