hardhat 3.14.0 → 3.16.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.
Files changed (71) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/src/internal/builtin-plugins/solidity/type-extensions.d.ts +2 -2
  3. package/dist/src/internal/builtin-plugins/solidity-test/edr-artifacts.d.ts.map +1 -1
  4. package/dist/src/internal/builtin-plugins/solidity-test/edr-artifacts.js +1 -1
  5. package/dist/src/internal/builtin-plugins/solidity-test/edr-artifacts.js.map +1 -1
  6. package/dist/src/internal/builtin-plugins/solidity-test/eip712/canonicalize.d.ts +1 -1
  7. package/dist/src/internal/builtin-plugins/solidity-test/eip712/canonicalize.d.ts.map +1 -1
  8. package/dist/src/internal/builtin-plugins/solidity-test/eip712/canonicalize.js +13 -11
  9. package/dist/src/internal/builtin-plugins/solidity-test/eip712/canonicalize.js.map +1 -1
  10. package/dist/src/internal/builtin-plugins/solidity-test/formatters.d.ts +6 -1
  11. package/dist/src/internal/builtin-plugins/solidity-test/formatters.d.ts.map +1 -1
  12. package/dist/src/internal/builtin-plugins/solidity-test/formatters.js +41 -0
  13. package/dist/src/internal/builtin-plugins/solidity-test/formatters.js.map +1 -1
  14. package/dist/src/internal/builtin-plugins/solidity-test/helpers.d.ts +16 -3
  15. package/dist/src/internal/builtin-plugins/solidity-test/helpers.d.ts.map +1 -1
  16. package/dist/src/internal/builtin-plugins/solidity-test/helpers.js +45 -2
  17. package/dist/src/internal/builtin-plugins/solidity-test/helpers.js.map +1 -1
  18. package/dist/src/internal/builtin-plugins/solidity-test/runner.d.ts.map +1 -1
  19. package/dist/src/internal/builtin-plugins/solidity-test/runner.js +18 -1
  20. package/dist/src/internal/builtin-plugins/solidity-test/runner.js.map +1 -1
  21. package/dist/src/internal/builtin-plugins/solidity-test/task-action.d.ts.map +1 -1
  22. package/dist/src/internal/builtin-plugins/solidity-test/task-action.js +15 -16
  23. package/dist/src/internal/builtin-plugins/solidity-test/task-action.js.map +1 -1
  24. package/package.json +2 -2
  25. package/src/internal/builtin-plugins/solidity/type-extensions.ts +2 -2
  26. package/src/internal/builtin-plugins/solidity-test/edr-artifacts.ts +1 -1
  27. package/src/internal/builtin-plugins/solidity-test/eip712/canonicalize.ts +13 -11
  28. package/src/internal/builtin-plugins/solidity-test/formatters.ts +60 -1
  29. package/src/internal/builtin-plugins/solidity-test/helpers.ts +56 -4
  30. package/src/internal/builtin-plugins/solidity-test/runner.ts +33 -1
  31. package/src/internal/builtin-plugins/solidity-test/task-action.ts +20 -20
  32. package/templates/01-node-test-runner-viem/contracts/Counter.sol +1 -1
  33. package/templates/01-node-test-runner-viem/contracts/Counter.t.sol +1 -1
  34. package/templates/01-node-test-runner-viem/hardhat.config.ts +2 -2
  35. package/templates/01-node-test-runner-viem/package.json +2 -2
  36. package/templates/02-mocha-ethers/contracts/Counter.sol +1 -1
  37. package/templates/02-mocha-ethers/contracts/Counter.t.sol +1 -1
  38. package/templates/02-mocha-ethers/hardhat.config.ts +2 -2
  39. package/templates/02-mocha-ethers/package.json +2 -2
  40. package/templates/03-minimal/hardhat.config.ts +1 -1
  41. package/templates/03-minimal/package.json +1 -1
  42. package/dist/src/internal/builtin-plugins/solidity-test/inline-config/constants.d.ts +0 -9
  43. package/dist/src/internal/builtin-plugins/solidity-test/inline-config/constants.d.ts.map +0 -1
  44. package/dist/src/internal/builtin-plugins/solidity-test/inline-config/constants.js +0 -24
  45. package/dist/src/internal/builtin-plugins/solidity-test/inline-config/constants.js.map +0 -1
  46. package/dist/src/internal/builtin-plugins/solidity-test/inline-config/helpers.d.ts +0 -24
  47. package/dist/src/internal/builtin-plugins/solidity-test/inline-config/helpers.d.ts.map +0 -1
  48. package/dist/src/internal/builtin-plugins/solidity-test/inline-config/helpers.js +0 -80
  49. package/dist/src/internal/builtin-plugins/solidity-test/inline-config/helpers.js.map +0 -1
  50. package/dist/src/internal/builtin-plugins/solidity-test/inline-config/index.d.ts +0 -13
  51. package/dist/src/internal/builtin-plugins/solidity-test/inline-config/index.d.ts.map +0 -1
  52. package/dist/src/internal/builtin-plugins/solidity-test/inline-config/index.js +0 -146
  53. package/dist/src/internal/builtin-plugins/solidity-test/inline-config/index.js.map +0 -1
  54. package/dist/src/internal/builtin-plugins/solidity-test/inline-config/parsing.d.ts +0 -19
  55. package/dist/src/internal/builtin-plugins/solidity-test/inline-config/parsing.d.ts.map +0 -1
  56. package/dist/src/internal/builtin-plugins/solidity-test/inline-config/parsing.js +0 -134
  57. package/dist/src/internal/builtin-plugins/solidity-test/inline-config/parsing.js.map +0 -1
  58. package/dist/src/internal/builtin-plugins/solidity-test/inline-config/types.d.ts +0 -10
  59. package/dist/src/internal/builtin-plugins/solidity-test/inline-config/types.d.ts.map +0 -1
  60. package/dist/src/internal/builtin-plugins/solidity-test/inline-config/types.js +0 -2
  61. package/dist/src/internal/builtin-plugins/solidity-test/inline-config/types.js.map +0 -1
  62. package/dist/src/internal/builtin-plugins/solidity-test/inline-config/validation.d.ts +0 -13
  63. package/dist/src/internal/builtin-plugins/solidity-test/inline-config/validation.d.ts.map +0 -1
  64. package/dist/src/internal/builtin-plugins/solidity-test/inline-config/validation.js +0 -96
  65. package/dist/src/internal/builtin-plugins/solidity-test/inline-config/validation.js.map +0 -1
  66. package/src/internal/builtin-plugins/solidity-test/inline-config/constants.ts +0 -25
  67. package/src/internal/builtin-plugins/solidity-test/inline-config/helpers.ts +0 -110
  68. package/src/internal/builtin-plugins/solidity-test/inline-config/index.ts +0 -285
  69. package/src/internal/builtin-plugins/solidity-test/inline-config/parsing.ts +0 -187
  70. package/src/internal/builtin-plugins/solidity-test/inline-config/types.ts +0 -9
  71. package/src/internal/builtin-plugins/solidity-test/inline-config/validation.ts +0 -144
