Skip to content

Commit 53700ef

Browse files
committed
chore: type fixes consensus
Signed-off-by: exploreriii <[email protected]>
1 parent 6d0a5ed commit 53700ef

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/hiero_sdk_python/consensus/topic_info.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
from hiero_sdk_python.hapi.services.basic_types_pb2 import Key, AccountID
33
from hiero_sdk_python.hapi.services.timestamp_pb2 import Timestamp
44
from hiero_sdk_python.hapi.services import consensus_topic_info_pb2
5-
from hiero_sdk_python import Duration
5+
from hiero_sdk_python.Duration import Duration
66
from hiero_sdk_python.utils.key_format import format_key
7+
from typing import Optional
78

89
class TopicInfo:
910
def __init__(
@@ -12,11 +13,12 @@ def __init__(
1213
running_hash: bytes,
1314
sequence_number: int,
1415
expiration_time: Timestamp,
15-
admin_key: Key,
16-
submit_key: Key,
17-
auto_renew_period: Duration,
18-
auto_renew_account: AccountID,
19-
ledger_id: bytes,
16+
admin_key: Optional[Key],
17+
submit_key: Optional[Key],
18+
auto_renew_period: Optional[Duration],
19+
auto_renew_account: Optional[AccountID],
20+
ledger_id: Optional[bytes],
21+
2022
) -> None:
2123
"""
2224
Initializes a new instance of the TopicInfo class.
@@ -89,6 +91,9 @@ def __str__(self) -> str:
8991
exp_dt = datetime.fromtimestamp(self.expiration_time.seconds)
9092

9193
running_hash_hex: str = self.running_hash.hex() if self.running_hash else None
94+
ledger_id_hex: Optional[str] = (
95+
self.ledger_id.hex() if isinstance(self.ledger_id, (bytes, bytearray)) else None
96+
)
9297

9398
return (
9499
"TopicInfo(\n"
@@ -100,6 +105,6 @@ def __str__(self) -> str:
100105
f" submit_key={format_key(self.submit_key)},\n"
101106
f" auto_renew_period={self.auto_renew_period.seconds},\n"
102107
f" auto_renew_account={self.auto_renew_account},\n"
103-
f" ledger_id={self.ledger_id}\n"
108+
f" ledger_id=0x{ledger_id_hex}\n"
104109
")"
105110
)

src/hiero_sdk_python/consensus/topic_message.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def __init__(self, response: mirror_proto.ConsensusTopicResponse) -> None:
1717
Args:
1818
response: The ConsensusTopicResponse containing chunk data.
1919
"""
20-
self.consensus_timestamp: Timestamp = Timestamp._from_protobuf(response.consensusTimestamp).to_date()
20+
self.consensus_timestamp: datetime = Timestamp._from_protobuf(response.consensusTimestamp).to_date()
2121
self.content_size: int = len(response.message)
2222
self.running_hash: Union[bytes, int] = response.runningHash
2323
self.sequence_number: Union[bytes, int] = response.sequenceNumber

0 commit comments

Comments
 (0)