-
Notifications
You must be signed in to change notification settings - Fork 3
/
hardhat.config.ts
165 lines (148 loc) · 4.51 KB
/
hardhat.config.ts
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
import { HardhatRuntimeEnvironment } from 'hardhat/types'
import { HardhatUserConfig, task } from 'hardhat/config'
import 'hardhat-contract-sizer'
import 'hardhat-gas-reporter'
import '@typechain/hardhat'
import '@nomiclabs/hardhat-waffle'
import '@nomiclabs/hardhat-ethers'
import '@openzeppelin/hardhat-upgrades'
import '@nomiclabs/hardhat-etherscan'
import '@openzeppelin/hardhat-defender'
import { deployDirect, deployProxy, verify } from './scripts/tasks'
import {
DEPLOYER_PRIVATE_KEY,
ETHERSCAN_API_KEY,
ROOT_CHAIN_RPC,
ROOT_GAS_PRICE,
DEFENDER_TEAM_API_KEY,
DEFENDER_TEAM_API_SECRET_KEY,
CHILD_CHAIN_RPC,
CHILD_GAS_PRICE,
FX_ROOT,
FX_CHILD,
CHECKPOINT_MANAGER,
} from './environment'
task('verifyMaticX', 'MaticX contracts verification').setAction(
async (args, hre: HardhatRuntimeEnvironment) => {
await verify(hre)
},
)
task("deployFxStateChildTunnel", "Deploy FxStateChildTunnel")
.setAction(async (args, hre: HardhatRuntimeEnvironment) => {
if (!isChildNetwork(hre.network.name)) return
await deployDirect(hre, "FxStateChildTunnel", FX_CHILD)
}
);
task("deployFxStateRootTunnel", "Deploy FxStateRootTunnel")
.addPositionalParam("maticX")
.setAction(async ({maticX}, hre: HardhatRuntimeEnvironment) => {
if (!isRootNetwork(hre.network.name)) return
await deployDirect(hre, "FxStateRootTunnel", CHECKPOINT_MANAGER, FX_ROOT, maticX)
}
);
task("deployRateProvider", "Deploy RateProvider")
.addPositionalParam("fxStateChildTunnel")
.setAction(async ({fxStateChildTunnel}, hre: HardhatRuntimeEnvironment) => {
if (!isChildNetwork(hre.network.name)) return
await deployDirect(hre, "RateProvider", fxStateChildTunnel)
}
);
task("deployMaticXImpl", "Deploy MaticX Implementation only")
.setAction(async (args, hre: HardhatRuntimeEnvironment) => {
if (!isRootNetwork(hre.network.name)) return
await deployDirect(hre, "MaticX")
}
);
task("deployValidatorRegistryImpl", "Deploy ValidatorRegistry Implementation only")
.setAction(async (args, hre: HardhatRuntimeEnvironment) => {
if (!isRootNetwork(hre.network.name)) return
await deployDirect(hre, "ValidatorRegistry")
}
);
task("deployChildPoolProxy", "Deploy ChildPool Proxy only")
.addPositionalParam("fxStateChildTunnel")
.addPositionalParam("maticX")
.addPositionalParam("manager")
.addPositionalParam("instantPoolOwner")
.addPositionalParam("treasury")
.addPositionalParam("instantWithdrawalFeeBps")
.setAction(async ({fxStateChildTunnel, maticX, manager, instantPoolOwner, treasury, instantWithdrawalFeeBps}, hre: HardhatRuntimeEnvironment) => {
if (!isChildNetwork(hre.network.name)) return
await deployProxy(hre, "ChildPool", fxStateChildTunnel, maticX, manager, instantPoolOwner, treasury, instantWithdrawalFeeBps)
}
);
task("deployChildPoolImpl", "Deploy ChildPool Implementation only")
.setAction(async (args, hre: HardhatRuntimeEnvironment) => {
if (!isChildNetwork(hre.network.name)) return
await deployDirect(hre, "ChildPool")
}
);
function isChildNetwork(selected: string) {
const expected = 'matic';
return _isCorrectNetwork(expected, selected);
}
function isRootNetwork(selected: string) {
const expected = 'mainnet';
return _isCorrectNetwork(expected, selected);
}
function _isCorrectNetwork(expected: string, selected: string) {
if (selected === expected) return true;
console.log(`Wrong network configuration! Expected: ${expected} Selected: ${selected}`)
}
const config: HardhatUserConfig = {
defaultNetwork: 'hardhat',
solidity: {
version: '0.8.7',
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
networks: {
localhost: {
url: 'http://127.0.0.1:8545',
},
testnet: {
url: ROOT_CHAIN_RPC,
accounts: [DEPLOYER_PRIVATE_KEY],
gasPrice: Number(ROOT_GAS_PRICE),
},
mainnet: {
url: ROOT_CHAIN_RPC,
accounts: [DEPLOYER_PRIVATE_KEY],
gasPrice: Number(ROOT_GAS_PRICE),
},
matic: {
url: CHILD_CHAIN_RPC,
accounts: [DEPLOYER_PRIVATE_KEY],
gasPrice: Number(CHILD_GAS_PRICE),
},
},
typechain: {
outDir: 'typechain',
target: 'ethers-v5',
},
mocha: {
timeout: 99999999,
},
etherscan: {
apiKey: ETHERSCAN_API_KEY,
},
defender: {
apiKey: DEFENDER_TEAM_API_KEY,
apiSecret: DEFENDER_TEAM_API_SECRET_KEY,
},
contractSizer: {
alphaSort: true,
disambiguatePaths: false,
runOnCompile: true,
strict: true,
},
gasReporter: {
currency: 'USD',
gasPrice: 50,
},
}
export default config