Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion tck/handlers/topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from hiero_sdk_python.account.account_id import AccountId
from hiero_sdk_python.consensus.topic_create_transaction import TopicCreateTransaction
from hiero_sdk_python.consensus.topic_delete_transaction import TopicDeleteTransaction
from hiero_sdk_python.consensus.topic_id import TopicId
from hiero_sdk_python.consensus.topic_info import TopicInfo
from hiero_sdk_python.consensus.topic_message_submit_transaction import TopicMessageSubmitTransaction
Expand All @@ -14,10 +15,11 @@
from hiero_sdk_python.transaction.transaction_receipt import TransactionReceipt
from tck.handlers.registry import rpc_method
from tck.param.custom_fee import CustomFeeLimitParams, CustomFeeParams
from tck.param.topic import CreateTopicParams, TopicMessageInfoParams, TopicMessageSubmitParams
from tck.param.topic import CreateTopicParams, DeleteTopicParams, TopicMessageInfoParams, TopicMessageSubmitParams
from tck.response.topic import (
CreateTopicResponse,
CustomFeeResponse,
DeleteTopicResponse,
FixedFeeResponse,
TopicInfoResponse,
TopicMessageSubmitResponse,
Expand Down Expand Up @@ -95,6 +97,25 @@ def create_topic(params: CreateTopicParams) -> CreateTopicResponse:
return CreateTopicResponse(topic_id, ResponseCode(receipt.status).name)


@rpc_method("deleteTopic")
def delete_topic(params: DeleteTopicParams) -> DeleteTopicResponse:
"""Delete topic."""
client = get_client(params.sessionId)
Comment thread
MonaaEid marked this conversation as resolved.

transaction = TopicDeleteTransaction().set_grpc_deadline(DEFAULT_GRPC_TIMEOUT)

if params.topicId is not None:
transaction.set_topic_id(TopicId.from_string(params.topicId))

if params.commonTransactionParams is not None:
params.commonTransactionParams.apply_common_params(transaction, client)

response = transaction.execute(client, wait_for_receipt=False)
receipt: TransactionReceipt = response.get_receipt(client, validate_status=True)

return DeleteTopicResponse(ResponseCode(receipt.status).name)
Comment thread
MonaaEid marked this conversation as resolved.


def _build_custom_fee_limit(params: CustomFeeLimitParams) -> CustomFeeLimit:
"""Build custom fee limit from params."""
custom_fee_limit = CustomFeeLimit()
Expand Down
16 changes: 16 additions & 0 deletions tck/param/topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,22 @@ def parse_json_params(cls, params: dict) -> CreateTopicParams:
)


@dataclass
class DeleteTopicParams(BaseTransactionParams):
"""Parameters for deleting a topic. Extends BaseTransactionParams to include common transaction parameters."""

topicId: str | None = None
Comment thread
MonaaEid marked this conversation as resolved.

@classmethod
def parse_json_params(cls, params: dict) -> DeleteTopicParams:
"""Parse JSON-RPC params into a DeleteTopicParams instance."""
return cls(
topicId=params.get("topicId"),
sessionId=parse_session_id(params),
commonTransactionParams=parse_common_transaction_params(params),
)


@dataclass
class TopicMessageSubmitParams(BaseTransactionParams):
"""Request parameters for submitTopicMessage endpoint."""
Expand Down
7 changes: 7 additions & 0 deletions tck/response/topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from dataclasses import dataclass

from tck.response.base import StatusOnlyResponse


@dataclass
class CreateTopicResponse:
Expand All @@ -11,6 +13,11 @@ class CreateTopicResponse:
status: str | None = None


@dataclass
class DeleteTopicResponse(StatusOnlyResponse):
"""Response payload for deleteTopic."""


@dataclass
class TopicMessageSubmitResponse:
"""Response payload for submitTopicMessage."""
Expand Down
Loading