Search in sources :

Example 16 with TokenId

use of com.hedera.hashgraph.sdk.TokenId in project hedera-mirror-node by hashgraph.

the class TokenFeature method mintNftToken.

@Given("I mint a serial number from the token")
public void mintNftToken() {
    TokenId tokenId = tokenIds.get(0);
    networkTransactionResponse = tokenClient.mint(tokenId, RandomUtils.nextBytes(4));
    assertNotNull(networkTransactionResponse.getTransactionId());
    TransactionReceipt receipt = networkTransactionResponse.getReceipt();
    assertNotNull(receipt);
    assertThat(receipt.serials.size()).isEqualTo(1);
    long serialNumber = receipt.serials.get(0);
    assertThat(serialNumber).isPositive();
    tokenSerialNumbers.get(tokenId).add(serialNumber);
}
Also used : TransactionReceipt(com.hedera.hashgraph.sdk.TransactionReceipt) TokenId(com.hedera.hashgraph.sdk.TokenId) Given(io.cucumber.java.en.Given)

Example 17 with TokenId

use of com.hedera.hashgraph.sdk.TokenId in project hedera-mirror-node by hashgraph.

the class CryptoTransferTransactionSupplierTest method createWithCustomAllTransfer.

@Test
void createWithCustomAllTransfer() {
    TokenId nftTokenId = TokenId.fromString("0.0.21");
    Hbar transferAmount = Hbar.fromTinybars(2);
    CryptoTransferTransactionSupplier cryptoTransferTransactionSupplier = new CryptoTransferTransactionSupplier();
    cryptoTransferTransactionSupplier.setAmount(2);
    cryptoTransferTransactionSupplier.setMaxTransactionFee(1);
    cryptoTransferTransactionSupplier.setNftTokenId(nftTokenId.toString());
    cryptoTransferTransactionSupplier.setRecipientAccountId(ACCOUNT_ID_2.toString());
    cryptoTransferTransactionSupplier.setSenderAccountId(ACCOUNT_ID.toString());
    cryptoTransferTransactionSupplier.setSerialNumber(new AtomicLong(10));
    cryptoTransferTransactionSupplier.setTokenId(TOKEN_ID.toString());
    cryptoTransferTransactionSupplier.setTransferTypes(Set.of(CRYPTO, NFT, TOKEN));
    TransferTransaction actual = cryptoTransferTransactionSupplier.get();
    assertThat(actual).returns(ONE_TINYBAR, TransferTransaction::getMaxTransactionFee).satisfies(a -> assertThat(a.getHbarTransfers()).containsEntry(ACCOUNT_ID, transferAmount.negated()).containsEntry(ACCOUNT_ID_2, transferAmount)).satisfies(a -> assertThat(a).extracting(TransferTransaction::getTokenNftTransfers, MAP).hasSize(1).extractingByKey(nftTokenId, LIST).extracting("serial", "sender", "receiver").containsExactlyInAnyOrder(tuple(10L, ACCOUNT_ID, ACCOUNT_ID_2), tuple(11L, ACCOUNT_ID, ACCOUNT_ID_2))).extracting(TransferTransaction::getHbarTransfers, MAP).hasSize(2).containsEntry(ACCOUNT_ID, transferAmount.negated()).containsEntry(ACCOUNT_ID_2, transferAmount);
}
Also used : TokenId(com.hedera.hashgraph.sdk.TokenId) Assertions.tuple(org.assertj.core.api.Assertions.tuple) TransferTransaction(com.hedera.hashgraph.sdk.TransferTransaction) MAP(org.assertj.core.api.InstanceOfAssertFactories.MAP) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) TOKEN(com.hedera.mirror.monitor.publish.transaction.account.CryptoTransferTransactionSupplier.TransferType.TOKEN) Set(java.util.Set) CRYPTO(com.hedera.mirror.monitor.publish.transaction.account.CryptoTransferTransactionSupplier.TransferType.CRYPTO) NFT(com.hedera.mirror.monitor.publish.transaction.account.CryptoTransferTransactionSupplier.TransferType.NFT) Test(org.junit.jupiter.api.Test) AtomicLong(java.util.concurrent.atomic.AtomicLong) LIST(org.assertj.core.api.InstanceOfAssertFactories.LIST) Hbar(com.hedera.hashgraph.sdk.Hbar) Collections(java.util.Collections) AbstractTransactionSupplierTest(com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest) AtomicLong(java.util.concurrent.atomic.AtomicLong) Hbar(com.hedera.hashgraph.sdk.Hbar) TokenId(com.hedera.hashgraph.sdk.TokenId) TransferTransaction(com.hedera.hashgraph.sdk.TransferTransaction) Test(org.junit.jupiter.api.Test) AbstractTransactionSupplierTest(com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)

Aggregations

TokenId (com.hedera.hashgraph.sdk.TokenId)17 Then (io.cucumber.java.en.Then)5 TokenCreateTransaction (com.hedera.hashgraph.sdk.TokenCreateTransaction)4 ExpandedAccountId (com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId)4 Given (io.cucumber.java.en.Given)4 Retryable (org.springframework.retry.annotation.Retryable)4 TransferTransaction (com.hedera.hashgraph.sdk.TransferTransaction)3 AccountCreateTransaction (com.hedera.hashgraph.sdk.AccountCreateTransaction)2 AccountDeleteTransaction (com.hedera.hashgraph.sdk.AccountDeleteTransaction)2 AccountId (com.hedera.hashgraph.sdk.AccountId)2 Client (com.hedera.hashgraph.sdk.Client)2 Hbar (com.hedera.hashgraph.sdk.Hbar)2 PrivateKey (com.hedera.hashgraph.sdk.PrivateKey)2 TokenAssociateTransaction (com.hedera.hashgraph.sdk.TokenAssociateTransaction)2 TokenDeleteTransaction (com.hedera.hashgraph.sdk.TokenDeleteTransaction)2 TransactionReceipt (com.hedera.hashgraph.sdk.TransactionReceipt)2 NetworkTransactionResponse (com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse)2 Var (com.google.errorprone.annotations.Var)1 AccountBalanceQuery (com.hedera.hashgraph.sdk.AccountBalanceQuery)1 CustomFee (com.hedera.hashgraph.sdk.CustomFee)1