hardhat 3.9.0 → 3.10.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 +44 -0
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +6 -5
- package/dist/src/config.js.map +1 -1
- package/dist/src/hhu.d.ts +3 -0
- package/dist/src/hhu.d.ts.map +1 -0
- package/dist/src/hhu.js +14 -0
- package/dist/src/hhu.js.map +1 -0
- 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 +4 -1
- package/dist/src/internal/builtin-plugins/artifacts/hook-handlers/hre.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/function-gas-snapshots.d.ts +2 -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 +21 -23
- package/dist/src/internal/builtin-plugins/gas-analytics/function-gas-snapshots.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.d.ts +2 -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 +21 -27
- 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 +3 -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 +18 -10
- package/dist/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.js.map +1 -1
- package/dist/src/internal/builtin-plugins/hhu/index.d.ts +4 -0
- package/dist/src/internal/builtin-plugins/hhu/index.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/hhu/index.js +9 -0
- package/dist/src/internal/builtin-plugins/hhu/index.js.map +1 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/constants/index.d.ts +3 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/constants/index.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/constants/index.js +8 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/constants/index.js.map +1 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/constants/zero-address.d.ts +4 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/constants/zero-address.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/constants/zero-address.js +6 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/constants/zero-address.js.map +1 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/convert/index.d.ts +3 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/convert/index.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/convert/index.js +27 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/convert/index.js.map +1 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/convert/pad.d.ts +10 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/convert/pad.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/convert/pad.js +31 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/convert/pad.js.map +1 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/fetch/block-number.d.ts +4 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/fetch/block-number.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/fetch/block-number.js +17 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/fetch/block-number.js.map +1 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/fetch/index.d.ts +3 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/fetch/index.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/fetch/index.js +8 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/fetch/index.js.map +1 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/index.d.ts +11 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/index.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/index.js +20 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/index.js.map +1 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/utils-task.d.ts +13 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/utils-task.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/utils-task.js +17 -0
- package/dist/src/internal/builtin-plugins/hhu/tasks/utils-task.js.map +1 -0
- package/dist/src/internal/builtin-plugins/hhu/types.d.ts +45 -0
- package/dist/src/internal/builtin-plugins/hhu/types.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/hhu/types.js +2 -0
- package/dist/src/internal/builtin-plugins/hhu/types.js.map +1 -0
- package/dist/src/internal/builtin-plugins/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/index.js +5 -0
- package/dist/src/internal/builtin-plugins/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/accounts/derive-private-keys.js +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 +2 -0
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/solidity-stack-trace.d.ts +2 -2
- package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/solidity-stack-trace.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/solidity-stack-trace.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-solidity-errors.d.ts +1 -0
- 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 +17 -0
- 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/edr/types/hardfork.d.ts +17 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/types/hardfork.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/types/hardfork.js +19 -2
- package/dist/src/internal/builtin-plugins/network-manager/edr/types/hardfork.js.map +1 -1
- 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 +5 -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/edr/utils/hardfork.d.ts +8 -0
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/hardfork.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/hardfork.js +30 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/hardfork.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/index.js +2 -10
- package/dist/src/internal/builtin-plugins/network-manager/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/network-option.d.ts +9 -0
- package/dist/src/internal/builtin-plugins/network-manager/network-option.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/network-manager/network-option.js +15 -0
- package/dist/src/internal/builtin-plugins/network-manager/network-option.js.map +1 -0
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/automatic-sender-handler.d.ts +4 -2
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/automatic-sender-handler.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/automatic-sender-handler.js +28 -6
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/automatic-sender-handler.js.map +1 -1
- package/dist/src/internal/builtin-plugins/node/task-action.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/node/task-action.js +2 -37
- package/dist/src/internal/builtin-plugins/node/task-action.js.map +1 -1
- package/dist/src/internal/builtin-plugins/node/utils/resolve-node-connection-params.d.ts +19 -0
- package/dist/src/internal/builtin-plugins/node/utils/resolve-node-connection-params.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/node/utils/resolve-node-connection-params.js +47 -0
- package/dist/src/internal/builtin-plugins/node/utils/resolve-node-connection-params.js.map +1 -0
- 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 +34 -7
- package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/config.d.ts +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/config.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/config.js +32 -9
- package/dist/src/internal/builtin-plugins/solidity-test/config.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/canonicalize.d.ts +9 -3
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/canonicalize.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/canonicalize.js +60 -27
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/canonicalize.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/index.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/index.js +19 -10
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/index.js.map +1 -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 +4 -1
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/index.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/index.js +13 -5
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/stack-trace-solidity-errors.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/stack-trace-solidity-errors.js +3 -1
- package/dist/src/internal/builtin-plugins/solidity-test/stack-trace-solidity-errors.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/task-action.js +2 -2
- 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 +6 -0
- package/dist/src/internal/builtin-plugins/solidity-test/type-extensions.d.ts.map +1 -1
- package/dist/src/internal/cli/help/get-global-help-string.d.ts +3 -1
- package/dist/src/internal/cli/help/get-global-help-string.d.ts.map +1 -1
- package/dist/src/internal/cli/help/get-global-help-string.js +3 -3
- package/dist/src/internal/cli/help/get-global-help-string.js.map +1 -1
- package/dist/src/internal/cli/help/get-help-string.d.ts +3 -1
- package/dist/src/internal/cli/help/get-help-string.d.ts.map +1 -1
- package/dist/src/internal/cli/help/get-help-string.js +4 -4
- package/dist/src/internal/cli/help/get-help-string.js.map +1 -1
- package/dist/src/internal/cli/help/utils.d.ts +3 -1
- package/dist/src/internal/cli/help/utils.d.ts.map +1 -1
- package/dist/src/internal/cli/help/utils.js +2 -2
- package/dist/src/internal/cli/help/utils.js.map +1 -1
- package/dist/src/internal/cli/hhu.d.ts +14 -0
- package/dist/src/internal/cli/hhu.d.ts.map +1 -0
- package/dist/src/internal/cli/hhu.js +184 -0
- package/dist/src/internal/cli/hhu.js.map +1 -0
- package/dist/src/internal/cli/main.d.ts +0 -25
- package/dist/src/internal/cli/main.d.ts.map +1 -1
- package/dist/src/internal/cli/main.js +23 -303
- package/dist/src/internal/cli/main.js.map +1 -1
- package/dist/src/internal/cli/parser.d.ts +25 -0
- package/dist/src/internal/cli/parser.d.ts.map +1 -0
- package/dist/src/internal/cli/parser.js +282 -0
- package/dist/src/internal/cli/parser.js.map +1 -0
- package/dist/src/internal/cli/telemetry/analytics/analytics.d.ts +1 -1
- package/dist/src/internal/cli/telemetry/analytics/analytics.d.ts.map +1 -1
- package/dist/src/internal/cli/telemetry/analytics/analytics.js +2 -1
- package/dist/src/internal/cli/telemetry/analytics/analytics.js.map +1 -1
- package/dist/src/internal/cli/telemetry/analytics/types.d.ts +1 -0
- package/dist/src/internal/cli/telemetry/analytics/types.d.ts.map +1 -1
- package/dist/src/internal/using-hardhat2-plugin-errors.d.ts +2 -2
- package/dist/src/internal/using-hardhat2-plugin-errors.d.ts.map +1 -1
- package/dist/src/internal/using-hardhat2-plugin-errors.js +7 -3
- package/dist/src/internal/using-hardhat2-plugin-errors.js.map +1 -1
- package/dist/src/plugins.d.ts.map +1 -1
- package/dist/src/plugins.js +3 -2
- package/dist/src/plugins.js.map +1 -1
- package/package.json +4 -4
- package/src/config.ts +17 -5
- package/src/hhu.ts +18 -0
- package/src/internal/builtin-plugins/artifacts/hook-handlers/hre.ts +11 -3
- package/src/internal/builtin-plugins/gas-analytics/function-gas-snapshots.ts +32 -32
- package/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.ts +32 -36
- package/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.ts +22 -9
- package/src/internal/builtin-plugins/hhu/index.ts +13 -0
- package/src/internal/builtin-plugins/hhu/tasks/constants/index.ts +18 -0
- package/src/internal/builtin-plugins/hhu/tasks/constants/zero-address.ts +9 -0
- package/src/internal/builtin-plugins/hhu/tasks/convert/index.ts +40 -0
- package/src/internal/builtin-plugins/hhu/tasks/convert/pad.ts +61 -0
- package/src/internal/builtin-plugins/hhu/tasks/fetch/block-number.ts +28 -0
- package/src/internal/builtin-plugins/hhu/tasks/fetch/index.ts +18 -0
- package/src/internal/builtin-plugins/hhu/tasks/index.ts +36 -0
- package/src/internal/builtin-plugins/hhu/tasks/utils-task.ts +29 -0
- package/src/internal/builtin-plugins/hhu/types.ts +57 -0
- package/src/internal/builtin-plugins/index.ts +6 -0
- package/src/internal/builtin-plugins/network-manager/accounts/derive-private-keys.ts +1 -1
- package/src/internal/builtin-plugins/network-manager/edr/edr-provider.ts +3 -0
- package/src/internal/builtin-plugins/network-manager/edr/stack-traces/solidity-stack-trace.ts +1 -1
- package/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-solidity-errors.ts +33 -0
- package/src/internal/builtin-plugins/network-manager/edr/types/hardfork.ts +20 -3
- package/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.ts +5 -0
- package/src/internal/builtin-plugins/network-manager/edr/utils/hardfork.ts +53 -1
- package/src/internal/builtin-plugins/network-manager/index.ts +3 -10
- package/src/internal/builtin-plugins/network-manager/network-option.ts +17 -0
- package/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/automatic-sender-handler.ts +39 -9
- package/src/internal/builtin-plugins/node/task-action.ts +2 -52
- package/src/internal/builtin-plugins/node/utils/resolve-node-connection-params.ts +79 -0
- package/src/internal/builtin-plugins/solidity/build-system/build-system.ts +51 -8
- package/src/internal/builtin-plugins/solidity-test/config.ts +53 -9
- package/src/internal/builtin-plugins/solidity-test/eip712/canonicalize.ts +64 -25
- package/src/internal/builtin-plugins/solidity-test/eip712/index.ts +23 -13
- package/src/internal/builtin-plugins/solidity-test/helpers.ts +5 -1
- package/src/internal/builtin-plugins/solidity-test/inline-config/index.ts +20 -9
- package/src/internal/builtin-plugins/solidity-test/stack-trace-solidity-errors.ts +6 -1
- package/src/internal/builtin-plugins/solidity-test/task-action.ts +2 -2
- package/src/internal/builtin-plugins/solidity-test/type-extensions.ts +6 -0
- package/src/internal/cli/help/get-global-help-string.ts +3 -2
- package/src/internal/cli/help/get-help-string.ts +4 -3
- package/src/internal/cli/help/utils.ts +2 -1
- package/src/internal/cli/hhu.ts +298 -0
- package/src/internal/cli/main.ts +41 -495
- package/src/internal/cli/parser.ts +472 -0
- package/src/internal/cli/telemetry/analytics/analytics.ts +5 -1
- package/src/internal/cli/telemetry/analytics/types.ts +3 -0
- package/src/internal/using-hardhat2-plugin-errors.ts +12 -3
- package/src/plugins.ts +5 -2
- package/templates/hardhat-3/01-node-test-runner-viem/package.json +6 -6
- package/templates/hardhat-3/02-mocha-ethers/package.json +9 -9
- package/templates/hardhat-3/03-minimal/package.json +1 -1
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import type { GlobalOptionDefinitions } from "../../types/global-options.js";
|
|
2
|
+
import type { HardhatRuntimeEnvironment } from "../../types/hre.js";
|
|
3
|
+
import type { Task, TaskDefinition } from "../../types/tasks.js";
|
|
4
|
+
import type { FakeHhuHardhatRuntimeEnvironment } from "../builtin-plugins/hhu/types.js";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
assertHardhatInvariant,
|
|
8
|
+
HardhatError,
|
|
9
|
+
} from "@nomicfoundation/hardhat-errors";
|
|
10
|
+
import { isCi } from "@nomicfoundation/hardhat-utils/ci";
|
|
11
|
+
import { createDebug } from "@nomicfoundation/hardhat-utils/debug";
|
|
12
|
+
import { setGlobalOptionsAsEnvVariables } from "@nomicfoundation/hardhat-utils/env";
|
|
13
|
+
import { ensureError } from "@nomicfoundation/hardhat-utils/error";
|
|
14
|
+
|
|
15
|
+
import { isResult } from "../../utils/result.js";
|
|
16
|
+
import { generateTasks } from "../builtin-plugins/hhu/tasks/index.js";
|
|
17
|
+
import { NETWORK_GLOBAL_OPTION } from "../builtin-plugins/network-manager/network-option.js";
|
|
18
|
+
import { globalFlag } from "../core/config.js";
|
|
19
|
+
import { TaskManagerImplementation } from "../core/tasks/task-manager.js";
|
|
20
|
+
import { getHardhatVersion } from "../utils/package.js";
|
|
21
|
+
|
|
22
|
+
import { printErrorMessages } from "./error-handler.js";
|
|
23
|
+
import { getGlobalHelpString } from "./help/get-global-help-string.js";
|
|
24
|
+
import { getHelpString } from "./help/get-help-string.js";
|
|
25
|
+
import {
|
|
26
|
+
parseGlobalOptions,
|
|
27
|
+
parseRawArguments,
|
|
28
|
+
parseTask,
|
|
29
|
+
parseTaskArguments,
|
|
30
|
+
} from "./parser.js";
|
|
31
|
+
import { sendTaskAnalytics } from "./telemetry/analytics/analytics.js";
|
|
32
|
+
import { setupGlobalUnhandledErrorHandlers } from "./telemetry/error-reporter/global-error-handlers.js";
|
|
33
|
+
import { sendErrorTelemetry } from "./telemetry/error-reporter/reporter.js";
|
|
34
|
+
|
|
35
|
+
interface MainOptions {
|
|
36
|
+
print?: (message: string) => void;
|
|
37
|
+
rethrowErrors?: true;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function main(
|
|
41
|
+
rawArguments: string[],
|
|
42
|
+
options: MainOptions = {},
|
|
43
|
+
): Promise<void> {
|
|
44
|
+
// We set up the global unhandled errors before running any functionality
|
|
45
|
+
setupGlobalUnhandledErrorHandlers();
|
|
46
|
+
|
|
47
|
+
const print = options.print ?? console.log;
|
|
48
|
+
|
|
49
|
+
const log = createDebug("hardhat:core:hhu:main");
|
|
50
|
+
|
|
51
|
+
let hhuGlobalOptions;
|
|
52
|
+
|
|
53
|
+
log("hhu started");
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
const cliArguments = parseRawArguments(rawArguments);
|
|
57
|
+
|
|
58
|
+
const usedCliArguments: boolean[] = new Array(cliArguments.length).fill(
|
|
59
|
+
false,
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
hhuGlobalOptions = await parseHhuGlobalOptions(
|
|
63
|
+
cliArguments,
|
|
64
|
+
usedCliArguments,
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
// We forward `network` as an env variable so it's available when we lazily
|
|
68
|
+
// import the real HRE in utils that need it. We explicitly whitelist it
|
|
69
|
+
// (rather than forwarding every hhu global option) so that hhu-only options
|
|
70
|
+
// never leak into the real HRE's global-option namespace.
|
|
71
|
+
setGlobalOptionsAsEnvVariables({ network: hhuGlobalOptions.network });
|
|
72
|
+
|
|
73
|
+
log("Parsed hhu global options");
|
|
74
|
+
|
|
75
|
+
if (hhuGlobalOptions.version) {
|
|
76
|
+
return await printHhuVersionMessage(print);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const globalOptionDefinitions: GlobalOptionDefinitions = new Map(
|
|
80
|
+
HHU_GLOBAL_OPTIONS_DEFINITIONS,
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const rootTasks = taskDefinitionsToTasksMap(
|
|
84
|
+
generateTasks({ prefixWithUtils: false }),
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
const taskOrId = parseTask(cliArguments, usedCliArguments, rootTasks);
|
|
88
|
+
|
|
89
|
+
if (Array.isArray(taskOrId)) {
|
|
90
|
+
if (taskOrId.length === 0) {
|
|
91
|
+
const globalHelp = await getGlobalHelpString(
|
|
92
|
+
rootTasks,
|
|
93
|
+
globalOptionDefinitions,
|
|
94
|
+
{ command: "hhu" },
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
print(globalHelp);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
throw new HardhatError(
|
|
102
|
+
HardhatError.ERRORS.CORE.TASK_DEFINITIONS.TASK_NOT_FOUND,
|
|
103
|
+
{ task: taskOrId.join(" ") },
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const task = taskOrId;
|
|
108
|
+
|
|
109
|
+
if (task.isEmpty && usedCliArguments.includes(false)) {
|
|
110
|
+
const invalidSubtask = cliArguments[usedCliArguments.indexOf(false)];
|
|
111
|
+
|
|
112
|
+
throw new HardhatError(
|
|
113
|
+
HardhatError.ERRORS.CORE.TASK_DEFINITIONS.UNRECOGNIZED_SUBTASK,
|
|
114
|
+
{
|
|
115
|
+
task: task.id.join(" "),
|
|
116
|
+
invalidSubtask,
|
|
117
|
+
},
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (hhuGlobalOptions.help || task.isEmpty) {
|
|
122
|
+
const taskHelp = await getHelpString(task, globalOptionDefinitions, {
|
|
123
|
+
command: "hhu",
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
print(taskHelp);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const taskArguments = parseTaskArguments(
|
|
131
|
+
cliArguments,
|
|
132
|
+
usedCliArguments,
|
|
133
|
+
task,
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
log(`Running task "${task.id.join(" ")}"`);
|
|
137
|
+
|
|
138
|
+
const [taskResult] = await Promise.all([
|
|
139
|
+
task.run(taskArguments),
|
|
140
|
+
sendTaskAnalytics(task.id, "hhu"),
|
|
141
|
+
]);
|
|
142
|
+
|
|
143
|
+
if (isResult(taskResult) && !taskResult.success) {
|
|
144
|
+
process.exitCode = 1;
|
|
145
|
+
}
|
|
146
|
+
} catch (error) {
|
|
147
|
+
ensureError(error);
|
|
148
|
+
await printErrorMessages(error, hhuGlobalOptions?.showStackTraces);
|
|
149
|
+
|
|
150
|
+
try {
|
|
151
|
+
await sendErrorTelemetry(error);
|
|
152
|
+
} catch (e) {
|
|
153
|
+
log("Couldn't report error to sentry: %O", e);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (options.rethrowErrors) {
|
|
157
|
+
throw error;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
process.exitCode = 1;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const HHU_GLOBAL_OPTIONS_DEFINITIONS: GlobalOptionDefinitions = new Map([
|
|
165
|
+
[
|
|
166
|
+
"help",
|
|
167
|
+
{
|
|
168
|
+
pluginId: "builtin",
|
|
169
|
+
option: globalFlag({
|
|
170
|
+
name: "help",
|
|
171
|
+
shortName: "h",
|
|
172
|
+
description:
|
|
173
|
+
"Show this message, or a task's help if its name is provided.",
|
|
174
|
+
}),
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
[
|
|
178
|
+
"showStackTraces",
|
|
179
|
+
{
|
|
180
|
+
pluginId: "builtin",
|
|
181
|
+
option: globalFlag({
|
|
182
|
+
name: "showStackTraces",
|
|
183
|
+
description: "Show stack traces (always enabled on CI servers).",
|
|
184
|
+
}),
|
|
185
|
+
},
|
|
186
|
+
],
|
|
187
|
+
[
|
|
188
|
+
"version",
|
|
189
|
+
{
|
|
190
|
+
pluginId: "builtin",
|
|
191
|
+
option: globalFlag({
|
|
192
|
+
name: "version",
|
|
193
|
+
description: "Show the version of hhu.",
|
|
194
|
+
}),
|
|
195
|
+
},
|
|
196
|
+
],
|
|
197
|
+
[
|
|
198
|
+
"network",
|
|
199
|
+
{
|
|
200
|
+
pluginId: "builtin",
|
|
201
|
+
option: NETWORK_GLOBAL_OPTION,
|
|
202
|
+
},
|
|
203
|
+
],
|
|
204
|
+
]);
|
|
205
|
+
|
|
206
|
+
export async function parseHhuGlobalOptions(
|
|
207
|
+
cliArguments: string[],
|
|
208
|
+
usedCliArguments: boolean[],
|
|
209
|
+
): Promise<{
|
|
210
|
+
help: boolean;
|
|
211
|
+
showStackTraces: boolean;
|
|
212
|
+
version: boolean;
|
|
213
|
+
network: string | undefined;
|
|
214
|
+
}> {
|
|
215
|
+
const hhuGlobalOptions = await parseGlobalOptions(
|
|
216
|
+
HHU_GLOBAL_OPTIONS_DEFINITIONS,
|
|
217
|
+
cliArguments,
|
|
218
|
+
usedCliArguments,
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
return {
|
|
222
|
+
help: hhuGlobalOptions.help ?? false,
|
|
223
|
+
showStackTraces: hhuGlobalOptions.showStackTraces ?? isCi(),
|
|
224
|
+
version: hhuGlobalOptions.version ?? false,
|
|
225
|
+
network: hhuGlobalOptions.network,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export async function printHhuVersionMessage(
|
|
230
|
+
print: (message: string) => void = console.log,
|
|
231
|
+
): Promise<void> {
|
|
232
|
+
print(await getHardhatVersion());
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function makeStrictProxy<T extends object>(
|
|
236
|
+
name: string,
|
|
237
|
+
object: Partial<T>,
|
|
238
|
+
): T {
|
|
239
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- inaccessible properties will throw an assertion error
|
|
240
|
+
return new Proxy(object as T, {
|
|
241
|
+
get(target, property) {
|
|
242
|
+
assertHardhatInvariant(
|
|
243
|
+
Object.hasOwn(object, property),
|
|
244
|
+
`Unexpected access of property "${String(property)}" in ${name}.`,
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- we know this is safe because of the assertion above
|
|
248
|
+
return target[property as keyof T];
|
|
249
|
+
},
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function taskDefinitionsToTasksMap(tasks: TaskDefinition[]): Map<string, Task> {
|
|
254
|
+
// To be able to parse the hhu arguments, we need to create a tasks map from
|
|
255
|
+
// the task definitions. The easiest way to do that is by using
|
|
256
|
+
// `TaskManagerImplementation`, but this needs an HRE and we don't want to
|
|
257
|
+
// create one just for this. So we use a fake HRE that has the minimum
|
|
258
|
+
// properties needed.
|
|
259
|
+
//
|
|
260
|
+
// The exception is `network.create`: utils that need a network get the real
|
|
261
|
+
// implementation, which lazily loads Hardhat (and thus creates the project's
|
|
262
|
+
// HRE) only when such a util actually runs.
|
|
263
|
+
//
|
|
264
|
+
// One downside of this approach is that we _won't_ get a compilation error
|
|
265
|
+
// if `TaskManagerImplementation` tries to access a property that doesn't exist in the
|
|
266
|
+
// fake HRE, but tests should catch that.
|
|
267
|
+
//
|
|
268
|
+
// The `satisfies FakeHhuHardhatRuntimeEnvironment` keeps this fake HRE in sync
|
|
269
|
+
// with the surface utils actions rely on.
|
|
270
|
+
const fakeHre = makeStrictProxy<HardhatRuntimeEnvironment>(
|
|
271
|
+
"hhu's proxied HRE",
|
|
272
|
+
{
|
|
273
|
+
config: makeStrictProxy<HardhatRuntimeEnvironment["config"]>(
|
|
274
|
+
"hhu's proxied config",
|
|
275
|
+
{
|
|
276
|
+
tasks,
|
|
277
|
+
plugins: [],
|
|
278
|
+
},
|
|
279
|
+
),
|
|
280
|
+
network: makeStrictProxy<HardhatRuntimeEnvironment["network"]>(
|
|
281
|
+
"hhu's proxied network",
|
|
282
|
+
{
|
|
283
|
+
create: async (networkOrParams) => {
|
|
284
|
+
const hre = await import("../../index.js");
|
|
285
|
+
return await hre.network.create(networkOrParams);
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
),
|
|
289
|
+
} satisfies FakeHhuHardhatRuntimeEnvironment,
|
|
290
|
+
);
|
|
291
|
+
|
|
292
|
+
const taskManager = new TaskManagerImplementation(
|
|
293
|
+
fakeHre,
|
|
294
|
+
new Map(HHU_GLOBAL_OPTIONS_DEFINITIONS),
|
|
295
|
+
);
|
|
296
|
+
|
|
297
|
+
return taskManager.rootTasks;
|
|
298
|
+
}
|