Skip to content

Commit

Permalink
Uses sp.min_fee if available
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jannotti committed Jan 20, 2024
1 parent 3e64019 commit ba69731
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions algosdk/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit ba69731

Please sign in to comment.