Skip to content

feat: implement endpoint for createTopic method#2215

Merged
exploreriii merged 11 commits into
hiero-ledger:mainfrom
MonaaEid:test/2207-createTopic-tck
May 15, 2026
Merged

feat: implement endpoint for createTopic method#2215
exploreriii merged 11 commits into
hiero-ledger:mainfrom
MonaaEid:test/2207-createTopic-tck

Conversation

@MonaaEid

@MonaaEid MonaaEid commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Description:
This pull request introduces a new "create topic" feature, along with improvements and refactoring to the key handling. The most significant changes are the addition of topic creation support with custom fee parameters, enhancements to key generation formatting and error handling.

New Topic Creation Feature:

  • Added a new handler tck/handlers/topic.py implementing the createTopic RPC method, supporting topic creation with custom fees, admin/submit keys, auto-renew account handling, and error mapping for various account states.
  • Introduced parameter classes in tck/param/topic.py (CreateTopicParams, CreateTopicCustomFeeParams, CreateTopicFixedFeeParams) to parse and validate topic creation parameters, including support for custom fees and key lists.
  • Added a response dataclass CreateTopicResponse in tck/response/topic.py for standardized topic creation responses.

Key Handling Improvements:

  • Refactored key generation in tck/handlers/key.py to use a helper for canonical public key formatting, improved error messages, and standardized recursive key processing and handler signatures for clarity and maintainability.

Related issue(s):

Fixes #2207

Notes for reviewer:
64 tests passed
image-1 (1).png

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

@github-actions github-actions Bot added skill: advanced requires knowledge of multiple areas in the codebase without defined steps to implement or examples lang: python Uses Python programming language scope: tests involves unit, integration, fuzz or TCK tests labels Apr 30, 2026
@github-actions

This comment was marked as resolved.

@codacy-production

codacy-production Bot commented Apr 30, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

…CK handlers

Signed-off-by: MonaaEid <monaa_eid@hotmail.com>
@MonaaEid
MonaaEid force-pushed the test/2207-createTopic-tck branch from 582ac6e to 376553e Compare May 1, 2026 03:52
…CK handlers

Signed-off-by: MonaaEid <monaa_eid@hotmail.com>
@MonaaEid
MonaaEid force-pushed the test/2207-createTopic-tck branch from 7fd7283 to 86e567c Compare May 1, 2026 14:20
…CK handlers

Signed-off-by: MonaaEid <monaa_eid@hotmail.com>
@MonaaEid
MonaaEid marked this pull request as ready for review May 1, 2026 14:48
@MonaaEid
MonaaEid requested review from a team as code owners May 1, 2026 14:48
@MonaaEid
MonaaEid requested review from Adityarya11, Copilot and nadineloepfe and removed request for Copilot May 1, 2026 14:48
@coderabbitai

This comment was marked as resolved.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 48aea2b7-e248-4042-b628-0f2bae8d7d0f

📥 Commits

Reviewing files that changed from the base of the PR and between bcc8417 and d7211e4.

📒 Files selected for processing (8)
  • tck/handlers/__init__.py
  • tck/handlers/key.py
  • tck/handlers/topic.py
  • tck/param/common.py
  • tck/param/topic.py
  • tck/response/topic.py
  • tck/util/param_utils.py
  • tests/tck/topic_handlers_test.py

Comment thread tck/handlers/topic.py Outdated
Comment thread tck/handlers/topic.py
Comment thread tck/param/topic.py
Comment thread tck/util/param_utils.py
Comment thread tests/tck/topic_handlers_test.py Outdated
@MonaaEid MonaaEid added step: 1st 1st stage of the review approval process reviewer: write requires a review with write permissions labels May 1, 2026
Comment thread tests/tck/topic_handlers_test.py Outdated
Comment thread tck/handlers/topic.py Outdated
Comment thread tck/handlers/topic.py Outdated
Comment thread tck/handlers/topic.py
Comment thread tck/handlers/topic.py Outdated
@github-actions

This comment was marked as resolved.

@github-actions github-actions Bot added the queue:junior-committer PR awaiting initial quality review label May 8, 2026
@exploreriii exploreriii removed reviewer: write requires a review with write permissions step: 1st 1st stage of the review approval process labels May 8, 2026
@github-actions github-actions Bot added the open to community review PR is open for community review and feedback label May 9, 2026

@aceppaluni aceppaluni left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to review when changes are addressed.

…CK handlers

Signed-off-by: MonaaEid <monaa_eid@hotmail.com>
Copilot AI review requested due to automatic review settings May 11, 2026 19:31
@MonaaEid
MonaaEid requested a review from manishdait May 11, 2026 23:10

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (3)
tck/param/topic.py (2)

23-28: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Reject malformed fixedFee.amount during parsing.

When amount is a non-numeric value (e.g., "bad"), to_int() returns None instead of raising an error. This allows invalid input to pass parameter validation and fail later during transaction construction, producing an internal error instead of a proper invalid params response at the JSON-RPC boundary.

