@diamondslab/diamonds-hardhat-foundry 1.0.1 → 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.
- package/dist/foundry.d.ts +11 -0
- package/dist/foundry.d.ts.map +1 -0
- package/dist/foundry.js +104 -0
- package/dist/foundry.js.map +1 -0
- package/dist/framework/DeploymentManager.d.ts +48 -0
- package/dist/framework/DeploymentManager.d.ts.map +1 -0
- package/dist/framework/DeploymentManager.js +145 -0
- package/dist/framework/DeploymentManager.js.map +1 -0
- package/dist/framework/ForgeFuzzingFramework.d.ts +57 -0
- package/dist/framework/ForgeFuzzingFramework.d.ts.map +1 -0
- package/dist/framework/ForgeFuzzingFramework.js +119 -0
- package/dist/framework/ForgeFuzzingFramework.js.map +1 -0
- package/dist/framework/HelperGenerator.d.ts +27 -0
- package/dist/framework/HelperGenerator.d.ts.map +1 -0
- package/dist/framework/HelperGenerator.js +195 -0
- package/dist/framework/HelperGenerator.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js.map +1 -0
- package/dist/tasks/deploy.d.ts +2 -0
- package/dist/tasks/deploy.d.ts.map +1 -0
- package/dist/tasks/deploy.js +82 -0
- package/dist/tasks/deploy.js.map +1 -0
- package/dist/tasks/generate-helpers.d.ts +2 -0
- package/dist/tasks/generate-helpers.d.ts.map +1 -0
- package/dist/tasks/generate-helpers.js +66 -0
- package/dist/tasks/generate-helpers.js.map +1 -0
- package/dist/tasks/init.d.ts +2 -0
- package/dist/tasks/init.d.ts.map +1 -0
- package/dist/tasks/init.js +78 -0
- package/dist/tasks/init.js.map +1 -0
- package/dist/tasks/test.d.ts +2 -0
- package/dist/tasks/test.d.ts.map +1 -0
- package/dist/tasks/test.js +83 -0
- package/dist/tasks/test.js.map +1 -0
- package/dist/types/config.d.ts +41 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +19 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/hardhat.d.ts +21 -0
- package/dist/types/hardhat.d.ts.map +1 -0
- package/dist/types/hardhat.js +8 -0
- package/dist/types/hardhat.js.map +1 -0
- package/dist/utils/foundry.d.ts +59 -0
- package/dist/utils/foundry.d.ts.map +1 -0
- package/dist/utils/foundry.js +164 -0
- package/dist/utils/foundry.js.map +1 -0
- package/dist/utils/logger.d.ts +38 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +66 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/validation.d.ts +33 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +131 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +2 -2
|
@@ -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,qCAAkC;AAElC;;GAEG;AAEH;;GAEG;AACH,SAAgB,2BAA2B;IACzC,IAAI;QACF,IAAA,wBAAQ,EAAC,iBAAiB,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QACjD,OAAO,IAAI,CAAC;KACb;IAAC,MAAM;QACN,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AAPD,kEAOC;AAED;;GAEG;AACH,SAAgB,cAAc;IAC5B,IAAI,CAAC,2BAA2B,EAAE,EAAE;QAClC,eAAM,CAAC,KAAK,CAAC,yCAAyC,CAAC,CAAC;QACxD,eAAM,CAAC,IAAI,CAAC,8CAA8C,CAAC,CAAC;QAC5D,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;KACtD;AACH,CAAC;AAND,wCAMC;AAED;;GAEG;AACH,SAAgB,sBAAsB,CAAC,WAAmB;IACxD,IAAI;QACF,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC;KACb;IAAC,MAAM;QACN,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AAPD,wDAOC;AAED;;GAEG;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\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.
|
|
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",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"clean": "rimraf dist"
|
|
41
41
|
},
|
|
42
42
|
"files": [
|
|
43
|
-
"dist/
|
|
43
|
+
"dist/",
|
|
44
44
|
"src/",
|
|
45
45
|
"contracts/",
|
|
46
46
|
"LICENSE",
|