Search in sources :

Example 1 with TokenUnfreezeTransaction

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

the class TokenUnfreezeIntegrationTest method canUnfreezeAccountWithToken.

@Test
@DisplayName("Can unfreeze account with token")
void canUnfreezeAccountWithToken() 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 TokenUnfreezeTransaction().setAccountId(accountId).setTokenId(tokenId).freezeWith(testEnv.client).sign(key).execute(testEnv.client).getReceipt(testEnv.client);
    testEnv.close(tokenId, accountId, key);
}
Also used : TokenUnfreezeTransaction(com.hedera.hashgraph.sdk.TokenUnfreezeTransaction) TokenAssociateTransaction(com.hedera.hashgraph.sdk.TokenAssociateTransaction) Hbar(com.hedera.hashgraph.sdk.Hbar) TokenCreateTransaction(com.hedera.hashgraph.sdk.TokenCreateTransaction) AccountCreateTransaction(com.hedera.hashgraph.sdk.AccountCreateTransaction) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 2 with TokenUnfreezeTransaction

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

the class TokenClient method unfreeze.

public NetworkTransactionResponse unfreeze(TokenId tokenId, AccountId accountId) {
    TokenUnfreezeTransaction tokenUnfreezeTransaction = new TokenUnfreezeTransaction().setAccountId(accountId).setMaxTransactionFee(sdkClient.getMaxTransactionFee()).setTokenId(tokenId).setTransactionMemo(getMemo("Unfreeze token account"));
    NetworkTransactionResponse response = executeTransactionAndRetrieveReceipt(tokenUnfreezeTransaction);
    log.debug("Unfreeze account {} with token {}", accountId, tokenId);
    return response;
}
Also used : TokenUnfreezeTransaction(com.hedera.hashgraph.sdk.TokenUnfreezeTransaction) NetworkTransactionResponse(com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse)

Example 3 with TokenUnfreezeTransaction

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

the class TokenUnfreezeTransactionSupplierTest method createWithMinimumData.

@Test
void createWithMinimumData() {
    TokenUnfreezeTransactionSupplier tokenUnfreezeTransactionSupplier = new TokenUnfreezeTransactionSupplier();
    tokenUnfreezeTransactionSupplier.setAccountId(ACCOUNT_ID.toString());
    tokenUnfreezeTransactionSupplier.setTokenId(TOKEN_ID.toString());
    TokenUnfreezeTransaction actual = tokenUnfreezeTransactionSupplier.get();
    assertThat(actual).returns(ACCOUNT_ID, TokenUnfreezeTransaction::getAccountId).returns(MAX_TRANSACTION_FEE_HBAR, TokenUnfreezeTransaction::getMaxTransactionFee).returns(TOKEN_ID, TokenUnfreezeTransaction::getTokenId);
}
Also used : TokenUnfreezeTransaction(com.hedera.hashgraph.sdk.TokenUnfreezeTransaction) Test(org.junit.jupiter.api.Test) AbstractTransactionSupplierTest(com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)

Example 4 with TokenUnfreezeTransaction

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

the class TokenUnfreezeTransactionSupplierTest method createWithCustomData.

@Test
void createWithCustomData() {
    TokenUnfreezeTransactionSupplier tokenUnfreezeTransactionSupplier = new TokenUnfreezeTransactionSupplier();
    tokenUnfreezeTransactionSupplier.setAccountId(ACCOUNT_ID.toString());
    tokenUnfreezeTransactionSupplier.setMaxTransactionFee(1);
    tokenUnfreezeTransactionSupplier.setTokenId(TOKEN_ID.toString());
    TokenUnfreezeTransaction actual = tokenUnfreezeTransactionSupplier.get();
    assertThat(actual).returns(ACCOUNT_ID, TokenUnfreezeTransaction::getAccountId).returns(ONE_TINYBAR, TokenUnfreezeTransaction::getMaxTransactionFee).returns(TOKEN_ID, TokenUnfreezeTransaction::getTokenId);
}
Also used : TokenUnfreezeTransaction(com.hedera.hashgraph.sdk.TokenUnfreezeTransaction) Test(org.junit.jupiter.api.Test) AbstractTransactionSupplierTest(com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)

Example 5 with TokenUnfreezeTransaction

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

the class TokenUnfreezeIntegrationTest method cannotUnfreezeAccountOnTokenWhenAccountWasNotAssociatedWith.

@Test
@DisplayName("Cannot unfreeze account on token when account was not associated with")
void cannotUnfreezeAccountOnTokenWhenAccountWasNotAssociatedWith() 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);
    assertThatExceptionOfType(ReceiptStatusException.class).isThrownBy(() -> {
        new TokenUnfreezeTransaction().setAccountId(accountId).setTokenId(tokenId).freezeWith(testEnv.client).sign(key).execute(testEnv.client).getReceipt(testEnv.client);
    }).withMessageContaining(Status.TOKEN_NOT_ASSOCIATED_TO_ACCOUNT.toString());
    testEnv.close(tokenId, accountId, key);
}
Also used : TokenUnfreezeTransaction(com.hedera.hashgraph.sdk.TokenUnfreezeTransaction) Hbar(com.hedera.hashgraph.sdk.Hbar) TokenCreateTransaction(com.hedera.hashgraph.sdk.TokenCreateTransaction) AccountCreateTransaction(com.hedera.hashgraph.sdk.AccountCreateTransaction) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

TokenUnfreezeTransaction (com.hedera.hashgraph.sdk.TokenUnfreezeTransaction)6 Test (org.junit.jupiter.api.Test)5 AccountCreateTransaction (com.hedera.hashgraph.sdk.AccountCreateTransaction)3 Hbar (com.hedera.hashgraph.sdk.Hbar)3 DisplayName (org.junit.jupiter.api.DisplayName)3 TokenCreateTransaction (com.hedera.hashgraph.sdk.TokenCreateTransaction)2 AbstractTransactionSupplierTest (com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)2 TokenAssociateTransaction (com.hedera.hashgraph.sdk.TokenAssociateTransaction)1 NetworkTransactionResponse (com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse)1