Search in sources :

Example 1 with TokenRevokeKycTransaction

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);
}
Also used : TokenAssociateTransaction(com.hedera.hashgraph.sdk.TokenAssociateTransaction) TokenRevokeKycTransaction(com.hedera.hashgraph.sdk.TokenRevokeKycTransaction) 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 TokenRevokeKycTransaction

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);
}
Also used : TokenRevokeKycTransaction(com.hedera.hashgraph.sdk.TokenRevokeKycTransaction) Hbar(com.hedera.hashgraph.sdk.Hbar) AccountCreateTransaction(com.hedera.hashgraph.sdk.AccountCreateTransaction) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 3 with TokenRevokeKycTransaction

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);
}
Also used : TokenRevokeKycTransaction(com.hedera.hashgraph.sdk.TokenRevokeKycTransaction) Test(org.junit.jupiter.api.Test) AbstractTransactionSupplierTest(com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)

Example 4 with TokenRevokeKycTransaction

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;
}
Also used : NetworkTransactionResponse(com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse) TokenRevokeKycTransaction(com.hedera.hashgraph.sdk.TokenRevokeKycTransaction)

Example 5 with TokenRevokeKycTransaction

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);
}
Also used : TokenRevokeKycTransaction(com.hedera.hashgraph.sdk.TokenRevokeKycTransaction) Test(org.junit.jupiter.api.Test) AbstractTransactionSupplierTest(com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)

Aggregations

TokenRevokeKycTransaction (com.hedera.hashgraph.sdk.TokenRevokeKycTransaction)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