• smartcontracts's avatar
    feat: introduce hardhat-deploy-config (#2755) · 27234f68
    smartcontracts authored
    * feat: introduce hardhat-deploy-config
    
    Creates a new package hardhat-deploy-config. We're using the same
    configuration system for all of our contracts package, so might as well
    turn it into a hardhat plugin to avoid duplicating code.
    
    * feat(ct): use hardhat-deploy-config
    
    * plugin: don't validate if spec not passed
    
    * contracts: update deps
    
    * contracts-bedrock: use deploy config plugin
    
    * contracts-bedrock: deploy instructions
    
    * contracts-bedrock: modularize deployment
    
    * contracts-bedrock: add deploy-config
    
    * contracts-bedrock: add in deploy config spec
    
    * lint: fix
    Co-authored-by: default avatarMark Tyneway <mark.tyneway@gmail.com>
    Co-authored-by: default avatarmergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
    27234f68
012-initialize-Proxy__L1CrossDomainMessenger.ts 1.97 KB
/* Imports: External */
import { DeployFunction } from 'hardhat-deploy/dist/types'
import { hexStringEquals, awaitCondition } from '@eth-optimism/core-utils'

/* Imports: Internal */
import { getContractFromArtifact } from '../src/deploy-utils'
import { names } from '../src/address-names'

const deployFn: DeployFunction = async (hre) => {
  const { deployer } = await hre.getNamedAccounts()

  // There's a risk that we could get front-run during a fresh deployment, which would brick this
  // contract and require that the proxy be re-deployed. We will not have this risk once we move
  // entirely to chugsplash-style deployments. It's unlikely to happen and relatively easy to
  // recover from so let's just ignore it for now.
  const Proxy__OVM_L1CrossDomainMessenger = await getContractFromArtifact(
    hre,
    names.managed.contracts.Proxy__OVM_L1CrossDomainMessenger,
    {
      iface: 'L1CrossDomainMessenger',
      signerOrProvider: deployer,
    }
  )

  const Lib_AddressManager = await getContractFromArtifact(
    hre,
    names.unmanaged.Lib_AddressManager
  )

  console.log(`Initializing Proxy__OVM_L1CrossDomainMessenger...`)
  await Proxy__OVM_L1CrossDomainMessenger.initialize(Lib_AddressManager.address)

  console.log(`Checking that contract was correctly initialized...`)
  await awaitCondition(
    async () => {
      return hexStringEquals(
        await Proxy__OVM_L1CrossDomainMessenger.libAddressManager(),
        Lib_AddressManager.address
      )
    },
    5000,
    100
  )

  console.log(`Setting Proxy__OVM_L1CrossDomainMessenger owner...`)
  const owner = hre.deployConfig.ovmAddressManagerOwner
  await Proxy__OVM_L1CrossDomainMessenger.transferOwnership(owner)

  console.log(`Checking that the contract owner was correctly set...`)
  await awaitCondition(
    async () => {
      return hexStringEquals(
        await Proxy__OVM_L1CrossDomainMessenger.owner(),
        owner
      )
    },
    5000,
    100
  )
}

deployFn.tags = ['finalize']

export default deployFn