Search in sources :

Example 6 with TokenUpdateTransaction

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

the class TokenClient method updateToken.

public NetworkTransactionResponse updateToken(TokenId tokenId, ExpandedAccountId expandedAccountId) {
    PublicKey publicKey = expandedAccountId.getPublicKey();
    String newSymbol = RandomStringUtils.randomAlphabetic(4).toUpperCase();
    String memo = getMemo("Update token");
    TokenUpdateTransaction tokenUpdateTransaction = new TokenUpdateTransaction().setAdminKey(publicKey).setAutoRenewAccountId(expandedAccountId.getAccountId()).setAutoRenewPeriod(Duration.ofSeconds(8_000_001L)).setTokenName(newSymbol + "_name").setSupplyKey(publicKey).setTokenMemo(memo).setTokenSymbol(newSymbol).setTokenId(tokenId).setTransactionMemo(memo).setTreasuryAccountId(client.getOperatorAccountId()).setWipeKey(publicKey).setMaxTransactionFee(sdkClient.getMaxTransactionFee());
    NetworkTransactionResponse networkTransactionResponse = executeTransactionAndRetrieveReceipt(tokenUpdateTransaction);
    log.debug("Updated token {}.", tokenId);
    return networkTransactionResponse;
}
Also used : NetworkTransactionResponse(com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse) PublicKey(com.hedera.hashgraph.sdk.PublicKey) TokenUpdateTransaction(com.hedera.hashgraph.sdk.TokenUpdateTransaction)

Example 7 with TokenUpdateTransaction

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

the class TokenUpdateTransactionSupplierTest method createWithMinimumData.

@Test
void createWithMinimumData() {
    TokenUpdateTransactionSupplier tokenUpdateTransactionSupplier = new TokenUpdateTransactionSupplier();
    tokenUpdateTransactionSupplier.setTokenId(TOKEN_ID.toString());
    TokenUpdateTransaction actual = tokenUpdateTransactionSupplier.get();
    assertThat(actual).returns(null, TokenUpdateTransaction::getAdminKey).returns(null, TokenUpdateTransaction::getAutoRenewAccountId).returns(Duration.ofSeconds(8000000), TokenUpdateTransaction::getAutoRenewPeriod).returns(null, TokenUpdateTransaction::getExpirationTime).returns(null, TokenUpdateTransaction::getFeeScheduleKey).returns(null, TokenUpdateTransaction::getFreezeKey).returns(null, TokenUpdateTransaction::getKycKey).returns(MAX_TRANSACTION_FEE_HBAR, TokenUpdateTransaction::getMaxTransactionFee).returns(null, TokenUpdateTransaction::getSupplyKey).returns(TOKEN_ID, TokenUpdateTransaction::getTokenId).returns("HMNT_name", TokenUpdateTransaction::getTokenName).returns("HMNT", TokenUpdateTransaction::getTokenSymbol).returns(null, TokenUpdateTransaction::getTreasuryAccountId).returns(null, TokenUpdateTransaction::getWipeKey).extracting(TokenUpdateTransaction::getTokenMemo, STRING).contains("Mirror node updated test token");
}
Also used : TokenUpdateTransaction(com.hedera.hashgraph.sdk.TokenUpdateTransaction) Test(org.junit.jupiter.api.Test) AbstractTransactionSupplierTest(com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)

Example 8 with TokenUpdateTransaction

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

the class TokenUpdateIntegrationTest method canUpdateToken.

