github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/cosmos-sdk/x/genutil/legacy/v0_39/migrate.go (about) 1 package v039 2 3 import ( 4 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/codec" 5 v038auth "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/x/auth/legacy/v0_38" 6 v039auth "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/x/auth/legacy/v0_39" 7 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/x/genutil/types" 8 ) 9 10 // Migrate migrates exported state from v0.38 to a v0.39 genesis state. 11 // 12 // NOTE: No actual migration occurs since the types do not change, but JSON 13 // serialization of accounts do change. 14 func Migrate(appState types.AppMap) types.AppMap { 15 v038Codec := codec.New() 16 codec.RegisterCrypto(v038Codec) 17 v038auth.RegisterCodec(v038Codec) 18 19 v039Codec := codec.New() 20 codec.RegisterCrypto(v039Codec) 21 v039auth.RegisterCodec(v039Codec) 22 23 // migrate x/auth state (JSON serialization only) 24 if appState[v038auth.ModuleName] != nil { 25 var authGenState v038auth.GenesisState 26 v038Codec.MustUnmarshalJSON(appState[v038auth.ModuleName], &authGenState) 27 28 delete(appState, v038auth.ModuleName) // delete old key in case the name changed 29 appState[v039auth.ModuleName] = v039Codec.MustMarshalJSON(v039auth.Migrate(authGenState)) 30 } 31 32 return appState 33 }