Skip to content

Commit c9b8013

Browse files
committed
fix(token): Update TokenInfoQuery to handle missing token_id and adjust pauseStatus type in response models
Signed-off-by: Ntege Daniel <danientege785@gmail.com>
1 parent f53a4d4 commit c9b8013

3 files changed

Lines changed: 10 additions & 13 deletions

File tree

src/hiero_sdk_python/query/token_info_query.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,12 @@ def _make_request(self) -> query_pb2.Query:
5757
Exception: If any other error occurs during request construction.
5858
"""
5959
try:
60-
if not self.token_id:
61-
raise ValueError("Token ID must be set before making the request.")
62-
6360
query_header = self._make_request_header()
6461

6562
token_info_query = token_get_info_pb2.TokenGetInfoQuery()
6663
token_info_query.header.CopyFrom(query_header)
67-
token_info_query.token.CopyFrom(self.token_id._to_proto())
64+
if self.token_id:
65+
token_info_query.token.CopyFrom(self.token_id._to_proto())
6866

6967
query = query_pb2.Query()
7068
query.tokenGetInfo.CopyFrom(token_info_query)

tck/handlers/token.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -489,10 +489,10 @@ def claim_token(params: ClaimTokenParams) -> ClaimTokenResponse:
489489
return ClaimTokenResponse(status=ResponseCode(receipt.status).name)
490490

491491

492-
def _serialize_key(key) -> str | None:
492+
def _serialize_key(key) -> str:
493493
"""Serialize a key to its DER-encoded hex string representation."""
494494
if key is None:
495-
return None
495+
return ""
496496

497497
to_string_der = getattr(key, "to_string_der", None)
498498
if callable(to_string_der):
@@ -537,14 +537,13 @@ def _serialize_custom_fee(fee: CustomFee) -> CustomFeeResponse:
537537
return response
538538

539539

540-
def _map_pause_status(pause_status: TokenPauseStatus) -> str:
541-
"""Map TokenPauseStatus enum to TCK string representation."""
540+
def _map_pause_status(pause_status: TokenPauseStatus) -> bool | None:
541+
"""Map TokenPauseStatus enum to TCK boolean representation."""
542542
mapping = {
543-
TokenPauseStatus.PAUSED: "PAUSED",
544-
TokenPauseStatus.UNPAUSED: "UNPAUSED",
545-
TokenPauseStatus.PAUSE_NOT_APPLICABLE: "NOT_APPLICABLE",
543+
TokenPauseStatus.PAUSED: True,
544+
TokenPauseStatus.UNPAUSED: False,
546545
}
547-
return mapping.get(pause_status, "NOT_APPLICABLE")
546+
return mapping.get(pause_status)
548547

549548

550549
def _map_token_type(token_type: TokenType | None) -> str | None:

tck/response/token.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class GetTokenInfoResponse:
8585
metadataKey: str | None = None
8686
defaultFreezeStatus: bool | None = None
8787
defaultKycStatus: bool | None = None
88-
pauseStatus: str | None = None
88+
pauseStatus: bool | None = None
8989
isDeleted: bool | None = None
9090
autoRenewAccountId: str | None = None
9191
autoRenewPeriod: str | None = None

0 commit comments

Comments
 (0)