Search in sources :

Example 6 with TokenGrantKycTransaction

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

the class TokenGrantKycTransactionSupplierTest method createWithMinimumData.

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

Example 7 with TokenGrantKycTransaction

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

the class TokenGrantKycTransactionSupplierTest method createWithCustomData.

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

Example 8 with TokenGrantKycTransaction

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

the class TokenTransferIntegrationTest method tokenTransferTest.

@Test
@DisplayName("Can transfer tokens")
void tokenTransferTest() throws Exception {
    var testEnv = new IntegrationTestEnv(1).useThrowawayAccount();
    var key = PrivateKey.generateED25519();
    @Var TransactionResponse response = new AccountCreateTransaction().setKey(key).setInitialBalance(new Hbar(1)).execute(testEnv.client);
    var accountId = response.getReceipt(testEnv.client).accountId;
    assertThat(accountId).isNotNull();
    response = 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);
    var tokenId = response.getReceipt(testEnv.client).tokenId;
    assertThat(tokenId).isNotNull();
    new TokenAssociateTransaction().setAccountId(accountId).setTokenIds(Collections.singletonList(tokenId)).freezeWith(testEnv.client).signWithOperator(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);
    testEnv.close(tokenId, accountId, key);
}
Also used : TransactionResponse(com.hedera.hashgraph.sdk.TransactionResponse) Var(com.google.errorprone.annotations.Var) 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) AccountCreateTransaction(com.hedera.hashgraph.sdk.AccountCreateTransaction) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 9 with TokenGrantKycTransaction

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

the class TokenGrantKycIntegrationTest method canGrantKycAccountWithToken.

@Test
@DisplayName("Can grant kyc to account with token")
void canGrantKycAccountWithToken() 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).freezeWith(testEnv.client).sign(key).execute(testEnv.client).getReceipt(testEnv.client);
    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) AccountCreateTransaction(com.hedera.hashgraph.sdk.AccountCreateTransaction) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 10 with TokenGrantKycTransaction

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

the class TokenGrantKycIntegrationTest method cannotGrantKycToAccountOnTokenWhenTokenIDIsNotSet.

@Test
@DisplayName("Cannot grant kyc to account on token when token ID is not set")
void cannotGrantKycToAccountOnTokenWhenTokenIDIsNotSet() throws Exception {
    var testEnv = new IntegrationTestEnv(1);
    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 TokenGrantKycTransaction().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 : Hbar(com.hedera.hashgraph.sdk.Hbar) TokenGrantKycTransaction(com.hedera.hashgraph.sdk.TokenGrantKycTransaction) AccountCreateTransaction(com.hedera.hashgraph.sdk.AccountCreateTransaction) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

TokenGrantKycTransaction (com.hedera.hashgraph.sdk.TokenGrantKycTransaction)15 Test (org.junit.jupiter.api.Test)13 AccountCreateTransaction (com.hedera.hashgraph.sdk.AccountCreateTransaction)12 Hbar (com.hedera.hashgraph.sdk.Hbar)11 TokenCreateTransaction (com.hedera.hashgraph.sdk.TokenCreateTransaction)11 DisplayName (org.junit.jupiter.api.DisplayName)11 TokenAssociateTransaction (com.hedera.hashgraph.sdk.TokenAssociateTransaction)10 TokenWipeTransaction (com.hedera.hashgraph.sdk.TokenWipeTransaction)8 TransferTransaction (com.hedera.hashgraph.sdk.TransferTransaction)8 Var (com.google.errorprone.annotations.Var)3 TokenMintTransaction (com.hedera.hashgraph.sdk.TokenMintTransaction)3 TransactionResponse (com.hedera.hashgraph.sdk.TransactionResponse)3 AbstractTransactionSupplierTest (com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)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 TransactionReceipt (com.hedera.hashgraph.sdk.TransactionReceipt)1