github.com/cosmos/cosmos-sdk@v0.50.10/x/auth/migrations/v4/migrate.go (about) 1 package v4 2 3 import ( 4 storetypes "cosmossdk.io/core/store" 5 6 "github.com/cosmos/cosmos-sdk/codec" 7 sdk "github.com/cosmos/cosmos-sdk/types" 8 "github.com/cosmos/cosmos-sdk/x/auth/exported" 9 "github.com/cosmos/cosmos-sdk/x/auth/types" 10 ) 11 12 var ParamsKey = []byte{0x00} 13 14 // Migrate migrates the x/auth module state from the consensus version 3 to 15 // version 4. Specifically, it takes the parameters that are currently stored 16 // and managed by the x/params modules and stores them directly into the x/auth 17 // module state. 18 func Migrate(ctx sdk.Context, storeService storetypes.KVStoreService, legacySubspace exported.Subspace, cdc codec.BinaryCodec) error { 19 store := storeService.OpenKVStore(ctx) 20 var currParams types.Params 21 legacySubspace.GetParamSet(ctx, &currParams) 22 23 if err := currParams.Validate(); err != nil { 24 return err 25 } 26 27 bz := cdc.MustMarshal(&currParams) 28 store.Set(ParamsKey, bz) 29 30 return nil 31 }