-
Notifications
You must be signed in to change notification settings - Fork 28
/
migrate.go
46 lines (38 loc) · 1.09 KB
/
migrate.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package v2
import (
"github.com/OmniFlix/omniflixhub/v2/x/onft/exported"
"github.com/OmniFlix/omniflixhub/v2/x/onft/types"
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
const (
ModuleName = "onft"
)
var ParamsKey = []byte{0x07}
// Migrate migrates the onft module state from the consensus version 1 to
// version 2. Specifically, it takes the parameters that are currently stored
// and managed by the x/params modules and stores them directly into the onft
// module state.
func Migrate(
ctx sdk.Context,
storeKey storetypes.StoreKey,
legacySubspace exported.Subspace,
cdc codec.BinaryCodec,
nftKeeper NFTKeeper,
) error {
var currParams types.Params
legacySubspace.GetParamSet(ctx, &currParams)
k := keeper{
storeKey: storeKey,
cdc: cdc,
nftKeeper: nftKeeper,
}
if err := currParams.ValidateBasic(); err != nil {
return err
}
store := ctx.KVStore(k.storeKey)
bz := cdc.MustMarshal(&currParams)
store.Set(ParamsKey, bz)
return MigrateCollections(ctx, storeKey, cdc, ctx.Logger(), k)
}