hardhat 3.2.0 → 3.3.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 +34 -0
- package/dist/src/internal/builtin-global-options.d.ts.map +1 -1
- package/dist/src/internal/builtin-global-options.js +14 -1
- package/dist/src/internal/builtin-global-options.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers.d.ts +0 -5
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers.js +12 -3
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/accounts/derive-private-keys.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/accounts/derive-private-keys.js +12 -2
- package/dist/src/internal/builtin-plugins/network-manager/accounts/derive-private-keys.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.d.ts +9 -3
- 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 +65 -42
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/genesis-state.d.ts +11 -0
- package/dist/src/internal/builtin-plugins/network-manager/edr/genesis-state.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/network-manager/edr/genesis-state.js +104 -0
- package/dist/src/internal/builtin-plugins/network-manager/edr/genesis-state.js.map +1 -0
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.d.ts +6 -0
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.js +152 -0
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.js.map +1 -0
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-output.d.ts +19 -0
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-output.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-output.js +104 -0
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-output.js.map +1 -0
- package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/hre.js +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/hre.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/network.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/network.js +8 -8
- package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/network.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/http-provider.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/http-provider.js +1 -0
- package/dist/src/internal/builtin-plugins/network-manager/http-provider.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/network-manager.d.ts +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 +63 -7
- package/dist/src/internal/builtin-plugins/network-manager/network-manager.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/local-accounts.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/local-accounts.js +56 -33
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/local-accounts.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers-array.d.ts +0 -3
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers-array.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers-array.js +9 -12
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers-array.js.map +1 -1
- package/dist/src/internal/builtin-plugins/node/artifacts/build-info-watcher.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/node/artifacts/build-info-watcher.js +1 -1
- package/dist/src/internal/builtin-plugins/node/artifacts/build-info-watcher.js.map +1 -1
- package/dist/src/internal/builtin-plugins/node/helpers.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/node/helpers.js +6 -2
- package/dist/src/internal/builtin-plugins/node/helpers.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/artifacts.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/artifacts.js +4 -0
- package/dist/src/internal/builtin-plugins/solidity/build-system/artifacts.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.d.ts +5 -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 +86 -47
- package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/cache.d.ts +1 -0
- package/dist/src/internal/builtin-plugins/solidity/build-system/cache.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/cache.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job.d.ts +3 -3
- package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job.js +24 -4
- package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/compiler.d.ts +16 -0
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/compiler.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/compiler.js +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/compiler.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.js +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/solc-config-selection.d.ts +2 -2
- package/dist/src/internal/builtin-plugins/solidity/build-system/solc-config-selection.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/solc-config-selection.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/config.d.ts +4 -2
- package/dist/src/internal/builtin-plugins/solidity/config.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/config.js +247 -68
- package/dist/src/internal/builtin-plugins/solidity/config.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/exports.d.ts +3 -0
- package/dist/src/internal/builtin-plugins/solidity/exports.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity/exports.js +3 -0
- package/dist/src/internal/builtin-plugins/solidity/exports.js.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity/hook-handlers/config.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/hook-handlers/config.js +2 -1
- package/dist/src/internal/builtin-plugins/solidity/hook-handlers/config.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/hook-handlers/solidity.d.ts +4 -0
- package/dist/src/internal/builtin-plugins/solidity/hook-handlers/solidity.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity/hook-handlers/solidity.js +7 -0
- package/dist/src/internal/builtin-plugins/solidity/hook-handlers/solidity.js.map +1 -0
- 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/solidity-hooks.d.ts +18 -0
- package/dist/src/internal/builtin-plugins/solidity/solidity-hooks.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity/solidity-hooks.js +33 -0
- package/dist/src/internal/builtin-plugins/solidity/solidity-hooks.js.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity/type-extensions.d.ts +201 -28
- package/dist/src/internal/builtin-plugins/solidity/type-extensions.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/type-extensions.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/edr-artifacts.d.ts +12 -6
- package/dist/src/internal/builtin-plugins/solidity-test/edr-artifacts.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/edr-artifacts.js +9 -7
- package/dist/src/internal/builtin-plugins/solidity-test/edr-artifacts.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/formatters.d.ts +1 -12
- package/dist/src/internal/builtin-plugins/solidity-test/formatters.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/formatters.js +0 -150
- package/dist/src/internal/builtin-plugins/solidity-test/formatters.js.map +1 -1
- 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 +5 -9
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/index.js +0 -7
- 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 +7 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/constants.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/constants.js +20 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/constants.js.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/helpers.d.ts +24 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/helpers.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/helpers.js +68 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/helpers.js.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/index.d.ts +13 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/index.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/index.js +136 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/index.js.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/parsing.d.ts +19 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/parsing.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/parsing.js +133 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/parsing.js.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/types.d.ts +10 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/types.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/types.js +2 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/types.js.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/validation.d.ts +12 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/validation.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/validation.js +81 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/validation.js.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/reporter.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/reporter.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/reporter.js +5 -2
- package/dist/src/internal/builtin-plugins/solidity-test/reporter.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/task-action.d.ts +0 -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 +21 -14
- package/dist/src/internal/builtin-plugins/solidity-test/task-action.js.map +1 -1
- package/dist/src/internal/builtin-plugins/test/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/test/index.js +0 -7
- package/dist/src/internal/builtin-plugins/test/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/test/task-action.d.ts +0 -1
- package/dist/src/internal/builtin-plugins/test/task-action.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/test/task-action.js +1 -4
- package/dist/src/internal/builtin-plugins/test/task-action.js.map +1 -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 +1 -1
- package/dist/src/internal/cli/help/get-help-string.js.map +1 -1
- package/dist/src/internal/cli/init/init.d.ts.map +1 -1
- package/dist/src/internal/cli/init/init.js +1 -1
- package/dist/src/internal/cli/init/init.js.map +1 -1
- package/dist/src/internal/cli/init/prompt.d.ts.map +1 -1
- package/dist/src/internal/cli/init/prompt.js +1 -7
- package/dist/src/internal/cli/init/prompt.js.map +1 -1
- package/dist/src/internal/core/hre.d.ts +2 -1
- package/dist/src/internal/core/hre.d.ts.map +1 -1
- package/dist/src/internal/core/hre.js +18 -0
- package/dist/src/internal/core/hre.js.map +1 -1
- package/dist/src/internal/core/plugins/detect-plugin-npm-dependency-problems.d.ts.map +1 -1
- package/dist/src/internal/core/plugins/detect-plugin-npm-dependency-problems.js +6 -1
- package/dist/src/internal/core/plugins/detect-plugin-npm-dependency-problems.js.map +1 -1
- package/dist/src/internal/core/user-interruptions.d.ts.map +1 -1
- package/dist/src/internal/core/user-interruptions.js +2 -5
- package/dist/src/internal/core/user-interruptions.js.map +1 -1
- package/dist/src/internal/utils/colorizer.d.ts +10 -0
- package/dist/src/internal/utils/colorizer.d.ts.map +1 -0
- package/dist/src/internal/utils/colorizer.js +2 -0
- package/dist/src/internal/utils/colorizer.js.map +1 -0
- package/dist/src/internal/utils/package.d.ts.map +1 -1
- package/dist/src/internal/utils/package.js +1 -1
- package/dist/src/internal/utils/package.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/hooks.d.ts +32 -0
- package/dist/src/types/hooks.d.ts.map +1 -1
- package/dist/src/types/solidity/compilation-job.d.ts +5 -5
- package/dist/src/types/solidity/compilation-job.d.ts.map +1 -1
- package/dist/src/types/solidity/solidity-artifacts.d.ts +15 -0
- package/dist/src/types/solidity/solidity-artifacts.d.ts.map +1 -1
- package/package.json +6 -5
- package/src/internal/builtin-global-options.ts +15 -1
- package/src/internal/builtin-plugins/gas-analytics/helpers.ts +13 -3
- package/src/internal/builtin-plugins/network-manager/accounts/derive-private-keys.ts +25 -3
- package/src/internal/builtin-plugins/network-manager/edr/edr-provider.ts +107 -56
- package/src/internal/builtin-plugins/network-manager/edr/genesis-state.ts +179 -0
- package/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.ts +197 -0
- package/src/internal/builtin-plugins/network-manager/edr/utils/trace-output.ts +137 -0
- package/src/internal/builtin-plugins/network-manager/hook-handlers/hre.ts +1 -0
- package/src/internal/builtin-plugins/network-manager/hook-handlers/network.ts +8 -11
- package/src/internal/builtin-plugins/network-manager/http-provider.ts +1 -0
- package/src/internal/builtin-plugins/network-manager/network-manager.ts +83 -10
- package/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/local-accounts.ts +98 -34
- package/src/internal/builtin-plugins/network-manager/request-handlers/handlers-array.ts +10 -30
- package/src/internal/builtin-plugins/node/artifacts/build-info-watcher.ts +1 -2
- package/src/internal/builtin-plugins/node/helpers.ts +9 -2
- package/src/internal/builtin-plugins/solidity/build-system/artifacts.ts +7 -2
- package/src/internal/builtin-plugins/solidity/build-system/build-system.ts +141 -65
- package/src/internal/builtin-plugins/solidity/build-system/cache.ts +1 -0
- package/src/internal/builtin-plugins/solidity/build-system/compilation-job.ts +34 -7
- package/src/internal/builtin-plugins/solidity/build-system/compiler/compiler.ts +1 -1
- package/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.ts +1 -2
- package/src/internal/builtin-plugins/solidity/build-system/solc-config-selection.ts +4 -2
- package/src/internal/builtin-plugins/solidity/config.ts +335 -110
- package/src/internal/builtin-plugins/solidity/exports.ts +2 -0
- package/src/internal/builtin-plugins/solidity/hook-handlers/config.ts +3 -0
- package/src/internal/builtin-plugins/solidity/hook-handlers/solidity.ts +9 -0
- package/src/internal/builtin-plugins/solidity/index.ts +1 -0
- package/src/internal/builtin-plugins/solidity/solidity-hooks.ts +53 -0
- package/src/internal/builtin-plugins/solidity/type-extensions.ts +258 -31
- package/src/internal/builtin-plugins/solidity-test/edr-artifacts.ts +22 -10
- package/src/internal/builtin-plugins/solidity-test/formatters.ts +1 -213
- package/src/internal/builtin-plugins/solidity-test/helpers.ts +8 -8
- package/src/internal/builtin-plugins/solidity-test/index.ts +0 -7
- package/src/internal/builtin-plugins/solidity-test/inline-config/constants.ts +21 -0
- package/src/internal/builtin-plugins/solidity-test/inline-config/helpers.ts +99 -0
- package/src/internal/builtin-plugins/solidity-test/inline-config/index.ts +272 -0
- package/src/internal/builtin-plugins/solidity-test/inline-config/parsing.ts +186 -0
- package/src/internal/builtin-plugins/solidity-test/inline-config/types.ts +9 -0
- package/src/internal/builtin-plugins/solidity-test/inline-config/validation.ts +122 -0
- package/src/internal/builtin-plugins/solidity-test/reporter.ts +6 -6
- package/src/internal/builtin-plugins/solidity-test/task-action.ts +42 -25
- package/src/internal/builtin-plugins/test/index.ts +0 -7
- package/src/internal/builtin-plugins/test/task-action.ts +1 -6
- package/src/internal/cli/help/get-help-string.ts +2 -2
- package/src/internal/cli/init/init.ts +1 -1
- package/src/internal/cli/init/prompt.ts +1 -14
- package/src/internal/core/hre.ts +33 -0
- package/src/internal/core/plugins/detect-plugin-npm-dependency-problems.ts +8 -1
- package/src/internal/core/user-interruptions.ts +3 -5
- package/src/internal/utils/colorizer.ts +9 -0
- package/src/internal/utils/package.ts +1 -2
- package/src/types/global-options.ts +1 -0
- package/src/types/hooks.ts +37 -0
- package/src/types/solidity/compilation-job.ts +5 -5
- package/src/types/solidity/solidity-artifacts.ts +16 -0
- package/templates/hardhat-3/01-node-test-runner-viem/package.json +5 -5
- package/templates/hardhat-3/02-mocha-ethers/package.json +11 -11
- package/templates/hardhat-3/03-minimal/package.json +1 -1
|
@@ -8,13 +8,20 @@ import { numberToHexString } from "@nomicfoundation/hardhat-utils/hex";
|
|
|
8
8
|
|
|
9
9
|
import { isHttpNetworkHdAccountsConfig } from "../type-validation.js";
|
|
10
10
|
|
|
11
|
+
import { AutomaticSenderHandler } from "./handlers/accounts/automatic-sender-handler.js";
|
|
12
|
+
import { FixedSenderHandler } from "./handlers/accounts/fixed-sender-handler.js";
|
|
13
|
+
import { HDWalletHandler } from "./handlers/accounts/hd-wallet-handler.js";
|
|
14
|
+
import { LocalAccountsHandler } from "./handlers/accounts/local-accounts.js";
|
|
15
|
+
import { ChainIdValidatorHandler } from "./handlers/chain-id/chain-id-handler.js";
|
|
16
|
+
import { AutomaticGasHandler } from "./handlers/gas/automatic-gas-handler.js";
|
|
17
|
+
import { AutomaticGasPriceHandler } from "./handlers/gas/automatic-gas-price-handler.js";
|
|
18
|
+
import { FixedGasHandler } from "./handlers/gas/fixed-gas-handler.js";
|
|
19
|
+
import { FixedGasPriceHandler } from "./handlers/gas/fixed-gas-price-handler.js";
|
|
20
|
+
|
|
11
21
|
/**
|
|
12
22
|
* This function returns an handlers array based on the values in the NetworkConnection and NetworkConfig.
|
|
13
23
|
* The order of the handlers, if all are present, is: chain handler, gas handlers (gasPrice first, then gas), sender handler and accounts handler.
|
|
14
24
|
* The order is important to get a correct result when the handlers are executed.
|
|
15
|
-
* The handlers are imported dynamically because some might take a long time to load.
|
|
16
|
-
* Out of the currently supported handlers, LocalAccountsHandler and, consequently, HDWalletHandler have been identified as the most expensive.
|
|
17
|
-
* See https://github.com/NomicFoundation/hardhat/pull/6481 for more details.
|
|
18
25
|
*/
|
|
19
26
|
export async function createHandlersArray<
|
|
20
27
|
ChainTypeT extends ChainType | string,
|
|
@@ -24,9 +31,6 @@ export async function createHandlersArray<
|
|
|
24
31
|
const networkConfig = networkConnection.networkConfig;
|
|
25
32
|
|
|
26
33
|
if (networkConfig.type === "http" && networkConfig.chainId !== undefined) {
|
|
27
|
-
const { ChainIdValidatorHandler } = await import(
|
|
28
|
-
"./handlers/chain-id/chain-id-handler.js"
|
|
29
|
-
);
|
|
30
34
|
requestHandlers.push(
|
|
31
35
|
new ChainIdValidatorHandler(
|
|
32
36
|
networkConnection.provider,
|
|
@@ -39,9 +43,6 @@ export async function createHandlersArray<
|
|
|
39
43
|
networkConfig.gasPrice === undefined ||
|
|
40
44
|
networkConfig.gasPrice === "auto"
|
|
41
45
|
) {
|
|
42
|
-
const { AutomaticGasPriceHandler } = await import(
|
|
43
|
-
"./handlers/gas/automatic-gas-price-handler.js"
|
|
44
|
-
);
|
|
45
46
|
// If you use a hook handler that signs locally, you are required to
|
|
46
47
|
// have all the transaction fields available, including the
|
|
47
48
|
// gasPrice / maxFeePerGas & maxPriorityFeePerGas.
|
|
@@ -56,18 +57,12 @@ export async function createHandlersArray<
|
|
|
56
57
|
new AutomaticGasPriceHandler(networkConnection.provider),
|
|
57
58
|
);
|
|
58
59
|
} else {
|
|
59
|
-
const { FixedGasPriceHandler } = await import(
|
|
60
|
-
"./handlers/gas/fixed-gas-price-handler.js"
|
|
61
|
-
);
|
|
62
60
|
requestHandlers.push(
|
|
63
61
|
new FixedGasPriceHandler(numberToHexString(networkConfig.gasPrice)),
|
|
64
62
|
);
|
|
65
63
|
}
|
|
66
64
|
|
|
67
65
|
if (networkConfig.gas === undefined || networkConfig.gas === "auto") {
|
|
68
|
-
const { AutomaticGasHandler } = await import(
|
|
69
|
-
"./handlers/gas/automatic-gas-handler.js"
|
|
70
|
-
);
|
|
71
66
|
requestHandlers.push(
|
|
72
67
|
new AutomaticGasHandler(
|
|
73
68
|
networkConnection.provider,
|
|
@@ -75,25 +70,16 @@ export async function createHandlersArray<
|
|
|
75
70
|
),
|
|
76
71
|
);
|
|
77
72
|
} else {
|
|
78
|
-
const { FixedGasHandler } = await import(
|
|
79
|
-
"./handlers/gas/fixed-gas-handler.js"
|
|
80
|
-
);
|
|
81
73
|
requestHandlers.push(
|
|
82
74
|
new FixedGasHandler(numberToHexString(networkConfig.gas)),
|
|
83
75
|
);
|
|
84
76
|
}
|
|
85
77
|
|
|
86
78
|
if (networkConfig.from === undefined) {
|
|
87
|
-
const { AutomaticSenderHandler } = await import(
|
|
88
|
-
"./handlers/accounts/automatic-sender-handler.js"
|
|
89
|
-
);
|
|
90
79
|
requestHandlers.push(
|
|
91
80
|
new AutomaticSenderHandler(networkConnection.provider),
|
|
92
81
|
);
|
|
93
82
|
} else {
|
|
94
|
-
const { FixedSenderHandler } = await import(
|
|
95
|
-
"./handlers/accounts/fixed-sender-handler.js"
|
|
96
|
-
);
|
|
97
83
|
requestHandlers.push(
|
|
98
84
|
new FixedSenderHandler(networkConnection.provider, networkConfig.from),
|
|
99
85
|
);
|
|
@@ -103,9 +89,6 @@ export async function createHandlersArray<
|
|
|
103
89
|
const accounts = networkConfig.accounts;
|
|
104
90
|
|
|
105
91
|
if (Array.isArray(accounts)) {
|
|
106
|
-
const { LocalAccountsHandler } = await import(
|
|
107
|
-
"./handlers/accounts/local-accounts.js"
|
|
108
|
-
);
|
|
109
92
|
const resolvedAccounts = await Promise.all(
|
|
110
93
|
accounts.map((acc) => acc.getHexString()),
|
|
111
94
|
);
|
|
@@ -114,9 +97,6 @@ export async function createHandlersArray<
|
|
|
114
97
|
new LocalAccountsHandler(networkConnection.provider, resolvedAccounts),
|
|
115
98
|
);
|
|
116
99
|
} else if (isHttpNetworkHdAccountsConfig(accounts)) {
|
|
117
|
-
const { HDWalletHandler } = await import(
|
|
118
|
-
"./handlers/accounts/hd-wallet-handler.js"
|
|
119
|
-
);
|
|
120
100
|
const hdWalletHandler = await HDWalletHandler.create(
|
|
121
101
|
networkConnection.provider,
|
|
122
102
|
await accounts.mnemonic.get(),
|
|
@@ -2,6 +2,7 @@ import type { FSWatcher } from "chokidar";
|
|
|
2
2
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
|
|
5
|
+
import { watch } from "chokidar";
|
|
5
6
|
import debug from "debug";
|
|
6
7
|
|
|
7
8
|
export type BuildInfoWatcher = FSWatcher;
|
|
@@ -59,8 +60,6 @@ export async function watchBuildInfo(
|
|
|
59
60
|
buildInfoDirPath: string,
|
|
60
61
|
handler: BuildInfoHandler,
|
|
61
62
|
): Promise<BuildInfoWatcher> {
|
|
62
|
-
const { watch } = await import("chokidar");
|
|
63
|
-
|
|
64
63
|
// NOTE: Deleting the build info directory while it is being watched will
|
|
65
64
|
// effectively cause the watcher to stop working.
|
|
66
65
|
// NOTE: We use chokidar's `awaitWriteFinish` option because we are certain
|
|
@@ -2,6 +2,7 @@ import type { BuildInfo } from "../../../types/artifacts.js";
|
|
|
2
2
|
import type { EdrNetworkAccountsConfig } from "../../../types/config.js";
|
|
3
3
|
import type { SolidityBuildInfoOutput } from "../../../types/solidity.js";
|
|
4
4
|
import type { EdrProvider } from "../network-manager/edr/edr-provider.js";
|
|
5
|
+
import type * as MicroEthSignerT from "micro-eth-signer";
|
|
5
6
|
|
|
6
7
|
import path from "node:path";
|
|
7
8
|
|
|
@@ -11,7 +12,9 @@ import {
|
|
|
11
12
|
} from "@nomicfoundation/hardhat-utils/fs";
|
|
12
13
|
import { hexStringToBytes } from "@nomicfoundation/hardhat-utils/hex";
|
|
13
14
|
import chalk from "chalk";
|
|
14
|
-
|
|
15
|
+
|
|
16
|
+
// micro-eth-signer is known to be slow to load, so we lazy load it
|
|
17
|
+
let microEthSigner: typeof MicroEthSignerT | undefined;
|
|
15
18
|
|
|
16
19
|
import { sendErrorTelemetry } from "../../cli/telemetry/sentry/reporter.js";
|
|
17
20
|
import { isDefaultEdrNetworkHDAccountsConfig } from "../network-manager/edr/edr-provider.js";
|
|
@@ -48,8 +51,12 @@ export async function formatEdrNetworkConfigAccounts(
|
|
|
48
51
|
maxPrefixLength = privateKeyPrefix.length;
|
|
49
52
|
}
|
|
50
53
|
|
|
54
|
+
if (microEthSigner === undefined) {
|
|
55
|
+
microEthSigner = await import("micro-eth-signer");
|
|
56
|
+
}
|
|
57
|
+
|
|
51
58
|
for (const [index, account] of accounts.entries()) {
|
|
52
|
-
const address = addr
|
|
59
|
+
const address = microEthSigner.addr
|
|
53
60
|
.fromPrivateKey(hexStringToBytes(await account.privateKey.getHexString()))
|
|
54
61
|
.toLowerCase();
|
|
55
62
|
const balance = (BigInt(account.balance) / 10n ** 18n).toString(10);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Artifact
|
|
1
|
+
import type { Artifact } from "../../../../types/artifacts.js";
|
|
2
2
|
import type { CompilationJob } from "../../../../types/solidity/compilation-job.js";
|
|
3
3
|
import type {
|
|
4
4
|
CompilerOutput,
|
|
@@ -107,11 +107,16 @@ declare module "hardhat/types/artifacts" {
|
|
|
107
107
|
export async function getBuildInfo(
|
|
108
108
|
compilationJob: CompilationJob,
|
|
109
109
|
): Promise<SolidityBuildInfo> {
|
|
110
|
-
|
|
110
|
+
// Defaulting to "solc" is safe here: if it's already "solc" or undefined,
|
|
111
|
+
// this doesn't alter the build info id.
|
|
112
|
+
const compilerType = compilationJob.solcConfig.type ?? "solc";
|
|
113
|
+
|
|
114
|
+
const buildInfo: SolidityBuildInfo = {
|
|
111
115
|
_format: "hh3-sol-build-info-1",
|
|
112
116
|
id: await compilationJob.getBuildId(),
|
|
113
117
|
solcVersion: compilationJob.solcConfig.version,
|
|
114
118
|
solcLongVersion: compilationJob.solcLongVersion,
|
|
119
|
+
compilerType,
|
|
115
120
|
userSourceNameMap:
|
|
116
121
|
compilationJob.dependencyGraph.getRootsUserSourceNameMap(),
|
|
117
122
|
input: await compilationJob.getSolcInput(),
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { CompileCache } from "./cache.js";
|
|
2
2
|
import type { DependencyGraphImplementation } from "./dependency-graph.js";
|
|
3
3
|
import type { Artifact } from "../../../../types/artifacts.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
SolidityCompilerConfig,
|
|
6
|
+
SolcSolidityCompilerConfig,
|
|
7
|
+
SolidityConfig,
|
|
8
|
+
} from "../../../../types/config.js";
|
|
5
9
|
import type { HookManager } from "../../../../types/hooks.js";
|
|
6
10
|
import type {
|
|
7
11
|
SolidityBuildSystem,
|
|
@@ -54,6 +58,7 @@ import pMap from "p-map";
|
|
|
54
58
|
|
|
55
59
|
import { FileBuildResultType } from "../../../../types/solidity/build-system.js";
|
|
56
60
|
import { DEFAULT_BUILD_PROFILE } from "../build-profiles.js";
|
|
61
|
+
import { getSolcCompilerForConfig } from "../solidity-hooks.js";
|
|
57
62
|
|
|
58
63
|
import {
|
|
59
64
|
getArtifactsDeclarationFile,
|
|
@@ -79,14 +84,12 @@ import { shouldSuppressWarning } from "./warning-suppression.js";
|
|
|
79
84
|
const log = debug("hardhat:core:solidity:build-system");
|
|
80
85
|
|
|
81
86
|
/**
|
|
82
|
-
*
|
|
83
|
-
* to the build profile's preferWasm if not set on the compiler.
|
|
87
|
+
* Returns true if the given compiler config is a SolcSolidityCompilerConfig.
|
|
84
88
|
*/
|
|
85
|
-
function
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return solcConfig.preferWasm ?? buildProfilePreferWasm;
|
|
89
|
+
export function isSolcSolidityCompilerConfig(
|
|
90
|
+
config: SolidityCompilerConfig,
|
|
91
|
+
): config is SolcSolidityCompilerConfig {
|
|
92
|
+
return config.type === undefined || config.type === "solc";
|
|
90
93
|
}
|
|
91
94
|
|
|
92
95
|
// Compiler warnings to suppress from build output.
|
|
@@ -439,7 +442,7 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
439
442
|
);
|
|
440
443
|
|
|
441
444
|
let subgraphsWithConfig: Array<
|
|
442
|
-
[
|
|
445
|
+
[SolidityCompilerConfig, DependencyGraphImplementation]
|
|
443
446
|
> = [];
|
|
444
447
|
for (const [rootFile, resolvedFile] of dependencyGraph.getRoots()) {
|
|
445
448
|
log(
|
|
@@ -459,19 +462,47 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
459
462
|
}
|
|
460
463
|
|
|
461
464
|
// get longVersion and isWasm from the compiler for each version
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
465
|
+
// These maps are keyed by compiler type first, then version, to avoid
|
|
466
|
+
// collisions between different compiler types using the same version string.
|
|
467
|
+
const solidityVersionToLongVersionPerCompilerType = new Map<
|
|
468
|
+
string,
|
|
469
|
+
Map<string, string>
|
|
470
|
+
>();
|
|
471
|
+
const versionIsWasmPerCompilerType = new Map<
|
|
472
|
+
string,
|
|
473
|
+
Map<string, boolean>
|
|
474
|
+
>();
|
|
475
|
+
for (const [compilerConfig] of subgraphsWithConfig) {
|
|
476
|
+
const compilerType = compilerConfig.type ?? "solc";
|
|
477
|
+
let longVersionMap =
|
|
478
|
+
solidityVersionToLongVersionPerCompilerType.get(compilerType);
|
|
479
|
+
if (longVersionMap === undefined) {
|
|
480
|
+
longVersionMap = new Map();
|
|
481
|
+
solidityVersionToLongVersionPerCompilerType.set(
|
|
482
|
+
compilerType,
|
|
483
|
+
longVersionMap,
|
|
484
|
+
);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
let isWasmMap = versionIsWasmPerCompilerType.get(compilerType);
|
|
488
|
+
if (isWasmMap === undefined) {
|
|
489
|
+
isWasmMap = new Map();
|
|
490
|
+
versionIsWasmPerCompilerType.set(compilerType, isWasmMap);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
let longVersion = longVersionMap.get(compilerConfig.version);
|
|
494
|
+
|
|
495
|
+
if (longVersion === undefined) {
|
|
496
|
+
const compiler = await this.#hooks.runHandlerChain(
|
|
497
|
+
"solidity",
|
|
498
|
+
"getCompiler",
|
|
499
|
+
[compilerConfig],
|
|
500
|
+
async (_context, cfg) =>
|
|
501
|
+
getSolcCompilerForConfig(cfg, buildProfile.preferWasm),
|
|
502
|
+
);
|
|
503
|
+
longVersion = compiler.longVersion;
|
|
504
|
+
longVersionMap.set(compilerConfig.version, longVersion);
|
|
505
|
+
isWasmMap.set(compilerConfig.version, compiler.isSolcJs);
|
|
475
506
|
}
|
|
476
507
|
}
|
|
477
508
|
|
|
@@ -480,17 +511,26 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
480
511
|
const sharedContentHashes = new Map<string, string>();
|
|
481
512
|
await Promise.all(
|
|
482
513
|
subgraphsWithConfig.map(async ([config, subgraph]) => {
|
|
483
|
-
const
|
|
514
|
+
const compilerType = config.type ?? "solc";
|
|
515
|
+
const longVersionMap =
|
|
516
|
+
solidityVersionToLongVersionPerCompilerType.get(compilerType);
|
|
517
|
+
|
|
518
|
+
assertHardhatInvariant(
|
|
519
|
+
longVersionMap !== undefined,
|
|
520
|
+
`No long version map for compiler type ${compilerType}`,
|
|
521
|
+
);
|
|
522
|
+
|
|
523
|
+
const longVersion = longVersionMap.get(config.version);
|
|
484
524
|
|
|
485
525
|
assertHardhatInvariant(
|
|
486
|
-
|
|
487
|
-
"
|
|
526
|
+
longVersion !== undefined,
|
|
527
|
+
"longVersion should not be undefined",
|
|
488
528
|
);
|
|
489
529
|
|
|
490
530
|
const individualJob = new CompilationJobImplementation(
|
|
491
531
|
subgraph,
|
|
492
532
|
config,
|
|
493
|
-
|
|
533
|
+
longVersion,
|
|
494
534
|
this.#hooks,
|
|
495
535
|
sharedContentHashes,
|
|
496
536
|
);
|
|
@@ -516,7 +556,15 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
516
556
|
for (const [rootFile, compilationJob] of indexedIndividualJobs.entries()) {
|
|
517
557
|
const jobHash = await compilationJob.getBuildId();
|
|
518
558
|
const cacheResult = this.#compileCache[rootFile];
|
|
519
|
-
const
|
|
559
|
+
const compilerType = compilationJob.solcConfig.type ?? "solc";
|
|
560
|
+
const isWasmMap = versionIsWasmPerCompilerType.get(compilerType);
|
|
561
|
+
|
|
562
|
+
assertHardhatInvariant(
|
|
563
|
+
isWasmMap !== undefined,
|
|
564
|
+
`No isWasm map for compiler type ${compilerType}`,
|
|
565
|
+
);
|
|
566
|
+
|
|
567
|
+
const isWasm = isWasmMap.get(compilationJob.solcConfig.version);
|
|
520
568
|
|
|
521
569
|
assertHardhatInvariant(
|
|
522
570
|
isWasm !== undefined,
|
|
@@ -529,6 +577,7 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
529
577
|
cacheResult === undefined ||
|
|
530
578
|
cacheResult.jobHash !== jobHash ||
|
|
531
579
|
cacheResult.isolated !== isolated ||
|
|
580
|
+
cacheResult.compilerType !== compilerType ||
|
|
532
581
|
cacheResult.wasm !== isWasm
|
|
533
582
|
) {
|
|
534
583
|
rootFilesToCompile.add(rootFile);
|
|
@@ -576,13 +625,15 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
576
625
|
log(`Merging compilation jobs`);
|
|
577
626
|
|
|
578
627
|
const mergedSubgraphsByConfig: Map<
|
|
579
|
-
|
|
628
|
+
SolidityCompilerConfig,
|
|
580
629
|
DependencyGraphImplementation
|
|
581
630
|
> = new Map();
|
|
582
631
|
|
|
583
|
-
// Note: This groups the subgraphs by
|
|
584
|
-
// based on reference, and not by deep equality.
|
|
585
|
-
//
|
|
632
|
+
// Note: This groups the subgraphs by compiler config. It compares the
|
|
633
|
+
// configs based on reference, and not by deep equality. This is
|
|
634
|
+
// inherently type-aware: two configs with different types will always be
|
|
635
|
+
// different references. It misses some merging opportunities, but this is
|
|
636
|
+
// Hardhat v2's behavior and works well enough.
|
|
586
637
|
for (const [config, subgraph] of subgraphsWithConfig) {
|
|
587
638
|
const rootFile = getSingleRootFilePath(subgraph);
|
|
588
639
|
|
|
@@ -613,18 +664,27 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
613
664
|
}
|
|
614
665
|
|
|
615
666
|
const compilationJobsPerFile = new Map<string, CompilationJob>();
|
|
616
|
-
for (const [
|
|
617
|
-
const
|
|
667
|
+
for (const [compilerConfig, subgraph] of subgraphsWithConfig) {
|
|
668
|
+
const compilerType = compilerConfig.type ?? "solc";
|
|
669
|
+
const longVersionMap =
|
|
670
|
+
solidityVersionToLongVersionPerCompilerType.get(compilerType);
|
|
618
671
|
|
|
619
672
|
assertHardhatInvariant(
|
|
620
|
-
|
|
621
|
-
|
|
673
|
+
longVersionMap !== undefined,
|
|
674
|
+
`No long version map for compiler type ${compilerType}`,
|
|
675
|
+
);
|
|
676
|
+
|
|
677
|
+
const longVersion = longVersionMap.get(compilerConfig.version);
|
|
678
|
+
|
|
679
|
+
assertHardhatInvariant(
|
|
680
|
+
longVersion !== undefined,
|
|
681
|
+
"longVersion should not be undefined",
|
|
622
682
|
);
|
|
623
683
|
|
|
624
684
|
const runnableCompilationJob = new CompilationJobImplementation(
|
|
625
685
|
subgraph,
|
|
626
|
-
|
|
627
|
-
|
|
686
|
+
compilerConfig,
|
|
687
|
+
longVersion,
|
|
628
688
|
this.#hooks,
|
|
629
689
|
sharedContentHashes,
|
|
630
690
|
);
|
|
@@ -677,19 +737,16 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
677
737
|
|
|
678
738
|
const { buildProfile } = this.#getBuildProfile(options?.buildProfile);
|
|
679
739
|
|
|
680
|
-
const compiler = await
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
),
|
|
687
|
-
compilerPath: runnableCompilationJob.solcConfig.path,
|
|
688
|
-
},
|
|
740
|
+
const compiler = await this.#hooks.runHandlerChain(
|
|
741
|
+
"solidity",
|
|
742
|
+
"getCompiler",
|
|
743
|
+
[runnableCompilationJob.solcConfig],
|
|
744
|
+
async (_context, cfg) =>
|
|
745
|
+
getSolcCompilerForConfig(cfg, buildProfile.preferWasm),
|
|
689
746
|
);
|
|
690
747
|
|
|
691
748
|
log(
|
|
692
|
-
`Compiling ${numberOfRootFiles} root files and ${numberOfFiles - numberOfRootFiles} dependency files with solc ${runnableCompilationJob.solcConfig.version} using ${compiler.compilerPath}`,
|
|
749
|
+
`Compiling ${numberOfRootFiles} root files and ${numberOfFiles - numberOfRootFiles} dependency files with ${runnableCompilationJob.solcConfig.type ?? "solc"} ${runnableCompilationJob.solcConfig.version} using ${compiler.compilerPath}`,
|
|
693
750
|
);
|
|
694
751
|
|
|
695
752
|
assertHardhatInvariant(
|
|
@@ -1016,8 +1073,10 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
1016
1073
|
): Promise<CompilerOutput> {
|
|
1017
1074
|
const quiet = options?.quiet ?? false;
|
|
1018
1075
|
|
|
1019
|
-
//
|
|
1020
|
-
//
|
|
1076
|
+
// Build info recompilation is always solc-only: build info files are
|
|
1077
|
+
// produced by solc and must be recompiled with the same solc version.
|
|
1078
|
+
// We bypass both downloadCompilers and getCompiler hooks — this is a
|
|
1079
|
+
// self-contained solc replay path, not plugin-configurable compilation.
|
|
1021
1080
|
await downloadSolcCompilers(new Set([buildInfo.solcVersion]), quiet);
|
|
1022
1081
|
|
|
1023
1082
|
const compiler = await getCompiler(buildInfo.solcVersion, {
|
|
@@ -1034,20 +1093,17 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
1034
1093
|
return;
|
|
1035
1094
|
}
|
|
1036
1095
|
|
|
1037
|
-
|
|
1096
|
+
const allSolidityCompilerConfigs = this.#getAllSolidityCompilerConfigs();
|
|
1097
|
+
await this.#hooks.runParallelHandlers("solidity", "downloadCompilers", [
|
|
1098
|
+
allSolidityCompilerConfigs,
|
|
1099
|
+
quiet,
|
|
1100
|
+
]);
|
|
1038
1101
|
this.#configuredCompilersDownloaded = true;
|
|
1039
1102
|
}
|
|
1040
1103
|
|
|
1041
|
-
#
|
|
1042
|
-
return
|
|
1043
|
-
Object.values(
|
|
1044
|
-
.map((profile) => [
|
|
1045
|
-
...profile.compilers.map((compiler) => compiler.version),
|
|
1046
|
-
...Object.values(profile.overrides).map(
|
|
1047
|
-
(override) => override.version,
|
|
1048
|
-
),
|
|
1049
|
-
])
|
|
1050
|
-
.flat(1),
|
|
1104
|
+
#getAllSolidityCompilerConfigs(): SolidityCompilerConfig[] {
|
|
1105
|
+
return Object.values(this.#options.solidityConfig.profiles).flatMap(
|
|
1106
|
+
(profile) => [...profile.compilers, ...Object.values(profile.overrides)],
|
|
1051
1107
|
);
|
|
1052
1108
|
}
|
|
1053
1109
|
|
|
@@ -1124,6 +1180,7 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
1124
1180
|
this.#compileCache[rootFilePath] = {
|
|
1125
1181
|
jobHash,
|
|
1126
1182
|
isolated,
|
|
1183
|
+
compilerType: individualJob.solcConfig.type ?? "solc",
|
|
1127
1184
|
artifactPaths,
|
|
1128
1185
|
buildInfoPath: emitArtifactsResult.buildInfoPath,
|
|
1129
1186
|
buildInfoOutputPath: emitArtifactsResult.buildInfoOutputPath,
|
|
@@ -1208,16 +1265,21 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
1208
1265
|
}
|
|
1209
1266
|
|
|
1210
1267
|
for (const job of runnableCompilationJobs) {
|
|
1268
|
+
const compilerType = job.solcConfig.type ?? "solc";
|
|
1211
1269
|
const solcVersion = job.solcConfig.version;
|
|
1212
1270
|
const solcInput = await job.getSolcInput();
|
|
1213
1271
|
const evmVersion =
|
|
1214
1272
|
solcInput.settings.evmVersion ??
|
|
1215
1273
|
`Check solc ${solcVersion}'s doc for its default evm version`;
|
|
1216
1274
|
|
|
1217
|
-
|
|
1275
|
+
// Group by compiler type + Solidity version to produce separate log
|
|
1276
|
+
// lines for e.g. "solc 0.8.33" vs "solx 0.1.3 (Solidity 0.8.33)".
|
|
1277
|
+
const groupKey = `${compilerType}#${solcVersion}`;
|
|
1278
|
+
|
|
1279
|
+
let jobsPerVersion = jobsPerVersionAndEvmVersion.get(groupKey);
|
|
1218
1280
|
if (jobsPerVersion === undefined) {
|
|
1219
1281
|
jobsPerVersion = new Map();
|
|
1220
|
-
jobsPerVersionAndEvmVersion.set(
|
|
1282
|
+
jobsPerVersionAndEvmVersion.set(groupKey, jobsPerVersion);
|
|
1221
1283
|
}
|
|
1222
1284
|
|
|
1223
1285
|
let jobsPerEvmVersion = jobsPerVersion.get(evmVersion);
|
|
@@ -1229,10 +1291,11 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
1229
1291
|
jobsPerEvmVersion.push(job);
|
|
1230
1292
|
}
|
|
1231
1293
|
|
|
1232
|
-
for (const
|
|
1294
|
+
for (const groupKey of [...jobsPerVersionAndEvmVersion.keys()].sort()) {
|
|
1233
1295
|
/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion --
|
|
1234
1296
|
This is a valid key, just sorted */
|
|
1235
|
-
const jobsPerEvmVersion = jobsPerVersionAndEvmVersion.get(
|
|
1297
|
+
const jobsPerEvmVersion = jobsPerVersionAndEvmVersion.get(groupKey)!;
|
|
1298
|
+
const [compilerType, solidityVersion] = groupKey.split("#");
|
|
1236
1299
|
|
|
1237
1300
|
for (const evmVersion of [...jobsPerEvmVersion.keys()].sort()) {
|
|
1238
1301
|
/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion --
|
|
@@ -1244,12 +1307,25 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
1244
1307
|
0,
|
|
1245
1308
|
);
|
|
1246
1309
|
|
|
1310
|
+
// For solc, the compiler version is the Solidity version.
|
|
1311
|
+
// For other compilers, extract the compiler's own version from the
|
|
1312
|
+
// longVersion stored on the compilation job, and show the Solidity
|
|
1313
|
+
// version separately.
|
|
1314
|
+
let compilerLabel: string;
|
|
1315
|
+
if (compilerType === "solc") {
|
|
1316
|
+
compilerLabel = `solc ${solidityVersion}`;
|
|
1317
|
+
} else {
|
|
1318
|
+
const longVersion = jobs[0].solcLongVersion;
|
|
1319
|
+
const compilerVersion = longVersion.split("+")[0];
|
|
1320
|
+
compilerLabel = `${compilerType} ${compilerVersion} (Solidity ${solidityVersion})`;
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1247
1323
|
console.log(
|
|
1248
1324
|
chalk.bold(
|
|
1249
1325
|
`Compiled ${rootFiles} Solidity ${pluralize(
|
|
1250
1326
|
options.scope === "contracts" ? "file" : "test file",
|
|
1251
1327
|
rootFiles,
|
|
1252
|
-
)} with
|
|
1328
|
+
)} with ${compilerLabel}`,
|
|
1253
1329
|
),
|
|
1254
1330
|
`(evm target: ${evmVersion})`,
|
|
1255
1331
|
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DependencyGraphImplementation } from "./dependency-graph.js";
|
|
2
2
|
import type { BuildInfo } from "../../../../types/artifacts.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { SolidityCompilerConfig } from "../../../../types/config.js";
|
|
4
4
|
import type { HookManager } from "../../../../types/hooks.js";
|
|
5
5
|
import type { CompilationJob } from "../../../../types/solidity/compilation-job.js";
|
|
6
6
|
import type { CompilerInput } from "../../../../types/solidity/compiler-io.js";
|
|
@@ -21,7 +21,7 @@ import { getEvmVersionFromSolcVersion } from "./solc-info.js";
|
|
|
21
21
|
|
|
22
22
|
export class CompilationJobImplementation implements CompilationJob {
|
|
23
23
|
public readonly dependencyGraph: DependencyGraph;
|
|
24
|
-
public readonly solcConfig:
|
|
24
|
+
public readonly solcConfig: SolidityCompilerConfig;
|
|
25
25
|
public readonly solcLongVersion: string;
|
|
26
26
|
|
|
27
27
|
readonly #hooks: HookManager;
|
|
@@ -34,7 +34,7 @@ export class CompilationJobImplementation implements CompilationJob {
|
|
|
34
34
|
|
|
35
35
|
constructor(
|
|
36
36
|
dependencyGraph: DependencyGraphImplementation,
|
|
37
|
-
solcConfig:
|
|
37
|
+
solcConfig: SolidityCompilerConfig,
|
|
38
38
|
solcLongVersion: string,
|
|
39
39
|
hooks: HookManager,
|
|
40
40
|
sharedContentHashes: Map<string, string> = new Map(),
|
|
@@ -236,17 +236,44 @@ export class CompilationJobImplementation implements CompilationJob {
|
|
|
236
236
|
// Changing this shouldn't be taken lightly, as it makes reproducing
|
|
237
237
|
// builds pretty difficult when upgrading Hardhat between versions that
|
|
238
238
|
// change it.
|
|
239
|
-
|
|
239
|
+
|
|
240
|
+
const compilerType = this.solcConfig.type;
|
|
241
|
+
|
|
242
|
+
// We normalize solcConfig.type to `undefined` so that "solc" and undefined
|
|
243
|
+
// produce the same hash, for backwards compatibility.
|
|
244
|
+
const normalizedSolcConfig = { ...this.solcConfig, type: undefined };
|
|
245
|
+
|
|
246
|
+
const preimageObject: Record<string, unknown> = {
|
|
240
247
|
format,
|
|
241
248
|
solcLongVersion: this.solcLongVersion,
|
|
242
249
|
smallerSolcInput,
|
|
243
|
-
solcConfig:
|
|
250
|
+
solcConfig: normalizedSolcConfig,
|
|
244
251
|
userSourceNameMap: this.dependencyGraph.getRootsUserSourceNameMap(),
|
|
245
|
-
}
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
// Include compiler type in the preimage for non-solc types, so that
|
|
255
|
+
// different compiler types produce different build IDs.
|
|
256
|
+
if (compilerType !== undefined && compilerType !== "solc") {
|
|
257
|
+
preimageObject.compilerType = compilerType;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
const preimage = JSON.stringify(preimageObject);
|
|
246
261
|
|
|
247
262
|
const jobHash = await createNonCryptographicHashId(preimage);
|
|
248
263
|
|
|
249
|
-
|
|
264
|
+
const versionPart = this.solcConfig.version.replaceAll(".", "_");
|
|
265
|
+
|
|
266
|
+
// For non-solc compiler types, include the compiler type in the build ID.
|
|
267
|
+
// We keep the `solc-` prefix for all types to avoid breaking codepaths
|
|
268
|
+
// that look for it.
|
|
269
|
+
if (compilerType !== undefined && compilerType !== "solc") {
|
|
270
|
+
/* eslint-disable-next-line @typescript-eslint/restrict-template-expressions --
|
|
271
|
+
compilerType is `never` in the base type system (only "solc" is registered),
|
|
272
|
+
but plugins can extend SolidityCompilerConfigPerType to add new compiler types. */
|
|
273
|
+
return `solc-${versionPart}-${compilerType}-${jobHash}`;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return `solc-${versionPart}-${jobHash}`;
|
|
250
277
|
}
|
|
251
278
|
|
|
252
279
|
#getSourceContentHash(sourceName: string, text: string): any {
|
|
@@ -39,7 +39,7 @@ import * as semver from "semver";
|
|
|
39
39
|
* @throws Error if the compilation process exits with a non-zero exit code.
|
|
40
40
|
* @throws HardhatInvariantError if the any of the io streams are null.
|
|
41
41
|
*/
|
|
42
|
-
async function spawnCompile(
|
|
42
|
+
export async function spawnCompile(
|
|
43
43
|
command: string,
|
|
44
44
|
args: string[],
|
|
45
45
|
input: CompilerInput,
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
import { getPrefixedHexString } from "@nomicfoundation/hardhat-utils/hex";
|
|
26
26
|
import { download } from "@nomicfoundation/hardhat-utils/request";
|
|
27
27
|
import { MultiProcessMutex } from "@nomicfoundation/hardhat-utils/synchronization";
|
|
28
|
+
import AdmZip from "adm-zip";
|
|
28
29
|
import debug from "debug";
|
|
29
30
|
|
|
30
31
|
import { NativeCompiler, SolcJsCompiler } from "./compiler.js";
|
|
@@ -469,8 +470,6 @@ export class CompilerDownloaderImplementation implements CompilerDownloader {
|
|
|
469
470
|
downloadPath.endsWith(".zip")
|
|
470
471
|
) {
|
|
471
472
|
// some window builds are zipped, some are not
|
|
472
|
-
const { default: AdmZip } = await import("adm-zip");
|
|
473
|
-
|
|
474
473
|
const solcFolder = path.join(this.#compilersDir, build.version);
|
|
475
474
|
await ensureDir(solcFolder);
|
|
476
475
|
|