002-ConfigureProxyAdmin.ts 1.38 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
import { DeployFunction } from 'hardhat-deploy/dist/types'
import 'hardhat-deploy'
import '@nomiclabs/hardhat-ethers'
import '@eth-optimism/hardhat-deploy-config'

const deployFn: DeployFunction = async (hre) => {
  const admin = await hre.deployments.get('ProxyAdmin')
  const ProxyAdmin = await hre.ethers.getContractAt('ProxyAdmin', admin.address)

  // This is set up for fresh networks only
  const proxies = [
    'L2OutputOracleProxy',
    'L1CrossDomainMessengerProxy',
    'L1StandardBridgeProxy',
    'OptimismPortalProxy',
    'OptimismMintableERC20FactoryProxy',
  ]

  // Wait on all the txs in parallel so that the deployment goes faster
  const txs = []
  for (const proxy of proxies) {
    const deployment = await hre.deployments.get(proxy)
    const Proxy = await hre.ethers.getContractAt('Proxy', deployment.address)
    const tx = await Proxy.changeAdmin(admin.address)
    txs.push(tx)
  }
  await Promise.all(txs.map((tx) => tx.wait()))

  const addressManager = await hre.deployments.get('AddressManager')
  const AddressManager = await hre.ethers.getContractAt(
    'AddressManager',
    addressManager.address
  )

  const postConfig = [
    await AddressManager.transferOwnership(admin.address),
    await ProxyAdmin.setAddressManager(addressManager.address),
  ]
  await Promise.all(postConfig.map((tx) => tx.wait()))
}

42
deployFn.tags = ['ConfigureProxyAdmin']
43 44

export default deployFn