@diamondslab/diamonds-hardhat-foundry 1.0.0 → 1.0.2

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.
Files changed (60) hide show
  1. package/dist/foundry.d.ts +11 -0
  2. package/dist/foundry.d.ts.map +1 -0
  3. package/dist/foundry.js +104 -0
  4. package/dist/foundry.js.map +1 -0
  5. package/dist/framework/DeploymentManager.d.ts +48 -0
  6. package/dist/framework/DeploymentManager.d.ts.map +1 -0
  7. package/dist/framework/DeploymentManager.js +145 -0
  8. package/dist/framework/DeploymentManager.js.map +1 -0
  9. package/dist/framework/ForgeFuzzingFramework.d.ts +57 -0
  10. package/dist/framework/ForgeFuzzingFramework.d.ts.map +1 -0
  11. package/dist/framework/ForgeFuzzingFramework.js +119 -0
  12. package/dist/framework/ForgeFuzzingFramework.js.map +1 -0
  13. package/dist/framework/HelperGenerator.d.ts +27 -0
  14. package/dist/framework/HelperGenerator.d.ts.map +1 -0
  15. package/dist/framework/HelperGenerator.js +195 -0
  16. package/dist/framework/HelperGenerator.js.map +1 -0
  17. package/dist/index.d.ts +10 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +113 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/tasks/deploy.d.ts +2 -0
  22. package/dist/tasks/deploy.d.ts.map +1 -0
  23. package/dist/tasks/deploy.js +82 -0
  24. package/dist/tasks/deploy.js.map +1 -0
  25. package/dist/tasks/generate-helpers.d.ts +2 -0
  26. package/dist/tasks/generate-helpers.d.ts.map +1 -0
  27. package/dist/tasks/generate-helpers.js +66 -0
  28. package/dist/tasks/generate-helpers.js.map +1 -0
  29. package/dist/tasks/init.d.ts +2 -0
  30. package/dist/tasks/init.d.ts.map +1 -0
  31. package/dist/tasks/init.js +78 -0
  32. package/dist/tasks/init.js.map +1 -0
  33. package/dist/tasks/test.d.ts +2 -0
  34. package/dist/tasks/test.d.ts.map +1 -0
  35. package/dist/tasks/test.js +83 -0
  36. package/dist/tasks/test.js.map +1 -0
  37. package/dist/types/config.d.ts +41 -0
  38. package/dist/types/config.d.ts.map +1 -0
  39. package/dist/types/config.js +19 -0
  40. package/dist/types/config.js.map +1 -0
  41. package/dist/types/hardhat.d.ts +21 -0
  42. package/dist/types/hardhat.d.ts.map +1 -0
  43. package/dist/types/hardhat.js +8 -0
  44. package/dist/types/hardhat.js.map +1 -0
  45. package/dist/utils/foundry.d.ts +59 -0
  46. package/dist/utils/foundry.d.ts.map +1 -0
  47. package/dist/utils/foundry.js +164 -0
  48. package/dist/utils/foundry.js.map +1 -0
  49. package/dist/utils/logger.d.ts +38 -0
  50. package/dist/utils/logger.d.ts.map +1 -0
  51. package/dist/utils/logger.js +66 -0
  52. package/dist/utils/logger.js.map +1 -0
  53. package/dist/utils/validation.d.ts +33 -0
  54. package/dist/utils/validation.d.ts.map +1 -0
  55. package/dist/utils/validation.js +131 -0
  56. package/dist/utils/validation.js.map +1 -0
  57. package/package.json +4 -4
  58. package/src/tasks/deploy.ts +4 -7
  59. package/src/tasks/generate-helpers.ts +4 -7
  60. package/src/tasks/test.ts +4 -7
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Logger = void 0;
7
+ const picocolors_1 = __importDefault(require("picocolors"));
8
+ /**
9
+ * Logger utility for colored console output
10
+ */
11
+ class Logger {
12
+ /**
13
+ * Log an info message in cyan
14
+ */
15
+ static info(message) {
16
+ console.log(picocolors_1.default.cyan(`ℹ ${message}`));
17
+ }
18
+ /**
19
+ * Log a success message in green
20
+ */
21
+ static success(message) {
22
+ console.log(picocolors_1.default.green(`✓ ${message}`));
23
+ }
24
+ /**
25
+ * Log a warning message in yellow
26
+ */
27
+ static warn(message) {
28
+ console.log(picocolors_1.default.yellow(`⚠ ${message}`));
29
+ }
30
+ /**
31
+ * Log an error message in red
32
+ */
33
+ static error(message) {
34
+ console.log(picocolors_1.default.red(`✗ ${message}`));
35
+ }
36
+ /**
37
+ * Log a step message in blue
38
+ */
39
+ static step(message) {
40
+ console.log(picocolors_1.default.blue(`→ ${message}`));
41
+ }
42
+ /**
43
+ * Log a verbose/debug message in gray
44
+ */
45
+ static debug(message) {
46
+ console.log(picocolors_1.default.gray(` ${message}`));
47
+ }
48
+ /**
49
+ * Log a highlighted message in magenta
50
+ */
51
+ static highlight(message) {
52
+ console.log(picocolors_1.default.magenta(`★ ${message}`));
53
+ }
54
+ /**
55
+ * Create a formatted section header
56
+ */
57
+ static section(title) {
58
+ console.log("");
59
+ console.log(picocolors_1.default.bold(picocolors_1.default.cyan(`${"=".repeat(60)}`)));
60
+ console.log(picocolors_1.default.bold(picocolors_1.default.cyan(` ${title}`)));
61
+ console.log(picocolors_1.default.bold(picocolors_1.default.cyan(`${"=".repeat(60)}`)));
62
+ console.log("");
63
+ }
64
+ }
65
+ exports.Logger = Logger;
66
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":";;;;;;AAAA,4DAAoC;AAEpC;;GAEG;AACH,MAAa,MAAM;IACjB;;OAEG;IACH,MAAM,CAAC,IAAI,CAAC,OAAe;QACzB,OAAO,CAAC,GAAG,CAAC,oBAAU,CAAC,IAAI,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC;IAC/C,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,OAAO,CAAC,OAAe;QAC5B,OAAO,CAAC,GAAG,CAAC,oBAAU,CAAC,KAAK,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC;IAChD,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,IAAI,CAAC,OAAe;QACzB,OAAO,CAAC,GAAG,CAAC,oBAAU,CAAC,MAAM,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC;IACj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["import picocolors from \"picocolors\";\n\n/**\n * Logger utility for colored console output\n */\nexport class Logger {\n /**\n * Log an info message in cyan\n */\n static info(message: string): void {\n console.log(picocolors.cyan(`ℹ ${message}`));\n }\n\n /**\n * Log a success message in green\n */\n static success(message: string): void {\n console.log(picocolors.green(`✓ ${message}`));\n }\n\n /**\n * Log a warning message in yellow\n */\n static warn(message: string): void {\n console.log(picocolors.yellow(`⚠ ${message}`));\n }\n\n /**\n * Log an error message in red\n */\n static error(message: string): void {\n console.log(picocolors.red(`✗ ${message}`));\n }\n\n /**\n * Log a step message in blue\n */\n static step(message: string): void {\n console.log(picocolors.blue(`→ ${message}`));\n }\n\n /**\n * Log a verbose/debug message in gray\n */\n static debug(message: string): void {\n console.log(picocolors.gray(` ${message}`));\n }\n\n /**\n * Log a highlighted message in magenta\n */\n static highlight(message: string): void {\n console.log(picocolors.magenta(`★ ${message}`));\n }\n\n /**\n * Create a formatted section header\n */\n static section(title: string): void {\n console.log(\"\");\n console.log(picocolors.bold(picocolors.cyan(`${\"=\".repeat(60)}`)));\n console.log(picocolors.bold(picocolors.cyan(` ${title}`)));\n console.log(picocolors.bold(picocolors.cyan(`${\"=\".repeat(60)}`)));\n console.log(\"\");\n }\n}\n"]}
@@ -0,0 +1,33 @@
1
+ import { DiamondsFoundryConfig } from "../types/config";
2
+ /**
3
+ * Validation utilities for diamonds-hardhat-foundry plugin
4
+ */
5
+ /**
6
+ * Check if Foundry is installed
7
+ */
8
+ export declare function validateFoundryInstallation(): boolean;
9
+ /**
10
+ * Check if Foundry is installed and throw error if not
11
+ */
12
+ export declare function requireFoundry(): void;
13
+ /**
14
+ * Check if a peer dependency is installed
15
+ */
16
+ export declare function validatePeerDependency(packageName: string): boolean;
17
+ /**
18
+ * Check if required peer dependencies are installed
19
+ */
20
+ export declare function validatePeerDependencies(): void;
21
+ /**
22
+ * Validate and merge user config with defaults
23
+ */
24
+ export declare function validateConfig(userConfig?: Partial<DiamondsFoundryConfig>): Required<DiamondsFoundryConfig>;
25
+ /**
26
+ * Check if a directory exists
27
+ */
28
+ export declare function validateDirectoryExists(path: string): boolean;
29
+ /**
30
+ * Validate output directory doesn't have conflicts
31
+ */
32
+ export declare function validateOutputDirectory(path: string, force?: boolean): void;
33
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAGxE;;GAEG;AAEH;;GAEG;AACH,wBAAgB,2BAA2B,IAAI,OAAO,CAOrD;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAMrC;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAOnE;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAqB/C;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,UAAU,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,GAC1C,QAAQ,CAAC,qBAAqB,CAAC,CA+CjC;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE7D;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,MAAM,EACZ,KAAK,GAAE,OAAe,GACrB,IAAI,CAMN"}
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateOutputDirectory = exports.validateDirectoryExists = exports.validateConfig = exports.validatePeerDependencies = exports.validatePeerDependency = exports.requireFoundry = exports.validateFoundryInstallation = void 0;
4
+ const child_process_1 = require("child_process");
5
+ const fs_1 = require("fs");
6
+ const config_1 = require("../types/config");
7
+ const logger_1 = require("./logger");
8
+ /**
9
+ * Validation utilities for diamonds-hardhat-foundry plugin
10
+ */
11
+ /**
12
+ * Check if Foundry is installed
13
+ */
14
+ function validateFoundryInstallation() {
15
+ try {
16
+ (0, child_process_1.execSync)("forge --version", { stdio: "ignore" });
17
+ return true;
18
+ }
19
+ catch {
20
+ return false;
21
+ }
22
+ }
23
+ exports.validateFoundryInstallation = validateFoundryInstallation;
24
+ /**
25
+ * Check if Foundry is installed and throw error if not
26
+ */
27
+ function requireFoundry() {
28
+ if (!validateFoundryInstallation()) {
29
+ logger_1.Logger.error("Foundry is not installed or not in PATH");
30
+ logger_1.Logger.info("Install Foundry from: https://getfoundry.sh/");
31
+ throw new Error("Foundry is required but not found");
32
+ }
33
+ }
34
+ exports.requireFoundry = requireFoundry;
35
+ /**
36
+ * Check if a peer dependency is installed
37
+ */
38
+ function validatePeerDependency(packageName) {
39
+ try {
40
+ require.resolve(packageName);
41
+ return true;
42
+ }
43
+ catch {
44
+ return false;
45
+ }
46
+ }
47
+ exports.validatePeerDependency = validatePeerDependency;
48
+ /**
49
+ * Check if required peer dependencies are installed
50
+ */
51
+ function validatePeerDependencies() {
52
+ const requiredDeps = [
53
+ "@diamondslab/diamonds",
54
+ "@diamondslab/hardhat-diamonds",
55
+ ];
56
+ const missing = [];
57
+ for (const dep of requiredDeps) {
58
+ if (!validatePeerDependency(dep)) {
59
+ missing.push(dep);
60
+ }
61
+ }
62
+ if (missing.length > 0) {
63
+ logger_1.Logger.error("Missing required peer dependencies:");
64
+ missing.forEach((dep) => logger_1.Logger.error(` - ${dep}`));
65
+ logger_1.Logger.info("\nInstall them with:");
66
+ logger_1.Logger.info(` npm install ${missing.join(" ")}`);
67
+ throw new Error("Missing peer dependencies");
68
+ }
69
+ }
70
+ exports.validatePeerDependencies = validatePeerDependencies;
71
+ /**
72
+ * Validate and merge user config with defaults
73
+ */
74
+ function validateConfig(userConfig) {
75
+ const config = {
76
+ ...config_1.DEFAULT_CONFIG,
77
+ ...userConfig,
78
+ };
79
+ // Validate helpersDir is a string
80
+ if (typeof config.helpersDir !== "string") {
81
+ throw new Error("diamondsFoundry.helpersDir must be a string");
82
+ }
83
+ // Validate generateExamples is boolean
84
+ if (typeof config.generateExamples !== "boolean") {
85
+ throw new Error("diamondsFoundry.generateExamples must be a boolean");
86
+ }
87
+ // Validate exampleTests is array
88
+ if (!Array.isArray(config.exampleTests)) {
89
+ throw new Error("diamondsFoundry.exampleTests must be an array");
90
+ }
91
+ // Validate exampleTests values
92
+ const validTests = ["unit", "integration", "fuzz"];
93
+ for (const test of config.exampleTests) {
94
+ if (!validTests.includes(test)) {
95
+ throw new Error(`Invalid exampleTests value: ${test}. Must be one of: ${validTests.join(", ")}`);
96
+ }
97
+ }
98
+ // Validate defaultNetwork is string
99
+ if (typeof config.defaultNetwork !== "string") {
100
+ throw new Error("diamondsFoundry.defaultNetwork must be a string");
101
+ }
102
+ // Validate reuseDeployment is boolean
103
+ if (typeof config.reuseDeployment !== "boolean") {
104
+ throw new Error("diamondsFoundry.reuseDeployment must be a boolean");
105
+ }
106
+ // Validate forgeTestArgs is array
107
+ if (!Array.isArray(config.forgeTestArgs)) {
108
+ throw new Error("diamondsFoundry.forgeTestArgs must be an array");
109
+ }
110
+ return config;
111
+ }
112
+ exports.validateConfig = validateConfig;
113
+ /**
114
+ * Check if a directory exists
115
+ */
116
+ function validateDirectoryExists(path) {
117
+ return (0, fs_1.existsSync)(path);
118
+ }
119
+ exports.validateDirectoryExists = validateDirectoryExists;
120
+ /**
121
+ * Validate output directory doesn't have conflicts
122
+ */
123
+ function validateOutputDirectory(path, force = false) {
124
+ if (!force && validateDirectoryExists(path)) {
125
+ logger_1.Logger.warn(`Output directory already exists: ${path}`);
126
+ logger_1.Logger.info("Use --force to overwrite");
127
+ throw new Error("Output directory exists");
128
+ }
129
+ }
130
+ exports.validateOutputDirectory = validateOutputDirectory;
131
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":";;;AAAA,iDAAyC;AACzC,2BAAgC;AAChC,4CAAwE;AACxE,qCA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AI,KAAK,CAAC,mDAAmD,CAAC,CAAC;KACtE;IAED,kCAAkC;IAClC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE;QACxC,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;KACnE;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAjDD,wCAiDC;AAED;;GAEG;AACH,SAAgB,uBAAuB,CAAC,IAAY;IAClD,OAAO,IAAA,eAAU,EAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAFD,0DAEC;AAED;;GAEG;AACH,SAAgB,uBAAuB,CACrC,IAAY,EACZ,QAAiB,KAAK;IAEtB,IAAI,CAAC,KAAK,IAAI,uBAAuB,CAAC,IAAI,CAAC,EAAE;QAC3C,eAAM,CAAC,IAAI,CAAC,oCAAoC,IAAI,EAAE,CAAC,CAAC;QACxD,eAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;KAC5C;AACH,CAAC;AATD,0DASC","sourcesContent":["import { execSync } from \"child_process\";\nimport { existsSync } from \"fs\";\nimport { DEFAULT_CONFIG, DiamondsFoundryConfig } from \"../types/config\";\nimport { Logger } from \"./logger\";\n\n/**\n * Validation utilities for diamonds-hardhat-foundry plugin\n */\n\n/**\n * Check if Foundry is installed\n */\nexport function validateFoundryInstallation(): boolean {\n try {\n execSync(\"forge --version\", { stdio: \"ignore\" });\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Check if Foundry is installed and throw error if not\n */\nexport function requireFoundry(): void {\n if (!validateFoundryInstallation()) {\n Logger.error(\"Foundry is not installed or not in PATH\");\n Logger.info(\"Install Foundry from: https://getfoundry.sh/\");\n throw new Error(\"Foundry is required but not found\");\n }\n}\n\n/**\n * Check if a peer dependency is installed\n */\nexport function validatePeerDependency(packageName: string): boolean {\n try {\n require.resolve(packageName);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Check if required peer dependencies are installed\n */\nexport function validatePeerDependencies(): void {\n const requiredDeps = [\n \"@diamondslab/diamonds\",\n \"@diamondslab/hardhat-diamonds\",\n ];\n\n const missing: string[] = [];\n\n for (const dep of requiredDeps) {\n if (!validatePeerDependency(dep)) {\n missing.push(dep);\n }\n }\n\n if (missing.length > 0) {\n Logger.error(\"Missing required peer dependencies:\");\n missing.forEach((dep) => Logger.error(` - ${dep}`));\n Logger.info(\"\\nInstall them with:\");\n Logger.info(` npm install ${missing.join(\" \")}`);\n throw new Error(\"Missing peer dependencies\");\n }\n}\n\n/**\n * Validate and merge user config with defaults\n */\nexport function validateConfig(\n userConfig?: Partial<DiamondsFoundryConfig>\n): Required<DiamondsFoundryConfig> {\n const config: Required<DiamondsFoundryConfig> = {\n ...DEFAULT_CONFIG,\n ...userConfig,\n };\n\n // Validate helpersDir is a string\n if (typeof config.helpersDir !== \"string\") {\n throw new Error(\"diamondsFoundry.helpersDir must be a string\");\n }\n\n // Validate generateExamples is boolean\n if (typeof config.generateExamples !== \"boolean\") {\n throw new Error(\"diamondsFoundry.generateExamples must be a boolean\");\n }\n\n // Validate exampleTests is array\n if (!Array.isArray(config.exampleTests)) {\n throw new Error(\"diamondsFoundry.exampleTests must be an array\");\n }\n\n // Validate exampleTests values\n const validTests = [\"unit\", \"integration\", \"fuzz\"];\n for (const test of config.exampleTests) {\n if (!validTests.includes(test)) {\n throw new Error(\n `Invalid exampleTests value: ${test}. Must be one of: ${validTests.join(\", \")}`\n );\n }\n }\n\n // Validate defaultNetwork is string\n if (typeof config.defaultNetwork !== \"string\") {\n throw new Error(\"diamondsFoundry.defaultNetwork must be a string\");\n }\n\n // Validate reuseDeployment is boolean\n if (typeof config.reuseDeployment !== \"boolean\") {\n throw new Error(\"diamondsFoundry.reuseDeployment must be a boolean\");\n }\n\n // Validate forgeTestArgs is array\n if (!Array.isArray(config.forgeTestArgs)) {\n throw new Error(\"diamondsFoundry.forgeTestArgs must be an array\");\n }\n\n return config;\n}\n\n/**\n * Check if a directory exists\n */\nexport function validateDirectoryExists(path: string): boolean {\n return existsSync(path);\n}\n\n/**\n * Validate output directory doesn't have conflicts\n */\nexport function validateOutputDirectory(\n path: string,\n force: boolean = false\n): void {\n if (!force && validateDirectoryExists(path)) {\n Logger.warn(`Output directory already exists: ${path}`);\n Logger.info(\"Use --force to overwrite\");\n throw new Error(\"Output directory exists\");\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diamondslab/diamonds-hardhat-foundry",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Hardhat plugin that integrates Foundry testing with Diamond proxy contracts, providing deployment helpers and fuzzing support",
5
5
  "repository": {
6
6
  "type": "git",
@@ -10,8 +10,8 @@
10
10
  "homepage": "https://github.com/diamondslab/diamonds-hardhat-foundry",
11
11
  "author": "Am0rfu5",
12
12
  "license": "MIT",
13
- "main": "dist/src/index.js",
14
- "types": "dist/src/index.d.ts",
13
+ "main": "dist/index.js",
14
+ "types": "dist/index.d.ts",
15
15
  "keywords": [
16
16
  "ethereum",
17
17
  "smart-contracts",
@@ -40,7 +40,7 @@
40
40
  "clean": "rimraf dist"
41
41
  },
42
42
  "files": [
43
- "dist/src/",
43
+ "dist/",
44
44
  "src/",
45
45
  "contracts/",
46
46
  "LICENSE",
@@ -12,14 +12,10 @@ import { validateFoundryInstallation } from "../utils/validation";
12
12
  * - Deploys Diamond using LocalDiamondDeployer
13
13
  * - Saves deployment record
14
14
  * - Optionally reuses existing deployment
15
+ *
16
+ * Use Hardhat's built-in --network flag to specify the network
15
17
  */
16
18
  task("diamonds-forge:deploy", "Deploy Diamond contract for Forge testing")
17
- .addOptionalParam(
18
- "network",
19
- "Target network for deployment",
20
- "hardhat",
21
- types.string
22
- )
23
19
  .addOptionalParam(
24
20
  "diamondName",
25
21
  "Name of the Diamond to deploy",
@@ -31,7 +27,8 @@ task("diamonds-forge:deploy", "Deploy Diamond contract for Forge testing")
31
27
  .setAction(async (taskArgs, hre: HardhatRuntimeEnvironment) => {
32
28
  Logger.section("Deploying Diamond for Forge Testing");
33
29
 
34
- const networkName = taskArgs.network;
30
+ // Use Hardhat's built-in network name from HRE
31
+ const networkName = hre.network.name;
35
32
  const diamondName = taskArgs.diamondName;
36
33
  const reuse = taskArgs.reuse;
37
34
  const force = taskArgs.force;
@@ -11,6 +11,8 @@ import { Logger } from "../utils/logger";
11
11
  * - Reads deployment record
12
12
  * - Generates DiamondDeployment.sol library
13
13
  * - Creates constants for addresses and facets
14
+ *
15
+ * Use Hardhat's built-in --network flag to specify the network
14
16
  */
15
17
  task("diamonds-forge:generate-helpers", "Generate Solidity helpers from Diamond deployment")
16
18
  .addOptionalParam(
@@ -19,12 +21,6 @@ task("diamonds-forge:generate-helpers", "Generate Solidity helpers from Diamond
19
21
  "ExampleDiamond",
20
22
  types.string
21
23
  )
22
- .addOptionalParam(
23
- "network",
24
- "Network where Diamond is deployed",
25
- "hardhat",
26
- types.string
27
- )
28
24
  .addOptionalParam(
29
25
  "outputDir",
30
26
  "Directory for generated helper files",
@@ -35,7 +31,8 @@ task("diamonds-forge:generate-helpers", "Generate Solidity helpers from Diamond
35
31
  Logger.section("Generating Diamond Deployment Helpers");
36
32
 
37
33
  const diamondName = taskArgs.diamondName;
38
- const networkName = taskArgs.network;
34
+ // Use Hardhat's built-in network name from HRE
35
+ const networkName = hre.network.name;
39
36
  const outputDir = taskArgs.outputDir || hre.diamondsFoundry.helpersDir;
40
37
 
41
38
  Logger.info(`Diamond: ${diamondName}`);
package/src/tasks/test.ts CHANGED
@@ -11,6 +11,8 @@ import { Logger } from "../utils/logger";
11
11
  * - Generates Solidity helpers
12
12
  * - Compiles Forge contracts
13
13
  * - Runs forge test with specified options
14
+ *
15
+ * Use Hardhat's built-in --network flag to specify the network
14
16
  */
15
17
  task("diamonds-forge:test", "Run Forge tests with Diamond deployment")
16
18
  .addOptionalParam(
@@ -19,12 +21,6 @@ task("diamonds-forge:test", "Run Forge tests with Diamond deployment")
19
21
  "ExampleDiamond",
20
22
  types.string
21
23
  )
22
- .addOptionalParam(
23
- "network",
24
- "Network for deployment",
25
- "hardhat",
26
- types.string
27
- )
28
24
  .addOptionalParam(
29
25
  "matchTest",
30
26
  "Run tests matching pattern (--match-test)",
@@ -51,7 +47,8 @@ task("diamonds-forge:test", "Run Forge tests with Diamond deployment")
51
47
  Logger.section("Running Forge Tests with Diamond");
52
48
 
53
49
  const diamondName = taskArgs.diamondName;
54
- const networkName = taskArgs.network;
50
+ // Use Hardhat's built-in network name from HRE
51
+ const networkName = hre.network.name;
55
52
  const matchTest = taskArgs.matchTest;
56
53
  const matchContract = taskArgs.matchContract;
57
54
  const verbosity = taskArgs.verbosity;