Skip to content

Commit 8bdb1f0

Browse files
add client to set max transaction fee in Transaction class
Signed-off-by: tech0priyanshu <priyanshuyadv101106@gmail.com>
1 parent 29b2484 commit 8bdb1f0

1 file changed

Lines changed: 9 additions & 15 deletions

File tree

src/hiero_sdk_python/transaction/transaction.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def __init__(self) -> None:
7676
self._default_transaction_fee = Hbar(2)
7777
self.operator_account_id = None
7878
self.batch_key: Key | None = None
79+
self._client: Client | None = None
7980

8081
def _make_request(self):
8182
"""
@@ -303,23 +304,10 @@ def freeze_with(self, client: Client):
303304
return self
304305

305306
# Resolve transaction_id and node_accountids to be set when using freeze()
307+
self._client = client
306308
self._resolve_transaction_id(client)
307309
self._resolve_node_ids(client)
308310

309-
# Resolve fee priority before building bodies:
310-
# 1. Explicit transaction fee (self.transaction_fee)
311-
# 2. Client default_max_transaction_fee
312-
# 3. Transaction class default (_default_transaction_fee)
313-
#
314-
# This must run before the loop below: once _transaction_body_bytes is
315-
# populated the transaction counts as frozen, and the transaction_fee
316-
# setter calls _require_not_frozen().
317-
if self.transaction_fee is None:
318-
if client is not None and client.default_max_transaction_fee is not None:
319-
self.transaction_fee = client.default_max_transaction_fee
320-
else:
321-
self.transaction_fee = self._default_transaction_fee
322-
323311
# We iterate through every node in the node_account_id list and
324312
# For each node_account_id build the transaction body
325313
# This allows the transaction to be submitted to the given node in the network
@@ -486,7 +474,13 @@ def build_base_transaction_body(self) -> transaction_pb2.TransactionBody:
486474
transaction_body.transactionID.CopyFrom(transaction_id_proto)
487475
transaction_body.nodeAccountID.CopyFrom(selected_node._to_proto())
488476

489-
fee = self._transaction_fee if self._transaction_fee is not None else self._default_transaction_fee
477+
if self._transaction_fee is None:
478+
if self._client is not None and self._client.default_max_transaction_fee is not None:
479+
self.transaction_fee = self._client.default_max_transaction_fee
480+
else:
481+
self.transaction_fee = self._default_transaction_fee
482+
483+
fee = self._transaction_fee
490484
if hasattr(fee, "to_tinybars"):
491485
transaction_body.transactionFee = int(fee.to_tinybars())
492486
else:

0 commit comments

Comments
 (0)