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