use of com.hedera.hashgraph.sdk.TokenRevokeKycTransaction in project hedera-sdk-java by hashgraph.
the class TokenRevokeKycIntegrationTest method canRevokeKycAccountWithToken.
@Test
@DisplayName("Can revoke kyc to account with token")
void canRevokeKycAccountWithToken() 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 TokenRevokeKycTransaction().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.TokenRevokeKycTransaction in project hedera-sdk-java by hashgraph.
the class TokenRevokeKycIntegrationTest method cannotRevokeKycToAccountOnTokenWhenTokenIDIsNotSet.
@Test
@DisplayName("Cannot revoke kyc to account on token when token ID is not set")
void cannotRevokeKycToAccountOnTokenWhenTokenIDIsNotSet() 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);
assertThatExceptionOfType(PrecheckStatusException.class).isThrownBy(() -> {
new TokenRevokeKycTransaction().setAccountId(accountId).freezeWith(testEnv.client).sign(key).execute(testEnv.client).getReceipt(testEnv.client);
}).withMessageContaining(Status.INVALID_TOKEN_ID.toString());
testEnv.close(accountId, key);
}
use of com.hedera.hashgraph.sdk.TokenRevokeKycTransaction in project hedera-mirror-node by hashgraph.
the class TokenRevokeKycTransactionSupplierTest method createWithMinimumData.
@Test
void createWithMinimumData() {
TokenRevokeKycTransactionSupplier tokenRevokeKycTransactionSupplier = new TokenRevokeKycTransactionSupplier();
tokenRevokeKycTransactionSupplier.setAccountId(ACCOUNT_ID.toString());
tokenRevokeKycTransactionSupplier.setTokenId(TOKEN_ID.toString());
TokenRevokeKycTransaction actual = tokenRevokeKycTransactionSupplier.get();
assertThat(actual).returns(ACCOUNT_ID, TokenRevokeKycTransaction::getAccountId).returns(MAX_TRANSACTION_FEE_HBAR, TokenRevokeKycTransaction::getMaxTransactionFee).returns(TOKEN_ID, TokenRevokeKycTransaction::getTokenId);
}
use of com.hedera.hashgraph.sdk.TokenRevokeKycTransaction in project hedera-mirror-node by hashgraph.
the class TokenClient method revokeKyc.
public NetworkTransactionResponse revokeKyc(TokenId tokenId, AccountId accountId) {
log.debug("Grant account {} with KYC for token {}", accountId, tokenId);
TokenRevokeKycTransaction tokenRevokeKycTransaction = new TokenRevokeKycTransaction().setAccountId(accountId).setTokenId(tokenId).setMaxTransactionFee(sdkClient.getMaxTransactionFee()).setTransactionMemo(getMemo("Revoke kyc for token"));
NetworkTransactionResponse networkTransactionResponse = executeTransactionAndRetrieveReceipt(tokenRevokeKycTransaction);
log.debug("Revoked Kyc for account {} with token {}", accountId, tokenId);
return networkTransactionResponse;
}
use of com.hedera.hashgraph.sdk.TokenRevokeKycTransaction in project hedera-mirror-node by hashgraph.
the class TokenRevokeKycTransactionSupplierTest method createWithCustomData.
@Test
void createWithCustomData() {
TokenRevokeKycTransactionSupplier tokenRevokeKycTransactionSupplier = new TokenRevokeKycTransactionSupplier();
tokenRevokeKycTransactionSupplier.setAccountId(ACCOUNT_ID.toString());
tokenRevokeKycTransactionSupplier.setMaxTransactionFee(1);
tokenRevokeKycTransactionSupplier.setTokenId(TOKEN_ID.toString());
TokenRevokeKycTransaction actual = tokenRevokeKycTransactionSupplier.get();
assertThat(actual).returns(ACCOUNT_ID, TokenRevokeKycTransaction::getAccountId).returns(ONE_TINYBAR, TokenRevokeKycTransaction::getMaxTransactionFee).returns(TOKEN_ID, TokenRevokeKycTransaction::getTokenId);
}
Aggregations