Commit 7746080f authored by Mark Tyneway's avatar Mark Tyneway

contracts-bedrock: fixup new hh deploy config usage

parent 2efd7f3a
...@@ -7,7 +7,7 @@ import { assertContractVariable, deploy } from '../src/deploy-utils' ...@@ -7,7 +7,7 @@ import { assertContractVariable, deploy } from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => { const deployFn: DeployFunction = async (hre) => {
const l1 = hre.network.companionNetworks['l1'] const l1 = hre.network.companionNetworks['l1']
const deployConfig = hre.deployConfig.getDeployConfig(l1) const deployConfig = hre.getDeployConfig(l1)
const sequencerFeeVaultRecipient = deployConfig.sequencerFeeVaultRecipient const sequencerFeeVaultRecipient = deployConfig.sequencerFeeVaultRecipient
if (sequencerFeeVaultRecipient === ethers.constants.AddressZero) { if (sequencerFeeVaultRecipient === ethers.constants.AddressZero) {
......
...@@ -7,7 +7,7 @@ import { assertContractVariable, deploy } from '../src/deploy-utils' ...@@ -7,7 +7,7 @@ import { assertContractVariable, deploy } from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => { const deployFn: DeployFunction = async (hre) => {
const l1 = hre.network.companionNetworks['l1'] const l1 = hre.network.companionNetworks['l1']
const deployConfig = hre.deployConfig.getDeployConfig(l1) const deployConfig = hre.getDeployConfig(l1)
const baseFeeVaultRecipient = deployConfig.baseFeeVaultRecipient const baseFeeVaultRecipient = deployConfig.baseFeeVaultRecipient
if (baseFeeVaultRecipient === ethers.constants.AddressZero) { if (baseFeeVaultRecipient === ethers.constants.AddressZero) {
......
...@@ -7,7 +7,7 @@ import { assertContractVariable, deploy } from '../src/deploy-utils' ...@@ -7,7 +7,7 @@ import { assertContractVariable, deploy } from '../src/deploy-utils'
const deployFn: DeployFunction = async (hre) => { const deployFn: DeployFunction = async (hre) => {
const l1 = hre.network.companionNetworks['l1'] const l1 = hre.network.companionNetworks['l1']
const deployConfig = hre.deployConfig.getDeployConfig(l1) const deployConfig = hre.getDeployConfig(l1)
const l1FeeVaultRecipient = deployConfig.l1FeeVaultRecipient const l1FeeVaultRecipient = deployConfig.l1FeeVaultRecipient
if (l1FeeVaultRecipient === ethers.constants.AddressZero) { if (l1FeeVaultRecipient === ethers.constants.AddressZero) {
......
...@@ -44,6 +44,15 @@ export const deploy = async ({ ...@@ -44,6 +44,15 @@ export const deploy = async ({
// external deployments when doing this check. By doing the check ourselves, we also get to // external deployments when doing this check. By doing the check ourselves, we also get to
// consider external deployments. If we already have the deployment, return early. // consider external deployments. If we already have the deployment, return early.
let result: Deployment | DeployResult = await hre.deployments.getOrNull(name) let result: Deployment | DeployResult = await hre.deployments.getOrNull(name)
// Wrap in a try/catch in case there is not a deployConfig for the current network.
let numDeployConfirmations: number
try {
numDeployConfirmations = hre.deployConfig.numDeployConfirmations
} catch (e) {
numDeployConfirmations = 1
}
if (result) { if (result) {
console.log(`skipping ${name}, using existing at ${result.address}`) console.log(`skipping ${name}, using existing at ${result.address}`)
} else { } else {
...@@ -52,7 +61,7 @@ export const deploy = async ({ ...@@ -52,7 +61,7 @@ export const deploy = async ({
from: deployer, from: deployer,
args, args,
log: true, log: true,
waitConfirmations: hre.deployConfig.numDeployConfirmations, waitConfirmations: numDeployConfirmations,
}) })
console.log(`Deployed ${name} at ${result.address}`) console.log(`Deployed ${name} at ${result.address}`)
// Only wait for the transaction if it was recently deployed in case the // Only wait for the transaction if it was recently deployed in case the
...@@ -68,7 +77,7 @@ export const deploy = async ({ ...@@ -68,7 +77,7 @@ export const deploy = async ({
// Create the contract object to return. // Create the contract object to return.
const created = asAdvancedContract({ const created = asAdvancedContract({
confirmations: hre.deployConfig.numDeployConfirmations, confirmations: numDeployConfirmations,
contract: new Contract( contract: new Contract(
result.address, result.address,
iface !== undefined iface !== undefined
...@@ -122,41 +131,41 @@ export const asAdvancedContract = (opts: { ...@@ -122,41 +131,41 @@ export const asAdvancedContract = (opts: {
// Override each function call to also `.wait()` so as to simplify the deploy scripts' syntax. // Override each function call to also `.wait()` so as to simplify the deploy scripts' syntax.
for (const fnName of Object.keys(contract.functions)) { for (const fnName of Object.keys(contract.functions)) {
const fn = contract[fnName].bind(contract) const fn = contract[fnName].bind(contract)
;(contract as any)[fnName] = async (...args: any) => { ; (contract as any)[fnName] = async (...args: any) => {
// We want to use the configured gas price but we need to set the gas price to zero if we're // We want to use the configured gas price but we need to set the gas price to zero if we're
// triggering a static function. // triggering a static function.
let gasPrice = opts.gasPrice let gasPrice = opts.gasPrice
if (contract.interface.getFunction(fnName).constant) { if (contract.interface.getFunction(fnName).constant) {
gasPrice = 0 gasPrice = 0
} }
// Now actually trigger the transaction (or call). // Now actually trigger the transaction (or call).
const tx = await fn(...args, { const tx = await fn(...args, {
gasPrice, gasPrice,
}) })
// Meant for static calls, we don't need to wait for anything, we get the result right away. // Meant for static calls, we don't need to wait for anything, we get the result right away.
if (typeof tx !== 'object' || typeof tx.wait !== 'function') { if (typeof tx !== 'object' || typeof tx.wait !== 'function') {
return tx return tx
} }
// Wait for the transaction to be included in a block and wait for the specified number of // Wait for the transaction to be included in a block and wait for the specified number of
// deployment confirmations. // deployment confirmations.
const maxTimeout = 120 const maxTimeout = 120
let timeout = 0 let timeout = 0
while (true) { while (true) {
await sleep(1000) await sleep(1000)
const receipt = await contract.provider.getTransactionReceipt(tx.hash) const receipt = await contract.provider.getTransactionReceipt(tx.hash)
if (receipt === null) { if (receipt === null) {
timeout++ timeout++
if (timeout > maxTimeout) { if (timeout > maxTimeout) {
throw new Error('timeout exceeded waiting for txn to be mined') throw new Error('timeout exceeded waiting for txn to be mined')
}
} else if (receipt.confirmations >= (opts.confirmations || 0)) {
return tx
} }
} else if (receipt.confirmations >= (opts.confirmations || 0)) {
return tx
} }
} }
}
} }
return contract return contract
...@@ -199,8 +208,15 @@ export const getContractFromArtifact = async ( ...@@ -199,8 +208,15 @@ export const getContractFromArtifact = async (
} }
} }
let numDeployConfirmations: number
try {
numDeployConfirmations = hre.deployConfig.numDeployConfirmations
} catch (e) {
numDeployConfirmations = 1
}
return asAdvancedContract({ return asAdvancedContract({
confirmations: hre.deployConfig.numDeployConfirmations, confirmations: numDeployConfirmations,
contract: new hre.ethers.Contract( contract: new hre.ethers.Contract(
artifact.address, artifact.address,
iface, iface,
...@@ -385,14 +401,13 @@ export const getTenderlySimulationLink = async ( ...@@ -385,14 +401,13 @@ export const getTenderlySimulationLink = async (
tx: ethers.PopulatedTransaction tx: ethers.PopulatedTransaction
): Promise<string> => { ): Promise<string> => {
if (process.env.TENDERLY_PROJECT && process.env.TENDERLY_USERNAME) { if (process.env.TENDERLY_PROJECT && process.env.TENDERLY_USERNAME) {
return `https://dashboard.tenderly.co/${process.env.TENDERLY_PROJECT}/${ return `https://dashboard.tenderly.co/${process.env.TENDERLY_PROJECT}/${process.env.TENDERLY_USERNAME
process.env.TENDERLY_USERNAME }/simulator/new?${new URLSearchParams({
}/simulator/new?${new URLSearchParams({ network: (await provider.getNetwork()).chainId.toString(),
network: (await provider.getNetwork()).chainId.toString(), contractAddress: tx.to,
contractAddress: tx.to, rawFunctionInput: tx.data,
rawFunctionInput: tx.data, from: tx.from,
from: tx.from, }).toString()}`
}).toString()}`
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment