hardhat 3.1.9 → 3.1.11
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 +33 -0
- package/dist/src/config.d.ts +20 -0
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +31 -0
- package/dist/src/config.js.map +1 -1
- package/dist/src/internal/builtin-plugins/artifacts/artifact-manager.d.ts +2 -2
- package/dist/src/internal/builtin-plugins/artifacts/artifact-manager.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/artifacts/artifact-manager.js.map +1 -1
- package/dist/src/internal/builtin-plugins/artifacts/hook-handlers/hre.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/artifacts/hook-handlers/hre.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/coverage-manager.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/coverage-manager.js +33 -21
- package/dist/src/internal/builtin-plugins/coverage/coverage-manager.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/helpers.d.ts +3 -5
- package/dist/src/internal/builtin-plugins/coverage/helpers.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/helpers.js +7 -19
- package/dist/src/internal/builtin-plugins/coverage/helpers.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/test.d.ts +7 -0
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/test.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/test.js +42 -0
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/test.js.map +1 -0
- package/dist/src/internal/builtin-plugins/coverage/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/index.js +1 -0
- package/dist/src/internal/builtin-plugins/coverage/index.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 +1 -1
- package/dist/src/internal/builtin-plugins/flatten/task-action.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/gas-analytics-manager.js +2 -2
- 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 +3 -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 +7 -19
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/test.d.ts +7 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/test.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/test.js +42 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/test.js.map +1 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/index.js +1 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js +17 -20
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-generation-errors.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-generation-errors.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-generation-errors.js +2 -2
- package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-generation-errors.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/type-validation.d.ts +0 -2
- package/dist/src/internal/builtin-plugins/network-manager/edr/type-validation.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/type-validation.js +0 -6
- package/dist/src/internal/builtin-plugins/network-manager/edr/type-validation.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.d.ts +1 -3
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.js +0 -49
- 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/hook-handlers/config.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/config.js +58 -20
- package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/config.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-validation.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-validation.js +8 -0
- package/dist/src/internal/builtin-plugins/network-manager/type-validation.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 +1 -2
- package/dist/src/internal/builtin-plugins/node/task-action.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-results.d.ts +2 -2
- package/dist/src/internal/builtin-plugins/solidity/build-results.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-results.js +2 -2
- package/dist/src/internal/builtin-plugins/solidity/build-results.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.d.ts +1 -0
- package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js +14 -6
- package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js.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 +0 -3
- 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 +3 -5
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/dependency-graph-building.d.ts +2 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/dependency-graph-building.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/dependency-graph-building.js +4 -2
- package/dist/src/internal/builtin-plugins/solidity/build-system/dependency-graph-building.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/dependency-graph.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/dependency-graph.js +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.d.ts +5 -2
- 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 +8 -2
- 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/error-messages.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/error-messages.js +19 -5
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/error-messages.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.d.ts +21 -2
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.js +84 -25
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/types.d.ts +3 -12
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/types.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/types.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/utils.d.ts +1 -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/solc-config-selection.d.ts +8 -6
- 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 +103 -27
- package/dist/src/internal/builtin-plugins/solidity/build-system/solc-config-selection.js.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/hook-handlers/hre.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.js +5 -0
- package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/tasks/build.js +1 -1
- package/dist/src/internal/builtin-plugins/solidity/tasks/build.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/type-extensions.d.ts +22 -0
- package/dist/src/internal/builtin-plugins/solidity/type-extensions.d.ts.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/edr-artifacts.d.ts +1 -1
- 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 +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/edr-artifacts.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/runner.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/runner.js +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 +16 -27
- 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/telemetry/task-action.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/telemetry/task-action.js +3 -2
- package/dist/src/internal/builtin-plugins/telemetry/task-action.js.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 +40 -13
- package/dist/src/internal/builtin-plugins/test/task-action.js.map +1 -1
- package/dist/src/internal/builtin-plugins/test/type-extensions.d.ts +27 -0
- package/dist/src/internal/builtin-plugins/test/type-extensions.d.ts.map +1 -1
- package/dist/src/internal/cli/banner-manager.d.ts +26 -0
- package/dist/src/internal/cli/banner-manager.d.ts.map +1 -0
- package/dist/src/internal/cli/banner-manager.js +146 -0
- package/dist/src/internal/cli/banner-manager.js.map +1 -0
- package/dist/src/internal/cli/error-handler.d.ts.map +1 -1
- package/dist/src/internal/cli/error-handler.js +15 -0
- package/dist/src/internal/cli/error-handler.js.map +1 -1
- package/dist/src/internal/cli/init/init.d.ts.map +1 -1
- package/dist/src/internal/cli/init/init.js +8 -0
- package/dist/src/internal/cli/init/init.js.map +1 -1
- package/dist/src/internal/cli/main.d.ts.map +1 -1
- package/dist/src/internal/cli/main.js +18 -1
- package/dist/src/internal/cli/main.js.map +1 -1
- package/dist/src/internal/cli/telemetry/analytics/subprocess.js +2 -0
- package/dist/src/internal/cli/telemetry/analytics/subprocess.js.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/anonymize-paths.js +1 -1
- package/dist/src/internal/cli/telemetry/sentry/reporter.d.ts.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/reporter.js +4 -0
- package/dist/src/internal/cli/telemetry/sentry/reporter.js.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/vendor/integrations/contextlines.d.ts +1 -1
- package/dist/src/internal/cli/telemetry/sentry/vendor/integrations/contextlines.d.ts.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/vendor/integrations/contextlines.js +47 -38
- package/dist/src/internal/cli/telemetry/sentry/vendor/integrations/contextlines.js.map +1 -1
- package/dist/src/internal/core/config-validation.d.ts +3 -3
- package/dist/src/internal/core/config-validation.d.ts.map +1 -1
- package/dist/src/internal/core/config-validation.js +48 -18
- package/dist/src/internal/core/config-validation.js.map +1 -1
- package/dist/src/internal/core/tasks/builders.d.ts +26 -16
- package/dist/src/internal/core/tasks/builders.d.ts.map +1 -1
- package/dist/src/internal/core/tasks/builders.js +65 -6
- package/dist/src/internal/core/tasks/builders.js.map +1 -1
- package/dist/src/internal/core/tasks/resolved-task.d.ts +2 -2
- package/dist/src/internal/core/tasks/resolved-task.d.ts.map +1 -1
- package/dist/src/internal/core/tasks/resolved-task.js +23 -9
- package/dist/src/internal/core/tasks/resolved-task.js.map +1 -1
- package/dist/src/internal/core/tasks/task-manager.d.ts.map +1 -1
- package/dist/src/internal/core/tasks/task-manager.js +14 -6
- package/dist/src/internal/core/tasks/task-manager.js.map +1 -1
- package/dist/src/internal/core/tasks/validations.d.ts +2 -0
- package/dist/src/internal/core/tasks/validations.d.ts.map +1 -1
- package/dist/src/internal/core/tasks/validations.js +11 -0
- package/dist/src/internal/core/tasks/validations.js.map +1 -1
- package/dist/src/internal/core/user-interruptions.js +1 -1
- package/dist/src/internal/deprecated-module-imported-from-hardhat2-plugin.d.ts +2 -0
- package/dist/src/internal/deprecated-module-imported-from-hardhat2-plugin.d.ts.map +1 -0
- package/dist/src/internal/deprecated-module-imported-from-hardhat2-plugin.js +12 -0
- package/dist/src/internal/deprecated-module-imported-from-hardhat2-plugin.js.map +1 -0
- package/dist/src/internal/using-hardhat2-plugin-errors.d.ts +35 -0
- package/dist/src/internal/using-hardhat2-plugin-errors.d.ts.map +1 -0
- package/dist/src/internal/using-hardhat2-plugin-errors.js +98 -0
- package/dist/src/internal/using-hardhat2-plugin-errors.js.map +1 -0
- package/dist/src/plugins.d.ts +8 -0
- package/dist/src/plugins.d.ts.map +1 -1
- package/dist/src/plugins.js +13 -0
- package/dist/src/plugins.js.map +1 -1
- package/dist/src/types/artifacts.d.ts +32 -3
- package/dist/src/types/artifacts.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +15 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/types/index.js +15 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/types/network.d.ts +1 -1
- package/dist/src/types/plugins.d.ts +2 -2
- package/dist/src/types/solidity/build-system.d.ts +56 -10
- package/dist/src/types/solidity/build-system.d.ts.map +1 -1
- package/dist/src/types/solidity/build-system.js +26 -2
- package/dist/src/types/solidity/build-system.js.map +1 -1
- package/dist/src/types/solidity/errors.d.ts +18 -0
- package/dist/src/types/solidity/errors.d.ts.map +1 -1
- package/dist/src/types/solidity/errors.js.map +1 -1
- package/dist/src/types/solidity/resolved-file.d.ts +2 -2
- package/dist/src/types/tasks.d.ts +103 -34
- package/dist/src/types/tasks.d.ts.map +1 -1
- package/dist/src/types/tasks.js.map +1 -1
- package/dist/src/types/test.d.ts +11 -0
- package/dist/src/types/test.d.ts.map +1 -1
- package/dist/src/types/utils.d.ts +16 -0
- package/dist/src/types/utils.d.ts.map +1 -1
- package/dist/src/utils/result.d.ts +33 -0
- package/dist/src/utils/result.d.ts.map +1 -0
- package/dist/src/utils/result.js +43 -0
- package/dist/src/utils/result.js.map +1 -0
- package/package.json +12 -7
- package/src/config.ts +37 -0
- package/src/internal/builtin-plugins/artifacts/artifact-manager.ts +4 -1
- package/src/internal/builtin-plugins/artifacts/hook-handlers/hre.ts +4 -1
- package/src/internal/builtin-plugins/coverage/coverage-manager.ts +57 -50
- package/src/internal/builtin-plugins/coverage/helpers.ts +11 -29
- package/src/internal/builtin-plugins/coverage/hook-handlers/test.ts +68 -0
- package/src/internal/builtin-plugins/coverage/index.ts +1 -0
- package/src/internal/builtin-plugins/flatten/task-action.ts +1 -0
- package/src/internal/builtin-plugins/gas-analytics/gas-analytics-manager.ts +4 -4
- package/src/internal/builtin-plugins/gas-analytics/helpers.ts +11 -29
- package/src/internal/builtin-plugins/gas-analytics/hook-handlers/test.ts +68 -0
- package/src/internal/builtin-plugins/gas-analytics/index.ts +1 -0
- package/src/internal/builtin-plugins/network-manager/edr/edr-provider.ts +21 -28
- package/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-generation-errors.ts +5 -2
- package/src/internal/builtin-plugins/network-manager/edr/type-validation.ts +0 -13
- package/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.ts +0 -64
- package/src/internal/builtin-plugins/network-manager/hook-handlers/config.ts +65 -21
- package/src/internal/builtin-plugins/network-manager/type-validation.ts +9 -0
- package/src/internal/builtin-plugins/node/task-action.ts +2 -2
- package/src/internal/builtin-plugins/solidity/build-results.ts +3 -1
- package/src/internal/builtin-plugins/solidity/build-system/build-system.ts +16 -5
- package/src/internal/builtin-plugins/solidity/build-system/compiler/compiler.ts +1 -1
- package/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.ts +7 -6
- package/src/internal/builtin-plugins/solidity/build-system/dependency-graph-building.ts +23 -1
- package/src/internal/builtin-plugins/solidity/build-system/dependency-graph.ts +1 -1
- package/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.ts +17 -3
- package/src/internal/builtin-plugins/solidity/build-system/resolver/error-messages.ts +19 -5
- package/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.ts +139 -35
- package/src/internal/builtin-plugins/solidity/build-system/resolver/types.ts +3 -9
- package/src/internal/builtin-plugins/solidity/build-system/resolver/utils.ts +1 -1
- package/src/internal/builtin-plugins/solidity/build-system/solc-config-selection.ts +125 -28
- package/src/internal/builtin-plugins/solidity/config.ts +2 -2
- package/src/internal/builtin-plugins/solidity/hook-handlers/hre.ts +8 -0
- package/src/internal/builtin-plugins/solidity/tasks/build.ts +1 -1
- package/src/internal/builtin-plugins/solidity/type-extensions.ts +28 -0
- package/src/internal/builtin-plugins/solidity-test/config.ts +1 -0
- package/src/internal/builtin-plugins/solidity-test/edr-artifacts.ts +2 -2
- package/src/internal/builtin-plugins/solidity-test/runner.ts +1 -1
- package/src/internal/builtin-plugins/solidity-test/task-action.ts +36 -38
- package/src/internal/builtin-plugins/solidity-test/type-extensions.ts +1 -0
- package/src/internal/builtin-plugins/telemetry/task-action.ts +4 -2
- package/src/internal/builtin-plugins/test/task-action.ts +71 -25
- package/src/internal/builtin-plugins/test/type-extensions.ts +42 -0
- package/src/internal/cli/banner-manager.ts +234 -0
- package/src/internal/cli/error-handler.ts +18 -0
- package/src/internal/cli/init/init.ts +8 -0
- package/src/internal/cli/main.ts +19 -1
- package/src/internal/cli/telemetry/analytics/subprocess.ts +2 -0
- package/src/internal/cli/telemetry/sentry/anonymize-paths.ts +1 -1
- package/src/internal/cli/telemetry/sentry/reporter.ts +5 -0
- package/src/internal/cli/telemetry/sentry/vendor/integrations/contextlines.ts +98 -50
- package/src/internal/core/config-validation.ts +67 -18
- package/src/internal/core/tasks/builders.ts +174 -30
- package/src/internal/core/tasks/resolved-task.ts +31 -13
- package/src/internal/core/tasks/task-manager.ts +23 -5
- package/src/internal/core/tasks/validations.ts +40 -0
- package/src/internal/core/user-interruptions.ts +1 -1
- package/src/internal/deprecated-module-imported-from-hardhat2-plugin.ts +12 -0
- package/src/internal/using-hardhat2-plugin-errors.ts +108 -0
- package/src/plugins.ts +16 -0
- package/src/types/artifacts.ts +40 -3
- package/src/types/hre.ts +1 -1
- package/src/types/index.ts +14 -0
- package/src/types/network.ts +1 -1
- package/src/types/plugins.ts +2 -2
- package/src/types/solidity/build-system.ts +75 -14
- package/src/types/solidity/errors.ts +22 -0
- package/src/types/solidity/resolved-file.ts +2 -2
- package/src/types/tasks.ts +143 -36
- package/src/types/test.ts +12 -0
- package/src/types/utils.ts +14 -0
- package/src/utils/result.ts +57 -0
- package/templates/hardhat-3/01-node-test-runner-viem/package.json +11 -11
- package/templates/hardhat-3/02-mocha-ethers/package.json +16 -16
- package/templates/hardhat-3/03-minimal/package.json +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/types/output.d.ts +0 -19
- package/dist/src/internal/builtin-plugins/network-manager/edr/types/output.d.ts.map +0 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/types/output.js +0 -2
- package/dist/src/internal/builtin-plugins/network-manager/edr/types/output.js.map +0 -1
- package/src/internal/builtin-plugins/network-manager/edr/types/output.ts +0 -19
|
@@ -15,6 +15,8 @@ import type {
|
|
|
15
15
|
ExtendTaskArguments,
|
|
16
16
|
TaskArguments,
|
|
17
17
|
LazyActionObject,
|
|
18
|
+
TaskAction,
|
|
19
|
+
TaskOverrideAction,
|
|
18
20
|
} from "../../../types/tasks.js";
|
|
19
21
|
|
|
20
22
|
import { HardhatError } from "@nomicfoundation/hardhat-errors";
|
|
@@ -54,7 +56,11 @@ export class EmptyTaskDefinitionBuilderImplementation
|
|
|
54
56
|
|
|
55
57
|
export class NewTaskDefinitionBuilderImplementation<
|
|
56
58
|
TaskArgumentsT extends TaskArguments = TaskArguments,
|
|
57
|
-
|
|
59
|
+
ActionTypeT extends
|
|
60
|
+
| "LAZY_ACTION"
|
|
61
|
+
| "INLINE_ACTION"
|
|
62
|
+
| "MISSING_ACTION" = "MISSING_ACTION",
|
|
63
|
+
> implements NewTaskDefinitionBuilder<TaskArgumentsT, ActionTypeT>
|
|
58
64
|
{
|
|
59
65
|
readonly #id: string[];
|
|
60
66
|
readonly #usedNames: Set<string> = new Set();
|
|
@@ -65,6 +71,7 @@ export class NewTaskDefinitionBuilderImplementation<
|
|
|
65
71
|
#description: string;
|
|
66
72
|
|
|
67
73
|
#action?: LazyActionObject<NewTaskActionFunction<TaskArgumentsT>>;
|
|
74
|
+
#inlineAction?: NewTaskActionFunction<TaskArgumentsT>;
|
|
68
75
|
|
|
69
76
|
constructor(id: string | string[], description: string = "") {
|
|
70
77
|
validateId(id);
|
|
@@ -80,10 +87,26 @@ export class NewTaskDefinitionBuilderImplementation<
|
|
|
80
87
|
|
|
81
88
|
public setAction(
|
|
82
89
|
action: LazyActionObject<NewTaskActionFunction<TaskArgumentsT>>,
|
|
83
|
-
):
|
|
90
|
+
): NewTaskDefinitionBuilder<TaskArgumentsT, "LAZY_ACTION"> {
|
|
91
|
+
this.#ensureNoActionSet();
|
|
92
|
+
|
|
84
93
|
this.#action = action;
|
|
85
94
|
|
|
86
|
-
|
|
95
|
+
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
96
|
+
-- Cast to update the ActionTypeT to the expected type for this scenario. */
|
|
97
|
+
return this as NewTaskDefinitionBuilder<TaskArgumentsT, "LAZY_ACTION">;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public setInlineAction(
|
|
101
|
+
inlineAction: NewTaskActionFunction<TaskArgumentsT>,
|
|
102
|
+
): NewTaskDefinitionBuilder<TaskArgumentsT, "INLINE_ACTION"> {
|
|
103
|
+
this.#ensureNoActionSet();
|
|
104
|
+
|
|
105
|
+
this.#inlineAction = inlineAction;
|
|
106
|
+
|
|
107
|
+
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
108
|
+
-- Cast to update the ActionTypeT to the expected type for this scenario. */
|
|
109
|
+
return this as NewTaskDefinitionBuilder<TaskArgumentsT, "INLINE_ACTION">;
|
|
87
110
|
}
|
|
88
111
|
|
|
89
112
|
public addOption<
|
|
@@ -104,7 +127,8 @@ export class NewTaskDefinitionBuilderImplementation<
|
|
|
104
127
|
defaultValue: ArgumentTypeToValueType<TypeT>;
|
|
105
128
|
hidden?: boolean;
|
|
106
129
|
}): NewTaskDefinitionBuilder<
|
|
107
|
-
ExtendTaskArguments<NameT, TypeT, TaskArgumentsT
|
|
130
|
+
ExtendTaskArguments<NameT, TypeT, TaskArgumentsT>,
|
|
131
|
+
ActionTypeT
|
|
108
132
|
> {
|
|
109
133
|
const argumentType = type ?? ArgumentType.STRING;
|
|
110
134
|
|
|
@@ -121,7 +145,13 @@ export class NewTaskDefinitionBuilderImplementation<
|
|
|
121
145
|
|
|
122
146
|
this.#options[name] = optionDefinition;
|
|
123
147
|
|
|
124
|
-
|
|
148
|
+
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
149
|
+
-- Cast to update the generic argument types. Propagate 'ActionTypeT' to preserve
|
|
150
|
+
the current action state for subsequent method calls. */
|
|
151
|
+
return this as NewTaskDefinitionBuilder<
|
|
152
|
+
ExtendTaskArguments<NameT, TypeT, TaskArgumentsT>,
|
|
153
|
+
ActionTypeT
|
|
154
|
+
>;
|
|
125
155
|
}
|
|
126
156
|
|
|
127
157
|
public addFlag<NameT extends string>(flagConfig: {
|
|
@@ -130,7 +160,8 @@ export class NewTaskDefinitionBuilderImplementation<
|
|
|
130
160
|
description?: string;
|
|
131
161
|
hidden?: boolean;
|
|
132
162
|
}): NewTaskDefinitionBuilder<
|
|
133
|
-
ExtendTaskArguments<NameT, ArgumentType.FLAG, TaskArgumentsT
|
|
163
|
+
ExtendTaskArguments<NameT, ArgumentType.FLAG, TaskArgumentsT>,
|
|
164
|
+
ActionTypeT
|
|
134
165
|
> {
|
|
135
166
|
return this.addOption({
|
|
136
167
|
...flagConfig,
|
|
@@ -146,7 +177,8 @@ export class NewTaskDefinitionBuilderImplementation<
|
|
|
146
177
|
description?: string;
|
|
147
178
|
defaultValue?: number;
|
|
148
179
|
}): NewTaskDefinitionBuilder<
|
|
149
|
-
ExtendTaskArguments<NameT, ArgumentType.LEVEL, TaskArgumentsT
|
|
180
|
+
ExtendTaskArguments<NameT, ArgumentType.LEVEL, TaskArgumentsT>,
|
|
181
|
+
ActionTypeT
|
|
150
182
|
> {
|
|
151
183
|
return this.addOption({
|
|
152
184
|
...levelConfig,
|
|
@@ -164,7 +196,8 @@ export class NewTaskDefinitionBuilderImplementation<
|
|
|
164
196
|
type?: TypeT;
|
|
165
197
|
defaultValue?: ArgumentTypeToValueType<TypeT>;
|
|
166
198
|
}): NewTaskDefinitionBuilder<
|
|
167
|
-
ExtendTaskArguments<NameT, TypeT, TaskArgumentsT
|
|
199
|
+
ExtendTaskArguments<NameT, TypeT, TaskArgumentsT>,
|
|
200
|
+
ActionTypeT
|
|
168
201
|
> {
|
|
169
202
|
return this.#addPositionalArgument({
|
|
170
203
|
...argConfig,
|
|
@@ -181,7 +214,8 @@ export class NewTaskDefinitionBuilderImplementation<
|
|
|
181
214
|
type?: TypeT;
|
|
182
215
|
defaultValue?: Array<ArgumentTypeToValueType<TypeT>>;
|
|
183
216
|
}): NewTaskDefinitionBuilder<
|
|
184
|
-
ExtendTaskArguments<NameT, TypeT, TaskArgumentsT
|
|
217
|
+
ExtendTaskArguments<NameT, TypeT[], TaskArgumentsT>,
|
|
218
|
+
ActionTypeT
|
|
185
219
|
> {
|
|
186
220
|
return this.#addPositionalArgument({
|
|
187
221
|
...argConfig,
|
|
@@ -189,8 +223,15 @@ export class NewTaskDefinitionBuilderImplementation<
|
|
|
189
223
|
});
|
|
190
224
|
}
|
|
191
225
|
|
|
192
|
-
public build():
|
|
193
|
-
|
|
226
|
+
public build(): ActionTypeT extends "LAZY_ACTION"
|
|
227
|
+
? Extract<
|
|
228
|
+
NewTaskDefinition,
|
|
229
|
+
{ action: LazyActionObject<NewTaskActionFunction> }
|
|
230
|
+
>
|
|
231
|
+
: ActionTypeT extends "INLINE_ACTION"
|
|
232
|
+
? Extract<NewTaskDefinition, { inlineAction: NewTaskActionFunction }>
|
|
233
|
+
: never {
|
|
234
|
+
if (this.#action === undefined && this.#inlineAction === undefined) {
|
|
194
235
|
throw new HardhatError(
|
|
195
236
|
HardhatError.ERRORS.CORE.TASK_DEFINITIONS.NO_ACTION,
|
|
196
237
|
{
|
|
@@ -199,18 +240,30 @@ export class NewTaskDefinitionBuilderImplementation<
|
|
|
199
240
|
);
|
|
200
241
|
}
|
|
201
242
|
|
|
243
|
+
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
244
|
+
-- Cast the return value because TypeScript cannot verify that the object matches
|
|
245
|
+
the conditional type. */
|
|
202
246
|
return {
|
|
203
247
|
type: TaskDefinitionType.NEW_TASK,
|
|
204
248
|
id: this.#id,
|
|
205
249
|
description: this.#description,
|
|
206
250
|
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
207
|
-
-- The type of the action is narrowed in the setAction function to
|
|
251
|
+
-- The type of the action is narrowed in the setAction function or setInlineAction to
|
|
208
252
|
improve the argument types. Once the task is built, we use the more
|
|
209
253
|
general type to avoid having to parameterize the NewTaskDefinition */
|
|
210
|
-
|
|
254
|
+
...((this.#action !== undefined
|
|
255
|
+
? { action: this.#action }
|
|
256
|
+
: { inlineAction: this.#inlineAction }) as TaskAction),
|
|
211
257
|
options: this.#options,
|
|
212
258
|
positionalArguments: this.#positionalArgs,
|
|
213
|
-
}
|
|
259
|
+
} as ActionTypeT extends "LAZY_ACTION"
|
|
260
|
+
? Extract<
|
|
261
|
+
NewTaskDefinition,
|
|
262
|
+
{ action: LazyActionObject<NewTaskActionFunction> }
|
|
263
|
+
>
|
|
264
|
+
: ActionTypeT extends "INLINE_ACTION"
|
|
265
|
+
? Extract<NewTaskDefinition, { inlineAction: NewTaskActionFunction }>
|
|
266
|
+
: never;
|
|
214
267
|
}
|
|
215
268
|
|
|
216
269
|
#addPositionalArgument<
|
|
@@ -231,7 +284,8 @@ export class NewTaskDefinitionBuilderImplementation<
|
|
|
231
284
|
| Array<ArgumentTypeToValueType<TypeT>>;
|
|
232
285
|
isVariadic: boolean;
|
|
233
286
|
}): NewTaskDefinitionBuilder<
|
|
234
|
-
ExtendTaskArguments<NameT, TypeT, TaskArgumentsT
|
|
287
|
+
ExtendTaskArguments<NameT, TypeT, TaskArgumentsT>,
|
|
288
|
+
ActionTypeT
|
|
235
289
|
> {
|
|
236
290
|
const argumentType = type ?? ArgumentType.STRING;
|
|
237
291
|
|
|
@@ -253,13 +307,34 @@ export class NewTaskDefinitionBuilderImplementation<
|
|
|
253
307
|
|
|
254
308
|
this.#positionalArgs.push(positionalArgDef);
|
|
255
309
|
|
|
256
|
-
|
|
310
|
+
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
311
|
+
-- Cast to update the generic argument types. Propagate 'ActionTypeT' to preserve
|
|
312
|
+
the current action state for subsequent method calls. */
|
|
313
|
+
return this as NewTaskDefinitionBuilder<
|
|
314
|
+
ExtendTaskArguments<NameT, TypeT, TaskArgumentsT>,
|
|
315
|
+
ActionTypeT
|
|
316
|
+
>;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
#ensureNoActionSet(): void {
|
|
320
|
+
if (this.#action !== undefined || this.#inlineAction !== undefined) {
|
|
321
|
+
throw new HardhatError(
|
|
322
|
+
HardhatError.ERRORS.CORE.TASK_DEFINITIONS.ACTION_ALREADY_SET,
|
|
323
|
+
{
|
|
324
|
+
task: formatTaskId(this.#id),
|
|
325
|
+
},
|
|
326
|
+
);
|
|
327
|
+
}
|
|
257
328
|
}
|
|
258
329
|
}
|
|
259
330
|
|
|
260
331
|
export class TaskOverrideDefinitionBuilderImplementation<
|
|
261
332
|
TaskArgumentsT extends TaskArguments = TaskArguments,
|
|
262
|
-
|
|
333
|
+
ActionTypeT extends
|
|
334
|
+
| "LAZY_ACTION"
|
|
335
|
+
| "INLINE_ACTION"
|
|
336
|
+
| "MISSING_ACTION" = "MISSING_ACTION",
|
|
337
|
+
> implements TaskOverrideDefinitionBuilder<TaskArgumentsT, ActionTypeT>
|
|
263
338
|
{
|
|
264
339
|
readonly #id: string[];
|
|
265
340
|
|
|
@@ -268,6 +343,7 @@ export class TaskOverrideDefinitionBuilderImplementation<
|
|
|
268
343
|
#description?: string;
|
|
269
344
|
|
|
270
345
|
#action?: LazyActionObject<TaskOverrideActionFunction<TaskArgumentsT>>;
|
|
346
|
+
#inlineAction?: TaskOverrideActionFunction<TaskArgumentsT>;
|
|
271
347
|
|
|
272
348
|
constructor(id: string | string[]) {
|
|
273
349
|
validateId(id);
|
|
@@ -282,10 +358,29 @@ export class TaskOverrideDefinitionBuilderImplementation<
|
|
|
282
358
|
|
|
283
359
|
public setAction(
|
|
284
360
|
action: LazyActionObject<TaskOverrideActionFunction<TaskArgumentsT>>,
|
|
285
|
-
):
|
|
361
|
+
): TaskOverrideDefinitionBuilder<TaskArgumentsT, "LAZY_ACTION"> {
|
|
362
|
+
this.#ensureNoActionSet();
|
|
363
|
+
|
|
286
364
|
this.#action = action;
|
|
287
365
|
|
|
288
|
-
|
|
366
|
+
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
367
|
+
-- Cast to update the ActionTypeT to the expected type for this scenario. */
|
|
368
|
+
return this as TaskOverrideDefinitionBuilder<TaskArgumentsT, "LAZY_ACTION">;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
public setInlineAction(
|
|
372
|
+
inlineAction: TaskOverrideActionFunction<TaskArgumentsT>,
|
|
373
|
+
): TaskOverrideDefinitionBuilder<TaskArgumentsT, "INLINE_ACTION"> {
|
|
374
|
+
this.#ensureNoActionSet();
|
|
375
|
+
|
|
376
|
+
this.#inlineAction = inlineAction;
|
|
377
|
+
|
|
378
|
+
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
379
|
+
-- Cast to update the ActionTypeT to the expected type for this scenario. */
|
|
380
|
+
return this as TaskOverrideDefinitionBuilder<
|
|
381
|
+
TaskArgumentsT,
|
|
382
|
+
"INLINE_ACTION"
|
|
383
|
+
>;
|
|
289
384
|
}
|
|
290
385
|
|
|
291
386
|
public addOption<
|
|
@@ -306,7 +401,8 @@ export class TaskOverrideDefinitionBuilderImplementation<
|
|
|
306
401
|
defaultValue: ArgumentTypeToValueType<TypeT>;
|
|
307
402
|
hidden?: boolean;
|
|
308
403
|
}): TaskOverrideDefinitionBuilder<
|
|
309
|
-
ExtendTaskArguments<NameT, TypeT, TaskArgumentsT
|
|
404
|
+
ExtendTaskArguments<NameT, TypeT, TaskArgumentsT>,
|
|
405
|
+
ActionTypeT
|
|
310
406
|
> {
|
|
311
407
|
const argumentType = type ?? ArgumentType.STRING;
|
|
312
408
|
|
|
@@ -331,16 +427,23 @@ export class TaskOverrideDefinitionBuilderImplementation<
|
|
|
331
427
|
|
|
332
428
|
this.#options[name] = optionDefinition;
|
|
333
429
|
|
|
334
|
-
|
|
430
|
+
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
431
|
+
-- Cast to update the generic argument types. Propagate 'ActionTypeT' to preserve
|
|
432
|
+
the current action state for subsequent method calls. */
|
|
433
|
+
return this as TaskOverrideDefinitionBuilder<
|
|
434
|
+
ExtendTaskArguments<NameT, TypeT, TaskArgumentsT>,
|
|
435
|
+
ActionTypeT
|
|
436
|
+
>;
|
|
335
437
|
}
|
|
336
438
|
|
|
337
439
|
public addFlag<NameT extends string>(flagConfig: {
|
|
338
|
-
name:
|
|
440
|
+
name: NameT;
|
|
339
441
|
shortName?: string;
|
|
340
442
|
description?: string;
|
|
341
443
|
hidden?: boolean;
|
|
342
444
|
}): TaskOverrideDefinitionBuilder<
|
|
343
|
-
ExtendTaskArguments<NameT, ArgumentType.FLAG, TaskArgumentsT
|
|
445
|
+
ExtendTaskArguments<NameT, ArgumentType.FLAG, TaskArgumentsT>,
|
|
446
|
+
ActionTypeT
|
|
344
447
|
> {
|
|
345
448
|
return this.addOption({
|
|
346
449
|
...flagConfig,
|
|
@@ -351,12 +454,13 @@ export class TaskOverrideDefinitionBuilderImplementation<
|
|
|
351
454
|
}
|
|
352
455
|
|
|
353
456
|
public addLevel<NameT extends string>(levelConfig: {
|
|
354
|
-
name:
|
|
457
|
+
name: NameT;
|
|
355
458
|
shortName?: string;
|
|
356
459
|
description?: string;
|
|
357
460
|
defaultValue?: number;
|
|
358
461
|
}): TaskOverrideDefinitionBuilder<
|
|
359
|
-
ExtendTaskArguments<NameT, ArgumentType.LEVEL, TaskArgumentsT
|
|
462
|
+
ExtendTaskArguments<NameT, ArgumentType.LEVEL, TaskArgumentsT>,
|
|
463
|
+
ActionTypeT
|
|
360
464
|
> {
|
|
361
465
|
return this.addOption({
|
|
362
466
|
...levelConfig,
|
|
@@ -365,8 +469,18 @@ export class TaskOverrideDefinitionBuilderImplementation<
|
|
|
365
469
|
});
|
|
366
470
|
}
|
|
367
471
|
|
|
368
|
-
public build():
|
|
369
|
-
|
|
472
|
+
public build(): ActionTypeT extends "LAZY_ACTION"
|
|
473
|
+
? Extract<
|
|
474
|
+
TaskOverrideDefinition,
|
|
475
|
+
{ action: LazyActionObject<TaskOverrideActionFunction> }
|
|
476
|
+
>
|
|
477
|
+
: ActionTypeT extends "INLINE_ACTION"
|
|
478
|
+
? Extract<
|
|
479
|
+
TaskOverrideDefinition,
|
|
480
|
+
{ inlineAction: TaskOverrideActionFunction }
|
|
481
|
+
>
|
|
482
|
+
: never {
|
|
483
|
+
if (this.#action === undefined && this.#inlineAction === undefined) {
|
|
370
484
|
throw new HardhatError(
|
|
371
485
|
HardhatError.ERRORS.CORE.TASK_DEFINITIONS.NO_ACTION,
|
|
372
486
|
{
|
|
@@ -375,16 +489,46 @@ export class TaskOverrideDefinitionBuilderImplementation<
|
|
|
375
489
|
);
|
|
376
490
|
}
|
|
377
491
|
|
|
492
|
+
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
493
|
+
-- Cast the return value because TypeScript cannot verify that the object matches
|
|
494
|
+
the conditional type. */
|
|
378
495
|
return {
|
|
379
496
|
type: TaskDefinitionType.TASK_OVERRIDE,
|
|
380
497
|
id: this.#id,
|
|
381
498
|
description: this.#description,
|
|
382
499
|
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
383
|
-
-- The type of the action is narrowed in the setAction function to
|
|
500
|
+
-- The type of the action is narrowed in the setAction function or setInlineAction to
|
|
384
501
|
improve the argument types. Once the task is built, we use the more
|
|
385
502
|
general type to avoid having to parameterize the TaskOverrideDefinition */
|
|
386
|
-
|
|
503
|
+
...((this.#action !== undefined
|
|
504
|
+
? {
|
|
505
|
+
action: this.#action,
|
|
506
|
+
}
|
|
507
|
+
: {
|
|
508
|
+
inlineAction: this.#inlineAction,
|
|
509
|
+
}) as TaskOverrideAction),
|
|
387
510
|
options: this.#options,
|
|
388
|
-
}
|
|
511
|
+
} as ActionTypeT extends "LAZY_ACTION"
|
|
512
|
+
? Extract<
|
|
513
|
+
TaskOverrideDefinition,
|
|
514
|
+
{ action: LazyActionObject<TaskOverrideActionFunction> }
|
|
515
|
+
>
|
|
516
|
+
: ActionTypeT extends "INLINE_ACTION"
|
|
517
|
+
? Extract<
|
|
518
|
+
TaskOverrideDefinition,
|
|
519
|
+
{ inlineAction: TaskOverrideActionFunction }
|
|
520
|
+
>
|
|
521
|
+
: never;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
#ensureNoActionSet(): void {
|
|
525
|
+
if (this.#action !== undefined || this.#inlineAction !== undefined) {
|
|
526
|
+
throw new HardhatError(
|
|
527
|
+
HardhatError.ERRORS.CORE.TASK_DEFINITIONS.ACTION_ALREADY_SET,
|
|
528
|
+
{
|
|
529
|
+
task: formatTaskId(this.#id),
|
|
530
|
+
},
|
|
531
|
+
);
|
|
532
|
+
}
|
|
389
533
|
}
|
|
390
534
|
}
|
|
@@ -8,6 +8,7 @@ import type {
|
|
|
8
8
|
LazyActionObject,
|
|
9
9
|
NewTaskActionFunction,
|
|
10
10
|
Task,
|
|
11
|
+
TaskAction,
|
|
11
12
|
TaskActions,
|
|
12
13
|
TaskArguments,
|
|
13
14
|
TaskOverrideActionFunction,
|
|
@@ -36,7 +37,7 @@ export class ResolvedTask implements Task {
|
|
|
36
37
|
return new ResolvedTask(
|
|
37
38
|
id,
|
|
38
39
|
description,
|
|
39
|
-
[{ pluginId, action: undefined }],
|
|
40
|
+
[{ pluginId, action: undefined, inlineAction: undefined }],
|
|
40
41
|
new Map(),
|
|
41
42
|
[],
|
|
42
43
|
pluginId,
|
|
@@ -49,7 +50,7 @@ export class ResolvedTask implements Task {
|
|
|
49
50
|
hre: HardhatRuntimeEnvironment,
|
|
50
51
|
id: string[],
|
|
51
52
|
description: string,
|
|
52
|
-
|
|
53
|
+
taskAction: TaskAction,
|
|
53
54
|
options: Record<string, OptionDefinition>,
|
|
54
55
|
positionalArguments: PositionalArgumentDefinition[],
|
|
55
56
|
pluginId?: string,
|
|
@@ -57,7 +58,12 @@ export class ResolvedTask implements Task {
|
|
|
57
58
|
return new ResolvedTask(
|
|
58
59
|
id,
|
|
59
60
|
description,
|
|
60
|
-
[
|
|
61
|
+
[
|
|
62
|
+
{
|
|
63
|
+
pluginId,
|
|
64
|
+
...taskAction,
|
|
65
|
+
},
|
|
66
|
+
],
|
|
61
67
|
new Map(Object.entries(options)),
|
|
62
68
|
positionalArguments,
|
|
63
69
|
pluginId,
|
|
@@ -80,7 +86,11 @@ export class ResolvedTask implements Task {
|
|
|
80
86
|
}
|
|
81
87
|
|
|
82
88
|
public get isEmpty(): boolean {
|
|
83
|
-
return
|
|
89
|
+
return (
|
|
90
|
+
this.actions.length === 1 &&
|
|
91
|
+
this.actions[0].action === undefined &&
|
|
92
|
+
this.actions[0].inlineAction === undefined
|
|
93
|
+
);
|
|
84
94
|
}
|
|
85
95
|
|
|
86
96
|
/**
|
|
@@ -142,17 +152,25 @@ export class ResolvedTask implements Task {
|
|
|
142
152
|
nextTaskArguments: TaskArguments,
|
|
143
153
|
currentIndex = this.actions.length - 1,
|
|
144
154
|
): Promise<any> => {
|
|
155
|
+
const currentTaskAction = this.actions[currentIndex];
|
|
156
|
+
|
|
157
|
+
let actionFn: NewTaskActionFunction | TaskOverrideActionFunction;
|
|
158
|
+
|
|
145
159
|
// The first action may be empty if the task was originally an empty task
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
160
|
+
if (currentTaskAction.inlineAction !== undefined) {
|
|
161
|
+
actionFn = currentTaskAction.inlineAction;
|
|
162
|
+
} else {
|
|
163
|
+
const action =
|
|
164
|
+
currentTaskAction.action ??
|
|
165
|
+
(async () => ({
|
|
166
|
+
default: () => {},
|
|
167
|
+
}));
|
|
151
168
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
169
|
+
actionFn = await this.#resolveImportAction(
|
|
170
|
+
action,
|
|
171
|
+
currentTaskAction.pluginId,
|
|
172
|
+
);
|
|
173
|
+
}
|
|
156
174
|
|
|
157
175
|
if (currentIndex === 0) {
|
|
158
176
|
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions --
|
|
@@ -19,6 +19,7 @@ import { TaskDefinitionType } from "../../../types/tasks.js";
|
|
|
19
19
|
import { ResolvedTask } from "./resolved-task.js";
|
|
20
20
|
import { formatTaskId, getActorFragment } from "./utils.js";
|
|
21
21
|
import {
|
|
22
|
+
validateAction,
|
|
22
23
|
validateId,
|
|
23
24
|
validateOption,
|
|
24
25
|
validatePositionalArgument,
|
|
@@ -41,7 +42,7 @@ export class TaskManagerImplementation implements TaskManager {
|
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
for (const taskDefinition of plugin.tasks) {
|
|
44
|
-
this.#validateTaskDefinition(taskDefinition);
|
|
45
|
+
this.#validateTaskDefinition(taskDefinition, true);
|
|
45
46
|
this.#reduceTaskDefinition(
|
|
46
47
|
globalOptionDefinitions,
|
|
47
48
|
taskDefinition,
|
|
@@ -52,7 +53,7 @@ export class TaskManagerImplementation implements TaskManager {
|
|
|
52
53
|
|
|
53
54
|
// reduce global user defined tasks
|
|
54
55
|
for (const taskDefinition of this.#hre.config.tasks) {
|
|
55
|
-
this.#validateTaskDefinition(taskDefinition);
|
|
56
|
+
this.#validateTaskDefinition(taskDefinition, false);
|
|
56
57
|
this.#reduceTaskDefinition(globalOptionDefinitions, taskDefinition);
|
|
57
58
|
}
|
|
58
59
|
}
|
|
@@ -171,7 +172,9 @@ export class TaskManagerImplementation implements TaskManager {
|
|
|
171
172
|
this.#hre,
|
|
172
173
|
taskDefinition.id,
|
|
173
174
|
taskDefinition.description,
|
|
174
|
-
taskDefinition.action
|
|
175
|
+
taskDefinition.action !== undefined
|
|
176
|
+
? { action: taskDefinition.action }
|
|
177
|
+
: { inlineAction: taskDefinition.inlineAction },
|
|
175
178
|
taskDefinition.options,
|
|
176
179
|
taskDefinition.positionalArguments,
|
|
177
180
|
pluginId,
|
|
@@ -278,10 +281,18 @@ export class TaskManagerImplementation implements TaskManager {
|
|
|
278
281
|
task.description = taskDefinition.description;
|
|
279
282
|
}
|
|
280
283
|
|
|
281
|
-
task.actions.push({
|
|
284
|
+
task.actions.push({
|
|
285
|
+
pluginId,
|
|
286
|
+
...(taskDefinition.action !== undefined
|
|
287
|
+
? { action: taskDefinition.action }
|
|
288
|
+
: { inlineAction: taskDefinition.inlineAction }),
|
|
289
|
+
});
|
|
282
290
|
}
|
|
283
291
|
|
|
284
|
-
#validateTaskDefinition(
|
|
292
|
+
#validateTaskDefinition(
|
|
293
|
+
taskDefinition: TaskDefinition,
|
|
294
|
+
isPlugin: boolean,
|
|
295
|
+
): void {
|
|
285
296
|
validateId(taskDefinition.id);
|
|
286
297
|
|
|
287
298
|
// Empty tasks don't have actions, options, or positional arguments
|
|
@@ -289,6 +300,13 @@ export class TaskManagerImplementation implements TaskManager {
|
|
|
289
300
|
return;
|
|
290
301
|
}
|
|
291
302
|
|
|
303
|
+
validateAction(
|
|
304
|
+
taskDefinition.action,
|
|
305
|
+
taskDefinition.inlineAction,
|
|
306
|
+
taskDefinition.id,
|
|
307
|
+
isPlugin,
|
|
308
|
+
);
|
|
309
|
+
|
|
292
310
|
const usedNames = new Set<string>();
|
|
293
311
|
|
|
294
312
|
Object.values(taskDefinition.options).forEach((optionDefinition) =>
|
|
@@ -4,6 +4,12 @@ import type {
|
|
|
4
4
|
OptionDefinition,
|
|
5
5
|
PositionalArgumentDefinition,
|
|
6
6
|
} from "../../../types/arguments.js";
|
|
7
|
+
import type {
|
|
8
|
+
LazyActionObject,
|
|
9
|
+
NewTaskActionFunction,
|
|
10
|
+
TaskArguments,
|
|
11
|
+
TaskOverrideActionFunction,
|
|
12
|
+
} from "../../../types/tasks.js";
|
|
7
13
|
|
|
8
14
|
import { HardhatError } from "@nomicfoundation/hardhat-errors";
|
|
9
15
|
|
|
@@ -23,6 +29,40 @@ export function validateId(id: string | string[]): void {
|
|
|
23
29
|
}
|
|
24
30
|
}
|
|
25
31
|
|
|
32
|
+
export function validateAction(
|
|
33
|
+
action:
|
|
34
|
+
| LazyActionObject<NewTaskActionFunction<TaskArguments>>
|
|
35
|
+
| LazyActionObject<TaskOverrideActionFunction<TaskArguments>>
|
|
36
|
+
| undefined,
|
|
37
|
+
inlineAction:
|
|
38
|
+
| NewTaskActionFunction<TaskArguments>
|
|
39
|
+
| TaskOverrideActionFunction<TaskArguments>
|
|
40
|
+
| undefined,
|
|
41
|
+
taskId: string[],
|
|
42
|
+
isPlugin: boolean,
|
|
43
|
+
): void {
|
|
44
|
+
if (isPlugin && inlineAction !== undefined) {
|
|
45
|
+
throw new HardhatError(
|
|
46
|
+
HardhatError.ERRORS.CORE.TASK_DEFINITIONS.INLINE_ACTION_CANNOT_BE_USED_IN_PLUGINS,
|
|
47
|
+
{ task: formatTaskId(taskId) },
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (action !== undefined && inlineAction !== undefined) {
|
|
52
|
+
throw new HardhatError(
|
|
53
|
+
HardhatError.ERRORS.CORE.TASK_DEFINITIONS.ACTION_AND_INLINE_ACTION_SET,
|
|
54
|
+
{ task: formatTaskId(taskId) },
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (action === undefined && inlineAction === undefined) {
|
|
59
|
+
throw new HardhatError(
|
|
60
|
+
HardhatError.ERRORS.CORE.TASK_DEFINITIONS.NO_ACTION,
|
|
61
|
+
{ task: formatTaskId(taskId) },
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
26
66
|
export function validateOption(
|
|
27
67
|
{ name, shortName, type, defaultValue }: OptionDefinition,
|
|
28
68
|
usedNames: Set<string>,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// This is an empty module that is used to exported it with a subpath that's
|
|
2
|
+
// commonly used by Hardhat 2 plugins. This is to avoid the plugins breaking
|
|
3
|
+
// when the `require` it, so that they have an opportunity to run a function
|
|
4
|
+
// that throws a better error message.
|
|
5
|
+
|
|
6
|
+
// The reason this module can be empty is that Hardhat 2 plugins are CJS modules
|
|
7
|
+
// so they can destructure the require and get `undefined` values, instead of
|
|
8
|
+
// a load-time error.
|
|
9
|
+
|
|
10
|
+
// We could also throw from this file, but if it gets imported by an ESM module
|
|
11
|
+
// you don't get an import-stack-trace, so you loose the possibility of figuring
|
|
12
|
+
// out which plugin is triggering the error.
|