@Test
@DisplayName("Can update token")
void canUpdateToken() throws Exception {
    var testEnv = new IntegrationTestEnv(1).useThrowawayAccount();
    var 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 = Objects.requireNonNull(response.getReceipt(testEnv.client).tokenId);
    @Var var info = new TokenInfoQuery().setTokenId(tokenId).execute(testEnv.client);
    assertThat(info.tokenId).isEqualTo(tokenId);
    assertThat(info.name).isEqualTo("ffff");
    assertThat(info.symbol).isEqualTo("F");
    assertThat(info.decimals).isEqualTo(3);
    assertThat(info.treasuryAccountId).isEqualTo(testEnv.operatorId);
    assertThat(info.adminKey).isNotNull();
    assertThat(info.freezeKey).isNotNull();
    assertThat(info.wipeKey).isNotNull();
    assertThat(info.kycKey).isNotNull();
    assertThat(info.supplyKey).isNotNull();
    assertThat(info.adminKey.toString()).isEqualTo(testEnv.operatorKey.toString());
    assertThat(info.freezeKey.toString()).isEqualTo(testEnv.operatorKey.toString());
    assertThat(info.wipeKey.toString()).isEqualTo(testEnv.operatorKey.toString());
    assertThat(info.kycKey.toString()).isEqualTo(testEnv.operatorKey.toString());
    assertThat(info.supplyKey.toString()).isEqualTo(testEnv.operatorKey.toString());
    assertThat(info.defaultFreezeStatus).isNotNull().isFalse();
    assertThat(info.defaultKycStatus).isNotNull().isFalse();
    new TokenUpdateTransaction().setTokenId(tokenId).setTokenName("aaaa").setTokenSymbol("A").execute(testEnv.client).getReceipt(testEnv.client);
    info = new TokenInfoQuery().setTokenId(tokenId).execute(testEnv.client);
    assertThat(info.tokenId).isEqualTo(tokenId);
    assertThat(info.name).isEqualTo("aaaa");
    assertThat(info.symbol).isEqualTo("A");
    assertThat(info.decimals).isEqualTo(3);
    assertThat(info.treasuryAccountId).isEqualTo(testEnv.operatorId);
    assertThat(info.adminKey).isNotNull();
    assertThat(info.freezeKey).isNotNull();
    assertThat(info.wipeKey).isNotNull();
    assertThat(info.kycKey).isNotNull();
    assertThat(info.supplyKey).isNotNull();
    assertThat(info.adminKey.toString()).isEqualTo(testEnv.operatorKey.toString());
    assertThat(info.freezeKey.toString()).isEqualTo(testEnv.operatorKey.toString());
    assertThat(info.wipeKey.toString()).isEqualTo(testEnv.operatorKey.toString());
    assertThat(info.kycKey.toString()).isEqualTo(testEnv.operatorKey.toString());
    assertThat(info.supplyKey.toString()).isEqualTo(testEnv.operatorKey.toString());
    assertThat(info.defaultFreezeStatus).isNotNull();
    assertThat(info.defaultFreezeStatus).isFalse();
    assertThat(info.defaultKycStatus).isNotNull();
    assertThat(info.defaultKycStatus).isFalse();
    testEnv.close(tokenId);
}
Also used : TokenInfoQuery(com.hedera.hashgraph.sdk.TokenInfoQuery) Var(com.google.errorprone.annotations.Var) TokenCreateTransaction(com.hedera.hashgraph.sdk.TokenCreateTransaction) TokenUpdateTransaction(com.hedera.hashgraph.sdk.TokenUpdateTransaction) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

TokenUpdateTransaction (com.hedera.hashgraph.sdk.TokenUpdateTransaction)8 Test (org.junit.jupiter.api.Test)5 PublicKey (com.hedera.hashgraph.sdk.PublicKey)3 AbstractTransactionSupplierTest (com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)3 AccountId (com.hedera.hashgraph.sdk.AccountId)2 TokenCreateTransaction (com.hedera.hashgraph.sdk.TokenCreateTransaction)2 NetworkTransactionResponse (com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse)2 DisplayName (org.junit.jupiter.api.DisplayName)2 Var (com.google.errorprone.annotations.Var)1 Hbar (com.hedera.hashgraph.sdk.Hbar)1 KeyList (com.hedera.hashgraph.sdk.KeyList)1 TokenInfoQuery (com.hedera.hashgraph.sdk.TokenInfoQuery)1 ExpandedAccountId (com.hedera.mirror.test.e2e.acceptance.props.ExpandedAccountId)1 Duration (java.time.Duration)1 Instant (java.time.Instant)1