Skip to content

Commit

Permalink
Contract deployers: configure signer for address publishing (#1676) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
BedrockSquirrel authored Feb 13, 2024
1 parent 3f487cb commit 53541be
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 20 deletions.
35 changes: 25 additions & 10 deletions contracts/deployment_scripts/bridge/001_deploy_bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,20 @@ 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 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");
const recordL1AddressTx = await mgmtContract.populateTransaction.SetImportantContractAddress("L1Bridge", layer1BridgeDeployment.address);

const receipt = await hre.companionNetworks.layer1.deployments.rawTx({
from: accountsL1.deployer,
to: mgmtContractAddress,
data: recordL1AddressTx.data,
log: true,
waitConfirmations: 1,
});
if (receipt.events?.length === 0) {
console.log(`Failed to set L1BridgeAddress=${layer1BridgeDeployment.address} on management contract.`);
} else {
console.log(`L1BridgeAddress=${layer1BridgeDeployment.address}`);
}
console.log(`L1BridgeAddress=${layer1BridgeDeployment.address}`)

// We get the Cross chain messenger deployment on the layer 2 network.
const messengerL2 = await deployments.get("CrossChainMessenger");
Expand All @@ -69,12 +77,19 @@ 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");
const recordL2AddressTx = await mgmtContract.populateTransaction.SetImportantContractAddress("L2Bridge", layer2BridgeDeployment.address);
const receipt2 = await hre.companionNetworks.layer1.deployments.rawTx({
from: accountsL1.deployer,
to: mgmtContractAddress,
data: recordL2AddressTx.data,
log: true,
waitConfirmations: 1,
});
if (receipt2.events?.length === 0) {
console.log(`Failed to set L2BridgeAddress=${layer2BridgeDeployment.address} on management contract.`);
} else {
console.log(`L2BridgeAddress=${layer2BridgeDeployment.address}`);
}
console.log(`L2BridgeAddress=${layer2BridgeDeployment.address}`)
console.log(` Bridge deployed with from L1 address=${accountsL1.deployer} L2 Address=${accountsL2.deployer}`);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,19 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

// get 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("L1CrossChainMessenger", crossChainDeployment.address);
const receipt = await tx.wait();
if (receipt.status !== 1) {
console.log("Failed to set L1CrossChainMessenger in management contract");
const tx = await mgmtContract.populateTransaction.SetImportantContractAddress("L1CrossChainMessenger", crossChainDeployment.address);
const receipt = await hre.companionNetworks.layer1.deployments.rawTx({
from: deployer,
to: mgmtContractAddress,
data: tx.data,
log: true,
waitConfirmations: 1,
});
if (receipt.events?.length === 0) {
console.log(`Failed to set L1CrossChainMessenger=${crossChainDeployment.address} on management contract.`);
} else {
console.log(`L1CrossChainMessenger=${crossChainDeployment.address}`);
}
console.log(`L1CrossChainMessenger=${crossChainDeployment.address}`);
};

export default func;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

// Get the prefunded L2 deployer account to use for deploying.
const {deployer} = await getNamedAccounts();
const l1Accounts = await companionNetworks.layer1.getNamedAccounts();

console.log(`Script: 001_deploy_cross_chain_messenger.ts - address used: ${deployer}`);

Expand All @@ -40,12 +41,19 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
});
// 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");
const tx = await mgmtContract.populateTransaction.SetImportantContractAddress("L2CrossChainMessenger", crossChainDeployment.address);
const receipt = await companionNetworks.layer1.deployments.rawTx({
from: l1Accounts.deployer,
to: mgmtContractAddress,
data: tx.data,
log: true,
waitConfirmations: 1,
});
if (receipt.events?.length === 0) {
console.log(`Failed to set L2CrossChainMessenger=${crossChainDeployment.address} on management contract.`);
} else {
console.log(`L2CrossChainMessenger=${crossChainDeployment.address}`);
}
console.log(`L2CrossChainMessenger=${crossChainDeployment.address}`);
};

export default func;
Expand Down

0 comments on commit 53541be

Please sign in to comment.