hardhat 3.4.5 → 3.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +54 -0
- package/dist/src/config.d.ts +0 -1
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js.map +1 -1
- package/dist/src/hre.d.ts +0 -1
- package/dist/src/hre.d.ts.map +1 -1
- package/dist/src/hre.js.map +1 -1
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/internal/builtin-global-options.d.ts.map +1 -1
- package/dist/src/internal/builtin-global-options.js +1 -1
- package/dist/src/internal/builtin-global-options.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.d.ts +21 -0
- 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 +49 -1
- 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 +2 -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 +12 -2
- package/dist/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/config-resolution.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/config-resolution.js +9 -2
- package/dist/src/internal/builtin-plugins/network-manager/config-resolution.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-constants.d.ts +1 -0
- 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 +1 -0
- 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 +25 -5
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.d.ts +16 -0
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.js +28 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.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 +2 -6
- package/dist/src/internal/builtin-plugins/network-manager/network-manager.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/config.d.ts +5 -3
- 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/network-manager/utils/apply-coverage-network-overrides.d.ts +18 -0
- package/dist/src/internal/builtin-plugins/network-manager/utils/apply-coverage-network-overrides.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/network-manager/utils/apply-coverage-network-overrides.js +27 -0
- package/dist/src/internal/builtin-plugins/network-manager/utils/apply-coverage-network-overrides.js.map +1 -0
- package/dist/src/internal/builtin-plugins/node/json-rpc/handler.js +6 -5
- package/dist/src/internal/builtin-plugins/node/json-rpc/handler.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.d.ts +1 -4
- 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 +1 -11
- 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 +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/warning-suppression.d.ts +6 -10
- package/dist/src/internal/builtin-plugins/solidity/build-system/warning-suppression.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/warning-suppression.js +54 -43
- package/dist/src/internal/builtin-plugins/solidity/build-system/warning-suppression.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/constants.d.ts +10 -0
- package/dist/src/internal/builtin-plugins/solidity/constants.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/constants.js +10 -0
- package/dist/src/internal/builtin-plugins/solidity/constants.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 +2 -1
- package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/index.js +1 -0
- package/dist/src/internal/builtin-plugins/solidity/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/tasks/compile.d.ts +9 -0
- package/dist/src/internal/builtin-plugins/solidity/tasks/compile.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity/tasks/compile.js +10 -0
- package/dist/src/internal/builtin-plugins/solidity/tasks/compile.js.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/config.d.ts +4 -3
- package/dist/src/internal/builtin-plugins/solidity-test/config.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/config.js +55 -8
- package/dist/src/internal/builtin-plugins/solidity-test/config.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/ast-walker.d.ts +58 -0
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/ast-walker.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/ast-walker.js +226 -0
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/ast-walker.js.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/canonicalize.d.ts +29 -0
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/canonicalize.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/canonicalize.js +244 -0
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/canonicalize.js.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/glob.d.ts +7 -0
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/glob.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/glob.js +204 -0
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/glob.js.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/index.d.ts +21 -0
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/index.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/index.js +77 -0
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/index.js.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.d.ts +4 -3
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.js +20 -3
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.js.map +1 -1
- 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 +5 -1
- package/dist/src/internal/builtin-plugins/solidity-test/task-action.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/test-profiles.d.ts +2 -0
- package/dist/src/internal/builtin-plugins/solidity-test/test-profiles.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/test-profiles.js +2 -0
- package/dist/src/internal/builtin-plugins/solidity-test/test-profiles.js.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/type-extensions.d.ts +91 -32
- package/dist/src/internal/builtin-plugins/solidity-test/type-extensions.d.ts.map +1 -1
- package/dist/src/internal/cli/error-handler.d.ts +11 -2
- package/dist/src/internal/cli/error-handler.d.ts.map +1 -1
- package/dist/src/internal/cli/error-handler.js +72 -46
- package/dist/src/internal/cli/error-handler.js.map +1 -1
- package/dist/src/internal/cli/init/init.d.ts +31 -6
- package/dist/src/internal/cli/init/init.d.ts.map +1 -1
- package/dist/src/internal/cli/init/init.js +126 -13
- package/dist/src/internal/cli/init/init.js.map +1 -1
- package/dist/src/internal/cli/init/package-manager.d.ts +7 -1
- package/dist/src/internal/cli/init/package-manager.d.ts.map +1 -1
- package/dist/src/internal/cli/init/package-manager.js +14 -2
- package/dist/src/internal/cli/init/package-manager.js.map +1 -1
- package/dist/src/internal/cli/main.d.ts.map +1 -1
- package/dist/src/internal/cli/main.js +42 -2
- package/dist/src/internal/cli/main.js.map +1 -1
- package/dist/src/internal/cli/telemetry/error-classification/classifier.d.ts +2 -1
- package/dist/src/internal/cli/telemetry/error-classification/classifier.d.ts.map +1 -1
- package/dist/src/internal/cli/telemetry/error-classification/classifier.js +2 -1
- package/dist/src/internal/cli/telemetry/error-classification/classifier.js.map +1 -1
- package/dist/src/internal/using-hardhat2-plugin-errors.d.ts.map +1 -1
- package/dist/src/internal/using-hardhat2-plugin-errors.js +8 -11
- package/dist/src/internal/using-hardhat2-plugin-errors.js.map +1 -1
- package/dist/src/types/arguments.d.ts +1 -0
- package/dist/src/types/arguments.d.ts.map +1 -1
- package/dist/src/types/arguments.js +1 -0
- package/dist/src/types/arguments.js.map +1 -1
- package/dist/src/types/artifacts.d.ts +1 -0
- package/dist/src/types/artifacts.d.ts.map +1 -1
- package/dist/src/types/artifacts.js +1 -1
- package/dist/src/types/artifacts.js.map +1 -1
- package/dist/src/types/builtin-plugin-type-extensions.d.ts +2 -0
- package/dist/src/types/builtin-plugin-type-extensions.d.ts.map +1 -0
- package/dist/src/types/builtin-plugin-type-extensions.js +2 -0
- package/dist/src/types/builtin-plugin-type-extensions.js.map +1 -0
- package/dist/src/types/config.d.ts +1 -0
- package/dist/src/types/config.d.ts.map +1 -1
- package/dist/src/types/config.js +1 -1
- package/dist/src/types/config.js.map +1 -1
- package/dist/src/types/global-options.d.ts +1 -0
- package/dist/src/types/global-options.d.ts.map +1 -1
- package/dist/src/types/global-options.js +1 -1
- package/dist/src/types/global-options.js.map +1 -1
- package/dist/src/types/hooks.d.ts +1 -0
- package/dist/src/types/hooks.d.ts.map +1 -1
- package/dist/src/types/hooks.js +1 -1
- package/dist/src/types/hooks.js.map +1 -1
- package/dist/src/types/hre.d.ts +1 -0
- package/dist/src/types/hre.d.ts.map +1 -1
- package/dist/src/types/hre.js +1 -1
- package/dist/src/types/hre.js.map +1 -1
- package/dist/src/types/index.d.ts +1 -0
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/index.js +1 -0
- package/dist/src/types/index.js.map +1 -1
- package/dist/src/types/network.d.ts +1 -0
- package/dist/src/types/network.d.ts.map +1 -1
- package/dist/src/types/network.js +1 -1
- package/dist/src/types/network.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 -1
- package/dist/src/types/plugins.js.map +1 -1
- package/dist/src/types/providers.d.ts +1 -0
- package/dist/src/types/providers.d.ts.map +1 -1
- package/dist/src/types/providers.js +1 -1
- package/dist/src/types/providers.js.map +1 -1
- package/dist/src/types/solidity.d.ts +1 -0
- package/dist/src/types/solidity.d.ts.map +1 -1
- package/dist/src/types/solidity.js +1 -0
- package/dist/src/types/solidity.js.map +1 -1
- package/dist/src/types/tasks.d.ts +1 -0
- package/dist/src/types/tasks.d.ts.map +1 -1
- package/dist/src/types/tasks.js +1 -0
- package/dist/src/types/tasks.js.map +1 -1
- package/dist/src/types/test.d.ts +1 -0
- package/dist/src/types/test.d.ts.map +1 -1
- package/dist/src/types/test.js +1 -1
- package/dist/src/types/test.js.map +1 -1
- package/dist/src/types/user-interruptions.d.ts +1 -0
- package/dist/src/types/user-interruptions.d.ts.map +1 -1
- package/dist/src/types/user-interruptions.js +1 -1
- package/dist/src/types/user-interruptions.js.map +1 -1
- package/package.json +12 -11
- package/src/config.ts +0 -2
- package/src/hre.ts +0 -3
- package/src/index.ts +0 -3
- package/src/internal/builtin-global-options.ts +2 -1
- package/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.ts +90 -1
- package/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.ts +24 -2
- package/src/internal/builtin-plugins/network-manager/config-resolution.ts +11 -3
- package/src/internal/builtin-plugins/network-manager/edr/edr-constants.ts +2 -0
- package/src/internal/builtin-plugins/network-manager/edr/edr-provider.ts +38 -8
- package/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.ts +43 -1
- package/src/internal/builtin-plugins/network-manager/network-manager.ts +5 -6
- package/src/internal/builtin-plugins/network-manager/type-extensions/config.ts +5 -3
- package/src/internal/builtin-plugins/network-manager/type-validation.ts +7 -1
- package/src/internal/builtin-plugins/network-manager/utils/apply-coverage-network-overrides.ts +32 -0
- package/src/internal/builtin-plugins/node/json-rpc/handler.ts +7 -5
- package/src/internal/builtin-plugins/solidity/build-system/build-system.ts +2 -15
- package/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.ts +1 -2
- package/src/internal/builtin-plugins/solidity/build-system/warning-suppression.ts +81 -59
- package/src/internal/builtin-plugins/solidity/constants.ts +11 -0
- package/src/internal/builtin-plugins/solidity/hook-handlers/hre.ts +2 -1
- package/src/internal/builtin-plugins/solidity/index.ts +1 -0
- package/src/internal/builtin-plugins/solidity/tasks/compile.ts +12 -0
- package/src/internal/builtin-plugins/solidity-test/config.ts +85 -12
- package/src/internal/builtin-plugins/solidity-test/eip712/ast-walker.ts +324 -0
- package/src/internal/builtin-plugins/solidity-test/eip712/canonicalize.ts +317 -0
- package/src/internal/builtin-plugins/solidity-test/eip712/glob.ts +225 -0
- package/src/internal/builtin-plugins/solidity-test/eip712/index.ts +120 -0
- package/src/internal/builtin-plugins/solidity-test/helpers.ts +28 -4
- package/src/internal/builtin-plugins/solidity-test/task-action.ts +12 -1
- package/src/internal/builtin-plugins/solidity-test/test-profiles.ts +1 -0
- package/src/internal/builtin-plugins/solidity-test/type-extensions.ts +100 -33
- package/src/internal/cli/error-handler.ts +103 -72
- package/src/internal/cli/init/init.ts +203 -16
- package/src/internal/cli/init/package-manager.ts +18 -1
- package/src/internal/cli/main.ts +65 -2
- package/src/internal/cli/telemetry/error-classification/classifier.ts +2 -1
- package/src/internal/using-hardhat2-plugin-errors.ts +8 -11
- package/src/types/arguments.ts +2 -0
- package/src/types/artifacts.ts +2 -0
- package/src/types/builtin-plugin-type-extensions.ts +15 -0
- package/src/types/config.ts +2 -0
- package/src/types/global-options.ts +2 -0
- package/src/types/hooks.ts +2 -0
- package/src/types/hre.ts +2 -0
- package/src/types/index.ts +2 -0
- package/src/types/network.ts +2 -0
- package/src/types/plugins.ts +1 -2
- package/src/types/providers.ts +2 -0
- package/src/types/solidity.ts +2 -0
- package/src/types/tasks.ts +2 -0
- package/src/types/test.ts +2 -0
- package/src/types/user-interruptions.ts +2 -0
- package/templates/hardhat-3/01-node-test-runner-viem/package.json +11 -11
- package/templates/hardhat-3/01-node-test-runner-viem/tsconfig.json +4 -7
- package/templates/hardhat-3/02-mocha-ethers/package.json +13 -13
- package/templates/hardhat-3/02-mocha-ethers/tsconfig.json +4 -7
- package/templates/hardhat-3/03-minimal/package.json +2 -2
- package/templates/hardhat-3/03-minimal/tsconfig.json +4 -7
|
@@ -95,21 +95,6 @@ export function isSolcSolidityCompilerConfig(
|
|
|
95
95
|
return config.type === undefined || config.type === "solc";
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
// Compiler warnings to suppress from build output.
|
|
99
|
-
// Each rule specifies a warning message and the source file it applies to.
|
|
100
|
-
// This allows suppressing known warnings from internal files (e.g., console.sol)
|
|
101
|
-
// while still showing the same warning type from user code.
|
|
102
|
-
export const SUPPRESSED_WARNINGS: Array<{
|
|
103
|
-
message: string;
|
|
104
|
-
sourceFile: string;
|
|
105
|
-
}> = [
|
|
106
|
-
{
|
|
107
|
-
message:
|
|
108
|
-
"Natspec memory-safe-assembly special comment for inline assembly is deprecated and scheduled for removal. Use the memory-safe block annotation instead.",
|
|
109
|
-
sourceFile: path.normalize("hardhat/console.sol"),
|
|
110
|
-
},
|
|
111
|
-
];
|
|
112
|
-
|
|
113
98
|
interface CompilationResult {
|
|
114
99
|
compilationJob: CompilationJob;
|
|
115
100
|
compilerOutput: CompilerOutput;
|
|
@@ -123,6 +108,7 @@ export interface SolidityBuildSystemOptions {
|
|
|
123
108
|
readonly artifactsPath: string;
|
|
124
109
|
readonly cachePath: string;
|
|
125
110
|
readonly solidityTestsPath: string;
|
|
111
|
+
readonly coverage: boolean;
|
|
126
112
|
}
|
|
127
113
|
|
|
128
114
|
/**
|
|
@@ -1417,6 +1403,7 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
1417
1403
|
msg,
|
|
1418
1404
|
this.#options.solidityTestsPath,
|
|
1419
1405
|
this.#options.projectRoot,
|
|
1406
|
+
this.#options.coverage,
|
|
1420
1407
|
);
|
|
1421
1408
|
}
|
|
1422
1409
|
|
package/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.ts
CHANGED
|
@@ -29,14 +29,13 @@ import {
|
|
|
29
29
|
} from "@nomicfoundation/hardhat-utils/package";
|
|
30
30
|
|
|
31
31
|
import { UserRemappingErrorType } from "../../../../../types/solidity.js";
|
|
32
|
+
import { HARDHAT_PROJECT_INPUT_SOURCE_NAME_ROOT } from "../../constants.js";
|
|
32
33
|
|
|
33
34
|
import { getNpmPackageName } from "./npm-module-parsing.js";
|
|
34
35
|
import { parseRemappingString, selectBestRemapping } from "./remappings.js";
|
|
35
36
|
import { sourceNamePathJoin } from "./source-name-utils.js";
|
|
36
37
|
import { UserRemappingType } from "./types.js";
|
|
37
38
|
|
|
38
|
-
const HARDHAT_PROJECT_INPUT_SOURCE_NAME_ROOT = "project";
|
|
39
|
-
|
|
40
39
|
/**
|
|
41
40
|
* Returns a normalized version of the path if it refers to a node_modules in
|
|
42
41
|
* the root directory (i.e. node_modules/...), or a `node_modules` directory
|
|
@@ -1,97 +1,119 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
| {
|
|
24
|
-
message: string;
|
|
25
|
-
scope: "test-files";
|
|
26
|
-
}
|
|
27
|
-
> = [
|
|
3
|
+
import { COVERAGE_LIBRARY_FILE_NAME } from "@nomicfoundation/edr";
|
|
4
|
+
|
|
5
|
+
export const NATSPEC_MEMORY_SAFE_ASSEMBLY_WARNING =
|
|
6
|
+
"Natspec memory-safe-assembly special comment for inline assembly is deprecated and scheduled for removal. Use the memory-safe block annotation instead.";
|
|
7
|
+
export const SPDX_WARNING = "SPDX license identifier not provided";
|
|
8
|
+
export const PRAGMA_WARNING =
|
|
9
|
+
"Source file does not specify required compiler version";
|
|
10
|
+
const CONTRACT_SIZE_WARNING = "Contract code size is";
|
|
11
|
+
|
|
12
|
+
// Suppression rules are grouped by scope. Each array has its own match logic
|
|
13
|
+
// in `shouldSuppressWarning` function; add new entries to the array that fits, or add
|
|
14
|
+
// a new array + block for a new scope.
|
|
15
|
+
|
|
16
|
+
// Warnings tied to a specific internal file (e.g. console.sol). Suppressed
|
|
17
|
+
// only when the warning points at that file.
|
|
18
|
+
const SPECIFIC_FILE_RULES: ReadonlyArray<{
|
|
19
|
+
message: string;
|
|
20
|
+
filePath: string;
|
|
21
|
+
}> = [
|
|
28
22
|
{
|
|
29
|
-
message:
|
|
30
|
-
"Natspec memory-safe-assembly special comment for inline assembly is deprecated and scheduled for removal. Use the memory-safe block annotation instead.",
|
|
31
|
-
scope: "specific-file",
|
|
23
|
+
message: NATSPEC_MEMORY_SAFE_ASSEMBLY_WARNING,
|
|
32
24
|
// Normalize to handle different OS path separators
|
|
33
25
|
filePath: path.normalize("hardhat/console.sol"),
|
|
34
26
|
},
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
// Warnings acceptable in test files. Suppressed when the warning points at a
|
|
30
|
+
// file ending in `.t.sol` or inside the configured Solidity test directory.
|
|
31
|
+
const TEST_FILE_WARNING_MESSAGES: readonly string[] = [
|
|
32
|
+
SPDX_WARNING,
|
|
33
|
+
PRAGMA_WARNING,
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
// Warnings suppressed only when running with `--coverage`. An entry with no
|
|
37
|
+
// `filePath` matches the message anywhere (e.g. contract-size warnings that
|
|
38
|
+
// fire on user files as a side effect of instrumentation); an entry with a
|
|
39
|
+
// `filePath` only matches when the diagnostic also points at that file
|
|
40
|
+
// (e.g. the injected coverage library file, which users can't edit).
|
|
41
|
+
const COVERAGE_MODE_RULES: ReadonlyArray<{
|
|
42
|
+
message: string;
|
|
43
|
+
filePath?: string;
|
|
44
|
+
}> = [
|
|
45
|
+
{ message: CONTRACT_SIZE_WARNING },
|
|
35
46
|
{
|
|
36
|
-
message:
|
|
37
|
-
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
message: "Source file does not specify required compiler version",
|
|
41
|
-
scope: "test-files",
|
|
47
|
+
message: NATSPEC_MEMORY_SAFE_ASSEMBLY_WARNING,
|
|
48
|
+
filePath: COVERAGE_LIBRARY_FILE_NAME,
|
|
42
49
|
},
|
|
43
50
|
];
|
|
44
51
|
|
|
45
52
|
/**
|
|
46
|
-
* Determines if a compiler warning should be suppressed
|
|
53
|
+
* Determines if a compiler warning should be suppressed.
|
|
47
54
|
*
|
|
48
55
|
* @param errorMessage - The formatted error message from the compiler
|
|
49
56
|
* @param absoluteSolidityTestsPath - Absolute path to the Solidity test directory
|
|
50
57
|
* @param absoluteProjectRoot - Absolute path to the project root
|
|
58
|
+
* @param coverage - Whether the build is running with `--coverage` enabled
|
|
51
59
|
* @returns true if the warning should be suppressed, false otherwise
|
|
52
60
|
*/
|
|
53
61
|
export function shouldSuppressWarning(
|
|
54
62
|
errorMessage: string,
|
|
55
63
|
absoluteSolidityTestsPath: string,
|
|
56
64
|
absoluteProjectRoot: string,
|
|
65
|
+
coverage: boolean,
|
|
57
66
|
): boolean {
|
|
58
|
-
//
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return SUPPRESSED_WARNINGS.some((rule) => {
|
|
70
|
-
if (!errorMessage.includes(rule.message)) {
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
67
|
+
// Warnings suppressed only when running with `--coverage`.
|
|
68
|
+
if (
|
|
69
|
+
coverage &&
|
|
70
|
+
COVERAGE_MODE_RULES.some(
|
|
71
|
+
(rule) =>
|
|
72
|
+
errorMessage.includes(rule.message) &&
|
|
73
|
+
(rule.filePath === undefined || errorMessage.includes(rule.filePath)),
|
|
74
|
+
)
|
|
75
|
+
) {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
73
78
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
79
|
+
// Warnings tied to a specific internal file (e.g. console.sol).
|
|
80
|
+
if (
|
|
81
|
+
SPECIFIC_FILE_RULES.some(
|
|
82
|
+
(rule) =>
|
|
83
|
+
errorMessage.includes(rule.message) &&
|
|
84
|
+
errorMessage.includes(rule.filePath),
|
|
85
|
+
)
|
|
86
|
+
) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
77
89
|
|
|
78
|
-
|
|
90
|
+
// Warnings allowed in test files.
|
|
91
|
+
if (TEST_FILE_WARNING_MESSAGES.some((m) => errorMessage.includes(m))) {
|
|
79
92
|
// Test files are identified by:
|
|
80
93
|
// - Ending in .t.sol (e.g., Counter.t.sol)
|
|
81
94
|
// - Being inside the configured Solidity test directory
|
|
82
|
-
|
|
83
95
|
if (/\.t\.sol(:|$|\s)/.test(errorMessage)) {
|
|
84
96
|
return true;
|
|
85
97
|
}
|
|
86
98
|
|
|
87
|
-
//
|
|
99
|
+
// Compute relative path from project root to test directory.
|
|
100
|
+
// Example:
|
|
101
|
+
// absoluteSolidityTestsPath: /workspaces/hardhat-4/packages/example-project/test/contracts
|
|
102
|
+
// absoluteProjectRoot: /workspaces/hardhat-4/packages/example-project
|
|
103
|
+
// relativeTestPath: test/contracts/ - note the addition of the `/`
|
|
104
|
+
// to avoid partial matches, e.g.: test/contractsUtils/
|
|
105
|
+
const relativeTestPath = path.join(
|
|
106
|
+
path.relative(absoluteProjectRoot, absoluteSolidityTestsPath),
|
|
107
|
+
"/",
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
// Extract file path from error message.
|
|
88
111
|
// Format: "Warning: message\n --> path/to/file.sol:line:column:"
|
|
89
112
|
const pathMatches = errorMessage.match(/-->\s+([^\s:]+\.sol)/);
|
|
90
|
-
|
|
91
113
|
if (pathMatches !== null) {
|
|
92
114
|
return pathMatches[1].includes(relativeTestPath);
|
|
93
115
|
}
|
|
116
|
+
}
|
|
94
117
|
|
|
95
|
-
|
|
96
|
-
});
|
|
118
|
+
return false;
|
|
97
119
|
}
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import type { CompilerInput } from "../../../types/solidity.js";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* The input source name prefix used for files belonging to the Hardhat
|
|
5
|
+
* project (as opposed to npm packages, which use `npm/<pkg>@<version>`).
|
|
6
|
+
*
|
|
7
|
+
* For example, a project file at `<root>/contracts/Foo.sol` has input
|
|
8
|
+
* source name `project/contracts/Foo.sol`. Part of the build-info format
|
|
9
|
+
* contract: changing this value would require a new build-info format
|
|
10
|
+
* version.
|
|
11
|
+
*/
|
|
12
|
+
export const HARDHAT_PROJECT_INPUT_SOURCE_NAME_ROOT = "project";
|
|
13
|
+
|
|
3
14
|
export const DEFAULT_OUTPUT_SELECTION: CompilerInput["settings"]["outputSelection"] =
|
|
4
15
|
{
|
|
5
16
|
"*": {
|
|
@@ -152,7 +152,7 @@ class LazySolidityBuildSystem implements SolidityBuildSystem {
|
|
|
152
152
|
|
|
153
153
|
export default async (): Promise<Partial<HardhatRuntimeEnvironmentHooks>> => {
|
|
154
154
|
return {
|
|
155
|
-
created: async (
|
|
155
|
+
created: async (context, hre) => {
|
|
156
156
|
hre.solidity = new LazySolidityBuildSystem(hre.hooks, {
|
|
157
157
|
solidityConfig: hre.config.solidity,
|
|
158
158
|
projectRoot: hre.config.paths.root,
|
|
@@ -160,6 +160,7 @@ export default async (): Promise<Partial<HardhatRuntimeEnvironmentHooks>> => {
|
|
|
160
160
|
artifactsPath: hre.config.paths.artifacts,
|
|
161
161
|
cachePath: hre.config.paths.cache,
|
|
162
162
|
solidityTestsPath: hre.config.paths.tests.solidity,
|
|
163
|
+
coverage: context.globalOptions.coverage,
|
|
163
164
|
});
|
|
164
165
|
},
|
|
165
166
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { NewTaskActionFunction } from "../../../../types/tasks.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Compile task action is an alias of the build task action, it invokes
|
|
5
|
+
* the build task to ensure any build overrides are properly executed when
|
|
6
|
+
* compile is run.
|
|
7
|
+
*/
|
|
8
|
+
const compileAction: NewTaskActionFunction = async (args, hre) => {
|
|
9
|
+
return await hre.tasks.getTask("build").run(args);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default compileAction;
|
|
@@ -6,17 +6,19 @@ import type {
|
|
|
6
6
|
} from "../../../types/config.js";
|
|
7
7
|
import type { HardhatUserConfigValidationError } from "../../../types/hooks.js";
|
|
8
8
|
import type {
|
|
9
|
-
SolidityTestConfig,
|
|
10
9
|
SolidityTestForkingConfig,
|
|
11
|
-
|
|
10
|
+
SolidityTestProfileConfig,
|
|
11
|
+
SolidityTestProfileUserConfig,
|
|
12
12
|
} from "../../../types/test.js";
|
|
13
13
|
|
|
14
14
|
import path from "node:path";
|
|
15
15
|
|
|
16
|
+
import { assertHardhatInvariant } from "@nomicfoundation/hardhat-errors";
|
|
16
17
|
import { isObject } from "@nomicfoundation/hardhat-utils/lang";
|
|
17
18
|
import { resolveFromRoot } from "@nomicfoundation/hardhat-utils/path";
|
|
18
19
|
import {
|
|
19
20
|
conditionalUnionType,
|
|
21
|
+
incompatibleFieldType,
|
|
20
22
|
sensitiveStringSchema,
|
|
21
23
|
sensitiveUrlSchema,
|
|
22
24
|
unionType,
|
|
@@ -24,11 +26,13 @@ import {
|
|
|
24
26
|
} from "@nomicfoundation/hardhat-zod-utils";
|
|
25
27
|
import { z } from "zod";
|
|
26
28
|
|
|
29
|
+
import { DEFAULT_TEST_PROFILE } from "./test-profiles.js";
|
|
30
|
+
|
|
27
31
|
// the keccak256 of "built for ethereum"
|
|
28
32
|
export const DEFAULT_FUZZ_SEED =
|
|
29
33
|
"0x7727ea51af0441c20da14dcd68a15dac8c9ebd589c5be8fa8c87c1d3720450bc";
|
|
30
34
|
|
|
31
|
-
const
|
|
35
|
+
const solidityTestProfileUserConfigType = z.object({
|
|
32
36
|
fsPermissions: z
|
|
33
37
|
.object({
|
|
34
38
|
readWriteFile: z.array(z.string()).optional(),
|
|
@@ -50,7 +54,11 @@ const solidityTestUserConfigType = z.object({
|
|
|
50
54
|
blockTimestamp: z.bigint().optional(),
|
|
51
55
|
prevRandao: z.bigint().optional(),
|
|
52
56
|
gasLimit: z.bigint().optional(),
|
|
53
|
-
blockGasLimit: z.bigint().or(z.literal(false)).optional(),
|
|
57
|
+
blockGasLimit: z.number().or(z.bigint()).or(z.literal(false)).optional(),
|
|
58
|
+
// TODO: widen back to .number().or(z.bigint()).or(z.literal(false))
|
|
59
|
+
// once Solidity test runner no longer breaks setUp() when
|
|
60
|
+
// disableTransactionGasCap is false. See PR #8301.
|
|
61
|
+
transactionGasCap: z.literal(false).optional(),
|
|
54
62
|
fuzz: z
|
|
55
63
|
.object({
|
|
56
64
|
failurePersistDir: z.string().optional(),
|
|
@@ -89,8 +97,49 @@ const solidityTestUserConfigType = z.object({
|
|
|
89
97
|
shrinkRunLimit: z.number().optional(),
|
|
90
98
|
})
|
|
91
99
|
.optional(),
|
|
100
|
+
eip712Types: z
|
|
101
|
+
.object({
|
|
102
|
+
include: z.array(z.string()).optional(),
|
|
103
|
+
exclude: z.array(z.string()).optional(),
|
|
104
|
+
})
|
|
105
|
+
.optional(),
|
|
92
106
|
});
|
|
93
107
|
|
|
108
|
+
const solidityTestFlatUserConfigType = solidityTestProfileUserConfigType.extend(
|
|
109
|
+
{
|
|
110
|
+
profiles: incompatibleFieldType(
|
|
111
|
+
"This field is incompatible with the flat solidity test config",
|
|
112
|
+
),
|
|
113
|
+
},
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
const solidityTestProfilesUserConfigType = z.object({
|
|
117
|
+
profiles: z
|
|
118
|
+
.record(z.string(), solidityTestProfileUserConfigType)
|
|
119
|
+
.refine(
|
|
120
|
+
(profiles) => DEFAULT_TEST_PROFILE in profiles,
|
|
121
|
+
"A `default` profile is required when using `profiles`",
|
|
122
|
+
)
|
|
123
|
+
.refine(
|
|
124
|
+
(profiles) =>
|
|
125
|
+
!(DEFAULT_TEST_PROFILE in profiles) ||
|
|
126
|
+
Object.keys(profiles).every((name) => name === DEFAULT_TEST_PROFILE),
|
|
127
|
+
"Only the `default` profile is supported. Other profile names will be supported in a future release.",
|
|
128
|
+
),
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
const solidityTestUserConfigType = conditionalUnionType(
|
|
132
|
+
[
|
|
133
|
+
[
|
|
134
|
+
(data) =>
|
|
135
|
+
isObject(data) && "profiles" in data && Object.keys(data).length === 1,
|
|
136
|
+
solidityTestProfilesUserConfigType,
|
|
137
|
+
],
|
|
138
|
+
[isObject, solidityTestFlatUserConfigType],
|
|
139
|
+
],
|
|
140
|
+
"Expected a Solidity test config or a `{ profiles: { ... } }` wrapper",
|
|
141
|
+
);
|
|
142
|
+
|
|
94
143
|
const userConfigType = z.object({
|
|
95
144
|
paths: z
|
|
96
145
|
.object({
|
|
@@ -111,7 +160,7 @@ const userConfigType = z.object({
|
|
|
111
160
|
});
|
|
112
161
|
|
|
113
162
|
export function resolveSolidityTestForkingConfig(
|
|
114
|
-
forkingUserConfig:
|
|
163
|
+
forkingUserConfig: SolidityTestProfileUserConfig["forking"],
|
|
115
164
|
resolveConfigurationVariable: ConfigurationVariableResolver,
|
|
116
165
|
): SolidityTestForkingConfig | undefined {
|
|
117
166
|
if (forkingUserConfig === undefined) {
|
|
@@ -159,16 +208,29 @@ export async function resolveSolidityTestUserConfig(
|
|
|
159
208
|
|
|
160
209
|
const defaultRpcCachePath = path.join(resolvedConfig.paths.cache, "edr");
|
|
161
210
|
|
|
211
|
+
const solidityUserConfig = userConfig.test?.solidity;
|
|
212
|
+
let profileUserConfig: SolidityTestProfileUserConfig | undefined;
|
|
213
|
+
if (solidityUserConfig !== undefined && "profiles" in solidityUserConfig) {
|
|
214
|
+
profileUserConfig = solidityUserConfig.profiles[DEFAULT_TEST_PROFILE];
|
|
215
|
+
assertHardhatInvariant(
|
|
216
|
+
profileUserConfig !== undefined,
|
|
217
|
+
"default profile must be present when the profiles wrapper user config is supplied",
|
|
218
|
+
);
|
|
219
|
+
} else {
|
|
220
|
+
profileUserConfig = solidityUserConfig;
|
|
221
|
+
}
|
|
222
|
+
|
|
162
223
|
const resolvedForking = resolveSolidityTestForkingConfig(
|
|
163
|
-
|
|
224
|
+
profileUserConfig?.forking,
|
|
164
225
|
resolveConfigurationVariable,
|
|
165
226
|
);
|
|
166
227
|
|
|
167
|
-
const
|
|
228
|
+
const resolvedDefaultProfile = {
|
|
168
229
|
rpcCachePath: defaultRpcCachePath,
|
|
169
|
-
...
|
|
170
|
-
fuzz: resolveFuzzConfig(
|
|
230
|
+
...profileUserConfig,
|
|
231
|
+
fuzz: resolveFuzzConfig(profileUserConfig?.fuzz),
|
|
171
232
|
forking: resolvedForking,
|
|
233
|
+
eip712Types: resolveEip712TypesConfig(profileUserConfig?.eip712Types),
|
|
172
234
|
};
|
|
173
235
|
|
|
174
236
|
return {
|
|
@@ -182,16 +244,27 @@ export async function resolveSolidityTestUserConfig(
|
|
|
182
244
|
},
|
|
183
245
|
test: {
|
|
184
246
|
...resolvedConfig.test,
|
|
185
|
-
solidity:
|
|
247
|
+
solidity: {
|
|
248
|
+
profiles: { [DEFAULT_TEST_PROFILE]: resolvedDefaultProfile },
|
|
249
|
+
},
|
|
186
250
|
},
|
|
187
251
|
};
|
|
188
252
|
}
|
|
189
253
|
|
|
190
254
|
export function resolveFuzzConfig(
|
|
191
|
-
fuzzUserConfig:
|
|
192
|
-
):
|
|
255
|
+
fuzzUserConfig: SolidityTestProfileUserConfig["fuzz"] = {},
|
|
256
|
+
): SolidityTestProfileConfig["fuzz"] {
|
|
193
257
|
return {
|
|
194
258
|
...fuzzUserConfig,
|
|
195
259
|
seed: fuzzUserConfig.seed ?? DEFAULT_FUZZ_SEED,
|
|
196
260
|
};
|
|
197
261
|
}
|
|
262
|
+
|
|
263
|
+
export function resolveEip712TypesConfig(
|
|
264
|
+
eip712TypesUserConfig: SolidityTestProfileUserConfig["eip712Types"] = {},
|
|
265
|
+
): SolidityTestProfileConfig["eip712Types"] {
|
|
266
|
+
return {
|
|
267
|
+
include: eip712TypesUserConfig.include ?? [],
|
|
268
|
+
exclude: eip712TypesUserConfig.exclude ?? [],
|
|
269
|
+
};
|
|
270
|
+
}
|