hardhat 3.1.12 → 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 +57 -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/coverage/helpers.d.ts +5 -0
- package/dist/src/internal/builtin-plugins/coverage/helpers.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/helpers.js +12 -0
- package/dist/src/internal/builtin-plugins/coverage/helpers.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/hre.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/hre.js +2 -5
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/hre.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/solidity.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/solidity.js +3 -5
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/solidity.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/test.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/test.js +4 -15
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/test.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/gas-analytics-manager.d.ts +11 -10
- package/dist/src/internal/builtin-plugins/gas-analytics/gas-analytics-manager.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/gas-analytics-manager.js +80 -13
- package/dist/src/internal/builtin-plugins/gas-analytics/gas-analytics-manager.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers.d.ts +5 -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 +25 -3
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/hre.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/hre.js +4 -5
- package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/hre.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/test.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/test.js +13 -17
- package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/test.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/index.js +8 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/type-extensions.d.ts +1 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/type-extensions.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/types.d.ts +33 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/types.d.ts.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 +2 -2
- 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 +78 -8
- 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/node/json-rpc/handler.js +7 -2
- package/dist/src/internal/builtin-plugins/node/json-rpc/handler.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 -2
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/index.d.ts +10 -0
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/index.js +29 -6
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/index.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/build-system/solc-info.d.ts +6 -0
- package/dist/src/internal/builtin-plugins/solidity/build-system/solc-info.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/solc-info.js +11 -0
- package/dist/src/internal/builtin-plugins/solidity/build-system/solc-info.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 +249 -64
- 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 +30 -20
- 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 +27 -13
- 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/network.d.ts +1 -1
- package/dist/src/types/network.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 +7 -6
- package/src/internal/builtin-global-options.ts +15 -1
- package/src/internal/builtin-plugins/coverage/helpers.ts +31 -0
- package/src/internal/builtin-plugins/coverage/hook-handlers/hre.ts +2 -10
- package/src/internal/builtin-plugins/coverage/hook-handlers/solidity.ts +3 -12
- package/src/internal/builtin-plugins/coverage/hook-handlers/test.ts +4 -25
- package/src/internal/builtin-plugins/gas-analytics/gas-analytics-manager.ts +118 -18
- package/src/internal/builtin-plugins/gas-analytics/helpers.ts +44 -3
- package/src/internal/builtin-plugins/gas-analytics/hook-handlers/hre.ts +6 -10
- package/src/internal/builtin-plugins/gas-analytics/hook-handlers/test.ts +18 -26
- package/src/internal/builtin-plugins/gas-analytics/index.ts +9 -1
- package/src/internal/builtin-plugins/gas-analytics/type-extensions.ts +1 -0
- package/src/internal/builtin-plugins/gas-analytics/types.ts +37 -0
- 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 +112 -12
- 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/node/json-rpc/handler.ts +8 -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 -7
- package/src/internal/builtin-plugins/solidity/build-system/compiler/index.ts +44 -9
- package/src/internal/builtin-plugins/solidity/build-system/solc-config-selection.ts +4 -2
- package/src/internal/builtin-plugins/solidity/build-system/solc-info.ts +15 -0
- package/src/internal/builtin-plugins/solidity/config.ts +337 -105
- 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 +52 -38
- package/src/internal/builtin-plugins/test/index.ts +0 -7
- package/src/internal/builtin-plugins/test/task-action.ts +39 -24
- 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/network.ts +2 -2
- 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 +6 -6
- package/templates/hardhat-3/02-mocha-ethers/package.json +11 -11
- package/templates/hardhat-3/03-minimal/package.json +1 -1
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import type { Colorizer } from "../../../../utils/colorizer.js";
|
|
2
|
+
import type {
|
|
3
|
+
LogTrace,
|
|
4
|
+
CallTrace,
|
|
5
|
+
DecodedTraceParameters,
|
|
6
|
+
} from "@nomicfoundation/edr";
|
|
7
|
+
|
|
8
|
+
import { LogKind, CallKind, IncludeTraces } from "@nomicfoundation/edr";
|
|
9
|
+
import { bytesToHexString } from "@nomicfoundation/hardhat-utils/hex";
|
|
10
|
+
|
|
11
|
+
type NestedArray<T> = Array<T | NestedArray<T>>;
|
|
12
|
+
|
|
13
|
+
export function verbosityToIncludeTraces(verbosity: number): IncludeTraces {
|
|
14
|
+
if (verbosity >= 4) {
|
|
15
|
+
return IncludeTraces.All;
|
|
16
|
+
} else if (verbosity >= 3) {
|
|
17
|
+
return IncludeTraces.Failing;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return IncludeTraces.None;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function formatTraces(
|
|
24
|
+
traces: CallTrace[],
|
|
25
|
+
prefix: string,
|
|
26
|
+
colorizer: Colorizer,
|
|
27
|
+
): string {
|
|
28
|
+
const lines = traces.map((trace) => formatTrace(trace, colorizer));
|
|
29
|
+
const formattedTraces = formatNestedArray(lines, prefix);
|
|
30
|
+
// Remove the trailing newline
|
|
31
|
+
return formattedTraces.slice(0, -1);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function formatInputs(
|
|
35
|
+
inputs: DecodedTraceParameters | Uint8Array,
|
|
36
|
+
color?: (text: string) => string,
|
|
37
|
+
): string | undefined {
|
|
38
|
+
if (inputs instanceof Uint8Array) {
|
|
39
|
+
return inputs.length > 0 ? bytesToHexString(inputs) : undefined;
|
|
40
|
+
} else {
|
|
41
|
+
const formattedName =
|
|
42
|
+
color !== undefined ? color(inputs.name) : inputs.name;
|
|
43
|
+
return `${formattedName}(${inputs.arguments.join(", ")})`;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function formatOutputs(outputs: string | Uint8Array): string | undefined {
|
|
48
|
+
if (outputs instanceof Uint8Array) {
|
|
49
|
+
return outputs.length > 0 ? bytesToHexString(outputs) : undefined;
|
|
50
|
+
} else {
|
|
51
|
+
return outputs;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function formatLog(log: LogTrace, colorizer: Colorizer): string[] {
|
|
56
|
+
const { parameters } = log;
|
|
57
|
+
const tag = colorizer.yellow("[event]");
|
|
58
|
+
const lines = [];
|
|
59
|
+
|
|
60
|
+
if (Array.isArray(parameters)) {
|
|
61
|
+
const hexValues = parameters.map((bytes) => bytesToHexString(bytes));
|
|
62
|
+
const topicCount = hexValues.length - 1;
|
|
63
|
+
|
|
64
|
+
for (let i = 0; i < topicCount; i++) {
|
|
65
|
+
const prefix = i === 0 ? `${tag} topic 0` : ` topic ${i}`;
|
|
66
|
+
lines.push(`${prefix}: ${colorizer.cyan(hexValues[i])}`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (hexValues.length > 0) {
|
|
70
|
+
const dataPrefix = topicCount > 0 ? " data" : `${tag} data`;
|
|
71
|
+
lines.push(
|
|
72
|
+
`${dataPrefix}: ${colorizer.cyan(hexValues[hexValues.length - 1])}`,
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
} else {
|
|
76
|
+
lines.push(
|
|
77
|
+
`${tag} ${parameters.name}(${colorizer.cyan(parameters.arguments.join(", "))})`,
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
return lines;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function formatTrace(
|
|
84
|
+
trace: CallTrace,
|
|
85
|
+
colorizer: Colorizer,
|
|
86
|
+
): NestedArray<string> {
|
|
87
|
+
const {
|
|
88
|
+
success,
|
|
89
|
+
address,
|
|
90
|
+
contract,
|
|
91
|
+
inputs,
|
|
92
|
+
gasUsed,
|
|
93
|
+
value,
|
|
94
|
+
kind,
|
|
95
|
+
isCheatcode,
|
|
96
|
+
outputs,
|
|
97
|
+
} = trace;
|
|
98
|
+
let color;
|
|
99
|
+
if (isCheatcode) {
|
|
100
|
+
color = colorizer.blue;
|
|
101
|
+
} else if (success) {
|
|
102
|
+
color = colorizer.green;
|
|
103
|
+
} else {
|
|
104
|
+
color = colorizer.red;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const formattedInputs = formatInputs(inputs, color);
|
|
108
|
+
const formattedOutputs = formatOutputs(outputs);
|
|
109
|
+
|
|
110
|
+
let openingLine: string;
|
|
111
|
+
let closingLine: string | undefined;
|
|
112
|
+
if (kind === CallKind.Create) {
|
|
113
|
+
openingLine = `[${gasUsed}] ${colorizer.yellow("→ new")} ${contract ?? "<unknown>"}@${address}`;
|
|
114
|
+
// TODO: Uncomment this when the formattedInputs starts containing
|
|
115
|
+
// the address of where the contract was deployed instead of the code.
|
|
116
|
+
// if (formattedInputs !== undefined) {
|
|
117
|
+
// openingLine = `${openingLine}@${formattedInputs}`;
|
|
118
|
+
// }
|
|
119
|
+
} else {
|
|
120
|
+
openingLine = `[${gasUsed}] ${color(contract ?? address)}`;
|
|
121
|
+
if (formattedInputs !== undefined) {
|
|
122
|
+
openingLine = `${openingLine}::${formattedInputs}`;
|
|
123
|
+
}
|
|
124
|
+
if (value !== 0n) {
|
|
125
|
+
openingLine = `${openingLine} {value: ${value}}`;
|
|
126
|
+
}
|
|
127
|
+
if (kind === CallKind.StaticCall) {
|
|
128
|
+
openingLine = `${openingLine} ${colorizer.yellow("[staticcall]")}`;
|
|
129
|
+
} else if (kind === CallKind.DelegateCall) {
|
|
130
|
+
openingLine = `${openingLine} ${colorizer.yellow("[delegatecall]")}`;
|
|
131
|
+
} else if (kind === CallKind.CallCode) {
|
|
132
|
+
openingLine = `${openingLine} ${colorizer.yellow("[callcode]")}`;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (formattedOutputs !== undefined) {
|
|
136
|
+
if (
|
|
137
|
+
formattedOutputs === "EvmError: Revert" ||
|
|
138
|
+
formattedOutputs.startsWith("revert:")
|
|
139
|
+
) {
|
|
140
|
+
closingLine = `${color("←")} ${color("[Revert]")} ${formattedOutputs}`;
|
|
141
|
+
} else {
|
|
142
|
+
closingLine = `${color("←")} ${formattedOutputs}`;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const lines = [];
|
|
147
|
+
lines.push(openingLine);
|
|
148
|
+
for (const child of trace.children) {
|
|
149
|
+
if (child.kind === LogKind.Log) {
|
|
150
|
+
lines.push(formatLog(child, colorizer));
|
|
151
|
+
} else {
|
|
152
|
+
lines.push(formatTrace(child, colorizer));
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (closingLine !== undefined) {
|
|
156
|
+
lines.push([closingLine]);
|
|
157
|
+
}
|
|
158
|
+
return lines;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function formatNestedArray(
|
|
162
|
+
data: NestedArray<string>,
|
|
163
|
+
prefix = "",
|
|
164
|
+
isTopLevel = true,
|
|
165
|
+
): string {
|
|
166
|
+
let output = "";
|
|
167
|
+
|
|
168
|
+
for (let i = 0; i < data.length; i++) {
|
|
169
|
+
const item = data[i];
|
|
170
|
+
|
|
171
|
+
if (Array.isArray(item) && typeof item[0] === "string") {
|
|
172
|
+
const [label, ...children] = item;
|
|
173
|
+
|
|
174
|
+
if (isTopLevel) {
|
|
175
|
+
// Blank line between top-level traces
|
|
176
|
+
if (i > 0) {
|
|
177
|
+
output += "\n";
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
output += `${prefix}${label}\n`;
|
|
181
|
+
output += formatNestedArray(children, prefix, false);
|
|
182
|
+
} else {
|
|
183
|
+
const isLast = i === data.length - 1;
|
|
184
|
+
const connector = isLast ? " └─ " : " ├─ ";
|
|
185
|
+
const childPrefix = isLast ? " " : " │ ";
|
|
186
|
+
output += `${prefix}${connector}${label}\n`;
|
|
187
|
+
output += formatNestedArray(children, prefix + childPrefix, false);
|
|
188
|
+
}
|
|
189
|
+
} else if (typeof item === "string") {
|
|
190
|
+
const isLast = i === data.length - 1;
|
|
191
|
+
const connector = isLast ? " └─ " : " ├─ ";
|
|
192
|
+
output += `${prefix}${connector}${item}\n`;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return output;
|
|
197
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type { Response } from "@nomicfoundation/edr";
|
|
2
|
+
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import debug from "debug";
|
|
5
|
+
|
|
6
|
+
import { formatTraces } from "./trace-formatters.js";
|
|
7
|
+
|
|
8
|
+
const log = debug("hardhat:core:hardhat-network:provider");
|
|
9
|
+
|
|
10
|
+
// Rotating palette for per-connection coloring of trace headers.
|
|
11
|
+
const LABEL_COLORS: Array<(text: string) => string> = [
|
|
12
|
+
chalk.cyan,
|
|
13
|
+
chalk.magenta,
|
|
14
|
+
chalk.blueBright,
|
|
15
|
+
chalk.yellowBright,
|
|
16
|
+
chalk.cyanBright,
|
|
17
|
+
chalk.magentaBright,
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
// Keyed by `network name` (not connection label) so the map stays bounded
|
|
21
|
+
// by the number of distinct networks, not the number of connections.
|
|
22
|
+
const networkColorMap = new Map<string, (text: string) => string>();
|
|
23
|
+
|
|
24
|
+
// These methods run a simulation before the actual transaction. We skip
|
|
25
|
+
// their traces on success to avoid duplicates, but still show them on
|
|
26
|
+
// failure since the real transaction won't be sent.
|
|
27
|
+
const TRACE_SUPPRESSED_METHODS = new Set(["eth_estimateGas"]);
|
|
28
|
+
|
|
29
|
+
// Bounded set: receipt-polling deduplication only needs a small window.
|
|
30
|
+
// Once the cap is reached the set is cleared so memory stays bounded
|
|
31
|
+
// in long-running nodes.
|
|
32
|
+
const TRACED_TX_HASHES_CAP = 1024;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Manages trace output formatting, deduplication, and coloring for a single
|
|
36
|
+
* provider connection.
|
|
37
|
+
*/
|
|
38
|
+
export class TraceOutputManager {
|
|
39
|
+
readonly #printLineFn: (line: string) => void;
|
|
40
|
+
readonly #connectionLabel: string;
|
|
41
|
+
readonly #labelColor: (text: string) => string;
|
|
42
|
+
readonly #verbosity: number;
|
|
43
|
+
readonly #tracedTxHashes = new Set<string>();
|
|
44
|
+
|
|
45
|
+
constructor(
|
|
46
|
+
printLineFn: (line: string) => void,
|
|
47
|
+
connectionId: number,
|
|
48
|
+
networkName: string,
|
|
49
|
+
verbosity: number,
|
|
50
|
+
) {
|
|
51
|
+
this.#printLineFn = printLineFn;
|
|
52
|
+
this.#connectionLabel = `connection #${connectionId} (${networkName})`;
|
|
53
|
+
this.#labelColor = this.#colorForNetwork(networkName);
|
|
54
|
+
this.#verbosity = verbosity;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Output call traces from an EDR response, applying deduplication and
|
|
59
|
+
* suppression rules based on the verbosity level.
|
|
60
|
+
*/
|
|
61
|
+
public outputCallTraces(
|
|
62
|
+
edrResponse: Response,
|
|
63
|
+
method: string,
|
|
64
|
+
txHash: string | undefined,
|
|
65
|
+
failed: boolean,
|
|
66
|
+
): void {
|
|
67
|
+
try {
|
|
68
|
+
// At verbosity < 5, suppress simulation-only methods on success and
|
|
69
|
+
// deduplicate traces for the same transaction. At verbosity >= 5
|
|
70
|
+
// (#showAllTraces), every RPC call with traces is shown.
|
|
71
|
+
|
|
72
|
+
if (this.#verbosity < 5) {
|
|
73
|
+
// Skip successful simulation-only methods, their trace will appear
|
|
74
|
+
// again in the subsequent eth_sendTransaction. Failed simulations
|
|
75
|
+
// are shown because the sendTransaction may never happen.
|
|
76
|
+
if (!failed && TRACE_SUPPRESSED_METHODS.has(method)) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Dedup: skip if we already traced this transaction.
|
|
81
|
+
// Prevents the same tx appearing multiple times from receipt polling.
|
|
82
|
+
if (txHash !== undefined && this.#tracedTxHashes.has(txHash)) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const rawTraces = edrResponse.callTraces();
|
|
88
|
+
|
|
89
|
+
// EDR returns duplicate traces for eth_estimateGas, take only the first.
|
|
90
|
+
const callTraces =
|
|
91
|
+
TRACE_SUPPRESSED_METHODS.has(method) && rawTraces.length > 1
|
|
92
|
+
? [rawTraces[0]]
|
|
93
|
+
: rawTraces;
|
|
94
|
+
|
|
95
|
+
if (callTraces.length === 0) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (txHash !== undefined) {
|
|
100
|
+
if (this.#tracedTxHashes.size >= TRACED_TX_HASHES_CAP) {
|
|
101
|
+
this.#tracedTxHashes.clear();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
this.#tracedTxHashes.add(txHash);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const coloredLabel = this.#labelColor(this.#connectionLabel);
|
|
108
|
+
const prefix = callTraces.length > 1 ? "Traces from" : "Trace from";
|
|
109
|
+
const coloredPrefix = this.#labelColor(prefix);
|
|
110
|
+
const styledMethod = failed ? chalk.red(method) : chalk.dim(method);
|
|
111
|
+
const header = `${coloredPrefix} ${coloredLabel}: ${styledMethod}`;
|
|
112
|
+
|
|
113
|
+
this.#printLineFn(`${header}\n${formatTraces(callTraces, " ", chalk)}`);
|
|
114
|
+
} catch (e) {
|
|
115
|
+
log("Failed to get call traces: %O", e);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Clear the dedup set (e.g. on snapshot revert so replayed txs are traced again).
|
|
121
|
+
*/
|
|
122
|
+
public clearTracedHashes(): void {
|
|
123
|
+
this.#tracedTxHashes.clear();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
#colorForNetwork(networkName: string): (text: string) => string {
|
|
127
|
+
let color = networkColorMap.get(networkName);
|
|
128
|
+
|
|
129
|
+
if (color === undefined) {
|
|
130
|
+
const index = networkColorMap.size % LABEL_COLORS.length;
|
|
131
|
+
color = LABEL_COLORS[index];
|
|
132
|
+
networkColorMap.set(networkName, color);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return color;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
@@ -9,10 +9,10 @@ import type {
|
|
|
9
9
|
} from "../../../../types/providers.js";
|
|
10
10
|
import type { RequestHandler } from "../request-handlers/types.js";
|
|
11
11
|
|
|
12
|
-
import { deepClone } from "@nomicfoundation/hardhat-utils/lang";
|
|
13
12
|
import { AsyncMutex } from "@nomicfoundation/hardhat-utils/synchronization";
|
|
14
13
|
|
|
15
14
|
import { isJsonRpcResponse } from "../json-rpc.js";
|
|
15
|
+
import { createHandlersArray } from "../request-handlers/handlers-array.js";
|
|
16
16
|
|
|
17
17
|
export default async (): Promise<Partial<NetworkHooks>> => {
|
|
18
18
|
// This map is essential for managing multiple network connections in Hardhat V3.
|
|
@@ -38,10 +38,6 @@ export default async (): Promise<Partial<NetworkHooks>> => {
|
|
|
38
38
|
nextJsonRpcRequest: JsonRpcRequest,
|
|
39
39
|
) => Promise<JsonRpcResponse>,
|
|
40
40
|
) {
|
|
41
|
-
const { createHandlersArray } = await import(
|
|
42
|
-
"../request-handlers/handlers-array.js"
|
|
43
|
-
);
|
|
44
|
-
|
|
45
41
|
const requestHandlers = await initializationMutex.exclusiveRun(
|
|
46
42
|
async () => {
|
|
47
43
|
let handlersPerConnection =
|
|
@@ -61,21 +57,22 @@ export default async (): Promise<Partial<NetworkHooks>> => {
|
|
|
61
57
|
},
|
|
62
58
|
);
|
|
63
59
|
|
|
64
|
-
// We
|
|
65
|
-
//
|
|
66
|
-
|
|
60
|
+
// We previously cloned here, but the performance impact is significant.
|
|
61
|
+
// TODO: ensure the passed in request is not mutated by adapting the
|
|
62
|
+
// handlers being applied here. See https://github.com/NomicFoundation/hardhat/issues/8090
|
|
63
|
+
let updatedRequest = jsonRpcRequest;
|
|
67
64
|
|
|
68
65
|
for (const handler of requestHandlers) {
|
|
69
|
-
const newRequestOrResponse = await handler.handle(
|
|
66
|
+
const newRequestOrResponse = await handler.handle(updatedRequest);
|
|
70
67
|
|
|
71
68
|
if (isJsonRpcResponse(newRequestOrResponse)) {
|
|
72
69
|
return newRequestOrResponse;
|
|
73
70
|
}
|
|
74
71
|
|
|
75
|
-
|
|
72
|
+
updatedRequest = newRequestOrResponse;
|
|
76
73
|
}
|
|
77
74
|
|
|
78
|
-
return next(context, networkConnection,
|
|
75
|
+
return next(context, networkConnection, updatedRequest);
|
|
79
76
|
},
|
|
80
77
|
|
|
81
78
|
async closeConnection<ChainTypeT extends ChainType | string>(
|
|
@@ -161,6 +161,7 @@ export class HttpProvider extends BaseProvider {
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
public async close(): Promise<void> {
|
|
164
|
+
this.removeAllListeners();
|
|
164
165
|
if (this.#dispatcher !== undefined) {
|
|
165
166
|
// See https://github.com/nodejs/undici/discussions/3522#discussioncomment-10498734
|
|
166
167
|
await this.#dispatcher.close();
|
|
@@ -21,7 +21,7 @@ import type {
|
|
|
21
21
|
JsonRpcRequest,
|
|
22
22
|
JsonRpcResponse,
|
|
23
23
|
} from "../../../types/providers.js";
|
|
24
|
-
import type { GasReportConfig } from "@nomicfoundation/edr";
|
|
24
|
+
import type { ContractDecoder, GasReportConfig } from "@nomicfoundation/edr";
|
|
25
25
|
|
|
26
26
|
import {
|
|
27
27
|
HardhatError,
|
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
} from "@nomicfoundation/hardhat-errors";
|
|
30
30
|
import { exists, readBinaryFile } from "@nomicfoundation/hardhat-utils/fs";
|
|
31
31
|
import { deepMerge } from "@nomicfoundation/hardhat-utils/lang";
|
|
32
|
+
import { AsyncMutex } from "@nomicfoundation/hardhat-utils/synchronization";
|
|
32
33
|
|
|
33
34
|
import { resolveUserConfigToHardhatConfig } from "../../core/hre.js";
|
|
34
35
|
import { isSupportedChainType } from "../../edr/chain-type.js";
|
|
@@ -37,6 +38,7 @@ import { JsonRpcServerImplementation } from "../node/json-rpc/server.js";
|
|
|
37
38
|
import { EdrProvider } from "./edr/edr-provider.js";
|
|
38
39
|
import { getHardforks } from "./edr/types/hardfork.js";
|
|
39
40
|
import { edrGasReportToHardhatGasMeasurements } from "./edr/utils/convert-to-edr.js";
|
|
41
|
+
import { verbosityToIncludeTraces } from "./edr/utils/trace-formatters.js";
|
|
40
42
|
import { HttpProvider } from "./http-provider.js";
|
|
41
43
|
import { NetworkConnectionImplementation } from "./network-connection.js";
|
|
42
44
|
|
|
@@ -55,8 +57,11 @@ export class NetworkManagerImplementation implements NetworkManager {
|
|
|
55
57
|
readonly #chainDescriptors: Readonly<ChainDescriptorsConfig>;
|
|
56
58
|
readonly #userProvidedConfigPath: Readonly<string | undefined>;
|
|
57
59
|
readonly #projectRoot: string;
|
|
60
|
+
readonly #verbosity: number;
|
|
58
61
|
|
|
59
62
|
#nextConnectionId = 0;
|
|
63
|
+
readonly #contractDecoderMutex = new AsyncMutex();
|
|
64
|
+
#contractDecoder: ContractDecoder | undefined;
|
|
60
65
|
|
|
61
66
|
constructor(
|
|
62
67
|
defaultNetwork: string,
|
|
@@ -68,6 +73,7 @@ export class NetworkManagerImplementation implements NetworkManager {
|
|
|
68
73
|
chainDescriptors: ChainDescriptorsConfig,
|
|
69
74
|
userProvidedConfigPath: string | undefined,
|
|
70
75
|
projectRoot: string,
|
|
76
|
+
verbosity: number,
|
|
71
77
|
) {
|
|
72
78
|
this.#defaultNetwork = defaultNetwork;
|
|
73
79
|
this.#defaultChainType = defaultChainType;
|
|
@@ -78,6 +84,7 @@ export class NetworkManagerImplementation implements NetworkManager {
|
|
|
78
84
|
this.#chainDescriptors = chainDescriptors;
|
|
79
85
|
this.#userProvidedConfigPath = userProvidedConfigPath;
|
|
80
86
|
this.#projectRoot = projectRoot;
|
|
87
|
+
this.#verbosity = verbosity;
|
|
81
88
|
}
|
|
82
89
|
|
|
83
90
|
public async connect<
|
|
@@ -110,11 +117,15 @@ export class NetworkManagerImplementation implements NetworkManager {
|
|
|
110
117
|
return networkConnection as NetworkConnection<ChainTypeT>;
|
|
111
118
|
}
|
|
112
119
|
|
|
113
|
-
public async createServer
|
|
114
|
-
|
|
120
|
+
public async createServer<
|
|
121
|
+
ChainTypeT extends ChainType | string = DefaultChainType,
|
|
122
|
+
>(
|
|
123
|
+
networkOrParams?: NetworkConnectionParams<ChainTypeT> | string,
|
|
115
124
|
_hostname?: string,
|
|
116
125
|
port?: number,
|
|
117
126
|
): Promise<JsonRpcServer> {
|
|
127
|
+
this.#ensureNetworkOrParamsIsNotHttpNetworkConfig(networkOrParams);
|
|
128
|
+
|
|
118
129
|
const insideDocker = await exists("/.dockerenv");
|
|
119
130
|
const hostname = _hostname ?? (insideDocker ? "0.0.0.0" : "127.0.0.1");
|
|
120
131
|
|
|
@@ -229,6 +240,42 @@ export class NetworkManagerImplementation implements NetworkManager {
|
|
|
229
240
|
};
|
|
230
241
|
}
|
|
231
242
|
|
|
243
|
+
// We load the build infos and their outputs to create a contract
|
|
244
|
+
// decoder when the first provider is created. Successive providers will
|
|
245
|
+
// reuse the same decoder as a performance optimization.
|
|
246
|
+
//
|
|
247
|
+
// The trade-off here is that if you create an EDR provider, then
|
|
248
|
+
// compile new contracts, and create a new provider, the new contracts
|
|
249
|
+
// won't be loaded.
|
|
250
|
+
//
|
|
251
|
+
// Even without this optimization, we already had the problem of new
|
|
252
|
+
// contracts not being visible to existing providers.
|
|
253
|
+
//
|
|
254
|
+
// In practice, most workflows compile everything before creating
|
|
255
|
+
// any network connection.
|
|
256
|
+
if (this.#contractDecoder === undefined) {
|
|
257
|
+
// We want to ensure that only one contract decoder is created so we
|
|
258
|
+
// protect the initialization with a mutex.
|
|
259
|
+
await this.#contractDecoderMutex.exclusiveRun(async () => {
|
|
260
|
+
// We check again if the decoder is undefined because another async
|
|
261
|
+
// execution context could have already initialized it while we were
|
|
262
|
+
// waiting for the mutex.
|
|
263
|
+
if (this.#contractDecoder === undefined) {
|
|
264
|
+
this.#contractDecoder = await EdrProvider.createContractDecoder({
|
|
265
|
+
buildInfos: await this.#getBuildInfosAndOutputsAsBuffers(),
|
|
266
|
+
ignoreContracts: false,
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
assertHardhatInvariant(
|
|
273
|
+
this.#contractDecoder !== undefined,
|
|
274
|
+
"Contract decoder should have been initialized before creating the provider",
|
|
275
|
+
);
|
|
276
|
+
|
|
277
|
+
const includeCallTraces = verbosityToIncludeTraces(this.#verbosity);
|
|
278
|
+
|
|
232
279
|
return EdrProvider.create({
|
|
233
280
|
chainDescriptors: this.#chainDescriptors,
|
|
234
281
|
// The resolvedNetworkConfig can have its chainType set to `undefined`
|
|
@@ -245,12 +292,13 @@ export class NetworkManagerImplementation implements NetworkManager {
|
|
|
245
292
|
chainType: resolvedChainType as ChainType,
|
|
246
293
|
},
|
|
247
294
|
jsonRpcRequestWrapper,
|
|
248
|
-
|
|
249
|
-
buildInfos: await this.#getBuildInfosAndOutputsAsBuffers(),
|
|
250
|
-
ignoreContracts: false,
|
|
251
|
-
},
|
|
295
|
+
contractDecoder: this.#contractDecoder,
|
|
252
296
|
coverageConfig,
|
|
253
297
|
gasReportConfig,
|
|
298
|
+
includeCallTraces,
|
|
299
|
+
connectionId: networkConnection.id,
|
|
300
|
+
networkName: networkConnection.networkName,
|
|
301
|
+
verbosity: this.#verbosity,
|
|
254
302
|
});
|
|
255
303
|
}
|
|
256
304
|
|
|
@@ -294,17 +342,32 @@ export class NetworkManagerImplementation implements NetworkManager {
|
|
|
294
342
|
*/
|
|
295
343
|
async #resolveNetworkConfig<ChainTypeT extends ChainType | string>(
|
|
296
344
|
resolvedNetworkName: string,
|
|
297
|
-
networkConfigOverride: NetworkConfigOverride
|
|
345
|
+
networkConfigOverride: NetworkConfigOverride = {},
|
|
298
346
|
resolvedChainType: ChainTypeT,
|
|
299
347
|
): Promise<NetworkConfig> {
|
|
300
348
|
const existingNetworkConfig = this.#networkConfigs[resolvedNetworkName];
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
349
|
+
|
|
350
|
+
const hasNoOverrides = Object.keys(networkConfigOverride).length === 0;
|
|
351
|
+
const isChainTypeUnchanged =
|
|
352
|
+
resolvedChainType === existingNetworkConfig.chainType;
|
|
353
|
+
const isChainTypeDefault =
|
|
354
|
+
existingNetworkConfig.chainType === undefined &&
|
|
355
|
+
resolvedChainType === this.#defaultChainType;
|
|
356
|
+
|
|
357
|
+
if (hasNoOverrides && isChainTypeUnchanged) {
|
|
305
358
|
return existingNetworkConfig;
|
|
306
359
|
}
|
|
307
360
|
|
|
361
|
+
if (hasNoOverrides && isChainTypeDefault) {
|
|
362
|
+
return {
|
|
363
|
+
...existingNetworkConfig,
|
|
364
|
+
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions --
|
|
365
|
+
TypeScript can't follow this case, but we are just providing the
|
|
366
|
+
default */
|
|
367
|
+
chainType: resolvedChainType as ChainType,
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
|
|
308
371
|
if (
|
|
309
372
|
"type" in networkConfigOverride &&
|
|
310
373
|
networkConfigOverride.type !== existingNetworkConfig.type
|
|
@@ -353,6 +416,20 @@ export class NetworkManagerImplementation implements NetworkManager {
|
|
|
353
416
|
);
|
|
354
417
|
|
|
355
418
|
if (!configResolutionResult.success) {
|
|
419
|
+
if (configResolutionResult.configValidationErrors !== undefined) {
|
|
420
|
+
throw new HardhatError(
|
|
421
|
+
HardhatError.ERRORS.CORE.NETWORK.INVALID_CONFIG_OVERRIDE,
|
|
422
|
+
{
|
|
423
|
+
errors: `\t${configResolutionResult.configValidationErrors
|
|
424
|
+
.map(
|
|
425
|
+
(error) =>
|
|
426
|
+
`* Error in resolved config ${error.path.join(".")}: ${error.message}`,
|
|
427
|
+
)
|
|
428
|
+
.join("\n\t")}`,
|
|
429
|
+
},
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
|
|
356
433
|
throw new HardhatError(
|
|
357
434
|
HardhatError.ERRORS.CORE.NETWORK.INVALID_CONFIG_OVERRIDE,
|
|
358
435
|
{
|
|
@@ -434,4 +511,27 @@ export class NetworkManagerImplementation implements NetworkManager {
|
|
|
434
511
|
|
|
435
512
|
return path;
|
|
436
513
|
}
|
|
514
|
+
|
|
515
|
+
#ensureNetworkOrParamsIsNotHttpNetworkConfig(
|
|
516
|
+
networkOrParams?: NetworkConnectionParams<string> | string,
|
|
517
|
+
) {
|
|
518
|
+
const networkName =
|
|
519
|
+
typeof networkOrParams === "string"
|
|
520
|
+
? networkOrParams
|
|
521
|
+
: networkOrParams?.network ?? this.#defaultNetwork;
|
|
522
|
+
|
|
523
|
+
const networkConfig = this.#networkConfigs[networkName];
|
|
524
|
+
|
|
525
|
+
if (networkConfig === undefined || networkConfig.type === "edr-simulated") {
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
throw new HardhatError(
|
|
530
|
+
HardhatError.ERRORS.CORE.NETWORK.CREATE_SERVER_UNSUPPORTED_NETWORK_TYPE,
|
|
531
|
+
{
|
|
532
|
+
networkName,
|
|
533
|
+
networkType: networkConfig.type,
|
|
534
|
+
},
|
|
535
|
+
);
|
|
536
|
+
}
|
|
437
537
|
}
|