Skip to content

Commit

Permalink
Chore/update error message (#8816) (#8817)
Browse files Browse the repository at this point in the history
* fix: block mint to module account

* chore: update spread factor charge panic message

(cherry picked from commit 79d5096)

Co-authored-by: PaddyMc <[email protected]>
  • Loading branch information
mergify[bot] and PaddyMc authored Nov 11, 2024
1 parent dece0d4 commit 0ac6de5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions x/concentrated-liquidity/swapstrategy/spread_rewards.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func computeSpreadRewardChargePerSwapStepOutGivenIn(hasReachedTarget bool, amoun
return osmomath.ZeroDec()
} else if spreadFactor.IsNegative() {
// This should never happen but is added as a defense-in-depth measure.
panic(fmt.Errorf("spread factor must be non-negative, was (%s)", spreadFactor))
panic(fmt.Errorf("spread factor must be non-negative, was (%s), if figure is more than -1 this panic is known and not an issue", spreadFactor))
}

var spreadRewardChargeTotal osmomath.Dec
Expand All @@ -50,7 +50,7 @@ func computeSpreadRewardChargePerSwapStepOutGivenIn(hasReachedTarget bool, amoun

if spreadRewardChargeTotal.IsNegative() {
// This should never happen but is added as a defense-in-depth measure.
panic(fmt.Errorf("spread factor charge must be non-negative, was (%s)", spreadRewardChargeTotal))
panic(fmt.Errorf("spread factor charge must be non-negative, was (%s), if figure is more than -1 this panic is known and not an issue", spreadRewardChargeTotal))
}

return spreadRewardChargeTotal
Expand Down
8 changes: 6 additions & 2 deletions x/tokenfactory/keeper/bankactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ func (k Keeper) mintTo(ctx sdk.Context, amount sdk.Coin, mintTo string) error {
return err
}

err = k.bankKeeper.MintCoins(ctx, types.ModuleName, sdk.NewCoins(amount))
addr, err := sdk.AccAddressFromBech32(mintTo)
if err != nil {
return err
}

addr, err := sdk.AccAddressFromBech32(mintTo)
if k.IsModuleAcc(ctx, addr) {
return types.ErrMintToModuleAccount
}

err = k.bankKeeper.MintCoins(ctx, types.ModuleName, sdk.NewCoins(amount))
if err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions x/tokenfactory/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ var (
ErrDenomDoesNotExist = errorsmod.Register(ModuleName, 10, "denom does not exist")
ErrBurnFromModuleAccount = errorsmod.Register(ModuleName, 11, "burning from Module Account is not allowed")
ErrBeforeSendHookOutOfGas = errorsmod.Register(ModuleName, 12, "gas meter hit maximum limit")
ErrMintToModuleAccount = errorsmod.Register(ModuleName, 13, "minting to Module Account is not allowed")
)

0 comments on commit 0ac6de5

Please sign in to comment.