Julian Strobl b205c5ff29
Revert "Revert unnecessary config patch (#323)" (#324)
This reverts commit b1c4d11ccf3e98bd46a13d7fb54b6b5c0aefbf29.
2024-02-26 13:04:41 +01:00

39 lines
997 B
Go

package keeper
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/planetmint/planetmint-go/config"
"github.com/planetmint/planetmint-go/x/machine/types"
)
// GetParams get all parameters as types.Params
func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) {
store := ctx.KVStore(k.storeKey)
bz := store.Get(types.KeyPrefix(types.ParamsKey))
if bz == nil {
return params
}
k.cdc.MustUnmarshal(bz, &params)
params = types.Params{
AssetRegistryDomain: config.GetConfig().AssetRegistryDomain,
AssetRegistryPath: config.GetConfig().AssetRegistryPath,
AssetRegistryScheme: config.GetConfig().AssetRegistryScheme,
}
return params
}
// SetParams set the params
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error {
if err := params.Validate(); err != nil {
return err
}
store := ctx.KVStore(k.storeKey)
bz, err := k.cdc.Marshal(&params)
if err != nil {
return err
}
store.Set(types.KeyPrefix(types.ParamsKey), bz)
return nil
}