diff --git a/contracts/deployment_scripts/bridge/001_deploy_bridge.ts b/contracts/deployment_scripts/bridge/001_deploy_bridge.ts index e912483d60..03b66c9dc4 100644 --- a/contracts/deployment_scripts/bridge/001_deploy_bridge.ts +++ b/contracts/deployment_scripts/bridge/001_deploy_bridge.ts @@ -38,8 +38,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { // get management contract and write the L1 bridge address to it const mgmtContract = (await hre.ethers.getContractFactory('ManagementContract')).attach(mgmtContractAddress) - const tx = await mgmtContract.SetImportantContractAddress("L1Bridge", layer1BridgeDeployment.address); - const receipt = await tx.wait(); + const recordL1AddressTx = await mgmtContract.SetImportantContractAddress("L1Bridge", layer1BridgeDeployment.address); + const receipt = await recordL1AddressTx.wait(); if (receipt.status !== 1) { console.log("Failed to set L1BridgeAddress in management contract"); } @@ -69,6 +69,12 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { log: true, }, "setRemoteBridge", layer2BridgeDeployment.address); + const recordL2AddressTx = await mgmtContract.SetImportantContractAddress("L2Bridge", layer2BridgeDeployment.address); + const receipt2 = await recordL2AddressTx.wait(); + if (receipt2.status !== 1) { + console.log("Failed to set L2BridgeAddress in management contract"); + } + console.log(`L2BridgeAddress=${layer2BridgeDeployment.address}`) console.log(` Bridge deployed with from L1 address=${accountsL1.deployer} L2 Address=${accountsL2.deployer}`); }; diff --git a/contracts/deployment_scripts/messenger/layer1/001_deploy_cross_chain_messenger.ts b/contracts/deployment_scripts/messenger/layer1/001_deploy_cross_chain_messenger.ts index 8311cf2227..bbe54b4b37 100644 --- a/contracts/deployment_scripts/messenger/layer1/001_deploy_cross_chain_messenger.ts +++ b/contracts/deployment_scripts/messenger/layer1/001_deploy_cross_chain_messenger.ts @@ -41,7 +41,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { if (receipt.status !== 1) { console.log("Failed to set L1CrossChainMessenger in management contract"); } - console.log(`L1CrossChainMessenger=${crossChainDeployment.address}`) + console.log(`L1CrossChainMessenger=${crossChainDeployment.address}`); }; export default func; diff --git a/contracts/deployment_scripts/messenger/layer2/001_deploy_cross_chain_messenger.ts b/contracts/deployment_scripts/messenger/layer2/001_deploy_cross_chain_messenger.ts index b49c9d797a..bf46fa65aa 100644 --- a/contracts/deployment_scripts/messenger/layer2/001_deploy_cross_chain_messenger.ts +++ b/contracts/deployment_scripts/messenger/layer2/001_deploy_cross_chain_messenger.ts @@ -11,8 +11,11 @@ import {DeployFunction} from 'hardhat-deploy/types'; const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const { deployments, - getNamedAccounts + getNamedAccounts, + companionNetworks, } = hre; + // Use the contract addresses from the management contract deployment. + const mgmtContractAddress = process.env.MGMT_CONTRACT_ADDRESS!! // Get the prefunded L2 deployer account to use for deploying. const {deployer} = await getNamedAccounts(); @@ -22,7 +25,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { // TODO: Remove hardcoded L2 message bus address when properly exposed. const messageBusAddress = hre.ethers.utils.getAddress("0x526c84529b2b8c11f57d93d3f5537aca3aecef9b"); // Deploy the L2 Cross chain messenger and use the L2 bus for validation - await deployments.deploy('CrossChainMessenger', { + const crossChainDeployment = await deployments.deploy('CrossChainMessenger', { from: deployer, log: true, proxy: { @@ -35,7 +38,14 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { } } }); - console.log("Deployed!") + // get L1 management contract and write the cross chain messenger address to it + const mgmtContract = (await hre.ethers.getContractFactory('ManagementContract')).attach(mgmtContractAddress); + const tx = await mgmtContract.SetImportantContractAddress("L2CrossChainMessenger", crossChainDeployment.address); + const receipt = await tx.wait(); + if (receipt.status !== 1) { + console.log("Failed to set L2CrossChainMessenger in management contract"); + } + console.log(`L2CrossChainMessenger=${crossChainDeployment.address}`); }; export default func;