From 59e4a8c356e531ebce25678801ec8128f5aaee67 Mon Sep 17 00:00:00 2001 From: Benjamin Patch Date: Wed, 25 Oct 2023 09:58:24 +1100 Subject: [PATCH 1/2] Remove need for child eth token env var in deployment scripts --- .env.sample | 3 +-- script/InitializeRootContracts.s.sol | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.env.sample b/.env.sample index f1854b16..957e611b 100644 --- a/.env.sample +++ b/.env.sample @@ -10,5 +10,4 @@ ROOT_GAS_SERVICE_ADDRESS= CHILD_GAS_SERVICE_ADDRESS= ROOT_CHAIN_NAME= CHILD_CHAIN_NAME= -ROOT_IMX_ADDRESS= -CHILD_ETH_ADDRESS= \ No newline at end of file +ROOT_IMX_ADDRESS= \ No newline at end of file diff --git a/script/InitializeRootContracts.s.sol b/script/InitializeRootContracts.s.sol index 56dc7e35..ad935886 100644 --- a/script/InitializeRootContracts.s.sol +++ b/script/InitializeRootContracts.s.sol @@ -22,7 +22,6 @@ contract InitializeRootContracts is Script { string memory rootRpcUrl = vm.envString("ROOT_RPC_URL"); uint256 rootPrivateKey = vm.envUint("ROOT_PRIVATE_KEY"); address rootIMXToken = vm.envAddress("ROOT_IMX_ADDRESS"); - address childETHToken = vm.envAddress("CHILD_ETH_ADDRESS"); /** * INITIALIZE ROOT CHAIN CONTRACTS From 56737b439c0a65058ad241c32c0f442ebca58e82 Mon Sep 17 00:00:00 2001 From: Benjamin Patch Date: Wed, 25 Oct 2023 11:11:24 +1100 Subject: [PATCH 2/2] Predict the child ETH address properly --- src/root/RootERC20Bridge.sol | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/root/RootERC20Bridge.sol b/src/root/RootERC20Bridge.sol index 17aab64b..8a7486a1 100644 --- a/src/root/RootERC20Bridge.sol +++ b/src/root/RootERC20Bridge.sol @@ -75,9 +75,10 @@ contract RootERC20Bridge is childERC20Bridge = newChildERC20Bridge; childTokenTemplate = newChildTokenTemplate; rootIMXToken = newRootIMXToken; - IChildERC20 clonedETHToken = - IChildERC20(Clones.cloneDeterministic(childTokenTemplate, keccak256(abi.encodePacked(NATIVE_ETH)))); - childETHToken = address(clonedETHToken); + + childETHToken = Clones.predictDeterministicAddress( + childTokenTemplate, keccak256(abi.encodePacked(NATIVE_ETH)), childERC20Bridge + ); rootBridgeAdaptor = IRootERC20BridgeAdaptor(newRootBridgeAdaptor); childBridgeAdaptor = Strings.toHexString(newChildBridgeAdaptor); }