@@ -25,23 +25,35 @@ class TransactionRecordQuery(Query):
2525 def __init__ (
2626 self ,
2727 transaction_id : Optional [TransactionId ] = None ,
28+ include_children : bool = False ,
2829 include_duplicates : bool = False ,
2930 ) -> None :
3031 """
3132 Initializes the TransactionRecordQuery with the provided transaction ID.
33+
34+ Args:
35+ transaction_id (TransactionId, optional): The ID of the transaction.
36+ include_children (bool): Whether to include child transaction records.
37+ include_duplicates (bool): Whether to include duplicate transaction records.
3238 """
3339 super ().__init__ ()
3440 if not isinstance (include_duplicates , bool ):
3541 raise TypeError (
3642 f"include_duplicates must be a bool (True or False), got { type (include_duplicates ).__name__ } "
3743 )
38-
44+
3945 if transaction_id is not None and not isinstance (transaction_id , TransactionId ):
4046 raise TypeError (
4147 f"transaction_id must be TransactionId or None, got { type (transaction_id ).__name__ } "
4248 )
4349
50+ if not isinstance (include_children , bool ):
51+ raise TypeError (
52+ f"include_children must be a bool (True or False), got { type (include_children ).__name__ } "
53+ )
54+
4455 self .transaction_id : Optional [TransactionId ] = transaction_id
56+ self .include_children : bool = bool (include_children )
4557 self .include_duplicates : bool = bool (include_duplicates )
4658
4759 def set_include_duplicates (
@@ -57,10 +69,12 @@ def set_include_duplicates(
5769 TransactionRecordQuery: The current instance for method chaining.
5870 """
5971 if not isinstance (include_duplicates , bool ):
60- raise TypeError (f"include_duplicates must be a boolean, got { type (include_duplicates ).__name__ } " )
72+ raise TypeError (
73+ f"include_duplicates must be a boolean, got { type (include_duplicates ).__name__ } "
74+ )
6175 self .include_duplicates = include_duplicates
6276 return self
63-
77+
6478 def set_transaction_id (
6579 self ,
6680 transaction_id : Optional [TransactionId ],
@@ -76,7 +90,7 @@ def set_transaction_id(
7690 Returns:
7791 TransactionRecordQuery: This query instance for chaining.
7892 """
79-
93+
8094 if transaction_id is not None and not isinstance (transaction_id , TransactionId ):
8195 raise TypeError (
8296 f"transaction_id must be TransactionId or None, got { type (transaction_id ).__name__ } "
@@ -85,6 +99,24 @@ def set_transaction_id(
8599 self .transaction_id = transaction_id
86100 return self
87101
102+ def set_include_children (self , include_children : bool ) -> "TransactionRecordQuery" :
103+ """
104+ Sets include_children for which to retrieve the child transaction records.
105+
106+ Args:
107+ include_children: bool.
108+
109+ Returns:
110+ TransactionRecordQuery: The current instance for method chaining.
111+ """
112+ if not isinstance (include_children , bool ):
113+ raise TypeError (
114+ f"include_children must be a boolean, got { type (include_children ).__name__ } "
115+ )
116+
117+ self .include_children = include_children
118+ return self
119+
88120 def _make_request (self ):
89121 """
90122 Constructs the protobuf request for the transaction record query.
@@ -108,6 +140,7 @@ def _make_request(self):
108140 transaction_get_record .header .CopyFrom (query_header )
109141 transaction_get_record .transactionID .CopyFrom (self .transaction_id ._to_proto ())
110142 transaction_get_record .includeDuplicates = self .include_duplicates
143+ transaction_get_record .include_child_records = self .include_children
111144
112145 query = query_pb2 .Query ()
113146 query .transactionGetRecord .CopyFrom (transaction_get_record )
@@ -236,9 +269,13 @@ def _map_status_error(
236269 return PrecheckError (status )
237270
238271 receipt = response .transactionGetRecord .transactionRecord .receipt
239-
240- return ReceiptStatusError (status , self .transaction_id , TransactionReceipt ._from_proto (receipt , self .transaction_id ))
241-
272+
273+ return ReceiptStatusError (
274+ status ,
275+ self .transaction_id ,
276+ TransactionReceipt ._from_proto (receipt , self .transaction_id ),
277+ )
278+
242279 def execute (self , client : Client , timeout : Optional [Union [int , float ]] = None ):
243280 """
244281 Executes the transaction record query.
@@ -263,14 +300,24 @@ def execute(self, client: Client, timeout: Optional[Union[int, float]] = None):
263300 self ._before_execute (client )
264301 response = self ._execute (client , timeout )
265302 primary_proto = response .transactionGetRecord .transactionRecord
303+ children = []
266304 if self .include_duplicates :
267305 duplicates = self ._map_record_list (
268306 response .transactionGetRecord .duplicateTransactionRecords
269307 )
270308 else :
271309 duplicates = []
310+
311+ if self .include_children :
312+ children = self ._map_record_list (
313+ response .transactionGetRecord .child_transaction_records
314+ )
315+
272316 return TransactionRecord ._from_proto (
273- primary_proto , transaction_id = self .transaction_id , duplicates = duplicates
317+ primary_proto ,
318+ transaction_id = self .transaction_id ,
319+ duplicates = duplicates ,
320+ children = children ,
274321 )
275322
276323 def _get_query_response (self , response : Any ):
0 commit comments