From 2b5a681ba1b9a1b2b93ad1722f2500c7d42b7e4b Mon Sep 17 00:00:00 2001 From: skosito Date: Wed, 24 Apr 2024 00:57:40 +0200 Subject: [PATCH] PR comments --- docs/spec/emissions/messages.md | 3 +++ x/emissions/keeper/msg_server_update_params.go | 2 ++ x/emissions/keeper/params.go | 12 ++++++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/spec/emissions/messages.md b/docs/spec/emissions/messages.md index a93824c40a..b3549681bd 100644 --- a/docs/spec/emissions/messages.md +++ b/docs/spec/emissions/messages.md @@ -2,6 +2,9 @@ ## MsgUpdateParams +UpdateParams defines a governance operation for updating the x/emissions module parameters. +The authority is hard-coded to the x/gov module account. + ```proto message MsgUpdateParams { string authority = 1; diff --git a/x/emissions/keeper/msg_server_update_params.go b/x/emissions/keeper/msg_server_update_params.go index 137f37e754..9581a1b19f 100644 --- a/x/emissions/keeper/msg_server_update_params.go +++ b/x/emissions/keeper/msg_server_update_params.go @@ -9,6 +9,8 @@ import ( "github.com/zeta-chain/zetacore/x/emissions/types" ) +// UpdateParams defines a governance operation for updating the x/emissions module parameters. +// The authority is hard-coded to the x/gov module account. func (k msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { if msg.Authority != k.authority { return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority) diff --git a/x/emissions/keeper/params.go b/x/emissions/keeper/params.go index c33c0c6317..2ba5a542a7 100644 --- a/x/emissions/keeper/params.go +++ b/x/emissions/keeper/params.go @@ -12,7 +12,11 @@ func (k Keeper) GetParams(ctx sdk.Context) (params types.Params, found bool) { if bz == nil { return types.Params{}, false } - k.cdc.MustUnmarshal(bz, ¶ms) + err := k.cdc.Unmarshal(bz, ¶ms) + if err != nil { + return types.Params{}, false + } + return params, true } @@ -23,7 +27,11 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { } store := ctx.KVStore(k.storeKey) - bz := k.cdc.MustMarshal(¶ms) + bz, err := k.cdc.Marshal(¶ms) + if err != nil { + return err + } + store.Set(types.KeyPrefix(types.ParamsKey), bz) return nil }