Search in sources :

Example 11 with PublicKey

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");
}
Also used : PublicKey(com.hedera.hashgraph.sdk.PublicKey) Instant(java.time.Instant) Duration(java.time.Duration) TokenUpdateTransaction(com.hedera.hashgraph.sdk.TokenUpdateTransaction) Test(org.junit.jupiter.api.Test) AbstractTransactionSupplierTest(com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)

Example 12 with PublicKey

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;
}
Also used : TopicCreateTransaction(com.hedera.hashgraph.sdk.TopicCreateTransaction) PublicKey(com.hedera.hashgraph.sdk.PublicKey)

Example 13 with PublicKey

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;
}
Also used : AccountId(com.hedera.hashgraph.sdk.AccountId) PublicKey(com.hedera.hashgraph.sdk.PublicKey) TokenUpdateTransaction(com.hedera.hashgraph.sdk.TokenUpdateTransaction)

Example 14 with PublicKey

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;
}
Also used : AccountId(com.hedera.hashgraph.sdk.AccountId) PublicKey(com.hedera.hashgraph.sdk.PublicKey) TokenCreateTransaction(com.hedera.hashgraph.sdk.TokenCreateTransaction)

Example 15 with PublicKey

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;
}
Also used : NetworkTransactionResponse(com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse) PublicKey(com.hedera.hashgraph.sdk.PublicKey) TokenUpdateTransaction(com.hedera.hashgraph.sdk.TokenUpdateTransaction)

Aggregations

PublicKey (com.hedera.hashgraph.sdk.PublicKey)25 AccountId (com.hedera.hashgraph.sdk.AccountId)9 PrivateKey (com.hedera.hashgraph.sdk.PrivateKey)9 AbstractTransactionSupplierTest (com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)8 Test (org.junit.jupiter.api.Test)8 AccountCreateTransaction (com.hedera.hashgraph.sdk.AccountCreateTransaction)7 Client (com.hedera.hashgraph.sdk.Client)6 TransactionReceipt (com.hedera.hashgraph.sdk.TransactionReceipt)6 TransactionResponse (com.hedera.hashgraph.sdk.TransactionResponse)6 Hbar (com.hedera.hashgraph.sdk.Hbar)4 KeyList (com.hedera.hashgraph.sdk.KeyList)4 TokenCreateTransaction (com.hedera.hashgraph.sdk.TokenCreateTransaction)4 TransferTransaction (com.hedera.hashgraph.sdk.TransferTransaction)4 AccountBalanceQuery (com.hedera.hashgraph.sdk.AccountBalanceQuery)3 TokenUpdateTransaction (com.hedera.hashgraph.sdk.TokenUpdateTransaction)3 TopicCreateTransaction (com.hedera.hashgraph.sdk.TopicCreateTransaction)3 NetworkTransactionResponse (com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse)3 AccountBalance (com.hedera.hashgraph.sdk.AccountBalance)2 AccountDeleteTransaction (com.hedera.hashgraph.sdk.AccountDeleteTransaction)2 ScheduleCreateTransaction (com.hedera.hashgraph.sdk.ScheduleCreateTransaction)2