-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Contract deploy: record L2 contract addresses #1667
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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(); | ||||||
|
@@ -25,11 +28,20 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | |||||
console.log(`Beginning deploy of cross chain messenger`); | ||||||
|
||||||
// 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, | ||||||
args: [ busAddress ], | ||||||
log: true, | ||||||
}); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no error handling for the deployment of |
||||||
|
||||||
// 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"); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The error message in the - console.log("Failed to set L2CrossChainMessenger in management contract");
+ console.log(`Failed to set L2CrossChainMessenger in management contract, transaction hash: ${tx.hash}`); Committable suggestion
Suggested change
|
||||||
} | ||||||
console.log(`L2CrossChainMessenger=${crossChainDeployment.address}`); | ||||||
}; | ||||||
|
||||||
export default func; | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The non-null assertion operator
!!
is used without checking ifMGMT_CONTRACT_ADDRESS
is actually set, which could lead to runtime errors if the environment variable is not provided. Consider adding a check to ensure the variable is set before using it.Committable suggestion