@diamondslab/diamonds-hardhat-foundry 2.2.3 โ†’ 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -14,7 +14,8 @@ Hardhat plugin that seamlessly integrates Foundry testing with [ERC-2535 Diamond
14
14
  - ๐Ÿš€ **Automated Diamond Deployment** - Deploy Diamond contracts with a single command
15
15
  - ๐Ÿ“ **Helper Generation** - Automatically generate Solidity helpers with deployment data
16
16
  - ๐Ÿงช **Test Scaffolding** - Create unit, integration, and fuzz test templates
17
- - ๐Ÿ”ง **Hardhat Tasks** - CLI tasks for init, deploy, generate, and test workflows
17
+ - ๏ฟฝ **Coverage Testing** - Run forge coverage with full Diamond integration and multiple report formats
18
+ - ๐Ÿ”ง **Hardhat Tasks** - CLI tasks for init, deploy, generate, test, and coverage workflows
18
19
  - ๐ŸŽฏ **Programmatic API** - Use framework classes directly in scripts
19
20
  - ๐Ÿ“š **Base Contracts** - Reusable Solidity utilities and test base classes
20
21
  - โšก **Foundry Integration** - Leverage Forge's speed and fuzzing capabilities
@@ -342,6 +343,80 @@ npx hardhat diamonds-forge:test --match-test "testOwnership" --verbosity 4
342
343
  npx hardhat diamonds-forge:test --skip-deployment --match-contract "MyTest"
343
344
  ```
344
345
 
346
+ ### `diamonds-forge:coverage`
347
+
348
+ Run forge coverage for your Diamond contracts with full integration support.
349
+
350
+ **Important:** Coverage requires a deployed Diamond on a persistent network (like localhost). See workflow below.
351
+
352
+ **Options:**
353
+
354
+ - `--diamond-name <name>` - Diamond to analyze (default: from config)
355
+ - `--network <name>` - Network for deployment (default: from config)
356
+ - `--report <format>` - Report format: summary, lcov, debug, bytecode (default: summary)
357
+ - `--report-file <path>` - Output file for coverage report
358
+ - `--lcov-version <version>` - LCOV version for LCOV reports (default: v1)
359
+ - `--match-test <pattern>` - Run tests matching pattern
360
+ - `--match-contract <pattern>` - Run tests in matching contracts
361
+ - `--match-path <glob>` - Run tests in files matching glob
362
+ - `--no-match-test <pattern>` - Skip tests matching pattern
363
+ - `--no-match-contract <pattern>` - Skip tests in matching contracts
364
+ - `--no-match-path <glob>` - Skip tests in files matching glob
365
+ - `--no-match-coverage <pattern>` - Exclude contracts from coverage
366
+ - `--verbosity <level>` - Verbosity level: 0-5 (default: 0)
367
+ - `--color <mode>` - Color output: auto, always, never (default: auto)
368
+ - And many more options for filtering, optimization, and EVM configuration
369
+
370
+ **Workflow (Required):**
371
+
372
+ ```bash
373
+ # Step 1: Start Hardhat node (persistent network)
374
+ npx hardhat node
375
+
376
+ # Step 2: Deploy Diamond to localhost network (in another terminal)
377
+ npx hardhat diamonds-forge:deploy --diamond-name MyDiamond --network localhost
378
+
379
+ # Step 3: Run coverage against deployed Diamond
380
+ npx hardhat diamonds-forge:coverage --diamond-name MyDiamond --network localhost
381
+ ```
382
+
383
+ **Examples:**
384
+
385
+ ```bash
386
+ # Basic coverage with default summary
387
+ npx hardhat diamonds-forge:coverage --diamond-name MyDiamond --network localhost
388
+
389
+ # Generate LCOV report for CI/CD
390
+ npx hardhat diamonds-forge:coverage \
391
+ --diamond-name MyDiamond \
392
+ --network localhost \
393
+ --report lcov \
394
+ --report-file coverage/lcov.info
395
+
396
+ # Coverage for specific test patterns
397
+ npx hardhat diamonds-forge:coverage \
398
+ --diamond-name MyDiamond \
399
+ --network localhost \
400
+ --match-contract "Unit" \
401
+ --verbosity 2
402
+
403
+ # Multiple report formats
404
+ npx hardhat diamonds-forge:coverage \
405
+ --diamond-name MyDiamond \
406
+ --network localhost \
407
+ --report summary \
408
+ --report lcov \
409
+ --report debug
410
+ ```
411
+
412
+ **Important Notes:**
413
+ - Always specify `--network localhost` (coverage needs deployed contracts)
414
+ - Cannot use `--network hardhat` (ephemeral in-memory network)
415
+ - Diamond must be deployed before running coverage
416
+ - Same workflow as `diamonds-forge:test` - both require persistent network
417
+
418
+ **See the [Coverage Guide](../../docs/FOUNDRY_FORGE_DIAMONDS_COVERAGE.md) for complete documentation, CI/CD integration examples, and best practices.**
419
+
345
420
  ## Dynamic Helper Generation
346
421
 
347
422
  Version 2.0.0+ introduces **dynamic helper generation** that creates deployment-specific Solidity helpers without hardcoded addresses.
@@ -0,0 +1,61 @@
1
+ import { HardhatRuntimeEnvironment } from "hardhat/types";
2
+ import { CoverageOptions } from "../types/config";
3
+ /**
4
+ * ForgeCoverageFramework - Orchestrates forge coverage execution for Diamond contracts
5
+ *
6
+ * Responsibilities:
7
+ * 1. Build forge coverage command with all options
8
+ * 2. Execute forge coverage with proper fork URL
9
+ * 3. Stream output to terminal
10
+ * 4. Handle errors appropriately
11
+ */
12
+ export declare class ForgeCoverageFramework {
13
+ private hre;
14
+ constructor(hre: HardhatRuntimeEnvironment);
15
+ /**
16
+ * Run forge coverage with provided options
17
+ *
18
+ * @param options - Coverage execution options
19
+ * @returns Promise<boolean> - true if coverage succeeds, false otherwise
20
+ */
21
+ runCoverage(options?: CoverageOptions): Promise<boolean>;
22
+ /**
23
+ * Build complete forge coverage command arguments
24
+ *
25
+ * @param options - Coverage options
26
+ * @returns Array of command arguments
27
+ */
28
+ private buildCoverageCommand;
29
+ /**
30
+ * Build report-related options
31
+ */
32
+ private buildReportOptions;
33
+ /**
34
+ * Build test filtering options
35
+ */
36
+ private buildFilterOptions;
37
+ /**
38
+ * Build display options
39
+ */
40
+ private buildDisplayOptions;
41
+ /**
42
+ * Build test execution options
43
+ */
44
+ private buildTestOptions;
45
+ /**
46
+ * Build EVM options
47
+ */
48
+ private buildEvmOptions;
49
+ /**
50
+ * Build build options
51
+ */
52
+ private buildBuildOptions;
53
+ /**
54
+ * Execute forge coverage command and stream output
55
+ *
56
+ * @param args - Command arguments
57
+ * @returns Promise<boolean> - true if command succeeds
58
+ */
59
+ private executeForge;
60
+ }
61
+ //# sourceMappingURL=ForgeCoverageFramework.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ForgeCoverageFramework.d.ts","sourceRoot":"","sources":["../../src/framework/ForgeCoverageFramework.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGlD;;;;;;;;GAQG;AACH,qBAAa,sBAAsB;IACrB,OAAO,CAAC,GAAG;gBAAH,GAAG,EAAE,yBAAyB;IAElD;;;;;OAKG;IACG,WAAW,CAAC,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,OAAO,CAAC;IA0BlE;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IAmB5B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAiC1B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAkC1B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IA2B3B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IA0BxB;;OAEG;IACH,OAAO,CAAC,eAAe;IAsBvB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IA0BzB;;;;;OAKG;IACH,OAAO,CAAC,YAAY;CAoBrB"}
@@ -0,0 +1,238 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ForgeCoverageFramework = void 0;
4
+ const child_process_1 = require("child_process");
5
+ const logger_1 = require("../utils/logger");
6
+ /**
7
+ * ForgeCoverageFramework - Orchestrates forge coverage execution for Diamond contracts
8
+ *
9
+ * Responsibilities:
10
+ * 1. Build forge coverage command with all options
11
+ * 2. Execute forge coverage with proper fork URL
12
+ * 3. Stream output to terminal
13
+ * 4. Handle errors appropriately
14
+ */
15
+ class ForgeCoverageFramework {
16
+ hre;
17
+ constructor(hre) {
18
+ this.hre = hre;
19
+ }
20
+ /**
21
+ * Run forge coverage with provided options
22
+ *
23
+ * @param options - Coverage execution options
24
+ * @returns Promise<boolean> - true if coverage succeeds, false otherwise
25
+ */
26
+ async runCoverage(options = {}) {
27
+ logger_1.Logger.section("Forge Coverage - Execution");
28
+ try {
29
+ // Build command arguments
30
+ const args = this.buildCoverageCommand(options);
31
+ logger_1.Logger.info(`Executing: forge coverage ${args.join(" ")}`);
32
+ logger_1.Logger.info("โณ Running coverage analysis (this may take a while)...\n");
33
+ // Execute forge coverage
34
+ const success = await this.executeForge(args);
35
+ if (success) {
36
+ logger_1.Logger.success("โœ… Coverage analysis completed successfully");
37
+ }
38
+ else {
39
+ logger_1.Logger.error("โŒ Coverage analysis failed");
40
+ }
41
+ return success;
42
+ }
43
+ catch (error) {
44
+ logger_1.Logger.error(`Coverage execution error: ${error.message}`);
45
+ return false;
46
+ }
47
+ }
48
+ /**
49
+ * Build complete forge coverage command arguments
50
+ *
51
+ * @param options - Coverage options
52
+ * @returns Array of command arguments
53
+ */
54
+ buildCoverageCommand(options) {
55
+ const args = [];
56
+ // Add fork URL if provided
57
+ if (options.forkUrl) {
58
+ args.push("--fork-url", options.forkUrl);
59
+ }
60
+ // Add all option groups
61
+ args.push(...this.buildReportOptions(options));
62
+ args.push(...this.buildFilterOptions(options));
63
+ args.push(...this.buildDisplayOptions(options));
64
+ args.push(...this.buildTestOptions(options));
65
+ args.push(...this.buildEvmOptions(options));
66
+ args.push(...this.buildBuildOptions(options));
67
+ return args.filter((arg) => arg !== "");
68
+ }
69
+ /**
70
+ * Build report-related options
71
+ */
72
+ buildReportOptions(options) {
73
+ const args = [];
74
+ // Multiple --report flags
75
+ if (options.report && options.report.length > 0) {
76
+ options.report.forEach((reportType) => {
77
+ args.push("--report", reportType);
78
+ });
79
+ }
80
+ if (options.reportFile) {
81
+ args.push("--report-file", options.reportFile);
82
+ }
83
+ if (options.lcovVersion) {
84
+ args.push("--lcov-version", options.lcovVersion);
85
+ }
86
+ if (options.includeLibs) {
87
+ args.push("--include-libs");
88
+ }
89
+ if (options.excludeTests) {
90
+ args.push("--exclude-tests");
91
+ }
92
+ if (options.irMinimum) {
93
+ args.push("--ir-minimum");
94
+ }
95
+ return args;
96
+ }
97
+ /**
98
+ * Build test filtering options
99
+ */
100
+ buildFilterOptions(options) {
101
+ const args = [];
102
+ if (options.matchTest) {
103
+ args.push("--match-test", options.matchTest);
104
+ }
105
+ if (options.noMatchTest) {
106
+ args.push("--no-match-test", options.noMatchTest);
107
+ }
108
+ if (options.matchContract) {
109
+ args.push("--match-contract", options.matchContract);
110
+ }
111
+ if (options.noMatchContract) {
112
+ args.push("--no-match-contract", options.noMatchContract);
113
+ }
114
+ if (options.matchPath) {
115
+ args.push("--match-path", options.matchPath);
116
+ }
117
+ if (options.noMatchPath) {
118
+ args.push("--no-match-path", options.noMatchPath);
119
+ }
120
+ if (options.noMatchCoverage) {
121
+ args.push("--no-match-coverage", options.noMatchCoverage);
122
+ }
123
+ return args;
124
+ }
125
+ /**
126
+ * Build display options
127
+ */
128
+ buildDisplayOptions(options) {
129
+ const args = [];
130
+ // Verbosity (-v, -vv, -vvv, etc.)
131
+ if (options.verbosity && options.verbosity > 0) {
132
+ args.push("-" + "v".repeat(options.verbosity));
133
+ }
134
+ if (options.quiet) {
135
+ args.push("--quiet");
136
+ }
137
+ if (options.json) {
138
+ args.push("--json");
139
+ }
140
+ if (options.md) {
141
+ args.push("--md");
142
+ }
143
+ if (options.color) {
144
+ args.push("--color", options.color);
145
+ }
146
+ return args;
147
+ }
148
+ /**
149
+ * Build test execution options
150
+ */
151
+ buildTestOptions(options) {
152
+ const args = [];
153
+ if (options.threads !== undefined) {
154
+ args.push("--threads", options.threads.toString());
155
+ }
156
+ if (options.fuzzRuns !== undefined) {
157
+ args.push("--fuzz-runs", options.fuzzRuns.toString());
158
+ }
159
+ if (options.fuzzSeed) {
160
+ args.push("--fuzz-seed", options.fuzzSeed);
161
+ }
162
+ if (options.failFast) {
163
+ args.push("--fail-fast");
164
+ }
165
+ if (options.allowFailure) {
166
+ args.push("--allow-failure");
167
+ }
168
+ return args;
169
+ }
170
+ /**
171
+ * Build EVM options
172
+ */
173
+ buildEvmOptions(options) {
174
+ const args = [];
175
+ if (options.forkBlockNumber !== undefined) {
176
+ args.push("--fork-block-number", options.forkBlockNumber.toString());
177
+ }
178
+ if (options.initialBalance) {
179
+ args.push("--initial-balance", options.initialBalance);
180
+ }
181
+ if (options.sender) {
182
+ args.push("--sender", options.sender);
183
+ }
184
+ if (options.ffi) {
185
+ args.push("--ffi");
186
+ }
187
+ return args;
188
+ }
189
+ /**
190
+ * Build build options
191
+ */
192
+ buildBuildOptions(options) {
193
+ const args = [];
194
+ if (options.force) {
195
+ args.push("--force");
196
+ }
197
+ if (options.noCache) {
198
+ args.push("--no-cache");
199
+ }
200
+ if (options.optimize) {
201
+ args.push("--optimize");
202
+ }
203
+ if (options.optimizerRuns !== undefined) {
204
+ args.push("--optimizer-runs", options.optimizerRuns.toString());
205
+ }
206
+ if (options.viaIr) {
207
+ args.push("--via-ir");
208
+ }
209
+ return args;
210
+ }
211
+ /**
212
+ * Execute forge coverage command and stream output
213
+ *
214
+ * @param args - Command arguments
215
+ * @returns Promise<boolean> - true if command succeeds
216
+ */
217
+ executeForge(args) {
218
+ return new Promise((resolve, reject) => {
219
+ const forgeProcess = (0, child_process_1.spawn)("forge", ["coverage", ...args], {
220
+ cwd: this.hre.config.paths.root,
221
+ stdio: "inherit", // Stream output directly to terminal
222
+ });
223
+ forgeProcess.on("close", (code) => {
224
+ if (code === 0) {
225
+ resolve(true);
226
+ }
227
+ else {
228
+ resolve(false);
229
+ }
230
+ });
231
+ forgeProcess.on("error", (error) => {
232
+ reject(new Error(`Failed to execute forge coverage: ${error.message}`));
233
+ });
234
+ });
235
+ }
236
+ }
237
+ exports.ForgeCoverageFramework = ForgeCoverageFramework;
238
+ //# sourceMappingURL=ForgeCoverageFramework.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ForgeCoverageFramework.js","sourceRoot":"","sources":["../../src/framework/ForgeCoverageFramework.ts"],"names":[],"mappings":";;;AAAA,iDAAsC;AAGtC,4CAAyC;AAEzC;;;;;;;;GAQG;AACH,MAAa,sBAAsB;IACb;IAApB,YAAoB,GAA8B;QAA9B,QAAG,GAAH,GAAG,CAA2B;IAAG,CAAC;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AE,GAAG,IAAI,CAAC,EAAE;gBACzD,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI;gBAC/B,KAAK,EAAE,SAAS,EAAE,qCAAqC;aACxD,CAAC,CAAC;YAEH,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;gBAChC,IAAI,IAAI,KAAK,CAAC,EAAE;oBACd,OAAO,CAAC,IAAI,CAAC,CAAC;iBACf;qBAAM;oBACL,OAAO,CAAC,KAAK,CAAC,CAAC;iBAChB;YACH,CAAC,CAAC,CAAC;YAEH,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;gBACjC,MAAM,CAAC,IAAI,KAAK,CAAC,qCAAqC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YAC1E,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAhRD,wDAgRC","sourcesContent":["import { spawn } from \"child_process\";\nimport { HardhatRuntimeEnvironment } from \"hardhat/types\";\nimport { CoverageOptions } from \"../types/config\";\nimport { Logger } from \"../utils/logger\";\n\n/**\n * ForgeCoverageFramework - Orchestrates forge coverage execution for Diamond contracts\n *\n * Responsibilities:\n * 1. Build forge coverage command with all options\n * 2. Execute forge coverage with proper fork URL\n * 3. Stream output to terminal\n * 4. Handle errors appropriately\n */\nexport class ForgeCoverageFramework {\n constructor(private hre: HardhatRuntimeEnvironment) {}\n\n /**\n * Run forge coverage with provided options\n *\n * @param options - Coverage execution options\n * @returns Promise<boolean> - true if coverage succeeds, false otherwise\n */\n async runCoverage(options: CoverageOptions = {}): Promise<boolean> {\n Logger.section(\"Forge Coverage - Execution\");\n\n try {\n // Build command arguments\n const args = this.buildCoverageCommand(options);\n\n Logger.info(`Executing: forge coverage ${args.join(\" \")}`);\n Logger.info(\"โณ Running coverage analysis (this may take a while)...\\n\");\n\n // Execute forge coverage\n const success = await this.executeForge(args);\n\n if (success) {\n Logger.success(\"โœ… Coverage analysis completed successfully\");\n } else {\n Logger.error(\"โŒ Coverage analysis failed\");\n }\n\n return success;\n } catch (error: any) {\n Logger.error(`Coverage execution error: ${error.message}`);\n return false;\n }\n }\n\n /**\n * Build complete forge coverage command arguments\n *\n * @param options - Coverage options\n * @returns Array of command arguments\n */\n private buildCoverageCommand(options: CoverageOptions): string[] {\n const args: string[] = [];\n\n // Add fork URL if provided\n if (options.forkUrl) {\n args.push(\"--fork-url\", options.forkUrl);\n }\n\n // Add all option groups\n args.push(...this.buildReportOptions(options));\n args.push(...this.buildFilterOptions(options));\n args.push(...this.buildDisplayOptions(options));\n args.push(...this.buildTestOptions(options));\n args.push(...this.buildEvmOptions(options));\n args.push(...this.buildBuildOptions(options));\n\n return args.filter((arg) => arg !== \"\");\n }\n\n /**\n * Build report-related options\n */\n private buildReportOptions(options: CoverageOptions): string[] {\n const args: string[] = [];\n\n // Multiple --report flags\n if (options.report && options.report.length > 0) {\n options.report.forEach((reportType) => {\n args.push(\"--report\", reportType);\n });\n }\n\n if (options.reportFile) {\n args.push(\"--report-file\", options.reportFile);\n }\n\n if (options.lcovVersion) {\n args.push(\"--lcov-version\", options.lcovVersion);\n }\n\n if (options.includeLibs) {\n args.push(\"--include-libs\");\n }\n\n if (options.excludeTests) {\n args.push(\"--exclude-tests\");\n }\n\n if (options.irMinimum) {\n args.push(\"--ir-minimum\");\n }\n\n return args;\n }\n\n /**\n * Build test filtering options\n */\n private buildFilterOptions(options: CoverageOptions): string[] {\n const args: string[] = [];\n\n if (options.matchTest) {\n args.push(\"--match-test\", options.matchTest);\n }\n\n if (options.noMatchTest) {\n args.push(\"--no-match-test\", options.noMatchTest);\n }\n\n if (options.matchContract) {\n args.push(\"--match-contract\", options.matchContract);\n }\n\n if (options.noMatchContract) {\n args.push(\"--no-match-contract\", options.noMatchContract);\n }\n\n if (options.matchPath) {\n args.push(\"--match-path\", options.matchPath);\n }\n\n if (options.noMatchPath) {\n args.push(\"--no-match-path\", options.noMatchPath);\n }\n\n if (options.noMatchCoverage) {\n args.push(\"--no-match-coverage\", options.noMatchCoverage);\n }\n\n return args;\n }\n\n /**\n * Build display options\n */\n private buildDisplayOptions(options: CoverageOptions): string[] {\n const args: string[] = [];\n\n // Verbosity (-v, -vv, -vvv, etc.)\n if (options.verbosity && options.verbosity > 0) {\n args.push(\"-\" + \"v\".repeat(options.verbosity));\n }\n\n if (options.quiet) {\n args.push(\"--quiet\");\n }\n\n if (options.json) {\n args.push(\"--json\");\n }\n\n if (options.md) {\n args.push(\"--md\");\n }\n\n if (options.color) {\n args.push(\"--color\", options.color);\n }\n\n return args;\n }\n\n /**\n * Build test execution options\n */\n private buildTestOptions(options: CoverageOptions): string[] {\n const args: string[] = [];\n\n if (options.threads !== undefined) {\n args.push(\"--threads\", options.threads.toString());\n }\n\n if (options.fuzzRuns !== undefined) {\n args.push(\"--fuzz-runs\", options.fuzzRuns.toString());\n }\n\n if (options.fuzzSeed) {\n args.push(\"--fuzz-seed\", options.fuzzSeed);\n }\n\n if (options.failFast) {\n args.push(\"--fail-fast\");\n }\n\n if (options.allowFailure) {\n args.push(\"--allow-failure\");\n }\n\n return args;\n }\n\n /**\n * Build EVM options\n */\n private buildEvmOptions(options: CoverageOptions): string[] {\n const args: string[] = [];\n\n if (options.forkBlockNumber !== undefined) {\n args.push(\"--fork-block-number\", options.forkBlockNumber.toString());\n }\n\n if (options.initialBalance) {\n args.push(\"--initial-balance\", options.initialBalance);\n }\n\n if (options.sender) {\n args.push(\"--sender\", options.sender);\n }\n\n if (options.ffi) {\n args.push(\"--ffi\");\n }\n\n return args;\n }\n\n /**\n * Build build options\n */\n private buildBuildOptions(options: CoverageOptions): string[] {\n const args: string[] = [];\n\n if (options.force) {\n args.push(\"--force\");\n }\n\n if (options.noCache) {\n args.push(\"--no-cache\");\n }\n\n if (options.optimize) {\n args.push(\"--optimize\");\n }\n\n if (options.optimizerRuns !== undefined) {\n args.push(\"--optimizer-runs\", options.optimizerRuns.toString());\n }\n\n if (options.viaIr) {\n args.push(\"--via-ir\");\n }\n\n return args;\n }\n\n /**\n * Execute forge coverage command and stream output\n *\n * @param args - Command arguments\n * @returns Promise<boolean> - true if command succeeds\n */\n private executeForge(args: string[]): Promise<boolean> {\n return new Promise((resolve, reject) => {\n const forgeProcess = spawn(\"forge\", [\"coverage\", ...args], {\n cwd: this.hre.config.paths.root,\n stdio: \"inherit\", // Stream output directly to terminal\n });\n\n forgeProcess.on(\"close\", (code) => {\n if (code === 0) {\n resolve(true);\n } else {\n resolve(false);\n }\n });\n\n forgeProcess.on(\"error\", (error) => {\n reject(new Error(`Failed to execute forge coverage: ${error.message}`));\n });\n });\n }\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import "./tasks/coverage";
1
2
  import "./tasks/deploy";
2
3
  import "./tasks/generate-helpers";
3
4
  import "./tasks/init";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,gBAAgB,CAAC;AACxB,OAAO,0BAA0B,CAAC;AAClC,OAAO,cAAc,CAAC;AACtB,OAAO,cAAc,CAAC;AACtB,OAAO,iBAAiB,CAAC;AAmBzB,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,gBAAgB,CAAC;AACxB,OAAO,0BAA0B,CAAC;AAClC,OAAO,cAAc,CAAC;AACtB,OAAO,cAAc,CAAC;AACtB,OAAO,iBAAiB,CAAC;AAmBzB,cAAc,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -18,6 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  const config_1 = require("hardhat/config");
21
+ require("./tasks/coverage");
21
22
  require("./tasks/deploy");
22
23
  require("./tasks/generate-helpers");
23
24
  require("./tasks/init");
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,2CAAqF;AACrF,0BAAwB;AACxB,oCAAkC;AAClC,wBAAsB;AACtB,wBAAsB;AACtB,2BAAyB;AAEzB,2BAA+C;AAC/C,iEAG0C;AAE1C,gDAAwB;AACxB,4DAAoC;AACpC,uCAKmB;AACnB,mDAAoD;AAEpD,eAAe;AACf,iDAA+B;AAE/B,MAAM,iBAAiB,GAAG,cAAc,CAAC;AAEzC,IAAI,eAAe,GAAG,KAAK,CAAC;AAE5B,8CAA8C;AAC9C,IAAA,qBAAY,EAAC,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE;IAClC,0CAA0C;IAC1C,MAAM,CAAC,eAAe,GAAG,IAAA,2BAAc,EAAC,UAAU,CAAC,eAAe,CAAC,CAAC;IAEpE,mFAAmF;IACnF,IAAI,CAAC,IAAA,eAAU,EAAC,cAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,EAAE;QAC7D,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE;YAC7C,OAAO,CAAC,GAAG,CACT,oBAAU,CAAC,MAAM,CACf,oIAAoI,iBAAiB,kBAAkB,CACxK,CACF,CAAC;SACH;QACD,OAAO;KACR;IAED,sBAAsB;IACtB,MAAM,aAAa,GAAG,IAAA,wBAAc,GAAE,CAAC;IAEvC,6BAA6B;IAC7B,IACE,aAAa,EAAE,GAAG,KAAK,SAAS;QAChC,aAAa,EAAE,UAAU,KAAK,SAAS,EACvC;QACA,MAAM,IAAI,6BAAmB,CAC3B,qFAAqF,CACtF,CAAC;KACH;IAED,gEAAgE;IAChE,MAAM,eAAe,GAAG,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC;IAClD,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,CAAC,eAAe,EAAE;QACpB,OAAO,EAAE,CAAC;KACX;IAED,OAAO,IAAA,uBAAa,GAAE,CAAC;AACzB,CAAC,CACF,CAAC;AAEF,IAAA,aAAI,EACF,iBAAiB,EACjB,qDAAqD,EACrD,KAAK,EAAE,CAAC,EAAE,GAA8B,EAAE,EAAE;IAC1C,MAAM,iBAAiB,GAAG,cAAI,CAAC,OAAO,CACpC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EACrB,cAAc,CACf,CAAC;IAEF,IAAI,IAAA,eAAU,EAAC,iBAAiB,CAAC,EAAE;QACjC,OAAO,CAAC,IAAI,CACV,oBAAU,CAAC,MAAM,CAAC,6CAA6C,CAAC,CACjE,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACjB;IAED,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;IAE7C,IAAA,kBAAa,EACX,iBAAiB,EACjB;QACE,mBAAmB;QACnB,UAAU,cAAI,CAAC,QAAQ,CACrB,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EACrB,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CACzB,GAAG;QACJ,aAAa;QACb,gCAAgC;QAChC,WAAW,cAAI,CAAC,QAAQ,CACtB,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EACrB,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CACvB,GAAG;QACJ,6BAA6B;KAC9B,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;IAEF,MAAM,IAAA,2BAAiB,EAAC,sBAAsB,CAAC,CAAC;AAClD,CAAC,CACF,CAAC","sourcesContent":["import { extendConfig, extendEnvironment, internalTask, task } from \"hardhat/config\";\nimport \"./tasks/deploy\";\nimport \"./tasks/generate-helpers\";\nimport \"./tasks/init\";\nimport \"./tasks/test\";\nimport \"./types/hardhat\";\n\nimport { existsSync, writeFileSync } from \"fs\";\nimport {\n TASK_COMPILE_GET_REMAPPINGS,\n TASK_COMPILE_TRANSFORM_IMPORT_NAME,\n} from \"hardhat/builtin-tasks/task-names\";\nimport { HardhatRuntimeEnvironment } from \"hardhat/types\";\nimport path from \"path\";\nimport picocolors from \"picocolors\";\nimport {\n getForgeConfig,\n getRemappings,\n HardhatFoundryError,\n installDependency,\n} from \"./foundry\";\nimport { validateConfig } from \"./utils/validation\";\n\n// Export types\nexport * from \"./types/config\";\n\nconst TASK_INIT_FOUNDRY = \"init-foundry\";\n\nlet pluginActivated = false;\n\n// Extend config with diamondsFoundry settings\nextendConfig((config, userConfig) => {\n // Validate and set diamondsFoundry config\n config.diamondsFoundry = validateConfig(userConfig.diamondsFoundry);\n\n // Check foundry.toml presence. Don't warn when running foundry initialization task\n if (!existsSync(path.join(config.paths.root, \"foundry.toml\"))) {\n if (!process.argv.includes(TASK_INIT_FOUNDRY)) {\n console.log(\n picocolors.yellow(\n `Warning: You are using the diamonds-hardhat-foundry plugin but there isn't a foundry.toml file in your project. Run 'npx hardhat ${TASK_INIT_FOUNDRY}' to create one.`\n )\n );\n }\n return;\n }\n\n // Load foundry config\n const foundryConfig = getForgeConfig();\n\n // Ensure required keys exist\n if (\n foundryConfig?.src === undefined ||\n foundryConfig?.cache_path === undefined\n ) {\n throw new HardhatFoundryError(\n \"Couldn't find `src` or `cache_path` config keys after running `forge config --json`\"\n );\n }\n\n // Ensure foundry src path doesn't mismatch user-configured path\n const userSourcesPath = userConfig.paths?.sources;\n const foundrySourcesPath = foundryConfig.src;\n\n if (\n userSourcesPath !== undefined &&\n path.resolve(userSourcesPath) !== path.resolve(foundrySourcesPath)\n ) {\n throw new HardhatFoundryError(\n `User-configured sources path (${userSourcesPath}) doesn't match path configured in foundry (${foundrySourcesPath})`\n );\n }\n\n // Set sources path\n config.paths.sources = path.resolve(config.paths.root, foundrySourcesPath);\n\n // Change hardhat's cache path if it clashes with foundry's\n const foundryCachePath = path.resolve(\n config.paths.root,\n foundryConfig.cache_path\n );\n if (config.paths.cache === foundryCachePath) {\n config.paths.cache = \"cache_hardhat\";\n }\n\n pluginActivated = true;\n});\n\n// Extend environment to add diamondsFoundry config to HRE\nextendEnvironment((hre: HardhatRuntimeEnvironment) => {\n hre.diamondsFoundry = hre.config.diamondsFoundry;\n});\n\n// This task is in place to detect old hardhat-core versions\ninternalTask(TASK_COMPILE_TRANSFORM_IMPORT_NAME).setAction(\n async (\n {\n importName,\n deprecationCheck,\n }: { importName: string; deprecationCheck: boolean },\n _hre\n ): Promise<string> => {\n // When the deprecationCheck param is passed, it means a new enough hardhat-core is being used\n if (deprecationCheck) {\n return importName;\n }\n throw new HardhatFoundryError(\n \"This version of diamonds-hardhat-foundry depends on hardhat version >= 2.17.2\"\n );\n }\n);\n\ninternalTask(TASK_COMPILE_GET_REMAPPINGS).setAction(\n async (): Promise<Record<string, string>> => {\n if (!pluginActivated) {\n return {};\n }\n\n return getRemappings();\n }\n);\n\ntask(\n TASK_INIT_FOUNDRY,\n \"Initialize foundry setup in current hardhat project\",\n async (_, hre: HardhatRuntimeEnvironment) => {\n const foundryConfigPath = path.resolve(\n hre.config.paths.root,\n \"foundry.toml\"\n );\n\n if (existsSync(foundryConfigPath)) {\n console.warn(\n picocolors.yellow(`File foundry.toml already exists. Aborting.`)\n );\n process.exit(1);\n }\n\n console.log(`Creating foundry.toml file...`);\n\n writeFileSync(\n foundryConfigPath,\n [\n `[profile.default]`,\n `src = '${path.relative(\n hre.config.paths.root,\n hre.config.paths.sources\n )}'`,\n `out = 'out'`,\n `libs = ['node_modules', 'lib']`,\n `test = '${path.relative(\n hre.config.paths.root,\n hre.config.paths.tests\n )}'`,\n `cache_path = 'cache_forge'`,\n ].join(\"\\n\")\n );\n\n await installDependency(\"foundry-rs/forge-std\");\n }\n);\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,2CAAqF;AACrF,4BAA0B;AAC1B,0BAAwB;A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AE,GAA8B,EAAE,EAAE;IAC1C,MAAM,iBAAiB,GAAG,cAAI,CAAC,OAAO,CACpC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EACrB,cAAc,CACf,CAAC;IAEF,IAAI,IAAA,eAAU,EAAC,iBAAiB,CAAC,EAAE;QACjC,OAAO,CAAC,IAAI,CACV,oBAAU,CAAC,MAAM,CAAC,6CAA6C,CAAC,CACjE,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACjB;IAED,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;IAE7C,IAAA,kBAAa,EACX,iBAAiB,EACjB;QACE,mBAAmB;QACnB,UAAU,cAAI,CAAC,QAAQ,CACrB,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EACrB,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CACzB,GAAG;QACJ,aAAa;QACb,gCAAgC;QAChC,WAAW,cAAI,CAAC,QAAQ,CACtB,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EACrB,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CACvB,GAAG;QACJ,6BAA6B;KAC9B,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;IAEF,MAAM,IAAA,2BAAiB,EAAC,sBAAsB,CAAC,CAAC;AAClD,CAAC,CACF,CAAC","sourcesContent":["import { extendConfig, extendEnvironment, internalTask, task } from \"hardhat/config\";\nimport \"./tasks/coverage\";\nimport \"./tasks/deploy\";\nimport \"./tasks/generate-helpers\";\nimport \"./tasks/init\";\nimport \"./tasks/test\";\nimport \"./types/hardhat\";\n\nimport { existsSync, writeFileSync } from \"fs\";\nimport {\n TASK_COMPILE_GET_REMAPPINGS,\n TASK_COMPILE_TRANSFORM_IMPORT_NAME,\n} from \"hardhat/builtin-tasks/task-names\";\nimport { HardhatRuntimeEnvironment } from \"hardhat/types\";\nimport path from \"path\";\nimport picocolors from \"picocolors\";\nimport {\n getForgeConfig,\n getRemappings,\n HardhatFoundryError,\n installDependency,\n} from \"./foundry\";\nimport { validateConfig } from \"./utils/validation\";\n\n// Export types\nexport * from \"./types/config\";\n\nconst TASK_INIT_FOUNDRY = \"init-foundry\";\n\nlet pluginActivated = false;\n\n// Extend config with diamondsFoundry settings\nextendConfig((config, userConfig) => {\n // Validate and set diamondsFoundry config\n config.diamondsFoundry = validateConfig(userConfig.diamondsFoundry);\n\n // Check foundry.toml presence. Don't warn when running foundry initialization task\n if (!existsSync(path.join(config.paths.root, \"foundry.toml\"))) {\n if (!process.argv.includes(TASK_INIT_FOUNDRY)) {\n console.log(\n picocolors.yellow(\n `Warning: You are using the diamonds-hardhat-foundry plugin but there isn't a foundry.toml file in your project. Run 'npx hardhat ${TASK_INIT_FOUNDRY}' to create one.`\n )\n );\n }\n return;\n }\n\n // Load foundry config\n const foundryConfig = getForgeConfig();\n\n // Ensure required keys exist\n if (\n foundryConfig?.src === undefined ||\n foundryConfig?.cache_path === undefined\n ) {\n throw new HardhatFoundryError(\n \"Couldn't find `src` or `cache_path` config keys after running `forge config --json`\"\n );\n }\n\n // Ensure foundry src path doesn't mismatch user-configured path\n const userSourcesPath = userConfig.paths?.sources;\n const foundrySourcesPath = foundryConfig.src;\n\n if (\n userSourcesPath !== undefined &&\n path.resolve(userSourcesPath) !== path.resolve(foundrySourcesPath)\n ) {\n throw new HardhatFoundryError(\n `User-configured sources path (${userSourcesPath}) doesn't match path configured in foundry (${foundrySourcesPath})`\n );\n }\n\n // Set sources path\n config.paths.sources = path.resolve(config.paths.root, foundrySourcesPath);\n\n // Change hardhat's cache path if it clashes with foundry's\n const foundryCachePath = path.resolve(\n config.paths.root,\n foundryConfig.cache_path\n );\n if (config.paths.cache === foundryCachePath) {\n config.paths.cache = \"cache_hardhat\";\n }\n\n pluginActivated = true;\n});\n\n// Extend environment to add diamondsFoundry config to HRE\nextendEnvironment((hre: HardhatRuntimeEnvironment) => {\n hre.diamondsFoundry = hre.config.diamondsFoundry;\n});\n\n// This task is in place to detect old hardhat-core versions\ninternalTask(TASK_COMPILE_TRANSFORM_IMPORT_NAME).setAction(\n async (\n {\n importName,\n deprecationCheck,\n }: { importName: string; deprecationCheck: boolean },\n _hre\n ): Promise<string> => {\n // When the deprecationCheck param is passed, it means a new enough hardhat-core is being used\n if (deprecationCheck) {\n return importName;\n }\n throw new HardhatFoundryError(\n \"This version of diamonds-hardhat-foundry depends on hardhat version >= 2.17.2\"\n );\n }\n);\n\ninternalTask(TASK_COMPILE_GET_REMAPPINGS).setAction(\n async (): Promise<Record<string, string>> => {\n if (!pluginActivated) {\n return {};\n }\n\n return getRemappings();\n }\n);\n\ntask(\n TASK_INIT_FOUNDRY,\n \"Initialize foundry setup in current hardhat project\",\n async (_, hre: HardhatRuntimeEnvironment) => {\n const foundryConfigPath = path.resolve(\n hre.config.paths.root,\n \"foundry.toml\"\n );\n\n if (existsSync(foundryConfigPath)) {\n console.warn(\n picocolors.yellow(`File foundry.toml already exists. Aborting.`)\n );\n process.exit(1);\n }\n\n console.log(`Creating foundry.toml file...`);\n\n writeFileSync(\n foundryConfigPath,\n [\n `[profile.default]`,\n `src = '${path.relative(\n hre.config.paths.root,\n hre.config.paths.sources\n )}'`,\n `out = 'out'`,\n `libs = ['node_modules', 'lib']`,\n `test = '${path.relative(\n hre.config.paths.root,\n hre.config.paths.tests\n )}'`,\n `cache_path = 'cache_forge'`,\n ].join(\"\\n\")\n );\n\n await installDependency(\"foundry-rs/forge-std\");\n }\n);\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=coverage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coverage.d.ts","sourceRoot":"","sources":["../../src/tasks/coverage.ts"],"names":[],"mappings":""}