github.com/cosmos/cosmos-sdk@v0.50.10/x/slashing/migrations/v3/migrate.go (about)

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