hardhat 3.4.1 → 3.4.3
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 +50 -0
- package/dist/src/cli.js +5 -5
- package/dist/src/cli.js.map +1 -1
- package/dist/src/internal/builtin-plugins/artifacts/artifact-manager.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/artifacts/artifact-manager.js +10 -3
- package/dist/src/internal/builtin-plugins/artifacts/artifact-manager.js.map +1 -1
- package/dist/src/internal/builtin-plugins/console/task-action.js +4 -4
- package/dist/src/internal/builtin-plugins/console/task-action.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/coverage-manager.js +7 -7
- package/dist/src/internal/builtin-plugins/coverage/coverage-manager.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/exports.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/coverage/exports.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/exports.js +1 -1
- package/dist/src/internal/builtin-plugins/coverage/exports.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/helpers/accessors.d.ts +7 -0
- package/dist/src/internal/builtin-plugins/coverage/helpers/accessors.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/coverage/helpers/accessors.js +24 -0
- package/dist/src/internal/builtin-plugins/coverage/helpers/accessors.js.map +1 -0
- package/dist/src/internal/builtin-plugins/coverage/helpers/compat.d.ts +4 -0
- package/dist/src/internal/builtin-plugins/coverage/helpers/compat.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/coverage/helpers/compat.js +27 -0
- package/dist/src/internal/builtin-plugins/coverage/helpers/compat.js.map +1 -0
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/clean.js +1 -1
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/clean.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 +18 -15
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/hre.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/solidity.js +3 -3
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/solidity.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/test.js +1 -1
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/test.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/instrumentation.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/instrumentation.js +7 -2
- package/dist/src/internal/builtin-plugins/coverage/instrumentation.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/process-coverage.js +6 -6
- package/dist/src/internal/builtin-plugins/coverage/process-coverage.js.map +1 -1
- package/dist/src/internal/builtin-plugins/flatten/task-action.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/flatten/task-action.js +4 -4
- package/dist/src/internal/builtin-plugins/flatten/task-action.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/function-gas-snapshots.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/function-gas-snapshots.js +10 -10
- package/dist/src/internal/builtin-plugins/gas-analytics/function-gas-snapshots.js.map +1 -1
- 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 +12 -9
- package/dist/src/internal/builtin-plugins/gas-analytics/gas-analytics-manager.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers/accessors.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers/accessors.js +10 -4
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers/accessors.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers/utils.js +2 -2
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers/utils.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 +18 -14
- package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/hre.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.js +11 -16
- package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.js +5 -5
- package/dist/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/config-resolution.js +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/config-resolution.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-constants.d.ts +14 -0
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-constants.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-constants.js +40 -0
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-constants.js.map +1 -0
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.d.ts +1 -12
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js +2 -41
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/types/hardfork.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/types/hardfork.js +2 -5
- package/dist/src/internal/builtin-plugins/network-manager/edr/types/hardfork.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.js +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.d.ts +2 -2
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.js +21 -24
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-output.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-output.js +13 -11
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-output.js.map +1 -1
- package/dist/src/internal/builtin-plugins/node/artifacts/build-info-watcher.js +2 -2
- 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 +2 -1
- package/dist/src/internal/builtin-plugins/node/helpers.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/node/helpers.js +4 -4
- package/dist/src/internal/builtin-plugins/node/helpers.js.map +1 -1
- package/dist/src/internal/builtin-plugins/node/json-rpc/server.js +2 -2
- package/dist/src/internal/builtin-plugins/node/json-rpc/server.js.map +1 -1
- package/dist/src/internal/builtin-plugins/node/task-action.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/node/task-action.js +4 -4
- package/dist/src/internal/builtin-plugins/node/task-action.js.map +1 -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 +68 -29
- package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job-cost.d.ts +8 -0
- package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job-cost.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job-cost.js +46 -0
- package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job-cost.js.map +1 -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 +9 -3
- 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 +2 -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.js +2 -2
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/solcjs-wrapper.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/solcjs-wrapper.js +7 -19
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/solcjs-wrapper.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.js +4 -3
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/utils.d.ts +2 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/utils.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/utils.js +12 -8
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/utils.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/solc-info.d.ts +3 -2
- 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 +15 -6
- 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.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/config.js +2 -2
- package/dist/src/internal/builtin-plugins/solidity/config.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/constants.d.ts +1 -0
- package/dist/src/internal/builtin-plugins/solidity/constants.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/constants.js +2 -0
- package/dist/src/internal/builtin-plugins/solidity/constants.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.js +6 -1
- package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/config.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/config.js +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/config.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.d.ts +1 -2
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.js +3 -3
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/reporter.d.ts +2 -2
- package/dist/src/internal/builtin-plugins/solidity-test/reporter.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/reporter.js +19 -17
- 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.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/task-action.js +6 -3
- package/dist/src/internal/builtin-plugins/solidity-test/task-action.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/type-extensions.d.ts +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/type-extensions.d.ts.map +1 -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 +9 -7
- package/dist/src/internal/builtin-plugins/test/task-action.js.map +1 -1
- package/dist/src/internal/cli/banner-manager.js +2 -2
- package/dist/src/internal/cli/banner-manager.js.map +1 -1
- package/dist/src/internal/cli/error-handler.d.ts.map +1 -1
- package/dist/src/internal/cli/error-handler.js +6 -6
- package/dist/src/internal/cli/error-handler.js.map +1 -1
- package/dist/src/internal/cli/help/get-help-string.js +2 -2
- 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 +57 -36
- package/dist/src/internal/cli/init/init.js.map +1 -1
- package/dist/src/internal/cli/init/package-manager.d.ts.map +1 -1
- package/dist/src/internal/cli/init/package-manager.js +5 -5
- package/dist/src/internal/cli/init/package-manager.js.map +1 -1
- package/dist/src/internal/cli/init/prompt.d.ts.map +1 -1
- package/dist/src/internal/cli/init/prompt.js +3 -3
- package/dist/src/internal/cli/init/prompt.js.map +1 -1
- package/dist/src/internal/cli/init/template.d.ts.map +1 -1
- package/dist/src/internal/cli/init/template.js +5 -14
- package/dist/src/internal/cli/init/template.js.map +1 -1
- package/dist/src/internal/cli/main.d.ts.map +1 -1
- package/dist/src/internal/cli/main.js +2 -2
- package/dist/src/internal/cli/main.js.map +1 -1
- package/dist/src/internal/cli/node-version.d.ts +1 -1
- package/dist/src/internal/cli/node-version.d.ts.map +1 -1
- package/dist/src/internal/cli/node-version.js +17 -10
- package/dist/src/internal/cli/node-version.js.map +1 -1
- package/dist/src/internal/cli/telemetry/analytics/analytics.js +2 -2
- package/dist/src/internal/cli/telemetry/analytics/analytics.js.map +1 -1
- package/dist/src/internal/cli/telemetry/analytics/utils.js +2 -2
- package/dist/src/internal/cli/telemetry/analytics/utils.js.map +1 -1
- package/dist/src/internal/cli/telemetry/error-reporter/global-error-handlers.js +2 -2
- package/dist/src/internal/cli/telemetry/error-reporter/global-error-handlers.js.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/reporter.js +2 -2
- package/dist/src/internal/cli/telemetry/sentry/reporter.js.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/subprocess.js +2 -2
- package/dist/src/internal/cli/telemetry/sentry/subprocess.js.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/transport.js +2 -2
- package/dist/src/internal/cli/telemetry/sentry/transport.js.map +1 -1
- package/dist/src/internal/cli/telemetry/telemetry-permissions.js +2 -2
- package/dist/src/internal/cli/telemetry/telemetry-permissions.js.map +1 -1
- package/dist/src/internal/config-loading.js +2 -2
- package/dist/src/internal/config-loading.js.map +1 -1
- package/dist/src/internal/core/hook-manager.d.ts.map +1 -1
- package/dist/src/internal/core/hook-manager.js +202 -58
- package/dist/src/internal/core/hook-manager.js.map +1 -1
- package/dist/src/internal/core/hre.js +2 -2
- package/dist/src/internal/core/hre.js.map +1 -1
- package/dist/src/internal/core/lazy-user-interruptions.d.ts +11 -0
- package/dist/src/internal/core/lazy-user-interruptions.d.ts.map +1 -0
- package/dist/src/internal/core/lazy-user-interruptions.js +39 -0
- package/dist/src/internal/core/lazy-user-interruptions.js.map +1 -0
- package/dist/src/internal/core/user-interruptions.js +4 -4
- package/dist/src/internal/core/user-interruptions.js.map +1 -1
- package/dist/src/internal/using-hardhat2-plugin-errors.d.ts.map +1 -1
- package/dist/src/internal/using-hardhat2-plugin-errors.js +2 -2
- package/dist/src/internal/using-hardhat2-plugin-errors.js.map +1 -1
- package/package.json +6 -9
- package/src/cli.ts +5 -5
- package/src/internal/builtin-plugins/artifacts/artifact-manager.ts +12 -5
- package/src/internal/builtin-plugins/console/task-action.ts +4 -4
- package/src/internal/builtin-plugins/coverage/coverage-manager.ts +7 -7
- package/src/internal/builtin-plugins/coverage/exports.ts +1 -1
- package/src/internal/builtin-plugins/coverage/helpers/accessors.ts +44 -0
- package/src/internal/builtin-plugins/coverage/helpers/compat.ts +37 -0
- package/src/internal/builtin-plugins/coverage/hook-handlers/clean.ts +1 -1
- package/src/internal/builtin-plugins/coverage/hook-handlers/hre.ts +26 -16
- package/src/internal/builtin-plugins/coverage/hook-handlers/solidity.ts +3 -3
- package/src/internal/builtin-plugins/coverage/hook-handlers/test.ts +1 -1
- package/src/internal/builtin-plugins/coverage/instrumentation.ts +21 -2
- package/src/internal/builtin-plugins/coverage/process-coverage.ts +6 -6
- package/src/internal/builtin-plugins/flatten/task-action.ts +8 -4
- package/src/internal/builtin-plugins/gas-analytics/function-gas-snapshots.ts +11 -10
- package/src/internal/builtin-plugins/gas-analytics/gas-analytics-manager.ts +13 -9
- package/src/internal/builtin-plugins/gas-analytics/helpers/accessors.ts +12 -5
- package/src/internal/builtin-plugins/gas-analytics/helpers/utils.ts +2 -2
- package/src/internal/builtin-plugins/gas-analytics/hook-handlers/hre.ts +29 -17
- package/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.ts +12 -15
- package/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.ts +11 -5
- package/src/internal/builtin-plugins/network-manager/config-resolution.ts +1 -1
- package/src/internal/builtin-plugins/network-manager/edr/edr-constants.ts +61 -0
- package/src/internal/builtin-plugins/network-manager/edr/edr-provider.ts +2 -61
- package/src/internal/builtin-plugins/network-manager/edr/types/hardfork.ts +3 -9
- package/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.ts +1 -1
- package/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.ts +23 -23
- package/src/internal/builtin-plugins/network-manager/edr/utils/trace-output.ts +14 -11
- package/src/internal/builtin-plugins/node/artifacts/build-info-watcher.ts +2 -2
- package/src/internal/builtin-plugins/node/helpers.ts +8 -5
- package/src/internal/builtin-plugins/node/json-rpc/server.ts +2 -2
- package/src/internal/builtin-plugins/node/task-action.ts +5 -4
- package/src/internal/builtin-plugins/solidity/build-system/build-system.ts +92 -52
- package/src/internal/builtin-plugins/solidity/build-system/compilation-job-cost.ts +61 -0
- package/src/internal/builtin-plugins/solidity/build-system/compiler/compiler.ts +17 -3
- package/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.ts +4 -2
- package/src/internal/builtin-plugins/solidity/build-system/compiler/index.ts +2 -2
- package/src/internal/builtin-plugins/solidity/build-system/compiler/solcjs-wrapper.ts +19 -22
- package/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.ts +9 -1
- package/src/internal/builtin-plugins/solidity/build-system/resolver/utils.ts +16 -7
- package/src/internal/builtin-plugins/solidity/build-system/solc-info.ts +27 -6
- package/src/internal/builtin-plugins/solidity/config.ts +5 -2
- package/src/internal/builtin-plugins/solidity/constants.ts +3 -0
- package/src/internal/builtin-plugins/solidity/hook-handlers/hre.ts +13 -4
- package/src/internal/builtin-plugins/solidity-test/config.ts +1 -0
- package/src/internal/builtin-plugins/solidity-test/helpers.ts +3 -4
- package/src/internal/builtin-plugins/solidity-test/reporter.ts +19 -18
- package/src/internal/builtin-plugins/solidity-test/task-action.ts +6 -3
- package/src/internal/builtin-plugins/solidity-test/type-extensions.ts +1 -0
- package/src/internal/builtin-plugins/test/task-action.ts +13 -7
- package/src/internal/cli/banner-manager.ts +2 -2
- package/src/internal/cli/error-handler.ts +10 -6
- package/src/internal/cli/help/get-help-string.ts +2 -2
- package/src/internal/cli/init/init.ts +86 -43
- package/src/internal/cli/init/package-manager.ts +8 -6
- package/src/internal/cli/init/prompt.ts +4 -3
- package/src/internal/cli/init/template.ts +22 -27
- package/src/internal/cli/main.ts +4 -3
- package/src/internal/cli/node-version.ts +20 -12
- package/src/internal/cli/telemetry/analytics/analytics.ts +2 -2
- package/src/internal/cli/telemetry/analytics/utils.ts +2 -2
- package/src/internal/cli/telemetry/error-reporter/global-error-handlers.ts +2 -2
- package/src/internal/cli/telemetry/sentry/reporter.ts +2 -2
- package/src/internal/cli/telemetry/sentry/subprocess.ts +2 -2
- package/src/internal/cli/telemetry/sentry/transport.ts +2 -2
- package/src/internal/cli/telemetry/telemetry-permissions.ts +2 -2
- package/src/internal/config-loading.ts +2 -2
- package/src/internal/core/hook-manager.ts +283 -101
- package/src/internal/core/hre.ts +2 -2
- package/src/internal/core/lazy-user-interruptions.ts +75 -0
- package/src/internal/core/user-interruptions.ts +4 -4
- package/src/internal/using-hardhat2-plugin-errors.ts +2 -2
- package/templates/hardhat-3/01-node-test-runner-viem/package.json +7 -7
- package/templates/hardhat-3/02-mocha-ethers/package.json +13 -13
- package/templates/hardhat-3/03-minimal/package.json +1 -1
- package/dist/src/internal/builtin-plugins/coverage/helpers.d.ts +0 -15
- package/dist/src/internal/builtin-plugins/coverage/helpers.d.ts.map +0 -1
- package/dist/src/internal/builtin-plugins/coverage/helpers.js +0 -35
- package/dist/src/internal/builtin-plugins/coverage/helpers.js.map +0 -1
- package/dist/src/internal/utils/colorizer.d.ts +0 -10
- package/dist/src/internal/utils/colorizer.d.ts.map +0 -1
- package/dist/src/internal/utils/colorizer.js +0 -2
- package/dist/src/internal/utils/colorizer.js.map +0 -1
- package/src/internal/builtin-plugins/coverage/helpers.ts +0 -63
- package/src/internal/utils/colorizer.ts +0 -9
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import type { ChainType } from "../../../../../types/network.js";
|
|
2
2
|
|
|
3
|
-
import { l1HardforkLatest, opLatestHardfork } from "@nomicfoundation/edr";
|
|
4
|
-
|
|
5
3
|
import { OPTIMISM_CHAIN_TYPE } from "../../../../constants.js";
|
|
6
|
-
import {
|
|
7
|
-
edrL1HardforkToHardhatL1HardforkName,
|
|
8
|
-
edrOpHardforkToHardhatOpHardforkName,
|
|
9
|
-
} from "../utils/convert-to-edr.js";
|
|
10
4
|
|
|
11
5
|
export enum L1HardforkName {
|
|
12
6
|
FRONTIER = "chainstart",
|
|
@@ -51,9 +45,9 @@ export function getHardforks(chainType: ChainType): string[] {
|
|
|
51
45
|
}
|
|
52
46
|
|
|
53
47
|
export function getCurrentHardfork(chainType: ChainType): string {
|
|
54
|
-
|
|
55
|
-
?
|
|
56
|
-
|
|
48
|
+
const order =
|
|
49
|
+
chainType === OPTIMISM_CHAIN_TYPE ? OP_HARDFORK_ORDER : L1_HARDFORK_ORDER;
|
|
50
|
+
return order[order.length - 1];
|
|
57
51
|
}
|
|
58
52
|
|
|
59
53
|
/**
|
|
@@ -61,7 +61,7 @@ import {
|
|
|
61
61
|
DEFAULT_EDR_NETWORK_BALANCE,
|
|
62
62
|
EDR_NETWORK_DEFAULT_PRIVATE_KEYS,
|
|
63
63
|
isDefaultEdrNetworkHDAccountsConfig,
|
|
64
|
-
} from "../edr-
|
|
64
|
+
} from "../edr-constants.js";
|
|
65
65
|
import { L1HardforkName, OpHardforkName } from "../types/hardfork.js";
|
|
66
66
|
|
|
67
67
|
import { getL1HardforkName, getOpHardforkName } from "./hardfork.js";
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type { Colorizer } from "../../../../utils/colorizer.js";
|
|
2
1
|
import type {
|
|
3
2
|
LogTrace,
|
|
4
3
|
CallTrace,
|
|
5
4
|
DecodedTraceParameters,
|
|
6
5
|
} from "@nomicfoundation/edr";
|
|
7
6
|
|
|
7
|
+
import { styleText } from "node:util";
|
|
8
|
+
|
|
8
9
|
import { LogKind, CallKind, IncludeTraces } from "@nomicfoundation/edr";
|
|
9
10
|
import { bytesToHexString } from "@nomicfoundation/hardhat-utils/hex";
|
|
10
11
|
|
|
@@ -23,9 +24,10 @@ export function verbosityToIncludeTraces(verbosity: number): IncludeTraces {
|
|
|
23
24
|
export function formatTraces(
|
|
24
25
|
traces: CallTrace[],
|
|
25
26
|
prefix: string,
|
|
26
|
-
|
|
27
|
+
// Allow passing a custom colorize function for testing purposes
|
|
28
|
+
colorize: typeof styleText = styleText,
|
|
27
29
|
): string {
|
|
28
|
-
const lines = traces.map((trace) => formatTrace(trace,
|
|
30
|
+
const lines = traces.map((trace) => formatTrace(trace, colorize));
|
|
29
31
|
const formattedTraces = formatNestedArray(lines, prefix);
|
|
30
32
|
// Remove the trailing newline
|
|
31
33
|
return formattedTraces.slice(0, -1);
|
|
@@ -52,9 +54,13 @@ function formatOutputs(outputs: string | Uint8Array): string | undefined {
|
|
|
52
54
|
}
|
|
53
55
|
}
|
|
54
56
|
|
|
55
|
-
function formatLog(
|
|
57
|
+
function formatLog(
|
|
58
|
+
log: LogTrace,
|
|
59
|
+
// Allow passing a custom colorize function for testing purposes
|
|
60
|
+
colorize: typeof styleText,
|
|
61
|
+
): string[] {
|
|
56
62
|
const { parameters } = log;
|
|
57
|
-
const tag =
|
|
63
|
+
const tag = colorize("yellow", "[event]");
|
|
58
64
|
const lines = [];
|
|
59
65
|
|
|
60
66
|
if (Array.isArray(parameters)) {
|
|
@@ -63,18 +69,18 @@ function formatLog(log: LogTrace, colorizer: Colorizer): string[] {
|
|
|
63
69
|
|
|
64
70
|
for (let i = 0; i < topicCount; i++) {
|
|
65
71
|
const prefix = i === 0 ? `${tag} topic 0` : ` topic ${i}`;
|
|
66
|
-
lines.push(`${prefix}: ${
|
|
72
|
+
lines.push(`${prefix}: ${colorize("cyan", hexValues[i])}`);
|
|
67
73
|
}
|
|
68
74
|
|
|
69
75
|
if (hexValues.length > 0) {
|
|
70
76
|
const dataPrefix = topicCount > 0 ? " data" : `${tag} data`;
|
|
71
77
|
lines.push(
|
|
72
|
-
`${dataPrefix}: ${
|
|
78
|
+
`${dataPrefix}: ${colorize("cyan", hexValues[hexValues.length - 1])}`,
|
|
73
79
|
);
|
|
74
80
|
}
|
|
75
81
|
} else {
|
|
76
82
|
lines.push(
|
|
77
|
-
`${tag} ${parameters.name}(${
|
|
83
|
+
`${tag} ${parameters.name}(${colorize("cyan", parameters.arguments.join(", "))})`,
|
|
78
84
|
);
|
|
79
85
|
}
|
|
80
86
|
return lines;
|
|
@@ -82,7 +88,7 @@ function formatLog(log: LogTrace, colorizer: Colorizer): string[] {
|
|
|
82
88
|
|
|
83
89
|
function formatTrace(
|
|
84
90
|
trace: CallTrace,
|
|
85
|
-
|
|
91
|
+
colorize: typeof styleText,
|
|
86
92
|
): NestedArray<string> {
|
|
87
93
|
const {
|
|
88
94
|
success,
|
|
@@ -95,14 +101,8 @@ function formatTrace(
|
|
|
95
101
|
isCheatcode,
|
|
96
102
|
outputs,
|
|
97
103
|
} = trace;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
color = colorizer.blue;
|
|
101
|
-
} else if (success) {
|
|
102
|
-
color = colorizer.green;
|
|
103
|
-
} else {
|
|
104
|
-
color = colorizer.red;
|
|
105
|
-
}
|
|
104
|
+
const colorName = isCheatcode ? "blue" : success ? "green" : "red";
|
|
105
|
+
const color = (text: string) => colorize(colorName, text);
|
|
106
106
|
|
|
107
107
|
const formattedInputs = formatInputs(inputs, color);
|
|
108
108
|
const formattedOutputs = formatOutputs(outputs);
|
|
@@ -110,7 +110,7 @@ function formatTrace(
|
|
|
110
110
|
let openingLine: string;
|
|
111
111
|
let closingLine: string | undefined;
|
|
112
112
|
if (kind === CallKind.Create) {
|
|
113
|
-
openingLine = `[${gasUsed}] ${
|
|
113
|
+
openingLine = `[${gasUsed}] ${colorize("yellow", "→ new")} ${contract ?? "<unknown>"}@${address}`;
|
|
114
114
|
// TODO: Uncomment this when the formattedInputs starts containing
|
|
115
115
|
// the address of where the contract was deployed instead of the code.
|
|
116
116
|
// if (formattedInputs !== undefined) {
|
|
@@ -125,11 +125,11 @@ function formatTrace(
|
|
|
125
125
|
openingLine = `${openingLine} {value: ${value}}`;
|
|
126
126
|
}
|
|
127
127
|
if (kind === CallKind.StaticCall) {
|
|
128
|
-
openingLine = `${openingLine} ${
|
|
128
|
+
openingLine = `${openingLine} ${colorize("yellow", "[staticcall]")}`;
|
|
129
129
|
} else if (kind === CallKind.DelegateCall) {
|
|
130
|
-
openingLine = `${openingLine} ${
|
|
130
|
+
openingLine = `${openingLine} ${colorize("yellow", "[delegatecall]")}`;
|
|
131
131
|
} else if (kind === CallKind.CallCode) {
|
|
132
|
-
openingLine = `${openingLine} ${
|
|
132
|
+
openingLine = `${openingLine} ${colorize("yellow", "[callcode]")}`;
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
if (formattedOutputs !== undefined) {
|
|
@@ -147,9 +147,9 @@ function formatTrace(
|
|
|
147
147
|
lines.push(openingLine);
|
|
148
148
|
for (const child of trace.children) {
|
|
149
149
|
if (child.kind === LogKind.Log) {
|
|
150
|
-
lines.push(formatLog(child,
|
|
150
|
+
lines.push(formatLog(child, colorize));
|
|
151
151
|
} else {
|
|
152
|
-
lines.push(formatTrace(child,
|
|
152
|
+
lines.push(formatTrace(child, colorize));
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
if (closingLine !== undefined) {
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import type { Response } from "@nomicfoundation/edr";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
|
|
3
|
+
import { styleText } from "node:util";
|
|
4
|
+
|
|
5
|
+
import { createDebug } from "@nomicfoundation/hardhat-utils/debug";
|
|
5
6
|
|
|
6
7
|
import { formatTraces } from "./trace-formatters.js";
|
|
7
8
|
|
|
8
|
-
const log =
|
|
9
|
+
const log = createDebug("hardhat:core:network-manager:edr:trace-output");
|
|
9
10
|
|
|
10
11
|
// Rotating palette for per-connection coloring of trace headers.
|
|
11
12
|
const LABEL_COLORS: Array<(text: string) => string> = [
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
(text: string) => styleText("cyan", text),
|
|
14
|
+
(text: string) => styleText("magenta", text),
|
|
15
|
+
(text: string) => styleText("blueBright", text),
|
|
16
|
+
(text: string) => styleText("yellowBright", text),
|
|
17
|
+
(text: string) => styleText("cyanBright", text),
|
|
18
|
+
(text: string) => styleText("magentaBright", text),
|
|
18
19
|
];
|
|
19
20
|
|
|
20
21
|
// Keyed by `network name` (not connection label) so the map stays bounded
|
|
@@ -107,10 +108,12 @@ export class TraceOutputManager {
|
|
|
107
108
|
const coloredLabel = this.#labelColor(this.#connectionLabel);
|
|
108
109
|
const prefix = callTraces.length > 1 ? "Traces from" : "Trace from";
|
|
109
110
|
const coloredPrefix = this.#labelColor(prefix);
|
|
110
|
-
const styledMethod = failed
|
|
111
|
+
const styledMethod = failed
|
|
112
|
+
? styleText("red", method)
|
|
113
|
+
: styleText("dim", method);
|
|
111
114
|
const header = `${coloredPrefix} ${coloredLabel}: ${styledMethod}`;
|
|
112
115
|
|
|
113
|
-
this.#printLineFn(`${header}\n${formatTraces(callTraces, " "
|
|
116
|
+
this.#printLineFn(`${header}\n${formatTraces(callTraces, " ")}`);
|
|
114
117
|
} catch (e) {
|
|
115
118
|
log("Failed to get call traces: %O", e);
|
|
116
119
|
}
|
|
@@ -2,13 +2,13 @@ import type { FSWatcher } from "chokidar";
|
|
|
2
2
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
|
|
5
|
+
import { createDebug } from "@nomicfoundation/hardhat-utils/debug";
|
|
5
6
|
import { watch } from "chokidar";
|
|
6
|
-
import debug from "debug";
|
|
7
7
|
|
|
8
8
|
export type BuildInfoWatcher = FSWatcher;
|
|
9
9
|
export type BuildInfoHandler = (buildId: string) => Promise<void>;
|
|
10
10
|
|
|
11
|
-
const log =
|
|
11
|
+
const log = createDebug("hardhat:core:tasks:node:artifacts");
|
|
12
12
|
|
|
13
13
|
const STABILITY_THRESHOLD = 250;
|
|
14
14
|
const POLL_INTERVAL = 50;
|
|
@@ -2,22 +2,23 @@ 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 { DebugLogger } from "@nomicfoundation/hardhat-utils/debug";
|
|
5
6
|
import type * as MicroEthSignerT from "micro-eth-signer";
|
|
6
7
|
|
|
7
8
|
import path from "node:path";
|
|
9
|
+
import { styleText } from "node:util";
|
|
8
10
|
|
|
9
11
|
import {
|
|
10
12
|
readJsonFile,
|
|
11
13
|
readJsonFileAsStream,
|
|
12
14
|
} from "@nomicfoundation/hardhat-utils/fs";
|
|
13
15
|
import { hexStringToBytes } from "@nomicfoundation/hardhat-utils/hex";
|
|
14
|
-
import chalk from "chalk";
|
|
15
16
|
|
|
16
17
|
// micro-eth-signer is known to be slow to load, so we lazy load it
|
|
17
18
|
let microEthSigner: typeof MicroEthSignerT | undefined;
|
|
18
19
|
|
|
19
20
|
import { sendErrorTelemetry } from "../../cli/telemetry/error-reporter/reporter.js";
|
|
20
|
-
import { isDefaultEdrNetworkHDAccountsConfig } from "../network-manager/edr/edr-
|
|
21
|
+
import { isDefaultEdrNetworkHDAccountsConfig } from "../network-manager/edr/edr-constants.js";
|
|
21
22
|
import { normalizeEdrNetworkAccountsConfig } from "../network-manager/edr/utils/convert-to-edr.js";
|
|
22
23
|
|
|
23
24
|
export async function formatEdrNetworkConfigAccounts(
|
|
@@ -94,7 +95,7 @@ export async function formatEdrNetworkConfigAccounts(
|
|
|
94
95
|
export function createBuildInfoUploadHandlerFrom(
|
|
95
96
|
buildInfoDirPath: string,
|
|
96
97
|
provider: EdrProvider,
|
|
97
|
-
log:
|
|
98
|
+
log: DebugLogger,
|
|
98
99
|
): (buildId: string) => Promise<void> {
|
|
99
100
|
const buildInfoHandler = async (buildId: string) => {
|
|
100
101
|
try {
|
|
@@ -116,7 +117,8 @@ export function createBuildInfoUploadHandlerFrom(
|
|
|
116
117
|
log(`Added compiler result for ${buildId}`);
|
|
117
118
|
} catch (error) {
|
|
118
119
|
console.warn(
|
|
119
|
-
|
|
120
|
+
styleText(
|
|
121
|
+
"yellow",
|
|
120
122
|
`There was a problem adding the new compiler result for build ${buildId}.`,
|
|
121
123
|
),
|
|
122
124
|
);
|
|
@@ -137,7 +139,8 @@ export function createBuildInfoUploadHandlerFrom(
|
|
|
137
139
|
|
|
138
140
|
// NOTE: This function is exported for testing purposes only
|
|
139
141
|
export function getPublicPrivateKeysWarning(): string {
|
|
140
|
-
return
|
|
142
|
+
return styleText(
|
|
143
|
+
"bold",
|
|
141
144
|
"WARNING: Funds sent on live network to accounts with publicly known private keys WILL BE LOST.",
|
|
142
145
|
);
|
|
143
146
|
}
|
|
@@ -5,12 +5,12 @@ import type { AddressInfo } from "node:net";
|
|
|
5
5
|
|
|
6
6
|
import http from "node:http";
|
|
7
7
|
|
|
8
|
-
import
|
|
8
|
+
import { createDebug } from "@nomicfoundation/hardhat-utils/debug";
|
|
9
9
|
import { WebSocketServer } from "ws";
|
|
10
10
|
|
|
11
11
|
import { JsonRpcHandler } from "./handler.js";
|
|
12
12
|
|
|
13
|
-
const log =
|
|
13
|
+
const log = createDebug("hardhat:core:tasks:node:json-rpc:server");
|
|
14
14
|
|
|
15
15
|
export interface JsonRpcServerConfig {
|
|
16
16
|
hostname: string;
|
|
@@ -3,14 +3,14 @@ import type { ChainType } from "../../../types/network.js";
|
|
|
3
3
|
import type { NewTaskActionFunction } from "../../../types/tasks.js";
|
|
4
4
|
|
|
5
5
|
import path from "node:path";
|
|
6
|
+
import { styleText } from "node:util";
|
|
6
7
|
|
|
7
8
|
import {
|
|
8
9
|
assertHardhatInvariant,
|
|
9
10
|
HardhatError,
|
|
10
11
|
} from "@nomicfoundation/hardhat-errors";
|
|
12
|
+
import { createDebug } from "@nomicfoundation/hardhat-utils/debug";
|
|
11
13
|
import { ensureDir, exists } from "@nomicfoundation/hardhat-utils/fs";
|
|
12
|
-
import chalk from "chalk";
|
|
13
|
-
import debug from "debug";
|
|
14
14
|
|
|
15
15
|
import { isSupportedChainType } from "../../edr/chain-type.js";
|
|
16
16
|
import { BUILD_INFO_DIR_NAME } from "../artifacts/artifact-manager.js";
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
} from "./helpers.js";
|
|
24
24
|
import { JsonRpcServerImplementation } from "./json-rpc/server.js";
|
|
25
25
|
|
|
26
|
-
const log =
|
|
26
|
+
const log = createDebug("hardhat:core:tasks:node");
|
|
27
27
|
|
|
28
28
|
interface NodeActionArguments {
|
|
29
29
|
hostname?: string;
|
|
@@ -143,7 +143,8 @@ const nodeAction: NewTaskActionFunction<NodeActionArguments> = async (
|
|
|
143
143
|
const { port: actualPort, address: actualHostname } = await server.listen();
|
|
144
144
|
|
|
145
145
|
console.log(
|
|
146
|
-
|
|
146
|
+
styleText(
|
|
147
|
+
"green",
|
|
147
148
|
`Started HTTP and WebSocket JSON-RPC server at http://${actualHostname}:${actualPort}/`,
|
|
148
149
|
),
|
|
149
150
|
);
|
|
@@ -33,11 +33,13 @@ import type {
|
|
|
33
33
|
|
|
34
34
|
import os from "node:os";
|
|
35
35
|
import path from "node:path";
|
|
36
|
+
import { styleText } from "node:util";
|
|
36
37
|
|
|
37
38
|
import {
|
|
38
39
|
assertHardhatInvariant,
|
|
39
40
|
HardhatError,
|
|
40
41
|
} from "@nomicfoundation/hardhat-errors";
|
|
42
|
+
import { createDebug } from "@nomicfoundation/hardhat-utils/debug";
|
|
41
43
|
import {
|
|
42
44
|
exists,
|
|
43
45
|
ensureDir,
|
|
@@ -49,12 +51,11 @@ import {
|
|
|
49
51
|
writeJsonFile,
|
|
50
52
|
writeJsonFileAsStream,
|
|
51
53
|
writeUtf8File,
|
|
54
|
+
readdirOrEmpty,
|
|
52
55
|
} from "@nomicfoundation/hardhat-utils/fs";
|
|
53
56
|
import { shortenPath } from "@nomicfoundation/hardhat-utils/path";
|
|
54
57
|
import { createSpinner } from "@nomicfoundation/hardhat-utils/spinner";
|
|
55
58
|
import { pluralize } from "@nomicfoundation/hardhat-utils/string";
|
|
56
|
-
import chalk from "chalk";
|
|
57
|
-
import debug from "debug";
|
|
58
59
|
import pMap from "p-map";
|
|
59
60
|
|
|
60
61
|
import { FileBuildResultType } from "../../../../types/solidity/build-system.js";
|
|
@@ -70,6 +71,7 @@ import {
|
|
|
70
71
|
getDuplicatedContractNamesDeclarationFile,
|
|
71
72
|
} from "./artifacts.js";
|
|
72
73
|
import { loadCache, saveCache } from "./cache.js";
|
|
74
|
+
import { sortCompilationJobsByDescendingCost } from "./compilation-job-cost.js";
|
|
73
75
|
import { CompilationJobImplementation } from "./compilation-job.js";
|
|
74
76
|
import { downloadSolcCompilers, getCompiler } from "./compiler/index.js";
|
|
75
77
|
import { buildDependencyGraph } from "./dependency-graph-building.js";
|
|
@@ -83,7 +85,7 @@ import {
|
|
|
83
85
|
import { SolcConfigSelector } from "./solc-config-selection.js";
|
|
84
86
|
import { shouldSuppressWarning } from "./warning-suppression.js";
|
|
85
87
|
|
|
86
|
-
const log =
|
|
88
|
+
const log = createDebug("hardhat:core:solidity:build-system");
|
|
87
89
|
|
|
88
90
|
/**
|
|
89
91
|
* Returns true if the given compiler config is a SolcSolidityCompilerConfig.
|
|
@@ -176,23 +178,15 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
176
178
|
options: { scope?: BuildScope } = {},
|
|
177
179
|
): Promise<string[]> {
|
|
178
180
|
const scope = options.scope ?? "contracts";
|
|
179
|
-
const unified = !this.#options.solidityConfig.splitTestsCompilation;
|
|
180
181
|
|
|
181
182
|
this.#ensureSplitCompilationModeIfTestsScope(scope);
|
|
182
183
|
|
|
184
|
+
const unified = !this.#options.solidityConfig.splitTestsCompilation;
|
|
185
|
+
const { localContractFiles, sourceTestFiles } =
|
|
186
|
+
await this.#getSoliditySourcesRootFilePaths();
|
|
187
|
+
|
|
183
188
|
switch (scope) {
|
|
184
189
|
case "contracts": {
|
|
185
|
-
const localContractFiles = (
|
|
186
|
-
await Promise.all(
|
|
187
|
-
this.#options.soliditySourcesPaths.map((dir) =>
|
|
188
|
-
getAllFilesMatching(
|
|
189
|
-
dir,
|
|
190
|
-
(f) => f.endsWith(".sol") && !f.endsWith(".t.sol"),
|
|
191
|
-
),
|
|
192
|
-
),
|
|
193
|
-
)
|
|
194
|
-
).flat(1);
|
|
195
|
-
|
|
196
190
|
const npmFilesToBuild =
|
|
197
191
|
this.#options.solidityConfig.npmFilesToBuild.map(
|
|
198
192
|
npmModuleToNpmRootPath,
|
|
@@ -204,18 +198,12 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
204
198
|
|
|
205
199
|
// In unified mode, contracts scope returns all roots: contracts,
|
|
206
200
|
// tests, and npm files.
|
|
207
|
-
const testFiles =
|
|
208
|
-
await
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
return await getAllFilesMatching(dir, (f) =>
|
|
214
|
-
f.endsWith(".t.sol"),
|
|
215
|
-
);
|
|
216
|
-
}),
|
|
217
|
-
])
|
|
218
|
-
).flat(1);
|
|
201
|
+
const testFiles = [
|
|
202
|
+
...(await getAllFilesMatching(this.#options.solidityTestsPath, (f) =>
|
|
203
|
+
f.endsWith(".sol"),
|
|
204
|
+
)),
|
|
205
|
+
...sourceTestFiles,
|
|
206
|
+
];
|
|
219
207
|
|
|
220
208
|
// Remove duplicates in case there is an intersection between
|
|
221
209
|
// the tests.solidity paths and the sources paths
|
|
@@ -224,18 +212,12 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
224
212
|
);
|
|
225
213
|
}
|
|
226
214
|
case "tests": {
|
|
227
|
-
let rootFilePaths =
|
|
228
|
-
await
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
return await getAllFilesMatching(dir, (f) =>
|
|
234
|
-
f.endsWith(".t.sol"),
|
|
235
|
-
);
|
|
236
|
-
}),
|
|
237
|
-
])
|
|
238
|
-
).flat(1);
|
|
215
|
+
let rootFilePaths = [
|
|
216
|
+
...(await getAllFilesMatching(this.#options.solidityTestsPath, (f) =>
|
|
217
|
+
f.endsWith(".sol"),
|
|
218
|
+
)),
|
|
219
|
+
...sourceTestFiles,
|
|
220
|
+
];
|
|
239
221
|
|
|
240
222
|
// NOTE: We remove duplicates in case there is an intersection between
|
|
241
223
|
// the tests.solidity paths and the sources paths
|
|
@@ -245,6 +227,46 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
245
227
|
}
|
|
246
228
|
}
|
|
247
229
|
|
|
230
|
+
/**
|
|
231
|
+
* Returns all the root files from the different solidity source dirs in the
|
|
232
|
+
* config, partitioned into contract files and test files according to their
|
|
233
|
+
* extensions.
|
|
234
|
+
*/
|
|
235
|
+
async #getSoliditySourcesRootFilePaths(): Promise<{
|
|
236
|
+
localContractFiles: string[];
|
|
237
|
+
sourceTestFiles: string[];
|
|
238
|
+
}> {
|
|
239
|
+
const sourceFileGroups = await Promise.all(
|
|
240
|
+
this.#options.soliditySourcesPaths.map(async (dir) => {
|
|
241
|
+
const localSolidityFiles = await getAllFilesMatching(dir, (f) =>
|
|
242
|
+
f.endsWith(".sol"),
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
const localContractFiles: string[] = [];
|
|
246
|
+
const sourceTestFiles: string[] = [];
|
|
247
|
+
|
|
248
|
+
for (const file of localSolidityFiles) {
|
|
249
|
+
if (file.endsWith(".t.sol")) {
|
|
250
|
+
sourceTestFiles.push(file);
|
|
251
|
+
} else {
|
|
252
|
+
localContractFiles.push(file);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return { localContractFiles, sourceTestFiles };
|
|
257
|
+
}),
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
return {
|
|
261
|
+
localContractFiles: sourceFileGroups.flatMap(
|
|
262
|
+
({ localContractFiles }) => localContractFiles,
|
|
263
|
+
),
|
|
264
|
+
sourceTestFiles: sourceFileGroups.flatMap(
|
|
265
|
+
({ sourceTestFiles }) => sourceTestFiles,
|
|
266
|
+
),
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
|
|
248
270
|
public isSuccessfulBuildResult(
|
|
249
271
|
buildResult: CompilationJobCreationError | Map<string, FileBuildResult>,
|
|
250
272
|
): buildResult is Map<string, FileBuildResult> {
|
|
@@ -318,8 +340,18 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
318
340
|
),
|
|
319
341
|
);
|
|
320
342
|
|
|
321
|
-
|
|
343
|
+
// We sort the compilation jobs in descending order of estimated
|
|
344
|
+
// compilation cost. This way we can use this algorithm:
|
|
345
|
+
// https://en.wikipedia.org/wiki/Longest-processing-time-first_scheduling
|
|
346
|
+
//
|
|
347
|
+
// Note that it works because pMap schedules the jobs in the order they
|
|
348
|
+
// are in the array.
|
|
349
|
+
const sortedCompilationJobs = sortCompilationJobsByDescendingCost(
|
|
322
350
|
runnableCompilationJobs,
|
|
351
|
+
);
|
|
352
|
+
|
|
353
|
+
const results: CompilationResult[] = await pMap(
|
|
354
|
+
sortedCompilationJobs,
|
|
323
355
|
async (runnableCompilationJob) => {
|
|
324
356
|
const { output, compiler } = await this.runCompilationJob(
|
|
325
357
|
runnableCompilationJob,
|
|
@@ -1102,18 +1134,23 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
1102
1134
|
reachableBuildInfoIds.filter((id) => id !== undefined),
|
|
1103
1135
|
);
|
|
1104
1136
|
|
|
1105
|
-
//
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
);
|
|
1137
|
+
// The build-info directory is expected to be flat: every build-info file
|
|
1138
|
+
// lives directly under it, so a non-recursive `readdir` is enough.
|
|
1139
|
+
const buildInfoFiles = await readdirOrEmpty(buildInfosDir);
|
|
1109
1140
|
|
|
1110
1141
|
for (const buildInfoFile of buildInfoFiles) {
|
|
1111
|
-
|
|
1142
|
+
let id: string | undefined;
|
|
1112
1143
|
|
|
1113
|
-
|
|
1144
|
+
if (buildInfoFile.endsWith(".output.json")) {
|
|
1145
|
+
id = buildInfoFile.slice(0, -".output.json".length);
|
|
1146
|
+
} else if (buildInfoFile.endsWith(".json")) {
|
|
1147
|
+
id = buildInfoFile.slice(0, -".json".length);
|
|
1148
|
+
} else {
|
|
1149
|
+
continue;
|
|
1150
|
+
}
|
|
1114
1151
|
|
|
1115
1152
|
if (!reachableBuildInfoIdsSet.has(id)) {
|
|
1116
|
-
await remove(buildInfoFile);
|
|
1153
|
+
await remove(path.join(buildInfosDir, buildInfoFile));
|
|
1117
1154
|
}
|
|
1118
1155
|
}
|
|
1119
1156
|
|
|
@@ -1330,13 +1367,14 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
1330
1367
|
error.message;
|
|
1331
1368
|
|
|
1332
1369
|
console.error(
|
|
1333
|
-
errorMessage
|
|
1334
|
-
"
|
|
1370
|
+
errorMessage
|
|
1371
|
+
.replace(/^\w+:/, (t) => styleText(["red", "bold"], t))
|
|
1372
|
+
.trimEnd() + "\n",
|
|
1335
1373
|
);
|
|
1336
1374
|
} else {
|
|
1337
1375
|
console.warn(
|
|
1338
1376
|
(error.formattedMessage ?? error.message)
|
|
1339
|
-
.replace(/^\w+:/, (t) =>
|
|
1377
|
+
.replace(/^\w+:/, (t) => styleText(["yellow", "bold"], t))
|
|
1340
1378
|
.trimEnd() + "\n",
|
|
1341
1379
|
);
|
|
1342
1380
|
}
|
|
@@ -1348,7 +1386,8 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
1348
1386
|
|
|
1349
1387
|
if (hasConsoleErrors) {
|
|
1350
1388
|
console.error(
|
|
1351
|
-
|
|
1389
|
+
styleText(
|
|
1390
|
+
"red",
|
|
1352
1391
|
`The console.log call you made isn't supported. See https://hardhat.org/console-log for the list of supported methods.`,
|
|
1353
1392
|
),
|
|
1354
1393
|
);
|
|
@@ -1441,7 +1480,8 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
1441
1480
|
}
|
|
1442
1481
|
|
|
1443
1482
|
console.log(
|
|
1444
|
-
|
|
1483
|
+
styleText(
|
|
1484
|
+
"bold",
|
|
1445
1485
|
`Compiled ${rootFiles} Solidity ${pluralize(
|
|
1446
1486
|
options.scope === "contracts" ? "file" : "test file",
|
|
1447
1487
|
rootFiles,
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { CompilationJob } from "../../../../types/solidity.js";
|
|
2
|
+
|
|
3
|
+
import { SOLC_DEFAULT_OPTIMIZER_RUNS } from "../constants.js";
|
|
4
|
+
|
|
5
|
+
// This doesn't need to be exact, it's used to account for the per-file
|
|
6
|
+
// overhead, so that many small files don't look free
|
|
7
|
+
const APPROXIMATE_AVERAGE_SIZE_OF_SOLIDITY_FILES = 10_000;
|
|
8
|
+
|
|
9
|
+
export function estimateCompilationJobCost(job: CompilationJob): number {
|
|
10
|
+
let totalChars = 0;
|
|
11
|
+
let fileCount = 0;
|
|
12
|
+
|
|
13
|
+
for (const file of job.dependencyGraph.getAllFiles()) {
|
|
14
|
+
totalChars += file.content.text.length;
|
|
15
|
+
fileCount += 1;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const settings = job.solcConfig.settings ?? {};
|
|
19
|
+
const viaIR = settings.viaIR === true;
|
|
20
|
+
const optimizerEnabled = settings.optimizer?.enabled === true;
|
|
21
|
+
const optimizerRuns: number =
|
|
22
|
+
settings.optimizer?.runs ?? SOLC_DEFAULT_OPTIMIZER_RUNS;
|
|
23
|
+
|
|
24
|
+
const viaIRMultiplier = viaIR === true ? 6.0 : 1.0;
|
|
25
|
+
const optimizerMultiplier = optimizerEnabled ? 1.4 : 1.0;
|
|
26
|
+
|
|
27
|
+
// The optimizer `runs` is not the number of times that the optimizer is run.
|
|
28
|
+
// It represents how many times the contract will be run.
|
|
29
|
+
// While it has an effect in the compilation time, it's not linear nor
|
|
30
|
+
// dominant.
|
|
31
|
+
//
|
|
32
|
+
// We use Math.log10 and Math.min to represent that:
|
|
33
|
+
// - increasing runs probably has diminishing impact in cost
|
|
34
|
+
// - going from 1 -> 200 matters more than 200 -> 20_000
|
|
35
|
+
// - runs should contribute weakly compared with viaIR
|
|
36
|
+
const runsMultiplier = optimizerEnabled
|
|
37
|
+
? 1 + Math.min(0.12, Math.log10(Math.max(1, optimizerRuns)) * 0.04)
|
|
38
|
+
: 1.0;
|
|
39
|
+
|
|
40
|
+
const fileOverhead = APPROXIMATE_AVERAGE_SIZE_OF_SOLIDITY_FILES * fileCount;
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
(totalChars + fileOverhead) *
|
|
44
|
+
viaIRMultiplier *
|
|
45
|
+
optimizerMultiplier *
|
|
46
|
+
runsMultiplier
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Returns a new array containing the given compilation jobs sorted by their
|
|
52
|
+
* estimated cost in descending order. The input array is not mutated.
|
|
53
|
+
*/
|
|
54
|
+
export function sortCompilationJobsByDescendingCost(
|
|
55
|
+
compilationJobs: CompilationJob[],
|
|
56
|
+
): CompilationJob[] {
|
|
57
|
+
return compilationJobs
|
|
58
|
+
.map((job) => ({ job, cost: estimateCompilationJobCost(job) }))
|
|
59
|
+
.sort((a, b) => b.cost - a.cost)
|
|
60
|
+
.map(({ job }) => job);
|
|
61
|
+
}
|