Skip to content

Commit

Permalink
chore: fix to prevent generating swap more than MaxSwaps
Browse files Browse the repository at this point in the history
  • Loading branch information
jaeseung-bae committed May 3, 2024
1 parent d15f3e5 commit 54cce5a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions x/fswap/keeper/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ import (
)

func (k Keeper) MakeSwap(ctx sdk.Context, swap types.Swap, toDenomMetadata bank.Metadata) error {
stats, err := k.getSwapStats(ctx)
if err != nil {
return err
}
if int(stats.SwapCount) >= k.config.MaxSwaps && !k.isUnlimited() {
return types.ErrCanNotHaveMoreSwap.Wrapf("cannot initialize genesis state, there are more than %d swaps", k.config.MaxSwaps)
}
isNewSwap := true
if _, err := k.getSwap(ctx, swap.FromDenom, swap.ToDenom); err == nil {
isNewSwap = false
Expand Down

0 comments on commit 54cce5a

Please sign in to comment.