Search in sources :

Example 6 with TokenWipeTransaction

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

the class TokenClient method wipeNonFungible.

public NetworkTransactionResponse wipeNonFungible(TokenId tokenId, long serialNumber, ExpandedAccountId expandedAccountId) {
    log.debug("Wipe serial number {} from token {}, account id {}", serialNumber, tokenId, expandedAccountId.getAccountId());
    TokenWipeTransaction transaction = getTokenWipeTransaction(tokenId, expandedAccountId).addSerial(serialNumber);
    NetworkTransactionResponse networkTransactionResponse = executeTransactionAndRetrieveReceipt(transaction);
    log.debug("Wiped serial number {} from token {}, account id {}", serialNumber, tokenId, expandedAccountId.getAccountId());
    return networkTransactionResponse;
}
Also used : NetworkTransactionResponse(com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse) TokenWipeTransaction(com.hedera.hashgraph.sdk.TokenWipeTransaction)

Example 7 with TokenWipeTransaction

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

the class TokenWipeTransactionSupplierTest method createWithMinimumData.

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

Example 8 with TokenWipeTransaction

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

the class TokenWipeTransactionSupplierTest method createWithCustomFungibleData.

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

Example 9 with TokenWipeTransaction

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

the class TokenWipeTransactionSupplierTest method createWithCustomNonFungibleData.

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

Example 10 with TokenWipeTransaction

use of com.hedera.hashgraph.sdk.TokenWipeTransaction in project hedera-sdk-java by hashgraph.

the class TokenWipeIntegrationTest method cannotWipeAccountsBalanceWhenAmountIsNotSet.

@Test
@DisplayName("Cannot wipe accounts balance when amount is not set")
void cannotWipeAccountsBalanceWhenAmountIsNotSet() throws Exception {
    var testEnv = new IntegrationTestEnv(1).useThrowawayAccount();
    var key = PrivateKey.generateED25519();
    var response = new AccountCreateTransaction().setKey(key).setInitialBalance(new Hbar(1)).execute(testEnv.client);
    var accountId = Objects.requireNonNull(response.getReceipt(testEnv.client).accountId);
    var tokenId = Objects.requireNonNull(new TokenCreateTransaction().setTokenName("ffff").setTokenSymbol("F").setDecimals(3).setInitialSupply(1000000).setTreasuryAccountId(testEnv.operatorId).setAdminKey(testEnv.operatorKey).setFreezeKey(testEnv.operatorKey).setWipeKey(testEnv.operatorKey).setKycKey(testEnv.operatorKey).setSupplyKey(testEnv.operatorKey).setFreezeDefault(false).execute(testEnv.client).getReceipt(testEnv.client).tokenId);
    new TokenAssociateTransaction().setAccountId(accountId).setTokenIds(Collections.singletonList(tokenId)).freezeWith(testEnv.client).sign(key).execute(testEnv.client).getReceipt(testEnv.client);
    new TokenGrantKycTransaction().setAccountId(accountId).setTokenId(tokenId).execute(testEnv.client).getReceipt(testEnv.client);
    new TransferTransaction().addTokenTransfer(tokenId, testEnv.operatorId, -10).addTokenTransfer(tokenId, accountId, 10).execute(testEnv.client).getReceipt(testEnv.client);
    assertThatExceptionOfType(PrecheckStatusException.class).isThrownBy(() -> {
        new TokenWipeTransaction().setTokenId(tokenId).setAccountId(accountId).execute(testEnv.client).getReceipt(testEnv.client);
    }).withMessageContaining(Status.INVALID_WIPING_AMOUNT.toString());
    testEnv.close(tokenId, accountId, key);
}
Also used : TokenAssociateTransaction(com.hedera.hashgraph.sdk.TokenAssociateTransaction) Hbar(com.hedera.hashgraph.sdk.Hbar) TokenCreateTransaction(com.hedera.hashgraph.sdk.TokenCreateTransaction) TokenGrantKycTransaction(com.hedera.hashgraph.sdk.TokenGrantKycTransaction) TransferTransaction(com.hedera.hashgraph.sdk.TransferTransaction) TokenWipeTransaction(com.hedera.hashgraph.sdk.TokenWipeTransaction) AccountCreateTransaction(com.hedera.hashgraph.sdk.AccountCreateTransaction) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

TokenWipeTransaction (com.hedera.hashgraph.sdk.TokenWipeTransaction)13 Test (org.junit.jupiter.api.Test)10 AccountCreateTransaction (com.hedera.hashgraph.sdk.AccountCreateTransaction)8 TokenAssociateTransaction (com.hedera.hashgraph.sdk.TokenAssociateTransaction)8 TokenCreateTransaction (com.hedera.hashgraph.sdk.TokenCreateTransaction)8 TokenGrantKycTransaction (com.hedera.hashgraph.sdk.TokenGrantKycTransaction)8 Hbar (com.hedera.hashgraph.sdk.Hbar)7 TransferTransaction (com.hedera.hashgraph.sdk.TransferTransaction)7 DisplayName (org.junit.jupiter.api.DisplayName)7 TokenMintTransaction (com.hedera.hashgraph.sdk.TokenMintTransaction)3 AbstractTransactionSupplierTest (com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)3 Var (com.google.errorprone.annotations.Var)2 TransactionResponse (com.hedera.hashgraph.sdk.TransactionResponse)2 NetworkTransactionResponse (com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse)2 AccountDeleteTransaction (com.hedera.hashgraph.sdk.AccountDeleteTransaction)1 AccountId (com.hedera.hashgraph.sdk.AccountId)1 Client (com.hedera.hashgraph.sdk.Client)1 PrivateKey (com.hedera.hashgraph.sdk.PrivateKey)1 TokenDeleteTransaction (com.hedera.hashgraph.sdk.TokenDeleteTransaction)1 TokenId (com.hedera.hashgraph.sdk.TokenId)1