Skip to content

Commit

Permalink
Deploy scripts: load message bus address dynamically (#2127)
Browse files Browse the repository at this point in the history
  • Loading branch information
BedrockSquirrel authored Nov 6, 2024
1 parent fafdc46 commit 4fce4ab
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
18 changes: 9 additions & 9 deletions contracts/deployment_scripts/testing/003_simple_withdrawal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,15 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
return;
const l2Network = hre;
const {deployer} = await hre.getNamedAccounts();

var mbusBase = await hre.ethers.getContractAt("MessageBus", "0x526c84529b2b8c11f57d93d3f5537aca3aecef9b");

const networkConfig : any = await hre.network.provider.request({method: 'net_config'});
console.log(`Network config = ${JSON.stringify(networkConfig, null, 2)}`);

const mgmtContractAddress = networkConfig.ManagementContractAddress;
const messageBusAddress = networkConfig.MessageBusAddress;
const l2MessageBusAddress = networkConfig.L2MessageBusAddress;

var mbusBase = await hre.ethers.getContractAt("MessageBus", l2MessageBusAddress);
const mbus = mbusBase.connect(await hre.ethers.provider.getSigner(deployer));
const tx = await mbus.getFunction("sendValueToL2").send(deployer, 1000, { value: 1000});
const receipt = await tx.wait()
Expand Down Expand Up @@ -96,13 +103,6 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
return
}


const networkConfig : any = await hre.network.provider.request({method: 'net_config'});
console.log(`Network config = ${JSON.stringify(networkConfig, null, 2)}`);

const mgmtContractAddress = networkConfig.ManagementContractAddress;
const messageBusAddress = networkConfig.MessageBusAddress;

const l1Accounts = await hre.companionNetworks.layer1.getNamedAccounts()
const fundTx = await hre.companionNetworks.layer1.deployments.rawTx({
from: l1Accounts.deployer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

console.log(` Using deployers for bridge interaction L1 address=${l1Accounts.deployer} L2 Address=${l2Accounts.deployer}`);

// Request the message bus address from the config endpoint
const networkConfig: any = await hre.network.provider.request({ method: 'net_config' });
if (!networkConfig || !networkConfig.L2MessageBusAddress) {
throw new Error("Failed to retrieve L2MessageBusAddress from network config");
}
const l2messageBusAddress = networkConfig.L2MessageBusAddress;
console.log(`Loaded message bus address = ${l2messageBusAddress}`);

// Tell the bridge to whitelist the address of HOC token. This generates a cross chain message.
let hocResult = await l1Network.deployments.execute("ObscuroBridge", {
from: l1Accounts.deployer,
Expand Down Expand Up @@ -95,7 +103,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
// Poll message submission
await new Promise(async (resolve, fail)=> {
setTimeout(fail, 30_000)
const messageBusContract = (await hre.ethers.getContractAt('MessageBus', '0x526c84529b2b8c11f57d93d3f5537aca3aecef9b'));
const messageBusContract = (await hre.ethers.getContractAt('MessageBus', l2messageBusAddress));
const gasLimit = await messageBusContract.getFunction('verifyMessageFinalized').estimateGas(messages[1], {
maxFeePerGas: 1000000001,
})
Expand Down

0 comments on commit 4fce4ab

Please sign in to comment.