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

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