hardhat 2.24.0 → 2.24.1
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/internal/cli/constants.d.ts.map +1 -1
- package/internal/cli/constants.js +7 -1
- package/internal/cli/constants.js.map +1 -1
- package/internal/core/config/config-loading.d.ts.map +1 -1
- package/internal/core/config/config-loading.js +1 -0
- package/internal/core/config/config-loading.js.map +1 -1
- package/internal/solidity/compiler/index.d.ts +15 -0
- package/internal/solidity/compiler/index.d.ts.map +1 -1
- package/internal/solidity/compiler/index.js +69 -35
- package/internal/solidity/compiler/index.js.map +1 -1
- package/package.json +1 -1
- package/src/internal/cli/constants.ts +7 -1
- package/src/internal/core/config/config-loading.ts +1 -0
- package/src/internal/solidity/compiler/index.ts +86 -47
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/internal/cli/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/internal/cli/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,uBAAuB,UAKnC,CAAC"}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SUPPORTED_NODE_VERSIONS = void 0;
|
|
4
|
-
|
|
4
|
+
// TODO: Remove 18 on June 30, 2025
|
|
5
|
+
exports.SUPPORTED_NODE_VERSIONS = [
|
|
6
|
+
"^18.0.0",
|
|
7
|
+
"^20.0.0",
|
|
8
|
+
"^22.0.0",
|
|
9
|
+
"^24.0.0",
|
|
10
|
+
];
|
|
5
11
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/internal/cli/constants.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/internal/cli/constants.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACtB,QAAA,uBAAuB,GAAG;IACrC,SAAS;IACT,SAAS;IACT,SAAS;IACT,SAAS;CACV,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-loading.d.ts","sourceRoot":"","sources":["../../../src/internal/core/config/config-loading.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,UAAU,EACX,MAAM,gBAAgB,CAAC;AAaxB,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,
|
|
1
|
+
{"version":3,"file":"config-loading.d.ts","sourceRoot":"","sources":["../../../src/internal/core/config/config-loading.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,UAAU,EACX,MAAM,gBAAgB,CAAC;AAaxB,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAwBzD;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,UAU/D;AAED,wBAAgB,kBAAkB,CAChC,gBAAgB,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,EAC5C,EACE,sBAA8B,EAC9B,0BAAkC,GACnC,GAAE;IACD,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,0BAA0B,CAAC,EAAE,OAAO,CAAC;CAItC,GACA;IAAE,cAAc,EAAE,aAAa,CAAC;IAAC,UAAU,EAAE,iBAAiB,CAAA;CAAE,CAiElE;AAiCD;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,QAmExE;AA6GD,wBAAgB,sBAAsB,CACpC,cAAc,EAAE,aAAa,CAAC,UAAU,CAAC,GACxC,UAAU,EAAE,CAId"}
|
|
@@ -28,6 +28,7 @@ function importCsjOrEsModule(filePath) {
|
|
|
28
28
|
// because Hardhat configs can only be CJS but a .js extension will be interpreted as ESM.
|
|
29
29
|
// The kind of error we get in these cases depends on the Node.js version.
|
|
30
30
|
const node20Heuristic = e.code === "ERR_REQUIRE_ESM";
|
|
31
|
+
// Also works for node v24
|
|
31
32
|
const node22Heuristic = e.message === "module is not defined" ||
|
|
32
33
|
e.message === "require is not defined";
|
|
33
34
|
if (node20Heuristic || node22Heuristic) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-loading.js","sourceRoot":"","sources":["../../../src/internal/core/config/config-loading.ts"],"names":[],"mappings":";;;;;;AAEA,4DAAoC;AACpC,kDAA0B;AAC1B,wDAA+B;AAC/B,gDAAwB;AACxB,oDAA4B;AAQ5B,2CAA+C;AAC/C,wDAAgE;AAChE,sCAAyC;AACzC,gDAAwC;AACxC,4DAAyD;AAEzD,4EAAgG;AAChG,2DAAoD;AACpD,qDAAwD;AAExD,MAAM,GAAG,GAAG,IAAA,eAAK,EAAC,qBAAqB,CAAC,CAAC;AAEzC,SAAgB,mBAAmB,CAAC,QAAgB;IAClD,IAAI;QACF,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;QACnC,OAAO,QAAQ,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC;KACrE;IAAC,OAAO,CAAM,EAAE;QACf,wFAAwF;QACxF,0FAA0F;QAC1F,0EAA0E;QAC1E,MAAM,eAAe,GAAG,CAAC,CAAC,IAAI,KAAK,iBAAiB,CAAC;QACrD,MAAM,eAAe,GACnB,CAAC,CAAC,OAAO,KAAK,uBAAuB;YACrC,CAAC,CAAC,OAAO,KAAK,wBAAwB,CAAC;QACzC,IAAI,eAAe,IAAI,eAAe,EAAE;YACtC,MAAM,IAAI,qBAAY,CACpB,oBAAM,CAAC,OAAO,CAAC,8BAA8B,EAC7C,EAAE,EACF,CAAC,CACF,CAAC;SACH;QAED,sFAAsF;QACtF,MAAM,CAAC,CAAC;KACT;AACH,CAAC;
|
|
1
|
+
{"version":3,"file":"config-loading.js","sourceRoot":"","sources":["../../../src/internal/core/config/config-loading.ts"],"names":[],"mappings":";;;;;;AAEA,4DAAoC;AACpC,kDAA0B;AAC1B,wDAA+B;AAC/B,gDAAwB;AACxB,oDAA4B;AAQ5B,2CAA+C;AAC/C,wDAAgE;AAChE,sCAAyC;AACzC,gDAAwC;AACxC,4DAAyD;AAEzD,4EAAgG;AAChG,2DAAoD;AACpD,qDAAwD;AAExD,MAAM,GAAG,GAAG,IAAA,eAAK,EAAC,qBAAqB,CAAC,CAAC;AAEzC,SAAgB,mBAAmB,CAAC,QAAgB;IAClD,IAAI;QACF,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;QACnC,OAAO,QAAQ,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC;KACrE;IAAC,OAAO,CAAM,EAAE;QACf,wFAAwF;QACxF,0FAA0F;QAC1F,0EAA0E;QAC1E,MAAM,eAAe,GAAG,CAAC,CAAC,IAAI,KAAK,iBAAiB,CAAC;QACrD,0BAA0B;QAC1B,MAAM,eAAe,GACnB,CAAC,CAAC,OAAO,KAAK,uBAAuB;YACrC,CAAC,CAAC,OAAO,KAAK,wBAAwB,CAAC;QACzC,IAAI,eAAe,IAAI,eAAe,EAAE;YACtC,MAAM,IAAI,qBAAY,CACpB,oBAAM,CAAC,OAAO,CAAC,8BAA8B,EAC7C,EAAE,EACF,CAAC,CACF,CAAC;SACH;QAED,sFAAsF;QACtF,MAAM,CAAC,CAAC;KACT;AACH,CAAC;AAxBD,kDAwBC;AAED,SAAgB,iBAAiB,CAAC,UAA8B;IAC9D,IAAI,UAAU,KAAK,SAAS,EAAE;QAC5B,UAAU,GAAG,IAAA,qCAAiB,GAAE,CAAC;KAClC;SAAM;QACL,IAAI,CAAC,cAAI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,CAAC,IAAI,CACV,oBAAU,CAAC,MAAM,CACf;;;CAGP,CACM,CACF,CAAC;KACH;AACH,CAAC;AAED,SAAgB,sBAAsB,CACpC,cAAyC;IAEzC,MAAM,gBAAgB,GAAG,cAAc,CAAC,SAAS,CAAC;IAClD,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IACjE,OAAO,CAAC,GAAG,gBAAgB,EAAE,GAAG,gBAAgB,CAAC,CAAC;AACpD,CAAC;AAND,wDAMC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ExecFileOptions } from "node:child_process";
|
|
1
3
|
import { CompilerInput, CompilerOutput } from "../../../types";
|
|
2
4
|
export interface ICompiler {
|
|
3
5
|
compile(input: CompilerInput): Promise<CompilerOutput>;
|
|
@@ -13,4 +15,17 @@ export declare class NativeCompiler implements ICompiler {
|
|
|
13
15
|
constructor(_pathToSolc: string, _solcVersion?: string | undefined);
|
|
14
16
|
compile(input: CompilerInput): Promise<any>;
|
|
15
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Executes a command using execFile, writes provided input to stdin,
|
|
20
|
+
* and returns a Promise that resolves with stdout and stderr.
|
|
21
|
+
*
|
|
22
|
+
* @param {string} file - The file to execute.
|
|
23
|
+
* @param {readonly string[]} args - The arguments to pass to the file.
|
|
24
|
+
* @param {ExecFileOptions} options - The options to pass to the exec function.
|
|
25
|
+
* @returns {Promise<{stdout: string, stderr: string}>}
|
|
26
|
+
*/
|
|
27
|
+
export declare function execFileWithInput(file: string, args: readonly string[], input: string, options?: ExecFileOptions): Promise<{
|
|
28
|
+
stdout: string;
|
|
29
|
+
stderr: string;
|
|
30
|
+
}>;
|
|
16
31
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/internal/solidity/compiler/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAI/D,MAAM,WAAW,SAAS;IACxB,OAAO,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CACxD;AAED,qBAAa,QAAS,YAAW,SAAS;IAC5B,OAAO,CAAC,aAAa;gBAAb,aAAa,EAAE,MAAM;IAE5B,OAAO,CAAC,KAAK,EAAE,aAAa;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/internal/solidity/compiler/index.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAI/D,MAAM,WAAW,SAAS;IACxB,OAAO,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CACxD;AAED,qBAAa,QAAS,YAAW,SAAS;IAC5B,OAAO,CAAC,aAAa;gBAAb,aAAa,EAAE,MAAM;IAE5B,OAAO,CAAC,KAAK,EAAE,aAAa;CAqB1C;AAED,qBAAa,cAAe,YAAW,SAAS;IAClC,OAAO,CAAC,WAAW;IAAU,OAAO,CAAC,YAAY,CAAC;gBAA1C,WAAW,EAAE,MAAM,EAAU,YAAY,CAAC,oBAAQ;IAEzD,OAAO,CAAC,KAAK,EAAE,aAAa;CAoC1C;AAED;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAwC7C"}
|
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.NativeCompiler = exports.Compiler = void 0;
|
|
29
|
+
exports.execFileWithInput = exports.NativeCompiler = exports.Compiler = void 0;
|
|
30
30
|
const child_process_1 = require("child_process");
|
|
31
31
|
const fs = __importStar(require("fs"));
|
|
32
32
|
const node_os_1 = __importDefault(require("node:os"));
|
|
@@ -40,23 +40,16 @@ class Compiler {
|
|
|
40
40
|
}
|
|
41
41
|
async compile(input) {
|
|
42
42
|
const scriptPath = node_path_1.default.join(__dirname, "./solcjs-runner.js");
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
subprocess.stdin.write(JSON.stringify(input));
|
|
54
|
-
subprocess.stdin.end();
|
|
55
|
-
}
|
|
56
|
-
catch (e) {
|
|
57
|
-
throw new errors_1.HardhatError(errors_list_1.ERRORS.SOLC.SOLCJS_ERROR, { error: e.message }, e);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
43
|
+
let output;
|
|
44
|
+
try {
|
|
45
|
+
const { stdout } = await execFileWithInput(process.execPath, [scriptPath, this._pathToSolcJs], JSON.stringify(input), {
|
|
46
|
+
maxBuffer: 1024 * 1024 * 500,
|
|
47
|
+
});
|
|
48
|
+
output = stdout;
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
throw new errors_1.HardhatError(errors_list_1.ERRORS.SOLC.SOLCJS_ERROR, {}, e);
|
|
52
|
+
}
|
|
60
53
|
return JSON.parse(output);
|
|
61
54
|
}
|
|
62
55
|
}
|
|
@@ -83,25 +76,66 @@ class NativeCompiler {
|
|
|
83
76
|
args.push(tmpFolder);
|
|
84
77
|
}
|
|
85
78
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
process.stdin.write(JSON.stringify(input));
|
|
97
|
-
process.stdin.end();
|
|
98
|
-
}
|
|
99
|
-
catch (e) {
|
|
100
|
-
throw new errors_1.HardhatError(errors_list_1.ERRORS.SOLC.CANT_RUN_NATIVE_COMPILER, {}, e);
|
|
101
|
-
}
|
|
102
|
-
});
|
|
79
|
+
let output;
|
|
80
|
+
try {
|
|
81
|
+
const { stdout } = await execFileWithInput(this._pathToSolc, args, JSON.stringify(input), {
|
|
82
|
+
maxBuffer: 1024 * 1024 * 500,
|
|
83
|
+
});
|
|
84
|
+
output = stdout;
|
|
85
|
+
}
|
|
86
|
+
catch (e) {
|
|
87
|
+
throw new errors_1.HardhatError(errors_list_1.ERRORS.SOLC.CANT_RUN_NATIVE_COMPILER, {}, e);
|
|
88
|
+
}
|
|
103
89
|
return JSON.parse(output);
|
|
104
90
|
}
|
|
105
91
|
}
|
|
106
92
|
exports.NativeCompiler = NativeCompiler;
|
|
93
|
+
/**
|
|
94
|
+
* Executes a command using execFile, writes provided input to stdin,
|
|
95
|
+
* and returns a Promise that resolves with stdout and stderr.
|
|
96
|
+
*
|
|
97
|
+
* @param {string} file - The file to execute.
|
|
98
|
+
* @param {readonly string[]} args - The arguments to pass to the file.
|
|
99
|
+
* @param {ExecFileOptions} options - The options to pass to the exec function.
|
|
100
|
+
* @returns {Promise<{stdout: string, stderr: string}>}
|
|
101
|
+
*/
|
|
102
|
+
async function execFileWithInput(file, args, input, options = {}) {
|
|
103
|
+
return new Promise((resolve, reject) => {
|
|
104
|
+
const child = (0, child_process_1.execFile)(file, args, options, (error, stdout, stderr) => {
|
|
105
|
+
// `error` is any execution error. e.g. command not found, non-zero exit code, etc.
|
|
106
|
+
if (error !== null) {
|
|
107
|
+
reject(error);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
resolve({ stdout, stderr });
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
// This could be triggered if node fails to spawn the child process
|
|
114
|
+
child.on("error", (err) => {
|
|
115
|
+
reject(err);
|
|
116
|
+
});
|
|
117
|
+
const stdin = child.stdin;
|
|
118
|
+
if (stdin !== null) {
|
|
119
|
+
stdin.on("error", (err) => {
|
|
120
|
+
// This captures EPIPE error
|
|
121
|
+
reject(err);
|
|
122
|
+
});
|
|
123
|
+
child.once("spawn", () => {
|
|
124
|
+
if (!stdin.writable || child.killed) {
|
|
125
|
+
return reject(new Error("Failed to write to unwritable stdin"));
|
|
126
|
+
}
|
|
127
|
+
stdin.write(input, (error) => {
|
|
128
|
+
if (error !== null && error !== undefined) {
|
|
129
|
+
reject(error);
|
|
130
|
+
}
|
|
131
|
+
stdin.end();
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
reject(new Error("No stdin on child process"));
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
exports.execFileWithInput = execFileWithInput;
|
|
107
141
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/internal/solidity/compiler/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAyC;AACzC,uCAAyB;AACzB,sDAAyB;AACzB,0DAA6B;AAC7B,+CAAiC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/internal/solidity/compiler/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAyC;AACzC,uCAAyB;AACzB,sDAAyB;AACzB,0DAA6B;AAC7B,+CAAiC;AAGjC,8CAAiD;AACjD,wDAAgD;AAMhD,MAAa,QAAQ;IACnB,YAAoB,aAAqB;QAArB,kBAAa,GAAb,aAAa,CAAQ;IAAG,CAAC;IAEtC,KAAK,CAAC,OAAO,CAAC,KAAoB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AC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACxB,MAAM,CAAC,GAAG,CAAC,CAAC;QACd,CAAC,CAAC,CAAC;QAEH,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QAE1B,IAAI,KAAK,KAAK,IAAI,EAAE;YAClB,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;gBACxB,4BAA4B;gBAC5B,MAAM,CAAC,GAAG,CAAC,CAAC;YACd,CAAC,CAAC,CAAC;YAEH,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE;gBACvB,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,MAAM,EAAE;oBACnC,OAAO,MAAM,CAAC,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC,CAAC;iBACjE;gBAED,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;oBAC3B,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;wBACzC,MAAM,CAAC,KAAK,CAAC,CAAC;qBACf;oBACD,KAAK,CAAC,GAAG,EAAE,CAAC;gBACd,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;SACJ;aAAM;YACL,MAAM,CAAC,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC,CAAC;SAChD;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AA7CD,8CA6CC"}
|
package/package.json
CHANGED
|
@@ -33,6 +33,7 @@ export function importCsjOrEsModule(filePath: string): any {
|
|
|
33
33
|
// because Hardhat configs can only be CJS but a .js extension will be interpreted as ESM.
|
|
34
34
|
// The kind of error we get in these cases depends on the Node.js version.
|
|
35
35
|
const node20Heuristic = e.code === "ERR_REQUIRE_ESM";
|
|
36
|
+
// Also works for node v24
|
|
36
37
|
const node22Heuristic =
|
|
37
38
|
e.message === "module is not defined" ||
|
|
38
39
|
e.message === "require is not defined";
|
|
@@ -3,6 +3,7 @@ import * as fs from "fs";
|
|
|
3
3
|
import os from "node:os";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import * as semver from "semver";
|
|
6
|
+
import { ExecFileOptions } from "node:child_process";
|
|
6
7
|
import { CompilerInput, CompilerOutput } from "../../../types";
|
|
7
8
|
import { HardhatError } from "../../core/errors";
|
|
8
9
|
import { ERRORS } from "../../core/errors-list";
|
|
@@ -17,32 +18,21 @@ export class Compiler implements ICompiler {
|
|
|
17
18
|
public async compile(input: CompilerInput) {
|
|
18
19
|
const scriptPath = path.join(__dirname, "./solcjs-runner.js");
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
subprocess.stdin!.write(JSON.stringify(input));
|
|
37
|
-
subprocess.stdin!.end();
|
|
38
|
-
} catch (e: any) {
|
|
39
|
-
throw new HardhatError(
|
|
40
|
-
ERRORS.SOLC.SOLCJS_ERROR,
|
|
41
|
-
{ error: e.message },
|
|
42
|
-
e
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
21
|
+
let output: string;
|
|
22
|
+
try {
|
|
23
|
+
const { stdout } = await execFileWithInput(
|
|
24
|
+
process.execPath,
|
|
25
|
+
[scriptPath, this._pathToSolcJs],
|
|
26
|
+
JSON.stringify(input),
|
|
27
|
+
{
|
|
28
|
+
maxBuffer: 1024 * 1024 * 500,
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
output = stdout;
|
|
33
|
+
} catch (e: any) {
|
|
34
|
+
throw new HardhatError(ERRORS.SOLC.SOLCJS_ERROR, {}, e);
|
|
35
|
+
}
|
|
46
36
|
|
|
47
37
|
return JSON.parse(output);
|
|
48
38
|
}
|
|
@@ -69,29 +59,78 @@ export class NativeCompiler implements ICompiler {
|
|
|
69
59
|
}
|
|
70
60
|
}
|
|
71
61
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return reject(err);
|
|
83
|
-
}
|
|
84
|
-
resolve(stdout);
|
|
85
|
-
}
|
|
86
|
-
);
|
|
62
|
+
let output: string;
|
|
63
|
+
try {
|
|
64
|
+
const { stdout } = await execFileWithInput(
|
|
65
|
+
this._pathToSolc,
|
|
66
|
+
args,
|
|
67
|
+
JSON.stringify(input),
|
|
68
|
+
{
|
|
69
|
+
maxBuffer: 1024 * 1024 * 500,
|
|
70
|
+
}
|
|
71
|
+
);
|
|
87
72
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
});
|
|
73
|
+
output = stdout;
|
|
74
|
+
} catch (e: any) {
|
|
75
|
+
throw new HardhatError(ERRORS.SOLC.CANT_RUN_NATIVE_COMPILER, {}, e);
|
|
76
|
+
}
|
|
94
77
|
|
|
95
78
|
return JSON.parse(output);
|
|
96
79
|
}
|
|
97
80
|
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Executes a command using execFile, writes provided input to stdin,
|
|
84
|
+
* and returns a Promise that resolves with stdout and stderr.
|
|
85
|
+
*
|
|
86
|
+
* @param {string} file - The file to execute.
|
|
87
|
+
* @param {readonly string[]} args - The arguments to pass to the file.
|
|
88
|
+
* @param {ExecFileOptions} options - The options to pass to the exec function.
|
|
89
|
+
* @returns {Promise<{stdout: string, stderr: string}>}
|
|
90
|
+
*/
|
|
91
|
+
export async function execFileWithInput(
|
|
92
|
+
file: string,
|
|
93
|
+
args: readonly string[],
|
|
94
|
+
input: string,
|
|
95
|
+
options: ExecFileOptions = {}
|
|
96
|
+
): Promise<{ stdout: string; stderr: string }> {
|
|
97
|
+
return new Promise((resolve, reject) => {
|
|
98
|
+
const child = execFile(file, args, options, (error, stdout, stderr) => {
|
|
99
|
+
// `error` is any execution error. e.g. command not found, non-zero exit code, etc.
|
|
100
|
+
if (error !== null) {
|
|
101
|
+
reject(error);
|
|
102
|
+
} else {
|
|
103
|
+
resolve({ stdout, stderr });
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// This could be triggered if node fails to spawn the child process
|
|
108
|
+
child.on("error", (err) => {
|
|
109
|
+
reject(err);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const stdin = child.stdin;
|
|
113
|
+
|
|
114
|
+
if (stdin !== null) {
|
|
115
|
+
stdin.on("error", (err) => {
|
|
116
|
+
// This captures EPIPE error
|
|
117
|
+
reject(err);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
child.once("spawn", () => {
|
|
121
|
+
if (!stdin.writable || child.killed) {
|
|
122
|
+
return reject(new Error("Failed to write to unwritable stdin"));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
stdin.write(input, (error) => {
|
|
126
|
+
if (error !== null && error !== undefined) {
|
|
127
|
+
reject(error);
|
|
128
|
+
}
|
|
129
|
+
stdin.end();
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
} else {
|
|
133
|
+
reject(new Error("No stdin on child process"));
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|