-
Notifications
You must be signed in to change notification settings - Fork 194
/
hardhat.config.ts
196 lines (182 loc) · 5.07 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
import { existsSync, readFileSync } from "node:fs";
import path from "node:path";
import "@nomicfoundation/hardhat-chai-matchers";
import "@nomicfoundation/hardhat-toolbox";
import "@typechain/hardhat";
import "dotenv/config";
import "solidity-coverage";
import "tsconfig-paths/register";
import "hardhat-tracer";
import "hardhat-watcher";
import "hardhat-ignore-warnings";
import "hardhat-contract-sizer";
import { globSync } from "glob";
import { TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS } from "hardhat/builtin-tasks/task-names";
import { HardhatUserConfig, subtask } from "hardhat/config";
import { mochaRootHooks } from "test/hooks";
import "./tasks";
const RPC_URL: string = process.env.RPC_URL || "";
const ACCOUNTS_PATH = "./accounts.json";
const HARDHAT_FORKING_URL = process.env.HARDHAT_FORKING_URL || "";
const INTEGRATION_WITH_SCRATCH_DEPLOY = process.env.INTEGRATION_WITH_SCRATCH_DEPLOY || "off";
/* Determines the forking configuration for Hardhat */
function getHardhatForkingConfig() {
if (INTEGRATION_WITH_SCRATCH_DEPLOY === "on" || !HARDHAT_FORKING_URL) {
return undefined;
}
return { url: HARDHAT_FORKING_URL };
}
function loadAccounts(networkName: string) {
// TODO: this plaintext accounts.json private keys management is a subject
// of rework to a solution with the keys stored encrypted
if (!existsSync(ACCOUNTS_PATH)) {
return [];
}
const content = JSON.parse(readFileSync(ACCOUNTS_PATH, "utf-8"));
if (!content.eth) {
return [];
}
return content.eth[networkName] || [];
}
const config: HardhatUserConfig = {
defaultNetwork: "hardhat",
networks: {
"local": {
url: process.env.LOCAL_RPC_URL || RPC_URL,
},
"mainnet-fork": {
url: process.env.MAINNET_RPC_URL || RPC_URL,
timeout: 20 * 60 * 1000, // 20 minutes
},
"hardhat": {
// setting base fee to 0 to avoid extra calculations doesn't work :(
// minimal base fee is 1 for EIP-1559
// gasPrice: 0,
// initialBaseFeePerGas: 0,
blockGasLimit: 30000000,
allowUnlimitedContractSize: true,
accounts: {
// default hardhat's node mnemonic
mnemonic: "test test test test test test test test test test test junk",
count: 30,
accountsBalance: "100000000000000000000000",
},
forking: getHardhatForkingConfig(),
},
"sepolia": {
url: RPC_URL,
chainId: 11155111,
accounts: loadAccounts("sepolia"),
},
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY || "",
},
solidity: {
compilers: [
{
version: "0.4.24",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
evmVersion: "constantinople",
},
},
{
version: "0.6.11",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
evmVersion: "istanbul",
},
},
{
version: "0.6.12",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
evmVersion: "istanbul",
},
},
{
version: "0.8.4",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
evmVersion: "istanbul",
},
},
{
version: "0.8.9",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
evmVersion: "istanbul",
},
},
],
},
tracer: {
tasks: ["watch"],
},
typechain: {
outDir: "typechain-types",
target: "ethers-v6",
alwaysGenerateOverloads: false,
externalArtifacts: ["externalArtifacts/*.json"],
dontOverrideCompile: false,
},
watcher: {
test: {
tasks: [{ command: "test", params: { testFiles: ["{path}"] } }],
files: ["./test/**/*"],
clearOnStart: true,
start: "echo Running tests...",
},
},
mocha: {
rootHooks: mochaRootHooks,
timeout: 20 * 60 * 1000, // 20 minutes
},
warnings: {
"@aragon/**/*": {
default: "off",
},
"contracts/*/mocks/**/*": {
default: "off",
},
"test/*/contracts/**/*": {
default: "off",
},
"contracts/common/interfaces/ILidoLocator.sol": {
default: "off",
},
},
contractSizer: {
alphaSort: false,
disambiguatePaths: false,
runOnCompile: true,
strict: true,
except: ["template", "mocks", "@aragon", "openzeppelin", "test"],
},
};
// a workaround for having an additional source directory for compilation
// see, https://github.com/NomicFoundation/hardhat/issues/776#issuecomment-1713584386
subtask(TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS).setAction(async (_, hre, runSuper) => {
const paths = await runSuper();
const otherDirectoryGlob = path.join(hre.config.paths.root, "test", "**", "*.sol");
// Don't need to compile test, helper and script files that are not part of the contracts for Hardhat.
const otherPaths = globSync(otherDirectoryGlob).filter((x) => !/\.([ths]\.sol)$/.test(x));
return [...paths, ...otherPaths];
});
export default config;