-
Notifications
You must be signed in to change notification settings - Fork 1
/
hardhat.config.ts
74 lines (66 loc) · 1.6 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
import * as fs from 'fs';
import glob from 'glob';
import { HardhatUserConfig, subtask } from 'hardhat/config';
import { TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS } from 'hardhat/builtin-tasks/task-names';
import '@nomicfoundation/hardhat-toolbox';
import '@nomiclabs/hardhat-ethers';
import '@typechain/hardhat';
import 'hardhat-deploy';
import 'hardhat-preprocessor';
import * as forkTasks from './script/fork';
import networks from './hardhat.network';
function getRemappings() {
return fs
.readFileSync('remappings.txt', 'utf8')
.split('\n')
.filter(Boolean) // remove empty lines
.map((line: string) => line.trim().split('='));
}
const config: HardhatUserConfig = {
namedAccounts: {
deployer: {
default: 0,
},
},
networks,
paths: {
artifacts: './out',
sources: './src',
cache: './cache_hardhat',
tests: './test',
},
preprocess: {
eachLine: () => ({
transform: (line: string) => {
if (line.match(/^\s*import /i)) {
for (const [from, to] of getRemappings()) {
if (line.includes(from)) {
line = line.replace(from, to);
break;
}
}
}
return line;
},
}),
},
solidity: {
version: '0.8.16',
settings: {
optimizer: {
enabled: true,
runs: 2000,
},
viaIR: true,
},
},
typechain: {
outDir: './types',
target: 'ethers-v5',
},
};
subtask(TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS, async () => {
return [...glob.sync('./src/**/*.sol'), ...glob.sync('./test/**/*.sol')];
});
forkTasks;
export default config;