Search in sources :

Example 76 with Transaction

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);
}
Also used : TokenTransferList(com.hederahashgraph.api.proto.java.TokenTransferList) Transaction(com.hederahashgraph.api.proto.java.Transaction) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 77 with Transaction

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());
}
Also used : TokenTransferList(com.hederahashgraph.api.proto.java.TokenTransferList) Transaction(com.hederahashgraph.api.proto.java.Transaction) ContractFunctionResult(com.hederahashgraph.api.proto.java.ContractFunctionResult) AtomicReference(java.util.concurrent.atomic.AtomicReference)

Example 78 with Transaction

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);
}
Also used : Transaction(com.hederahashgraph.api.proto.java.Transaction) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 79 with Transaction

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);
}
Also used : TokenTransferList(com.hederahashgraph.api.proto.java.TokenTransferList) Transaction(com.hederahashgraph.api.proto.java.Transaction) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 80 with Transaction

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);
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) EntityId(com.hedera.mirror.common.domain.entity.EntityId) FixedFee(com.hederahashgraph.api.proto.java.FixedFee) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) StringValue(com.google.protobuf.StringValue) Duration(com.hederahashgraph.api.proto.java.Duration) NftTransfer(com.hederahashgraph.api.proto.java.NftTransfer) StringUtils(org.apache.commons.lang3.StringUtils) EntityType(com.hedera.mirror.common.domain.entity.EntityType) TokenTransferList(com.hederahashgraph.api.proto.java.TokenTransferList) Token(com.hedera.mirror.common.domain.token.Token) TokenId(com.hedera.mirror.common.domain.token.TokenId) TestUtils(com.hedera.mirror.importer.TestUtils) MethodSource(org.junit.jupiter.params.provider.MethodSource) ContractResult(com.hedera.mirror.common.domain.contract.ContractResult) TokenRepository(com.hedera.mirror.importer.repository.TokenRepository) TokenFreezeStatusEnum(com.hedera.mirror.common.domain.token.TokenFreezeStatusEnum) Assertions.from(org.assertj.core.api.Assertions.from) EntityIdEndec(com.hedera.mirror.common.domain.entity.EntityIdEndec) Resource(javax.annotation.Resource) TokenPauseStatusEnum(com.hedera.mirror.common.domain.token.TokenPauseStatusEnum) Arguments(org.junit.jupiter.params.provider.Arguments) Collectors(java.util.stream.Collectors) ByteString(com.google.protobuf.ByteString) Test(org.junit.jupiter.api.Test) CustomFee(com.hedera.mirror.common.domain.transaction.CustomFee) AccountAmount(com.hederahashgraph.api.proto.java.AccountAmount) List(java.util.List) Nft(com.hedera.mirror.common.domain.token.Nft) Stream(java.util.stream.Stream) Builder(lombok.Builder) AssessedCustomFeeWrapper(com.hedera.mirror.importer.domain.AssessedCustomFeeWrapper) Lists(org.assertj.core.util.Lists) TokenAccountRepository(com.hedera.mirror.importer.repository.TokenAccountRepository) ObjectAssert(org.assertj.core.api.ObjectAssert) NftTransferId(com.hedera.mirror.common.domain.token.NftTransferId) Optional(java.util.Optional) TokenAccount(com.hedera.mirror.common.domain.token.TokenAccount) TokenAssociation(com.hederahashgraph.api.proto.java.TokenAssociation) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) Transaction(com.hederahashgraph.api.proto.java.Transaction) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) NftId(com.hedera.mirror.common.domain.token.NftId) RoyaltyFee(com.hederahashgraph.api.proto.java.RoyaltyFee) EnumSource(org.junit.jupiter.params.provider.EnumSource) CustomFeeWrapper(com.hedera.mirror.importer.domain.CustomFeeWrapper) AtomicReference(java.util.concurrent.atomic.AtomicReference) ArrayList(java.util.ArrayList) JdbcTemplate(org.springframework.jdbc.core.JdbcTemplate) NftAllowance(com.hederahashgraph.api.proto.java.NftAllowance) FractionalFee(com.hederahashgraph.api.proto.java.FractionalFee) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) NftTransferRepository(com.hedera.mirror.importer.repository.NftTransferRepository) AccountID(com.hederahashgraph.api.proto.java.AccountID) AssessedCustomFee(com.hedera.mirror.common.domain.transaction.AssessedCustomFee) Timestamp(com.hederahashgraph.api.proto.java.Timestamp) NftRepository(com.hedera.mirror.importer.repository.NftRepository) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) TokenAccountId(com.hedera.mirror.common.domain.token.TokenAccountId) TokenTransferRepository(com.hedera.mirror.importer.repository.TokenTransferRepository) Entity(com.hedera.mirror.common.domain.entity.Entity) Consumer(java.util.function.Consumer) TokenType(com.hederahashgraph.api.proto.java.TokenType) Fraction(com.hederahashgraph.api.proto.java.Fraction) Key(com.hederahashgraph.api.proto.java.Key) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) TokenID(com.hederahashgraph.api.proto.java.TokenID) TokenKycStatusEnum(com.hedera.mirror.common.domain.token.TokenKycStatusEnum) Assertions(org.junit.jupiter.api.Assertions) NON_FUNGIBLE_UNIQUE(com.hederahashgraph.api.proto.java.TokenType.NON_FUNGIBLE_UNIQUE) ContractFunctionResult(com.hederahashgraph.api.proto.java.ContractFunctionResult) FUNGIBLE_COMMON(com.hederahashgraph.api.proto.java.TokenType.FUNGIBLE_COMMON) Comparator(java.util.Comparator) Collections(java.util.Collections) TokenSupplyType(com.hederahashgraph.api.proto.java.TokenSupplyType) TokenTransfer(com.hedera.mirror.common.domain.token.TokenTransfer) TokenTransferList(com.hederahashgraph.api.proto.java.TokenTransferList) Transaction(com.hederahashgraph.api.proto.java.Transaction) EntityId(com.hedera.mirror.common.domain.entity.EntityId) TokenId(com.hedera.mirror.common.domain.token.TokenId) NftTransferId(com.hedera.mirror.common.domain.token.NftTransferId) NftId(com.hedera.mirror.common.domain.token.NftId) TokenAccountId(com.hedera.mirror.common.domain.token.TokenAccountId) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Transaction (com.hederahashgraph.api.proto.java.Transaction)174 Test (org.junit.jupiter.api.Test)128 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)108 TransactionBody (com.hederahashgraph.api.proto.java.TransactionBody)93 RecordItem (com.hedera.mirror.common.domain.transaction.RecordItem)91 TransactionRecord (com.hederahashgraph.api.proto.java.TransactionRecord)84 SignedTransaction (com.hederahashgraph.api.proto.java.SignedTransaction)63 FileAppendTransactionBody (com.hederahashgraph.api.proto.java.FileAppendTransactionBody)28 FileCreateTransactionBody (com.hederahashgraph.api.proto.java.FileCreateTransactionBody)28 FileUpdateTransactionBody (com.hederahashgraph.api.proto.java.FileUpdateTransactionBody)28 UtilityTest (com.hedera.mirror.importer.util.UtilityTest)26 CryptoUpdateTransactionBody (com.hederahashgraph.api.proto.java.CryptoUpdateTransactionBody)26 CryptoAddLiveHashTransactionBody (com.hederahashgraph.api.proto.java.CryptoAddLiveHashTransactionBody)25 CryptoCreateTransactionBody (com.hederahashgraph.api.proto.java.CryptoCreateTransactionBody)25 CryptoDeleteLiveHashTransactionBody (com.hederahashgraph.api.proto.java.CryptoDeleteLiveHashTransactionBody)25 Entity (com.hedera.mirror.common.domain.entity.Entity)22 TokenTransferList (com.hederahashgraph.api.proto.java.TokenTransferList)21 ContractUpdateTransactionBody (com.hederahashgraph.api.proto.java.ContractUpdateTransactionBody)18 ContractCallTransactionBody (com.hederahashgraph.api.proto.java.ContractCallTransactionBody)17 ContractCreateTransactionBody (com.hederahashgraph.api.proto.java.ContractCreateTransactionBody)17