Search in sources :

Example 1 with TokenBurnTransaction

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

the class TokenClient method burnNonFungible.

public NetworkTransactionResponse burnNonFungible(TokenId tokenId, long serialNumber) {
    log.debug("Burn serial number {} from token {}", serialNumber, tokenId);
    TokenBurnTransaction tokenBurnTransaction = getTokenBurnTransaction(tokenId).addSerial(serialNumber).setTransactionMemo(getMemo("Token burn"));
    NetworkTransactionResponse networkTransactionResponse = executeTransactionAndRetrieveReceipt(tokenBurnTransaction);
    log.debug("Burned serial number {} from token {}", serialNumber, tokenId);
    return networkTransactionResponse;
}
Also used : NetworkTransactionResponse(com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse) TokenBurnTransaction(com.hedera.hashgraph.sdk.TokenBurnTransaction)

Example 2 with TokenBurnTransaction

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

the class TokenClient method burnFungible.

public NetworkTransactionResponse burnFungible(TokenId tokenId, long amount) {
    log.debug("Burn {} tokens from {}", amount, tokenId);
    TokenBurnTransaction tokenBurnTransaction = getTokenBurnTransaction(tokenId).setAmount(amount).setTransactionMemo(getMemo("Token burn"));
    NetworkTransactionResponse networkTransactionResponse = executeTransactionAndRetrieveReceipt(tokenBurnTransaction);
    log.debug("Burned {} extra tokens for token {}", amount, tokenId);
    return networkTransactionResponse;
}
Also used : NetworkTransactionResponse(com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse) TokenBurnTransaction(com.hedera.hashgraph.sdk.TokenBurnTransaction)

Example 3 with TokenBurnTransaction

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

the class TokenBurnTransactionSupplierTest method createWithCustomFungibleData.

@Test
void createWithCustomFungibleData() {
    TokenBurnTransactionSupplier tokenBurnTransactionSupplier = new TokenBurnTransactionSupplier();
    tokenBurnTransactionSupplier.setAmount(2);
    tokenBurnTransactionSupplier.setMaxTransactionFee(1);
    tokenBurnTransactionSupplier.setTokenId(TOKEN_ID.toString());
    tokenBurnTransactionSupplier.setType(TokenType.FUNGIBLE_COMMON);
    TokenBurnTransaction actual = tokenBurnTransactionSupplier.get();
    assertThat(actual).returns(2L, TokenBurnTransaction::getAmount).returns(ONE_TINYBAR, TokenBurnTransaction::getMaxTransactionFee).returns(Collections.emptyList(), TokenBurnTransaction::getSerials).returns(TOKEN_ID, TokenBurnTransaction::getTokenId);
}
Also used : TokenBurnTransaction(com.hedera.hashgraph.sdk.TokenBurnTransaction) Test(org.junit.jupiter.api.Test) AbstractTransactionSupplierTest(com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)

Example 4 with TokenBurnTransaction

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

the class TokenBurnTransactionSupplierTest method createWithMinimumData.

@Test
void createWithMinimumData() {
    TokenBurnTransactionSupplier tokenBurnTransactionSupplier = new TokenBurnTransactionSupplier();
    tokenBurnTransactionSupplier.setTokenId(TOKEN_ID.toString());
    TokenBurnTransaction actual = tokenBurnTransactionSupplier.get();
    assertThat(actual).returns(1L, TokenBurnTransaction::getAmount).returns(MAX_TRANSACTION_FEE_HBAR, TokenBurnTransaction::getMaxTransactionFee).returns(Collections.emptyList(), TokenBurnTransaction::getSerials).returns(TOKEN_ID, TokenBurnTransaction::getTokenId);
}
Also used : TokenBurnTransaction(com.hedera.hashgraph.sdk.TokenBurnTransaction) Test(org.junit.jupiter.api.Test) AbstractTransactionSupplierTest(com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)

Example 5 with TokenBurnTransaction

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

the class TokenBurnTransactionSupplierTest method createWithCustomNonFungibleData.

@Test
void createWithCustomNonFungibleData() {
    TokenBurnTransactionSupplier tokenBurnTransactionSupplier = new TokenBurnTransactionSupplier();
    tokenBurnTransactionSupplier.setAmount(2);
    tokenBurnTransactionSupplier.setMaxTransactionFee(1);
    tokenBurnTransactionSupplier.setSerialNumber(new AtomicLong(10));
    tokenBurnTransactionSupplier.setTokenId(TOKEN_ID.toString());
    tokenBurnTransactionSupplier.setType(TokenType.NON_FUNGIBLE_UNIQUE);
    TokenBurnTransaction actual = tokenBurnTransactionSupplier.get();
    assertThat(actual).returns(0L, TokenBurnTransaction::getAmount).returns(ONE_TINYBAR, TokenBurnTransaction::getMaxTransactionFee).returns(TOKEN_ID, TokenBurnTransaction::getTokenId).returns(Arrays.asList(10L, 11L), TokenBurnTransaction::getSerials);
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) TokenBurnTransaction(com.hedera.hashgraph.sdk.TokenBurnTransaction) Test(org.junit.jupiter.api.Test) AbstractTransactionSupplierTest(com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)

Aggregations

TokenBurnTransaction (com.hedera.hashgraph.sdk.TokenBurnTransaction)7 Test (org.junit.jupiter.api.Test)5 AbstractTransactionSupplierTest (com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)3 TokenCreateTransaction (com.hedera.hashgraph.sdk.TokenCreateTransaction)2 NetworkTransactionResponse (com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse)2 DisplayName (org.junit.jupiter.api.DisplayName)2 AccountCreateTransaction (com.hedera.hashgraph.sdk.AccountCreateTransaction)1 Hbar (com.hedera.hashgraph.sdk.Hbar)1 TokenAssociateTransaction (com.hedera.hashgraph.sdk.TokenAssociateTransaction)1 TokenMintTransaction (com.hedera.hashgraph.sdk.TokenMintTransaction)1 TransferTransaction (com.hedera.hashgraph.sdk.TransferTransaction)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1