hardhat 3.4.4 → 3.5.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 +61 -0
- package/dist/src/config.d.ts +0 -1
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +0 -3
- package/dist/src/config.js.map +1 -1
- package/dist/src/hre.d.ts +0 -1
- package/dist/src/hre.d.ts.map +1 -1
- package/dist/src/hre.js +0 -3
- package/dist/src/hre.js.map +1 -1
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +0 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/internal/builtin-global-options.d.ts.map +1 -1
- package/dist/src/internal/builtin-global-options.js +1 -1
- package/dist/src/internal/builtin-global-options.js.map +1 -1
- package/dist/src/internal/builtin-plugins/artifacts/index.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/artifacts/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/artifacts/index.js +0 -1
- package/dist/src/internal/builtin-plugins/artifacts/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/clean/index.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/clean/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/clean/index.js +0 -1
- package/dist/src/internal/builtin-plugins/clean/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/clean/type-extensions.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/clean/type-extensions.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/clean/type-extensions.js +1 -1
- package/dist/src/internal/builtin-plugins/clean/type-extensions.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/solidity.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/solidity.js +7 -10
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/solidity.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/index.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/coverage/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/index.js +0 -1
- package/dist/src/internal/builtin-plugins/coverage/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/instrumentation.d.ts +1 -4
- package/dist/src/internal/builtin-plugins/coverage/instrumentation.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/instrumentation.js +2 -4
- package/dist/src/internal/builtin-plugins/coverage/instrumentation.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/type-extensions.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/coverage/type-extensions.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/type-extensions.js +1 -1
- package/dist/src/internal/builtin-plugins/coverage/type-extensions.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/index.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/index.js +0 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.d.ts +21 -0
- 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 +49 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.d.ts +2 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.js +12 -2
- package/dist/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/type-extensions.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/type-extensions.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/type-extensions.js +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/type-extensions.js.map +1 -1
- package/dist/src/internal/builtin-plugins/index.d.ts +8 -8
- package/dist/src/internal/builtin-plugins/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/config-resolution.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/config-resolution.js +9 -2
- package/dist/src/internal/builtin-plugins/network-manager/config-resolution.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-constants.d.ts +1 -0
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-constants.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-constants.js +1 -0
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-constants.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js +25 -5
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-solidity-errors.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-solidity-errors.js +7 -6
- 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 +16 -0
- 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 +28 -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/index.d.ts +4 -4
- package/dist/src/internal/builtin-plugins/network-manager/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/index.js +0 -4
- package/dist/src/internal/builtin-plugins/network-manager/index.js.map +1 -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 +2 -6
- package/dist/src/internal/builtin-plugins/network-manager/network-manager.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/config.d.ts +5 -4
- 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-extensions/config.js +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/config.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/global-options.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/global-options.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/global-options.js +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/global-options.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/hooks.d.ts +0 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/hooks.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/hooks.js +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/hooks.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/hre.d.ts +0 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/hre.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/hre.js +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-extensions/hre.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-validation.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-validation.js +3 -1
- package/dist/src/internal/builtin-plugins/network-manager/type-validation.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/utils/apply-coverage-network-overrides.d.ts +18 -0
- package/dist/src/internal/builtin-plugins/network-manager/utils/apply-coverage-network-overrides.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/network-manager/utils/apply-coverage-network-overrides.js +27 -0
- package/dist/src/internal/builtin-plugins/network-manager/utils/apply-coverage-network-overrides.js.map +1 -0
- package/dist/src/internal/builtin-plugins/node/json-rpc/handler.js +6 -5
- package/dist/src/internal/builtin-plugins/node/json-rpc/handler.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js +22 -9
- package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.js +7 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/constants.d.ts +10 -0
- package/dist/src/internal/builtin-plugins/solidity/constants.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/constants.js +10 -0
- package/dist/src/internal/builtin-plugins/solidity/constants.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/index.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/solidity/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/index.js +1 -1
- package/dist/src/internal/builtin-plugins/solidity/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/tasks/compile.d.ts +9 -0
- package/dist/src/internal/builtin-plugins/solidity/tasks/compile.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity/tasks/compile.js +10 -0
- package/dist/src/internal/builtin-plugins/solidity/tasks/compile.js.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity/type-extensions.d.ts +0 -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 +1 -4
- package/dist/src/internal/builtin-plugins/solidity/type-extensions.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/config.d.ts +4 -3
- package/dist/src/internal/builtin-plugins/solidity-test/config.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/config.js +55 -8
- package/dist/src/internal/builtin-plugins/solidity-test/config.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/ast-walker.d.ts +58 -0
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/ast-walker.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/ast-walker.js +226 -0
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/ast-walker.js.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/canonicalize.d.ts +29 -0
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/canonicalize.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/canonicalize.js +244 -0
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/canonicalize.js.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/glob.d.ts +7 -0
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/glob.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/glob.js +204 -0
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/glob.js.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/index.d.ts +21 -0
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/index.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/index.js +77 -0
- package/dist/src/internal/builtin-plugins/solidity-test/eip712/index.js.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.d.ts +4 -3
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.js +20 -3
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/index.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/index.js +0 -1
- package/dist/src/internal/builtin-plugins/solidity-test/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/constants.d.ts +4 -2
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/constants.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/constants.js +5 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/constants.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/helpers.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/helpers.js +15 -3
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/helpers.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/validation.d.ts +3 -2
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/validation.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/validation.js +18 -4
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/validation.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 +5 -1
- package/dist/src/internal/builtin-plugins/solidity-test/task-action.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/test-profiles.d.ts +2 -0
- package/dist/src/internal/builtin-plugins/solidity-test/test-profiles.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/test-profiles.js +2 -0
- package/dist/src/internal/builtin-plugins/solidity-test/test-profiles.js.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/type-extensions.d.ts +91 -33
- package/dist/src/internal/builtin-plugins/solidity-test/type-extensions.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/type-extensions.js +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/type-extensions.js.map +1 -1
- package/dist/src/internal/builtin-plugins/test/index.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/test/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/test/index.js +0 -1
- package/dist/src/internal/builtin-plugins/test/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/test/type-extensions.d.ts +0 -1
- package/dist/src/internal/builtin-plugins/test/type-extensions.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/test/type-extensions.js +1 -1
- package/dist/src/internal/builtin-plugins/test/type-extensions.js.map +1 -1
- package/dist/src/internal/cli/init/init.d.ts +31 -6
- package/dist/src/internal/cli/init/init.d.ts.map +1 -1
- package/dist/src/internal/cli/init/init.js +121 -10
- package/dist/src/internal/cli/init/init.js.map +1 -1
- package/dist/src/internal/cli/main.d.ts.map +1 -1
- package/dist/src/internal/cli/main.js +41 -1
- package/dist/src/internal/cli/main.js.map +1 -1
- package/dist/src/types/arguments.d.ts +1 -0
- package/dist/src/types/arguments.d.ts.map +1 -1
- package/dist/src/types/arguments.js +1 -0
- package/dist/src/types/arguments.js.map +1 -1
- package/dist/src/types/artifacts.d.ts +1 -0
- package/dist/src/types/artifacts.d.ts.map +1 -1
- package/dist/src/types/artifacts.js +1 -1
- package/dist/src/types/artifacts.js.map +1 -1
- package/dist/src/types/builtin-plugin-type-extensions.d.ts +2 -0
- package/dist/src/types/builtin-plugin-type-extensions.d.ts.map +1 -0
- package/dist/src/types/builtin-plugin-type-extensions.js +2 -0
- package/dist/src/types/builtin-plugin-type-extensions.js.map +1 -0
- package/dist/src/types/config.d.ts +1 -1
- package/dist/src/types/config.d.ts.map +1 -1
- package/dist/src/types/config.js +1 -3
- package/dist/src/types/config.js.map +1 -1
- package/dist/src/types/global-options.d.ts +1 -0
- package/dist/src/types/global-options.d.ts.map +1 -1
- package/dist/src/types/global-options.js +1 -1
- package/dist/src/types/global-options.js.map +1 -1
- package/dist/src/types/hooks.d.ts +1 -0
- package/dist/src/types/hooks.d.ts.map +1 -1
- package/dist/src/types/hooks.js +1 -1
- package/dist/src/types/hooks.js.map +1 -1
- package/dist/src/types/hre.d.ts +1 -0
- package/dist/src/types/hre.d.ts.map +1 -1
- package/dist/src/types/hre.js +1 -1
- package/dist/src/types/hre.js.map +1 -1
- package/dist/src/types/index.d.ts +1 -0
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/index.js +1 -0
- package/dist/src/types/index.js.map +1 -1
- package/dist/src/types/network.d.ts +1 -0
- package/dist/src/types/network.d.ts.map +1 -1
- package/dist/src/types/network.js +1 -1
- package/dist/src/types/network.js.map +1 -1
- package/dist/src/types/plugins.d.ts +1 -1
- package/dist/src/types/plugins.d.ts.map +1 -1
- package/dist/src/types/plugins.js +1 -3
- package/dist/src/types/plugins.js.map +1 -1
- package/dist/src/types/providers.d.ts +1 -0
- package/dist/src/types/providers.d.ts.map +1 -1
- package/dist/src/types/providers.js +1 -1
- package/dist/src/types/providers.js.map +1 -1
- package/dist/src/types/solidity.d.ts +1 -0
- package/dist/src/types/solidity.d.ts.map +1 -1
- package/dist/src/types/solidity.js +1 -0
- package/dist/src/types/solidity.js.map +1 -1
- package/dist/src/types/tasks.d.ts +1 -0
- package/dist/src/types/tasks.d.ts.map +1 -1
- package/dist/src/types/tasks.js +1 -0
- package/dist/src/types/tasks.js.map +1 -1
- package/dist/src/types/test.d.ts +1 -0
- package/dist/src/types/test.d.ts.map +1 -1
- package/dist/src/types/test.js +1 -1
- package/dist/src/types/test.js.map +1 -1
- package/dist/src/types/user-interruptions.d.ts +1 -0
- package/dist/src/types/user-interruptions.d.ts.map +1 -1
- package/dist/src/types/user-interruptions.js +1 -1
- package/dist/src/types/user-interruptions.js.map +1 -1
- package/package.json +12 -12
- package/src/config.ts +0 -3
- package/src/hre.ts +0 -4
- package/src/index.ts +0 -4
- package/src/internal/builtin-global-options.ts +2 -1
- package/src/internal/builtin-plugins/artifacts/index.ts +1 -1
- package/src/internal/builtin-plugins/clean/index.ts +1 -1
- package/src/internal/builtin-plugins/clean/type-extensions.ts +0 -1
- package/src/internal/builtin-plugins/coverage/hook-handlers/solidity.ts +8 -13
- package/src/internal/builtin-plugins/coverage/index.ts +1 -1
- package/src/internal/builtin-plugins/coverage/instrumentation.ts +0 -5
- package/src/internal/builtin-plugins/coverage/type-extensions.ts +0 -1
- package/src/internal/builtin-plugins/gas-analytics/index.ts +1 -1
- package/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.ts +90 -1
- package/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.ts +24 -2
- package/src/internal/builtin-plugins/gas-analytics/type-extensions.ts +0 -1
- package/src/internal/builtin-plugins/index.ts +10 -10
- package/src/internal/builtin-plugins/network-manager/config-resolution.ts +11 -3
- package/src/internal/builtin-plugins/network-manager/edr/edr-constants.ts +2 -0
- package/src/internal/builtin-plugins/network-manager/edr/edr-provider.ts +38 -8
- package/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-solidity-errors.ts +10 -11
- package/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.ts +43 -1
- package/src/internal/builtin-plugins/network-manager/index.ts +4 -4
- package/src/internal/builtin-plugins/network-manager/network-manager.ts +5 -6
- package/src/internal/builtin-plugins/network-manager/type-extensions/config.ts +5 -4
- package/src/internal/builtin-plugins/network-manager/type-extensions/global-options.ts +0 -1
- package/src/internal/builtin-plugins/network-manager/type-extensions/hooks.ts +0 -1
- package/src/internal/builtin-plugins/network-manager/type-extensions/hre.ts +0 -1
- package/src/internal/builtin-plugins/network-manager/type-validation.ts +7 -1
- package/src/internal/builtin-plugins/network-manager/utils/apply-coverage-network-overrides.ts +32 -0
- package/src/internal/builtin-plugins/node/json-rpc/handler.ts +7 -5
- package/src/internal/builtin-plugins/solidity/build-system/build-system.ts +32 -16
- package/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.ts +8 -2
- package/src/internal/builtin-plugins/solidity/constants.ts +11 -0
- package/src/internal/builtin-plugins/solidity/index.ts +2 -1
- package/src/internal/builtin-plugins/solidity/tasks/compile.ts +12 -0
- package/src/internal/builtin-plugins/solidity/type-extensions.ts +0 -4
- package/src/internal/builtin-plugins/solidity-test/config.ts +85 -12
- package/src/internal/builtin-plugins/solidity-test/eip712/ast-walker.ts +324 -0
- package/src/internal/builtin-plugins/solidity-test/eip712/canonicalize.ts +317 -0
- package/src/internal/builtin-plugins/solidity-test/eip712/glob.ts +225 -0
- package/src/internal/builtin-plugins/solidity-test/eip712/index.ts +120 -0
- package/src/internal/builtin-plugins/solidity-test/helpers.ts +28 -4
- package/src/internal/builtin-plugins/solidity-test/index.ts +1 -1
- package/src/internal/builtin-plugins/solidity-test/inline-config/constants.ts +6 -2
- package/src/internal/builtin-plugins/solidity-test/inline-config/helpers.ts +15 -4
- package/src/internal/builtin-plugins/solidity-test/inline-config/validation.ts +25 -4
- package/src/internal/builtin-plugins/solidity-test/task-action.ts +12 -1
- package/src/internal/builtin-plugins/solidity-test/test-profiles.ts +1 -0
- package/src/internal/builtin-plugins/solidity-test/type-extensions.ts +100 -34
- package/src/internal/builtin-plugins/test/index.ts +1 -1
- package/src/internal/builtin-plugins/test/type-extensions.ts +0 -1
- package/src/internal/cli/init/init.ts +198 -16
- package/src/internal/cli/main.ts +64 -1
- package/src/types/arguments.ts +2 -0
- package/src/types/artifacts.ts +2 -0
- package/src/types/builtin-plugin-type-extensions.ts +15 -0
- package/src/types/config.ts +1 -3
- package/src/types/global-options.ts +2 -0
- package/src/types/hooks.ts +2 -0
- package/src/types/hre.ts +2 -0
- package/src/types/index.ts +2 -0
- package/src/types/network.ts +2 -0
- package/src/types/plugins.ts +1 -3
- package/src/types/providers.ts +2 -0
- package/src/types/solidity.ts +2 -0
- package/src/types/tasks.ts +2 -0
- package/src/types/test.ts +2 -0
- package/src/types/user-interruptions.ts +2 -0
- package/templates/hardhat-3/01-node-test-runner-viem/package.json +12 -12
- package/templates/hardhat-3/01-node-test-runner-viem/tsconfig.json +4 -7
- package/templates/hardhat-3/02-mocha-ethers/package.json +15 -15
- package/templates/hardhat-3/02-mocha-ethers/tsconfig.json +4 -7
- package/templates/hardhat-3/03-minimal/package.json +2 -2
- package/templates/hardhat-3/03-minimal/tsconfig.json +4 -7
- package/coverage.sol +0 -38
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-extensions.js","sourceRoot":"","sources":["../../../../../src/internal/builtin-plugins/solidity/type-extensions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"type-extensions.js","sourceRoot":"","sources":["../../../../../src/internal/builtin-plugins/solidity/type-extensions.ts"],"names":[],"mappings":""}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { HardhatUserConfig } from "../../../config.js";
|
|
2
2
|
import type { ConfigurationVariableResolver, HardhatConfig } from "../../../types/config.js";
|
|
3
3
|
import type { HardhatUserConfigValidationError } from "../../../types/hooks.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { SolidityTestForkingConfig, SolidityTestProfileConfig, SolidityTestProfileUserConfig } from "../../../types/test.js";
|
|
5
5
|
export declare const DEFAULT_FUZZ_SEED = "0x7727ea51af0441c20da14dcd68a15dac8c9ebd589c5be8fa8c87c1d3720450bc";
|
|
6
|
-
export declare function resolveSolidityTestForkingConfig(forkingUserConfig:
|
|
6
|
+
export declare function resolveSolidityTestForkingConfig(forkingUserConfig: SolidityTestProfileUserConfig["forking"], resolveConfigurationVariable: ConfigurationVariableResolver): SolidityTestForkingConfig | undefined;
|
|
7
7
|
export declare function validateSolidityTestUserConfig(userConfig: unknown): HardhatUserConfigValidationError[];
|
|
8
8
|
export declare function resolveSolidityTestUserConfig(userConfig: HardhatUserConfig, resolvedConfig: HardhatConfig, resolveConfigurationVariable: ConfigurationVariableResolver): Promise<HardhatConfig>;
|
|
9
|
-
export declare function resolveFuzzConfig(fuzzUserConfig?:
|
|
9
|
+
export declare function resolveFuzzConfig(fuzzUserConfig?: SolidityTestProfileUserConfig["fuzz"]): SolidityTestProfileConfig["fuzz"];
|
|
10
|
+
export declare function resolveEip712TypesConfig(eip712TypesUserConfig?: SolidityTestProfileUserConfig["eip712Types"]): SolidityTestProfileConfig["eip712Types"];
|
|
10
11
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../../src/internal/builtin-plugins/solidity-test/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EACV,6BAA6B,EAC7B,aAAa,EAEd,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../../src/internal/builtin-plugins/solidity-test/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EACV,6BAA6B,EAC7B,aAAa,EAEd,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,KAAK,EACV,yBAAyB,EACzB,yBAAyB,EACzB,6BAA6B,EAC9B,MAAM,wBAAwB,CAAC;AAoBhC,eAAO,MAAM,iBAAiB,uEACwC,CAAC;AAiIvE,wBAAgB,gCAAgC,CAC9C,iBAAiB,EAAE,6BAA6B,CAAC,SAAS,CAAC,EAC3D,4BAA4B,EAAE,6BAA6B,GAC1D,yBAAyB,GAAG,SAAS,CAyBvC;AAED,wBAAgB,8BAA8B,CAC5C,UAAU,EAAE,OAAO,GAClB,gCAAgC,EAAE,CAEpC;AAED,wBAAsB,6BAA6B,CACjD,UAAU,EAAE,iBAAiB,EAC7B,cAAc,EAAE,aAAa,EAC7B,4BAA4B,EAAE,6BAA6B,GAC1D,OAAO,CAAC,aAAa,CAAC,CAkDxB;AAED,wBAAgB,iBAAiB,CAC/B,cAAc,GAAE,6BAA6B,CAAC,MAAM,CAAM,GACzD,yBAAyB,CAAC,MAAM,CAAC,CAKnC;AAED,wBAAgB,wBAAwB,CACtC,qBAAqB,GAAE,6BAA6B,CAAC,aAAa,CAAM,GACvE,yBAAyB,CAAC,aAAa,CAAC,CAK1C"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
import { assertHardhatInvariant } from "@nomicfoundation/hardhat-errors";
|
|
2
3
|
import { isObject } from "@nomicfoundation/hardhat-utils/lang";
|
|
3
4
|
import { resolveFromRoot } from "@nomicfoundation/hardhat-utils/path";
|
|
4
|
-
import { conditionalUnionType, sensitiveStringSchema, sensitiveUrlSchema, unionType, validateUserConfigZodType, } from "@nomicfoundation/hardhat-zod-utils";
|
|
5
|
+
import { conditionalUnionType, incompatibleFieldType, sensitiveStringSchema, sensitiveUrlSchema, unionType, validateUserConfigZodType, } from "@nomicfoundation/hardhat-zod-utils";
|
|
5
6
|
import { z } from "zod";
|
|
7
|
+
import { DEFAULT_TEST_PROFILE } from "./test-profiles.js";
|
|
6
8
|
// the keccak256 of "built for ethereum"
|
|
7
9
|
export const DEFAULT_FUZZ_SEED = "0x7727ea51af0441c20da14dcd68a15dac8c9ebd589c5be8fa8c87c1d3720450bc";
|
|
8
|
-
const
|
|
10
|
+
const solidityTestProfileUserConfigType = z.object({
|
|
9
11
|
fsPermissions: z
|
|
10
12
|
.object({
|
|
11
13
|
readWriteFile: z.array(z.string()).optional(),
|
|
@@ -27,7 +29,11 @@ const solidityTestUserConfigType = z.object({
|
|
|
27
29
|
blockTimestamp: z.bigint().optional(),
|
|
28
30
|
prevRandao: z.bigint().optional(),
|
|
29
31
|
gasLimit: z.bigint().optional(),
|
|
30
|
-
blockGasLimit: z.bigint().or(z.literal(false)).optional(),
|
|
32
|
+
blockGasLimit: z.number().or(z.bigint()).or(z.literal(false)).optional(),
|
|
33
|
+
// TODO: widen back to .number().or(z.bigint()).or(z.literal(false))
|
|
34
|
+
// once Solidity test runner no longer breaks setUp() when
|
|
35
|
+
// disableTransactionGasCap is false. See PR #8301.
|
|
36
|
+
transactionGasCap: z.literal(false).optional(),
|
|
31
37
|
fuzz: z
|
|
32
38
|
.object({
|
|
33
39
|
failurePersistDir: z.string().optional(),
|
|
@@ -61,7 +67,30 @@ const solidityTestUserConfigType = z.object({
|
|
|
61
67
|
shrinkRunLimit: z.number().optional(),
|
|
62
68
|
})
|
|
63
69
|
.optional(),
|
|
70
|
+
eip712Types: z
|
|
71
|
+
.object({
|
|
72
|
+
include: z.array(z.string()).optional(),
|
|
73
|
+
exclude: z.array(z.string()).optional(),
|
|
74
|
+
})
|
|
75
|
+
.optional(),
|
|
64
76
|
});
|
|
77
|
+
const solidityTestFlatUserConfigType = solidityTestProfileUserConfigType.extend({
|
|
78
|
+
profiles: incompatibleFieldType("This field is incompatible with the flat solidity test config"),
|
|
79
|
+
});
|
|
80
|
+
const solidityTestProfilesUserConfigType = z.object({
|
|
81
|
+
profiles: z
|
|
82
|
+
.record(z.string(), solidityTestProfileUserConfigType)
|
|
83
|
+
.refine((profiles) => DEFAULT_TEST_PROFILE in profiles, "A `default` profile is required when using `profiles`")
|
|
84
|
+
.refine((profiles) => !(DEFAULT_TEST_PROFILE in profiles) ||
|
|
85
|
+
Object.keys(profiles).every((name) => name === DEFAULT_TEST_PROFILE), "Only the `default` profile is supported. Other profile names will be supported in a future release."),
|
|
86
|
+
});
|
|
87
|
+
const solidityTestUserConfigType = conditionalUnionType([
|
|
88
|
+
[
|
|
89
|
+
(data) => isObject(data) && "profiles" in data && Object.keys(data).length === 1,
|
|
90
|
+
solidityTestProfilesUserConfigType,
|
|
91
|
+
],
|
|
92
|
+
[isObject, solidityTestFlatUserConfigType],
|
|
93
|
+
], "Expected a Solidity test config or a `{ profiles: { ... } }` wrapper");
|
|
65
94
|
const userConfigType = z.object({
|
|
66
95
|
paths: z
|
|
67
96
|
.object({
|
|
@@ -107,12 +136,22 @@ export async function resolveSolidityTestUserConfig(userConfig, resolvedConfig,
|
|
|
107
136
|
testsPath = typeof testsPath === "object" ? testsPath.solidity : testsPath;
|
|
108
137
|
testsPath ??= "test";
|
|
109
138
|
const defaultRpcCachePath = path.join(resolvedConfig.paths.cache, "edr");
|
|
110
|
-
const
|
|
111
|
-
|
|
139
|
+
const solidityUserConfig = userConfig.test?.solidity;
|
|
140
|
+
let profileUserConfig;
|
|
141
|
+
if (solidityUserConfig !== undefined && "profiles" in solidityUserConfig) {
|
|
142
|
+
profileUserConfig = solidityUserConfig.profiles[DEFAULT_TEST_PROFILE];
|
|
143
|
+
assertHardhatInvariant(profileUserConfig !== undefined, "default profile must be present when the profiles wrapper user config is supplied");
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
profileUserConfig = solidityUserConfig;
|
|
147
|
+
}
|
|
148
|
+
const resolvedForking = resolveSolidityTestForkingConfig(profileUserConfig?.forking, resolveConfigurationVariable);
|
|
149
|
+
const resolvedDefaultProfile = {
|
|
112
150
|
rpcCachePath: defaultRpcCachePath,
|
|
113
|
-
...
|
|
114
|
-
fuzz: resolveFuzzConfig(
|
|
151
|
+
...profileUserConfig,
|
|
152
|
+
fuzz: resolveFuzzConfig(profileUserConfig?.fuzz),
|
|
115
153
|
forking: resolvedForking,
|
|
154
|
+
eip712Types: resolveEip712TypesConfig(profileUserConfig?.eip712Types),
|
|
116
155
|
};
|
|
117
156
|
return {
|
|
118
157
|
...resolvedConfig,
|
|
@@ -125,7 +164,9 @@ export async function resolveSolidityTestUserConfig(userConfig, resolvedConfig,
|
|
|
125
164
|
},
|
|
126
165
|
test: {
|
|
127
166
|
...resolvedConfig.test,
|
|
128
|
-
solidity:
|
|
167
|
+
solidity: {
|
|
168
|
+
profiles: { [DEFAULT_TEST_PROFILE]: resolvedDefaultProfile },
|
|
169
|
+
},
|
|
129
170
|
},
|
|
130
171
|
};
|
|
131
172
|
}
|
|
@@ -135,4 +176,10 @@ export function resolveFuzzConfig(fuzzUserConfig = {}) {
|
|
|
135
176
|
seed: fuzzUserConfig.seed ?? DEFAULT_FUZZ_SEED,
|
|
136
177
|
};
|
|
137
178
|
}
|
|
179
|
+
export function resolveEip712TypesConfig(eip712TypesUserConfig = {}) {
|
|
180
|
+
return {
|
|
181
|
+
include: eip712TypesUserConfig.include ?? [],
|
|
182
|
+
exclude: eip712TypesUserConfig.exclude ?? [],
|
|
183
|
+
};
|
|
184
|
+
}
|
|
138
185
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../../src/internal/builtin-plugins/solidity-test/config.ts"],"names":[],"mappings":"AAaA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,SAAS,EACT,yBAAyB,GAC1B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,wCAAwC;AACxC,MAAM,CAAC,MAAM,iBAAiB,GAC5B,oEAAoE,CAAC;AAEvE,MAAM,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../../src/internal/builtin-plugins/solidity-test/config.ts"],"names":[],"mappings":"AAaA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,E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;YACL,GAAG,cAAc,CAAC,KAAK;YACvB,KAAK,EAAE;gBACL,GAAG,cAAc,CAAC,KAAK,CAAC,KAAK;gBAC7B,QAAQ,EAAE,eAAe,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC;aAChE;SACF;QACD,IAAI,EAAE;YACJ,GAAG,cAAc,CAAC,IAAI;YACtB,QAAQ,EAAE;gBACR,QAAQ,EAAE,EAAE,CAAC,oBAAoB,CAAC,EAAE,sBAAsB,EAAE;aAC7D;SACF;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,iBAAwD,EAAE;IAE1D,OAAO;QACL,GAAG,cAAc;QACjB,IAAI,EAAE,cAAc,CAAC,IAAI,IAAI,iBAAiB;KAC/C,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,wBAAwB,CACtC,wBAAsE,EAAE;IAExE,OAAO;QACL,OAAO,EAAE,qBAAqB,CAAC,OAAO,IAAI,EAAE;QAC5C,OAAO,EAAE,qBAAqB,CAAC,OAAO,IAAI,EAAE;KAC7C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A single field of a Solidity struct
|
|
3
|
+
*/
|
|
4
|
+
export interface StructMember {
|
|
5
|
+
name: string;
|
|
6
|
+
/**
|
|
7
|
+
* EIP-712 type string, or `undefined` if the type can't be encoded (e.g. mappings).
|
|
8
|
+
*/
|
|
9
|
+
type: string | undefined;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A Solidity struct extracted from a source AST (Abstract Syntax Tree).
|
|
13
|
+
*/
|
|
14
|
+
export interface CollectedStruct {
|
|
15
|
+
name: string;
|
|
16
|
+
members: StructMember[];
|
|
17
|
+
/**
|
|
18
|
+
* Project-relative source path. Used for diagnostics only.
|
|
19
|
+
*/
|
|
20
|
+
sourcePath: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A user-defined value type (`type Foo is bytes32;`) resolves to its
|
|
24
|
+
* underlying elementary type for EIP-712 encoding.
|
|
25
|
+
* The map is keyed by the user-defined value type definition's solc node id,
|
|
26
|
+
* which is what `referencedDeclaration` on a `UserDefinedTypeName` reference
|
|
27
|
+
* points to.
|
|
28
|
+
*/
|
|
29
|
+
export type UserDefinedValueTypeIndex = Map<number, Record<string, unknown>>;
|
|
30
|
+
/**
|
|
31
|
+
* Walks every AST in the build and indexes every `UserDefinedValueTypeDefinition`
|
|
32
|
+
* by its node `id`, mapping to its `underlyingType` (an `ElementaryTypeName`).
|
|
33
|
+
*
|
|
34
|
+
* User-defined value types can sit at file scope or inside a contract, and a
|
|
35
|
+
* struct in one source may reference a user-defined value type defined in
|
|
36
|
+
* another, so this must run across every AST in the build — not just the ones
|
|
37
|
+
* matched by the user's include globs.
|
|
38
|
+
*/
|
|
39
|
+
export declare function buildUserDefinedValueTypeIndex(asts: unknown[]): UserDefinedValueTypeIndex;
|
|
40
|
+
/**
|
|
41
|
+
* Returns every struct definition reachable from a solc source AST (Abstract Syntax Tree),
|
|
42
|
+
* including structs nested inside contracts.
|
|
43
|
+
*/
|
|
44
|
+
export declare function extractStructsFromAst(ast: unknown, sourcePath: string, userDefinedValueTypeI?: UserDefinedValueTypeIndex): CollectedStruct[];
|
|
45
|
+
/**
|
|
46
|
+
* Converts a solc `typeName` AST node into its EIP-712 type string, following
|
|
47
|
+
* the same conventions as `forge bind-json`:
|
|
48
|
+
*
|
|
49
|
+
* - elementary types pass through (`address`, `uint256`, `string`, ...)
|
|
50
|
+
* - enums → `uint8`
|
|
51
|
+
* - contracts / interfaces → `address`
|
|
52
|
+
* - structs → bare name (`Wallet.Person` → `Person`)
|
|
53
|
+
* - user-defined value types → underlying elementary type (`type Foo is bytes32` → `bytes32`)
|
|
54
|
+
* - arrays → `T[]` (dynamic) or `T[N]` (fixed)
|
|
55
|
+
* - mappings / functions → `undefined` (not EIP-712 encodable)
|
|
56
|
+
*/
|
|
57
|
+
export declare function encodeMemberType(typeName: unknown, userDefinedValueTypeI?: UserDefinedValueTypeIndex): string | undefined;
|
|
58
|
+
//# sourceMappingURL=ast-walker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast-walker.d.ts","sourceRoot":"","sources":["../../../../../../src/internal/builtin-plugins/solidity-test/eip712/ast-walker.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,yBAAyB,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAE7E;;;;;;;;GAQG;AACH,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,OAAO,EAAE,GACd,yBAAyB,CA+B3B;AAeD;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,OAAO,EACZ,UAAU,EAAE,MAAM,EAClB,qBAAqB,GAAE,yBAAqC,GAC3D,eAAe,EAAE,CAoCnB;AAyCD;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,OAAO,EACjB,qBAAqB,GAAE,yBAAqC,GAC3D,MAAM,GAAG,SAAS,CAoIpB"}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { isObject } from "@nomicfoundation/hardhat-utils/lang";
|
|
2
|
+
/**
|
|
3
|
+
* Walks every AST in the build and indexes every `UserDefinedValueTypeDefinition`
|
|
4
|
+
* by its node `id`, mapping to its `underlyingType` (an `ElementaryTypeName`).
|
|
5
|
+
*
|
|
6
|
+
* User-defined value types can sit at file scope or inside a contract, and a
|
|
7
|
+
* struct in one source may reference a user-defined value type defined in
|
|
8
|
+
* another, so this must run across every AST in the build — not just the ones
|
|
9
|
+
* matched by the user's include globs.
|
|
10
|
+
*/
|
|
11
|
+
export function buildUserDefinedValueTypeIndex(asts) {
|
|
12
|
+
const index = new Map();
|
|
13
|
+
for (const ast of asts) {
|
|
14
|
+
if (!isObject(ast) || ast.nodeType !== "SourceUnit") {
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
const topLevelNodes = Array.isArray(ast.nodes) ? ast.nodes : [];
|
|
18
|
+
for (const node of topLevelNodes) {
|
|
19
|
+
if (!isObject(node)) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
if (node.nodeType === "UserDefinedValueTypeDefinition") {
|
|
23
|
+
recordUserDefinedValueType(node, index);
|
|
24
|
+
}
|
|
25
|
+
else if (node.nodeType === "ContractDefinition") {
|
|
26
|
+
const members = Array.isArray(node.nodes) ? node.nodes : [];
|
|
27
|
+
for (const member of members) {
|
|
28
|
+
if (isObject(member) &&
|
|
29
|
+
member.nodeType === "UserDefinedValueTypeDefinition") {
|
|
30
|
+
recordUserDefinedValueType(member, index);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return index;
|
|
37
|
+
}
|
|
38
|
+
function recordUserDefinedValueType(node, index) {
|
|
39
|
+
if (typeof node.id === "number" &&
|
|
40
|
+
isObject(node.underlyingType) &&
|
|
41
|
+
node.underlyingType.nodeType === "ElementaryTypeName") {
|
|
42
|
+
index.set(node.id, node.underlyingType);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Returns every struct definition reachable from a solc source AST (Abstract Syntax Tree),
|
|
47
|
+
* including structs nested inside contracts.
|
|
48
|
+
*/
|
|
49
|
+
export function extractStructsFromAst(ast, sourcePath, userDefinedValueTypeI = new Map()) {
|
|
50
|
+
if (!isObject(ast) || ast.nodeType !== "SourceUnit") {
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
const results = [];
|
|
54
|
+
const topLevelNodes = Array.isArray(ast.nodes) ? ast.nodes : [];
|
|
55
|
+
for (const node of topLevelNodes) {
|
|
56
|
+
if (!isObject(node)) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (node.nodeType === "StructDefinition") {
|
|
60
|
+
const collected = collectStruct(node, sourcePath, userDefinedValueTypeI);
|
|
61
|
+
if (collected !== undefined) {
|
|
62
|
+
results.push(collected);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else if (node.nodeType === "ContractDefinition") {
|
|
66
|
+
const members = Array.isArray(node.nodes) ? node.nodes : [];
|
|
67
|
+
for (const member of members) {
|
|
68
|
+
if (isObject(member) && member.nodeType === "StructDefinition") {
|
|
69
|
+
const collected = collectStruct(member, sourcePath, userDefinedValueTypeI);
|
|
70
|
+
if (collected !== undefined) {
|
|
71
|
+
results.push(collected);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return results;
|
|
78
|
+
}
|
|
79
|
+
function collectStruct(node, sourcePath, userDefinedValueTypeI) {
|
|
80
|
+
if (typeof node.name !== "string") {
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
const memberNodes = Array.isArray(node.members)
|
|
84
|
+
? node.members
|
|
85
|
+
: [];
|
|
86
|
+
const members = [];
|
|
87
|
+
for (const memberNode of memberNodes) {
|
|
88
|
+
if (!isObject(memberNode) ||
|
|
89
|
+
memberNode.nodeType !== "VariableDeclaration") {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (typeof memberNode.name !== "string") {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
members.push({
|
|
96
|
+
name: memberNode.name,
|
|
97
|
+
type: encodeMemberType(memberNode.typeName, userDefinedValueTypeI),
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
name: node.name,
|
|
102
|
+
members,
|
|
103
|
+
sourcePath,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Converts a solc `typeName` AST node into its EIP-712 type string, following
|
|
108
|
+
* the same conventions as `forge bind-json`:
|
|
109
|
+
*
|
|
110
|
+
* - elementary types pass through (`address`, `uint256`, `string`, ...)
|
|
111
|
+
* - enums → `uint8`
|
|
112
|
+
* - contracts / interfaces → `address`
|
|
113
|
+
* - structs → bare name (`Wallet.Person` → `Person`)
|
|
114
|
+
* - user-defined value types → underlying elementary type (`type Foo is bytes32` → `bytes32`)
|
|
115
|
+
* - arrays → `T[]` (dynamic) or `T[N]` (fixed)
|
|
116
|
+
* - mappings / functions → `undefined` (not EIP-712 encodable)
|
|
117
|
+
*/
|
|
118
|
+
export function encodeMemberType(typeName, userDefinedValueTypeI = new Map()) {
|
|
119
|
+
if (!isObject(typeName)) {
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
switch (typeName.nodeType) {
|
|
123
|
+
case "ElementaryTypeName": {
|
|
124
|
+
// Prefer `typeDescriptions.typeString` over `name`: solc emits the
|
|
125
|
+
// unresolved alias in `name` (`uint`, `int`, `byte`), but the canonical
|
|
126
|
+
// EIP-712 type is in `typeString` (`uint256`, `int256`, `bytes1`).
|
|
127
|
+
// `address payable` is the exception — `typeString` is `"address payable"`
|
|
128
|
+
// while the canonical EIP-712 type is just `address`.
|
|
129
|
+
const desc = isObject(typeName.typeDescriptions)
|
|
130
|
+
? typeName.typeDescriptions
|
|
131
|
+
: undefined;
|
|
132
|
+
const typeString = typeof desc?.typeString === "string" ? desc.typeString : undefined;
|
|
133
|
+
if (typeString !== undefined) {
|
|
134
|
+
return typeString.endsWith(" payable")
|
|
135
|
+
? typeString.slice(0, -" payable".length)
|
|
136
|
+
: typeString;
|
|
137
|
+
}
|
|
138
|
+
return typeof typeName.name === "string" ? typeName.name : undefined;
|
|
139
|
+
}
|
|
140
|
+
case "UserDefinedTypeName": {
|
|
141
|
+
// `typeDescriptions.typeString` is the only reliable way to tell what
|
|
142
|
+
// kind of user-defined type this is — e.g. "struct Foo", "enum Bar",
|
|
143
|
+
// "contract Token". The AST node itself doesn't say. Note that solc
|
|
144
|
+
// emits the "contract " prefix for interface references as well.
|
|
145
|
+
const desc = isObject(typeName.typeDescriptions)
|
|
146
|
+
? typeName.typeDescriptions
|
|
147
|
+
: undefined;
|
|
148
|
+
const typeString = typeof desc?.typeString === "string" ? desc.typeString : "";
|
|
149
|
+
if (typeString.startsWith("enum ")) {
|
|
150
|
+
return "uint8";
|
|
151
|
+
}
|
|
152
|
+
if (typeString.startsWith("contract ")) {
|
|
153
|
+
return "address";
|
|
154
|
+
}
|
|
155
|
+
if (typeString.startsWith("struct ")) {
|
|
156
|
+
// EIP-712 references structs by their bare name, so strip both the
|
|
157
|
+
// "struct " prefix, any storage-location suffix solc may append
|
|
158
|
+
// ("memory", "storage", ...), and any qualifier ("Wallet.Person").
|
|
159
|
+
const remainder = typeString.slice("struct ".length).trim();
|
|
160
|
+
const namePart = remainder.split(/\s+/)[0];
|
|
161
|
+
const segments = namePart.split(".");
|
|
162
|
+
return segments[segments.length - 1];
|
|
163
|
+
}
|
|
164
|
+
// User-defined value types (`type Foo is bytes32;`, solc 0.8.8+).
|
|
165
|
+
// Resolve via `referencedDeclaration` against the build-wide
|
|
166
|
+
// user-defined value type index
|
|
167
|
+
// and recurse on the underlying elementary type — matching forge's
|
|
168
|
+
// `Resolver::resolve_type` so `Foo h` encodes as `bytes32 h`, not `Foo h`.
|
|
169
|
+
const refId = typeof typeName.referencedDeclaration === "number"
|
|
170
|
+
? typeName.referencedDeclaration
|
|
171
|
+
: isObject(typeName.pathNode) &&
|
|
172
|
+
typeof typeName.pathNode.referencedDeclaration === "number"
|
|
173
|
+
? typeName.pathNode.referencedDeclaration
|
|
174
|
+
: undefined;
|
|
175
|
+
if (refId !== undefined) {
|
|
176
|
+
const underlying = userDefinedValueTypeI.get(refId);
|
|
177
|
+
if (underlying !== undefined) {
|
|
178
|
+
return encodeMemberType(underlying, userDefinedValueTypeI);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
// Fallback when the reference can't be resolved (missing
|
|
182
|
+
// `referencedDeclaration`, or its definition wasn't in the build).
|
|
183
|
+
// Emitting the name lets the downstream encoder produce a clear error
|
|
184
|
+
// rather than failing silently here.
|
|
185
|
+
if (typeof typeName.name === "string") {
|
|
186
|
+
return typeName.name;
|
|
187
|
+
}
|
|
188
|
+
if (isObject(typeName.pathNode) &&
|
|
189
|
+
typeof typeName.pathNode.name === "string") {
|
|
190
|
+
const segments = typeName.pathNode.name.split(".");
|
|
191
|
+
return segments[segments.length - 1];
|
|
192
|
+
}
|
|
193
|
+
return undefined;
|
|
194
|
+
}
|
|
195
|
+
case "ArrayTypeName": {
|
|
196
|
+
const base = encodeMemberType(typeName.baseType, userDefinedValueTypeI);
|
|
197
|
+
if (base === undefined) {
|
|
198
|
+
return undefined;
|
|
199
|
+
}
|
|
200
|
+
// solc omits `length` entirely for dynamic arrays; it isn't emitted as `null`.
|
|
201
|
+
const length = typeName.length;
|
|
202
|
+
if (length === null || length === undefined) {
|
|
203
|
+
return `${base}[]`;
|
|
204
|
+
}
|
|
205
|
+
// Always read from typeString: `Literal.value` preserves source text
|
|
206
|
+
// (`0x100`, `1_000`) but typeString canonicalizes to decimal.
|
|
207
|
+
const desc = isObject(typeName.typeDescriptions)
|
|
208
|
+
? typeName.typeDescriptions
|
|
209
|
+
: undefined;
|
|
210
|
+
const typeString = typeof desc?.typeString === "string" ? desc.typeString : "";
|
|
211
|
+
const match = /\[(\d+)\]$/.exec(typeString);
|
|
212
|
+
if (match !== null) {
|
|
213
|
+
return `${base}[${match[1]}]`;
|
|
214
|
+
}
|
|
215
|
+
return undefined;
|
|
216
|
+
}
|
|
217
|
+
case "Mapping":
|
|
218
|
+
return undefined;
|
|
219
|
+
case "FunctionTypeName":
|
|
220
|
+
// EIP-712 can't encode function types.
|
|
221
|
+
return undefined;
|
|
222
|
+
default:
|
|
223
|
+
return undefined;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
//# sourceMappingURL=ast-walker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast-walker.js","sourceRoot":"","sources":["../../../../../../src/internal/builtin-plugins/solidity-test/eip712/ast-walker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAkC/D;;;;;;;;GAQG;AACH,MAAM,UAAU,8BAA8B,CAC5C,IAAe;IAEf,MAAM,KAAK,GAA8B,IAAI,GAAG,EAAE,CAAC;IAEnD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;YACpD,SAAS;QACX,CAAC;QAED,MAAM,aAAa,GAAc,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3E,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;YACjC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;gBACpB,SAAS;YACX,CAAC;YAED,IAAI,IAAI,CAAC,QAAQ,KAAK,gCAAgC,EAAE,CAAC;gBACvD,0BAA0B,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YAC1C,CAAC;iBAAM,IAAI,IAAI,CAAC,QAAQ,KAAK,oBAAoB,EAAE,CAAC;gBAClD,MAAM,OAAO,GAAc,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;gBACvE,KAAK,M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AC/B,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBAC5C,OAAO,GAAG,IAAI,IAAI,CAAC;YACrB,CAAC;YAED,qEAAqE;YACrE,8DAA8D;YAC9D,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,gBAAgB,CAAC;gBAC9C,CAAC,CAAC,QAAQ,CAAC,gBAAgB;gBAC3B,CAAC,CAAC,SAAS,CAAC;YACd,MAAM,UAAU,GACd,OAAO,IAAI,EAAE,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;YAC9D,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAE5C,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBACnB,OAAO,GAAG,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;YAChC,CAAC;YAED,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,KAAK,SAAS;YACZ,OAAO,SAAS,CAAC;QAEnB,KAAK,kBAAkB;YACrB,uCAAuC;YACvC,OAAO,SAAS,CAAC;QAEnB;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { CollectedStruct } from "./ast-walker.js";
|
|
2
|
+
/**
|
|
3
|
+
* Produces the flat list of canonical EIP-712 type strings expected by EDR.
|
|
4
|
+
*
|
|
5
|
+
* Each encodable struct contributes one entry, built like this:
|
|
6
|
+
* 1. Start with the struct's own head: `Name(type1 name1,type2 name2,...)`.
|
|
7
|
+
* 2. If the struct has fields that reference other structs, append those
|
|
8
|
+
* structs' heads after it, sorted alphabetically.
|
|
9
|
+
*
|
|
10
|
+
* Examples:
|
|
11
|
+
* - `Person` has only primitive fields (address, string), so its entry is
|
|
12
|
+
* just its own head:
|
|
13
|
+
* `Person(address wallet,string name)`
|
|
14
|
+
* - `Mail` has a `Person` field, so its entry is its head plus `Person`'s
|
|
15
|
+
* head appended:
|
|
16
|
+
* `Mail(Person from,Person to,string contents)Person(address wallet,string name)`
|
|
17
|
+
*
|
|
18
|
+
* Structs that contain members whose type cannot be EIP-712 encoded (mappings,
|
|
19
|
+
* function types, etc.) are dropped entirely, along with any structs that
|
|
20
|
+
* depend on them transitively. This matches `forge bind-json`'s behavior:
|
|
21
|
+
* `resolve_struct_eip712` returns `None` for any struct containing unsupported
|
|
22
|
+
* constructs and propagates `None` through the dep graph so dependents are
|
|
23
|
+
* also dropped.
|
|
24
|
+
*
|
|
25
|
+
* Only names in `selectedNames` are emitted; non-selected structs still
|
|
26
|
+
* participate in dep resolution so cross-file deps inline correctly.
|
|
27
|
+
*/
|
|
28
|
+
export declare function canonicalizeStructs(structs: CollectedStruct[], selectedNames: Set<string>): string[];
|
|
29
|
+
//# sourceMappingURL=canonicalize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonicalize.d.ts","sourceRoot":"","sources":["../../../../../../src/internal/builtin-plugins/solidity-test/eip712/canonicalize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAIvD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,eAAe,EAAE,EAC1B,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,GACzB,MAAM,EAAE,CA6BV"}
|