-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathhardhat.config.js
More file actions
124 lines (110 loc) · 3.23 KB
/
Copy pathhardhat.config.js
File metadata and controls
124 lines (110 loc) · 3.23 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
/** @type import('hardhat/config').HardhatUserConfig */
require("dotenv").config();
require("ts-node").register({
transpileOnly: true,
// Use inline compilerOptions instead of tsconfig.json to avoid
// interfering with ESM-only packages.
skipProject: true,
compilerOptions: {
module: "CommonJS",
target: "ES2020",
esModuleInterop: true,
allowSyntheticDefaultImports: true,
resolveJsonModule: true,
strict: false,
},
});
require("@nomicfoundation/hardhat-ethers");
require("@nomicfoundation/hardhat-foundry");
const { internalTask } = require("hardhat/config");
const {
TASK_COMPILE_GET_REMAPPINGS,
TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS,
} = require("hardhat/builtin-tasks/task-names");
const path = require("path");
// Override the remappings task to filter out context remappings (lines with ":"
// before "="). This is needed because Soldeer generates context remappings for
// dependencies that use different versions of the same library (e.g. Pendle SY)
// and hardhat-foundry doesn't support them.
internalTask(TASK_COMPILE_GET_REMAPPINGS).setAction(async (_, __, runSuper) => {
const { exec } = require("child_process");
const { promisify } = require("util");
const execAsync = promisify(exec);
const { stdout } = await execAsync("forge remappings");
const remappings = {};
for (const line of stdout.split(/\r\n|\r|\n/)) {
if (line.trim() === "") continue;
// Skip context remappings (contain ":" before "=")
const eqIdx = line.indexOf("=");
const colonIdx = line.indexOf(":");
if (colonIdx !== -1 && (eqIdx === -1 || colonIdx < eqIdx)) continue;
const [from, ...rest] = line.split("=");
if (remappings[from] === undefined) {
remappings[from] = rest.join("=");
}
}
return remappings;
});
// Exclude Pendle SY contracts from Hardhat compilation since they require
// OZ 4.9.3 context remappings that Hardhat doesn't support.
internalTask(TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS).setAction(
async (_, __, runSuper) => {
const paths = await runSuper();
return paths.filter(
(p) => !p.includes(path.join("contracts", "pendle") + path.sep),
);
},
);
require("./src/js/tasks/tasks");
// Auto-load TypeScript action files
const fs = require("fs");
const actionsDir = path.join(__dirname, "src/js/tasks/actions");
if (fs.existsSync(actionsDir)) {
for (const file of fs.readdirSync(actionsDir)) {
if (file.endsWith(".ts")) {
require(path.join(actionsDir, file));
}
}
}
module.exports = {
networks: {
mainnet: {
url: `${process.env.MAINNET_URL}`,
},
hardhat: {
forking: {
url: `${process.env.MAINNET_URL}`,
...(process.env.BLOCK_NUMBER
? { blockNumber: process.env.BLOCK_NUMBER }
: {}),
},
},
local: {
url: "http://localhost:8545",
},
holesky: {
url: `${process.env.HOLESKY_URL}`,
chainId: 17000,
},
sonic: {
url: `${process.env.SONIC_URL}`,
chainId: 146,
},
testnet: {
url: `${process.env.TESTNET_URL}`,
chainId: 1,
},
},
solidity: {
version: "0.8.36",
settings: {
evmVersion: "cancun",
optimizer: {
enabled: true,
},
},
},
tracer: {
tasks: ["snap", "swap"],
},
};