use of com.hedera.hashgraph.sdk.PublicKey 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.PublicKey in project hedera-mirror-node by hashgraph.
the class ConsensusCreateTopicTransactionSupplier method get.
@Override
public TopicCreateTransaction get() {
TopicCreateTransaction topicCreateTransaction = new TopicCreateTransaction().setMaxTransactionFee(Hbar.fromTinybars(maxTransactionFee)).setTopicMemo(Utility.getMemo("Mirror node created test topic"));
if (adminKey != null) {
PublicKey key = PublicKey.fromString(adminKey);
topicCreateTransaction.setAdminKey(key).setSubmitKey(key);
}
if (autoRenewAccountId != null) {
topicCreateTransaction.setAutoRenewAccountId(AccountId.fromString(autoRenewAccountId));
}
return topicCreateTransaction;
}
use of com.hedera.hashgraph.sdk.PublicKey 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;
}
use of com.hedera.hashgraph.sdk.PublicKey in project hedera-mirror-node by hashgraph.
the class TokenCreateTransactionSupplier method get.
@Override
public TokenCreateTransaction get() {
AccountId treasuryAccount = AccountId.fromString(treasuryAccountId);
TokenCreateTransaction tokenCreateTransaction = new TokenCreateTransaction().setAutoRenewAccountId(treasuryAccount).setFreezeDefault(freezeDefault).setMaxTransactionFee(Hbar.fromTinybars(maxTransactionFee)).setSupplyType(supplyType).setTokenMemo(Utility.getMemo("Mirror node created test token")).setTokenName(symbol + "_name").setTokenSymbol(symbol).setTokenType(type).setTreasuryAccountId(treasuryAccount);
if (adminKey != null) {
PublicKey key = PublicKey.fromString(adminKey);
tokenCreateTransaction.setAdminKey(key).setFeeScheduleKey(key).setFreezeKey(key).setKycKey(key).setSupplyKey(key).setWipeKey(key);
}
if (type == TokenType.FUNGIBLE_COMMON) {
tokenCreateTransaction.setDecimals(decimals).setInitialSupply(initialSupply);
}
if (supplyType == TokenSupplyType.FINITE) {
tokenCreateTransaction.setMaxSupply(maxSupply);
}
return tokenCreateTransaction;
}
use of com.hedera.hashgraph.sdk.PublicKey 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;
}
Aggregations