Search in sources :

Example 11 with TopicCreateTransaction

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

the class TopicClient method createTopic.

public NetworkTransactionResponse createTopic(ExpandedAccountId adminAccount, PublicKey submitKey) {
    String memo = getMemo("Create Topic");
    TopicCreateTransaction consensusTopicCreateTransaction = new TopicCreateTransaction().setAdminKey(adminAccount.getPublicKey()).setAutoRenewAccountId(sdkClient.getExpandedOperatorAccountId().getAccountId()).setMaxTransactionFee(sdkClient.getMaxTransactionFee()).setTopicMemo(memo).setTransactionMemo(memo).setAutoRenewPeriod(// INSUFFICIENT_TX_FEE, also unsupported
    autoRenewPeriod);
    if (submitKey != null) {
        consensusTopicCreateTransaction.setSubmitKey(submitKey);
    }
    NetworkTransactionResponse networkTransactionResponse = executeTransactionAndRetrieveReceipt(consensusTopicCreateTransaction, KeyList.of(adminAccount.getPrivateKey()));
    TopicId topicId = networkTransactionResponse.getReceipt().topicId;
    log.debug("Created new topic {}", topicId);
    return networkTransactionResponse;
}
Also used : TopicCreateTransaction(com.hedera.hashgraph.sdk.TopicCreateTransaction) NetworkTransactionResponse(com.hedera.mirror.test.e2e.acceptance.response.NetworkTransactionResponse) TopicId(com.hedera.hashgraph.sdk.TopicId)

Example 12 with TopicCreateTransaction

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

the class ConsensusCreateTopicTransactionSupplierTest method createWithMinimumData.

@Test
void createWithMinimumData() {
    ConsensusCreateTopicTransactionSupplier consensusCreateTopicTransactionSupplier = new ConsensusCreateTopicTransactionSupplier();
    TopicCreateTransaction actual = consensusCreateTopicTransactionSupplier.get();
    assertThat(actual).returns(null, TopicCreateTransaction::getAdminKey).returns(null, TopicCreateTransaction::getAutoRenewAccountId).returns(MAX_TRANSACTION_FEE_HBAR, TopicCreateTransaction::getMaxTransactionFee).returns(null, TopicCreateTransaction::getSubmitKey).extracting(TopicCreateTransaction::getTopicMemo, STRING).contains("Mirror node created test topic");
}
Also used : TopicCreateTransaction(com.hedera.hashgraph.sdk.TopicCreateTransaction) Test(org.junit.jupiter.api.Test) AbstractTransactionSupplierTest(com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)

Example 13 with TopicCreateTransaction

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

the class ConsensusCreateTopicTransactionSupplierTest method createWithCustomData.

@Test
void createWithCustomData() {
    PublicKey key = PrivateKey.generate().getPublicKey();
    ConsensusCreateTopicTransactionSupplier consensusCreateTopicTransactionSupplier = new ConsensusCreateTopicTransactionSupplier();
    consensusCreateTopicTransactionSupplier.setAdminKey(key.toString());
    consensusCreateTopicTransactionSupplier.setAutoRenewAccountId(ACCOUNT_ID.toString());
    consensusCreateTopicTransactionSupplier.setMaxTransactionFee(1);
    TopicCreateTransaction actual = consensusCreateTopicTransactionSupplier.get();
    assertThat(actual).returns(key, TopicCreateTransaction::getAdminKey).returns(ACCOUNT_ID, TopicCreateTransaction::getAutoRenewAccountId).returns(ONE_TINYBAR, TopicCreateTransaction::getMaxTransactionFee).returns(key, TopicCreateTransaction::getSubmitKey).extracting(TopicCreateTransaction::getTopicMemo, STRING).contains("Mirror node created test topic");
}
Also used : TopicCreateTransaction(com.hedera.hashgraph.sdk.TopicCreateTransaction) PublicKey(com.hedera.hashgraph.sdk.PublicKey) Test(org.junit.jupiter.api.Test) AbstractTransactionSupplierTest(com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)

Example 14 with TopicCreateTransaction

use of com.hedera.hashgraph.sdk.TopicCreateTransaction 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 15 with TopicCreateTransaction

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

the class TopicCreateIntegrationTest method canCreateTopic.

@Test
@DisplayName("Can create topic")
void canCreateTopic() throws Exception {
    var testEnv = new IntegrationTestEnv(1);
    var response = new TopicCreateTransaction().setAdminKey(testEnv.operatorKey).setTopicMemo("[e2e::TopicCreateTransaction]").execute(testEnv.client);
    var topicId = Objects.requireNonNull(response.getReceipt(testEnv.client).topicId);
    new TopicDeleteTransaction().setTopicId(topicId).execute(testEnv.client).getReceipt(testEnv.client);
    testEnv.close();
}
Also used : TopicCreateTransaction(com.hedera.hashgraph.sdk.TopicCreateTransaction) TopicDeleteTransaction(com.hedera.hashgraph.sdk.TopicDeleteTransaction) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

TopicCreateTransaction (com.hedera.hashgraph.sdk.TopicCreateTransaction)26 Test (org.junit.jupiter.api.Test)19 DisplayName (org.junit.jupiter.api.DisplayName)17 TopicDeleteTransaction (com.hedera.hashgraph.sdk.TopicDeleteTransaction)15 TopicInfoQuery (com.hedera.hashgraph.sdk.TopicInfoQuery)10 TopicMessageSubmitTransaction (com.hedera.hashgraph.sdk.TopicMessageSubmitTransaction)10 Var (com.google.errorprone.annotations.Var)4 TopicMessageQuery (com.hedera.hashgraph.sdk.TopicMessageQuery)4 TransactionResponse (com.hedera.hashgraph.sdk.TransactionResponse)4 Client (com.hedera.hashgraph.sdk.Client)3 PublicKey (com.hedera.hashgraph.sdk.PublicKey)3 TopicId (com.hedera.hashgraph.sdk.TopicId)3 Hbar (com.hedera.hashgraph.sdk.Hbar)2 KeyList (com.hedera.hashgraph.sdk.KeyList)2 TransactionReceipt (com.hedera.hashgraph.sdk.TransactionReceipt)2 AbstractTransactionSupplierTest (com.hedera.mirror.monitor.publish.transaction.AbstractTransactionSupplierTest)2 AccountCreateTransaction (com.hedera.hashgraph.sdk.AccountCreateTransaction)1 MaxQueryPaymentExceededException (com.hedera.hashgraph.sdk.MaxQueryPaymentExceededException)1 PrivateKey (com.hedera.hashgraph.sdk.PrivateKey)1 ScheduleInfoQuery (com.hedera.hashgraph.sdk.ScheduleInfoQuery)1