@@ -2,24 +2,49 @@ package app
2
2
3
3
import (
4
4
"fmt"
5
+ "math/big"
5
6
6
7
"github.com/cosmos/cosmos-sdk/codec"
7
8
storetypes "github.com/cosmos/cosmos-sdk/store/types"
8
9
sdk "github.com/cosmos/cosmos-sdk/types"
9
10
"github.com/cosmos/cosmos-sdk/types/module"
10
11
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
11
12
clientkeeper "github.com/cosmos/ibc-go/v7/modules/core/02-client/keeper"
13
+ "github.com/ethereum/go-ethereum/common"
12
14
13
15
e2eetypes "github.com/crypto-org-chain/cronos/v2/x/e2ee/types"
14
16
)
15
17
18
+ type contractMigration struct {
19
+ Contract common.Address
20
+ Slot common.Hash
21
+ Value common.Hash
22
+ }
23
+
24
+ // ContractMigrations records the list of contract migrations, chain-id -> migrations
25
+ var ContractMigrations = map [string ][]contractMigration {
26
+ "cronostestnet_338-3" : {
27
+ {
28
+ Contract : common .HexToAddress ("0x6265bf2371ccf45767184c8bd77b5c52e752c2bb" ),
29
+ Slot : common .BigToHash (big .NewInt (0 )),
30
+ Value : common .HexToHash ("0x000000000000000000000000730CbB94480d50788481373B43d83133e171367e" ),
31
+ },
32
+ },
33
+ }
34
+
16
35
func (app * App ) RegisterUpgradeHandlers (cdc codec.BinaryCodec , clientKeeper clientkeeper.Keeper ) {
17
36
planName := "v1.3"
18
37
app .UpgradeKeeper .SetUpgradeHandler (planName , func (ctx sdk.Context , _ upgradetypes.Plan , fromVM module.VersionMap ) (module.VersionMap , error ) {
19
38
m , err := app .mm .RunMigrations (ctx , app .configurator , fromVM )
20
39
if err != nil {
21
40
return m , err
22
41
}
42
+
43
+ // migrate contract states
44
+ for _ , migration := range ContractMigrations [ctx .ChainID ()] {
45
+ app .EvmKeeper .SetState (ctx , migration .Contract , migration .Slot , migration .Value .Bytes ())
46
+ }
47
+
23
48
return m , nil
24
49
})
25
50
0 commit comments