cosmos-sdk/x/auth/keeper/params.go
Facundo Medica d29e8eb4f6
refactor!: use KVStoreService in x/auth (#15520)
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
2023-03-27 18:57:02 +00:00

34 lines
727 B
Go

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