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