hardhat 3.3.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +54 -0
- package/dist/src/internal/builtin-plugins/artifacts/artifact-manager.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/artifacts/artifact-manager.js +5 -13
- package/dist/src/internal/builtin-plugins/artifacts/artifact-manager.js.map +1 -1
- package/dist/src/internal/builtin-plugins/console/task-action.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/console/task-action.js +2 -1
- package/dist/src/internal/builtin-plugins/console/task-action.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/exports.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/exports.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/exports.js +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/exports.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 +1 -2
- 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 +7 -5
- 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 +60 -44
- 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 +6 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers/accessors.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers/accessors.js +14 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers/accessors.js.map +1 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers/compat.d.ts +4 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers/compat.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers/compat.js +27 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers/compat.js.map +1 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers/utils.d.ts +36 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers/utils.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers/utils.js +86 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers/utils.js.map +1 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/hre.js +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/hre.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/test.js +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/test.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 +1 -2
- package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/types.d.ts +10 -2
- package/dist/src/internal/builtin-plugins/gas-analytics/types.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/solidity-stack-trace.d.ts +4 -4
- package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/solidity-stack-trace.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/solidity-stack-trace.js +2 -2
- package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/solidity-stack-trace.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-solidity-errors.d.ts +6 -3
- package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-solidity-errors.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-solidity-errors.js +23 -5
- package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-solidity-errors.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.js +2 -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/hook-handlers/hre.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/hre.js +22 -0
- package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/hre.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/network.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/network.js +17 -9
- package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/network.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/network-manager.d.ts +11 -1
- package/dist/src/internal/builtin-plugins/network-manager/network-manager.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/network-manager.js +86 -19
- package/dist/src/internal/builtin-plugins/network-manager/network-manager.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/hd-wallet-handler.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/hd-wallet-handler.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/local-accounts.d.ts +1 -0
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/local-accounts.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/local-accounts.js +22 -8
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/local-accounts.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/sender.d.ts +2 -0
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/sender.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/sender.js +19 -12
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/sender.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/chain-id/chain-id-handler.d.ts +1 -0
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/chain-id/chain-id-handler.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/chain-id/chain-id-handler.js +9 -3
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/chain-id/chain-id-handler.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/gas/automatic-gas-handler.d.ts +2 -0
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/gas/automatic-gas-handler.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/gas/automatic-gas-handler.js +5 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/gas/automatic-gas-handler.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/gas/automatic-gas-price-handler.d.ts +1 -0
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/gas/automatic-gas-price-handler.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/gas/automatic-gas-price-handler.js +5 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/gas/automatic-gas-price-handler.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/gas/fixed-gas-handler.d.ts +1 -0
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/gas/fixed-gas-handler.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/gas/fixed-gas-handler.js +5 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/gas/fixed-gas-handler.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/gas/fixed-gas-price-handler.d.ts +1 -0
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/gas/fixed-gas-price-handler.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/gas/fixed-gas-price-handler.js +5 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/gas/fixed-gas-price-handler.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/types.d.ts +9 -0
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/types.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/revert-error-code.d.ts +2 -0
- package/dist/src/internal/builtin-plugins/network-manager/revert-error-code.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/network-manager/revert-error-code.js +3 -0
- package/dist/src/internal/builtin-plugins/network-manager/revert-error-code.js.map +1 -0
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/config.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/config.d.ts.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 +2 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-validation.js.map +1 -1
- package/dist/src/internal/builtin-plugins/node/json-rpc/handler.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/node/json-rpc/handler.js +8 -2
- package/dist/src/internal/builtin-plugins/node/json-rpc/handler.js.map +1 -1
- package/dist/src/internal/builtin-plugins/node/task-action.js +2 -2
- package/dist/src/internal/builtin-plugins/node/task-action.js.map +1 -1
- package/dist/src/internal/builtin-plugins/run/task-action.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/run/task-action.js +2 -1
- package/dist/src/internal/builtin-plugins/run/task-action.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/artifacts.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/artifacts.js +3 -0
- package/dist/src/internal/builtin-plugins/solidity/build-system/artifacts.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.d.ts +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 +114 -31
- package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/cache.d.ts +2 -0
- package/dist/src/internal/builtin-plugins/solidity/build-system/cache.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/cache.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job.d.ts +3 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job.js +11 -3
- package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/dependency-graph.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/dependency-graph.js +5 -5
- package/dist/src/internal/builtin-plugins/solidity/build-system/dependency-graph.js.map +1 -1
- 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 +1 -0
- package/dist/src/internal/builtin-plugins/solidity/build-system/solc-info.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/warning-suppression.js +2 -2
- package/dist/src/internal/builtin-plugins/solidity/build-system/warning-suppression.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 +19 -16
- package/dist/src/internal/builtin-plugins/solidity/config.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/constants.d.ts +3 -0
- package/dist/src/internal/builtin-plugins/solidity/constants.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity/constants.js +19 -0
- package/dist/src/internal/builtin-plugins/solidity/constants.js.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity/tasks/build.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/solidity/tasks/build.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/tasks/build.js +225 -55
- package/dist/src/internal/builtin-plugins/solidity/tasks/build.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/type-extensions.d.ts +30 -4
- package/dist/src/internal/builtin-plugins/solidity/type-extensions.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/type-extensions.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/config.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/config.js +5 -3
- package/dist/src/internal/builtin-plugins/solidity-test/config.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.d.ts +0 -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 +0 -3
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/runner.d.ts +2 -8
- package/dist/src/internal/builtin-plugins/solidity-test/runner.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/runner.js +47 -50
- package/dist/src/internal/builtin-plugins/solidity-test/runner.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/stack-trace-solidity-errors.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/stack-trace-solidity-errors.js +11 -2
- package/dist/src/internal/builtin-plugins/solidity-test/stack-trace-solidity-errors.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/task-action.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/task-action.js +108 -32
- 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 -2
- 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 +3 -4
- package/dist/src/internal/builtin-plugins/test/task-action.js.map +1 -1
- package/dist/src/internal/cli/main.d.ts.map +1 -1
- package/dist/src/internal/cli/main.js +8 -0
- package/dist/src/internal/cli/main.js.map +1 -1
- package/dist/src/types/artifacts.d.ts +5 -4
- package/dist/src/types/artifacts.d.ts.map +1 -1
- package/dist/src/types/network.d.ts +39 -0
- package/dist/src/types/network.d.ts.map +1 -1
- package/dist/src/types/solidity/build-system.d.ts +66 -3
- package/dist/src/types/solidity/build-system.d.ts.map +1 -1
- package/dist/src/types/solidity/build-system.js.map +1 -1
- package/dist/src/types/solidity/compilation-job.d.ts +6 -0
- package/dist/src/types/solidity/compilation-job.d.ts.map +1 -1
- package/dist/src/types/solidity/solidity-artifacts.d.ts +14 -0
- package/dist/src/types/solidity/solidity-artifacts.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/internal/builtin-plugins/artifacts/artifact-manager.ts +9 -15
- package/src/internal/builtin-plugins/console/task-action.ts +2 -1
- package/src/internal/builtin-plugins/gas-analytics/exports.ts +1 -1
- package/src/internal/builtin-plugins/gas-analytics/function-gas-snapshots.ts +1 -2
- package/src/internal/builtin-plugins/gas-analytics/gas-analytics-manager.ts +100 -61
- package/src/internal/builtin-plugins/gas-analytics/helpers/accessors.ts +31 -0
- package/src/internal/builtin-plugins/gas-analytics/helpers/compat.ts +37 -0
- package/src/internal/builtin-plugins/gas-analytics/helpers/utils.ts +112 -0
- package/src/internal/builtin-plugins/gas-analytics/hook-handlers/hre.ts +1 -1
- package/src/internal/builtin-plugins/gas-analytics/hook-handlers/test.ts +1 -1
- package/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.ts +1 -2
- package/src/internal/builtin-plugins/gas-analytics/types.ts +11 -2
- package/src/internal/builtin-plugins/network-manager/edr/stack-traces/solidity-stack-trace.ts +4 -0
- package/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-solidity-errors.ts +28 -4
- package/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.ts +2 -1
- package/src/internal/builtin-plugins/network-manager/hook-handlers/hre.ts +29 -0
- package/src/internal/builtin-plugins/network-manager/hook-handlers/network.ts +20 -14
- package/src/internal/builtin-plugins/network-manager/network-manager.ts +130 -27
- package/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/hd-wallet-handler.ts +1 -0
- package/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/local-accounts.ts +30 -13
- package/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/sender.ts +25 -17
- package/src/internal/builtin-plugins/network-manager/request-handlers/handlers/chain-id/chain-id-handler.ts +13 -5
- package/src/internal/builtin-plugins/network-manager/request-handlers/handlers/gas/automatic-gas-handler.ts +7 -1
- package/src/internal/builtin-plugins/network-manager/request-handlers/handlers/gas/automatic-gas-price-handler.ts +7 -1
- package/src/internal/builtin-plugins/network-manager/request-handlers/handlers/gas/fixed-gas-handler.ts +7 -1
- package/src/internal/builtin-plugins/network-manager/request-handlers/handlers/gas/fixed-gas-price-handler.ts +7 -1
- package/src/internal/builtin-plugins/network-manager/request-handlers/types.ts +10 -0
- package/src/internal/builtin-plugins/network-manager/revert-error-code.ts +2 -0
- package/src/internal/builtin-plugins/network-manager/type-extensions/config.ts +1 -1
- package/src/internal/builtin-plugins/network-manager/type-validation.ts +5 -1
- package/src/internal/builtin-plugins/node/json-rpc/handler.ts +10 -2
- package/src/internal/builtin-plugins/node/task-action.ts +2 -2
- package/src/internal/builtin-plugins/run/task-action.ts +2 -1
- package/src/internal/builtin-plugins/solidity/build-system/artifacts.ts +3 -0
- package/src/internal/builtin-plugins/solidity/build-system/build-system.ts +156 -34
- package/src/internal/builtin-plugins/solidity/build-system/cache.ts +2 -0
- package/src/internal/builtin-plugins/solidity/build-system/compilation-job.ts +15 -9
- package/src/internal/builtin-plugins/solidity/build-system/dependency-graph.ts +9 -7
- package/src/internal/builtin-plugins/solidity/build-system/solc-info.ts +1 -0
- package/src/internal/builtin-plugins/solidity/build-system/warning-suppression.ts +2 -2
- package/src/internal/builtin-plugins/solidity/config.ts +23 -13
- package/src/internal/builtin-plugins/solidity/constants.ts +21 -0
- package/src/internal/builtin-plugins/solidity/tasks/build.ts +359 -74
- package/src/internal/builtin-plugins/solidity/type-extensions.ts +38 -8
- package/src/internal/builtin-plugins/solidity-test/config.ts +11 -2
- package/src/internal/builtin-plugins/solidity-test/helpers.ts +0 -7
- package/src/internal/builtin-plugins/solidity-test/runner.ts +64 -83
- package/src/internal/builtin-plugins/solidity-test/stack-trace-solidity-errors.ts +15 -2
- package/src/internal/builtin-plugins/solidity-test/task-action.ts +161 -43
- package/src/internal/builtin-plugins/solidity-test/type-extensions.ts +1 -2
- package/src/internal/builtin-plugins/test/task-action.ts +3 -4
- package/src/internal/cli/main.ts +14 -0
- package/src/types/artifacts.ts +5 -4
- package/src/types/network.ts +48 -0
- package/src/types/solidity/build-system.ts +66 -3
- package/src/types/solidity/compilation-job.ts +7 -0
- package/src/types/solidity/solidity-artifacts.ts +16 -0
- package/templates/hardhat-2/04-mocha-viem-ts/package.json +1 -1
- package/templates/hardhat-3/01-node-test-runner-viem/gitignore +11 -0
- package/templates/hardhat-3/01-node-test-runner-viem/package.json +12 -12
- package/templates/hardhat-3/01-node-test-runner-viem/scripts/send-op-tx.ts +1 -1
- package/templates/hardhat-3/01-node-test-runner-viem/test/Counter.ts +1 -1
- package/templates/hardhat-3/02-mocha-ethers/gitignore +11 -0
- package/templates/hardhat-3/02-mocha-ethers/package.json +14 -14
- package/templates/hardhat-3/02-mocha-ethers/scripts/send-op-tx.ts +1 -1
- package/templates/hardhat-3/02-mocha-ethers/test/Counter.ts +1 -1
- package/templates/hardhat-3/03-minimal/gitignore +11 -0
- package/templates/hardhat-3/03-minimal/package.json +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers.d.ts +0 -14
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers.d.ts.map +0 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers.js +0 -55
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers.js.map +0 -1
- package/src/internal/builtin-plugins/gas-analytics/helpers.ts +0 -96
|
@@ -22,6 +22,7 @@ import type {
|
|
|
22
22
|
CacheHitInfo,
|
|
23
23
|
} from "../../../../types/solidity/build-system.js";
|
|
24
24
|
import type {
|
|
25
|
+
ToolVersions,
|
|
25
26
|
CompilationJob,
|
|
26
27
|
Compiler,
|
|
27
28
|
CompilerOutput,
|
|
@@ -57,6 +58,7 @@ import debug from "debug";
|
|
|
57
58
|
import pMap from "p-map";
|
|
58
59
|
|
|
59
60
|
import { FileBuildResultType } from "../../../../types/solidity/build-system.js";
|
|
61
|
+
import { getHardhatVersion } from "../../../utils/package.js";
|
|
60
62
|
import { DEFAULT_BUILD_PROFILE } from "../build-profiles.js";
|
|
61
63
|
import { getSolcCompilerForConfig } from "../solidity-hooks.js";
|
|
62
64
|
|
|
@@ -153,15 +155,17 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
153
155
|
|
|
154
156
|
public async getScope(fsPath: string): Promise<BuildScope> {
|
|
155
157
|
if (
|
|
156
|
-
fsPath.startsWith(this.#options.solidityTestsPath) &&
|
|
158
|
+
fsPath.startsWith(this.#options.solidityTestsPath + path.sep) &&
|
|
157
159
|
fsPath.endsWith(".sol")
|
|
158
160
|
) {
|
|
159
161
|
return "tests";
|
|
160
162
|
}
|
|
161
163
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
164
|
+
if (fsPath.endsWith(".t.sol")) {
|
|
165
|
+
for (const sourcesPath of this.#options.soliditySourcesPaths) {
|
|
166
|
+
if (fsPath.startsWith(sourcesPath + path.sep)) {
|
|
167
|
+
return "tests";
|
|
168
|
+
}
|
|
165
169
|
}
|
|
166
170
|
}
|
|
167
171
|
|
|
@@ -172,10 +176,13 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
172
176
|
options: { scope?: BuildScope } = {},
|
|
173
177
|
): Promise<string[]> {
|
|
174
178
|
const scope = options.scope ?? "contracts";
|
|
179
|
+
const unified = !this.#options.solidityConfig.splitTestsCompilation;
|
|
180
|
+
|
|
181
|
+
this.#ensureSplitCompilationModeIfTestsScope(scope);
|
|
175
182
|
|
|
176
183
|
switch (scope) {
|
|
177
|
-
case "contracts":
|
|
178
|
-
const
|
|
184
|
+
case "contracts": {
|
|
185
|
+
const localContractFiles = (
|
|
179
186
|
await Promise.all(
|
|
180
187
|
this.#options.soliditySourcesPaths.map((dir) =>
|
|
181
188
|
getAllFilesMatching(
|
|
@@ -191,8 +198,30 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
191
198
|
npmModuleToNpmRootPath,
|
|
192
199
|
);
|
|
193
200
|
|
|
194
|
-
|
|
195
|
-
|
|
201
|
+
if (!unified) {
|
|
202
|
+
return [...localContractFiles, ...npmFilesToBuild];
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// In unified mode, contracts scope returns all roots: contracts,
|
|
206
|
+
// tests, and npm files.
|
|
207
|
+
const testFiles = (
|
|
208
|
+
await Promise.all([
|
|
209
|
+
getAllFilesMatching(this.#options.solidityTestsPath, (f) =>
|
|
210
|
+
f.endsWith(".sol"),
|
|
211
|
+
),
|
|
212
|
+
...this.#options.soliditySourcesPaths.map(async (dir) => {
|
|
213
|
+
return getAllFilesMatching(dir, (f) => f.endsWith(".t.sol"));
|
|
214
|
+
}),
|
|
215
|
+
])
|
|
216
|
+
).flat(1);
|
|
217
|
+
|
|
218
|
+
// Remove duplicates in case there is an intersection between
|
|
219
|
+
// the tests.solidity paths and the sources paths
|
|
220
|
+
return Array.from(
|
|
221
|
+
new Set([...localContractFiles, ...npmFilesToBuild, ...testFiles]),
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
case "tests": {
|
|
196
225
|
let rootFilePaths = (
|
|
197
226
|
await Promise.all([
|
|
198
227
|
getAllFilesMatching(this.#options.solidityTestsPath, (f) =>
|
|
@@ -208,6 +237,7 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
208
237
|
// the tests.solidity paths and the sources paths
|
|
209
238
|
rootFilePaths = Array.from(new Set(rootFilePaths));
|
|
210
239
|
return rootFilePaths;
|
|
240
|
+
}
|
|
211
241
|
}
|
|
212
242
|
}
|
|
213
243
|
|
|
@@ -219,12 +249,14 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
219
249
|
|
|
220
250
|
public async build(
|
|
221
251
|
rootFilePaths: string[],
|
|
222
|
-
|
|
252
|
+
options?: BuildOptions,
|
|
223
253
|
): Promise<CompilationJobCreationError | Map<string, FileBuildResult>> {
|
|
254
|
+
this.#ensureSplitCompilationModeIfTestsScope(options?.scope);
|
|
255
|
+
|
|
224
256
|
return this.#hooks.runHandlerChain(
|
|
225
257
|
"solidity",
|
|
226
258
|
"build",
|
|
227
|
-
[rootFilePaths,
|
|
259
|
+
[rootFilePaths, options],
|
|
228
260
|
async (_context, nextRootFilePaths, nextOptions) =>
|
|
229
261
|
this.#build(nextRootFilePaths, nextOptions),
|
|
230
262
|
);
|
|
@@ -232,25 +264,27 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
232
264
|
|
|
233
265
|
async #build(
|
|
234
266
|
rootFilePaths: string[],
|
|
235
|
-
|
|
267
|
+
options?: BuildOptions,
|
|
236
268
|
): Promise<CompilationJobCreationError | Map<string, FileBuildResult>> {
|
|
237
|
-
const
|
|
269
|
+
const resolvedOptions: Required<BuildOptions> = {
|
|
238
270
|
buildProfile: DEFAULT_BUILD_PROFILE,
|
|
239
271
|
concurrency: Math.max(os.cpus().length - 1, 1),
|
|
240
272
|
force: false,
|
|
241
273
|
isolated: false,
|
|
242
274
|
quiet: false,
|
|
243
275
|
scope: "contracts",
|
|
244
|
-
...
|
|
276
|
+
...options,
|
|
245
277
|
};
|
|
246
278
|
|
|
247
|
-
await this.#downloadConfiguredCompilers(
|
|
279
|
+
await this.#downloadConfiguredCompilers(resolvedOptions.quiet);
|
|
248
280
|
|
|
249
|
-
const { buildProfile } = this.#getBuildProfile(
|
|
281
|
+
const { buildProfile } = this.#getBuildProfile(
|
|
282
|
+
resolvedOptions.buildProfile,
|
|
283
|
+
);
|
|
250
284
|
|
|
251
285
|
const compilationJobsResult = await this.getCompilationJobs(
|
|
252
286
|
rootFilePaths,
|
|
253
|
-
|
|
287
|
+
resolvedOptions,
|
|
254
288
|
);
|
|
255
289
|
|
|
256
290
|
if (!compilationJobsResult.success) {
|
|
@@ -258,7 +292,7 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
258
292
|
}
|
|
259
293
|
|
|
260
294
|
const spinner = createSpinner({
|
|
261
|
-
text: `Compiling your Solidity ${
|
|
295
|
+
text: `Compiling your Solidity ${resolvedOptions.scope}...`,
|
|
262
296
|
enabled: true,
|
|
263
297
|
});
|
|
264
298
|
spinner.start();
|
|
@@ -284,7 +318,7 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
284
318
|
async (runnableCompilationJob) => {
|
|
285
319
|
const { output, compiler } = await this.runCompilationJob(
|
|
286
320
|
runnableCompilationJob,
|
|
287
|
-
|
|
321
|
+
resolvedOptions,
|
|
288
322
|
);
|
|
289
323
|
|
|
290
324
|
return {
|
|
@@ -294,7 +328,7 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
294
328
|
};
|
|
295
329
|
},
|
|
296
330
|
{
|
|
297
|
-
concurrency:
|
|
331
|
+
concurrency: resolvedOptions.concurrency,
|
|
298
332
|
// An error when running the compiler is not a compilation failure, but
|
|
299
333
|
// a fatal failure trying to run it, so we just throw on the first error
|
|
300
334
|
stopOnError: true,
|
|
@@ -319,7 +353,7 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
319
353
|
const emitArtifactsResult = await this.emitArtifacts(
|
|
320
354
|
compilationResult.compilationJob,
|
|
321
355
|
compilationResult.compilerOutput,
|
|
322
|
-
|
|
356
|
+
resolvedOptions,
|
|
323
357
|
);
|
|
324
358
|
|
|
325
359
|
const { artifactsPerFile } = emitArtifactsResult;
|
|
@@ -335,7 +369,7 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
335
369
|
compilationResult,
|
|
336
370
|
emitArtifactsResult,
|
|
337
371
|
buildProfile.isolated,
|
|
338
|
-
|
|
372
|
+
resolvedOptions.scope,
|
|
339
373
|
);
|
|
340
374
|
}),
|
|
341
375
|
);
|
|
@@ -403,10 +437,10 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
403
437
|
});
|
|
404
438
|
}
|
|
405
439
|
|
|
406
|
-
if (!
|
|
440
|
+
if (!resolvedOptions.quiet) {
|
|
407
441
|
if (isSuccessfulBuild) {
|
|
408
442
|
await this.#printCompilationResult(runnableCompilationJobs, {
|
|
409
|
-
scope:
|
|
443
|
+
scope: resolvedOptions.scope,
|
|
410
444
|
});
|
|
411
445
|
}
|
|
412
446
|
}
|
|
@@ -421,6 +455,8 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
421
455
|
rootFilePaths: string[],
|
|
422
456
|
options?: GetCompilationJobsOptions,
|
|
423
457
|
): Promise<CompilationJobCreationError | GetCompilationJobsResult> {
|
|
458
|
+
this.#ensureSplitCompilationModeIfTestsScope(options?.scope);
|
|
459
|
+
|
|
424
460
|
await this.#downloadConfiguredCompilers(options?.quiet);
|
|
425
461
|
|
|
426
462
|
const dependencyGraph = await buildDependencyGraph(
|
|
@@ -436,6 +472,11 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
436
472
|
|
|
437
473
|
log(`Using build profile ${buildProfileName}`);
|
|
438
474
|
|
|
475
|
+
let toolVersions: ToolVersions | undefined;
|
|
476
|
+
if (buildProfile.toolVersionsInBuildInfo === true) {
|
|
477
|
+
toolVersions = { hardhat: await getHardhatVersion() };
|
|
478
|
+
}
|
|
479
|
+
|
|
439
480
|
const solcConfigSelector = new SolcConfigSelector(
|
|
440
481
|
buildProfileName,
|
|
441
482
|
buildProfile,
|
|
@@ -533,6 +574,7 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
533
574
|
longVersion,
|
|
534
575
|
this.#hooks,
|
|
535
576
|
sharedContentHashes,
|
|
577
|
+
toolVersions,
|
|
536
578
|
);
|
|
537
579
|
|
|
538
580
|
await individualJob.getBuildId(); // precompute
|
|
@@ -584,6 +626,26 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
584
626
|
continue;
|
|
585
627
|
}
|
|
586
628
|
|
|
629
|
+
// Validate output layout: if the cached layout doesn't match the
|
|
630
|
+
// expected layout for the current config, treat it as a miss.
|
|
631
|
+
// Pre-existing cache entries without these fields are also treated
|
|
632
|
+
// as misses.
|
|
633
|
+
const expectedLayout = await this.#getExpectedOutputLayout(
|
|
634
|
+
rootFile,
|
|
635
|
+
options?.scope ?? "contracts",
|
|
636
|
+
);
|
|
637
|
+
|
|
638
|
+
if (
|
|
639
|
+
cacheResult.artifactsDirectory === undefined ||
|
|
640
|
+
cacheResult.emitsTypeDeclarations === undefined ||
|
|
641
|
+
cacheResult.artifactsDirectory !== expectedLayout.artifactsDirectory ||
|
|
642
|
+
cacheResult.emitsTypeDeclarations !==
|
|
643
|
+
expectedLayout.emitsTypeDeclarations
|
|
644
|
+
) {
|
|
645
|
+
rootFilesToCompile.add(rootFile);
|
|
646
|
+
continue;
|
|
647
|
+
}
|
|
648
|
+
|
|
587
649
|
// If any of the emitted files are not present anymore, compile it
|
|
588
650
|
const {
|
|
589
651
|
artifactPaths,
|
|
@@ -687,6 +749,7 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
687
749
|
longVersion,
|
|
688
750
|
this.#hooks,
|
|
689
751
|
sharedContentHashes,
|
|
752
|
+
toolVersions,
|
|
690
753
|
);
|
|
691
754
|
|
|
692
755
|
for (const [userSourceName, root] of subgraph.getRoots().entries()) {
|
|
@@ -808,6 +871,10 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
808
871
|
): Promise<EmitArtifactsResult> {
|
|
809
872
|
const scope = options.scope ?? "contracts";
|
|
810
873
|
|
|
874
|
+
this.#ensureSplitCompilationModeIfTestsScope(scope);
|
|
875
|
+
|
|
876
|
+
const unified = !this.#options.solidityConfig.splitTestsCompilation;
|
|
877
|
+
|
|
811
878
|
const artifactsPerFile = new Map<string, string[]>();
|
|
812
879
|
const typeFilePaths = new Map<string, string>();
|
|
813
880
|
const buildId = await runnableCompilationJob.getBuildId();
|
|
@@ -858,8 +925,15 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
858
925
|
|
|
859
926
|
artifactsPerFile.set(formatRootPath(userSourceName, root), paths);
|
|
860
927
|
|
|
861
|
-
//
|
|
862
|
-
|
|
928
|
+
// In split mode, test roots are never part of a "contracts"-scoped pass,
|
|
929
|
+
// so the scope guard below is sufficient. In unified mode, both contract
|
|
930
|
+
// and test roots share the same pass, so we check individually.
|
|
931
|
+
const isTestRoot = unified
|
|
932
|
+
? (await this.getScope(root.fsPath)) === "tests"
|
|
933
|
+
: false;
|
|
934
|
+
|
|
935
|
+
// Write the type declaration file for contract roots only.
|
|
936
|
+
if (scope === "contracts" && !isTestRoot) {
|
|
863
937
|
const artifactsDeclarationFilePath = path.join(
|
|
864
938
|
fileFolder,
|
|
865
939
|
"artifacts.d.ts",
|
|
@@ -954,6 +1028,12 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
954
1028
|
}
|
|
955
1029
|
|
|
956
1030
|
public async getArtifactsDirectory(scope: BuildScope): Promise<string> {
|
|
1031
|
+
// In unified mode, both scopes point to the main artifacts directory
|
|
1032
|
+
// because contract and test artifacts live together.
|
|
1033
|
+
if (!this.#options.solidityConfig.splitTestsCompilation) {
|
|
1034
|
+
return this.#options.artifactsPath;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
957
1037
|
return scope === "contracts"
|
|
958
1038
|
? this.#options.artifactsPath
|
|
959
1039
|
: path.join(this.#options.cachePath, "test-artifacts");
|
|
@@ -963,9 +1043,11 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
963
1043
|
rootFilePaths: string[],
|
|
964
1044
|
options: { scope?: BuildScope } = {},
|
|
965
1045
|
): Promise<void> {
|
|
966
|
-
log(`Cleaning up artifacts`);
|
|
967
|
-
|
|
968
1046
|
const scope = options.scope ?? "contracts";
|
|
1047
|
+
|
|
1048
|
+
this.#ensureSplitCompilationModeIfTestsScope(scope);
|
|
1049
|
+
|
|
1050
|
+
log(`Cleaning up artifacts`);
|
|
969
1051
|
const artifactsDirectory = await this.getArtifactsDirectory(scope);
|
|
970
1052
|
|
|
971
1053
|
const userSourceNames = rootFilePaths.map((rootFilePath) => {
|
|
@@ -1017,7 +1099,7 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
1017
1099
|
|
|
1018
1100
|
// Get all the reachable build info files
|
|
1019
1101
|
const buildInfoFiles = await getAllFilesMatching(buildInfosDir, (f) =>
|
|
1020
|
-
f.startsWith(buildInfosDir),
|
|
1102
|
+
f.startsWith(buildInfosDir + path.sep),
|
|
1021
1103
|
);
|
|
1022
1104
|
|
|
1023
1105
|
for (const buildInfoFile of buildInfoFiles) {
|
|
@@ -1141,6 +1223,34 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
1141
1223
|
return `${error.type}: ${error.message}`.replace(/[:\s]*$/g, "").trim();
|
|
1142
1224
|
}
|
|
1143
1225
|
|
|
1226
|
+
async #getExpectedOutputLayout(
|
|
1227
|
+
rootFilePath: string,
|
|
1228
|
+
scope: BuildScope,
|
|
1229
|
+
): Promise<{ artifactsDirectory: string; emitsTypeDeclarations: boolean }> {
|
|
1230
|
+
const artifactsDirectory = await this.getArtifactsDirectory(scope);
|
|
1231
|
+
|
|
1232
|
+
const unified = !this.#options.solidityConfig.splitTestsCompilation;
|
|
1233
|
+
|
|
1234
|
+
// In unified mode, test roots under contracts scope don't emit type
|
|
1235
|
+
// declarations. In split mode, the scope alone determines this.
|
|
1236
|
+
let emitsTypeDeclarations: boolean;
|
|
1237
|
+
if (scope === "contracts") {
|
|
1238
|
+
if (unified) {
|
|
1239
|
+
const parsed = parseRootPath(rootFilePath);
|
|
1240
|
+
const isTestRoot = isNpmParsedRootPath(parsed)
|
|
1241
|
+
? false
|
|
1242
|
+
: (await this.getScope(parsed.fsPath)) === "tests";
|
|
1243
|
+
emitsTypeDeclarations = !isTestRoot;
|
|
1244
|
+
} else {
|
|
1245
|
+
emitsTypeDeclarations = true;
|
|
1246
|
+
}
|
|
1247
|
+
} else {
|
|
1248
|
+
emitsTypeDeclarations = false;
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
return { artifactsDirectory, emitsTypeDeclarations };
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1144
1254
|
async #cacheCompilationResult(
|
|
1145
1255
|
indexedIndividualJobs: Map<string, CompilationJob>,
|
|
1146
1256
|
result: CompilationResult,
|
|
@@ -1169,14 +1279,13 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
1169
1279
|
|
|
1170
1280
|
const typeFilePath = emitArtifactsResult.typeFilePaths.get(rootFilePath);
|
|
1171
1281
|
|
|
1172
|
-
// Type declaration file is not generated for solidity tests
|
|
1173
|
-
assertHardhatInvariant(
|
|
1174
|
-
scope === "tests" || typeFilePath !== undefined,
|
|
1175
|
-
`No type file found on map for contract ${rootFilePath}`,
|
|
1176
|
-
);
|
|
1177
|
-
|
|
1178
1282
|
const jobHash = await individualJob.getBuildId();
|
|
1179
1283
|
|
|
1284
|
+
const expectedLayout = await this.#getExpectedOutputLayout(
|
|
1285
|
+
rootFilePath,
|
|
1286
|
+
scope,
|
|
1287
|
+
);
|
|
1288
|
+
|
|
1180
1289
|
this.#compileCache[rootFilePath] = {
|
|
1181
1290
|
jobHash,
|
|
1182
1291
|
isolated,
|
|
@@ -1186,6 +1295,8 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
1186
1295
|
buildInfoOutputPath: emitArtifactsResult.buildInfoOutputPath,
|
|
1187
1296
|
typeFilePath,
|
|
1188
1297
|
wasm: result.compiler.isSolcJs,
|
|
1298
|
+
artifactsDirectory: expectedLayout.artifactsDirectory,
|
|
1299
|
+
emitsTypeDeclarations: expectedLayout.emitsTypeDeclarations,
|
|
1189
1300
|
};
|
|
1190
1301
|
}
|
|
1191
1302
|
}
|
|
@@ -1332,6 +1443,17 @@ export class SolidityBuildSystemImplementation implements SolidityBuildSystem {
|
|
|
1332
1443
|
}
|
|
1333
1444
|
}
|
|
1334
1445
|
}
|
|
1446
|
+
|
|
1447
|
+
#ensureSplitCompilationModeIfTestsScope(scope: BuildScope = "contracts") {
|
|
1448
|
+
if (
|
|
1449
|
+
scope === "tests" &&
|
|
1450
|
+
!this.#options.solidityConfig.splitTestsCompilation
|
|
1451
|
+
) {
|
|
1452
|
+
throw new HardhatError(
|
|
1453
|
+
HardhatError.ERRORS.CORE.SOLIDITY.SPLIT_TESTS_COMPILATION_DISABLED,
|
|
1454
|
+
);
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1335
1457
|
}
|
|
1336
1458
|
|
|
1337
1459
|
function toForwardSlash(str: string): string {
|
|
@@ -5,6 +5,7 @@ import type { HookManager } from "../../../../types/hooks.js";
|
|
|
5
5
|
import type { CompilationJob } from "../../../../types/solidity/compilation-job.js";
|
|
6
6
|
import type { CompilerInput } from "../../../../types/solidity/compiler-io.js";
|
|
7
7
|
import type { DependencyGraph } from "../../../../types/solidity/dependency-graph.js";
|
|
8
|
+
import type { ToolVersions } from "../../../../types/solidity/solidity-artifacts.js";
|
|
8
9
|
|
|
9
10
|
import { createHash } from "node:crypto";
|
|
10
11
|
|
|
@@ -16,6 +17,7 @@ import {
|
|
|
16
17
|
ResolvedFileType,
|
|
17
18
|
type ResolvedFile,
|
|
18
19
|
} from "../../../../types/solidity.js";
|
|
20
|
+
import { DEFAULT_OUTPUT_SELECTION } from "../constants.js";
|
|
19
21
|
|
|
20
22
|
import { getEvmVersionFromSolcVersion } from "./solc-info.js";
|
|
21
23
|
|
|
@@ -23,6 +25,7 @@ export class CompilationJobImplementation implements CompilationJob {
|
|
|
23
25
|
public readonly dependencyGraph: DependencyGraph;
|
|
24
26
|
public readonly solcConfig: SolidityCompilerConfig;
|
|
25
27
|
public readonly solcLongVersion: string;
|
|
28
|
+
public readonly toolVersions?: ToolVersions;
|
|
26
29
|
|
|
27
30
|
readonly #hooks: HookManager;
|
|
28
31
|
// This map is shared across compilation jobs and is meant to store content hashes of source files
|
|
@@ -38,12 +41,14 @@ export class CompilationJobImplementation implements CompilationJob {
|
|
|
38
41
|
solcLongVersion: string,
|
|
39
42
|
hooks: HookManager,
|
|
40
43
|
sharedContentHashes: Map<string, string> = new Map(),
|
|
44
|
+
toolVersions?: ToolVersions,
|
|
41
45
|
) {
|
|
42
46
|
this.dependencyGraph = dependencyGraph;
|
|
43
47
|
this.solcConfig = solcConfig;
|
|
44
48
|
this.solcLongVersion = solcLongVersion;
|
|
45
49
|
this.#hooks = hooks;
|
|
46
50
|
this.#sharedContentHashes = sharedContentHashes;
|
|
51
|
+
this.toolVersions = toolVersions;
|
|
47
52
|
}
|
|
48
53
|
|
|
49
54
|
public async getSolcInput(): Promise<CompilerInput> {
|
|
@@ -130,19 +135,14 @@ export class CompilationJobImplementation implements CompilationJob {
|
|
|
130
135
|
// from other files (e.g. new Foo()), and it won't output its bytecode if
|
|
131
136
|
// it's not asked for. This would prevent EDR from doing any runtime
|
|
132
137
|
// analysis.
|
|
133
|
-
const outputSelection
|
|
138
|
+
const outputSelection: CompilerInput["settings"]["outputSelection"] =
|
|
139
|
+
await deepClone(settings.outputSelection ?? {});
|
|
134
140
|
outputSelection["*"] ??= {};
|
|
135
141
|
outputSelection["*"][""] ??= [];
|
|
136
142
|
outputSelection["*"]["*"] ??= [];
|
|
137
143
|
|
|
138
|
-
outputSelection["*"][""].push("
|
|
139
|
-
outputSelection["*"]["*"].push(
|
|
140
|
-
"abi",
|
|
141
|
-
"evm.bytecode",
|
|
142
|
-
"evm.deployedBytecode",
|
|
143
|
-
"evm.methodIdentifiers",
|
|
144
|
-
"metadata",
|
|
145
|
-
);
|
|
144
|
+
outputSelection["*"][""].push(...DEFAULT_OUTPUT_SELECTION["*"][""]);
|
|
145
|
+
outputSelection["*"]["*"].push(...DEFAULT_OUTPUT_SELECTION["*"]["*"]);
|
|
146
146
|
|
|
147
147
|
const sources: { [sourceName: string]: { content: string } } = {};
|
|
148
148
|
|
|
@@ -257,6 +257,12 @@ export class CompilationJobImplementation implements CompilationJob {
|
|
|
257
257
|
preimageObject.compilerType = compilerType;
|
|
258
258
|
}
|
|
259
259
|
|
|
260
|
+
// Include tool versions in the preimage when present, so that
|
|
261
|
+
// different tool versions produce different build IDs.
|
|
262
|
+
if (this.toolVersions !== undefined) {
|
|
263
|
+
preimageObject.toolVersions = this.toolVersions;
|
|
264
|
+
}
|
|
265
|
+
|
|
260
266
|
const preimage = JSON.stringify(preimageObject);
|
|
261
267
|
|
|
262
268
|
const jobHash = await createNonCryptographicHashId(preimage);
|
|
@@ -205,13 +205,15 @@ export class DependencyGraphImplementation implements DependencyGraph {
|
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
public getAllRemappings(): readonly string[] {
|
|
208
|
-
return
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
208
|
+
return [
|
|
209
|
+
...new Set(
|
|
210
|
+
this.#dependenciesMap
|
|
211
|
+
.values()
|
|
212
|
+
.flatMap((dependencies) =>
|
|
213
|
+
dependencies.values().flatMap((remappings) => remappings.values()),
|
|
214
|
+
),
|
|
215
|
+
),
|
|
216
|
+
].sort();
|
|
215
217
|
}
|
|
216
218
|
|
|
217
219
|
public toJSON(): DependencyGraphImplementationJson {
|
|
@@ -57,8 +57,8 @@ export function shouldSuppressWarning(
|
|
|
57
57
|
): boolean {
|
|
58
58
|
// Compute relative path from project root to test directory.
|
|
59
59
|
// Example:
|
|
60
|
-
// absoluteSolidityTestsPath: /workspaces/hardhat-4/
|
|
61
|
-
// absoluteProjectRoot: /workspaces/hardhat-4/
|
|
60
|
+
// absoluteSolidityTestsPath: /workspaces/hardhat-4/packages/example-project/test/contracts
|
|
61
|
+
// absoluteProjectRoot: /workspaces/hardhat-4/packages/example-project
|
|
62
62
|
// relativeTestPath: test/contracts/ - note the addition of the `/`
|
|
63
63
|
// to avoid partial matches, e.g.: test/contractsUtils/
|
|
64
64
|
const relativeTestPath = path.join(
|
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
hasOfficialArm64Build,
|
|
33
33
|
missesSomeOfficialNativeBuilds,
|
|
34
34
|
} from "./build-system/solc-info.js";
|
|
35
|
+
import { DEFAULT_OUTPUT_SELECTION } from "./constants.js";
|
|
35
36
|
|
|
36
37
|
/**
|
|
37
38
|
* The top-level type SolidityUserConfig is a union type too complex for
|
|
@@ -80,6 +81,7 @@ const incompatibleCompilerFields = {
|
|
|
80
81
|
const commonSolidityUserConfigFields = {
|
|
81
82
|
isolated: z.boolean().optional(),
|
|
82
83
|
npmFilesToBuild: z.array(z.string()).optional(),
|
|
84
|
+
splitTestsCompilation: z.boolean().optional(),
|
|
83
85
|
};
|
|
84
86
|
|
|
85
87
|
const commonSolidityCompilerUserConfigFields = {
|
|
@@ -119,12 +121,14 @@ const solidityCompilerUserConfigType = conditionalUnionType(
|
|
|
119
121
|
const solcSingleVersionSolidityUserConfigType =
|
|
120
122
|
solcSolidityCompilerUserConfigType.extend({
|
|
121
123
|
...commonSolidityUserConfigFields,
|
|
124
|
+
toolVersionsInBuildInfo: z.boolean().optional(),
|
|
122
125
|
...incompatibleVersionFields,
|
|
123
126
|
});
|
|
124
127
|
|
|
125
128
|
const otherSingleVersionSolidityUserConfigType =
|
|
126
129
|
otherSolidityCompilerUserConfigType.extend({
|
|
127
130
|
...commonSolidityUserConfigFields,
|
|
131
|
+
toolVersionsInBuildInfo: z.boolean().optional(),
|
|
128
132
|
...incompatibleVersionFields,
|
|
129
133
|
});
|
|
130
134
|
|
|
@@ -149,6 +153,7 @@ const multiVersionSolidityUserConfigType = z.object({
|
|
|
149
153
|
compilers: z.array(solidityCompilerUserConfigType).nonempty(),
|
|
150
154
|
overrides: z.record(z.string(), solidityCompilerUserConfigType).optional(),
|
|
151
155
|
...commonSolidityUserConfigFields,
|
|
156
|
+
toolVersionsInBuildInfo: z.boolean().optional(),
|
|
152
157
|
...incompatibleCompilerFields,
|
|
153
158
|
});
|
|
154
159
|
|
|
@@ -163,6 +168,7 @@ const singleVersionBuildProfileUserConfigType = conditionalUnionType(
|
|
|
163
168
|
(!("type" in data) || data.type === undefined || data.type === "solc"),
|
|
164
169
|
solcSolidityCompilerUserConfigType.extend({
|
|
165
170
|
isolated: z.boolean().optional(),
|
|
171
|
+
toolVersionsInBuildInfo: z.boolean().optional(),
|
|
166
172
|
...incompatibleVersionFields,
|
|
167
173
|
}),
|
|
168
174
|
],
|
|
@@ -170,6 +176,7 @@ const singleVersionBuildProfileUserConfigType = conditionalUnionType(
|
|
|
170
176
|
(data) => isObject(data) && "type" in data && data.type !== "solc",
|
|
171
177
|
otherSolidityCompilerUserConfigType.extend({
|
|
172
178
|
isolated: z.boolean().optional(),
|
|
179
|
+
toolVersionsInBuildInfo: z.boolean().optional(),
|
|
173
180
|
...incompatibleVersionFields,
|
|
174
181
|
}),
|
|
175
182
|
],
|
|
@@ -182,6 +189,7 @@ const multiVersionBuildProfileUserConfigType = z.object({
|
|
|
182
189
|
compilers: z.array(solidityCompilerUserConfigType).nonempty(),
|
|
183
190
|
overrides: z.record(z.string(), solidityCompilerUserConfigType).optional(),
|
|
184
191
|
isolated: z.boolean().optional(),
|
|
192
|
+
toolVersionsInBuildInfo: z.boolean().optional(),
|
|
185
193
|
...incompatibleCompilerFields,
|
|
186
194
|
});
|
|
187
195
|
|
|
@@ -202,6 +210,7 @@ const buildProfilesSolidityUserConfigType = z.object({
|
|
|
202
210
|
"Expected an object configuring one or more versions of Solidity",
|
|
203
211
|
),
|
|
204
212
|
),
|
|
213
|
+
...commonSolidityUserConfigFields,
|
|
205
214
|
...incompatibleProfileFields,
|
|
206
215
|
});
|
|
207
216
|
|
|
@@ -430,6 +439,7 @@ function resolveSolidityConfig(
|
|
|
430
439
|
},
|
|
431
440
|
npmFilesToBuild: [],
|
|
432
441
|
registeredCompilerTypes: ["solc"],
|
|
442
|
+
splitTestsCompilation: false,
|
|
433
443
|
};
|
|
434
444
|
}
|
|
435
445
|
|
|
@@ -437,14 +447,20 @@ function resolveSolidityConfig(
|
|
|
437
447
|
if ("version" in solidityConfig || "compilers" in solidityConfig) {
|
|
438
448
|
return {
|
|
439
449
|
profiles: {
|
|
440
|
-
default: resolveBuildProfileConfig(
|
|
450
|
+
default: resolveBuildProfileConfig(
|
|
451
|
+
solidityConfig,
|
|
452
|
+
false,
|
|
453
|
+
solidityConfig.toolVersionsInBuildInfo,
|
|
454
|
+
),
|
|
441
455
|
production: resolveBuildProfileConfig(
|
|
442
456
|
copyFromDefault(solidityConfig),
|
|
443
457
|
true,
|
|
458
|
+
solidityConfig.toolVersionsInBuildInfo,
|
|
444
459
|
),
|
|
445
460
|
},
|
|
446
461
|
npmFilesToBuild: solidityConfig.npmFilesToBuild ?? [],
|
|
447
462
|
registeredCompilerTypes: ["solc"],
|
|
463
|
+
splitTestsCompilation: solidityConfig.splitTestsCompilation ?? false,
|
|
448
464
|
};
|
|
449
465
|
}
|
|
450
466
|
|
|
@@ -457,6 +473,7 @@ function resolveSolidityConfig(
|
|
|
457
473
|
profiles[profileName] = resolveBuildProfileConfig(
|
|
458
474
|
profile,
|
|
459
475
|
profileName === "production",
|
|
476
|
+
profile.toolVersionsInBuildInfo,
|
|
460
477
|
);
|
|
461
478
|
}
|
|
462
479
|
|
|
@@ -475,6 +492,7 @@ function resolveSolidityConfig(
|
|
|
475
492
|
profiles,
|
|
476
493
|
npmFilesToBuild: solidityConfig.npmFilesToBuild ?? [],
|
|
477
494
|
registeredCompilerTypes: ["solc"],
|
|
495
|
+
splitTestsCompilation: solidityConfig.splitTestsCompilation ?? false,
|
|
478
496
|
};
|
|
479
497
|
}
|
|
480
498
|
|
|
@@ -483,6 +501,7 @@ function resolveBuildProfileConfig(
|
|
|
483
501
|
| SingleVersionSolidityUserConfig
|
|
484
502
|
| MultiVersionSolidityUserConfig,
|
|
485
503
|
production: boolean = false,
|
|
504
|
+
toolVersionsInBuildInfo?: boolean,
|
|
486
505
|
): SolidityBuildProfileConfig {
|
|
487
506
|
if ("version" in solidityConfig) {
|
|
488
507
|
return {
|
|
@@ -490,6 +509,7 @@ function resolveBuildProfileConfig(
|
|
|
490
509
|
overrides: {},
|
|
491
510
|
isolated: solidityConfig.isolated ?? production,
|
|
492
511
|
preferWasm: solidityConfig.preferWasm ?? false,
|
|
512
|
+
toolVersionsInBuildInfo: toolVersionsInBuildInfo ?? production,
|
|
493
513
|
};
|
|
494
514
|
}
|
|
495
515
|
|
|
@@ -507,6 +527,7 @@ function resolveBuildProfileConfig(
|
|
|
507
527
|
),
|
|
508
528
|
isolated: solidityConfig.isolated ?? production,
|
|
509
529
|
preferWasm: solidityConfig.preferWasm ?? false,
|
|
530
|
+
toolVersionsInBuildInfo: toolVersionsInBuildInfo ?? production,
|
|
510
531
|
};
|
|
511
532
|
}
|
|
512
533
|
|
|
@@ -515,18 +536,7 @@ function resolveSolidityCompilerConfig(
|
|
|
515
536
|
production: boolean = false,
|
|
516
537
|
): SolidityCompilerConfig {
|
|
517
538
|
const defaultSettings: SolidityCompilerConfig["settings"] = {
|
|
518
|
-
outputSelection:
|
|
519
|
-
"*": {
|
|
520
|
-
"": ["ast"],
|
|
521
|
-
"*": [
|
|
522
|
-
"abi",
|
|
523
|
-
"evm.bytecode",
|
|
524
|
-
"evm.deployedBytecode",
|
|
525
|
-
"evm.methodIdentifiers",
|
|
526
|
-
"metadata",
|
|
527
|
-
],
|
|
528
|
-
},
|
|
529
|
-
},
|
|
539
|
+
outputSelection: DEFAULT_OUTPUT_SELECTION,
|
|
530
540
|
};
|
|
531
541
|
|
|
532
542
|
if (production && isSolcSolidityCompilerUserConfig(compilerConfig)) {
|