hardhat 3.4.3 → 3.4.5
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 +25 -0
- package/dist/src/config.d.ts +1 -1
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +0 -3
- package/dist/src/config.js.map +1 -1
- package/dist/src/hre.d.ts +1 -1
- package/dist/src/hre.d.ts.map +1 -1
- package/dist/src/hre.js +0 -3
- package/dist/src/hre.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +0 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/artifacts/index.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/artifacts/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/artifacts/index.js +0 -1
- package/dist/src/internal/builtin-plugins/artifacts/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/clean/index.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/clean/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/clean/index.js +0 -1
- package/dist/src/internal/builtin-plugins/clean/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/clean/type-extensions.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/clean/type-extensions.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/clean/type-extensions.js +1 -1
- package/dist/src/internal/builtin-plugins/clean/type-extensions.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/coverage-manager.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/coverage/coverage-manager.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/coverage-manager.js +9 -9
- package/dist/src/internal/builtin-plugins/coverage/coverage-manager.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/solidity.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/solidity.js +7 -10
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/solidity.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/index.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/coverage/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/index.js +0 -1
- package/dist/src/internal/builtin-plugins/coverage/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/instrumentation.d.ts +1 -4
- package/dist/src/internal/builtin-plugins/coverage/instrumentation.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/instrumentation.js +2 -4
- package/dist/src/internal/builtin-plugins/coverage/instrumentation.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/type-extensions.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/coverage/type-extensions.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/type-extensions.js +1 -1
- package/dist/src/internal/builtin-plugins/coverage/type-extensions.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/index.d.ts +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 +0 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/type-extensions.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/type-extensions.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/type-extensions.js +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/type-extensions.js.map +1 -1
- package/dist/src/internal/builtin-plugins/index.d.ts +8 -8
- package/dist/src/internal/builtin-plugins/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-solidity-errors.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-solidity-errors.js +7 -6
- package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-solidity-errors.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/index.d.ts +4 -4
- package/dist/src/internal/builtin-plugins/network-manager/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/index.js +0 -4
- package/dist/src/internal/builtin-plugins/network-manager/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/config.d.ts +0 -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-extensions/config.js +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/config.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/global-options.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/global-options.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/global-options.js +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/global-options.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/hooks.d.ts +0 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/hooks.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/hooks.js +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/hooks.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/hre.d.ts +0 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/hre.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/hre.js +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/hre.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 +22 -9
- package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.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 +6 -0
- 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/index.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/solidity/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/index.js +0 -1
- package/dist/src/internal/builtin-plugins/solidity/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/type-extensions.d.ts +0 -4
- package/dist/src/internal/builtin-plugins/solidity/type-extensions.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/type-extensions.js +1 -4
- package/dist/src/internal/builtin-plugins/solidity/type-extensions.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/index.d.ts +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 +0 -1
- package/dist/src/internal/builtin-plugins/solidity-test/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/constants.d.ts +4 -2
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/constants.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/constants.js +5 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/constants.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/helpers.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/helpers.js +15 -3
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/helpers.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/validation.d.ts +3 -2
- 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 +18 -4
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/validation.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/type-extensions.d.ts +0 -1
- package/dist/src/internal/builtin-plugins/solidity-test/type-extensions.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/type-extensions.js +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/type-extensions.js.map +1 -1
- package/dist/src/internal/builtin-plugins/test/index.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/test/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/test/index.js +0 -1
- package/dist/src/internal/builtin-plugins/test/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/test/type-extensions.d.ts +0 -1
- package/dist/src/internal/builtin-plugins/test/type-extensions.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/test/type-extensions.js +1 -1
- package/dist/src/internal/builtin-plugins/test/type-extensions.js.map +1 -1
- package/dist/src/internal/cli/telemetry/error-classification/classifier.d.ts +58 -0
- package/dist/src/internal/cli/telemetry/error-classification/classifier.d.ts.map +1 -0
- package/dist/src/internal/cli/telemetry/error-classification/classifier.js +402 -0
- package/dist/src/internal/cli/telemetry/error-classification/classifier.js.map +1 -0
- package/dist/src/internal/cli/telemetry/error-classification/codebase-dependent-helpers.d.ts +67 -0
- package/dist/src/internal/cli/telemetry/error-classification/codebase-dependent-helpers.d.ts.map +1 -0
- package/dist/src/internal/cli/telemetry/error-classification/codebase-dependent-helpers.js +140 -0
- package/dist/src/internal/cli/telemetry/error-classification/codebase-dependent-helpers.js.map +1 -0
- package/dist/src/internal/cli/telemetry/error-classification/filter.d.ts +15 -0
- package/dist/src/internal/cli/telemetry/error-classification/filter.d.ts.map +1 -0
- package/dist/src/internal/cli/telemetry/error-classification/filter.js +114 -0
- package/dist/src/internal/cli/telemetry/error-classification/filter.js.map +1 -0
- package/dist/src/internal/cli/telemetry/error-classification/helpers.d.ts +52 -0
- package/dist/src/internal/cli/telemetry/error-classification/helpers.d.ts.map +1 -0
- package/dist/src/internal/cli/telemetry/error-classification/helpers.js +163 -0
- package/dist/src/internal/cli/telemetry/error-classification/helpers.js.map +1 -0
- package/dist/src/internal/cli/telemetry/error-reporter/reporter.d.ts.map +1 -1
- package/dist/src/internal/cli/telemetry/error-reporter/reporter.js +14 -0
- package/dist/src/internal/cli/telemetry/error-reporter/reporter.js.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/anonymizer.d.ts +0 -2
- package/dist/src/internal/cli/telemetry/sentry/anonymizer.d.ts.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/anonymizer.js +0 -117
- package/dist/src/internal/cli/telemetry/sentry/anonymizer.js.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/init.d.ts.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/init.js +14 -9
- package/dist/src/internal/cli/telemetry/sentry/init.js.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/reporter.d.ts.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/reporter.js +1 -27
- package/dist/src/internal/cli/telemetry/sentry/reporter.js.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/subprocess.js +11 -17
- package/dist/src/internal/cli/telemetry/sentry/subprocess.js.map +1 -1
- package/dist/src/types/config.d.ts +0 -1
- package/dist/src/types/config.d.ts.map +1 -1
- package/dist/src/types/config.js +1 -3
- package/dist/src/types/config.js.map +1 -1
- package/dist/src/types/plugins.d.ts +1 -1
- package/dist/src/types/plugins.d.ts.map +1 -1
- package/dist/src/types/plugins.js +1 -3
- package/dist/src/types/plugins.js.map +1 -1
- package/package.json +3 -4
- package/src/config.ts +2 -3
- package/src/hre.ts +2 -3
- package/src/index.ts +2 -3
- package/src/internal/builtin-plugins/artifacts/index.ts +1 -1
- package/src/internal/builtin-plugins/clean/index.ts +1 -1
- package/src/internal/builtin-plugins/clean/type-extensions.ts +0 -1
- package/src/internal/builtin-plugins/coverage/coverage-manager.ts +14 -10
- package/src/internal/builtin-plugins/coverage/hook-handlers/solidity.ts +8 -13
- package/src/internal/builtin-plugins/coverage/index.ts +1 -1
- package/src/internal/builtin-plugins/coverage/instrumentation.ts +0 -5
- package/src/internal/builtin-plugins/coverage/type-extensions.ts +0 -1
- package/src/internal/builtin-plugins/gas-analytics/index.ts +1 -1
- package/src/internal/builtin-plugins/gas-analytics/type-extensions.ts +0 -1
- package/src/internal/builtin-plugins/index.ts +10 -10
- package/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-solidity-errors.ts +10 -11
- package/src/internal/builtin-plugins/network-manager/index.ts +4 -4
- package/src/internal/builtin-plugins/network-manager/type-extensions/config.ts +0 -1
- package/src/internal/builtin-plugins/network-manager/type-extensions/global-options.ts +0 -1
- package/src/internal/builtin-plugins/network-manager/type-extensions/hooks.ts +0 -1
- package/src/internal/builtin-plugins/network-manager/type-extensions/hre.ts +0 -1
- package/src/internal/builtin-plugins/solidity/build-system/build-system.ts +32 -16
- package/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.ts +7 -0
- package/src/internal/builtin-plugins/solidity/index.ts +1 -1
- package/src/internal/builtin-plugins/solidity/type-extensions.ts +0 -4
- package/src/internal/builtin-plugins/solidity-test/index.ts +1 -1
- package/src/internal/builtin-plugins/solidity-test/inline-config/constants.ts +6 -2
- package/src/internal/builtin-plugins/solidity-test/inline-config/helpers.ts +15 -4
- package/src/internal/builtin-plugins/solidity-test/inline-config/validation.ts +25 -4
- package/src/internal/builtin-plugins/solidity-test/type-extensions.ts +0 -1
- package/src/internal/builtin-plugins/test/index.ts +1 -1
- package/src/internal/builtin-plugins/test/type-extensions.ts +0 -1
- package/src/internal/cli/telemetry/error-classification/classifier.ts +636 -0
- package/src/internal/cli/telemetry/error-classification/codebase-dependent-helpers.ts +200 -0
- package/src/internal/cli/telemetry/error-classification/filter.ts +140 -0
- package/src/internal/cli/telemetry/error-classification/helpers.ts +235 -0
- package/src/internal/cli/telemetry/error-reporter/reporter.ts +21 -0
- package/src/internal/cli/telemetry/sentry/anonymizer.ts +0 -168
- package/src/internal/cli/telemetry/sentry/init.ts +42 -33
- package/src/internal/cli/telemetry/sentry/reporter.ts +1 -44
- package/src/internal/cli/telemetry/sentry/subprocess.ts +11 -19
- package/src/types/config.ts +0 -4
- package/src/types/plugins.ts +2 -3
- package/templates/hardhat-3/01-node-test-runner-viem/package.json +11 -11
- package/templates/hardhat-3/02-mocha-ethers/package.json +14 -14
- package/templates/hardhat-3/03-minimal/package.json +1 -1
- package/coverage.sol +0 -38
|
@@ -43,7 +43,6 @@ import { createDebug } from "@nomicfoundation/hardhat-utils/debug";
|
|
|
43
43
|
import {
|
|
44
44
|
exists,
|
|
45
45
|
ensureDir,
|
|
46
|
-
getAllDirectoriesMatching,
|
|
47
46
|
getAllFilesMatching,
|
|
48
47
|
move,
|
|
49
48
|
readJsonFile,
|
|
@@ -1098,29 +1097,46 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
1098
1097
|
|
|
1099
1098
|
const userSourceNamesSet = new Set(userSourceNames);
|
|
1100
1099
|
|
|
1101
|
-
|
|
1100
|
+
const buildInfosDir = path.join(artifactsDirectory, `build-info`);
|
|
1101
|
+
|
|
1102
|
+
// We accept both `.json` files and per-file `artifacts.d.ts` files:
|
|
1103
|
+
// source files that compile but produce no contracts emit only the
|
|
1104
|
+
// declaration file, but their parent dir still belongs in the cleanup
|
|
1105
|
+
// candidate set.
|
|
1106
|
+
// TODO: This logic is originated with the artifacts manager, but now uses both json files and `artifacts.d.ts` as the test
|
|
1107
|
+
const allArtifactFiles = await getAllFilesMatching(
|
|
1102
1108
|
artifactsDirectory,
|
|
1103
|
-
(
|
|
1104
|
-
|
|
1109
|
+
(p) => {
|
|
1110
|
+
// Ignore top level files (e.g. the project-wide artifacts.d.ts)
|
|
1111
|
+
if (
|
|
1112
|
+
p.indexOf(path.sep, artifactsDirectory.length + path.sep.length) ===
|
|
1113
|
+
-1
|
|
1114
|
+
) {
|
|
1115
|
+
return false;
|
|
1116
|
+
}
|
|
1117
|
+
return p.endsWith(".json") || path.basename(p) === "artifacts.d.ts";
|
|
1118
|
+
},
|
|
1119
|
+
(dir) => dir !== buildInfosDir,
|
|
1120
|
+
);
|
|
1121
|
+
|
|
1122
|
+
const artifactDirs = new Set(
|
|
1123
|
+
allArtifactFiles.map((file) => path.dirname(file)),
|
|
1124
|
+
);
|
|
1125
|
+
const removedDirs = new Set<string>();
|
|
1126
|
+
|
|
1127
|
+
for (const dir of artifactDirs) {
|
|
1105
1128
|
const relativePath = toForwardSlash(
|
|
1106
|
-
path.relative(artifactsDirectory,
|
|
1129
|
+
path.relative(artifactsDirectory, dir),
|
|
1107
1130
|
);
|
|
1108
1131
|
|
|
1109
1132
|
if (!userSourceNamesSet.has(relativePath)) {
|
|
1110
|
-
await remove(
|
|
1133
|
+
await remove(dir);
|
|
1134
|
+
removedDirs.add(dir);
|
|
1111
1135
|
}
|
|
1112
1136
|
}
|
|
1113
1137
|
|
|
1114
|
-
const
|
|
1115
|
-
|
|
1116
|
-
// TODO: This logic is duplicated with respect to the artifacts manager
|
|
1117
|
-
const artifactPaths = await getAllFilesMatching(
|
|
1118
|
-
artifactsDirectory,
|
|
1119
|
-
(p) =>
|
|
1120
|
-
p.endsWith(".json") && // Only consider json files
|
|
1121
|
-
// Ignore top level json files
|
|
1122
|
-
p.indexOf(path.sep, artifactsDirectory.length + path.sep.length) !== -1,
|
|
1123
|
-
(dir) => dir !== buildInfosDir,
|
|
1138
|
+
const artifactPaths = allArtifactFiles.filter(
|
|
1139
|
+
(p) => p.endsWith(".json") && !removedDirs.has(path.dirname(p)),
|
|
1124
1140
|
);
|
|
1125
1141
|
|
|
1126
1142
|
const reachableBuildInfoIds = await Promise.all(
|
package/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.ts
CHANGED
|
@@ -478,6 +478,13 @@ export class RemappedNpmPackagesGraphImplementation
|
|
|
478
478
|
(f) => !f.endsWith("node_modules"),
|
|
479
479
|
);
|
|
480
480
|
|
|
481
|
+
// Sort by path so the first-wins dedup downstream is deterministic across
|
|
482
|
+
// filesystems. We sort here (and not after hook composition) so that hooks
|
|
483
|
+
// can rely on the contract that remappings they append after next() come
|
|
484
|
+
// last — e.g. hardhat-foundry appends forge's remappings after the
|
|
485
|
+
// package's own remappings.txt files, expecting remappings.txt to win.
|
|
486
|
+
remappingsTxtFiles.sort();
|
|
487
|
+
|
|
481
488
|
const results: Array<{ remappings: string[]; source: string }> = [];
|
|
482
489
|
for (const file of remappingsTxtFiles) {
|
|
483
490
|
const contents = await readUtf8File(file);
|
|
@@ -3,7 +3,7 @@ import type { HardhatPlugin } from "../../../types/plugins.js";
|
|
|
3
3
|
import { ArgumentType } from "../../../types/arguments.js";
|
|
4
4
|
import { globalOption, task } from "../../core/config.js";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
export type * from "./type-extensions.js";
|
|
7
7
|
|
|
8
8
|
const buildTask = task("build", "Build project")
|
|
9
9
|
.addFlag({
|
|
@@ -11,7 +11,6 @@ import type {
|
|
|
11
11
|
CompilerOutput,
|
|
12
12
|
} from "../../../types/solidity.js";
|
|
13
13
|
|
|
14
|
-
import "../../../types/config.js";
|
|
15
14
|
declare module "../../../types/config.js" {
|
|
16
15
|
/**
|
|
17
16
|
* An interface with a key per compiler type.
|
|
@@ -318,21 +317,18 @@ declare module "../../../types/config.js" {
|
|
|
318
317
|
}
|
|
319
318
|
}
|
|
320
319
|
|
|
321
|
-
import "../../../types/hre.js";
|
|
322
320
|
declare module "../../../types/hre.js" {
|
|
323
321
|
export interface HardhatRuntimeEnvironment {
|
|
324
322
|
solidity: SolidityBuildSystem;
|
|
325
323
|
}
|
|
326
324
|
}
|
|
327
325
|
|
|
328
|
-
import "../../../types/global-options.js";
|
|
329
326
|
declare module "../../../types/global-options.js" {
|
|
330
327
|
export interface GlobalOptions {
|
|
331
328
|
buildProfile: string;
|
|
332
329
|
}
|
|
333
330
|
}
|
|
334
331
|
|
|
335
|
-
import "../../../types/hooks.js";
|
|
336
332
|
declare module "../../../types/hooks.js" {
|
|
337
333
|
export interface HardhatHooks {
|
|
338
334
|
solidity: SolidityHooks;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export const HARDHAT_CONFIG_PREFIX = "hardhat-config:";
|
|
2
2
|
export const FORGE_CONFIG_PREFIX = "forge-config:";
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* All supported inline config keys and their expected value types.
|
|
6
|
+
*/
|
|
7
|
+
export const KEY_TYPES: Record<string, "number" | "boolean" | "string"> = {
|
|
6
8
|
"fuzz.runs": "number",
|
|
7
9
|
"fuzz.maxTestRejects": "number",
|
|
8
10
|
"fuzz.showLogs": "boolean",
|
|
@@ -13,6 +15,8 @@ export const KEY_TYPES: Record<string, "number" | "boolean"> = {
|
|
|
13
15
|
"invariant.callOverride": "boolean",
|
|
14
16
|
"invariant.timeout": "number",
|
|
15
17
|
allowInternalExpectRevert: "boolean",
|
|
18
|
+
isolate: "boolean",
|
|
19
|
+
evmVersion: "string",
|
|
16
20
|
};
|
|
17
21
|
|
|
18
22
|
/** Top-level key categories (e.g. "fuzz", "invariant", "allowInternalExpectRevert"). */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { RawInlineOverride } from "./types.js";
|
|
2
2
|
import type { TestFunctionConfigOverride } from "@nomicfoundation/edr";
|
|
3
3
|
|
|
4
|
+
import { assertHardhatInvariant } from "@nomicfoundation/hardhat-errors";
|
|
4
5
|
import { bytesIncludesUtf8String } from "@nomicfoundation/hardhat-utils/bytes";
|
|
5
6
|
|
|
6
7
|
import { getFullyQualifiedName } from "../../../../utils/contract-names.js";
|
|
@@ -57,10 +58,20 @@ export function buildConfigOverride(
|
|
|
57
58
|
|
|
58
59
|
for (const override of overrides) {
|
|
59
60
|
const expectedType = KEY_TYPES[override.key];
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
let parsed: number | boolean | string;
|
|
62
|
+
if (expectedType === "number") {
|
|
63
|
+
parsed = Number(override.rawValue);
|
|
64
|
+
} else if (expectedType === "boolean") {
|
|
65
|
+
parsed = override.rawValue.toLowerCase() === "true";
|
|
66
|
+
} else if (expectedType === "string") {
|
|
67
|
+
// Validation has already proven the surrounding double quotes.
|
|
68
|
+
parsed = override.rawValue.slice(1, -1);
|
|
69
|
+
} else {
|
|
70
|
+
assertHardhatInvariant(
|
|
71
|
+
false,
|
|
72
|
+
`Unhandled inline config value type for key ${override.key}`,
|
|
73
|
+
);
|
|
74
|
+
}
|
|
64
75
|
|
|
65
76
|
const dotIndex = override.key.indexOf(".");
|
|
66
77
|
if (dotIndex === -1) {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { RawInlineOverride } from "./types.js";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
HardhatError,
|
|
5
|
+
assertHardhatInvariant,
|
|
6
|
+
} from "@nomicfoundation/hardhat-errors";
|
|
4
7
|
|
|
5
8
|
import { KEY_TYPES } from "./constants.js";
|
|
6
9
|
import { getFunctionFqn } from "./helpers.js";
|
|
@@ -9,8 +12,9 @@ import { getFunctionFqn } from "./helpers.js";
|
|
|
9
12
|
* Validates a list of raw inline overrides, checking for:
|
|
10
13
|
* - Valid keys
|
|
11
14
|
* - No duplicate keys for the same function
|
|
12
|
-
* - Values of the expected type (numbers must be non-negative integers,
|
|
13
|
-
* must be "true" or "false"
|
|
15
|
+
* - Values of the expected type (numbers must be non-negative integers,
|
|
16
|
+
* booleans must be "true" or "false", strings must be a non-empty
|
|
17
|
+
* double-quoted literal)
|
|
14
18
|
*
|
|
15
19
|
* Throws a HardhatError if any validation fails.
|
|
16
20
|
*/
|
|
@@ -104,7 +108,7 @@ export function validateInlineOverrides(overrides: RawInlineOverride[]): void {
|
|
|
104
108
|
},
|
|
105
109
|
);
|
|
106
110
|
}
|
|
107
|
-
} else {
|
|
111
|
+
} else if (expectedType === "boolean") {
|
|
108
112
|
const lowerValue = rawValue.toLowerCase();
|
|
109
113
|
if (lowerValue !== "true" && lowerValue !== "false") {
|
|
110
114
|
throw new HardhatError(
|
|
@@ -117,6 +121,23 @@ export function validateInlineOverrides(overrides: RawInlineOverride[]): void {
|
|
|
117
121
|
},
|
|
118
122
|
);
|
|
119
123
|
}
|
|
124
|
+
} else if (expectedType === "string") {
|
|
125
|
+
if (!/^"[^"\n]+"$/.test(rawValue)) {
|
|
126
|
+
throw new HardhatError(
|
|
127
|
+
HardhatError.ERRORS.CORE.SOLIDITY_TESTS.INLINE_CONFIG_INVALID_VALUE,
|
|
128
|
+
{
|
|
129
|
+
value: rawValue,
|
|
130
|
+
key: rawKey,
|
|
131
|
+
expectedType: "non-empty double-quoted string",
|
|
132
|
+
functionFqn,
|
|
133
|
+
},
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
assertHardhatInvariant(
|
|
138
|
+
false,
|
|
139
|
+
`Unhandled inline config value type for key ${key}`,
|
|
140
|
+
);
|
|
120
141
|
}
|
|
121
142
|
}
|
|
122
143
|
}
|
|
@@ -3,7 +3,7 @@ import type { HardhatPlugin } from "../../../types/plugins.js";
|
|
|
3
3
|
import { ArgumentType } from "../../../types/arguments.js";
|
|
4
4
|
import { task } from "../../core/config.js";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
export type * from "./type-extensions.js";
|
|
7
7
|
|
|
8
8
|
const hardhatPlugin: HardhatPlugin = {
|
|
9
9
|
id: "builtin:test",
|