Skip to content

Commit

Permalink
txns: Uses sp.min_fee if available (#530)
Browse files Browse the repository at this point in the history
* 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.

* Only use the constant if sp.min_fee is None (not when 0)
  • Loading branch information
jannotti committed Jan 23, 2024
1 parent 12d5fa8 commit 9383b8b
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 = constants.min_txn_fee if sp.min_fee is None else sp.min_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 = constants.min_txn_fee if sp.min_fee is None else sp.min_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 = constants.min_txn_fee if sp.min_fee is None else sp.min_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 = constants.min_txn_fee if sp.min_fee is None else sp.min_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 = constants.min_txn_fee if sp.min_fee is None else sp.min_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 = constants.min_txn_fee if sp.min_fee is None else sp.min_fee
self.fee = max(self.estimate_size() * self.fee, mf)

@staticmethod
def state_schema(schema):
Expand Down

0 comments on commit 9383b8b

Please sign in to comment.