012-initialize-Proxy__L1CrossDomainMessenger.ts 1.97 KB
Newer Older
1 2
/* Imports: External */
import { DeployFunction } from 'hardhat-deploy/dist/types'
3
import { hexStringEquals, awaitCondition } from '@eth-optimism/core-utils'
4 5

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

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

12 13 14 15 16
  // 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(
17
    hre,
18
    names.managed.contracts.Proxy__OVM_L1CrossDomainMessenger,
19 20 21 22 23
    {
      iface: 'L1CrossDomainMessenger',
      signerOrProvider: deployer,
    }
  )
24 25

  const Lib_AddressManager = await getContractFromArtifact(
26
    hre,
27
    names.unmanaged.Lib_AddressManager
28
  )
29

30
  console.log(`Initializing Proxy__OVM_L1CrossDomainMessenger...`)
31
  await Proxy__OVM_L1CrossDomainMessenger.initialize(Lib_AddressManager.address)
32 33

  console.log(`Checking that contract was correctly initialized...`)
34 35 36 37 38 39 40 41 42 43
  await awaitCondition(
    async () => {
      return hexStringEquals(
        await Proxy__OVM_L1CrossDomainMessenger.libAddressManager(),
        Lib_AddressManager.address
      )
    },
    5000,
    100
  )
44 45

  console.log(`Setting Proxy__OVM_L1CrossDomainMessenger owner...`)
46
  const owner = hre.deployConfig.ovmAddressManagerOwner
47 48 49 50 51 52 53 54 55 56 57 58 59
  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
  )
60 61
}

62
deployFn.tags = ['finalize']
63 64

export default deployFn