015-finalize.ts 1.21 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 8 9

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

11 12 13 14 15 16 17
  const Lib_AddressManager = await getContractFromArtifact(
    hre,
    'Lib_AddressManager',
    {
      signerOrProvider: deployer,
    }
  )
18

19
  const owner = hre.deployConfig.ovmAddressManagerOwner
20
  const remoteOwner = await Lib_AddressManager.owner()
21
  if (hexStringEquals(owner, remoteOwner)) {
22 23 24 25 26 27 28
    console.log(
      `✓ Not changing owner of Lib_AddressManager because it's already correctly set`
    )
    return
  }

  console.log(`Transferring ownership of Lib_AddressManager to ${owner}...`)
29 30 31
  await Lib_AddressManager.transferOwnership(owner)

  console.log(`Confirming transfer was successful...`)
32 33 34 35 36 37 38
  await awaitCondition(
    async () => {
      return hexStringEquals(await Lib_AddressManager.owner(), owner)
    },
    5000,
    100
  )
39 40 41 42

  console.log(`✓ Set owner of Lib_AddressManager to: ${owner}`)
}

43
deployFn.tags = ['upgrade', 'finalize']
44 45

export default deployFn