Skip to content

Commit 7812125

Browse files
clockworkgrlumtisilgooz
authored
fix(pkg/cosmosfaucet): include requested funds to the rate limit calc (#1453)
* fix: coinsMax check Checks both total transferred so far and total transferred so far + amount requested against the max credit limit * fix: lint errors * Update starport/pkg/cosmosfaucet/transfer.go Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com> * Update starport/pkg/cosmosfaucet/transfer.go Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com> * Update starport/pkg/cosmosfaucet/transfer.go Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com> * chore Co-authored-by: Lucas Bertrand <lucas.bertrand.22@gmail.com> Co-authored-by: İlker Göktuğ ÖZTÜRK <ilkergoktugozturk@gmail.com>
1 parent fef5962 commit 7812125

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

starport/pkg/cosmosfaucet/transfer.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,14 @@ func (f Faucet) Transfer(ctx context.Context, toAccountAddress string, amount ui
5555
return err
5656
}
5757

58-
if f.coinsMax[denom] != 0 && totalSent >= f.coinsMax[denom] {
59-
return fmt.Errorf("account has reached maximum credit allowed per account (%d)", f.coinsMax[denom])
58+
if f.coinsMax[denom] != 0 {
59+
if totalSent >= f.coinsMax[denom] {
60+
return fmt.Errorf("account has reached maximum credit allowed per account (%d)", f.coinsMax[denom])
61+
}
62+
63+
if (totalSent + amount) >= f.coinsMax[denom] {
64+
return fmt.Errorf("account is about to reach maximum credit allowed per account. it can only receive up to (%d) in total", f.coinsMax[denom])
65+
}
6066
}
6167

6268
fromAccount, err := f.runner.ShowAccount(ctx, f.accountName)

0 commit comments

Comments
 (0)