hardhat 3.11.1 → 3.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -2
- package/dist/src/internal/builtin-plugins/artifacts/artifact-manager.js.map +1 -1
- package/dist/src/internal/builtin-plugins/artifacts/hook-handlers/hre.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/artifacts/hook-handlers/hre.js +2 -1
- package/dist/src/internal/builtin-plugins/artifacts/hook-handlers/hre.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/hre.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/hre.js +2 -1
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/hre.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/function-gas-snapshots.d.ts +3 -2
- package/dist/src/internal/builtin-plugins/gas-analytics/function-gas-snapshots.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/function-gas-snapshots.js +19 -10
- package/dist/src/internal/builtin-plugins/gas-analytics/function-gas-snapshots.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers/utils.d.ts +7 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers/utils.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers/utils.js +10 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers/utils.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/hre.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/hre.js +2 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/hre.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/index.js +12 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.d.ts +3 -2
- package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.js +30 -9
- package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.d.ts +19 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.js +36 -11
- package/dist/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.js.map +1 -1
- package/dist/src/internal/builtin-plugins/hhu/types.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/accounts/derive-private-keys.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-constants.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-constants.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/hre.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/network-connection.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/network-connection.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/network-manager.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/network-manager.js +9 -1
- package/dist/src/internal/builtin-plugins/network-manager/network-manager.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/local-accounts.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/local-accounts.js +10 -5
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/local-accounts.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/config.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-validation.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-validation.js +3 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-validation.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-results.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-results.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js +2 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job.js +2 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/types.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/config.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/config.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/type-extensions.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.d.ts +2 -1
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.js +5 -4
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/index.js +6 -0
- package/dist/src/internal/builtin-plugins/solidity-test/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/index.js +4 -2
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/parsing.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/parsing.js +2 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/parsing.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/validation.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/validation.js +2 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/validation.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/reporter.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/reporter.js +5 -3
- package/dist/src/internal/builtin-plugins/solidity-test/reporter.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/runner.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/runner.js +2 -1
- package/dist/src/internal/builtin-plugins/solidity-test/runner.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/task-action.d.ts +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/task-action.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/task-action.js +6 -3
- package/dist/src/internal/builtin-plugins/solidity-test/task-action.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/type-extensions.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/test/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/test/index.js +6 -0
- package/dist/src/internal/builtin-plugins/test/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/test/task-action.d.ts +1 -0
- package/dist/src/internal/builtin-plugins/test/task-action.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/test/task-action.js +7 -2
- package/dist/src/internal/builtin-plugins/test/task-action.js.map +1 -1
- package/dist/src/internal/cli/error-handling/error-handler.d.ts.map +1 -0
- package/dist/src/internal/cli/{error-handler.js → error-handling/error-handler.js} +14 -2
- package/dist/src/internal/cli/error-handling/error-handler.js.map +1 -0
- package/dist/src/internal/cli/error-handling/native-binding-error.d.ts +18 -0
- package/dist/src/internal/cli/error-handling/native-binding-error.d.ts.map +1 -0
- package/dist/src/internal/cli/error-handling/native-binding-error.js +57 -0
- package/dist/src/internal/cli/error-handling/native-binding-error.js.map +1 -0
- package/dist/src/internal/cli/hhu.js +1 -1
- package/dist/src/internal/cli/hhu.js.map +1 -1
- package/dist/src/internal/cli/init/template.d.ts.map +1 -1
- package/dist/src/internal/cli/init/template.js +15 -1
- package/dist/src/internal/cli/init/template.js.map +1 -1
- package/dist/src/internal/cli/main.d.ts.map +1 -1
- package/dist/src/internal/cli/main.js +3 -2
- package/dist/src/internal/cli/main.js.map +1 -1
- package/dist/src/internal/cli/telemetry/analytics/analytics.d.ts +1 -0
- package/dist/src/internal/cli/telemetry/analytics/analytics.d.ts.map +1 -1
- package/dist/src/internal/cli/telemetry/analytics/analytics.js +9 -0
- package/dist/src/internal/cli/telemetry/analytics/analytics.js.map +1 -1
- package/dist/src/internal/cli/telemetry/analytics/types.d.ts +5 -0
- package/dist/src/internal/cli/telemetry/analytics/types.d.ts.map +1 -1
- package/dist/src/internal/cli/telemetry/error-reporter/global-error-handlers.js.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/anonymizer.d.ts.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/anonymizer.js.map +1 -1
- package/dist/src/internal/constants.d.ts +10 -0
- package/dist/src/internal/constants.d.ts.map +1 -1
- package/dist/src/internal/constants.js +10 -0
- package/dist/src/internal/constants.js.map +1 -1
- package/dist/src/internal/core/config.d.ts +14 -1
- package/dist/src/internal/core/config.d.ts.map +1 -1
- package/dist/src/internal/core/config.js +15 -6
- package/dist/src/internal/core/config.js.map +1 -1
- package/dist/src/internal/core/configuration-variables.d.ts.map +1 -1
- package/dist/src/internal/core/configuration-variables.js +10 -1
- package/dist/src/internal/core/configuration-variables.js.map +1 -1
- package/dist/src/internal/core/hook-manager.d.ts.map +1 -1
- package/dist/src/internal/core/hook-manager.js.map +1 -1
- package/dist/src/internal/core/hre.d.ts.map +1 -1
- package/dist/src/internal/core/hre.js.map +1 -1
- package/dist/src/internal/core/lazy-user-interruptions.d.ts.map +1 -1
- package/dist/src/internal/core/lazy-user-interruptions.js +2 -1
- package/dist/src/internal/core/lazy-user-interruptions.js.map +1 -1
- package/dist/src/internal/core/tasks/builders.d.ts.map +1 -1
- package/dist/src/internal/core/tasks/builders.js.map +1 -1
- package/dist/src/internal/core/tasks/resolved-task.d.ts.map +1 -1
- package/dist/src/internal/core/tasks/resolved-task.js +2 -1
- package/dist/src/internal/core/tasks/resolved-task.js.map +1 -1
- package/dist/src/internal/core/tasks/task-manager.d.ts.map +1 -1
- package/dist/src/internal/core/tasks/task-manager.js +2 -1
- package/dist/src/internal/core/tasks/task-manager.js.map +1 -1
- package/dist/src/internal/core/tasks/validations.d.ts.map +1 -1
- package/dist/src/internal/core/tasks/validations.js +2 -1
- package/dist/src/internal/core/tasks/validations.js.map +1 -1
- package/dist/src/internal/core/user-interruptions.d.ts.map +1 -1
- package/dist/src/internal/core/user-interruptions.js.map +1 -1
- package/dist/src/internal/global-hre-instance.d.ts.map +1 -1
- package/dist/src/internal/global-hre-instance.js.map +1 -1
- package/dist/src/types/artifacts.d.ts.map +1 -1
- package/dist/src/types/config.d.ts +11 -0
- package/dist/src/types/config.d.ts.map +1 -1
- package/dist/src/types/solidity/build-system.d.ts.map +1 -1
- package/dist/src/types/solidity/build-system.js.map +1 -1
- package/dist/src/types/solidity/errors.d.ts.map +1 -1
- package/dist/src/types/solidity/errors.js.map +1 -1
- package/dist/src/types/tasks.d.ts.map +1 -1
- package/package.json +13 -13
- package/src/internal/builtin-plugins/artifacts/artifact-manager.ts +2 -2
- package/src/internal/builtin-plugins/artifacts/hook-handlers/hre.ts +3 -5
- package/src/internal/builtin-plugins/coverage/hook-handlers/hre.ts +3 -5
- package/src/internal/builtin-plugins/gas-analytics/function-gas-snapshots.ts +29 -7
- package/src/internal/builtin-plugins/gas-analytics/helpers/utils.ts +15 -0
- package/src/internal/builtin-plugins/gas-analytics/hook-handlers/hre.ts +3 -5
- package/src/internal/builtin-plugins/gas-analytics/index.ts +13 -0
- package/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.ts +41 -6
- package/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.ts +61 -11
- package/src/internal/builtin-plugins/hhu/types.ts +1 -2
- package/src/internal/builtin-plugins/network-manager/accounts/derive-private-keys.ts +4 -6
- package/src/internal/builtin-plugins/network-manager/edr/edr-constants.ts +1 -2
- package/src/internal/builtin-plugins/network-manager/edr/edr-provider.ts +2 -3
- package/src/internal/builtin-plugins/network-manager/hook-handlers/hre.ts +2 -3
- package/src/internal/builtin-plugins/network-manager/network-connection.ts +1 -2
- package/src/internal/builtin-plugins/network-manager/network-manager.ts +11 -1
- package/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/local-accounts.ts +10 -9
- package/src/internal/builtin-plugins/network-manager/type-extensions/config.ts +6 -14
- package/src/internal/builtin-plugins/network-manager/type-validation.ts +5 -1
- package/src/internal/builtin-plugins/solidity/build-results.ts +1 -2
- package/src/internal/builtin-plugins/solidity/build-system/build-system.ts +2 -1
- package/src/internal/builtin-plugins/solidity/build-system/compilation-job.ts +2 -1
- package/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.ts +1 -3
- package/src/internal/builtin-plugins/solidity/build-system/resolver/types.ts +1 -2
- package/src/internal/builtin-plugins/solidity/config.ts +2 -4
- package/src/internal/builtin-plugins/solidity/hook-handlers/hre.ts +1 -2
- package/src/internal/builtin-plugins/solidity/type-extensions.ts +16 -14
- package/src/internal/builtin-plugins/solidity-test/helpers.ts +11 -3
- package/src/internal/builtin-plugins/solidity-test/index.ts +6 -0
- package/src/internal/builtin-plugins/solidity-test/inline-config/index.ts +4 -2
- package/src/internal/builtin-plugins/solidity-test/inline-config/parsing.ts +2 -1
- package/src/internal/builtin-plugins/solidity-test/inline-config/validation.ts +2 -1
- package/src/internal/builtin-plugins/solidity-test/reporter.ts +6 -7
- package/src/internal/builtin-plugins/solidity-test/runner.ts +2 -1
- package/src/internal/builtin-plugins/solidity-test/task-action.ts +7 -3
- package/src/internal/builtin-plugins/solidity-test/type-extensions.ts +1 -2
- package/src/internal/builtin-plugins/test/index.ts +6 -0
- package/src/internal/builtin-plugins/test/task-action.ts +10 -2
- package/src/internal/cli/{error-handler.ts → error-handling/error-handler.ts} +21 -5
- package/src/internal/cli/error-handling/native-binding-error.ts +78 -0
- package/src/internal/cli/hhu.ts +1 -1
- package/src/internal/cli/init/template.ts +16 -1
- package/src/internal/cli/main.ts +6 -5
- package/src/internal/cli/telemetry/analytics/analytics.ts +13 -0
- package/src/internal/cli/telemetry/analytics/types.ts +6 -0
- package/src/internal/cli/telemetry/error-reporter/global-error-handlers.ts +2 -2
- package/src/internal/cli/telemetry/sentry/anonymizer.ts +2 -4
- package/src/internal/constants.ts +11 -0
- package/src/internal/core/config.ts +37 -3
- package/src/internal/core/configuration-variables.ts +12 -4
- package/src/internal/core/hook-manager.ts +2 -4
- package/src/internal/core/hre.ts +1 -3
- package/src/internal/core/lazy-user-interruptions.ts +3 -5
- package/src/internal/core/tasks/builders.ts +8 -17
- package/src/internal/core/tasks/resolved-task.ts +2 -1
- package/src/internal/core/tasks/task-manager.ts +2 -1
- package/src/internal/core/tasks/validations.ts +2 -1
- package/src/internal/core/user-interruptions.ts +1 -3
- package/src/internal/global-hre-instance.ts +1 -2
- package/src/types/artifacts.ts +1 -2
- package/src/types/config.ts +12 -0
- package/src/types/solidity/build-system.ts +8 -17
- package/src/types/solidity/errors.ts +3 -6
- package/src/types/tasks.ts +5 -11
- package/templates/01-node-test-runner-viem/package.json +1 -1
- package/templates/02-mocha-ethers/package.json +1 -1
- package/templates/03-minimal/package.json +1 -1
- package/dist/src/internal/cli/error-handler.d.ts.map +0 -1
- package/dist/src/internal/cli/error-handler.js.map +0 -1
- /package/dist/src/internal/cli/{error-handler.d.ts → error-handling/error-handler.d.ts} +0 -0
|
@@ -10,6 +10,7 @@ import { styleText } from "node:util";
|
|
|
10
10
|
import { bytesToHexString } from "@nomicfoundation/hardhat-utils/hex";
|
|
11
11
|
|
|
12
12
|
import { sendErrorTelemetry } from "../../cli/telemetry/error-reporter/reporter.js";
|
|
13
|
+
import { ALWAYS_COLLECT_STACK_TRACES_VERBOSITY } from "../../constants.js";
|
|
13
14
|
import { SolidityTestStackTraceGenerationError } from "../network-manager/edr/stack-traces/stack-trace-generation-errors.js";
|
|
14
15
|
import { encodeStackTraceEntry } from "../network-manager/edr/stack-traces/stack-trace-solidity-errors.js";
|
|
15
16
|
import { formatTraces } from "../network-manager/edr/utils/trace-formatters.js";
|
|
@@ -17,6 +18,8 @@ import { formatTraces } from "../network-manager/edr/utils/trace-formatters.js";
|
|
|
17
18
|
import { formatArtifactId } from "./formatters.js";
|
|
18
19
|
import { getMessageFromLastStackTraceEntry } from "./stack-trace-solidity-errors.js";
|
|
19
20
|
|
|
21
|
+
const RERUN_VERBOSITY_HINT = `Try rerunning your tests with -${"v".repeat(ALWAYS_COLLECT_STACK_TRACES_VERBOSITY)} or above.`;
|
|
22
|
+
|
|
20
23
|
class Indenter {
|
|
21
24
|
#indentation: number;
|
|
22
25
|
|
|
@@ -272,7 +275,7 @@ export async function* testReporter(
|
|
|
272
275
|
reason =
|
|
273
276
|
failure.reason?.startsWith("FFI is disabled") === true
|
|
274
277
|
? "FFI is disabled; set `test.solidity.ffi` to `true` in your Hardhat config to allow tests to call external commands"
|
|
275
|
-
: failure.reason ?? "Unknown error";
|
|
278
|
+
: (failure.reason ?? "Unknown error");
|
|
276
279
|
}
|
|
277
280
|
yield* output(indenter.t`${colorize("red", `Error: ${reason}`)}\n`);
|
|
278
281
|
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check -- Ignore Cases not matched: undefined
|
|
@@ -305,17 +308,13 @@ export async function* testReporter(
|
|
|
305
308
|
yield* output(
|
|
306
309
|
indenter.t`Stack Trace Warning: ${colorize("grey", "The test is not safe to replay because a fork url without a fork block number was provided.")}\n`,
|
|
307
310
|
);
|
|
308
|
-
yield* output(
|
|
309
|
-
indenter.t`Try rerunning your tests with -vvv or above.\n`,
|
|
310
|
-
);
|
|
311
|
+
yield* output(indenter.t`${RERUN_VERBOSITY_HINT}\n`);
|
|
311
312
|
}
|
|
312
313
|
if (stackTrace.impureCheatcodes.length > 0) {
|
|
313
314
|
yield* output(
|
|
314
315
|
indenter.t`Stack Trace Warning: ${colorize("grey", `The test is not safe to replay because it uses impure cheatcodes: ${stackTrace.impureCheatcodes.join(", ")}`)}\n`,
|
|
315
316
|
);
|
|
316
|
-
yield* output(
|
|
317
|
-
indenter.t`Try rerunning your tests with -vvv or above.\n`,
|
|
318
|
-
);
|
|
317
|
+
yield* output(indenter.t`${RERUN_VERBOSITY_HINT}\n`);
|
|
319
318
|
}
|
|
320
319
|
break;
|
|
321
320
|
case "HeuristicFailed":
|
|
@@ -102,7 +102,8 @@ export function run(
|
|
|
102
102
|
|
|
103
103
|
stream.destroy(
|
|
104
104
|
new HardhatError(
|
|
105
|
-
HardhatError.ERRORS.CORE.SOLIDITY_TESTS
|
|
105
|
+
HardhatError.ERRORS.CORE.SOLIDITY_TESTS
|
|
106
|
+
.UNHANDLED_EDR_ERROR_SOLIDITY_TESTS,
|
|
106
107
|
{
|
|
107
108
|
error: error.message,
|
|
108
109
|
},
|
|
@@ -50,6 +50,7 @@ interface TestActionArguments {
|
|
|
50
50
|
testFiles: string[];
|
|
51
51
|
chainType: string;
|
|
52
52
|
grep?: string;
|
|
53
|
+
grepExclude?: string;
|
|
53
54
|
noCompile: boolean;
|
|
54
55
|
testSummaryIndex: number;
|
|
55
56
|
}
|
|
@@ -59,7 +60,7 @@ export interface SolidityTestRunResult extends TestRunResult {
|
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
62
|
-
{ testFiles, chainType, grep, noCompile, testSummaryIndex },
|
|
63
|
+
{ testFiles, chainType, grep, grepExclude, noCompile, testSummaryIndex },
|
|
63
64
|
hre,
|
|
64
65
|
): Promise<Result<SolidityTestRunResult, SolidityTestRunResult>> => {
|
|
65
66
|
// Set an environment variable that plugins can use to detect when a process is running tests
|
|
@@ -163,7 +164,8 @@ const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
|
163
164
|
|
|
164
165
|
if (notCompiledFiles.length > 0) {
|
|
165
166
|
throw new HardhatError(
|
|
166
|
-
HardhatError.ERRORS.CORE.SOLIDITY_TESTS
|
|
167
|
+
HardhatError.ERRORS.CORE.SOLIDITY_TESTS
|
|
168
|
+
.SELECTED_TEST_FILES_NOT_COMPILED,
|
|
167
169
|
{
|
|
168
170
|
files: notCompiledFiles.map((f) => `- ${f}`).join("\n"),
|
|
169
171
|
},
|
|
@@ -251,6 +253,7 @@ const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
|
251
253
|
verbosity,
|
|
252
254
|
observability: observabilityConfig,
|
|
253
255
|
testPattern: grep,
|
|
256
|
+
excludeTestPattern: grepExclude,
|
|
254
257
|
generateGasReport:
|
|
255
258
|
hre.globalOptions.gasStats ||
|
|
256
259
|
hre.globalOptions.gasStatsJson !== undefined,
|
|
@@ -416,7 +419,8 @@ async function validateThatProvidedFilesAreTests(
|
|
|
416
419
|
|
|
417
420
|
if (nonTests.length > 0) {
|
|
418
421
|
throw new HardhatError(
|
|
419
|
-
HardhatError.ERRORS.CORE.SOLIDITY_TESTS
|
|
422
|
+
HardhatError.ERRORS.CORE.SOLIDITY_TESTS
|
|
423
|
+
.SELECTED_FILES_ARE_NOT_SOLIDITY_TESTS,
|
|
420
424
|
{
|
|
421
425
|
files: nonTests.map((f) => `- ${f}`).join("\n"),
|
|
422
426
|
},
|
|
@@ -85,8 +85,7 @@ declare module "../../../types/test.js" {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
export type SolidityTestUserConfig =
|
|
88
|
-
|
|
|
89
|
-
| SolidityTestProfilesUserConfig;
|
|
88
|
+
SolidityTestProfileUserConfig | SolidityTestProfilesUserConfig;
|
|
90
89
|
|
|
91
90
|
export interface HardhatTestUserConfig {
|
|
92
91
|
solidity?: SolidityTestUserConfig;
|
|
@@ -29,6 +29,12 @@ const hardhatPlugin: HardhatPlugin = definePlugin({
|
|
|
29
29
|
type: ArgumentType.STRING_WITHOUT_DEFAULT,
|
|
30
30
|
defaultValue: undefined,
|
|
31
31
|
})
|
|
32
|
+
.addOption({
|
|
33
|
+
name: "grepExclude",
|
|
34
|
+
description: "Skip tests matching the given string or regexp",
|
|
35
|
+
type: ArgumentType.STRING_WITHOUT_DEFAULT,
|
|
36
|
+
defaultValue: undefined,
|
|
37
|
+
})
|
|
32
38
|
.addFlag({
|
|
33
39
|
name: "noCompile",
|
|
34
40
|
description: "Do not compile the project before running the tests",
|
|
@@ -24,6 +24,7 @@ interface TestActionArguments {
|
|
|
24
24
|
testFiles: string[];
|
|
25
25
|
chainType: string;
|
|
26
26
|
grep: string | undefined;
|
|
27
|
+
grepExclude: string | undefined;
|
|
27
28
|
noCompile: boolean;
|
|
28
29
|
}
|
|
29
30
|
|
|
@@ -51,7 +52,7 @@ function isTestRunResult(
|
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
const runAllTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
54
|
-
{ testFiles, chainType, grep, noCompile, ...otherArgs },
|
|
55
|
+
{ testFiles, chainType, grep, grepExclude, noCompile, ...otherArgs },
|
|
55
56
|
hre,
|
|
56
57
|
): Promise<Result<void, void>> => {
|
|
57
58
|
// If this code is executed, it means the user has not specified a test runner.
|
|
@@ -98,10 +99,17 @@ const runAllTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
|
98
99
|
|
|
99
100
|
const args: TaskArguments = {
|
|
100
101
|
testFiles: files,
|
|
101
|
-
grep,
|
|
102
102
|
noCompile: subtask.options.has("noCompile"),
|
|
103
103
|
};
|
|
104
104
|
|
|
105
|
+
if (subtask.options.has("grep")) {
|
|
106
|
+
args.grep = grep;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (subtask.options.has("grepExclude")) {
|
|
110
|
+
args.grepExclude = grepExclude;
|
|
111
|
+
}
|
|
112
|
+
|
|
105
113
|
if (subtask.options.has("chainType")) {
|
|
106
114
|
args.chainType = chainType;
|
|
107
115
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type * as ClassifierT from "
|
|
1
|
+
import type * as ClassifierT from "../telemetry/error-classification/classifier.js";
|
|
2
2
|
|
|
3
3
|
import { styleText } from "node:util";
|
|
4
4
|
|
|
@@ -7,7 +7,9 @@ import {
|
|
|
7
7
|
HardhatPluginError,
|
|
8
8
|
} from "@nomicfoundation/hardhat-errors";
|
|
9
9
|
|
|
10
|
-
import { HARDHAT_NAME, HARDHAT_WEBSITE_URL } from "
|
|
10
|
+
import { HARDHAT_NAME, HARDHAT_WEBSITE_URL } from "../../constants.js";
|
|
11
|
+
|
|
12
|
+
import { detectNativeBindingFailure } from "./native-binding-error.js";
|
|
11
13
|
|
|
12
14
|
// The classifier may import many unrelated things top-level to do its job, so
|
|
13
15
|
// we load it lazily.
|
|
@@ -165,10 +167,24 @@ async function getErrorWithCategory(error: Error): Promise<ErrorWithCategory> {
|
|
|
165
167
|
};
|
|
166
168
|
}
|
|
167
169
|
|
|
170
|
+
const nativeBindingFailure = detectNativeBindingFailure(error);
|
|
171
|
+
if (nativeBindingFailure !== undefined) {
|
|
172
|
+
return {
|
|
173
|
+
category: ErrorCategory.HARDHAT,
|
|
174
|
+
categorizedError: new HardhatError(
|
|
175
|
+
HardhatError.ERRORS.CORE.GENERAL.NATIVE_BINDING_LOAD_FAILED,
|
|
176
|
+
{
|
|
177
|
+
parentPackage: nativeBindingFailure.parentPackage,
|
|
178
|
+
missingPackage: nativeBindingFailure.missingPackage,
|
|
179
|
+
},
|
|
180
|
+
error,
|
|
181
|
+
),
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
|
|
168
185
|
if (classifierModule === undefined) {
|
|
169
|
-
classifierModule =
|
|
170
|
-
"
|
|
171
|
-
);
|
|
186
|
+
classifierModule =
|
|
187
|
+
await import("../telemetry/error-classification/classifier.js");
|
|
172
188
|
}
|
|
173
189
|
|
|
174
190
|
// Pass `ignoreDevelopmentTimeFilter=true` so the migration footer also shows
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The platform triple that napi-rs appends to the platform package name, e.g.
|
|
3
|
+
* `@nomicfoundation/edr-linux-x64-gnu`, `@scope/pkg-darwin-arm64`.
|
|
4
|
+
*/
|
|
5
|
+
const PLATFORM_SUFFIX_REGEX =
|
|
6
|
+
/-(?:android|darwin|freebsd|linux|win32)-(?:arm|arm64|ia32|x64|riscv64|ppc64|s390x)(?:-(?:gnu|musl|msvc|eabi|gnueabihf))?$/;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Matches both the CJS (`Cannot find module 'x'`) and ESM
|
|
10
|
+
* (`Cannot find package 'x' imported from y`) forms.
|
|
11
|
+
*/
|
|
12
|
+
const MISSING_MODULE_REGEX = /Cannot find (?:module|package) '([^']+)'/g;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The packages Hardhat itself ships a native binding for.
|
|
16
|
+
*/
|
|
17
|
+
const HARDHAT_NATIVE_BINDING_PACKAGES = [
|
|
18
|
+
"@nomicfoundation/edr",
|
|
19
|
+
"@nomicfoundation/solidity-analyzer",
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
export interface NativeBindingFailure {
|
|
23
|
+
/** The package whose loader failed, e.g. `@nomicfoundation/edr`. */
|
|
24
|
+
parentPackage: string;
|
|
25
|
+
/** The platform package that couldn't be found. */
|
|
26
|
+
missingPackage: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Detect whether a given error is a napi-rs native binding load failure.
|
|
31
|
+
*
|
|
32
|
+
* Packages like `@nomicfoundation/edr` and `@nomicfoundation/solidity-analyzer`
|
|
33
|
+
* ship one prebuilt binary per platform in a separate package, and their
|
|
34
|
+
* generated loader `require`s the one matching the current platform. When that
|
|
35
|
+
* package is missing from the installation the loader throws at import time, so
|
|
36
|
+
* the failure surfaces as an opaque `MODULE_NOT_FOUND` from deep inside
|
|
37
|
+
* `node_modules`.
|
|
38
|
+
*/
|
|
39
|
+
export function detectNativeBindingFailure(
|
|
40
|
+
error: Error,
|
|
41
|
+
): NativeBindingFailure | undefined {
|
|
42
|
+
const chain = errorChain(error);
|
|
43
|
+
|
|
44
|
+
// Some link in the chain names the missing platform package.
|
|
45
|
+
for (const chainedError of chain) {
|
|
46
|
+
for (const match of chainedError.message.matchAll(MISSING_MODULE_REGEX)) {
|
|
47
|
+
const moduleName = match[1];
|
|
48
|
+
|
|
49
|
+
if (!PLATFORM_SUFFIX_REGEX.test(moduleName)) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const parentPackage = moduleName.replace(PLATFORM_SUFFIX_REGEX, "");
|
|
54
|
+
|
|
55
|
+
if (!HARDHAT_NATIVE_BINDING_PACKAGES.includes(parentPackage)) {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return { missingPackage: moduleName, parentPackage };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function errorChain(error: Error): Error[] {
|
|
67
|
+
const chain: Error[] = [];
|
|
68
|
+
const seen = new Set<unknown>();
|
|
69
|
+
let current: unknown = error;
|
|
70
|
+
|
|
71
|
+
while (current instanceof Error && !seen.has(current)) {
|
|
72
|
+
seen.add(current);
|
|
73
|
+
chain.push(current);
|
|
74
|
+
current = current.cause;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return chain;
|
|
78
|
+
}
|
package/src/internal/cli/hhu.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { globalFlag } from "../core/config.js";
|
|
|
19
19
|
import { TaskManagerImplementation } from "../core/tasks/task-manager.js";
|
|
20
20
|
import { getHardhatVersion } from "../utils/package.js";
|
|
21
21
|
|
|
22
|
-
import { printErrorMessages } from "./error-handler.js";
|
|
22
|
+
import { printErrorMessages } from "./error-handling/error-handler.js";
|
|
23
23
|
import { getGlobalHelpString } from "./help/get-global-help-string.js";
|
|
24
24
|
import { getHelpString } from "./help/get-help-string.js";
|
|
25
25
|
import {
|
|
@@ -13,6 +13,21 @@ import {
|
|
|
13
13
|
type PackageJson,
|
|
14
14
|
} from "@nomicfoundation/hardhat-utils/package";
|
|
15
15
|
|
|
16
|
+
// Directories that may exist inside a template dir (build/tooling output,
|
|
17
|
+
// dependencies) but are never part of the template itself. They are all
|
|
18
|
+
// gitignored in the templates, but `getAllFilesMatching` does not honor
|
|
19
|
+
// .gitignore, so we must exclude them explicitly.
|
|
20
|
+
const IGNORED_TEMPLATE_DIRS = new Set([
|
|
21
|
+
"node_modules",
|
|
22
|
+
"artifacts",
|
|
23
|
+
"cache",
|
|
24
|
+
"types",
|
|
25
|
+
"dist",
|
|
26
|
+
"bundle",
|
|
27
|
+
"coverage",
|
|
28
|
+
"snapshots",
|
|
29
|
+
]);
|
|
30
|
+
|
|
16
31
|
/**
|
|
17
32
|
* This type describes a hardhat project template. It consists of:
|
|
18
33
|
* - name: The name of the template;
|
|
@@ -75,7 +90,7 @@ export async function getTemplates(): Promise<Template[]> {
|
|
|
75
90
|
}
|
|
76
91
|
return true;
|
|
77
92
|
},
|
|
78
|
-
(dir) => path.basename(dir)
|
|
93
|
+
(dir) => !IGNORED_TEMPLATE_DIRS.has(path.basename(dir)),
|
|
79
94
|
);
|
|
80
95
|
|
|
81
96
|
const files = matchingFiles.map((f) => path.relative(pathToTemplate, f));
|
package/src/internal/cli/main.ts
CHANGED
|
@@ -28,7 +28,7 @@ import { warnAboutUnusedLoadedPlugins } from "../core/plugins/unused-plugins-war
|
|
|
28
28
|
import { setGlobalHardhatRuntimeEnvironment } from "../global-hre-instance.js";
|
|
29
29
|
import { createHardhatRuntimeEnvironment } from "../hre-initialization.js";
|
|
30
30
|
|
|
31
|
-
import { printErrorMessages } from "./error-handler.js";
|
|
31
|
+
import { printErrorMessages } from "./error-handling/error-handler.js";
|
|
32
32
|
import { getGlobalHelpString } from "./help/get-global-help-string.js";
|
|
33
33
|
import { getHelpString } from "./help/get-help-string.js";
|
|
34
34
|
import {
|
|
@@ -123,7 +123,8 @@ export async function main(
|
|
|
123
123
|
|
|
124
124
|
if (listTemplates) {
|
|
125
125
|
throw new HardhatError(
|
|
126
|
-
HardhatError.ERRORS.CORE.ARGUMENTS
|
|
126
|
+
HardhatError.ERRORS.CORE.ARGUMENTS
|
|
127
|
+
.CANNOT_COMBINE_TEMPLATE_AND_TEMPLATES,
|
|
127
128
|
);
|
|
128
129
|
}
|
|
129
130
|
|
|
@@ -306,9 +307,9 @@ export async function main(
|
|
|
306
307
|
|
|
307
308
|
const deprecatedConnectWasCalled = Boolean(
|
|
308
309
|
"wasConnectCalled" in hre.network &&
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
310
|
+
hre.network.wasConnectCalled !== undefined &&
|
|
311
|
+
typeof hre.network.wasConnectCalled === "function" &&
|
|
312
|
+
hre.network.wasConnectCalled(),
|
|
312
313
|
);
|
|
313
314
|
|
|
314
315
|
if (deprecatedConnectWasCalled) {
|
|
@@ -81,6 +81,19 @@ export async function sendProjectTypeAnalytics(
|
|
|
81
81
|
return await sendAnalytics(initAnalyticsEvent);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
export async function sendNetworkAnalytics(
|
|
85
|
+
chainType: string,
|
|
86
|
+
): Promise<boolean> {
|
|
87
|
+
const networkAnalyticsEvent: AnalyticsEvent = {
|
|
88
|
+
name: "network",
|
|
89
|
+
params: {
|
|
90
|
+
chainType,
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
return await sendAnalytics(networkAnalyticsEvent);
|
|
95
|
+
}
|
|
96
|
+
|
|
84
97
|
// Return a boolean for testing purposes to confirm whether analytics were sent based on the consent value and not in CI environments
|
|
85
98
|
async function sendAnalytics(analyticsEvent: AnalyticsEvent): Promise<boolean> {
|
|
86
99
|
if (!(await isTelemetryAllowed())) {
|
|
@@ -22,8 +22,8 @@ function createUnhandledErrorListener(isPromiseRejection: boolean) {
|
|
|
22
22
|
? error
|
|
23
23
|
: new Error(
|
|
24
24
|
isObject(error) &&
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
"message" in error &&
|
|
26
|
+
typeof error.message === "string"
|
|
27
27
|
? error.message
|
|
28
28
|
: "Unknown error",
|
|
29
29
|
{ cause: error },
|
|
@@ -30,12 +30,10 @@ interface WordMatch {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export type AnonymizeEnvelopeResult =
|
|
33
|
-
|
|
34
|
-
| { success: false; error: string };
|
|
33
|
+
{ success: true; envelope: Envelope } | { success: false; error: string };
|
|
35
34
|
|
|
36
35
|
export type AnonymizeEventResult =
|
|
37
|
-
|
|
38
|
-
| { success: false; error: string };
|
|
36
|
+
{ success: true; event: Event } | { success: false; error: string };
|
|
39
37
|
|
|
40
38
|
const ANONYMIZED_MNEMONIC = "<mnemonic>";
|
|
41
39
|
const MNEMONIC_PHRASE_LENGTH_THRESHOLD = 7;
|
|
@@ -11,3 +11,14 @@ export const OPTIMISM_CHAIN_TYPE = "op";
|
|
|
11
11
|
export const DEFAULT_NETWORK_NAME = "default";
|
|
12
12
|
|
|
13
13
|
export const DEFAULT_VERBOSITY = 2;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The verbosity level (`-vvvvv`) at and above which stack traces are always
|
|
17
|
+
* collected. Below it, stack traces are produced by re-running the failing
|
|
18
|
+
* test with tracing enabled — much cheaper, but tests with non-deterministic
|
|
19
|
+
* side effects (impure cheatcodes, a fork pinned to `latest`) can't be
|
|
20
|
+
* replayed and report an `UnsafeToReplay` warning instead. Always-on
|
|
21
|
+
* collection records step traces for every test, which balloons memory on
|
|
22
|
+
* large suites, so it's reserved for the highest verbosity.
|
|
23
|
+
*/
|
|
24
|
+
export const ALWAYS_COLLECT_STACK_TRACES_VERBOSITY = 5;
|
|
@@ -23,18 +23,52 @@ import {
|
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Creates a configuration variable, which will be fetched at runtime.
|
|
26
|
+
*
|
|
27
|
+
* The second argument is an options object with an optional `format` (a
|
|
28
|
+
* template that must include the `{variable}` marker) and an optional
|
|
29
|
+
* `default` value. The default is used as a fallback when the variable can't
|
|
30
|
+
* be resolved from any other source (see {@link ConfigurationVariable.default}).
|
|
26
31
|
*/
|
|
27
32
|
export function configVariable(
|
|
28
33
|
name: string,
|
|
29
|
-
format
|
|
34
|
+
options?: { format?: string; default?: string },
|
|
35
|
+
): ConfigurationVariable;
|
|
36
|
+
/**
|
|
37
|
+
* @deprecated Passing the `format` as a string is deprecated. Pass an options
|
|
38
|
+
* object instead: `configVariable(name, { format })`.
|
|
39
|
+
*/
|
|
40
|
+
export function configVariable(
|
|
41
|
+
name: string,
|
|
42
|
+
format: string,
|
|
43
|
+
): ConfigurationVariable;
|
|
44
|
+
export function configVariable(
|
|
45
|
+
name: string,
|
|
46
|
+
formatOrOptions: string | { format?: string; default?: string } = {},
|
|
30
47
|
): ConfigurationVariable {
|
|
48
|
+
const { format = CONFIGURATION_VARIABLE_MARKER, default: defaultValue } =
|
|
49
|
+
typeof formatOrOptions === "string"
|
|
50
|
+
? { format: formatOrOptions }
|
|
51
|
+
: formatOrOptions;
|
|
52
|
+
|
|
31
53
|
if (!format.includes(CONFIGURATION_VARIABLE_MARKER)) {
|
|
32
54
|
throw new HardhatError(
|
|
33
|
-
HardhatError.ERRORS.CORE.GENERAL
|
|
55
|
+
HardhatError.ERRORS.CORE.GENERAL
|
|
56
|
+
.CONFIG_VARIABLE_FORMAT_MUST_INCLUDE_VARIABLE,
|
|
34
57
|
{ format, marker: CONFIGURATION_VARIABLE_MARKER },
|
|
35
58
|
);
|
|
36
59
|
}
|
|
37
|
-
|
|
60
|
+
|
|
61
|
+
const configurationVariable: ConfigurationVariable = {
|
|
62
|
+
_type: "ConfigurationVariable",
|
|
63
|
+
name,
|
|
64
|
+
format,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
if (defaultValue !== undefined) {
|
|
68
|
+
configurationVariable.default = defaultValue;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return configurationVariable;
|
|
38
72
|
}
|
|
39
73
|
|
|
40
74
|
/**
|
|
@@ -24,9 +24,7 @@ export function resolveConfigurationVariable(
|
|
|
24
24
|
return new LazyResolvedConfigurationVariable(hooks, variable);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
abstract class BaseResolvedConfigurationVariable
|
|
28
|
-
implements ResolvedConfigurationVariable
|
|
29
|
-
{
|
|
27
|
+
abstract class BaseResolvedConfigurationVariable implements ResolvedConfigurationVariable {
|
|
30
28
|
public _type: "ResolvedConfigurationVariable" =
|
|
31
29
|
"ResolvedConfigurationVariable";
|
|
32
30
|
|
|
@@ -115,6 +113,14 @@ export class LazyResolvedConfigurationVariable extends BaseResolvedConfiguration
|
|
|
115
113
|
}
|
|
116
114
|
|
|
117
115
|
protected async _getRawValue(): Promise<string> {
|
|
116
|
+
// Env vars take precedence over every configurationVariables plugin hook
|
|
117
|
+
// (e.g. keystore). Skip the hook chain entirely when the env var is set so
|
|
118
|
+
// plugins are not consulted and cannot override the env value.
|
|
119
|
+
const envValue = process.env[this.#variable.name];
|
|
120
|
+
if (typeof envValue === "string") {
|
|
121
|
+
return envValue;
|
|
122
|
+
}
|
|
123
|
+
|
|
118
124
|
const mutex = LazyResolvedConfigurationVariable.#mutexes.get(this.#hooks);
|
|
119
125
|
assertHardhatInvariant(mutex !== undefined, "Mutex must be defined");
|
|
120
126
|
|
|
@@ -125,7 +131,9 @@ export class LazyResolvedConfigurationVariable extends BaseResolvedConfiguration
|
|
|
125
131
|
"fetchValue",
|
|
126
132
|
[this.#variable],
|
|
127
133
|
async (_context, v) => {
|
|
128
|
-
|
|
134
|
+
// Fall back to the default only when the env var is unset. An empty
|
|
135
|
+
// string still takes precedence
|
|
136
|
+
const value = process.env[v.name] ?? v.default;
|
|
129
137
|
|
|
130
138
|
if (typeof value !== "string") {
|
|
131
139
|
throw new HardhatError(
|
|
@@ -386,8 +386,7 @@ export class HookManagerImplementation implements HookManager {
|
|
|
386
386
|
hookCategoryName: HookCategoryNameT,
|
|
387
387
|
): Promise<Array<Partial<HardhatHooks[HookCategoryNameT]>>> {
|
|
388
388
|
const cached = this.#resolvedStaticCategories.get(hookCategoryName) as
|
|
389
|
-
|
|
390
|
-
| undefined;
|
|
389
|
+
Array<Partial<HardhatHooks[HookCategoryNameT]>> | undefined;
|
|
391
390
|
|
|
392
391
|
if (cached !== undefined) {
|
|
393
392
|
return cached;
|
|
@@ -405,8 +404,7 @@ export class HookManagerImplementation implements HookManager {
|
|
|
405
404
|
return await this.#mutex.exclusiveRun(async () => {
|
|
406
405
|
// Re-check under the mutex in case another caller just populated it.
|
|
407
406
|
const recheck = this.#resolvedStaticCategories.get(hookCategoryName) as
|
|
408
|
-
|
|
409
|
-
| undefined;
|
|
407
|
+
Array<Partial<HardhatHooks[HookCategoryNameT]>> | undefined;
|
|
410
408
|
|
|
411
409
|
if (recheck !== undefined) {
|
|
412
410
|
return recheck;
|
package/src/internal/core/hre.ts
CHANGED
|
@@ -44,9 +44,7 @@ import { LazyUserInterruptionManager } from "./lazy-user-interruptions.js";
|
|
|
44
44
|
import { resolvePluginList } from "./plugins/resolve-plugin-list.js";
|
|
45
45
|
import { TaskManagerImplementation } from "./tasks/task-manager.js";
|
|
46
46
|
|
|
47
|
-
export class HardhatRuntimeEnvironmentImplementation
|
|
48
|
-
implements HardhatRuntimeEnvironment
|
|
49
|
-
{
|
|
47
|
+
export class HardhatRuntimeEnvironmentImplementation implements HardhatRuntimeEnvironment {
|
|
50
48
|
// NOTE: This is a small architectural violation, as these shouldn't be needed
|
|
51
49
|
// here, because they are added by plugins. But as those plugins are builtin,
|
|
52
50
|
// their type extensions also affect this module.
|
|
@@ -3,8 +3,7 @@ import type { HookManager } from "../../types/hooks.js";
|
|
|
3
3
|
import type { UserInterruptionManager } from "../../types/user-interruptions.js";
|
|
4
4
|
|
|
5
5
|
let UserInterruptionManagerImplementation:
|
|
6
|
-
|
|
7
|
-
| undefined;
|
|
6
|
+
typeof UserInterruptionManagerImplementationT | undefined;
|
|
8
7
|
|
|
9
8
|
export class LazyUserInterruptionManager implements UserInterruptionManager {
|
|
10
9
|
readonly #hooks: HookManager;
|
|
@@ -59,9 +58,8 @@ export class LazyUserInterruptionManager implements UserInterruptionManager {
|
|
|
59
58
|
// impl, so callers end up holding different impl instances and state,
|
|
60
59
|
// which can cause concurrency issues.
|
|
61
60
|
if (UserInterruptionManagerImplementation === undefined) {
|
|
62
|
-
({ UserInterruptionManagerImplementation } =
|
|
63
|
-
"./user-interruptions.js"
|
|
64
|
-
));
|
|
61
|
+
({ UserInterruptionManagerImplementation } =
|
|
62
|
+
await import("./user-interruptions.js"));
|
|
65
63
|
}
|
|
66
64
|
|
|
67
65
|
if (this.#userInterruptionManager === undefined) {
|
|
@@ -31,9 +31,7 @@ import {
|
|
|
31
31
|
validatePositionalArgument,
|
|
32
32
|
} from "./validations.js";
|
|
33
33
|
|
|
34
|
-
export class EmptyTaskDefinitionBuilderImplementation
|
|
35
|
-
implements EmptyTaskDefinitionBuilder
|
|
36
|
-
{
|
|
34
|
+
export class EmptyTaskDefinitionBuilderImplementation implements EmptyTaskDefinitionBuilder {
|
|
37
35
|
readonly #id: string[];
|
|
38
36
|
|
|
39
37
|
readonly #description: string;
|
|
@@ -56,12 +54,9 @@ export class EmptyTaskDefinitionBuilderImplementation
|
|
|
56
54
|
|
|
57
55
|
export class NewTaskDefinitionBuilderImplementation<
|
|
58
56
|
TaskArgumentsT extends TaskArguments = TaskArguments,
|
|
59
|
-
ActionTypeT extends
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
| "MISSING_ACTION" = "MISSING_ACTION",
|
|
63
|
-
> implements NewTaskDefinitionBuilder<TaskArgumentsT, ActionTypeT>
|
|
64
|
-
{
|
|
57
|
+
ActionTypeT extends "LAZY_ACTION" | "INLINE_ACTION" | "MISSING_ACTION" =
|
|
58
|
+
"MISSING_ACTION",
|
|
59
|
+
> implements NewTaskDefinitionBuilder<TaskArgumentsT, ActionTypeT> {
|
|
65
60
|
readonly #id: string[];
|
|
66
61
|
readonly #usedNames: Set<string> = new Set();
|
|
67
62
|
|
|
@@ -280,8 +275,7 @@ export class NewTaskDefinitionBuilderImplementation<
|
|
|
280
275
|
description?: string;
|
|
281
276
|
type?: TypeT;
|
|
282
277
|
defaultValue?:
|
|
283
|
-
| ArgumentTypeToValueType<TypeT
|
|
284
|
-
| Array<ArgumentTypeToValueType<TypeT>>;
|
|
278
|
+
ArgumentTypeToValueType<TypeT> | Array<ArgumentTypeToValueType<TypeT>>;
|
|
285
279
|
isVariadic: boolean;
|
|
286
280
|
}): NewTaskDefinitionBuilder<
|
|
287
281
|
ExtendTaskArguments<NameT, TypeT, TaskArgumentsT>,
|
|
@@ -330,12 +324,9 @@ export class NewTaskDefinitionBuilderImplementation<
|
|
|
330
324
|
|
|
331
325
|
export class TaskOverrideDefinitionBuilderImplementation<
|
|
332
326
|
TaskArgumentsT extends TaskArguments = TaskArguments,
|
|
333
|
-
ActionTypeT extends
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
| "MISSING_ACTION" = "MISSING_ACTION",
|
|
337
|
-
> implements TaskOverrideDefinitionBuilder<TaskArgumentsT, ActionTypeT>
|
|
338
|
-
{
|
|
327
|
+
ActionTypeT extends "LAZY_ACTION" | "INLINE_ACTION" | "MISSING_ACTION" =
|
|
328
|
+
"MISSING_ACTION",
|
|
329
|
+
> implements TaskOverrideDefinitionBuilder<TaskArgumentsT, ActionTypeT> {
|
|
339
330
|
readonly #id: string[];
|
|
340
331
|
|
|
341
332
|
readonly #options: Record<string, OptionDefinition> = {};
|
|
@@ -208,7 +208,8 @@ export class ResolvedTask implements Task {
|
|
|
208
208
|
value === undefined
|
|
209
209
|
) {
|
|
210
210
|
throw new HardhatError(
|
|
211
|
-
HardhatError.ERRORS.CORE.TASK_DEFINITIONS
|
|
211
|
+
HardhatError.ERRORS.CORE.TASK_DEFINITIONS
|
|
212
|
+
.MISSING_VALUE_FOR_TASK_ARGUMENT,
|
|
212
213
|
{
|
|
213
214
|
argument: argument.name,
|
|
214
215
|
task: formatTaskId(this.id),
|
|
@@ -265,7 +265,8 @@ export class TaskManagerImplementation implements TaskManager {
|
|
|
265
265
|
task.positionalArguments.some((p) => p.name === optionName);
|
|
266
266
|
if (hasArgument) {
|
|
267
267
|
throw new HardhatError(
|
|
268
|
-
HardhatError.ERRORS.CORE.TASK_DEFINITIONS
|
|
268
|
+
HardhatError.ERRORS.CORE.TASK_DEFINITIONS
|
|
269
|
+
.TASK_OVERRIDE_OPTION_ALREADY_DEFINED,
|
|
269
270
|
{
|
|
270
271
|
actorFragment: getActorFragment(pluginId),
|
|
271
272
|
option: optionName,
|