Skip to content

feat: implemented wipeToken TCK endpt.#2414

Draft
Adityarya11 wants to merge 1 commit into
hiero-ledger:mainfrom
Adityarya11:feat/tck-wipeToken#2398
Draft

feat: implemented wipeToken TCK endpt.#2414
Adityarya11 wants to merge 1 commit into
hiero-ledger:mainfrom
Adityarya11:feat/tck-wipeToken#2398

Conversation

@Adityarya11

Copy link
Copy Markdown
Contributor

Description:
This PR introduce the wipeToken method to tck module.

Changes Made:

Related issue(s):

Fixes #2398

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.) (No Need)
  • Ruff formatted.

Signed-off-by: Adityarya11 <arya050411@gmail.com>
@github-actions github-actions Bot added approved Issue has been approved by team member scope: TCK involves engineering for the implementation of TCK method and module skill: advanced requires knowledge of multiple areas in the codebase without defined steps to implement or examples labels Jul 10, 2026
@Adityarya11 Adityarya11 marked this pull request as ready for review July 10, 2026 13:48
@Adityarya11 Adityarya11 requested a review from a team as a code owner July 10, 2026 13:48
@Adityarya11 Adityarya11 marked this pull request as draft July 10, 2026 13:49
@Adityarya11 Adityarya11 self-assigned this Jul 10, 2026

Copilot AI 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.

Pull request overview

This PR adds TCK support for the wipeToken JSON-RPC endpoint, aligning the Python SDK’s TCK module with the TokenWipeTransaction specification.

Changes:

  • Added WipeTokenParams request model and JSON param parsing for the new endpoint.
  • Added WipeTokenResponse response model.
  • Implemented the wipeToken RPC handler and transaction builder using TokenWipeTransaction.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
tck/response/token.py Adds a status-only response dataclass for wipeToken.
tck/param/token.py Adds request params dataclass + JSON parsing for wipeToken.
tck/handlers/token.py Adds wipeToken RPC method and constructs/executes TokenWipeTransaction.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tck/handlers/token.py

from __future__ import annotations

from hiero_sdk_python import TokenWipeTransaction
Comment thread tck/handlers/token.py
Comment on lines +501 to +503
serialNumberList = [int(serial_number) for serial_number in params.serialNumbers]

transaction.set_serial(serialNumberList)
Comment thread tck/handlers/token.py
Comment on lines +520 to +522
reciept: TransactionReceipt = response.get_receipt(client, validate_status=True)

return WipeTokenResponse(status=ResponseCode(reciept.status).name)
Comment thread tck/handlers/token.py
Comment on lines +508 to +522
@rpc_method("wipeToken")
def wipe_token(params: WipeTokenParams) -> WipeTokenResponse:
"""Wipes the provided amount of fungible or non-fungible tokens from the specified Hedera account"""

client = get_client(params.sessionId)

transaction = _build_wipe_token_transaction(params)

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

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

return WipeTokenResponse(status=ResponseCode(reciept.status).name)
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Adds the wipeToken RPC endpoint to the TCK module, including parameter validation, response modeling, TokenWipeTransaction construction, execution, receipt retrieval, and status mapping.

Changes

wipeToken endpoint

Layer / File(s) Summary
Request and response contracts
tck/param/token.py, tck/response/token.py
Adds WipeTokenParams with validation for token, account, amount, serial numbers, session, and common transaction parameters, plus WipeTokenResponse.
Transaction construction and RPC execution
tck/handlers/token.py
Adds the wipeToken RPC handler, builds and executes TokenWipeTransaction, retrieves the receipt, and returns the mapped status.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant JSONRPCClient
  participant wipe_token
  participant TokenWipeTransaction
  participant TransactionReceipt
  JSONRPCClient->>wipe_token: WipeTokenParams
  wipe_token->>TokenWipeTransaction: build transaction
  wipe_token->>TokenWipeTransaction: execute
  wipe_token->>TransactionReceipt: get_receipt(validate_status=True)
  TransactionReceipt-->>wipe_token: receipt.status
  wipe_token-->>JSONRPCClient: WipeTokenResponse
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the new wipeToken TCK endpoint.
Description check ✅ Passed The description matches the change and references the wipeToken TCK endpoint and its spec.
Linked Issues check ✅ Passed The PR adds the handler, params, and response model required by issue #2398.
Out of Scope Changes check ✅ Passed The changes stay focused on the wipeToken endpoint and its related data models.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
📋 Issue Planner

Built with CodeRabbit's Coding Plans for faster development and fewer bugs.

View plan used: #2398

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@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: 4


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 3201578c-9494-407f-b06a-7558c2cbc0b2

📥 Commits

Reviewing files that changed from the base of the PR and between deb64f3 and 4be1827.

📒 Files selected for processing (3)
  • tck/handlers/token.py
  • tck/param/token.py
  • tck/response/token.py

Comment thread tck/handlers/token.py
Comment on lines +497 to +498
if params.amount is not None:
transaction.set_amount(to_int(params.amount))

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

to_int can return None, causing set_amount(None) to be called silently.

