use of com.hedera.hashgraph.sdk.TokenUpdateTransaction in project hedera-sdk-java by hashgraph.
the class TokenUpdateIntegrationTest method cannotUpdateImmutableToken.
@Test
@DisplayName("Cannot update immutable token")
void cannotUpdateImmutableToken() throws Exception {
var testEnv = new IntegrationTestEnv(1).useThrowawayAccount(new Hbar(10));
var response = new TokenCreateTransaction().setTokenName("ffff").setTokenSymbol("F").setTreasuryAccountId(testEnv.operatorId).setFreezeDefault(false).execute(testEnv.client);
var tokenId = Objects.requireNonNull(response.getReceipt(testEnv.client).tokenId);
assertThatExceptionOfType(ReceiptStatusException.class).isThrownBy(() -> {
new TokenUpdateTransaction().setTokenId(tokenId).setTokenName("aaaa").setTokenSymbol("A").execute(testEnv.client).getReceipt(testEnv.client);
}).withMessageContaining(Status.TOKEN_IS_IMMUTABLE.toString());
testEnv.close();
}
use of com.hedera.hashgraph.sdk.TokenUpdateTransaction in project hedera-mirror-node by hashgraph.
the class TokenClient method updateTokenTreasury.
public NetworkTransactionResponse updateTokenTreasury(TokenId tokenId, ExpandedAccountId newTreasuryId) {
AccountId treasuryAccountId = newTreasuryId.getAccountId();
String memo = getMemo("Update token");
TokenUpdateTransaction tokenUpdateTransaction = new TokenUpdateTransaction().setTokenId(tokenId).setTokenMemo(memo).setTreasuryAccountId(treasuryAccountId).setTransactionMemo(memo);
KeyList keyList = KeyList.of(newTreasuryId.getPrivateKey());
NetworkTransactionResponse networkTransactionResponse = executeTransactionAndRetrieveReceipt(tokenUpdateTransaction, keyList);
log.debug("Updated token {} treasury account {}.", tokenId, treasuryAccountId);
return networkTransactionResponse;
}
use of com.hedera.hashgraph.sdk.TokenUpdateTransaction in project hedera-mirror-node by hashgraph.
the class TokenUpdateTransactionSupplierTest method createWithCustomData.
@Test
void createWithCustomData() {
Duration autoRenewPeriod = Duration.ofSeconds(1);
Instant expirationTime = Instant.now().plus(1, ChronoUnit.DAYS);
PublicKey key = PrivateKey.generate().getPublicKey();
TokenUpdateTransactionSupplier tokenUpdateTransactionSupplier = new TokenUpdateTransactionSupplier();
tokenUpdateTransactionSupplier.setAdminKey(key.toString());
tokenUpdateTransactionSupplier.setAutoRenewPeriod(autoRenewPeriod);
tokenUpdateTransactionSupplier.setMaxTransactionFee(1);
tokenUpdateTransactionSupplier.setSymbol("TEST");
tokenUpdateTransactionSupplier.setTokenId(TOKEN_ID.toString());
tokenUpdateTransactionSupplier.setTreasuryAccountId(ACCOUNT_ID.toString());
tokenUpdateTransactionSupplier.setTokenId(TOKEN_ID.toString());
TokenUpdateTransaction actual = tokenUpdateTransactionSupplier.get();
assertThat(actual).returns(key, TokenUpdateTransaction::getAdminKey).returns(ACCOUNT_ID, TokenUpdateTransaction::getAutoRenewAccountId).returns(autoRenewPeriod, TokenUpdateTransaction::getAutoRenewPeriod).returns(null, TokenUpdateTransaction::getExpirationTime).returns(key, TokenUpdateTransaction::getFeeScheduleKey).returns(key, TokenUpdateTransaction::getFreezeKey).returns(key, TokenUpdateTransaction::getKycKey).returns(ONE_TINYBAR, TokenUpdateTransaction::getMaxTransactionFee).returns(key, TokenUpdateTransaction::getSupplyKey).returns(TOKEN_ID, TokenUpdateTransaction::getTokenId).returns("TEST_name", TokenUpdateTransaction::getTokenName).returns("TEST", TokenUpdateTransaction::getTokenSymbol).returns(ACCOUNT_ID, TokenUpdateTransaction::getTreasuryAccountId).returns(key, TokenUpdateTransaction::getWipeKey).extracting(TokenUpdateTransaction::getTokenMemo, STRING).contains("Mirror node updated test token");
}
use of com.hedera.hashgraph.sdk.TokenUpdateTransaction in project hedera-mirror-node by hashgraph.
the class TokenUpdateTransactionSupplierTest method createWithExpiration.
@Test
void createWithExpiration() {
TokenUpdateTransactionSupplier tokenUpdateTransactionSupplier = new TokenUpdateTransactionSupplier();
tokenUpdateTransactionSupplier.setTokenId(TOKEN_ID.toString());
tokenUpdateTransactionSupplier.setExpirationTime(Instant.MAX);
TokenUpdateTransaction actual = tokenUpdateTransactionSupplier.get();
assertThat(actual).returns(null, TokenUpdateTransaction::getAdminKey).returns(null, TokenUpdateTransaction::getAutoRenewAccountId).returns(null, TokenUpdateTransaction::getAutoRenewPeriod).returns(Instant.MAX, 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-mirror-node by hashgraph.
the class TokenUpdateTransactionSupplier method get.
@Override
public TokenUpdateTransaction get() {
TokenUpdateTransaction tokenUpdateTransaction = new TokenUpdateTransaction().setMaxTransactionFee(Hbar.fromTinybars(maxTransactionFee)).setTokenMemo(Utility.getMemo("Mirror node updated test token")).setTokenName(symbol + "_name").setTokenSymbol(symbol).setTokenId(TokenId.fromString(tokenId));
if (adminKey != null) {
PublicKey key = PublicKey.fromString(adminKey);
tokenUpdateTransaction.setAdminKey(key).setFeeScheduleKey(key).setFreezeKey(key).setKycKey(key).setSupplyKey(key).setWipeKey(key);
}
if (treasuryAccountId != null) {
AccountId treastury = AccountId.fromString(treasuryAccountId);
tokenUpdateTransaction.setAutoRenewAccountId(treastury).setTreasuryAccountId(treastury);
}
if (expirationTime != null) {
tokenUpdateTransaction.setExpirationTime(expirationTime);
} else {
tokenUpdateTransaction.setAutoRenewPeriod(autoRenewPeriod);
}
return tokenUpdateTransaction;
}
Aggregations