Skip to content

Commit

Permalink
Merge pull request #3361 from AElfProject/hotfix/method-fee-free-allo…
Browse files Browse the repository at this point in the history
…wances

Fix wrong method fee free allowances for balance less than threshold
  • Loading branch information
jason-aelf authored Jan 18, 2023
2 parents 3906a55 + d94588f commit 8d733b0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions contract/AElf.Contracts.MultiToken/TokenContract_Fees.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ private void SetOrRefreshMethodFeeFreeAllowances(Address address)
var config = State.MethodFeeFreeAllowancesConfig.Value;
if (config == null || State.Balances[address][Context.Variables.NativeSymbol] < config.Threshold)
{
// Won't refresh method fee free allowance if inputted address hasn't reach the threshold.
return;
}

Expand Down Expand Up @@ -919,11 +918,14 @@ private MethodFeeFreeAllowances CalculateMethodFeeFreeAllowances(Address input)

var config = freeAllowancesConfig.Clone();

var balance = State.Balances[input][Context.Variables.NativeSymbol];
if (balance < config.Threshold) return new MethodFeeFreeAllowances();

var lastRefreshTime = State.MethodFeeFreeAllowancesLastRefreshTimeMap[input];

if (freeAllowances == null)
{
if (State.Balances[input][Context.Variables.NativeSymbol] >= config.Threshold)
if (balance >= config.Threshold)
{
return new MethodFeeFreeAllowances { Value = { config.FreeAllowances.Value } };
}
Expand Down

0 comments on commit 8d733b0

Please sign in to comment.