to_int catches ValueError/TypeError and returns None. If a user provides amount: "abc", to_int returns None and set_amount(None) is called instead of raising a validation error. This is a silent failure — the user intended to wipe tokens but the amount is silently discarded. Validate the conversion result before passing it to set_amount.

🐛 Proposed fix
     if params.amount is not None:
-        transaction.set_amount(to_int(params.amount))
+        amount = to_int(params.amount)
+        if amount is None:
+            raise ValueError("amount must be a valid integer")
+        transaction.set_amount(amount)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if params.amount is not None:
transaction.set_amount(to_int(params.amount))
if params.amount is not None:
amount = to_int(params.amount)
if amount is None:
raise ValueError("amount must be a valid integer")
transaction.set_amount(amount)

Comment thread tck/handlers/token.py
Comment on lines +500 to +503
if params.serialNumbers is not None:
serialNumberList = [int(serial_number) for serial_number in params.serialNumbers]

transaction.set_serial(serialNumberList)

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

int(serial_number) raises raw ValueError for non-numeric strings.

parse_json_params validates that serial number items are strings but not that they are valid integer strings. If a user provides serialNumbers: ["abc"], the int() call at line 501 raises a raw ValueError with an unhelpful message like invalid literal for int() with base 10: 'abc'. While handle_sdk_errors wraps this, a clearer validation error would improve the TCK user experience. Consider validating during parsing or providing a clearer error message here.

Comment thread tck/handlers/token.py
Comment on lines +520 to +522
reciept: TransactionReceipt = response.get_receipt(client, validate_status=True)

return WipeTokenResponse(status=ResponseCode(reciept.status).name)

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.

📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Fix typo: recieptreceipt.

The local variable reciept is misspelled. It should be receipt for readability and consistency.

✏️ Proposed fix
-    reciept: TransactionReceipt = response.get_receipt(client, validate_status=True)
+    receipt: TransactionReceipt = response.get_receipt(client, validate_status=True)
 
-    return WipeTokenResponse(status=ResponseCode(reciept.status).name)
+    return WipeTokenResponse(status=ResponseCode(receipt.status).name)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
reciept: TransactionReceipt = response.get_receipt(client, validate_status=True)
return WipeTokenResponse(status=ResponseCode(reciept.status).name)
receipt: TransactionReceipt = response.get_receipt(client, validate_status=True)
return WipeTokenResponse(status=ResponseCode(receipt.status).name)

Comment thread tck/param/token.py
Comment on lines +255 to +259
return cls(
tokenId=params.get("tokenId"),
accountId=params.get("accountId"),
amount=params.get("amount"),
serialNumbers=serial_numbers,

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Add type validation for tokenId, accountId, and amount.

parse_json_params validates serialNumbers but does not validate that tokenId, accountId, or amount are strings. The allowance endpoint (tck/param/allowance.py:128) validates tokenId with isinstance(token_id, str). Without this validation, non-string values pass through silently and only fail later in the handler with less clear errors from TokenId.from_string() or to_int().

🛡️ Proposed fix
         return cls(
-            tokenId=params.get("tokenId"),
-            accountId=params.get("accountId"),
-            amount=params.get("amount"),
+            tokenId=_parse_str_param(params, "tokenId"),
+            accountId=_parse_str_param(params, "accountId"),
+            amount=_parse_str_param(params, "amount"),
             serialNumbers=serial_numbers,
             sessionId=parse_session_id(params),
             commonTransactionParams=parse_common_transaction_params(params),
         )

Or inline validation:

+        token_id = params.get("tokenId")
+        if token_id is not None and not isinstance(token_id, str):
+            raise ValueError("tokenId must be a string")
+        account_id = params.get("accountId")
+        if account_id is not None and not isinstance(account_id, str):
+            raise ValueError("accountId must be a string")
+        amount = params.get("amount")
+        if amount is not None and not isinstance(amount, str):
+            raise ValueError("amount must be a string")
+
         return cls(
-            tokenId=params.get("tokenId"),
-            accountId=params.get("accountId"),
-            amount=params.get("amount"),
+            tokenId=token_id,
+            accountId=account_id,
+            amount=amount,
             serialNumbers=serial_numbers,
             sessionId=parse_session_id(params),
             commonTransactionParams=parse_common_transaction_params(params),
         )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return cls(
tokenId=params.get("tokenId"),
accountId=params.get("accountId"),
amount=params.get("amount"),
serialNumbers=serial_numbers,
token_id = params.get("tokenId")
if token_id is not None and not isinstance(token_id, str):
raise ValueError("tokenId must be a string")
account_id = params.get("accountId")
if account_id is not None and not isinstance(account_id, str):
raise ValueError("accountId must be a string")
amount = params.get("amount")
if amount is not None and not isinstance(amount, str):
raise ValueError("amount must be a string")
return cls(
tokenId=token_id,
accountId=account_id,
amount=amount,
serialNumbers=serial_numbers,

@manishdait

Copy link
Copy Markdown
Contributor

Hi @Adityarya11, Please update the branch and resolve the conflicts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Issue has been approved by team member scope: TCK involves engineering for the implementation of TCK method and module 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.

Add wipeToken endpoint to tck module

4 participants