mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-05-22 14:56:39 +00:00

* Revert "feat: bring back config parameters" This reverts commit 4ab279033cae5e351cd13c348a21e4717705f341. Unnecessary because cosmos sdk handles chain upgrades properly: it holds the chain and waits for a new binary version. * refactor: use testnet parameters as default in x/dao --------- Signed-off-by: Julian Strobl <jmastr@mailbox.org>
33 lines
737 B
Go
33 lines
737 B
Go
package keeper
|
|
|
|
import (
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"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, ¶ms)
|
|
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(¶ms)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
store.Set(types.KeyPrefix(types.ParamsKey), bz)
|
|
|
|
return nil
|
|
}
|