forked from dydxfoundation/governance-contracts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
hardhat.config.ts
115 lines (102 loc) · 2.75 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
import fs from 'fs';
import path from 'path';
import * as dotenv from 'dotenv';
import { HardhatUserConfig } from 'hardhat/config';
import {
HardhatNetworkUserConfig,
HttpNetworkUserConfig,
} from 'hardhat/types';
import config from './src/config';
import { NetworkName } from './src/types';
import '@typechain/hardhat';
import '@nomiclabs/hardhat-ethers';
import '@nomiclabs/hardhat-waffle';
import 'solidity-coverage';
import 'hardhat-abi-exporter';
dotenv.config();
// Should be set when running hardhat compile or hardhat typechain.
const SKIP_LOAD = process.env.SKIP_LOAD === 'true';
// Testnet and mainnet configuration.
const ALCHEMY_KEY = process.env.ALCHEMY_KEY || '';
const MNEMONIC = process.env.MNEMONIC || '';
const MNEMONIC_PATH = "m/44'/60'/0'/0";
// Load hardhat tasks.
if (!SKIP_LOAD) {
console.log('Loading scripts...');
const tasksDir = path.join(__dirname, 'tasks');
const tasksDirs = fs.readdirSync(tasksDir);
tasksDirs.forEach((dirName) => {
const tasksDirPath = path.join(tasksDir, dirName);
const tasksFiles = fs.readdirSync(tasksDirPath);
tasksFiles.forEach((fileName) => {
const tasksFilePath = path.join(tasksDirPath, fileName);
/* eslint-disable-next-line global-require */
require(tasksFilePath);
});
});
}
function getRemoteNetworkConfig(
networkName: NetworkName,
networkId: number,
): HttpNetworkUserConfig {
return {
url: `https://eth-${networkName}.alchemyapi.io/v2/${ALCHEMY_KEY}`,
chainId: networkId,
accounts: {
mnemonic: MNEMONIC,
path: MNEMONIC_PATH,
initialIndex: 0,
count: 10,
},
};
}
function getHardhatConfig(): HardhatNetworkUserConfig {
const networkConfig: HardhatNetworkUserConfig = {
hardfork: 'berlin',
blockGasLimit: 15000000,
chainId: 31337,
throwOnTransactionFailures: true,
throwOnCallFailures: true,
};
if (config.FORK_MAINNET) {
networkConfig.forking = {
url: `https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_KEY}`,
blockNumber: config.FORK_BLOCK_NUMBER,
};
}
return networkConfig;
}
const hardhatConfig: HardhatUserConfig = {
solidity: {
compilers: [
{
version: '0.7.5',
settings: {
optimizer: {
enabled: true,
runs: 200,
},
evmVersion: 'berlin',
},
},
],
},
typechain: {
outDir: 'types',
target: 'ethers-v5',
alwaysGenerateOverloads: false,
},
mocha: {
timeout: 0,
},
networks: {
kovan: getRemoteNetworkConfig(NetworkName.kovan, 42),
ropsten: getRemoteNetworkConfig(NetworkName.ropsten, 3),
mainnet: getRemoteNetworkConfig(NetworkName.mainnet, 1),
hardhat: getHardhatConfig(),
},
abiExporter: {
clear: true,
},
};
export default hardhatConfig;