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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* 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