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);
}
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;
}
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);
}
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);
}
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);
}
Aggregations