@nomicfoundation/hardhat-utils 3.0.0-next.2 → 3.0.0-next.21
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/src/bigint.d.ts.map +1 -1
- package/dist/src/bigint.js +1 -0
- package/dist/src/bigint.js.map +1 -1
- package/dist/src/debug.d.ts.map +1 -1
- package/dist/src/error.d.ts +19 -2
- package/dist/src/error.d.ts.map +1 -1
- package/dist/src/error.js +22 -2
- package/dist/src/error.js.map +1 -1
- package/dist/src/fs.d.ts +35 -3
- package/dist/src/fs.d.ts.map +1 -1
- package/dist/src/fs.js +155 -25
- package/dist/src/fs.js.map +1 -1
- package/dist/src/internal/lang.d.ts +1 -0
- package/dist/src/internal/lang.d.ts.map +1 -1
- package/dist/src/internal/lang.js +28 -0
- package/dist/src/internal/lang.js.map +1 -1
- package/dist/src/lang.d.ts +19 -0
- package/dist/src/lang.d.ts.map +1 -1
- package/dist/src/lang.js +22 -1
- package/dist/src/lang.js.map +1 -1
- package/dist/src/package.d.ts +12 -0
- package/dist/src/package.d.ts.map +1 -1
- package/dist/src/package.js.map +1 -1
- package/dist/src/path.d.ts +2 -2
- package/dist/src/path.d.ts.map +1 -1
- package/dist/src/path.js +12 -3
- package/dist/src/path.js.map +1 -1
- package/dist/src/request.d.ts +17 -7
- package/dist/src/request.d.ts.map +1 -1
- package/dist/src/request.js +13 -5
- package/dist/src/request.js.map +1 -1
- package/dist/src/stream.d.ts +1 -1
- package/dist/src/stream.js +1 -1
- package/dist/src/subprocess.js +1 -1
- package/dist/src/subprocess.js.map +1 -1
- package/dist/src/synchronization.js +4 -4
- package/dist/src/synchronization.js.map +1 -1
- package/package.json +9 -13
- package/src/bigint.ts +1 -0
- package/src/error.ts +26 -2
- package/src/fs.ts +196 -28
- package/src/internal/lang.ts +38 -0
- package/src/lang.ts +26 -1
- package/src/package.ts +26 -0
- package/src/path.ts +16 -6
- package/src/request.ts +25 -9
- package/src/stream.ts +1 -1
- package/src/subprocess.ts +1 -1
- package/src/synchronization.ts +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lang.d.ts","sourceRoot":"","sources":["../../../src/internal/lang.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lang.d.ts","sourceRoot":"","sources":["../../../src/internal/lang.ts"],"names":[],"mappings":"AAKA,wBAAsB,oBAAoB,IAAI,OAAO,EAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,EAAC,CAQxE;AAED,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,EAC9D,MAAM,EAAE,CAAC,EACT,MAAM,EAAE,CAAC,GACR,CAAC,GAAG,CAAC,CA+BP"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isObject } from "../lang.js";
|
|
1
2
|
let clone = null;
|
|
2
3
|
export async function getDeepCloneFunction() {
|
|
3
4
|
const { default: rfdc } = await import("rfdc");
|
|
@@ -6,4 +7,31 @@ export async function getDeepCloneFunction() {
|
|
|
6
7
|
}
|
|
7
8
|
return clone;
|
|
8
9
|
}
|
|
10
|
+
export function deepMergeImpl(target, source) {
|
|
11
|
+
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
12
|
+
-- The result is expected to include properties from both target and source,
|
|
13
|
+
but initially only target is spread in, so a cast is needed. */
|
|
14
|
+
const result = { ...target };
|
|
15
|
+
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
16
|
+
-- TypeScript cannot infer the correct union of string and symbol keys, but all keys come from U */
|
|
17
|
+
const keys = [
|
|
18
|
+
...Object.keys(source),
|
|
19
|
+
...Object.getOwnPropertySymbols(source),
|
|
20
|
+
];
|
|
21
|
+
for (const key of keys) {
|
|
22
|
+
if (isObject(source[key]) &&
|
|
23
|
+
// Only merge recursively objects that are not class instances
|
|
24
|
+
Object.getPrototypeOf(source[key]) === Object.prototype) {
|
|
25
|
+
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
26
|
+
-- The call signature expects the second argument to be of type U; the type is correct, but TypeScript can't infer it here. */
|
|
27
|
+
result[key] = deepMergeImpl(result[key] ?? {}, source[key]);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
31
|
+
-- Cast required because TypeScript can't guarantee that a dynamic key from `U` exists in `T & U` or has the correct value type. */
|
|
32
|
+
result[key] = source[key];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
9
37
|
//# sourceMappingURL=lang.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lang.js","sourceRoot":"","sources":["../../../src/internal/lang.ts"],"names":[],"mappings":"AAEA,IAAI,KAAK,GAAoC,IAAI,CAAC;AAClD,MAAM,CAAC,KAAK,UAAU,oBAAoB;IACxC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC;IAE/C,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,KAAK,GAAG,IAAI,EAAE,CAAC;IACjB,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
1
|
+
{"version":3,"file":"lang.js","sourceRoot":"","sources":["../../../src/internal/lang.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,IAAI,KAAK,GAAoC,IAAI,CAAC;AAClD,MAAM,CAAC,KAAK,UAAU,oBAAoB;IACxC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC;IAE/C,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,KAAK,GAAG,IAAI,EAAE,CAAC;IACjB,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,MAAS,EACT,MAAS;IAET;;mEAE+D;IAC/D,MAAM,MAAM,GAAG,EAAE,GAAG,MAAM,EAAW,CAAC;IAEtC;uGACmG;IACnG,MAAM,IAAI,GAAG;QACX,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;QACtB,GAAG,MAAM,CAAC,qBAAqB,CAAC,MAAM,CAAC;KACtB,CAAC;IAEpB,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IACE,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACrB,8DAA8D;YAC9D,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,MAAM,CAAC,SAAS,EACvD,CAAC;YACD;0IAC8H;YAC9H,MAAM,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,MAAM,CAAC,GAAG,CAAM,CACjC,CAAC;QACjC,CAAC;aAAM,CAAC;YACN;gJACoI;YACpI,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAsC,CAAC;QACjE,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/src/lang.d.ts
CHANGED
|
@@ -13,6 +13,25 @@ export declare function deepClone<T>(value: T): Promise<T>;
|
|
|
13
13
|
* @returns True if the values are deeply equal, false otherwise.
|
|
14
14
|
*/
|
|
15
15
|
export declare function deepEqual<T>(x: T, y: T): Promise<boolean>;
|
|
16
|
+
/**
|
|
17
|
+
* Deeply merges two objects.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* - Arrays or `undefined` values are not valid inputs.
|
|
21
|
+
* - Functions: If a function exists in both the target and source, the source function overwrites the target.
|
|
22
|
+
* - Symbol properties: Symbol-keyed properties are merged just like string keys.
|
|
23
|
+
* - Class instances: Class instances are not merged recursively. If a class instance exists in the source, it will replace the one in the target.
|
|
24
|
+
*
|
|
25
|
+
* @param target The target object to merge into.
|
|
26
|
+
* @param source The source object to merge from.
|
|
27
|
+
* @returns A new object containing the deeply merged properties.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* deepMerge({ a: { b: 1 } }, { a: { c: 2 } }) // => { a: { b: 1, c: 2 } }
|
|
31
|
+
*
|
|
32
|
+
* deepMerge({ a: { fn: () => "from target" } }, { a: { fn: () => "from source" } }) // => { a: { fn: () => "from source" } }
|
|
33
|
+
*/
|
|
34
|
+
export declare function deepMerge<T extends object, U extends object>(target: T, source: U): T & U;
|
|
16
35
|
/**
|
|
17
36
|
* Checks if a value is an object. This function returns false for arrays.
|
|
18
37
|
*
|
package/dist/src/lang.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lang.d.ts","sourceRoot":"","sources":["../../src/lang.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAIvD;AAED;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAI/D;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,CAE3C;AAED;;;;;GAKG;AACH,wBAAsB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE1D"}
|
|
1
|
+
{"version":3,"file":"lang.d.ts","sourceRoot":"","sources":["../../src/lang.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAIvD;AAED;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAI/D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,EAC1D,MAAM,EAAE,CAAC,EACT,MAAM,EAAE,CAAC,GACR,CAAC,GAAG,CAAC,CAEP;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,CAE3C;AAED;;;;;GAKG;AACH,wBAAsB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE1D"}
|
package/dist/src/lang.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getDeepCloneFunction } from "./internal/lang.js";
|
|
1
|
+
import { deepMergeImpl, getDeepCloneFunction } from "./internal/lang.js";
|
|
2
2
|
/**
|
|
3
3
|
* Creates a deep clone of the provided value.
|
|
4
4
|
*
|
|
@@ -20,6 +20,27 @@ export async function deepEqual(x, y) {
|
|
|
20
20
|
const { deepEqual: _deepEqual } = await import("fast-equals");
|
|
21
21
|
return _deepEqual(x, y);
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Deeply merges two objects.
|
|
25
|
+
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* - Arrays or `undefined` values are not valid inputs.
|
|
28
|
+
* - Functions: If a function exists in both the target and source, the source function overwrites the target.
|
|
29
|
+
* - Symbol properties: Symbol-keyed properties are merged just like string keys.
|
|
30
|
+
* - Class instances: Class instances are not merged recursively. If a class instance exists in the source, it will replace the one in the target.
|
|
31
|
+
*
|
|
32
|
+
* @param target The target object to merge into.
|
|
33
|
+
* @param source The source object to merge from.
|
|
34
|
+
* @returns A new object containing the deeply merged properties.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* deepMerge({ a: { b: 1 } }, { a: { c: 2 } }) // => { a: { b: 1, c: 2 } }
|
|
38
|
+
*
|
|
39
|
+
* deepMerge({ a: { fn: () => "from target" } }, { a: { fn: () => "from source" } }) // => { a: { fn: () => "from source" } }
|
|
40
|
+
*/
|
|
41
|
+
export function deepMerge(target, source) {
|
|
42
|
+
return deepMergeImpl(target, source);
|
|
43
|
+
}
|
|
23
44
|
/**
|
|
24
45
|
* Checks if a value is an object. This function returns false for arrays.
|
|
25
46
|
*
|
package/dist/src/lang.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lang.js","sourceRoot":"","sources":["../../src/lang.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"lang.js","sourceRoot":"","sources":["../../src/lang.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAEzE;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAI,KAAQ;IACzC,MAAM,UAAU,GAAG,MAAM,oBAAoB,EAAE,CAAC;IAEhD,OAAO,UAAU,CAAI,KAAK,CAAC,CAAC;AAC9B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAI,CAAI,EAAE,CAAI;IAC3C,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAC;IAE9D,OAAO,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC1B,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,SAAS,CACvB,MAAS,EACT,MAAS;IAET,OAAO,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACvC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CACtB,KAAc;IAEd,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,OAAe;IACzC,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC;AACtE,CAAC"}
|
package/dist/src/package.d.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
export type PackageExports = PackageExportPath | {
|
|
2
|
+
[path: PackageExportsEntry]: PackageExportsValue;
|
|
3
|
+
[condition: string]: PackageExportsValue;
|
|
4
|
+
};
|
|
5
|
+
/** Allows "." and "./{name}" */
|
|
6
|
+
export type PackageExportsEntry = `.${string}`;
|
|
7
|
+
/** Internal path */
|
|
8
|
+
export type PackageExportPath = `./${string}`;
|
|
9
|
+
export type PackageExportsValue = PackageExportPath | null | {
|
|
10
|
+
[condition: string]: PackageExportsValue;
|
|
11
|
+
} | PackageExportsValue[];
|
|
1
12
|
/**
|
|
2
13
|
* The structure of a `package.json` file. This is a subset of the actual
|
|
3
14
|
* `package.json` file, if you need to access other fields you add them here.
|
|
@@ -10,6 +21,7 @@ export interface PackageJson {
|
|
|
10
21
|
engines?: {
|
|
11
22
|
node?: string;
|
|
12
23
|
};
|
|
24
|
+
exports?: PackageExports;
|
|
13
25
|
dependencies?: Record<string, string>;
|
|
14
26
|
devDependencies?: Record<string, string>;
|
|
15
27
|
peerDependencies?: Record<string, string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../src/package.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../src/package.ts"],"names":[],"mappings":"AAcA,MAAM,MAAM,cA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;AACH,wBAAsB,sBAAsB,CAC1C,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,MAAM,CAAC,CAIjB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,MAAM,EACZ,qBAAqB,EAAE,MAAM,GAC5B,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAc7B;AAED,OAAO,EACL,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC"}
|
package/dist/src/package.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.js","sourceRoot":"","sources":["../../src/package.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EACL,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"package.js","sourceRoot":"","sources":["../../src/package.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EACL,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,mB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AAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,qBAAqB,CAAC,IAAI,EAAE,CAAC;IAEvE,MAAM,UAAU,GAAG,CAAC,GAAG,qBAAqB,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,cAAc,CAAC,CAAC;IAEzE,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,UAAU,CAAC,CAAC;QAE7D,IAAI,MAAM,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC;YAClC,OAAO,WAAW,CAAC,eAAe,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;AACH,CAAC;AAED,OAAO,EACL,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC"}
|
package/dist/src/path.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export declare function resolveFromRoot(root: string, target: string): string;
|
|
|
13
13
|
* Tries to return a shorter version of the path if its inside the given folder.
|
|
14
14
|
*
|
|
15
15
|
* This is useful for displaying paths in the terminal, as they can be shorter
|
|
16
|
-
* when they are
|
|
16
|
+
* when they are inside the current working directory. For example, if the
|
|
17
17
|
* current working directory is `/home/user/project`, and the path is
|
|
18
18
|
* `/home/user/project/contracts/File.sol`, the shorter path is
|
|
19
19
|
* `contracts/File.sol`.
|
|
@@ -22,5 +22,5 @@ export declare function resolveFromRoot(root: string, target: string): string;
|
|
|
22
22
|
* @param folder The absolute path to the folder.
|
|
23
23
|
* @returns The shorter path, if possible, or the original path.
|
|
24
24
|
*/
|
|
25
|
-
export declare function shortenPath(absolutePath: string
|
|
25
|
+
export declare function shortenPath(absolutePath: string): string;
|
|
26
26
|
//# sourceMappingURL=path.d.ts.map
|
package/dist/src/path.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/path.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAMpE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/path.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAMpE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAqBxD"}
|
package/dist/src/path.js
CHANGED
|
@@ -19,7 +19,7 @@ export function resolveFromRoot(root, target) {
|
|
|
19
19
|
* Tries to return a shorter version of the path if its inside the given folder.
|
|
20
20
|
*
|
|
21
21
|
* This is useful for displaying paths in the terminal, as they can be shorter
|
|
22
|
-
* when they are
|
|
22
|
+
* when they are inside the current working directory. For example, if the
|
|
23
23
|
* current working directory is `/home/user/project`, and the path is
|
|
24
24
|
* `/home/user/project/contracts/File.sol`, the shorter path is
|
|
25
25
|
* `contracts/File.sol`.
|
|
@@ -28,8 +28,17 @@ export function resolveFromRoot(root, target) {
|
|
|
28
28
|
* @param folder The absolute path to the folder.
|
|
29
29
|
* @returns The shorter path, if possible, or the original path.
|
|
30
30
|
*/
|
|
31
|
-
export function shortenPath(absolutePath
|
|
32
|
-
const
|
|
31
|
+
export function shortenPath(absolutePath) {
|
|
32
|
+
const cwd = process.cwd();
|
|
33
|
+
let relativePath = path.relative(cwd, absolutePath);
|
|
34
|
+
if (relativePath === "..") {
|
|
35
|
+
return ".." + path.sep;
|
|
36
|
+
}
|
|
37
|
+
if (!relativePath.startsWith(".." + path.sep) &&
|
|
38
|
+
!relativePath.startsWith("." + path.sep) &&
|
|
39
|
+
!path.isAbsolute(relativePath)) {
|
|
40
|
+
relativePath = "." + path.sep + relativePath;
|
|
41
|
+
}
|
|
33
42
|
if (relativePath.length < absolutePath.length) {
|
|
34
43
|
return relativePath;
|
|
35
44
|
}
|
package/dist/src/path.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path.js","sourceRoot":"","sources":["../../src/path.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY,EAAE,MAAc;IAC1D,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5B,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACpC,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,WAAW,
|
|
1
|
+
{"version":3,"file":"path.js","sourceRoot":"","sources":["../../src/path.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY,EAAE,MAAc;IAC1D,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5B,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACpC,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,WAAW,CAAC,YAAoB;IAC9C,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC1B,IAAI,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IAEpD,IAAI,YAAY,KAAK,IAAI,EAAE,CAAC;QAC1B,OAAO,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC;IACzB,CAAC;IAED,IACE,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC;QACzC,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACxC,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,EAC9B,CAAC;QACD,YAAY,GAAG,GAAG,GAAG,IAAI,CAAC,GAAG,GAAG,YAAY,CAAC;IAC/C,CAAC;IAED,IAAI,YAAY,CAAC,MAAM,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC;QAC9C,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
package/dist/src/request.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type EventEmitter from "node:events";
|
|
2
2
|
import type UndiciT from "undici";
|
|
3
|
-
export declare const DEFAULT_TIMEOUT_IN_MILLISECONDS =
|
|
3
|
+
export declare const DEFAULT_TIMEOUT_IN_MILLISECONDS = 300000;
|
|
4
4
|
export declare const DEFAULT_MAX_REDIRECTS = 10;
|
|
5
5
|
export declare const DEFAULT_POOL_MAX_CONNECTIONS = 128;
|
|
6
6
|
export declare const DEFAULT_USER_AGENT = "Hardhat";
|
|
@@ -35,18 +35,26 @@ export interface RequestOptions {
|
|
|
35
35
|
extraHeaders?: Record<string, string>;
|
|
36
36
|
abortSignal?: AbortSignal | EventEmitter;
|
|
37
37
|
}
|
|
38
|
+
export interface HttpResponse {
|
|
39
|
+
statusCode: number;
|
|
40
|
+
body: {
|
|
41
|
+
json(): Promise<any>;
|
|
42
|
+
text(): Promise<string>;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
38
45
|
/**
|
|
39
46
|
* Performs a HTTP request.
|
|
40
47
|
*
|
|
41
48
|
* @param url The url to make the request to.
|
|
42
49
|
* @param requestOptions The options to configure the request. See {@link RequestOptions}.
|
|
43
50
|
* @param dispatcherOrDispatcherOptions Either a dispatcher or dispatcher options. See {@link DispatcherOptions}.
|
|
44
|
-
* @returns
|
|
51
|
+
* @returns An object containing the status code and the response body. The body can be accessed as JSON or text.
|
|
52
|
+
* `body` can not be consumed twice. For example, calling `text()` after `json()` throws `TypeError`.
|
|
45
53
|
* @throws ConnectionRefusedError If the connection is refused by the server.
|
|
46
54
|
* @throws RequestTimeoutError If the request times out.
|
|
47
55
|
* @throws RequestError If the request fails for any other reason.
|
|
48
56
|
*/
|
|
49
|
-
export declare function getRequest(url: string, requestOptions?: RequestOptions, dispatcherOrDispatcherOptions?: UndiciT.Dispatcher | DispatcherOptions): Promise<
|
|
57
|
+
export declare function getRequest(url: string, requestOptions?: RequestOptions, dispatcherOrDispatcherOptions?: UndiciT.Dispatcher | DispatcherOptions): Promise<HttpResponse>;
|
|
50
58
|
/**
|
|
51
59
|
* Performs a POST request with a JSON body.
|
|
52
60
|
*
|
|
@@ -54,12 +62,13 @@ export declare function getRequest(url: string, requestOptions?: RequestOptions,
|
|
|
54
62
|
* @param body The body of the request, represented as an object.
|
|
55
63
|
* @param requestOptions The options to configure the request. See {@link RequestOptions}.
|
|
56
64
|
* @param dispatcherOrDispatcherOptions Either a dispatcher or dispatcher options. See {@link DispatcherOptions}.
|
|
57
|
-
* @returns
|
|
65
|
+
* @returns An object containing the status code and the response body. The body can be accessed as JSON or text.
|
|
66
|
+
* `body` can not be consumed twice. For example, calling `text()` after `json()` throws `TypeError`.
|
|
58
67
|
* @throws ConnectionRefusedError If the connection is refused by the server.
|
|
59
68
|
* @throws RequestTimeoutError If the request times out.
|
|
60
69
|
* @throws RequestError If the request fails for any other reason.
|
|
61
70
|
*/
|
|
62
|
-
export declare function postJsonRequest(url: string, body: unknown, requestOptions?: RequestOptions, dispatcherOrDispatcherOptions?: UndiciT.Dispatcher | DispatcherOptions): Promise<
|
|
71
|
+
export declare function postJsonRequest(url: string, body: unknown, requestOptions?: RequestOptions, dispatcherOrDispatcherOptions?: UndiciT.Dispatcher | DispatcherOptions): Promise<HttpResponse>;
|
|
63
72
|
/**
|
|
64
73
|
* Performs a POST request with a form body.
|
|
65
74
|
*
|
|
@@ -67,12 +76,13 @@ export declare function postJsonRequest(url: string, body: unknown, requestOptio
|
|
|
67
76
|
* @param body The body of the request, represented as an object.
|
|
68
77
|
* @param requestOptions The options to configure the request. See {@link RequestOptions}.
|
|
69
78
|
* @param dispatcherOrDispatcherOptions Either a dispatcher or dispatcher options. See {@link DispatcherOptions}.
|
|
70
|
-
* @returns
|
|
79
|
+
* @returns An object containing the status code and the response body. The body can be accessed as JSON or text.
|
|
80
|
+
* `body` can not be consumed twice. For example, calling `text()` after `json()` throws `TypeError`.
|
|
71
81
|
* @throws ConnectionRefusedError If the connection is refused by the server.
|
|
72
82
|
* @throws RequestTimeoutError If the request times out.
|
|
73
83
|
* @throws RequestError If the request fails for any other reason.
|
|
74
84
|
*/
|
|
75
|
-
export declare function postFormRequest(url: string, body: unknown, requestOptions?: RequestOptions, dispatcherOrDispatcherOptions?: UndiciT.Dispatcher | DispatcherOptions): Promise<
|
|
85
|
+
export declare function postFormRequest(url: string, body: unknown, requestOptions?: RequestOptions, dispatcherOrDispatcherOptions?: UndiciT.Dispatcher | DispatcherOptions): Promise<HttpResponse>;
|
|
76
86
|
/**
|
|
77
87
|
* Downloads a file from a url to a destination path.
|
|
78
88
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,YAAY,MAAM,aAAa,CAAC;AAE5C,OAAO,KAAK,OAAO,MAAM,QAAQ,CAAC;AAuBlC,eAAO,MAAM,+BAA+B,
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,YAAY,MAAM,aAAa,CAAC;AAE5C,OAAO,KAAK,OAAO,MAAM,QAAQ,CAAC;AAuBlC,eAAO,MAAM,+BAA+B,SAAU,CAAC;AACvD,eAAO,MAAM,qBAAqB,KAAK,CAAC;AACxC,eAAO,MAAM,4BAA4B,MAAM,CAAC;A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AAY,CAAC,CAyBvB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,OAAO,EACb,cAAc,GAAE,cAAmB,EACnC,6BAA6B,CAAC,EAAE,OAAO,CAAC,UAAU,GAAG,iBAAiB,GACrE,OAAO,CAAC,YAAY,CAAC,CA0BvB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,QAAQ,CAC5B,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,MAAM,EACnB,cAAc,GAAE,cAAmB,EACnC,6BAA6B,CAAC,EAAE,OAAO,CAAC,UAAU,GAAG,iBAAiB,GACrE,OAAO,CAAC,IAAI,CAAC,CAgCf;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,MAAM,EACX,EACE,OAAO,EACP,KAAK,EACL,IAAI,EACJ,cAAc,EACd,gBAAgB,GACjB,GAAE,iBAAsB,GACxB,OAAO,CAAC,UAAU,CAAC,CAyBrB;AAED,wBAAsB,iBAAiB,CACrC,OAAO,GAAE;IACP,OAAO,CAAC,EAAE,MAAM,CAAC;CACb,GACL,OAAO,CAAC,cAAc,CAAC,CAKzB;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAiBnD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAO/C;AAED,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,qBAAqB,CAAC"}
|
package/dist/src/request.js
CHANGED
|
@@ -5,7 +5,7 @@ import { ensureError } from "./error.js";
|
|
|
5
5
|
import { DownloadError, RequestError, DispatcherError, } from "./errors/request.js";
|
|
6
6
|
import { move } from "./fs.js";
|
|
7
7
|
import { generateTempFilePath, getBaseDispatcherOptions, getBaseRequestOptions, getBasicDispatcher, getPoolDispatcher, getProxyDispatcher, handleError, } from "./internal/request.js";
|
|
8
|
-
export const DEFAULT_TIMEOUT_IN_MILLISECONDS =
|
|
8
|
+
export const DEFAULT_TIMEOUT_IN_MILLISECONDS = 300_000; // Aligned with unidici
|
|
9
9
|
export const DEFAULT_MAX_REDIRECTS = 10;
|
|
10
10
|
export const DEFAULT_POOL_MAX_CONNECTIONS = 128;
|
|
11
11
|
export const DEFAULT_USER_AGENT = "Hardhat";
|
|
@@ -15,7 +15,8 @@ export const DEFAULT_USER_AGENT = "Hardhat";
|
|
|
15
15
|
* @param url The url to make the request to.
|
|
16
16
|
* @param requestOptions The options to configure the request. See {@link RequestOptions}.
|
|
17
17
|
* @param dispatcherOrDispatcherOptions Either a dispatcher or dispatcher options. See {@link DispatcherOptions}.
|
|
18
|
-
* @returns
|
|
18
|
+
* @returns An object containing the status code and the response body. The body can be accessed as JSON or text.
|
|
19
|
+
* `body` can not be consumed twice. For example, calling `text()` after `json()` throws `TypeError`.
|
|
19
20
|
* @throws ConnectionRefusedError If the connection is refused by the server.
|
|
20
21
|
* @throws RequestTimeoutError If the request times out.
|
|
21
22
|
* @throws RequestError If the request fails for any other reason.
|
|
@@ -42,7 +43,8 @@ export async function getRequest(url, requestOptions = {}, dispatcherOrDispatche
|
|
|
42
43
|
* @param body The body of the request, represented as an object.
|
|
43
44
|
* @param requestOptions The options to configure the request. See {@link RequestOptions}.
|
|
44
45
|
* @param dispatcherOrDispatcherOptions Either a dispatcher or dispatcher options. See {@link DispatcherOptions}.
|
|
45
|
-
* @returns
|
|
46
|
+
* @returns An object containing the status code and the response body. The body can be accessed as JSON or text.
|
|
47
|
+
* `body` can not be consumed twice. For example, calling `text()` after `json()` throws `TypeError`.
|
|
46
48
|
* @throws ConnectionRefusedError If the connection is refused by the server.
|
|
47
49
|
* @throws RequestTimeoutError If the request times out.
|
|
48
50
|
* @throws RequestError If the request fails for any other reason.
|
|
@@ -74,7 +76,8 @@ export async function postJsonRequest(url, body, requestOptions = {}, dispatcher
|
|
|
74
76
|
* @param body The body of the request, represented as an object.
|
|
75
77
|
* @param requestOptions The options to configure the request. See {@link RequestOptions}.
|
|
76
78
|
* @param dispatcherOrDispatcherOptions Either a dispatcher or dispatcher options. See {@link DispatcherOptions}.
|
|
77
|
-
* @returns
|
|
79
|
+
* @returns An object containing the status code and the response body. The body can be accessed as JSON or text.
|
|
80
|
+
* `body` can not be consumed twice. For example, calling `text()` after `json()` throws `TypeError`.
|
|
78
81
|
* @throws ConnectionRefusedError If the connection is refused by the server.
|
|
79
82
|
* @throws RequestTimeoutError If the request times out.
|
|
80
83
|
* @throws RequestError If the request fails for any other reason.
|
|
@@ -114,7 +117,12 @@ export async function postFormRequest(url, body, requestOptions = {}, dispatcher
|
|
|
114
117
|
export async function download(url, destination, requestOptions = {}, dispatcherOrDispatcherOptions) {
|
|
115
118
|
let statusCode;
|
|
116
119
|
try {
|
|
117
|
-
|
|
120
|
+
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
121
|
+
-- We need the full Dispatcher.ResponseData here for stream.pipeline,
|
|
122
|
+
but HttpResponse doesn’t expose the raw ReadableStream.
|
|
123
|
+
TODO: wrap undici's request so we can keep the public API
|
|
124
|
+
strictly typed without falling back to Undici types. */
|
|
125
|
+
const response = (await getRequest(url, requestOptions, dispatcherOrDispatcherOptions));
|
|
118
126
|
const { body } = response;
|
|
119
127
|
statusCode = response.statusCode;
|
|
120
128
|
if (statusCode < 200 || statusCode >= 300) {
|
package/dist/src/request.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/request.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAC3C,OAAO,MAAM,MAAM,sBAAsB,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EACL,aAAa,EACb,YAAY,EACZ,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,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,qBAAqB,CAAC"}
|
package/dist/src/stream.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Writable } from "node:stream";
|
|
2
2
|
/**
|
|
3
|
-
* Creates a
|
|
3
|
+
* Creates a Transform that writes everything to actualWritable, without closing it
|
|
4
4
|
* when finished.
|
|
5
5
|
*
|
|
6
6
|
* This is useful to pipe things to stdout, without closing it, while being
|
package/dist/src/stream.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Writable } from "node:stream";
|
|
2
2
|
/**
|
|
3
|
-
* Creates a
|
|
3
|
+
* Creates a Transform that writes everything to actualWritable, without closing it
|
|
4
4
|
* when finished.
|
|
5
5
|
*
|
|
6
6
|
* This is useful to pipe things to stdout, without closing it, while being
|
package/dist/src/subprocess.js
CHANGED
|
@@ -21,7 +21,7 @@ export async function spawnDetachedSubProcess(absolutePathToSubProcessFile, args
|
|
|
21
21
|
}
|
|
22
22
|
const subprocessArgs = [absolutePathToSubProcessFile, ...args];
|
|
23
23
|
if (absolutePathToSubProcessFile.endsWith(".ts")) {
|
|
24
|
-
subprocessArgs.unshift("--import", "tsx/esm");
|
|
24
|
+
subprocessArgs.unshift("--import", import.meta.resolve("tsx/esm"));
|
|
25
25
|
}
|
|
26
26
|
const subprocess = spawn(process.execPath, subprocessArgs, {
|
|
27
27
|
detached: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subprocess.js","sourceRoot":"","sources":["../../src/subprocess.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EACL,2BAA2B,EAC3B,8BAA8B,GAC/B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE9C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,4BAAoC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AAE,GAAG,IAAI,CAAC,CAAC;IAE/D,IAAI,4BAA4B,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,cAAc,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;IACrE,CAAC;IAED,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,cAAc,EAAE;QACzD,QAAQ,EAAE,IAAI;QACd,GAAG;QACH,KAAK,EAAE,QAAQ;KAChB,CAAC,CAAC;IAEH,UAAU,CAAC,KAAK,EAAE,CAAC;AACrB,CAAC"}
|
|
@@ -10,7 +10,7 @@ import fs from "node:fs";
|
|
|
10
10
|
import os from "node:os";
|
|
11
11
|
import path from "node:path";
|
|
12
12
|
import debug from "debug";
|
|
13
|
-
import {
|
|
13
|
+
import { ensureNodeErrnoExceptionError } from "./error.js";
|
|
14
14
|
import { FileSystemAccessError } from "./errors/fs.js";
|
|
15
15
|
import { sleep } from "./lang.js";
|
|
16
16
|
const log = debug("hardhat:util:multi-process-mutex");
|
|
@@ -51,7 +51,7 @@ export class MultiProcessMutex {
|
|
|
51
51
|
return true;
|
|
52
52
|
}
|
|
53
53
|
catch (e) {
|
|
54
|
-
|
|
54
|
+
ensureNodeErrnoExceptionError(e);
|
|
55
55
|
if (e.code === "EEXIST") {
|
|
56
56
|
// File already exists, so the mutex is already acquired
|
|
57
57
|
return false;
|
|
@@ -77,7 +77,7 @@ export class MultiProcessMutex {
|
|
|
77
77
|
fileStat = fs.statSync(this.#mutexFilePath);
|
|
78
78
|
}
|
|
79
79
|
catch (e) {
|
|
80
|
-
|
|
80
|
+
ensureNodeErrnoExceptionError(e);
|
|
81
81
|
if (e.code === "ENOENT") {
|
|
82
82
|
// The file might have been deleted by another process while this function was trying to access it.
|
|
83
83
|
return false;
|
|
@@ -95,7 +95,7 @@ export class MultiProcessMutex {
|
|
|
95
95
|
fs.unlinkSync(this.#mutexFilePath);
|
|
96
96
|
}
|
|
97
97
|
catch (e) {
|
|
98
|
-
|
|
98
|
+
ensureNodeErrnoExceptionError(e);
|
|
99
99
|
if (e.code === "ENOENT") {
|
|
100
100
|
// The file might have been deleted by another process while this function was trying to access it.
|
|
101
101
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"synchronization.js","sourceRoot":"","sources":["../../src/synchronization.ts"],"names":[],"mappings":"AAAA,4HAA4H;AAC5H,2FAA2F;AAC3F,mDAAmD;AACnD,0GAA0G;AAC1G,oFAAoF;AACpF,yGAAyG;AACzG,oJAAoJ;AACpJ,6GAA6G;AAE7G,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"synchronization.js","sourceRoot":"","sources":["../../src/synchronization.ts"],"names":[],"mappings":"AAAA,4HAA4H;AAC5H,2FAA2F;AAC3F,mDAAmD;AACnD,0GAA0G;AAC1G,oFAAoF;AACpF,yGAAyG;AACzG,oJAAoJ;AACpJ,6GAA6G;AAE7G,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,MAAM,GAAG,GAAG,KAAK,CAAC,kCAAkC,CAAC,CAAC;AACtD,MAAM,gCAAgC,GAAG,KAAK,CAAC;AAC/C,MAAM,6BAA6B,GAAG,GAAG,CAAC;AAE1C,MAAM,OAAO,iBAAiB;IACnB,cA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CAAC,gCAAgC,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC;YAC5D,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACrC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,6BAA6B,CAAC,CAAC,CAAC,CAAC;YAEjC,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACxB,mGAAmG;gBACnG,OAAO;YACT,CAAC;YAED,MAAM,IAAI,qBAAqB,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nomicfoundation/hardhat-utils",
|
|
3
|
-
"version": "3.0.0-next.
|
|
3
|
+
"version": "3.0.0-next.21",
|
|
4
4
|
"description": "Utilities for Hardhat and its plugins",
|
|
5
5
|
"homepage": "https://github.com/nomicfoundation/hardhat/tree/v-next/v-next/hardhat-utils",
|
|
6
6
|
"repository": {
|
|
@@ -48,30 +48,25 @@
|
|
|
48
48
|
"README.md"
|
|
49
49
|
],
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@
|
|
52
|
-
"@nomicfoundation/hardhat-node-test-reporter": "^3.0.0-next.2",
|
|
51
|
+
"@nomicfoundation/hardhat-node-test-reporter": "^3.0.0-next.21",
|
|
53
52
|
"@types/bn.js": "^5.1.5",
|
|
54
53
|
"@types/debug": "^4.1.7",
|
|
55
54
|
"@types/node": "^20.14.9",
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"eslint-config-prettier": "9.1.0",
|
|
60
|
-
"eslint-import-resolver-typescript": "^3.6.1",
|
|
61
|
-
"eslint-plugin-import": "2.29.1",
|
|
62
|
-
"eslint-plugin-no-only-tests": "3.1.0",
|
|
63
|
-
"expect-type": "^0.19.0",
|
|
55
|
+
"c8": "^9.1.0",
|
|
56
|
+
"eslint": "9.25.1",
|
|
57
|
+
"expect-type": "^1.2.1",
|
|
64
58
|
"prettier": "3.2.5",
|
|
65
59
|
"rimraf": "^5.0.5",
|
|
66
60
|
"tsx": "^4.19.3",
|
|
67
|
-
"typescript": "~5.
|
|
68
|
-
"typescript-eslint": "7.7.1"
|
|
61
|
+
"typescript": "~5.8.0"
|
|
69
62
|
},
|
|
70
63
|
"dependencies": {
|
|
64
|
+
"@streamparser/json-node": "^0.0.22",
|
|
71
65
|
"debug": "^4.3.2",
|
|
72
66
|
"env-paths": "^2.2.0",
|
|
73
67
|
"ethereum-cryptography": "^2.2.1",
|
|
74
68
|
"fast-equals": "^5.0.1",
|
|
69
|
+
"json-stream-stringify": "^3.1.6",
|
|
75
70
|
"rfdc": "^1.3.1",
|
|
76
71
|
"undici": "^6.16.1"
|
|
77
72
|
},
|
|
@@ -82,6 +77,7 @@
|
|
|
82
77
|
"prettier": "prettier \"**/*.{ts,js,md,json}\"",
|
|
83
78
|
"test": "node --import tsx/esm --test --test-reporter=@nomicfoundation/hardhat-node-test-reporter \"test/*.ts\" \"test/!(fixture-projects|helpers)/**/*.ts\"",
|
|
84
79
|
"test:only": "node --import tsx/esm --test --test-only --test-reporter=@nomicfoundation/hardhat-node-test-reporter \"test/*.ts\" \"test/!(fixture-projects|helpers)/**/*.ts\"",
|
|
80
|
+
"test:coverage": "c8 --reporter html --reporter text --all --exclude test --exclude \"src/**/{types,type-extensions}.ts\" --src src node --import tsx/esm --test --test-reporter=@nomicfoundation/hardhat-node-test-reporter \"test/*.ts\" \"test/!(fixture-projects|helpers)/**/*.ts\"",
|
|
85
81
|
"pretest": "pnpm build",
|
|
86
82
|
"pretest:only": "pnpm build",
|
|
87
83
|
"build": "tsc --build .",
|
package/src/bigint.ts
CHANGED
|
@@ -38,6 +38,7 @@ export function max(x: bigint, y: bigint): bigint {
|
|
|
38
38
|
* @throws InvalidParameterError If the input value cannot be converted to a bigint.
|
|
39
39
|
*/
|
|
40
40
|
export function toBigInt(value: number | string | bigint): bigint {
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check -- The other types will throw an error
|
|
41
42
|
switch (typeof value) {
|
|
42
43
|
case "number":
|
|
43
44
|
if (!Number.isInteger(value)) {
|
package/src/error.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Abstract custom error class, which inherits from the built-in Error class,
|
|
3
|
-
* making sure that the standard
|
|
3
|
+
* making sure that the standard error properties are set, and the stack trace
|
|
4
4
|
* is not polluted with the custom error class' code.
|
|
5
5
|
*
|
|
6
6
|
* This class supports the `cause` property, which can be used to pass the
|
|
7
7
|
* original error that caused the custom error to be thrown. Note that it needs
|
|
8
8
|
* to be an instance of the built-in Error class, or a subclass of it. See `ensureError`
|
|
9
|
-
* for a
|
|
9
|
+
* for a convenient way of using it.
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* ```ts
|
|
@@ -78,6 +78,30 @@ export function ensureError<ErrorT extends Error>(
|
|
|
78
78
|
throw thrown;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Ensures that the provided value is a NodeJS.ErrnoException with a string 'code'.
|
|
83
|
+
* @param thrown The value to check.
|
|
84
|
+
* @throws The value if its not an error or if it doesn't have a code property.
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* try {
|
|
88
|
+
* await fs.promises.readFile("non-existing-file.txt");
|
|
89
|
+
* } catch (error) {
|
|
90
|
+
* ensureNodeErrnoExceptionError(error);
|
|
91
|
+
* console.error(error.code);
|
|
92
|
+
* }
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export function ensureNodeErrnoExceptionError(
|
|
96
|
+
thrown: unknown,
|
|
97
|
+
): asserts thrown is NodeJS.ErrnoException & Error & { code: string } {
|
|
98
|
+
ensureError(thrown);
|
|
99
|
+
|
|
100
|
+
if (!("code" in thrown) || typeof thrown.code !== "string") {
|
|
101
|
+
throw thrown;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
81
105
|
/**
|
|
82
106
|
* Throws an error for an unreachable code path. This function is typically
|
|
83
107
|
* used in a default case of a switch statement where all possible values of
|