github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/x/genutil/client/legacy/v0_18/migrate.go (about) 1 package v018 2 3 import ( 4 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/codec" 5 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/x/genutil" 6 v016evm "github.com/fibonacci-chain/fbc/x/evm/legacy/v0_16" 7 v018evm "github.com/fibonacci-chain/fbc/x/evm/legacy/v0_18" 8 v011staking "github.com/fibonacci-chain/fbc/x/staking/legacy/v0_11" 9 v018staking "github.com/fibonacci-chain/fbc/x/staking/legacy/v0_18" 10 ) 11 12 // Migrate migrates exported state from v0.16 to a v0.17 genesis state. 13 func Migrate(appState genutil.AppMap) genutil.AppMap { 14 v016Codec := codec.New() 15 codec.RegisterCrypto(v016Codec) 16 17 v018Codec := codec.New() 18 codec.RegisterCrypto(v018Codec) 19 20 // migrate auth state 21 if appState[v018evm.ModuleName] != nil { 22 var evmState v016evm.GenesisState 23 v016Codec.MustUnmarshalJSON(appState[v018evm.ModuleName], &evmState) 24 25 delete(appState, v018evm.ModuleName) // delete old key in case the name changed 26 appState[v018evm.ModuleName] = v018Codec.MustMarshalJSON(v018evm.Migrate(evmState)) 27 } 28 29 // migrate statking state 30 if appState[v018staking.ModuleName] != nil { 31 var stakingState v011staking.GenesisState 32 v016Codec.MustUnmarshalJSON(appState[v018staking.ModuleName], &stakingState) 33 34 delete(appState, v018staking.ModuleName) // delete old key in case the name changed 35 appState[v018staking.ModuleName] = v018Codec.MustMarshalJSON(v018staking.Migrate(stakingState)) 36 } 37 38 return appState 39 }