@@ -1,144 +0,0 @@
1
- import type { RawInlineOverride } from "./types.js";
2
-
3
- import {
4
- HardhatError,
5
- assertHardhatInvariant,
6
- } from "@nomicfoundation/hardhat-errors";
7
-
8
- import { KEY_TYPES } from "./constants.js";
9
- import { getFunctionFqn } from "./helpers.js";
10
-
11
- /**
12
- * Validates a list of raw inline overrides, checking for:
13
- * - Valid keys
14
- * - No duplicate keys for the same function
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)
18
- *
19
- * Throws a HardhatError if any validation fails.
20
- */
21
- export function validateInlineOverrides(overrides: RawInlineOverride[]): void {
22
- const seen = new Set<string>();
23
-
24
- for (const {
25
- inputSourceName,
26
- contractName,
27
- functionName,
28
- functionSelector,
29
- rawKey,
30
- rawValue,
31
- key,
32
- } of overrides) {
33
- const functionFqn = getFunctionFqn(
34
- inputSourceName,
35
- contractName,
36
- functionName,
37
- );
38
-
39
- // Validate key
40
- if (!Object.hasOwn(KEY_TYPES, key)) {
41
- throw new HardhatError(
42
- HardhatError.ERRORS.CORE.SOLIDITY_TESTS.INLINE_CONFIG_INVALID_KEY,
43
- {
44
- key: rawKey,
45
- validKeys: Object.keys(KEY_TYPES).join(", "),
46
- functionFqn,
47
- },
48
- );
49
- }
50
-
51
- // Validate key matches test type
52
- const dotIndex = key.indexOf(".");
53
- if (dotIndex !== -1) {
54
- const keyCategory = key.slice(0, dotIndex);
55
- const isFuzzTest = functionName.startsWith("test");
56
- const isInvariantTest = functionName.startsWith("invariant");
57
-
58
- if (
59
- (isFuzzTest && keyCategory === "invariant") ||
60
- (isInvariantTest && keyCategory === "fuzz")
61
- ) {
62
- const testType = isFuzzTest ? "fuzz" : "invariant";
63
- const validPrefix = isFuzzTest ? "fuzz." : "invariant.";
64
- const validKeys = Object.keys(KEY_TYPES)
65
- .filter((k) => k.startsWith(validPrefix) || !k.includes("."))
66
- .join(", ");
67
-
68
- throw new HardhatError(
69
- HardhatError.ERRORS.CORE.SOLIDITY_TESTS
70
- .INLINE_CONFIG_INVALID_KEY_FOR_TEST_TYPE,
71
- {
72
- key: rawKey,
73
- functionFqn,
74
- testType,
75
- validKeys,
76
- },
77
- );
78
- }
79
- }
80
-
81
- // Check for duplicates (include selector to allow same key on overloaded functions)
82
- const functionId =
83
- functionSelector !== undefined
84
- ? `${functionFqn}#${functionSelector}`
85
- : functionFqn;
86
- const dedupeKey = `${functionId}-${key}`;
87
- if (seen.has(dedupeKey)) {
88
- throw new HardhatError(
89
- HardhatError.ERRORS.CORE.SOLIDITY_TESTS.INLINE_CONFIG_DUPLICATE_KEY,
90
- { key: rawKey, functionFqn },
91
- );
92
- }
93
- seen.add(dedupeKey);
94
-
95
- // Validate value type
96
- const expectedType = KEY_TYPES[key];
97
- if (expectedType === "number") {
98
- if (
99
- !/^(0|[1-9]\d*)$/.test(rawValue) ||
100
- !Number.isSafeInteger(Number(rawValue))
101
- ) {
102
- throw new HardhatError(
103
- HardhatError.ERRORS.CORE.SOLIDITY_TESTS.INLINE_CONFIG_INVALID_VALUE,
104
- {
105
- value: rawValue,
106
- key: rawKey,
107
- expectedType: "non-negative integer",
108
- functionFqn,
109
- },
110
- );
111
- }
112
- } else if (expectedType === "boolean") {
113
- const lowerValue = rawValue.toLowerCase();
114
- if (lowerValue !== "true" && lowerValue !== "false") {
115
- throw new HardhatError(
116
- HardhatError.ERRORS.CORE.SOLIDITY_TESTS.INLINE_CONFIG_INVALID_VALUE,
117
- {
118
- value: rawValue,
119
- key: rawKey,
120
- expectedType: "boolean",
121
- functionFqn,
122
- },
123
- );
124
- }
125
- } else if (expectedType === "string") {
126
- if (!/^"[^"\n]+"$/.test(rawValue)) {
127
- throw new HardhatError(
128
- HardhatError.ERRORS.CORE.SOLIDITY_TESTS.INLINE_CONFIG_INVALID_VALUE,
129
- {
130
- value: rawValue,
131
- key: rawKey,
132
- expectedType: "non-empty double-quoted string",
133
- functionFqn,
134
- },
135
- );
136
- }
137
- } else {
138
- assertHardhatInvariant(
139
- false,
140
- `Unhandled inline config value type for key ${key}`,
141
- );
142
- }
143
- }
144
- }