Julian Strobl 412e15449b feat: add migration to v0.8.0
Take x/dao and x/machine default parameters and store them into the
respective module state.

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2024-02-26 08:30:10 +01:00

26 lines
708 B
Go

package v2
import (
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/planetmint/planetmint-go/x/machine/types"
)
// MigrateStore migrates the x/machine module state from the consensus version
// 1 to version 2. Specifically, it takes the default params and stores them
// directly into the x/machine module state.
func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error {
store := ctx.KVStore(storeKey)
params := types.DefaultParams()
bz, err := cdc.Marshal(&params)
if err != nil {
return err
}
store.Set(types.KeyPrefix(types.ParamsKey), bz)
return nil
}