forked from yearn/tokenized-strategy-foundry-mix
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhardhat.config.ts
101 lines (89 loc) · 2.86 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
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-foundry";
import "@nomiclabs/hardhat-ethers";
import { task } from "hardhat/config";
import path from "path";
import glob from "glob";
import fs from "fs";
import "hardhat-abi-exporter";
import "@typechain/hardhat";
import "@nomicfoundation/hardhat-verify";
const remappings = fs
.readFileSync("remappings.txt", "utf-8")
.split("\n")
.filter((line) => line.trim() !== "") // Remove empty lines
.map((line) => line.trim().split("="));
const resolveImportPath = (importPath: string): string => {
for (const [prefix, target] of remappings) {
if (importPath.startsWith(prefix)) {
return path.join(target, importPath.slice(prefix.length));
}
}
return importPath;
};
task("compile", "Compiles the project, including libraries in the lib folder", async (_, { run }) => {
const excludedPaths = [
path.resolve(__dirname, "src/test/kontrol/*.sol"),
];
// Locate all source files in the src folder
const sourceFiles = glob.sync(path.resolve(__dirname, "src/**/*.sol"));
// Locate all library files in the lib folder
const libraryFiles = glob.sync(path.resolve(__dirname, "lib/**/*.sol"));
// Combine source files and library files, excluding specific paths
const allFiles = [...sourceFiles, ...libraryFiles];
const filesToCompile = allFiles.filter(
(file) => !excludedPaths.some((excluded) => file.startsWith(excluded))
);
console.log("Files to compile:", filesToCompile);
// Run the Solidity compile task with the filtered list of files
await run("compile:solidity", { sources: filesToCompile, force: false, quiet: false });
});
const config: HardhatUserConfig = {
solidity: {
version: "0.8.23",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
abiExporter: {
runOnCompile: true,
clear: true,
flat: false,
format: "json",
},
etherscan: {
// Your API key for Etherscan
// Obtain one at https://etherscan.io/
apiKey: process.env.ETHERSCAN_API_KEY
},
typechain: {
outDir: "typechain-types",
target: "ethers-v5",
},
paths: {
sources: "./src", // Where your contracts are
artifacts: "./artifacts", // Where compiled artifacts go
cache: "./cache" // Cache directory
},
networks: {
sepolia: {
url: process.env.SEPOLIA_RPC_URL || "",
accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [],
chainId: 11155111
},
avalanche: {
url: process.env.AVALANCHE_RPC_URL || "https://api.avax.network/ext/bc/C/rpc",
accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [],
chainId: 43114
},
mainnet: {
url: process.env.MAINNET_RPC_URL || "",
accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [],
chainId: 1
}
}
};
export default config;