22from hiero_sdk_python .hapi .services .basic_types_pb2 import Key , AccountID
33from hiero_sdk_python .hapi .services .timestamp_pb2 import Timestamp
44from 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
66from hiero_sdk_python .utils .key_format import format_key
7+ from typing import Optional
78
89class 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 )
0 commit comments