diff --git a/x/exomint/client/cli/tx.go b/x/exomint/client/cli/tx.go index 8ec0fb46e..94e54c517 100644 --- a/x/exomint/client/cli/tx.go +++ b/x/exomint/client/cli/tx.go @@ -50,10 +50,7 @@ func CmdUpdateParams() *cobra.Command { return err } - msg, err := newBuildUpdateParamsMsg(clientCtx, cmd.Flags()) - if err != nil { - return err - } + msg := newBuildUpdateParamsMsg(clientCtx, cmd.Flags()) // this calls ValidateBasic internally so we don't need to do that. return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) @@ -79,7 +76,7 @@ func CmdUpdateParams() *cobra.Command { func newBuildUpdateParamsMsg( clientCtx client.Context, fs *pflag.FlagSet, -) (*types.MsgUpdateParams, error) { +) *types.MsgUpdateParams { sender := clientCtx.GetFromAddress() // #nosec G703 // this only errors if the flag isn't defined. mintDenom, _ := fs.GetString(FlagMintDenom) @@ -99,5 +96,5 @@ func newBuildUpdateParamsMsg( EpochIdentifier: epochIdentifier, }, } - return msg, nil + return msg } diff --git a/x/exomint/keeper/msg_server.go b/x/exomint/keeper/msg_server.go index b068a3a69..46334796b 100644 --- a/x/exomint/keeper/msg_server.go +++ b/x/exomint/keeper/msg_server.go @@ -52,6 +52,15 @@ func (k Keeper) UpdateParams( logger.Info("UpdateParams", "overriding EpochIdentifier with value", prevParams.EpochIdentifier) nextParams.EpochIdentifier = prevParams.EpochIdentifier } + // stateful validations + // no need to check if MintDenom is registered in BankKeeper, since it does not + // itself perform such checks. + // the reward is already guaranteed to be positive and fits in the bit length. + // we just have to check epoch here. + if _, found := k.epochsKeeper.GetEpochInfo(c, nextParams.EpochIdentifier); !found { + logger.Info("UpdateParams", "overriding EpochIdentifier with value", prevParams.EpochIdentifier) + nextParams.EpochIdentifier = prevParams.EpochIdentifier + } k.SetParams(c, msg.Params) return nil, nil }