@@ -16,7 +16,9 @@ import (
1616 "github.com/ChainSafe/chainbridge-core/chains/evm/calls/transactor"
1717 "github.com/ChainSafe/chainbridge-core/chains/evm/calls/transactor/signAndSend"
1818 "github.com/ChainSafe/chainbridge-core/keystore"
19+ "github.com/ChainSafe/chainbridge-core/types"
1920 "github.com/ethereum/go-ethereum/common"
21+ "github.com/ethereum/go-ethereum/common/hexutil"
2022 "github.com/rs/zerolog/log"
2123)
2224
@@ -42,6 +44,9 @@ type EVME2EConfig struct {
4244 GenericHandlerAddr common.Address
4345 Erc721Addr common.Address
4446 Erc721HandlerAddr common.Address
47+ ResourceIDERC20 string
48+ ResourceIDERC721 string
49+ ResourceIDGeneric string
4550}
4651
4752type E2EClient interface {
@@ -88,6 +93,12 @@ func PrepareLocalEVME2EEnv(
8893 return EVME2EConfig {}, err
8994 }
9095
96+ resourceIDERC20 := calls .SliceTo32Bytes (common .LeftPadBytes ([]byte {0 }, 31 ))
97+
98+ resourceIDGenericHandler := calls .SliceTo32Bytes (common .LeftPadBytes ([]byte {1 }, 31 ))
99+
100+ resourceIDERC721 := calls .SliceTo32Bytes (common .LeftPadBytes ([]byte {2 }, 31 ))
101+
91102 conf := EVME2EConfig {
92103 BridgeAddr : bridgeContractAddress ,
93104
@@ -99,19 +110,22 @@ func PrepareLocalEVME2EEnv(
99110
100111 Erc721Addr : erc721ContractAddress ,
101112 Erc721HandlerAddr : erc721HandlerContractAddress ,
113+ ResourceIDERC20 : hexutil .Encode (resourceIDERC20 [:]),
114+ ResourceIDERC721 : hexutil .Encode (resourceIDERC721 [:]),
115+ ResourceIDGeneric : hexutil .Encode (resourceIDGenericHandler [:]),
102116 }
103117
104- err = PrepareErc20EVME2EEnv (bridgeContract , erc20Contract , mintTo , conf )
118+ err = PrepareErc20EVME2EEnv (bridgeContract , erc20Contract , mintTo , conf , resourceIDERC20 )
105119 if err != nil {
106120 return EVME2EConfig {}, err
107121 }
108122
109- err = PrepareErc721EVME2EEnv (bridgeContract , erc721Contract , conf )
123+ err = PrepareErc721EVME2EEnv (bridgeContract , erc721Contract , conf , resourceIDERC721 )
110124 if err != nil {
111125 return EVME2EConfig {}, err
112126 }
113127
114- err = PrepareGenericEVME2EEnv (bridgeContract , conf )
128+ err = PrepareGenericEVME2EEnv (bridgeContract , conf , resourceIDGenericHandler )
115129 if err != nil {
116130 return EVME2EConfig {}, err
117131 }
@@ -181,10 +195,8 @@ func deployErc721(
181195}
182196
183197func PrepareErc20EVME2EEnv (
184- bridgeContract * bridge.BridgeContract , erc20Contract * erc20.ERC20Contract , mintTo common.Address , conf EVME2EConfig ,
198+ bridgeContract * bridge.BridgeContract , erc20Contract * erc20.ERC20Contract , mintTo common.Address , conf EVME2EConfig , resourceID types. ResourceID ,
185199) error {
186- // Setting resource
187- resourceID := calls .SliceTo32Bytes (common .LeftPadBytes ([]byte {0 }, 31 ))
188200 _ , err := bridgeContract .AdminSetResource (
189201 conf .Erc20HandlerAddr , resourceID , conf .Erc20Addr , transactor.TransactOptions {GasLimit : 2000000 },
190202 )
@@ -215,8 +227,7 @@ func PrepareErc20EVME2EEnv(
215227 return nil
216228}
217229
218- func PrepareGenericEVME2EEnv (bridgeContract * bridge.BridgeContract , conf EVME2EConfig ) error {
219- resourceID := calls .SliceTo32Bytes (common .LeftPadBytes ([]byte {1 }, 31 ))
230+ func PrepareGenericEVME2EEnv (bridgeContract * bridge.BridgeContract , conf EVME2EConfig , resourceID types.ResourceID ) error {
220231 _ , err := bridgeContract .AdminSetGenericResource (
221232 conf .GenericHandlerAddr ,
222233 resourceID ,
@@ -232,9 +243,7 @@ func PrepareGenericEVME2EEnv(bridgeContract *bridge.BridgeContract, conf EVME2EC
232243 return nil
233244}
234245
235- func PrepareErc721EVME2EEnv (bridgeContract * bridge.BridgeContract , erc721Contract * erc721.ERC721Contract , conf EVME2EConfig ) error {
236- // Registering resource
237- resourceID := calls .SliceTo32Bytes (common .LeftPadBytes ([]byte {2 }, 31 ))
246+ func PrepareErc721EVME2EEnv (bridgeContract * bridge.BridgeContract , erc721Contract * erc721.ERC721Contract , conf EVME2EConfig , resourceID types.ResourceID ) error {
238247 _ , err := bridgeContract .AdminSetResource (conf .Erc721HandlerAddr , resourceID , conf .Erc721Addr , transactor.TransactOptions {GasLimit : 2000000 })
239248 if err != nil {
240249 return err
0 commit comments