2021-03-22 04:30:26 -07:00
|
|
|
package v043
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
|
|
|
"github.com/cosmos/cosmos-sdk/x/genutil/types"
|
2021-07-05 07:55:51 -07:00
|
|
|
v040gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v040"
|
|
|
|
v043gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v043"
|
2021-06-23 06:03:33 -07:00
|
|
|
gov "github.com/cosmos/cosmos-sdk/x/gov/types"
|
2021-03-22 04:30:26 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
// Migrate migrates exported state from v0.40 to a v0.43 genesis state.
|
|
|
|
func Migrate(appState types.AppMap, clientCtx client.Context) types.AppMap {
|
|
|
|
// Migrate x/gov.
|
|
|
|
if appState[v040gov.ModuleName] != nil {
|
|
|
|
// unmarshal relative source genesis application state
|
2021-06-23 06:03:33 -07:00
|
|
|
var oldGovState gov.GenesisState
|
2021-06-11 04:49:39 -07:00
|
|
|
clientCtx.Codec.MustUnmarshalJSON(appState[v040gov.ModuleName], &oldGovState)
|
2021-03-22 04:30:26 -07:00
|
|
|
|
|
|
|
// delete deprecated x/gov genesis state
|
|
|
|
delete(appState, v040gov.ModuleName)
|
|
|
|
|
|
|
|
// Migrate relative source genesis application state and marshal it into
|
|
|
|
// the respective key.
|
2021-06-11 04:49:39 -07:00
|
|
|
appState[v043gov.ModuleName] = clientCtx.Codec.MustMarshalJSON(v043gov.MigrateJSON(&oldGovState))
|
2021-03-22 04:30:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return appState
|
|
|
|
}
|