🛡️ Proposed fix
 `@classmethod`
 def parse_json_params(cls, params: dict) -> CreateTopicFixedFeeParams:
+    amount = to_int(params.get("amount"))
+    if amount is None:
+        raise ValueError("fixedFee.amount must be an integer")
     return cls(
-        amount=to_int(params.get("amount")),
+        amount=amount,
         denominatingTokenId=non_empty_string_or_none(params.get("denominatingTokenId")),
     )

39-51: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Validate fixedFee structure when present.

If the caller provides {"fixedFee": "bad"} (a non-dict value), line 50's isinstance check fails and the method silently assigns None instead of raising a validation error. This masks malformed input that should be rejected at the parameter boundary.

🛡️ Proposed fix
 `@classmethod`
 def parse_json_params(cls, params: dict) -> CreateTopicCustomFeeParams:
     fixed_fee = params.get("fixedFee")
+    if fixed_fee is not None and not isinstance(fixed_fee, dict):
+        raise ValueError("fixedFee must be an object")

     fee_collector_account_id = params.get("feeCollectorAccountId")
     if isinstance(fee_collector_account_id, str):
         fee_collector_account_id = fee_collector_account_id.strip()

     return cls(
         feeCollectorAccountId=fee_collector_account_id,
         feeCollectorsExempt=to_bool(params.get("feeCollectorsExempt")),
         fixedFee=(CreateTopicFixedFeeParams.parse_json_params(fixed_fee) if isinstance(fixed_fee, dict) else None),
     )
tck/handlers/topic.py (1)

70-82: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Fail fast when the session does not resolve to a client.

get_client() at line 72 can return None, but lines 80 and 82 use client without validation. An unrecognized sessionId will surface as an internal error (likely AttributeError or SDK exception) instead of a deterministic JSON-RPC error.

🛡️ Proposed fix
 `@rpc_method`("createTopic")
 def create_topic(params: CreateTopicParams) -> CreateTopicResponse:
     client = get_client(params.sessionId)
+    if client is None:
+        raise ValueError("Unknown session ID")

     transaction = _build_create_topic_transaction(params)

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: cbbd17ed-a99b-4cd4-9659-c3e2d13cf95a

📥 Commits

Reviewing files that changed from the base of the PR and between 1e8aa1d and a621641.

📒 Files selected for processing (2)
  • tck/handlers/topic.py
  • tck/param/topic.py

Comment thread tck/handlers/topic.py
Comment thread tck/handlers/topic.py
@MonaaEid
MonaaEid requested review from Copilot and removed request for Copilot May 13, 2026 01:55

@AntonioCeppellini AntonioCeppellini left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @MonaaEid great work so far :D
i agree with the 3 coderabbit suggestions.
are there any tests incoming for this PR?

@aceppaluni aceppaluni left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with code rabbit. Please let us know if you have questions on the suggestions

Additionally, did you commit test files?

@MonaaEid

Copy link
Copy Markdown
Contributor Author

Nope, there are no test files in unit/integration tests if you mean that @AntonioCeppellini @aceppaluni

@MonaaEid
MonaaEid requested review from Copilot and removed request for Copilot May 15, 2026 11:03
@github-actions github-actions Bot added queue:committers PR awaiting committer technical review and removed queue:junior-committer PR awaiting initial quality review labels May 15, 2026
@manishdait

Copy link
Copy Markdown
Contributor

@MonaaEid, Please update the branch

@MonaaEid
MonaaEid requested review from Copilot and removed request for Copilot May 15, 2026 11:51
@manishdait manishdait added this to the v0.2.7 milestone May 15, 2026
@github-actions github-actions Bot added queue:junior-committer PR awaiting initial quality review and removed queue:committers PR awaiting committer technical review labels May 15, 2026

@AntonioCeppellini AntonioCeppellini left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LETSGOOOOO 🚀 🥦

@exploreriii
exploreriii dismissed aceppaluni’s stale review May 15, 2026 15:30

integration tests not relevant in this case

@exploreriii
exploreriii merged commit 05719bd into hiero-ledger:main May 15, 2026
16 of 17 checks passed
@github-actions

Copy link
Copy Markdown

👋 Hi @MonaaEid! Great work completing a Advanced issue! 🎉

Thanks for your contribution! 🚀

Here are some issues you might want to explore next:

🌟 Stay connected:

Happy coding! 🚀
— Hiero Python SDK Team

@MonaaEid
MonaaEid deleted the test/2207-createTopic-tck branch May 15, 2026 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lang: python Uses Python programming language open to community review PR is open for community review and feedback queue:junior-committer PR awaiting initial quality review scope: tests involves unit, integration, fuzz or TCK tests skill: advanced requires knowledge of multiple areas in the codebase without defined steps to implement or examples

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TCK: Implement endpoint for createTopic

5 participants