Some checks failed
CodeQL / Analyze (push) Waiting to run
Docker Build & Push Simapp (main) / docker-build (push) Waiting to run
golangci-lint / lint (push) Waiting to run
Tests / Code Coverage / build (amd64) (push) Waiting to run
Tests / Code Coverage / build (arm64) (push) Waiting to run
Tests / Code Coverage / unit-tests (map[additional-args:-tags="test_e2e" name:e2e path:./e2e]) (push) Waiting to run
Tests / Code Coverage / unit-tests (map[name:08-wasm path:./modules/light-clients/08-wasm]) (push) Waiting to run
Tests / Code Coverage / unit-tests (map[name:ibc-go path:.]) (push) Waiting to run
Deploy to GitHub Pages / Deploy to GitHub Pages (push) Has been cancelled
Buf-Push / push (push) Has been cancelled
42 lines
1.3 KiB
Go
42 lines
1.3 KiB
Go
package v7
|
|
|
|
import (
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
|
|
|
clientv7 "github.com/cosmos/ibc-go/v10/modules/core/02-client/migrations/v7"
|
|
ibcexported "github.com/cosmos/ibc-go/v10/modules/core/exported"
|
|
"github.com/cosmos/ibc-go/v10/modules/core/types"
|
|
)
|
|
|
|
// MigrateGenesis accepts an exported IBC client genesis file and migrates it to:
|
|
//
|
|
// - Update solo machine client state protobuf definition (v2 to v3)
|
|
// - Remove all solo machine consensus states
|
|
// - Remove any localhost clients
|
|
func MigrateGenesis(appState genutiltypes.AppMap, cdc codec.ProtoCodecMarshaler) (genutiltypes.AppMap, error) {
|
|
if appState[ibcexported.ModuleName] == nil {
|
|
return appState, nil
|
|
}
|
|
|
|
// ensure legacy solo machines types are registered
|
|
clientv7.RegisterInterfaces(cdc.InterfaceRegistry())
|
|
|
|
// unmarshal old ibc genesis state
|
|
ibcGenState := &types.GenesisState{}
|
|
cdc.MustUnmarshalJSON(appState[ibcexported.ModuleName], ibcGenState)
|
|
|
|
clientGenState, err := clientv7.MigrateGenesis(&ibcGenState.ClientGenesis, cdc)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
ibcGenState.ClientGenesis = *clientGenState
|
|
|
|
// delete old genesis state
|
|
delete(appState, ibcexported.ModuleName)
|
|
|
|
// set new ibc genesis state
|
|
appState[ibcexported.ModuleName] = cdc.MustMarshalJSON(ibcGenState)
|
|
return appState, nil
|
|
}
|