-
Notifications
You must be signed in to change notification settings - Fork 0
/
hardhat.config.ts
302 lines (278 loc) · 7.78 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
// require("@nomicfoundation/hardhat-chai-matchers");
import '@openzeppelin/hardhat-upgrades';
import "@nomicfoundation/hardhat-toolbox";
import "@nomicfoundation/hardhat-chai-matchers";
import path from 'path';
import fs from 'fs';
import { HardhatUserConfig } from 'hardhat/types/config';
import { TASK_COMPILE } from 'hardhat/builtin-tasks/task-names';
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { task } from 'hardhat/config';
import { pickBy } from 'lodash';
const dotenv = require('dotenv');
dotenv.config();
type MintersMap = Record<string, string[]>;
type AdminsMap = Record<string, string[]>;
type ProtocolAdminsMap = Record<string, string[]>;
type TokenManagersMap = Record<string, string[]>;
export type Treasury = { address: string; name: string; };
type Treasuries = Record<string, Treasury[]>;
type Pools = Record<string, string[]>;
// We need to extend HardhatUserConfig in order to support custom uns settings.
declare module 'hardhat/types/config' {
interface HardhatUserConfig {
accounts?: {
minters: MintersMap;
admins: AdminsMap;
};
}
interface HardhatConfig {
accounts: {
minters: MintersMap;
admins: AdminsMap;
};
}
interface ProjectPathsUserConfig {
flatArtifacts: string;
}
interface ProjectPathsConfig {
flatArtifacts: string;
}
}
import '@nomiclabs/hardhat-solhint';
// import '@typechain/hardhat';
// import '@nomiclabs/hardhat-ethers';
// import '@nomiclabs/hardhat-waffle';
// import "@nomicfoundation/hardhat-toolbox";
// import "@nomicfoundation/hardhat-verify"
// import '@nomiclabs/hardhat-etherscan';
// import '@openzeppelin/hardhat-upgrades';
// There are no type declarations for
// require('solidity-coverage');
// import 'hardhat-gas-reporter';
import 'hardhat-contract-sizer';
import yargs from 'yargs/yargs';
// import { Sandbox } from './sandbox';
/// ENVVAR
// - ENABLE_GAS_REPORT
// - ENABLE_CONTRACT_SIZER
// - CI
const argv = yargs().env('').boolean('enableGasReport').boolean('enableContractSizer').boolean('ci').parseSync();
task(
TASK_COMPILE,
'hook compile task to perform post-compile task',
async (_, hre: HardhatRuntimeEnvironment, runSuper) => {
const { root, flatArtifacts } = hre.config.paths;
const outputDir = path.resolve(root, flatArtifacts);
await runSuper();
if (fs.existsSync(outputDir)) {
fs.rmSync(outputDir, { recursive: true });
}
fs.mkdirSync(outputDir, { recursive: true });
for (const artifactPath of await hre.artifacts.getArtifactPaths()) {
const artifact = fs.readFileSync(artifactPath);
const { abi, contractName } = JSON.parse(artifact.toString());
if (!abi.length || contractName.includes('Mock')) continue;
const target = path.join(outputDir, `${contractName}.json`);
fs.copyFileSync(artifactPath, target);
}
},
);
// NOTE: Order matters
import "tsconfig-paths/register";
import 'hardhat-abi-exporter';
const settings = {
optimizer: {
enabled: true,
runs: 200,
},
};
const config: HardhatUserConfig = {
solidity: {
compilers: [
{
version: '0.5.12',
settings,
},
{
version: '0.6.6',
settings: {
...settings,
metadata: {
bytecodeHash: 'none',
},
},
},
{
version: '0.8.4',
settings: {
...settings,
metadata: {
bytecodeHash: 'none',
},
},
},
{
version: '0.8.9',
settings: {
...settings,
metadata: {
bytecodeHash: 'none',
},
},
},
{
version: '0.8.11',
settings: {
...settings,
metadata: {
bytecodeHash: 'none',
},
},
},
{
version: '0.8.13',
settings: {
...settings,
metadata: {
bytecodeHash: 'none',
},
},
},
{
version: '0.8.14',
settings: {
...settings,
metadata: {
bytecodeHash: 'none',
},
},
},
{
version: '0.8.19',
settings: {
...settings,
metadata: {
bytecodeHash: 'none',
},
},
},
{
version: '0.8.20',
settings: {
...settings,
metadata: {
bytecodeHash: 'none',
},
},
},
],
},
paths: {
artifacts: './.artifacts',
flatArtifacts: './artifacts',
},
networks: {
hardhat: {
allowUnlimitedContractSize: true,
blockGasLimit: 10000000,
initialBaseFeePerGas: 0,
hardfork: 'shanghai',
chainId: 1337,
},
localhost: {
allowUnlimitedContractSize: true,
url: 'http://127.0.0.1:8545',
chainId: 1337,
loggingEnabled: true,
},
// sandbox: Sandbox.defaultNetworkOptions(),
goerli: {
url: process.env.GOERLI_RPC_URL,
chainId: 5,
accounts: process.env.GOERLI_DEPLOYER_PRIVATE_KEY ? [process.env.GOERLI_DEPLOYER_PRIVATE_KEY as string] : undefined,
},
mainnet: {
url: process.env.MAINNET_RPC_URL,
chainId: 1,
accounts: process.env.MAINNET_DEPLOYER_PRIVATE_KEY ? [process.env.MAINNET_DEPLOYER_PRIVATE_KEY as string] : undefined,
loggingEnabled: true,
},
mumbai: {
url: process.env.MUMBAI_RPC_URL,
chainId: 80001,
accounts: [
process.env.MUMBAI_DEPLOYER_PRIVATE_KEY as string,
process.env.MUMBAI_PROTOCOL_ADMIN_PRIVATE_KEY as string
],
loggingEnabled: true,
blockGasLimit: 20000000,
},
polygon: {
url: process.env.POLYGON_RPC_URL,
chainId: 137,
accounts: process.env.POLYGON_DEPLOYER_PRIVATE_KEY ? [
process.env.POLYGON_DEPLOYER_PRIVATE_KEY as string,
process.env.POLYGON_PROTOCOL_ADMIN_PRIVATE_KEY as string
] : undefined,
loggingEnabled: true,
blockGasLimit: 44000000000
},
skaleCalypsoTestnet: {
url: process.env.SKALE_CALYPSO_RPC_URL,
chainId: 344106930,
accounts: process.env.SKALE_DEPLOYER_PRIVATE_KEY ? [process.env.SKALE_DEPLOYER_PRIVATE_KEY as string] : undefined,
loggingEnabled: true,
},
},
typechain: {
outDir: 'types',
target: 'ethers-v6',
},
gasReporter: {
enabled: argv.enableGasReport,
currency: 'USD',
outputFile: argv.ci ? 'gas-report.txt' : undefined,
excludeContracts: ['ERC721ReceiverMock', 'ERC2771RegistryContextMock', 'ERC20Upgradeable'],
},
contractSizer: {
alphaSort: true,
runOnCompile: argv.enableContractSizer,
disambiguatePaths: false,
only: ['DEPLOYERRegistry.sol', 'ProxyReader.sol', 'MintingManager.sol', 'MainController.sol', 'MainControllerBase.sol', 'PaymentSettings.sol'],
},
mocha: {
timeout: 100000,
require: ['./test/helpers/setup.ts'],
},
etherscan: {
apiKey: pickBy({
mainnet: process.env.ETHERSCAN_API_KEY,
goerli: process.env.ETHERSCAN_API_KEY,
polygon: process.env.POLYGONSCAN_API_KEY,
polygonMumbai: process.env.POLYGONSCAN_API_KEY,
}) as Record<string, string>,
},
abiExporter: {
path: './artifacts/abi',
clear: true,
flat: true,
except: ['Mock'],
spacing: 0,
},
accounts: {
minters: {
hardhat: ['0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'],
localhost: ['0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'],
polygon: [process.env.POLYGON_PROTOCOL_ADMIN_ADDRESS as string],
mumbai: [process.env.MUMBAI_PROTOCOL_ADMIN_ADDRESS as string],
},
admins: {
hardhat: ['0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'],
localhost: ['0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'],
polygon: [process.env.POLYGON_PROTOCOL_ADMIN_ADDRESS as string],
mumbai: [process.env.MUMBAI_PROTOCOL_ADMIN_ADDRESS as string],
},
},
};
export default config;