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