From ba6973110fe7a8b190ee9000fb1efee1bc53fce2 Mon Sep 17 00:00:00 2001 From: John Jannotti Date: Sat, 20 Jan 2024 13:31:30 -0500 Subject: [PATCH] Uses sp.min_fee if available Rather than use a hard coded constant for min_fee, use the one that is returned in SuggestedParams if available. Since some people may create a SuggestedParams by hand rather than get one from server (because our APIs require one even though the caller may feel they "know better"), continue to use the constant if the sp.min_fee is None. --- algosdk/transaction.py | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/algosdk/transaction.py b/algosdk/transaction.py index e68cb4b7..28ac1518 100644 --- a/algosdk/transaction.py +++ b/algosdk/transaction.py @@ -368,9 +368,8 @@ def __init__( raise error.WrongAmountType self.close_remainder_to = close_remainder_to if not sp.flat_fee: - self.fee = max( - self.estimate_size() * self.fee, constants.min_txn_fee - ) + mf = sp.min_fee or constants.min_txn_fee + self.fee = max(self.estimate_size() * self.fee, mf) def dictify(self): d = dict() @@ -480,9 +479,8 @@ def __init__( self.sprfkey = self._fixed_bytes64(sprfkey, 64) if not sp.flat_fee: - self.fee = max( - self.estimate_size() * self.fee, constants.min_txn_fee - ) + mf = sp.min_fee or constants.min_txn_fee + self.fee = max(self.estimate_size() * self.fee, mf) def dictify(self): d = {} @@ -866,9 +864,8 @@ def __init__( if self.decimals < 0 or self.decimals > constants.max_asset_decimals: raise error.OutOfRangeDecimalsError if not sp.flat_fee: - self.fee = max( - self.estimate_size() * self.fee, constants.min_txn_fee - ) + mf = sp.min_fee or constants.min_txn_fee + self.fee = max(self.estimate_size() * self.fee, mf) def dictify(self): d = dict() @@ -1221,9 +1218,8 @@ def __init__( self.target = target self.new_freeze_state = new_freeze_state if not sp.flat_fee: - self.fee = max( - self.estimate_size() * self.fee, constants.min_txn_fee - ) + mf = sp.min_fee or constants.min_txn_fee + self.fee = max(self.estimate_size() * self.fee, mf) def dictify(self): d = dict() @@ -1339,9 +1335,8 @@ def __init__( self.close_assets_to = close_assets_to self.revocation_target = revocation_target if not sp.flat_fee: - self.fee = max( - self.estimate_size() * self.fee, constants.min_txn_fee - ) + mf = sp.min_fee or constants.min_txn_fee + self.fee = max(self.estimate_size() * self.fee, mf) def dictify(self): d = dict() @@ -1612,9 +1607,8 @@ def __init__( boxes, self.foreign_apps, self.index ) if not sp.flat_fee: - self.fee = max( - self.estimate_size() * self.fee, constants.min_txn_fee - ) + mf = sp.min_fee or constants.min_txn_fee + self.fee = max(self.estimate_size() * self.fee, mf) @staticmethod def state_schema(schema):