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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* eslint @typescript-eslint/no-var-requires: "off" */
import { ethers } from 'ethers'
import { DeployFunction } from 'hardhat-deploy/dist/types'
import { awaitCondition } from '@eth-optimism/core-utils'
import {
getContractFromArtifact,
fundAccount,
sendImpersonatedTx,
BIG_BALANCE,
} from '../src/deploy-utils'
import { names } from '../src/address-names'
const deployFn: DeployFunction = async (hre) => {
if (!hre.deployConfig.isForkedNetwork) {
return
}
console.log(`Running custom setup for forked experimental networks`)
const { deployer } = await hre.getNamedAccounts()
// Fund the deployer account so it can be used for the rest of this deployment.
console.log(`Funding deployer account...`)
await fundAccount(hre, deployer, BIG_BALANCE)
// Get a reference to the AddressManager contract.
const Lib_AddressManager = await getContractFromArtifact(
hre,
names.unmanaged.Lib_AddressManager
)
// Transfer ownership of the AddressManager to the deployer.
console.log(`Setting AddressManager owner to ${deployer}`)
await sendImpersonatedTx({
hre,
contract: Lib_AddressManager,
fn: 'transferOwnership',
from: await Lib_AddressManager.owner(),
gas: ethers.BigNumber.from(2_000_000).toHexString(),
args: [deployer],
})
console.log(`Waiting for owner to be correctly set...`)
await awaitCondition(
async () => {
return (await Lib_AddressManager.owner()) === deployer
},
5000,
100
)
// Get a reference to the L1StandardBridge contract.
const Proxy__OVM_L1StandardBridge = await getContractFromArtifact(
hre,
'Proxy__OVM_L1StandardBridge'
)
// Transfer ownership of the L1StandardBridge to the deployer.
console.log(`Setting L1StandardBridge owner to ${deployer}`)
await sendImpersonatedTx({
hre,
contract: Proxy__OVM_L1StandardBridge,
fn: 'setOwner',
from: await Proxy__OVM_L1StandardBridge.callStatic.getOwner({
from: hre.ethers.constants.AddressZero,
}),
gas: ethers.BigNumber.from(2_000_000).toHexString(),
args: [deployer],
})
console.log(`Waiting for owner to be correctly set...`)
await awaitCondition(
async () => {
return (
(await Proxy__OVM_L1StandardBridge.callStatic.getOwner({
from: hre.ethers.constants.AddressZero,
})) === deployer
)
},
5000,
100
)
}
deployFn.tags = ['hardhat', 'upgrade']
export default deployFn