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
|
@@ -38,24 +38,26 @@ export default async (): Promise<Partial<NetworkHooks>> => {
|
|
|
38
38
|
nextJsonRpcRequest: JsonRpcRequest,
|
|
39
39
|
) => Promise<JsonRpcResponse>,
|
|
40
40
|
) {
|
|
41
|
-
|
|
42
|
-
async () => {
|
|
43
|
-
let handlersPerConnection =
|
|
44
|
-
requestHandlersPerConnection.get(networkConnection);
|
|
41
|
+
let requestHandlers = requestHandlersPerConnection.get(networkConnection);
|
|
45
42
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
if (requestHandlers === undefined) {
|
|
44
|
+
requestHandlers = await initializationMutex.exclusiveRun(async () => {
|
|
45
|
+
// We check again in case another execution of this function
|
|
46
|
+
// initialized the handlers while we were waiting for the mutex.
|
|
47
|
+
const handlersPerConnectionAfterWaiting =
|
|
48
|
+
requestHandlersPerConnection.get(networkConnection);
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
handlersPerConnection,
|
|
53
|
-
);
|
|
50
|
+
if (handlersPerConnectionAfterWaiting !== undefined) {
|
|
51
|
+
return handlersPerConnectionAfterWaiting;
|
|
54
52
|
}
|
|
55
53
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
const result = await createHandlersArray(networkConnection);
|
|
55
|
+
|
|
56
|
+
requestHandlersPerConnection.set(networkConnection, result);
|
|
57
|
+
|
|
58
|
+
return result;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
59
61
|
|
|
60
62
|
// We previously cloned here, but the performance impact is significant.
|
|
61
63
|
// TODO: ensure the passed in request is not mutated by adapting the
|
|
@@ -63,6 +65,10 @@ export default async (): Promise<Partial<NetworkHooks>> => {
|
|
|
63
65
|
let updatedRequest = jsonRpcRequest;
|
|
64
66
|
|
|
65
67
|
for (const handler of requestHandlers) {
|
|
68
|
+
if (!handler.isSupportedMethod(updatedRequest)) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
|
|
66
72
|
const newRequestOrResponse = await handler.handle(updatedRequest);
|
|
67
73
|
|
|
68
74
|
if (isJsonRpcResponse(newRequestOrResponse)) {
|
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
DefaultChainType,
|
|
13
13
|
JsonRpcServer,
|
|
14
14
|
NetworkConnection,
|
|
15
|
+
CachedNetworkConnectionParams,
|
|
15
16
|
NetworkConnectionParams,
|
|
16
17
|
NetworkManager,
|
|
17
18
|
} from "../../../types/network.js";
|
|
@@ -59,10 +60,18 @@ export class NetworkManagerImplementation implements NetworkManager {
|
|
|
59
60
|
readonly #projectRoot: string;
|
|
60
61
|
readonly #verbosity: number;
|
|
61
62
|
|
|
63
|
+
#connectCalled = false;
|
|
64
|
+
|
|
62
65
|
#nextConnectionId = 0;
|
|
63
66
|
readonly #contractDecoderMutex = new AsyncMutex();
|
|
64
67
|
#contractDecoder: ContractDecoder | undefined;
|
|
65
68
|
|
|
69
|
+
readonly #getOrCreateMutex = new AsyncMutex();
|
|
70
|
+
readonly #getOrCreateCache = new Map<
|
|
71
|
+
string,
|
|
72
|
+
Map<string, NetworkConnection<ChainType | string>>
|
|
73
|
+
>();
|
|
74
|
+
|
|
66
75
|
constructor(
|
|
67
76
|
defaultNetwork: string,
|
|
68
77
|
defaultChainType: DefaultChainType,
|
|
@@ -87,9 +96,7 @@ export class NetworkManagerImplementation implements NetworkManager {
|
|
|
87
96
|
this.#verbosity = verbosity;
|
|
88
97
|
}
|
|
89
98
|
|
|
90
|
-
public async
|
|
91
|
-
ChainTypeT extends ChainType | string = DefaultChainType,
|
|
92
|
-
>(
|
|
99
|
+
public async create<ChainTypeT extends ChainType | string = DefaultChainType>(
|
|
93
100
|
networkOrParams?: NetworkConnectionParams<ChainTypeT> | string,
|
|
94
101
|
): Promise<NetworkConnection<ChainTypeT>> {
|
|
95
102
|
let networkName: string | undefined;
|
|
@@ -117,6 +124,80 @@ export class NetworkManagerImplementation implements NetworkManager {
|
|
|
117
124
|
return networkConnection as NetworkConnection<ChainTypeT>;
|
|
118
125
|
}
|
|
119
126
|
|
|
127
|
+
public async connect<
|
|
128
|
+
ChainTypeT extends ChainType | string = DefaultChainType,
|
|
129
|
+
>(
|
|
130
|
+
networkOrParams?: NetworkConnectionParams<ChainTypeT> | string,
|
|
131
|
+
): Promise<NetworkConnection<ChainTypeT>> {
|
|
132
|
+
this.#connectCalled = true;
|
|
133
|
+
|
|
134
|
+
return this.create(networkOrParams);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
public async getOrCreate<
|
|
138
|
+
ChainTypeT extends ChainType | string = DefaultChainType,
|
|
139
|
+
>(
|
|
140
|
+
networkOrParams?: CachedNetworkConnectionParams<ChainTypeT> | string,
|
|
141
|
+
): Promise<NetworkConnection<ChainTypeT>> {
|
|
142
|
+
let network: string | undefined;
|
|
143
|
+
let chainType: ChainTypeT | undefined;
|
|
144
|
+
|
|
145
|
+
if (typeof networkOrParams === "string") {
|
|
146
|
+
network = networkOrParams;
|
|
147
|
+
} else if (networkOrParams !== undefined) {
|
|
148
|
+
network = networkOrParams.network;
|
|
149
|
+
chainType = networkOrParams.chainType;
|
|
150
|
+
|
|
151
|
+
if ("override" in networkOrParams) {
|
|
152
|
+
throw new HardhatError(
|
|
153
|
+
HardhatError.ERRORS.CORE.NETWORK.INVALID_CONFIG_OVERRIDE,
|
|
154
|
+
{
|
|
155
|
+
errors: "\t* Config overrides are not supported by getOrCreate.",
|
|
156
|
+
},
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const { resolvedNetworkName, resolvedChainType } =
|
|
162
|
+
this.#resolveNetworkAndChainType(network, chainType);
|
|
163
|
+
|
|
164
|
+
const cached = this.#getOrCreateCache
|
|
165
|
+
.get(resolvedNetworkName)
|
|
166
|
+
?.get(resolvedChainType);
|
|
167
|
+
if (cached !== undefined) {
|
|
168
|
+
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
169
|
+
-- Cast is safe: the cache keys guarantee the chain type matches */
|
|
170
|
+
return cached as NetworkConnection<ChainTypeT>;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return this.#getOrCreateMutex.exclusiveRun(async () => {
|
|
174
|
+
// Double-check after acquiring the mutex — another call may have
|
|
175
|
+
// populated the cache while we were waiting.
|
|
176
|
+
const cachedAfterWaiting = this.#getOrCreateCache
|
|
177
|
+
.get(resolvedNetworkName)
|
|
178
|
+
?.get(resolvedChainType);
|
|
179
|
+
if (cachedAfterWaiting !== undefined) {
|
|
180
|
+
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
181
|
+
-- Cast is safe: the cache keys guarantee the chain type matches */
|
|
182
|
+
return cachedAfterWaiting as NetworkConnection<ChainTypeT>;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const connection = await this.create({
|
|
186
|
+
network: resolvedNetworkName,
|
|
187
|
+
chainType: resolvedChainType,
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
let networkCache = this.#getOrCreateCache.get(resolvedNetworkName);
|
|
191
|
+
if (networkCache === undefined) {
|
|
192
|
+
networkCache = new Map();
|
|
193
|
+
this.#getOrCreateCache.set(resolvedNetworkName, networkCache);
|
|
194
|
+
}
|
|
195
|
+
networkCache.set(resolvedChainType, connection);
|
|
196
|
+
|
|
197
|
+
return connection;
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
120
201
|
public async createServer<
|
|
121
202
|
ChainTypeT extends ChainType | string = DefaultChainType,
|
|
122
203
|
>(
|
|
@@ -129,7 +210,7 @@ export class NetworkManagerImplementation implements NetworkManager {
|
|
|
129
210
|
const insideDocker = await exists("/.dockerenv");
|
|
130
211
|
const hostname = _hostname ?? (insideDocker ? "0.0.0.0" : "127.0.0.1");
|
|
131
212
|
|
|
132
|
-
const { provider } = await this.
|
|
213
|
+
const { provider } = await this.create(networkOrParams);
|
|
133
214
|
|
|
134
215
|
return new JsonRpcServerImplementation({
|
|
135
216
|
hostname,
|
|
@@ -138,30 +219,24 @@ export class NetworkManagerImplementation implements NetworkManager {
|
|
|
138
219
|
});
|
|
139
220
|
}
|
|
140
221
|
|
|
222
|
+
/**
|
|
223
|
+
* Returns whether the deprecated `connect` method has been called on this
|
|
224
|
+
* instance. It is not on the public NetworkManager interface as it is only
|
|
225
|
+
* used by the CLI to print a deprecation warning at exit.
|
|
226
|
+
*
|
|
227
|
+
* @returns whether the deprecated `connect` method has ever been called
|
|
228
|
+
*/
|
|
229
|
+
public wasConnectCalled(): boolean {
|
|
230
|
+
return this.#connectCalled;
|
|
231
|
+
}
|
|
232
|
+
|
|
141
233
|
async #initializeNetworkConnection<ChainTypeT extends ChainType | string>(
|
|
142
234
|
networkName?: string,
|
|
143
235
|
chainType?: ChainTypeT,
|
|
144
236
|
networkConfigOverride?: NetworkConfigOverride,
|
|
145
237
|
): Promise<NetworkConnection<ChainTypeT>> {
|
|
146
|
-
const resolvedNetworkName
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if (existingNetworkConfig === undefined) {
|
|
150
|
-
throw new HardhatError(
|
|
151
|
-
HardhatError.ERRORS.CORE.NETWORK.NETWORK_NOT_FOUND,
|
|
152
|
-
{
|
|
153
|
-
networkName: resolvedNetworkName,
|
|
154
|
-
},
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions --
|
|
159
|
-
* Type assertion is safe: defaultChainType ensures non-undefined, and the
|
|
160
|
-
* resolved value will be ChainTypeT (if provided) or a fallback that
|
|
161
|
-
* satisfies the ChainType | string constraint */
|
|
162
|
-
const resolvedChainType = (chainType ??
|
|
163
|
-
existingNetworkConfig.chainType ??
|
|
164
|
-
this.#defaultChainType) as ChainTypeT;
|
|
238
|
+
const { resolvedNetworkName, resolvedChainType } =
|
|
239
|
+
this.#resolveNetworkAndChainType(networkName, chainType);
|
|
165
240
|
|
|
166
241
|
const resolvedNetworkConfig = await this.#resolveNetworkConfig(
|
|
167
242
|
resolvedNetworkName,
|
|
@@ -287,9 +362,7 @@ export class NetworkManagerImplementation implements NetworkManager {
|
|
|
287
362
|
allowUnlimitedContractSize: shouldEnableCoverage
|
|
288
363
|
? true
|
|
289
364
|
: resolvedNetworkConfig.allowUnlimitedContractSize,
|
|
290
|
-
|
|
291
|
-
This case is safe because we have a check above */
|
|
292
|
-
chainType: resolvedChainType as ChainType,
|
|
365
|
+
chainType: resolvedChainType,
|
|
293
366
|
},
|
|
294
367
|
jsonRpcRequestWrapper,
|
|
295
368
|
contractDecoder: this.#contractDecoder,
|
|
@@ -387,7 +460,7 @@ export class NetworkManagerImplementation implements NetworkManager {
|
|
|
387
460
|
throw new HardhatError(
|
|
388
461
|
HardhatError.ERRORS.CORE.NETWORK.INVALID_CONFIG_OVERRIDE,
|
|
389
462
|
{
|
|
390
|
-
errors: `\t* The chainType cannot be specified in config overrides. Pass it at the top level instead: hre.network.
|
|
463
|
+
errors: `\t* The chainType cannot be specified in config overrides. Pass it at the top level instead: hre.network.create({ chainType: 'op' })`,
|
|
391
464
|
},
|
|
392
465
|
);
|
|
393
466
|
}
|
|
@@ -474,6 +547,36 @@ export class NetworkManagerImplementation implements NetworkManager {
|
|
|
474
547
|
return resolvedNetworkConfigOverride;
|
|
475
548
|
}
|
|
476
549
|
|
|
550
|
+
#resolveNetworkAndChainType<
|
|
551
|
+
ChainTypeT extends ChainType | string = DefaultChainType,
|
|
552
|
+
>(
|
|
553
|
+
network: string | undefined,
|
|
554
|
+
chainType: ChainTypeT | undefined,
|
|
555
|
+
): { resolvedNetworkName: string; resolvedChainType: ChainTypeT } {
|
|
556
|
+
const resolvedNetworkName = network ?? this.#defaultNetwork;
|
|
557
|
+
const existingNetworkConfig = this.#networkConfigs[resolvedNetworkName];
|
|
558
|
+
|
|
559
|
+
if (existingNetworkConfig === undefined) {
|
|
560
|
+
throw new HardhatError(
|
|
561
|
+
HardhatError.ERRORS.CORE.NETWORK.NETWORK_NOT_FOUND,
|
|
562
|
+
{
|
|
563
|
+
networkName: resolvedNetworkName,
|
|
564
|
+
},
|
|
565
|
+
);
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
const resolvedChainType =
|
|
569
|
+
chainType ?? existingNetworkConfig.chainType ?? this.#defaultChainType;
|
|
570
|
+
|
|
571
|
+
return {
|
|
572
|
+
resolvedNetworkName,
|
|
573
|
+
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
574
|
+
-- The cast is safe because the fallback values are valid chain
|
|
575
|
+
types that match the caller's expected type at runtime. */
|
|
576
|
+
resolvedChainType: resolvedChainType as ChainTypeT,
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
|
|
477
580
|
async #getBuildInfosAndOutputsAsBuffers(): Promise<
|
|
478
581
|
Array<{ buildInfo: Uint8Array; output: Uint8Array }>
|
|
479
582
|
> {
|
|
@@ -39,6 +39,15 @@ import { ChainId } from "../chain-id/chain-id.js";
|
|
|
39
39
|
|
|
40
40
|
const EXTRA_ENTROPY = false;
|
|
41
41
|
export class LocalAccountsHandler extends ChainId implements RequestHandler {
|
|
42
|
+
readonly #methods: ReadonlySet<string> = new Set([
|
|
43
|
+
"eth_accounts",
|
|
44
|
+
"eth_requestAccounts",
|
|
45
|
+
"eth_sign",
|
|
46
|
+
"personal_sign",
|
|
47
|
+
"eth_signTypedData_v4",
|
|
48
|
+
"eth_sendTransaction",
|
|
49
|
+
]);
|
|
50
|
+
|
|
42
51
|
readonly #localAccountsHexPrivateKeys: string[];
|
|
43
52
|
|
|
44
53
|
#addressToPrivateKey: Map<string, Uint8Array> | undefined;
|
|
@@ -53,6 +62,27 @@ export class LocalAccountsHandler extends ChainId implements RequestHandler {
|
|
|
53
62
|
this.#localAccountsHexPrivateKeys = localAccountsHexPrivateKeys;
|
|
54
63
|
}
|
|
55
64
|
|
|
65
|
+
public isSupportedMethod(jsonRpcRequest: JsonRpcRequest): boolean {
|
|
66
|
+
return this.#methods.has(jsonRpcRequest.method);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public async handle(
|
|
70
|
+
jsonRpcRequest: JsonRpcRequest,
|
|
71
|
+
): Promise<JsonRpcRequest | JsonRpcResponse> {
|
|
72
|
+
if (!this.isSupportedMethod(jsonRpcRequest)) {
|
|
73
|
+
return jsonRpcRequest;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const response = await this.#resolveRequest(jsonRpcRequest);
|
|
77
|
+
if (response !== null) {
|
|
78
|
+
return response;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
await this.#modifyRequest(jsonRpcRequest);
|
|
82
|
+
|
|
83
|
+
return jsonRpcRequest;
|
|
84
|
+
}
|
|
85
|
+
|
|
56
86
|
async #getAddressesAndPrivateKeysMap(): Promise<{
|
|
57
87
|
addresses: string[];
|
|
58
88
|
addressToPrivateKey: Map<string, Uint8Array>;
|
|
@@ -75,19 +105,6 @@ export class LocalAccountsHandler extends ChainId implements RequestHandler {
|
|
|
75
105
|
};
|
|
76
106
|
}
|
|
77
107
|
|
|
78
|
-
public async handle(
|
|
79
|
-
jsonRpcRequest: JsonRpcRequest,
|
|
80
|
-
): Promise<JsonRpcRequest | JsonRpcResponse> {
|
|
81
|
-
const response = await this.#resolveRequest(jsonRpcRequest);
|
|
82
|
-
if (response !== null) {
|
|
83
|
-
return response;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
await this.#modifyRequest(jsonRpcRequest);
|
|
87
|
-
|
|
88
|
-
return jsonRpcRequest;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
108
|
async #resolveRequest(
|
|
92
109
|
jsonRpcRequest: JsonRpcRequest,
|
|
93
110
|
): Promise<JsonRpcResponse | null> {
|
package/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/sender.ts
CHANGED
|
@@ -17,35 +17,43 @@ import { getRequestParams } from "../../../json-rpc.js";
|
|
|
17
17
|
* The class also provides a mechanism to retrieve the sender account, which must be implemented by subclasses.
|
|
18
18
|
*/
|
|
19
19
|
export abstract class SenderHandler implements RequestHandler {
|
|
20
|
+
readonly #methods: ReadonlySet<string> = new Set([
|
|
21
|
+
"eth_sendTransaction",
|
|
22
|
+
"eth_call",
|
|
23
|
+
"eth_estimateGas",
|
|
24
|
+
]);
|
|
25
|
+
|
|
20
26
|
protected readonly provider: EthereumProvider;
|
|
21
27
|
|
|
22
28
|
constructor(provider: EthereumProvider) {
|
|
23
29
|
this.provider = provider;
|
|
24
30
|
}
|
|
25
31
|
|
|
32
|
+
public isSupportedMethod(jsonRpcRequest: JsonRpcRequest): boolean {
|
|
33
|
+
return this.#methods.has(jsonRpcRequest.method);
|
|
34
|
+
}
|
|
35
|
+
|
|
26
36
|
public async handle(
|
|
27
37
|
jsonRpcRequest: JsonRpcRequest,
|
|
28
38
|
): Promise<JsonRpcRequest | JsonRpcResponse> {
|
|
39
|
+
if (!this.isSupportedMethod(jsonRpcRequest)) {
|
|
40
|
+
return jsonRpcRequest;
|
|
41
|
+
}
|
|
42
|
+
|
|
29
43
|
const method = jsonRpcRequest.method;
|
|
30
44
|
const params = getRequestParams(jsonRpcRequest);
|
|
31
45
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
tx.from = senderAccount;
|
|
44
|
-
} else if (method === "eth_sendTransaction") {
|
|
45
|
-
throw new HardhatError(
|
|
46
|
-
HardhatError.ERRORS.CORE.NETWORK.NO_REMOTE_ACCOUNT_AVAILABLE,
|
|
47
|
-
);
|
|
48
|
-
}
|
|
46
|
+
const [tx] = params;
|
|
47
|
+
|
|
48
|
+
if (isObject(tx) && tx.from === undefined) {
|
|
49
|
+
const senderAccount = await this.getSender();
|
|
50
|
+
|
|
51
|
+
if (senderAccount !== undefined) {
|
|
52
|
+
tx.from = senderAccount;
|
|
53
|
+
} else if (method === "eth_sendTransaction") {
|
|
54
|
+
throw new HardhatError(
|
|
55
|
+
HardhatError.ERRORS.CORE.NETWORK.NO_REMOTE_ACCOUNT_AVAILABLE,
|
|
56
|
+
);
|
|
49
57
|
}
|
|
50
58
|
}
|
|
51
59
|
|
|
@@ -25,17 +25,25 @@ export class ChainIdValidatorHandler extends ChainId implements RequestHandler {
|
|
|
25
25
|
this.#expectedChainId = expectedChainId;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
public
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
public isSupportedMethod(jsonRpcRequest: JsonRpcRequest): boolean {
|
|
29
|
+
if (this.#alreadyValidated) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
|
|
31
33
|
if (
|
|
32
34
|
jsonRpcRequest.method === "eth_chainId" ||
|
|
33
35
|
jsonRpcRequest.method === "net_version"
|
|
34
36
|
) {
|
|
35
|
-
return
|
|
37
|
+
return false;
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public async handle(
|
|
44
|
+
jsonRpcRequest: JsonRpcRequest,
|
|
45
|
+
): Promise<JsonRpcRequest | JsonRpcResponse> {
|
|
46
|
+
if (!this.isSupportedMethod(jsonRpcRequest)) {
|
|
39
47
|
return jsonRpcRequest;
|
|
40
48
|
}
|
|
41
49
|
|
|
@@ -25,6 +25,8 @@ export class AutomaticGasHandler
|
|
|
25
25
|
extends MultipliedGasEstimation
|
|
26
26
|
implements RequestHandler
|
|
27
27
|
{
|
|
28
|
+
readonly #methods: ReadonlySet<string> = new Set(["eth_sendTransaction"]);
|
|
29
|
+
|
|
28
30
|
constructor(
|
|
29
31
|
provider: EthereumProvider,
|
|
30
32
|
gasMultiplier: number = DEFAULT_GAS_MULTIPLIER,
|
|
@@ -32,10 +34,14 @@ export class AutomaticGasHandler
|
|
|
32
34
|
super(provider, gasMultiplier);
|
|
33
35
|
}
|
|
34
36
|
|
|
37
|
+
public isSupportedMethod(jsonRpcRequest: JsonRpcRequest): boolean {
|
|
38
|
+
return this.#methods.has(jsonRpcRequest.method);
|
|
39
|
+
}
|
|
40
|
+
|
|
35
41
|
public async handle(
|
|
36
42
|
jsonRpcRequest: JsonRpcRequest,
|
|
37
43
|
): Promise<JsonRpcRequest | JsonRpcResponse> {
|
|
38
|
-
if (jsonRpcRequest
|
|
44
|
+
if (!this.isSupportedMethod(jsonRpcRequest)) {
|
|
39
45
|
return jsonRpcRequest;
|
|
40
46
|
}
|
|
41
47
|
|
|
@@ -19,6 +19,8 @@ import { getRequestParams } from "../../../json-rpc.js";
|
|
|
19
19
|
* It ensures that gas prices are set correctly.
|
|
20
20
|
*/
|
|
21
21
|
export class AutomaticGasPriceHandler implements RequestHandler {
|
|
22
|
+
readonly #methods: ReadonlySet<string> = new Set(["eth_sendTransaction"]);
|
|
23
|
+
|
|
22
24
|
readonly #provider: EthereumProvider;
|
|
23
25
|
|
|
24
26
|
// We pay the max base fee that can be required if the next
|
|
@@ -36,10 +38,14 @@ export class AutomaticGasPriceHandler implements RequestHandler {
|
|
|
36
38
|
#nodeHasFeeHistory?: boolean;
|
|
37
39
|
#nodeSupportsEIP1559?: boolean;
|
|
38
40
|
|
|
41
|
+
public isSupportedMethod(jsonRpcRequest: JsonRpcRequest): boolean {
|
|
42
|
+
return this.#methods.has(jsonRpcRequest.method);
|
|
43
|
+
}
|
|
44
|
+
|
|
39
45
|
public async handle(
|
|
40
46
|
jsonRpcRequest: JsonRpcRequest,
|
|
41
47
|
): Promise<JsonRpcRequest | JsonRpcResponse> {
|
|
42
|
-
if (jsonRpcRequest
|
|
48
|
+
if (!this.isSupportedMethod(jsonRpcRequest)) {
|
|
43
49
|
return jsonRpcRequest;
|
|
44
50
|
}
|
|
45
51
|
|
|
@@ -14,16 +14,22 @@ import { getRequestParams } from "../../../json-rpc.js";
|
|
|
14
14
|
* For `eth_sendTransaction` requests, it sets the gas field with the value provided via the class constructor, if it hasn't been specified already.
|
|
15
15
|
*/
|
|
16
16
|
export class FixedGasHandler implements RequestHandler {
|
|
17
|
+
readonly #methods: ReadonlySet<string> = new Set(["eth_sendTransaction"]);
|
|
18
|
+
|
|
17
19
|
readonly #gas: PrefixedHexString;
|
|
18
20
|
|
|
19
21
|
constructor(gas: PrefixedHexString) {
|
|
20
22
|
this.#gas = gas;
|
|
21
23
|
}
|
|
22
24
|
|
|
25
|
+
public isSupportedMethod(jsonRpcRequest: JsonRpcRequest): boolean {
|
|
26
|
+
return this.#methods.has(jsonRpcRequest.method);
|
|
27
|
+
}
|
|
28
|
+
|
|
23
29
|
public async handle(
|
|
24
30
|
jsonRpcRequest: JsonRpcRequest,
|
|
25
31
|
): Promise<JsonRpcRequest | JsonRpcResponse> {
|
|
26
|
-
if (jsonRpcRequest
|
|
32
|
+
if (!this.isSupportedMethod(jsonRpcRequest)) {
|
|
27
33
|
return jsonRpcRequest;
|
|
28
34
|
}
|
|
29
35
|
|
|
@@ -14,16 +14,22 @@ import { getRequestParams } from "../../../json-rpc.js";
|
|
|
14
14
|
* For `eth_sendTransaction` requests, it sets the gasPrice field with the value provided via the class constructor, if it hasn't been specified already.
|
|
15
15
|
*/
|
|
16
16
|
export class FixedGasPriceHandler implements RequestHandler {
|
|
17
|
+
readonly #methods: ReadonlySet<string> = new Set(["eth_sendTransaction"]);
|
|
18
|
+
|
|
17
19
|
readonly #gasPrice: PrefixedHexString;
|
|
18
20
|
|
|
19
21
|
constructor(gasPrice: PrefixedHexString) {
|
|
20
22
|
this.#gasPrice = gasPrice;
|
|
21
23
|
}
|
|
22
24
|
|
|
25
|
+
public isSupportedMethod(jsonRpcRequest: JsonRpcRequest): boolean {
|
|
26
|
+
return this.#methods.has(jsonRpcRequest.method);
|
|
27
|
+
}
|
|
28
|
+
|
|
23
29
|
public async handle(
|
|
24
30
|
jsonRpcRequest: JsonRpcRequest,
|
|
25
31
|
): Promise<JsonRpcRequest | JsonRpcResponse> {
|
|
26
|
-
if (jsonRpcRequest
|
|
32
|
+
if (!this.isSupportedMethod(jsonRpcRequest)) {
|
|
27
33
|
return jsonRpcRequest;
|
|
28
34
|
}
|
|
29
35
|
|
|
@@ -14,6 +14,16 @@ import type {
|
|
|
14
14
|
*
|
|
15
15
|
*/
|
|
16
16
|
export interface RequestHandler {
|
|
17
|
+
/**
|
|
18
|
+
* A guard to ensure the request is supported by the handler.
|
|
19
|
+
* If the handler does not support the request, then it can be safely
|
|
20
|
+
* skipped.
|
|
21
|
+
*
|
|
22
|
+
* @param jsonRpcRequest - The JSON-RPC request to check.
|
|
23
|
+
* @returns true if the method will be processed by the handler, false otherwise.
|
|
24
|
+
*/
|
|
25
|
+
isSupportedMethod(jsonRpcRequest: JsonRpcRequest): boolean;
|
|
26
|
+
|
|
17
27
|
handle(
|
|
18
28
|
jsonRpcRequest: JsonRpcRequest,
|
|
19
29
|
): Promise<JsonRpcRequest | JsonRpcResponse>;
|
|
@@ -147,7 +147,7 @@ declare module "../../../../types/config.js" {
|
|
|
147
147
|
export interface EdrNetworkForkingUserConfig {
|
|
148
148
|
enabled?: boolean;
|
|
149
149
|
url: SensitiveString;
|
|
150
|
-
blockNumber?: number;
|
|
150
|
+
blockNumber?: number | bigint;
|
|
151
151
|
httpHeaders?: Record<string, string>;
|
|
152
152
|
}
|
|
153
153
|
|
|
@@ -45,6 +45,10 @@ const nonnegativeIntSchema = z.number().int().nonnegative();
|
|
|
45
45
|
const nonnegativeBigIntSchema = z.bigint().nonnegative();
|
|
46
46
|
|
|
47
47
|
const blockNumberSchema = nonnegativeIntSchema;
|
|
48
|
+
const forkingBlockNumberSchema = unionType(
|
|
49
|
+
[z.number().int().nonnegative().safe(), z.bigint().nonnegative()],
|
|
50
|
+
"Expected a nonnegative safe int or a nonnegative bigint",
|
|
51
|
+
);
|
|
48
52
|
const chainIdSchema = nonnegativeIntSchema;
|
|
49
53
|
|
|
50
54
|
const chainTypeUserConfigSchema = unionType(
|
|
@@ -267,7 +271,7 @@ const edrNetworkAccountsUserConfigSchema = conditionalUnionType(
|
|
|
267
271
|
const edrNetworkForkingUserConfigSchema = z.object({
|
|
268
272
|
enabled: z.optional(z.boolean()),
|
|
269
273
|
url: sensitiveUrlSchema,
|
|
270
|
-
blockNumber: z.optional(
|
|
274
|
+
blockNumber: z.optional(forkingBlockNumberSchema),
|
|
271
275
|
httpHeaders: z.optional(z.record(z.string())),
|
|
272
276
|
});
|
|
273
277
|
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
InvalidRequestError,
|
|
22
22
|
ProviderError,
|
|
23
23
|
} from "../../network-manager/provider-errors.js";
|
|
24
|
+
import { REVERT_ERROR_CODE } from "../../network-manager/revert-error-code.js";
|
|
24
25
|
|
|
25
26
|
export class JsonRpcHandler {
|
|
26
27
|
readonly #provider: EthereumProvider;
|
|
@@ -256,8 +257,15 @@ const _handleError = (error: Error): JsonRpcResponse => {
|
|
|
256
257
|
const txHash = extractTxHash(error);
|
|
257
258
|
const returnData = extractReturnData(error);
|
|
258
259
|
|
|
259
|
-
//
|
|
260
|
-
|
|
260
|
+
// Check if this is a revert error (code 3) matching the geth/anvil convention.
|
|
261
|
+
const isRevertError =
|
|
262
|
+
"code" in error &&
|
|
263
|
+
typeof error.code === "number" &&
|
|
264
|
+
error.code === REVERT_ERROR_CODE;
|
|
265
|
+
|
|
266
|
+
// In case of non-hardhat error that is not a revert, treat it as internal
|
|
267
|
+
// and associate the appropriate error code.
|
|
268
|
+
if (!ProviderError.isProviderError(error) && !isRevertError) {
|
|
261
269
|
error = new InternalError(undefined, error);
|
|
262
270
|
}
|
|
263
271
|
|
|
@@ -106,10 +106,10 @@ const nodeAction: NewTaskActionFunction<NodeActionArguments> = async (
|
|
|
106
106
|
);
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
// NOTE: This is where we initialize the network; the
|
|
109
|
+
// NOTE: This is where we initialize the network; the create method returns
|
|
110
110
|
// a fully resolved networkConfig object which might be useful for display
|
|
111
111
|
const { networkConfig, provider } =
|
|
112
|
-
await hre.network.
|
|
112
|
+
await hre.network.create(connectionParams);
|
|
113
113
|
|
|
114
114
|
assertHardhatInvariant(
|
|
115
115
|
provider instanceof EdrProvider,
|
|
@@ -25,7 +25,8 @@ const runScriptWithHardhat: NewTaskActionFunction<RunActionArguments> = async (
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
if (!noCompile) {
|
|
28
|
-
|
|
28
|
+
const noTests = hre.config.solidity.splitTestsCompilation;
|
|
29
|
+
await hre.tasks.getTask("build").run({ quiet: true, noTests });
|
|
29
30
|
console.log();
|
|
30
31
|
}
|
|
31
32
|
|
|
@@ -117,6 +117,9 @@ export async function getBuildInfo(
|
|
|
117
117
|
solcVersion: compilationJob.solcConfig.version,
|
|
118
118
|
solcLongVersion: compilationJob.solcLongVersion,
|
|
119
119
|
compilerType,
|
|
120
|
+
...(compilationJob.toolVersions !== undefined
|
|
121
|
+
? { toolVersions: compilationJob.toolVersions }
|
|
122
|
+
: {}),
|
|
120
123
|
userSourceNameMap:
|
|
121
124
|
compilationJob.dependencyGraph.getRootsUserSourceNameMap(),
|
|
122
125
|
input: await compilationJob.getSolcInput(),
|