github.com/cosmos/cosmos-sdk@v0.50.10/x/staking/keeper/migrations.go (about) 1 package keeper 2 3 import ( 4 "github.com/cosmos/cosmos-sdk/runtime" 5 sdk "github.com/cosmos/cosmos-sdk/types" 6 "github.com/cosmos/cosmos-sdk/x/staking/exported" 7 v2 "github.com/cosmos/cosmos-sdk/x/staking/migrations/v2" 8 v3 "github.com/cosmos/cosmos-sdk/x/staking/migrations/v3" 9 v4 "github.com/cosmos/cosmos-sdk/x/staking/migrations/v4" 10 v5 "github.com/cosmos/cosmos-sdk/x/staking/migrations/v5" 11 ) 12 13 // Migrator is a struct for handling in-place store migrations. 14 type Migrator struct { 15 keeper *Keeper 16 legacySubspace exported.Subspace 17 } 18 19 // NewMigrator returns a new Migrator instance. 20 func NewMigrator(keeper *Keeper, legacySubspace exported.Subspace) Migrator { 21 return Migrator{ 22 keeper: keeper, 23 legacySubspace: legacySubspace, 24 } 25 } 26 27 // Migrate1to2 migrates from version 1 to 2. 28 func (m Migrator) Migrate1to2(ctx sdk.Context) error { 29 store := runtime.KVStoreAdapter(m.keeper.storeService.OpenKVStore(ctx)) 30 return v2.MigrateStore(ctx, store) 31 } 32 33 // Migrate2to3 migrates x/staking state from consensus version 2 to 3. 34 func (m Migrator) Migrate2to3(ctx sdk.Context) error { 35 store := runtime.KVStoreAdapter(m.keeper.storeService.OpenKVStore(ctx)) 36 return v3.MigrateStore(ctx, store, m.keeper.cdc, m.legacySubspace) 37 } 38 39 // Migrate3to4 migrates x/staking state from consensus version 3 to 4. 40 func (m Migrator) Migrate3to4(ctx sdk.Context) error { 41 store := runtime.KVStoreAdapter(m.keeper.storeService.OpenKVStore(ctx)) 42 return v4.MigrateStore(ctx, store, m.keeper.cdc, m.legacySubspace) 43 } 44 45 // Migrate4to5 migrates x/staking state from consensus version 4 to 5. 46 func (m Migrator) Migrate4to5(ctx sdk.Context) error { 47 store := runtime.KVStoreAdapter(m.keeper.storeService.OpenKVStore(ctx)) 48 return v5.MigrateStore(ctx, store, m.keeper.cdc) 49 }