cosmos-sdk/x/auth/keeper/params.go
likhita-809 1815981b02
feat: deprecate x/params usage in x/auth (#12475)
* generate proto files

* wip

* wip: fix tests

* wip: add tests

* fix tests

* fix tests

* add changelog

* address review comments

* address review comments

* add err check for setparams

* updates

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Aleksandr Bezobchuk <aleks.bezobchuk@gmail.com>
2022-07-11 19:16:27 +02:00

31 lines
700 B
Go

package keeper
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/types"
)
// SetParams sets the auth module's parameters.
func (ak AccountKeeper) SetParams(ctx sdk.Context, params types.Params) error {
if err := params.Validate(); err != nil {
return err
}
store := ctx.KVStore(ak.storeKey)
bz := ak.cdc.MustMarshal(&params)
store.Set(types.ParamsKey, bz)
return nil
}
// GetParams gets the auth module's parameters.
func (ak AccountKeeper) GetParams(ctx sdk.Context) (params types.Params) {
store := ctx.KVStore(ak.storeKey)
bz := store.Get(types.ParamsKey)
if bz == nil {
return params
}
ak.cdc.MustUnmarshal(bz, &params)
return params
}