mukan-ibc/modules/core/migrations/v7/genesis.go
Mukan Erkin Törük 88dd97a9f8
Some checks failed
CodeQL / Analyze (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
Docker Build & Push Simapp (main) / docker-build (push) Has been cancelled
refactor: replace all github.com upstream refs with git.cw.tr/mukan-network
2026-05-11 03:36:22 +03:00

42 lines
1.3 KiB
Go

package v7
import (
"git.cw.tr/mukan-network/mukan-sdk/codec"
genutiltypes "git.cw.tr/mukan-network/mukan-sdk/x/genutil/types"
clientv7 "git.cw.tr/mukan-network/mukan-ibc/modules/core/02-client/migrations/v7"
ibcexported "git.cw.tr/mukan-network/mukan-ibc/modules/core/exported"
"git.cw.tr/mukan-network/mukan-ibc/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
}