-
Notifications
You must be signed in to change notification settings - Fork 5
/
hardhat.config.ts
96 lines (89 loc) · 2.38 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
// Native dependencies
import fs from "fs";
// Import Hardhat extensions
import "@nomiclabs/hardhat-ethers";
import "@nomiclabs/hardhat-waffle";
import "@nomiclabs/hardhat-web3";
import "hardhat-gas-reporter";
import "solidity-coverage";
import "hardhat-preprocessor";
// Dependencies
import { subtask } from "hardhat/config";
import { TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS } from "hardhat/builtin-tasks/task-names";
import path from "path";
import dotenv from "dotenv";
dotenv.config({
path: path.resolve(process.cwd(), ".env"),
});
// Type compilation can be turned off. This is useful when compiling for
// coverage determination.
if (process.env.TYPE_COMPILATION !== "false") {
require("@typechain/hardhat");
}
// Ignore Forge test files during compilation; otherwise these will throw exceptions
// due to their using the alternative dependency system.
subtask(TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS).setAction(
async (_, __, runSuper) => {
const paths = await runSuper();
return paths.filter((p: string) => !p.endsWith(".t.sol"));
}
);
// Load Forge dependency mapping
const forgeRemapping = fs
.readFileSync("remappings.txt", "utf8")
.split("\n")
.filter(Boolean) // remove empty lines
.map((line) => line.trim().split("="));
/**
* @type import('hardhat/config').HardhatUserConfig
*/
export default {
// defaultNetwork: "",
// networks: {},
solidity: {
version: "0.8.12",
settings: {
optimizer: {
// Dev: Turn on for production compilations
enabled: false,
runs: 200,
},
},
},
preprocess: {
eachLine: () => ({
transform: (line: string) => {
if (line.match(/^\s*import /i)) {
for (const [from, to] of forgeRemapping) {
if (line.includes(from)) {
line = line.replace(from, to);
break;
}
}
}
return line;
},
}),
},
paths: {
sources: "./contracts",
tests: "./tests",
cache: "./cache-hh",
artifacts: "./artifacts",
},
mocha: {
timeout: 0,
// ! Will not do anything until Mocha upgraded to v8.
// parallel: true,
},
// Docs: https://github.com/cgewecke/hardhat-gas-reporter
gasReporter: {
enabled: process.env.REPORT_GAS === "true",
currency: "USD",
coinmarketcap: process.env.COINMARKETCAP_API_KEY,
},
typechain: {
outDir: "types",
target: "ethers-v5",
},
};