-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathhardhat.config.ts
79 lines (69 loc) · 2.34 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
import { HardhatUserConfig, HttpNetworkUserConfig } from "hardhat/types";
import fs from 'fs';
import path from 'path';
import "solidity-coverage"
import '@typechain/hardhat'
import "@nomiclabs/hardhat-ethers";
import "@nomiclabs/hardhat-waffle";
import "@nomiclabs/hardhat-etherscan";
import { NetworkName } from "./tasks/helpers/types";
require('dotenv').config()
const MNEMONIC = process.env.MNEMONIC || '';
const MNEMONIC_PATH = "m/44'/60'/0'/0";
// Should be set when running hardhat compile or hardhat typechain.
const SKIP_LOAD = process.env.SKIP_LOAD === 'true';
// 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/${process.env.ALCHEMY_KEY}`,
chainId: networkId,
accounts: {
mnemonic: MNEMONIC,
path: MNEMONIC_PATH,
initialIndex: 0,
count: 10,
},
};
}
const config: HardhatUserConfig = {
networks: {
hardhat: {
forking: {
url: `https://eth-mainnet.alchemyapi.io/v2/${process.env.ALCHEMY_KEY}`,
}
},
goerli: getRemoteNetworkConfig(NetworkName.goerli, 5),
ropsten: getRemoteNetworkConfig(NetworkName.ropsten, 3),
mainnet: getRemoteNetworkConfig(NetworkName.mainnet, 1),
},
solidity: {
compilers: [{ version: "0.8.0", settings: { optimizer: {enabled: true, runs: 200} } }],
},
typechain: {
outDir: 'src/types',
target: 'ethers-v5',
alwaysGenerateOverloads: false, // should overloads with full signatures like deposit(uint256) be generated always, even if there are no overloads?
externalArtifacts: ['externalArtifacts/*.json'], // optional array of glob patterns with external artifacts to process (for example external libs from node_modules)
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY,
}
};
export default config;