Skip to content

Commit aacefc6

Browse files
committed
chore: imporve freeze_with to work with the client without operator
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
1 parent c18dcbb commit aacefc6

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

src/hiero_sdk_python/transaction/transaction.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def freeze(self):
248248
"""
249249
return self.freeze_with(None)
250250

251-
def freeze_with(self, client):
251+
def freeze_with(self, client: "Client"):
252252
"""
253253
Freezes the transaction by building the transaction body and setting necessary IDs.
254254
@@ -266,20 +266,27 @@ def freeze_with(self, client):
266266

267267

268268
# Check transaction_id and node id to be set when using freeze()
269-
if client is None:
270-
if self.transaction_id is None:
269+
if self.transaction_id is None:
270+
if client is not None:
271+
operator_account_id = client.operator_account_id
272+
if operator_account_id is not None:
273+
self.transaction_id = client.generate_transaction_id()
274+
else:
275+
raise ValueError(
276+
"Client must have an operator_account or transactionId must be set."
277+
)
278+
else:
271279
raise ValueError(
272280
"Transaction ID must be set before freezing. Use freeze_with(client) or set_transaction_id()."
273281
)
274-
275-
if self.node_account_id is None and len(self.node_account_ids) == 0:
282+
283+
284+
if self.node_account_id is None and len(self.node_account_ids) == 0:
285+
if client is None:
276286
raise ValueError(
277287
"Node account ID must be set before freezing. Use freeze_with(client) or manually set node_account_ids."
278288
)
279289

280-
if self.transaction_id is None:
281-
self.transaction_id = client.generate_transaction_id()
282-
283290
# We iterate through every node in the client's network
284291
# For each node, set the node_account_id and build the transaction body
285292
# This allows the transaction to be submitted to any node in the network

0 commit comments

Comments
 (0)