Skip to content

Commit 7930bb9

Browse files
committed
add validation for farming params update
1 parent 9ef83f2 commit 7930bb9

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

x/farming/keeper/msg_server.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,11 @@ func (m msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParam
221221
// get the current params
222222
params := m.GetParams(ctx)
223223

224+
// validate params update
225+
if err := types.ValidateParamsUpdate(params, msg.Params); err != nil {
226+
return nil, err
227+
}
228+
224229
// update params
225230
m.SetParams(ctx, msg.Params)
226231

x/farming/types/params.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ func (p Params) Validate() error {
5757
return nil
5858
}
5959

60+
// ValidateParamsUpdate validates the given params update
61+
func ValidateParamsUpdate(params Params, newParams Params) error {
62+
if newParams.RewardPerEpoch.Denom != params.RewardPerEpoch.Denom {
63+
return errorsmod.Wrap(ErrInvalidParams, "reward denom cannot be updated")
64+
}
65+
66+
return nil
67+
}
68+
6069
// validateEpochDuration validates the given epoch duration
6170
func validateEpochDuration(p Params) error {
6271
if p.EpochDuration < 0 {

0 commit comments

Comments
 (0)