Commit 29a33b96 authored by Maurelian's avatar Maurelian Committed by Kelvin Fichter

fix(contracts): Use chainId to detect hh environments

parent c3db334f
/* Imports: External */ /* Imports: External */
import { hexStringEquals, awaitCondition } from '@eth-optimism/core-utils' import { hexStringEquals, awaitCondition } from '@eth-optimism/core-utils'
import { DeployFunction } from 'hardhat-deploy/dist/types' import { DeployFunction } from 'hardhat-deploy/dist/types'
import { defaultHardhatNetworkParams } from 'hardhat/internal/core/config/default-config'
/* Imports: Internal */ /* Imports: Internal */
import { getContractFromArtifact } from '../src/hardhat-deploy-ethers' import { getContractFromArtifact } from '../src/hardhat-deploy-ethers'
...@@ -71,15 +72,11 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -71,15 +72,11 @@ const deployFn: DeployFunction = async (hre) => {
(4) Wait for the deploy process to continue. (4) Wait for the deploy process to continue.
`) `)
// Check if the hardhat runtime environment has the owner of the AddressManager. This will only // Only execute this step if we're on the hardhat chain ID. This will only happen in CI. If this
// happen in CI. If this is the case, we can skip directly to transferring ownership over to the // is the case, we can skip directly to transferring ownership over to the AddressDictator
// AddressDictator contract. // contract.
const hreSigners = await hre.ethers.getSigners() const { chainId } = await hre.ethers.provider.getNetwork()
const hreHasOwner = hreSigners.some((signer) => { if (chainId === defaultHardhatNetworkParams.chainId) {
return hexStringEquals(signer.address, currentOwner)
})
if (hreHasOwner) {
// Hardhat has the owner loaded into it, we can skip directly to transferOwnership.
const owner = await hre.ethers.getSigner(currentOwner) const owner = await hre.ethers.getSigner(currentOwner)
await Lib_AddressManager.connect(owner).transferOwnership( await Lib_AddressManager.connect(owner).transferOwnership(
AddressDictator.address AddressDictator.address
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import { DeployFunction } from 'hardhat-deploy/dist/types' import { DeployFunction } from 'hardhat-deploy/dist/types'
import { ethers } from 'ethers' import { ethers } from 'ethers'
import { hexStringEquals, awaitCondition } from '@eth-optimism/core-utils' import { hexStringEquals, awaitCondition } from '@eth-optimism/core-utils'
import { defaultHardhatNetworkParams } from 'hardhat/internal/core/config/default-config'
/* Imports: Internal */ /* Imports: Internal */
import { getContractDefinition } from '../src/contract-defs' import { getContractDefinition } from '../src/contract-defs'
...@@ -82,16 +83,10 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -82,16 +83,10 @@ const deployFn: DeployFunction = async (hre) => {
(4) Wait for the deploy process to continue. (4) Wait for the deploy process to continue.
`) `)
// Check if the hardhat runtime environment has the owner of the proxy. This will only // Check if if we're on the hardhat chain ID. This will only happen in CI. If this is the case, we
// happen in CI. If this is the case, we can skip directly to transferring ownership over to the // can skip directly to transferring ownership over to the ChugSplashDictator contract.
// ChugSplashDictator contract. const { chainId } = await hre.ethers.provider.getNetwork()
const hreSigners = await hre.ethers.getSigners() if (chainId === defaultHardhatNetworkParams.chainId) {
const hreHasOwner = hreSigners.some((signer) => {
return hexStringEquals(signer.address, currentOwner)
})
if (hreHasOwner) {
// Hardhat has the owner loaded into it, we can skip directly to transferOwnership.
const owner = await hre.ethers.getSigner(currentOwner) const owner = await hre.ethers.getSigner(currentOwner)
await Proxy__OVM_L1StandardBridge.connect(owner).setOwner( await Proxy__OVM_L1StandardBridge.connect(owner).setOwner(
ChugSplashDictator.address ChugSplashDictator.address
......
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