Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito committed Apr 23, 2024
1 parent 700fb8d commit 2b5a681
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions docs/spec/emissions/messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions x/emissions/keeper/msg_server_update_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 10 additions & 2 deletions x/emissions/keeper/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, &params)
err := k.cdc.Unmarshal(bz, &params)
if err != nil {
return types.Params{}, false

Check warning on line 17 in x/emissions/keeper/params.go

View check run for this annotation

Codecov / codecov/patch

x/emissions/keeper/params.go#L17

Added line #L17 was not covered by tests
}

return params, true
}

Expand All @@ -23,7 +27,11 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error {
}

store := ctx.KVStore(k.storeKey)
bz := k.cdc.MustMarshal(&params)
bz, err := k.cdc.Marshal(&params)
if err != nil {
return err

Check warning on line 32 in x/emissions/keeper/params.go

View check run for this annotation

Codecov / codecov/patch

x/emissions/keeper/params.go#L32

Added line #L32 was not covered by tests
}

store.Set(types.KeyPrefix(types.ParamsKey), bz)
return nil
}

0 comments on commit 2b5a681

Please sign in to comment.