|
20 | 20 | import com.hedera.hashgraph.sdk.PrivateKey; |
21 | 21 | import com.hedera.hashgraph.sdk.PublicKey; |
22 | 22 | import com.hedera.hashgraph.sdk.Query; |
| 23 | +import com.hedera.hashgraph.sdk.TopicCreateTransaction; |
| 24 | +import com.hedera.hashgraph.sdk.TopicDeleteTransaction; |
| 25 | +import com.hedera.hashgraph.sdk.TopicMessageSubmitTransaction; |
23 | 26 | import com.hedera.hashgraph.sdk.Transaction; |
24 | 27 | import com.hedera.hashgraph.sdk.TransactionReceipt; |
25 | 28 | import com.hedera.hashgraph.sdk.TransactionRecord; |
26 | 29 | import com.hedera.hashgraph.sdk.TransactionResponse; |
27 | | -import com.hedera.hashgraph.sdk.proto.ConsensusCreateTopic; |
28 | 30 | import com.openelements.hedera.base.ContractParam; |
29 | 31 | import com.openelements.hedera.base.HederaException; |
30 | 32 | import com.openelements.hedera.base.protocol.AccountBalanceRequest; |
|
52 | 54 | import com.openelements.hedera.base.protocol.FileUpdateRequest; |
53 | 55 | import com.openelements.hedera.base.protocol.FileUpdateResult; |
54 | 56 | import com.openelements.hedera.base.protocol.ProtocolLayerClient; |
| 57 | +import com.openelements.hedera.base.protocol.TopicCreateResult; |
| 58 | +import com.openelements.hedera.base.protocol.TopicDeleteRequest; |
| 59 | +import com.openelements.hedera.base.protocol.TopicDeleteResult; |
| 60 | +import com.openelements.hedera.base.protocol.TopicSubmitMessageRequest; |
| 61 | +import com.openelements.hedera.base.protocol.TopicSubmitMessageResult; |
55 | 62 | import edu.umd.cs.findbugs.annotations.NonNull; |
56 | 63 | import java.util.List; |
57 | 64 | import java.util.Objects; |
@@ -243,6 +250,44 @@ public AccountDeleteResult executeAccountDeleteTransaction(@NonNull final Accoun |
243 | 250 | return new AccountDeleteResult(record.transactionId, record.receipt.status, record.transactionHash, record.consensusTimestamp, record.transactionFee); |
244 | 251 | } |
245 | 252 |
|
| 253 | + public TopicCreateResult executeTopicCreateTransaction() throws HederaException { |
| 254 | + try { |
| 255 | + final TopicCreateTransaction transaction = new TopicCreateTransaction(); |
| 256 | + final TransactionResponse response = transaction.execute(client); |
| 257 | + final TransactionReceipt receipt = response.getReceipt(client); |
| 258 | + return new TopicCreateResult(receipt.transactionId, receipt.status, receipt.topicId); |
| 259 | + } catch (final Exception e) { |
| 260 | + throw new HederaException("Failed to execute create topic transaction", e); |
| 261 | + } |
| 262 | + } |
| 263 | + |
| 264 | + public TopicDeleteResult executeTopicDeleteTransaction(@NonNull final TopicDeleteRequest request) throws HederaException { |
| 265 | + Objects.requireNonNull(request, "request must not be null"); |
| 266 | + try { |
| 267 | + final TopicDeleteTransaction transaction = new TopicDeleteTransaction(); |
| 268 | + transaction.setTopicId(request.topicId()); |
| 269 | + final TransactionResponse response = transaction.execute(client); |
| 270 | + final TransactionReceipt receipt = response.getReceipt(client); |
| 271 | + return new TopicDeleteResult(receipt.transactionId, receipt.status); |
| 272 | + } catch (final Exception e) { |
| 273 | + throw new HederaException("Failed to execute create topic transaction", e); |
| 274 | + } |
| 275 | + } |
| 276 | + |
| 277 | + public TopicSubmitMessageResult executeTopicMessageSubmitTransaction(@NonNull final TopicSubmitMessageRequest request) throws HederaException { |
| 278 | + Objects.requireNonNull(request, "request must not be null"); |
| 279 | + try { |
| 280 | + final TopicMessageSubmitTransaction transaction = new TopicMessageSubmitTransaction(); |
| 281 | + transaction.setTopicId(request.topicId()); |
| 282 | + transaction.setMessage(request.message()); |
| 283 | + final TransactionResponse response = transaction.execute(client); |
| 284 | + final TransactionReceipt receipt = response.getReceipt(client); |
| 285 | + return new TopicSubmitMessageResult(receipt.transactionId, receipt.status); |
| 286 | + } catch (final Exception e) { |
| 287 | + throw new HederaException("Failed to execute create topic transaction", e); |
| 288 | + } |
| 289 | + } |
| 290 | + |
246 | 291 | @NonNull |
247 | 292 | private ContractFunctionParameters createParameters(@NonNull List<ContractParam<?>> params) { |
248 | 293 | Objects.requireNonNull(params, "params must not be null"); |
|
0 commit comments