Repository navigation
Expand file tree
/
Copy pathhardhat.config.ts
More file actions
142 lines (128 loc) · 3.43 KB
/
Copy pathhardhat.config.ts
File metadata and controls
142 lines (128 loc) · 3.43 KB
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
import path from "path";
import * as tdly from "@tenderly/hardhat-tenderly";
import * as dotenv from "dotenv";
import { TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS } from "hardhat/builtin-tasks/task-names";
import { subtask } from "hardhat/config";
import type { HardhatUserConfig } from "hardhat/config";
import "@nomiclabs/hardhat-truffle5";
import "@nomicfoundation/hardhat-toolbox";
import "hardhat-contract-sizer";
import "./scripts/index";
dotenv.config();
tdly.setup();
const UNUSED_CONTRACTS = [
"CollectionRouter2",
"CollectionRouterWithRoyalties",
].map((contractName: string) => {
return path.resolve(`./contracts/routers/${contractName}.sol`).toString();
});
const TESTING_DIRS = ["./contracts/test"].map((relPath: string) => {
return path.resolve(relPath).toString();
});
subtask(
TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS,
async (_, { config: _config }, runSuper) => {
const shouldCompileTestFiles =
process.env.TESTING?.toLowerCase() === "true";
const paths: any = await runSuper();
const excludedFiles = UNUSED_CONTRACTS;
const excludedDirs = shouldCompileTestFiles ? [] : TESTING_DIRS;
const filteredPaths = paths.filter((solidityFilePath: string) => {
// First check if it's in an excluded directory
for (const excludedDir of excludedDirs) {
if (solidityFilePath.startsWith(excludedDir)) {
return false;
}
}
// Then check if it's an excluded file
for (const excludedFile of excludedFiles) {
if (excludedFile === solidityFilePath) {
return false;
}
}
return true;
});
return filteredPaths;
}
);
const config: HardhatUserConfig = {
solidity: {
compilers: [
{
version: "0.8.17",
settings: {
optimizer: {
enabled: true,
runs: 150,
},
viaIR: true,
},
},
],
},
gasReporter: {
enabled: true,
coinmarketcap: process.env.COINMARKETCAP_API_KEY,
},
contractSizer: { runOnCompile: true },
networks: {
hardhat: {
allowUnlimitedContractSize: true,
},
...Object.fromEntries(
Object.entries({
mainnet: 1,
goerli: 5,
mumbai: 80001,
"base-goerli": 84531,
}).map(([networkName, chainId]) => {
return [
networkName,
{
chainId,
url:
process.env[
`${networkName.replace(/-/, "_").toUpperCase()}_URL`
] || "",
accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [],
},
];
})
),
},
etherscan: {
// hardhat verify --list-networks
apiKey: {
...Object.fromEntries(
["mainnet", "goerli", "base-goerli"].map((networkName) => [
networkName,
process.env.ETHERSCAN_API_KEY,
])
),
...Object.fromEntries(
["polygonMumbai"].map((networkName) => [
networkName,
process.env.POLYGONSCAN_API_KEY,
])
),
} as Record<string, string> | undefined,
customChains: [
{
network: "base-goerli",
chainId: 84531,
urls: {
apiURL: "https://api-goerli.basescan.org/api",
browserURL: "https://goerli.basescan.org",
},
},
],
},
paths: {
tests: "./test/hh",
},
mocha: {
grep: "Gas",
invert: process.env.RUN_GAS?.toLowerCase() !== "true",
},
};
export default config;