Skip to content

Commit cf301ad

Browse files
authored
feat: add support for hardhat project (#214)
<!-- Please read and fill out this form before submitting your PR. Please make sure you have reviewed our contributors guide before submitting your first PR. --> ## Overview This will lay foundations for using deployment and upgrades via the uups plugin, run static code analyzers, etc. Let me know what you think of having 3 projects in the same repo: - go project - foundry project - hardhat project ## Checklist <!-- Please complete the checklist to ensure that the PR is ready to be reviewed. IMPORTANT: PRs should be left in Draft until the below checklist is completed. --> - [ ] New and updated code has appropriate documentation - [ ] New and updated code has new and/or updated testing - [ ] Required CI checks are passing - [ ] Visual proof for any user facing features like CLI or documentation updates - [ ] Linked issues closed with keywords
1 parent 69d0fbc commit cf301ad

File tree

7 files changed

+9391
-0
lines changed

7 files changed

+9391
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,8 @@ coverage
5656
**/typechain/**/*
5757
node_modules
5858
out/
59+
60+
# hardhat
61+
62+
typechain-types/
63+
cache_hardhat/

hardhat.config.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { HardhatUserConfig } from "hardhat/config";
2+
import "@nomicfoundation/hardhat-toolbox";
3+
import "hardhat-preprocessor";
4+
import fs from "fs";
5+
6+
const config: HardhatUserConfig = {
7+
solidity: {
8+
version: "0.8.20",
9+
settings: {
10+
optimizer: {
11+
enabled: true,
12+
runs: 200,
13+
},
14+
viaIR: true
15+
},
16+
},
17+
preprocess: {
18+
eachLine: (hre) => ({
19+
transform: (line: string) => {
20+
if (line.match(/^\s*import /i)) {
21+
for (const [from, to] of getRemappings()) {
22+
if (line.includes(from)) {
23+
line = line.replace(from, to);
24+
break;
25+
}
26+
}
27+
}
28+
return line;
29+
},
30+
}),
31+
},
32+
paths: {
33+
sources: "./src",
34+
cache: "./cache_hardhat",
35+
},
36+
};
37+
38+
export default config;
39+
40+
function getRemappings() {
41+
return fs
42+
.readFileSync("remappings.txt", "utf8")
43+
.split("\n")
44+
.filter(Boolean) // remove empty lines
45+
.map((line) => line.trim().split("="));
46+
}

0 commit comments

Comments
 (0)