hardhat 2.13.0-dev.1 → 2.13.0-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/builtin-tasks/compile.js +17 -7
- package/builtin-tasks/compile.js.map +1 -1
- package/builtin-tasks/flatten.js +10 -4
- package/builtin-tasks/flatten.js.map +1 -1
- package/builtin-tasks/help.js +2 -4
- package/builtin-tasks/help.js.map +1 -1
- package/builtin-tasks/task-names.d.ts +1 -0
- package/builtin-tasks/task-names.d.ts.map +1 -1
- package/builtin-tasks/task-names.js +3 -2
- package/builtin-tasks/task-names.js.map +1 -1
- package/builtin-tasks/test.js +22 -1
- package/builtin-tasks/test.js.map +1 -1
- package/internal/artifacts.d.ts +5 -0
- package/internal/artifacts.d.ts.map +1 -1
- package/internal/artifacts.js +29 -10
- package/internal/artifacts.js.map +1 -1
- package/internal/cli/bootstrap.d.ts +1 -0
- package/internal/cli/bootstrap.js +12 -20
- package/internal/cli/bootstrap.js.map +1 -1
- package/internal/cli/cli.d.ts +0 -1
- package/internal/cli/cli.d.ts.map +1 -1
- package/internal/cli/cli.js +24 -24
- package/internal/cli/cli.js.map +1 -1
- package/internal/cli/project-creation.d.ts +1 -1
- package/internal/cli/project-creation.d.ts.map +1 -1
- package/internal/cli/project-creation.js +105 -25
- package/internal/cli/project-creation.js.map +1 -1
- package/internal/cli/prompt.d.ts +2 -2
- package/internal/cli/prompt.d.ts.map +1 -1
- package/internal/cli/prompt.js +1 -2
- package/internal/cli/prompt.js.map +1 -1
- package/internal/cli/types.d.ts +1 -0
- package/internal/cli/types.d.ts.map +1 -1
- package/internal/core/config/config-env.d.ts +5 -11
- package/internal/core/config/config-env.d.ts.map +1 -1
- package/internal/core/config/config-env.js +2 -13
- package/internal/core/config/config-env.js.map +1 -1
- package/internal/core/config/config-loading.d.ts +2 -1
- package/internal/core/config/config-loading.d.ts.map +1 -1
- package/internal/core/config/config-loading.js +25 -7
- package/internal/core/config/config-loading.js.map +1 -1
- package/internal/core/config/config-resolution.d.ts.map +1 -1
- package/internal/core/config/config-resolution.js +2 -1
- package/internal/core/config/config-resolution.js.map +1 -1
- package/internal/core/config/config-validation.d.ts +2 -0
- package/internal/core/config/config-validation.d.ts.map +1 -1
- package/internal/core/config/config-validation.js +18 -1
- package/internal/core/config/config-validation.js.map +1 -1
- package/internal/core/config/extenders.d.ts +4 -7
- package/internal/core/config/extenders.d.ts.map +1 -1
- package/internal/core/config/extenders.js +5 -12
- package/internal/core/config/extenders.js.map +1 -1
- package/internal/core/errors-list.d.ts +35 -7
- package/internal/core/errors-list.d.ts.map +1 -1
- package/internal/core/errors-list.js +117 -85
- package/internal/core/errors-list.js.map +1 -1
- package/internal/core/flamegraph.js +10 -10
- package/internal/core/jsonrpc/types/output/metadata.d.ts +13 -0
- package/internal/core/jsonrpc/types/output/metadata.d.ts.map +1 -0
- package/internal/core/jsonrpc/types/output/metadata.js +3 -0
- package/internal/core/jsonrpc/types/output/metadata.js.map +1 -0
- package/internal/core/project-structure.d.ts.map +1 -1
- package/internal/core/project-structure.js +6 -0
- package/internal/core/project-structure.js.map +1 -1
- package/internal/core/providers/accounts.d.ts.map +1 -1
- package/internal/core/providers/accounts.js +4 -1
- package/internal/core/providers/accounts.js.map +1 -1
- package/internal/core/providers/backwards-compatibility.d.ts.map +1 -1
- package/internal/core/providers/backwards-compatibility.js +3 -0
- package/internal/core/providers/backwards-compatibility.js.map +1 -1
- package/internal/core/providers/construction.d.ts.map +1 -1
- package/internal/core/providers/construction.js +25 -5
- package/internal/core/providers/construction.js.map +1 -1
- package/internal/core/providers/gas-providers.d.ts +1 -1
- package/internal/core/providers/gas-providers.d.ts.map +1 -1
- package/internal/core/providers/gas-providers.js +1 -1
- package/internal/core/providers/gas-providers.js.map +1 -1
- package/internal/core/providers/http.d.ts +2 -2
- package/internal/core/providers/http.d.ts.map +1 -1
- package/internal/core/providers/http.js +41 -19
- package/internal/core/providers/http.js.map +1 -1
- package/internal/core/runtime-environment.d.ts +4 -2
- package/internal/core/runtime-environment.d.ts.map +1 -1
- package/internal/core/runtime-environment.js +39 -47
- package/internal/core/runtime-environment.js.map +1 -1
- package/internal/core/tasks/dsl.d.ts +6 -6
- package/internal/core/tasks/dsl.d.ts.map +1 -1
- package/internal/core/tasks/dsl.js.map +1 -1
- package/internal/core/tasks/task-definitions.d.ts +2 -2
- package/internal/core/tasks/task-definitions.d.ts.map +1 -1
- package/internal/core/tasks/task-definitions.js.map +1 -1
- package/internal/hardhat-network/jsonrpc/client.d.ts.map +1 -1
- package/internal/hardhat-network/jsonrpc/client.js +5 -3
- package/internal/hardhat-network/jsonrpc/client.js.map +1 -1
- package/internal/hardhat-network/jsonrpc/handler.d.ts +1 -0
- package/internal/hardhat-network/jsonrpc/handler.d.ts.map +1 -1
- package/internal/hardhat-network/jsonrpc/handler.js +13 -18
- package/internal/hardhat-network/jsonrpc/handler.js.map +1 -1
- package/internal/hardhat-network/provider/RethnetState.d.ts +26 -0
- package/internal/hardhat-network/provider/RethnetState.d.ts.map +1 -0
- package/internal/hardhat-network/provider/RethnetState.js +84 -0
- package/internal/hardhat-network/provider/RethnetState.js.map +1 -0
- package/internal/hardhat-network/provider/modules/eth.js +4 -4
- package/internal/hardhat-network/provider/modules/evm.d.ts +2 -1
- package/internal/hardhat-network/provider/modules/evm.d.ts.map +1 -1
- package/internal/hardhat-network/provider/modules/evm.js +10 -4
- package/internal/hardhat-network/provider/modules/evm.js.map +1 -1
- package/internal/hardhat-network/provider/modules/hardhat.d.ts +2 -0
- package/internal/hardhat-network/provider/modules/hardhat.d.ts.map +1 -1
- package/internal/hardhat-network/provider/modules/hardhat.js +9 -0
- package/internal/hardhat-network/provider/modules/hardhat.js.map +1 -1
- package/internal/hardhat-network/provider/modules/web3.d.ts +3 -0
- package/internal/hardhat-network/provider/modules/web3.d.ts.map +1 -1
- package/internal/hardhat-network/provider/modules/web3.js +4 -4
- package/internal/hardhat-network/provider/modules/web3.js.map +1 -1
- package/internal/hardhat-network/provider/node-types.d.ts +1 -1
- package/internal/hardhat-network/provider/node-types.d.ts.map +1 -1
- package/internal/hardhat-network/provider/node.d.ts +6 -0
- package/internal/hardhat-network/provider/node.d.ts.map +1 -1
- package/internal/hardhat-network/provider/node.js +44 -5
- package/internal/hardhat-network/provider/node.js.map +1 -1
- package/internal/hardhat-network/provider/output.d.ts +1 -1
- package/internal/hardhat-network/provider/output.d.ts.map +1 -1
- package/internal/hardhat-network/provider/output.js +1 -1
- package/internal/hardhat-network/provider/output.js.map +1 -1
- package/internal/hardhat-network/provider/provider.d.ts +25 -21
- package/internal/hardhat-network/provider/provider.d.ts.map +1 -1
- package/internal/hardhat-network/provider/provider.js +26 -43
- package/internal/hardhat-network/provider/provider.js.map +1 -1
- package/internal/hardhat-network/provider/return-data.js +2 -2
- package/internal/hardhat-network/provider/return-data.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.js +4 -2
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.js +4 -2
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.js +4 -2
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.js.map +1 -1
- package/internal/hardhat-network/provider/utils/bloom.d.ts +4 -0
- package/internal/hardhat-network/provider/utils/bloom.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/bloom.js +6 -0
- package/internal/hardhat-network/provider/utils/bloom.js.map +1 -1
- package/internal/hardhat-network/provider/utils/convertToRethnet.d.ts +8 -25
- package/internal/hardhat-network/provider/utils/convertToRethnet.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/convertToRethnet.js +122 -174
- package/internal/hardhat-network/provider/utils/convertToRethnet.js.map +1 -1
- package/internal/hardhat-network/provider/utils/makeFakeSignature.d.ts +7 -0
- package/internal/hardhat-network/provider/utils/makeFakeSignature.d.ts.map +1 -0
- package/internal/hardhat-network/provider/utils/makeFakeSignature.js +31 -0
- package/internal/hardhat-network/provider/utils/makeFakeSignature.js.map +1 -0
- package/internal/hardhat-network/provider/utils/makeForkClient.d.ts +1 -0
- package/internal/hardhat-network/provider/utils/makeForkClient.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/makeForkClient.js +4 -1
- package/internal/hardhat-network/provider/utils/makeForkClient.js.map +1 -1
- package/internal/hardhat-network/provider/utils/putGenesisBlock.d.ts +1 -1
- package/internal/hardhat-network/provider/utils/putGenesisBlock.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/putGenesisBlock.js +2 -2
- package/internal/hardhat-network/provider/utils/putGenesisBlock.js.map +1 -1
- package/internal/hardhat-network/provider/vm/block-builder.d.ts +4 -3
- package/internal/hardhat-network/provider/vm/block-builder.d.ts.map +1 -1
- package/internal/hardhat-network/provider/vm/block-builder.js +9 -5
- package/internal/hardhat-network/provider/vm/block-builder.js.map +1 -1
- package/internal/hardhat-network/provider/vm/creation.d.ts +10 -0
- package/internal/hardhat-network/provider/vm/creation.d.ts.map +1 -0
- package/internal/hardhat-network/provider/vm/creation.js +29 -0
- package/internal/hardhat-network/provider/vm/creation.js.map +1 -0
- package/internal/hardhat-network/provider/vm/dual.d.ts +14 -14
- package/internal/hardhat-network/provider/vm/dual.d.ts.map +1 -1
- package/internal/hardhat-network/provider/vm/dual.js +426 -58
- package/internal/hardhat-network/provider/vm/dual.js.map +1 -1
- package/internal/hardhat-network/provider/vm/ethereumjs.d.ts +23 -22
- package/internal/hardhat-network/provider/vm/ethereumjs.d.ts.map +1 -1
- package/internal/hardhat-network/provider/vm/ethereumjs.js +181 -37
- package/internal/hardhat-network/provider/vm/ethereumjs.js.map +1 -1
- package/internal/hardhat-network/provider/vm/exit.d.ts +23 -0
- package/internal/hardhat-network/provider/vm/exit.d.ts.map +1 -0
- package/internal/hardhat-network/provider/vm/exit.js +130 -0
- package/internal/hardhat-network/provider/vm/exit.js.map +1 -0
- package/internal/hardhat-network/provider/vm/rethnet.d.ts +18 -30
- package/internal/hardhat-network/provider/vm/rethnet.d.ts.map +1 -1
- package/internal/hardhat-network/provider/vm/rethnet.js +164 -51
- package/internal/hardhat-network/provider/vm/rethnet.js.map +1 -1
- package/internal/hardhat-network/provider/vm/vm-adapter.d.ts +29 -13
- package/internal/hardhat-network/provider/vm/vm-adapter.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/compiler-to-model.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/compiler-to-model.js +37 -11
- package/internal/hardhat-network/stack-traces/compiler-to-model.js.map +1 -1
- package/internal/hardhat-network/stack-traces/consoleLogger.js.map +1 -1
- package/internal/hardhat-network/stack-traces/constants.d.ts +1 -1
- package/internal/hardhat-network/stack-traces/constants.js +1 -1
- package/internal/hardhat-network/stack-traces/debug.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/debug.js +6 -2
- package/internal/hardhat-network/stack-traces/debug.js.map +1 -1
- package/internal/hardhat-network/stack-traces/error-inferrer.d.ts +1 -0
- package/internal/hardhat-network/stack-traces/error-inferrer.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/error-inferrer.js +87 -60
- package/internal/hardhat-network/stack-traces/error-inferrer.js.map +1 -1
- package/internal/hardhat-network/stack-traces/model.d.ts +3 -1
- package/internal/hardhat-network/stack-traces/model.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/model.js +9 -1
- package/internal/hardhat-network/stack-traces/model.js.map +1 -1
- package/internal/hardhat-network/stack-traces/solidity-errors.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/solidity-errors.js +4 -3
- package/internal/hardhat-network/stack-traces/solidity-errors.js.map +1 -1
- package/internal/hardhat-network/stack-traces/solidity-stack-trace.d.ts +2 -2
- package/internal/hardhat-network/stack-traces/solidity-stack-trace.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/solidityTracer.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/solidityTracer.js +1 -0
- package/internal/hardhat-network/stack-traces/solidityTracer.js.map +1 -1
- package/internal/hardhat-network/stack-traces/vm-debug-tracer.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/vm-debug-tracer.js +2 -1
- package/internal/hardhat-network/stack-traces/vm-debug-tracer.js.map +1 -1
- package/internal/lib/hardhat-lib.d.ts.map +1 -1
- package/internal/lib/hardhat-lib.js +1 -4
- package/internal/lib/hardhat-lib.js.map +1 -1
- package/internal/solidity/compiler/downloader.js +2 -2
- package/internal/solidity/compiler/downloader.js.map +1 -1
- package/internal/solidity/compiler/index.d.ts.map +1 -1
- package/internal/solidity/compiler/index.js +7 -1
- package/internal/solidity/compiler/index.js.map +1 -1
- package/internal/solidity/dependencyGraph.d.ts.map +1 -1
- package/internal/solidity/dependencyGraph.js +2 -0
- package/internal/solidity/dependencyGraph.js.map +1 -1
- package/internal/solidity/resolver.d.ts +4 -3
- package/internal/solidity/resolver.d.ts.map +1 -1
- package/internal/solidity/resolver.js +26 -7
- package/internal/solidity/resolver.js.map +1 -1
- package/internal/util/abi-helpers.d.ts +1 -0
- package/internal/util/abi-helpers.d.ts.map +1 -1
- package/internal/util/abi-helpers.js +9 -0
- package/internal/util/abi-helpers.js.map +1 -1
- package/internal/util/console.d.ts.map +1 -1
- package/internal/util/console.js +1 -1
- package/internal/util/console.js.map +1 -1
- package/internal/util/download.d.ts +3 -1
- package/internal/util/download.d.ts.map +1 -1
- package/internal/util/download.js +14 -12
- package/internal/util/download.js.map +1 -1
- package/internal/util/keys-derivation.d.ts.map +1 -1
- package/internal/util/keys-derivation.js +4 -1
- package/internal/util/keys-derivation.js.map +1 -1
- package/internal/util/packageInfo.d.ts +7 -1
- package/internal/util/packageInfo.d.ts.map +1 -1
- package/internal/util/packageInfo.js +23 -11
- package/internal/util/packageInfo.js.map +1 -1
- package/internal/util/proxy.d.ts +2 -0
- package/internal/util/proxy.d.ts.map +1 -0
- package/internal/util/proxy.js +19 -0
- package/internal/util/proxy.js.map +1 -0
- package/package.json +9 -10
- package/recommended-gitignore.txt +1 -1
- package/register.js +1 -4
- package/register.js.map +1 -1
- package/sample-projects/javascript/hardhat.config.js +1 -1
- package/sample-projects/javascript/scripts/deploy.js +2 -2
- package/sample-projects/javascript-esm/LICENSE.md +11 -0
- package/sample-projects/javascript-esm/README.md +13 -0
- package/sample-projects/javascript-esm/contracts/Lock.sol +34 -0
- package/sample-projects/javascript-esm/hardhat.config.cjs +6 -0
- package/sample-projects/javascript-esm/scripts/deploy.js +22 -0
- package/sample-projects/javascript-esm/test/Lock.js +123 -0
- package/sample-projects/typescript/hardhat.config.ts +1 -1
- package/sample-projects/typescript/scripts/deploy.ts +2 -2
- package/sample-projects/typescript/tsconfig.json +2 -1
- package/src/builtin-tasks/compile.ts +30 -11
- package/src/builtin-tasks/flatten.ts +18 -4
- package/src/builtin-tasks/help.ts +15 -16
- package/src/builtin-tasks/task-names.ts +2 -0
- package/src/builtin-tasks/test.ts +30 -2
- package/src/internal/artifacts.ts +947 -0
- package/src/internal/cli/bootstrap.ts +14 -36
- package/src/internal/cli/cli.ts +44 -35
- package/src/internal/cli/project-creation.ts +129 -32
- package/src/internal/cli/prompt.ts +2 -4
- package/src/internal/cli/types.ts +2 -0
- package/src/internal/core/config/config-env.ts +15 -27
- package/src/internal/core/config/config-loading.ts +35 -11
- package/src/internal/core/config/config-resolution.ts +4 -3
- package/src/internal/core/config/config-validation.ts +20 -0
- package/src/internal/core/config/extenders.ts +6 -15
- package/src/internal/core/errors-list.ts +121 -85
- package/src/internal/core/flamegraph.ts +10 -10
- package/src/internal/core/jsonrpc/types/output/metadata.ts +32 -0
- package/src/internal/core/project-structure.ts +8 -0
- package/src/internal/core/providers/accounts.ts +5 -2
- package/src/internal/core/providers/backwards-compatibility.ts +3 -0
- package/src/internal/core/providers/construction.ts +29 -24
- package/src/internal/core/providers/gas-providers.ts +1 -1
- package/src/internal/core/providers/http.ts +38 -26
- package/src/internal/core/runtime-environment.ts +65 -60
- package/src/internal/core/tasks/dsl.ts +17 -17
- package/src/internal/core/tasks/task-definitions.ts +6 -2
- package/src/internal/hardhat-network/jsonrpc/client.ts +7 -4
- package/src/internal/hardhat-network/jsonrpc/handler.ts +31 -28
- package/src/internal/hardhat-network/provider/modules/eth.ts +4 -4
- package/src/internal/hardhat-network/provider/modules/evm.ts +15 -3
- package/src/internal/hardhat-network/provider/modules/hardhat.ts +14 -0
- package/src/internal/hardhat-network/provider/modules/web3.ts +4 -4
- package/src/internal/hardhat-network/provider/node-types.ts +1 -1
- package/src/internal/hardhat-network/provider/node.ts +63 -1
- package/src/internal/hardhat-network/provider/output.ts +2 -2
- package/src/internal/hardhat-network/provider/provider.ts +61 -50
- package/src/internal/hardhat-network/provider/return-data.ts +2 -2
- package/src/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.ts +5 -2
- package/src/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.ts +5 -2
- package/src/internal/hardhat-network/provider/transactions/FakeSenderTransaction.ts +5 -2
- package/src/internal/hardhat-network/provider/utils/makeFakeSignature.ts +46 -0
- package/src/internal/hardhat-network/provider/utils/makeForkClient.ts +10 -1
- package/src/internal/hardhat-network/provider/utils/putGenesisBlock.ts +2 -2
- package/src/internal/hardhat-network/stack-traces/compiler-to-model.ts +73 -11
- package/src/internal/hardhat-network/stack-traces/consoleLogger.ts +1 -1
- package/src/internal/hardhat-network/stack-traces/constants.ts +1 -1
- package/src/internal/hardhat-network/stack-traces/debug.ts +9 -2
- package/src/internal/hardhat-network/stack-traces/error-inferrer.ts +179 -95
- package/src/internal/hardhat-network/stack-traces/model.ts +11 -1
- package/src/internal/hardhat-network/stack-traces/solidity-errors.ts +5 -3
- package/src/internal/hardhat-network/stack-traces/solidity-stack-trace.ts +2 -2
- package/src/internal/hardhat-network/stack-traces/solidityTracer.ts +3 -0
- package/src/internal/hardhat-network/stack-traces/vm-debug-tracer.ts +4 -1
- package/src/internal/lib/hardhat-lib.ts +1 -6
- package/src/internal/solidity/compiler/downloader.ts +3 -3
- package/src/internal/solidity/compiler/index.ts +9 -1
- package/src/internal/solidity/dependencyGraph.ts +2 -0
- package/src/internal/solidity/resolver.ts +38 -11
- package/src/internal/util/abi-helpers.ts +9 -0
- package/src/internal/util/console.ts +4 -2
- package/src/internal/util/download.ts +16 -16
- package/src/internal/util/keys-derivation.ts +4 -1
- package/src/internal/util/packageInfo.ts +33 -10
- package/src/internal/util/proxy.ts +18 -0
- package/src/register.ts +1 -6
- package/src/types/artifacts.ts +19 -105
- package/src/types/config.ts +2 -0
- package/src/types/runtime.ts +16 -13
- package/src/utils/source-names.ts +15 -0
- package/types/artifacts.d.ts +14 -90
- package/types/artifacts.d.ts.map +1 -1
- package/types/config.d.ts +2 -0
- package/types/config.d.ts.map +1 -1
- package/types/runtime.d.ts +9 -10
- package/types/runtime.d.ts.map +1 -1
- package/utils/source-names.d.ts +5 -0
- package/utils/source-names.d.ts.map +1 -1
- package/utils/source-names.js +14 -1
- package/utils/source-names.js.map +1 -1
- package/internal/artifacts/caching.d.ts +0 -27
- package/internal/artifacts/caching.d.ts.map +0 -1
- package/internal/artifacts/caching.js +0 -167
- package/internal/artifacts/caching.js.map +0 -1
- package/internal/artifacts/index.d.ts +0 -44
- package/internal/artifacts/index.d.ts.map +0 -1
- package/internal/artifacts/index.js +0 -187
- package/internal/artifacts/index.js.map +0 -1
- package/internal/artifacts/mutable.d.ts +0 -29
- package/internal/artifacts/mutable.d.ts.map +0 -1
- package/internal/artifacts/mutable.js +0 -226
- package/internal/artifacts/mutable.js.map +0 -1
- package/internal/artifacts/readonly.d.ts +0 -88
- package/internal/artifacts/readonly.d.ts.map +0 -1
- package/internal/artifacts/readonly.js +0 -324
- package/internal/artifacts/readonly.js.map +0 -1
- package/src/internal/artifacts/caching.ts +0 -239
- package/src/internal/artifacts/index.ts +0 -296
- package/src/internal/artifacts/mutable.ts +0 -330
- package/src/internal/artifacts/readonly.ts +0 -438
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
/* eslint "@typescript-eslint/no-non-null-assertion": "error" */
|
|
1
2
|
import { ERROR } from "@nomicfoundation/ethereumjs-evm/dist/exceptions";
|
|
2
3
|
import { defaultAbiCoder as abi } from "@ethersproject/abi";
|
|
3
4
|
import semver from "semver";
|
|
4
5
|
|
|
6
|
+
import { assertHardhatInvariant } from "../../core/errors";
|
|
5
7
|
import { AbiHelpers } from "../../util/abi-helpers";
|
|
6
8
|
import { ReturnData } from "../provider/return-data";
|
|
7
9
|
|
|
@@ -69,13 +71,16 @@ export class ErrorInferrer {
|
|
|
69
71
|
trace.calldata.slice(0, 4)
|
|
70
72
|
);
|
|
71
73
|
|
|
72
|
-
if (
|
|
74
|
+
if (
|
|
75
|
+
calledFunction !== undefined &&
|
|
76
|
+
this._isFunctionNotPayableError(trace, calledFunction)
|
|
77
|
+
) {
|
|
73
78
|
return [
|
|
74
79
|
{
|
|
75
80
|
type: StackTraceEntryType.FUNCTION_NOT_PAYABLE_ERROR,
|
|
76
81
|
sourceReference: this._getFunctionStartSourceReference(
|
|
77
82
|
trace,
|
|
78
|
-
calledFunction
|
|
83
|
+
calledFunction
|
|
79
84
|
),
|
|
80
85
|
value: trace.value,
|
|
81
86
|
},
|
|
@@ -197,8 +202,9 @@ export class ErrorInferrer {
|
|
|
197
202
|
stacktrace[i + 2].type === StackTraceEntryType.RETURNDATA_SIZE_ERROR
|
|
198
203
|
) {
|
|
199
204
|
// ! below for tsc. we confirmed existence in the enclosing conditional.
|
|
200
|
-
const thatSrcRef = stacktrace[i + 2].sourceReference
|
|
205
|
+
const thatSrcRef = stacktrace[i + 2].sourceReference;
|
|
201
206
|
if (
|
|
207
|
+
thatSrcRef !== undefined &&
|
|
202
208
|
frame.sourceReference.range[0] === thatSrcRef.range[0] &&
|
|
203
209
|
frame.sourceReference.range[1] === thatSrcRef.range[1] &&
|
|
204
210
|
frame.sourceReference.line === thatSrcRef.line
|
|
@@ -286,7 +292,11 @@ export class ErrorInferrer {
|
|
|
286
292
|
lastSubmessageData.stepIndex
|
|
287
293
|
)
|
|
288
294
|
) {
|
|
289
|
-
const lastFrame = inferredStacktrace.pop()
|
|
295
|
+
const lastFrame = inferredStacktrace.pop();
|
|
296
|
+
assertHardhatInvariant(
|
|
297
|
+
lastFrame !== undefined,
|
|
298
|
+
"Expected inferred stack trace to have at least one frame"
|
|
299
|
+
);
|
|
290
300
|
inferredStacktrace.push({
|
|
291
301
|
type: StackTraceEntryType.CONTRACT_CALL_RUN_OUT_OF_GAS_ERROR,
|
|
292
302
|
sourceReference: lastFrame.sourceReference,
|
|
@@ -421,13 +431,23 @@ export class ErrorInferrer {
|
|
|
421
431
|
);
|
|
422
432
|
} else if (isDecodedCallTrace(trace)) {
|
|
423
433
|
// This is here because of the optimizations
|
|
434
|
+
const functionSelector =
|
|
435
|
+
trace.bytecode.contract.getFunctionFromSelector(
|
|
436
|
+
trace.calldata.slice(0, 4)
|
|
437
|
+
);
|
|
438
|
+
|
|
439
|
+
// in general this shouldn't happen, but it does when viaIR is enabled,
|
|
440
|
+
// "optimizerSteps": "u" is used, and the called function is fallback or
|
|
441
|
+
// receive
|
|
442
|
+
if (functionSelector === undefined) {
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
|
|
424
446
|
inferredStacktrace.push({
|
|
425
447
|
type: StackTraceEntryType.REVERT_ERROR,
|
|
426
448
|
sourceReference: this._getFunctionStartSourceReference(
|
|
427
449
|
trace,
|
|
428
|
-
|
|
429
|
-
trace.calldata.slice(0, 4)
|
|
430
|
-
)!
|
|
450
|
+
functionSelector
|
|
431
451
|
),
|
|
432
452
|
message: new ReturnData(trace.returnData),
|
|
433
453
|
isInvalidOpcodeError: lastInstruction.opcode === Opcode.INVALID,
|
|
@@ -519,12 +539,8 @@ export class ErrorInferrer {
|
|
|
519
539
|
return;
|
|
520
540
|
}
|
|
521
541
|
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
const selector = returnData.getSelector();
|
|
525
|
-
if (selector !== undefined) {
|
|
526
|
-
errorMessage += ` with selector ${selector}`;
|
|
527
|
-
}
|
|
542
|
+
const rawReturnData = returnData.value.toString("hex");
|
|
543
|
+
let errorMessage = `reverted with an unrecognized custom error (return data: 0x${rawReturnData})`;
|
|
528
544
|
|
|
529
545
|
for (const customError of trace.bytecode.contract.customErrors) {
|
|
530
546
|
if (returnData.matchesSelector(customError.selector)) {
|
|
@@ -621,15 +637,21 @@ export class ErrorInferrer {
|
|
|
621
637
|
);
|
|
622
638
|
|
|
623
639
|
if (calledFunction !== undefined) {
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
640
|
+
const isValidCalldata = calledFunction.isValidCalldata(
|
|
641
|
+
trace.calldata.slice(4)
|
|
642
|
+
);
|
|
643
|
+
|
|
644
|
+
if (!isValidCalldata) {
|
|
645
|
+
return [
|
|
646
|
+
{
|
|
647
|
+
type: StackTraceEntryType.INVALID_PARAMS_ERROR,
|
|
648
|
+
sourceReference: this._getFunctionStartSourceReference(
|
|
649
|
+
trace,
|
|
650
|
+
calledFunction
|
|
651
|
+
),
|
|
652
|
+
},
|
|
653
|
+
];
|
|
654
|
+
}
|
|
633
655
|
}
|
|
634
656
|
|
|
635
657
|
if (this._solidity063MaybeUnmappedRevert(trace)) {
|
|
@@ -650,10 +672,17 @@ export class ErrorInferrer {
|
|
|
650
672
|
stacktrace: SolidityStackTrace
|
|
651
673
|
): SolidityStackTrace | undefined {
|
|
652
674
|
if (this._isCalledNonContractAccountError(trace)) {
|
|
675
|
+
const sourceReference = this._getLastSourceReference(trace);
|
|
676
|
+
|
|
677
|
+
// We are sure this is not undefined because there was at least a call instruction
|
|
678
|
+
assertHardhatInvariant(
|
|
679
|
+
sourceReference !== undefined,
|
|
680
|
+
"Expected source reference to be defined"
|
|
681
|
+
);
|
|
682
|
+
|
|
653
683
|
const nonContractCalledFrame: SolidityStackTraceEntry = {
|
|
654
684
|
type: StackTraceEntryType.NONCONTRACT_ACCOUNT_CALLED_ERROR,
|
|
655
|
-
|
|
656
|
-
sourceReference: this._getLastSourceReference(trace)!,
|
|
685
|
+
sourceReference,
|
|
657
686
|
};
|
|
658
687
|
|
|
659
688
|
return [...stacktrace, nonContractCalledFrame];
|
|
@@ -753,12 +782,8 @@ export class ErrorInferrer {
|
|
|
753
782
|
|
|
754
783
|
private _isFunctionNotPayableError(
|
|
755
784
|
trace: DecodedCallMessageTrace,
|
|
756
|
-
calledFunction: ContractFunction
|
|
785
|
+
calledFunction: ContractFunction
|
|
757
786
|
): boolean {
|
|
758
|
-
if (calledFunction === undefined) {
|
|
759
|
-
return false;
|
|
760
|
-
}
|
|
761
|
-
|
|
762
787
|
// This error doesn't return data
|
|
763
788
|
if (trace.returnData.length > 0) {
|
|
764
789
|
return false;
|
|
@@ -1061,7 +1086,14 @@ export class ErrorInferrer {
|
|
|
1061
1086
|
continue;
|
|
1062
1087
|
}
|
|
1063
1088
|
|
|
1064
|
-
|
|
1089
|
+
const sourceReference = sourceLocationToSourceReference(
|
|
1090
|
+
trace.bytecode,
|
|
1091
|
+
inst.location
|
|
1092
|
+
);
|
|
1093
|
+
|
|
1094
|
+
if (sourceReference !== undefined) {
|
|
1095
|
+
return sourceReference;
|
|
1096
|
+
}
|
|
1065
1097
|
}
|
|
1066
1098
|
|
|
1067
1099
|
return undefined;
|
|
@@ -1109,27 +1141,49 @@ export class ErrorInferrer {
|
|
|
1109
1141
|
trace: DecodedEvmMessageTrace,
|
|
1110
1142
|
inst: Instruction
|
|
1111
1143
|
): RevertErrorStackTraceEntry {
|
|
1144
|
+
const sourceReference = sourceLocationToSourceReference(
|
|
1145
|
+
trace.bytecode,
|
|
1146
|
+
inst.location
|
|
1147
|
+
);
|
|
1148
|
+
assertHardhatInvariant(
|
|
1149
|
+
sourceReference !== undefined,
|
|
1150
|
+
"Expected source reference to be defined"
|
|
1151
|
+
);
|
|
1152
|
+
|
|
1112
1153
|
return {
|
|
1113
1154
|
type: StackTraceEntryType.REVERT_ERROR,
|
|
1114
|
-
sourceReference
|
|
1115
|
-
trace.bytecode,
|
|
1116
|
-
inst.location
|
|
1117
|
-
)!,
|
|
1155
|
+
sourceReference,
|
|
1118
1156
|
message: new ReturnData(trace.returnData),
|
|
1119
1157
|
isInvalidOpcodeError: inst.opcode === Opcode.INVALID,
|
|
1120
1158
|
};
|
|
1121
1159
|
}
|
|
1122
1160
|
|
|
1161
|
+
private _instructionWithinFunctionToUnmappedSolc063RevertErrorStackTraceEntry(
|
|
1162
|
+
trace: DecodedEvmMessageTrace,
|
|
1163
|
+
inst: Instruction
|
|
1164
|
+
): UnmappedSolc063RevertErrorStackTraceEntry {
|
|
1165
|
+
const sourceReference = sourceLocationToSourceReference(
|
|
1166
|
+
trace.bytecode,
|
|
1167
|
+
inst.location
|
|
1168
|
+
);
|
|
1169
|
+
|
|
1170
|
+
return {
|
|
1171
|
+
type: StackTraceEntryType.UNMAPPED_SOLC_0_6_3_REVERT_ERROR,
|
|
1172
|
+
sourceReference,
|
|
1173
|
+
};
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1123
1176
|
private _instructionWithinFunctionToPanicStackTraceEntry(
|
|
1124
1177
|
trace: DecodedEvmMessageTrace,
|
|
1125
1178
|
inst: Instruction,
|
|
1126
1179
|
errorCode: bigint
|
|
1127
1180
|
): PanicErrorStackTraceEntry {
|
|
1181
|
+
const lastSourceReference = this._getLastSourceReference(trace);
|
|
1128
1182
|
return {
|
|
1129
1183
|
type: StackTraceEntryType.PANIC_ERROR,
|
|
1130
1184
|
sourceReference:
|
|
1131
1185
|
sourceLocationToSourceReference(trace.bytecode, inst.location) ??
|
|
1132
|
-
|
|
1186
|
+
lastSourceReference,
|
|
1133
1187
|
errorCode,
|
|
1134
1188
|
};
|
|
1135
1189
|
}
|
|
@@ -1139,11 +1193,18 @@ export class ErrorInferrer {
|
|
|
1139
1193
|
inst: Instruction,
|
|
1140
1194
|
message: string
|
|
1141
1195
|
): CustomErrorStackTraceEntry {
|
|
1196
|
+
const lastSourceReference = this._getLastSourceReference(trace);
|
|
1197
|
+
|
|
1198
|
+
assertHardhatInvariant(
|
|
1199
|
+
lastSourceReference !== undefined,
|
|
1200
|
+
"Expected last source reference to be defined"
|
|
1201
|
+
);
|
|
1202
|
+
|
|
1142
1203
|
return {
|
|
1143
1204
|
type: StackTraceEntryType.CUSTOM_ERROR,
|
|
1144
1205
|
sourceReference:
|
|
1145
1206
|
sourceLocationToSourceReference(trace.bytecode, inst.location) ??
|
|
1146
|
-
|
|
1207
|
+
lastSourceReference,
|
|
1147
1208
|
message,
|
|
1148
1209
|
};
|
|
1149
1210
|
}
|
|
@@ -1255,16 +1316,16 @@ export class ErrorInferrer {
|
|
|
1255
1316
|
): UnmappedSolc063RevertErrorStackTraceEntry | undefined {
|
|
1256
1317
|
// If we are within a function there's a last valid location. It may
|
|
1257
1318
|
// be the entire contract.
|
|
1258
|
-
const prevInst = this._getLastInstructionWithValidLocation(trace)
|
|
1319
|
+
const prevInst = this._getLastInstructionWithValidLocation(trace);
|
|
1259
1320
|
const lastStep = trace.steps[trace.steps.length - 1] as EvmStep;
|
|
1260
1321
|
const nextInstPc = lastStep.pc + 1;
|
|
1261
1322
|
const hasNextInst = trace.bytecode.hasInstruction(nextInstPc);
|
|
1262
1323
|
|
|
1263
1324
|
if (hasNextInst) {
|
|
1264
1325
|
const nextInst = trace.bytecode.getInstruction(nextInstPc);
|
|
1265
|
-
const prevLoc = prevInst
|
|
1326
|
+
const prevLoc = prevInst?.location;
|
|
1266
1327
|
const nextLoc = nextInst.location;
|
|
1267
|
-
const prevFunc = prevLoc
|
|
1328
|
+
const prevFunc = prevLoc?.getContainingFunction();
|
|
1268
1329
|
const nextFunc = nextLoc?.getContainingFunction();
|
|
1269
1330
|
|
|
1270
1331
|
// This is probably a require. This means that we have the exact
|
|
@@ -1274,37 +1335,31 @@ export class ErrorInferrer {
|
|
|
1274
1335
|
if (
|
|
1275
1336
|
prevFunc !== undefined &&
|
|
1276
1337
|
nextLoc !== undefined &&
|
|
1338
|
+
prevLoc !== undefined &&
|
|
1277
1339
|
prevLoc.equals(nextLoc)
|
|
1278
1340
|
) {
|
|
1279
|
-
return
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
),
|
|
1284
|
-
type: StackTraceEntryType.UNMAPPED_SOLC_0_6_3_REVERT_ERROR,
|
|
1285
|
-
};
|
|
1341
|
+
return this._instructionWithinFunctionToUnmappedSolc063RevertErrorStackTraceEntry(
|
|
1342
|
+
trace,
|
|
1343
|
+
nextInst
|
|
1344
|
+
);
|
|
1286
1345
|
}
|
|
1287
1346
|
|
|
1288
1347
|
let revertFrame: UnmappedSolc063RevertErrorStackTraceEntry | undefined;
|
|
1289
1348
|
|
|
1290
1349
|
// If the previous and next location don't match, we try to use the
|
|
1291
1350
|
// previous one if it's inside a function, otherwise we use the next one
|
|
1292
|
-
if (prevFunc !== undefined) {
|
|
1293
|
-
revertFrame =
|
|
1294
|
-
|
|
1351
|
+
if (prevFunc !== undefined && prevInst !== undefined) {
|
|
1352
|
+
revertFrame =
|
|
1353
|
+
this._instructionWithinFunctionToUnmappedSolc063RevertErrorStackTraceEntry(
|
|
1295
1354
|
trace,
|
|
1296
1355
|
prevInst
|
|
1297
|
-
)
|
|
1298
|
-
type: StackTraceEntryType.UNMAPPED_SOLC_0_6_3_REVERT_ERROR,
|
|
1299
|
-
};
|
|
1356
|
+
);
|
|
1300
1357
|
} else if (nextFunc !== undefined) {
|
|
1301
|
-
revertFrame =
|
|
1302
|
-
|
|
1358
|
+
revertFrame =
|
|
1359
|
+
this._instructionWithinFunctionToUnmappedSolc063RevertErrorStackTraceEntry(
|
|
1303
1360
|
trace,
|
|
1304
1361
|
nextInst
|
|
1305
|
-
)
|
|
1306
|
-
type: StackTraceEntryType.UNMAPPED_SOLC_0_6_3_REVERT_ERROR,
|
|
1307
|
-
};
|
|
1362
|
+
);
|
|
1308
1363
|
}
|
|
1309
1364
|
|
|
1310
1365
|
if (revertFrame !== undefined) {
|
|
@@ -1314,18 +1369,15 @@ export class ErrorInferrer {
|
|
|
1314
1369
|
return revertFrame;
|
|
1315
1370
|
}
|
|
1316
1371
|
|
|
1317
|
-
if (isCreateTrace(trace)) {
|
|
1372
|
+
if (isCreateTrace(trace) && prevInst !== undefined) {
|
|
1318
1373
|
// Solidity is smart enough to stop emitting extra instructions after
|
|
1319
1374
|
// an unconditional revert happens in a constructor. If this is the case
|
|
1320
1375
|
// we just return a special error.
|
|
1321
1376
|
const constructorRevertFrame: UnmappedSolc063RevertErrorStackTraceEntry =
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
),
|
|
1327
|
-
type: StackTraceEntryType.UNMAPPED_SOLC_0_6_3_REVERT_ERROR,
|
|
1328
|
-
};
|
|
1377
|
+
this._instructionWithinFunctionToUnmappedSolc063RevertErrorStackTraceEntry(
|
|
1378
|
+
trace,
|
|
1379
|
+
prevInst
|
|
1380
|
+
);
|
|
1329
1381
|
|
|
1330
1382
|
// When the latest instruction is not within a function we need
|
|
1331
1383
|
// some default sourceReference to show to the user
|
|
@@ -1353,24 +1405,22 @@ export class ErrorInferrer {
|
|
|
1353
1405
|
return constructorRevertFrame;
|
|
1354
1406
|
}
|
|
1355
1407
|
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1408
|
+
if (prevInst !== undefined) {
|
|
1409
|
+
// We may as well just be in a function or modifier and just happen
|
|
1410
|
+
// to be at the last instruction of the runtime bytecode.
|
|
1411
|
+
// In this case we just return whatever the last mapped intruction
|
|
1412
|
+
// points to.
|
|
1413
|
+
const latestInstructionRevertFrame: UnmappedSolc063RevertErrorStackTraceEntry =
|
|
1414
|
+
this._instructionWithinFunctionToUnmappedSolc063RevertErrorStackTraceEntry(
|
|
1363
1415
|
trace,
|
|
1364
1416
|
prevInst
|
|
1365
|
-
)
|
|
1366
|
-
type: StackTraceEntryType.UNMAPPED_SOLC_0_6_3_REVERT_ERROR,
|
|
1367
|
-
};
|
|
1417
|
+
);
|
|
1368
1418
|
|
|
1369
|
-
|
|
1370
|
-
|
|
1419
|
+
if (latestInstructionRevertFrame.sourceReference !== undefined) {
|
|
1420
|
+
this._solidity063CorrectLineNumber(latestInstructionRevertFrame);
|
|
1421
|
+
}
|
|
1422
|
+
return latestInstructionRevertFrame;
|
|
1371
1423
|
}
|
|
1372
|
-
|
|
1373
|
-
return latestInstructionRevertFrame;
|
|
1374
1424
|
}
|
|
1375
1425
|
|
|
1376
1426
|
private _isContractTooLargeError(trace: DecodedCreateMessageTrace) {
|
|
@@ -1380,6 +1430,10 @@ export class ErrorInferrer {
|
|
|
1380
1430
|
private _solidity063CorrectLineNumber(
|
|
1381
1431
|
revertFrame: UnmappedSolc063RevertErrorStackTraceEntry
|
|
1382
1432
|
) {
|
|
1433
|
+
if (revertFrame.sourceReference === undefined) {
|
|
1434
|
+
return;
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1383
1437
|
const lines = revertFrame.sourceReference.sourceContent.split("\n");
|
|
1384
1438
|
|
|
1385
1439
|
const currentLine = lines[revertFrame.sourceReference.line - 1];
|
|
@@ -1447,13 +1501,19 @@ export class ErrorInferrer {
|
|
|
1447
1501
|
bytecode: Bytecode,
|
|
1448
1502
|
callInst: Instruction
|
|
1449
1503
|
): CallFailedErrorStackTraceEntry {
|
|
1504
|
+
const sourceReference = sourceLocationToSourceReference(
|
|
1505
|
+
bytecode,
|
|
1506
|
+
callInst.location
|
|
1507
|
+
);
|
|
1508
|
+
assertHardhatInvariant(
|
|
1509
|
+
sourceReference !== undefined,
|
|
1510
|
+
"Expected source reference to be defined"
|
|
1511
|
+
);
|
|
1512
|
+
|
|
1450
1513
|
// Calls only happen within functions
|
|
1451
1514
|
return {
|
|
1452
1515
|
type: StackTraceEntryType.CALL_FAILED_ERROR,
|
|
1453
|
-
sourceReference
|
|
1454
|
-
bytecode,
|
|
1455
|
-
callInst.location
|
|
1456
|
-
)!,
|
|
1516
|
+
sourceReference,
|
|
1457
1517
|
};
|
|
1458
1518
|
}
|
|
1459
1519
|
|
|
@@ -1502,10 +1562,16 @@ export class ErrorInferrer {
|
|
|
1502
1562
|
const callOpcodeStep = trace.steps[callSubtraceStepIndex - 1] as EvmStep;
|
|
1503
1563
|
const callInst = trace.bytecode.getInstruction(callOpcodeStep.pc);
|
|
1504
1564
|
|
|
1565
|
+
// Calls are always made from within functions
|
|
1566
|
+
assertHardhatInvariant(
|
|
1567
|
+
callInst.location !== undefined,
|
|
1568
|
+
"Expected call instruction location to be defined"
|
|
1569
|
+
);
|
|
1570
|
+
|
|
1505
1571
|
return this._isLastLocation(
|
|
1506
1572
|
trace,
|
|
1507
1573
|
callSubtraceStepIndex + 1,
|
|
1508
|
-
callInst.location
|
|
1574
|
+
callInst.location
|
|
1509
1575
|
);
|
|
1510
1576
|
}
|
|
1511
1577
|
|
|
@@ -1514,7 +1580,14 @@ export class ErrorInferrer {
|
|
|
1514
1580
|
instIndex: number,
|
|
1515
1581
|
callInstruction: Instruction
|
|
1516
1582
|
): boolean {
|
|
1517
|
-
const callLocation = callInstruction.location
|
|
1583
|
+
const callLocation = callInstruction.location;
|
|
1584
|
+
|
|
1585
|
+
// Calls are always made from within functions
|
|
1586
|
+
assertHardhatInvariant(
|
|
1587
|
+
callLocation !== undefined,
|
|
1588
|
+
"Expected call location to be defined"
|
|
1589
|
+
);
|
|
1590
|
+
|
|
1518
1591
|
return this._isLastLocation(trace, instIndex, callLocation);
|
|
1519
1592
|
}
|
|
1520
1593
|
|
|
@@ -1685,30 +1758,41 @@ export function instructionToCallstackStackTraceEntry(
|
|
|
1685
1758
|
};
|
|
1686
1759
|
}
|
|
1687
1760
|
|
|
1688
|
-
const func = inst.location
|
|
1761
|
+
const func = inst.location?.getContainingFunction();
|
|
1689
1762
|
|
|
1690
1763
|
if (func !== undefined) {
|
|
1764
|
+
const sourceReference = sourceLocationToSourceReference(
|
|
1765
|
+
bytecode,
|
|
1766
|
+
inst.location
|
|
1767
|
+
);
|
|
1768
|
+
assertHardhatInvariant(
|
|
1769
|
+
sourceReference !== undefined,
|
|
1770
|
+
"Expected source reference to be defined"
|
|
1771
|
+
);
|
|
1772
|
+
|
|
1691
1773
|
return {
|
|
1692
1774
|
type: StackTraceEntryType.CALLSTACK_ENTRY,
|
|
1693
|
-
sourceReference
|
|
1694
|
-
bytecode,
|
|
1695
|
-
inst.location
|
|
1696
|
-
)!,
|
|
1775
|
+
sourceReference,
|
|
1697
1776
|
functionType: func.type,
|
|
1698
1777
|
};
|
|
1699
1778
|
}
|
|
1700
1779
|
|
|
1780
|
+
assertHardhatInvariant(
|
|
1781
|
+
inst.location !== undefined,
|
|
1782
|
+
"Expected instruction location to be defined"
|
|
1783
|
+
);
|
|
1784
|
+
|
|
1701
1785
|
return {
|
|
1702
1786
|
type: StackTraceEntryType.CALLSTACK_ENTRY,
|
|
1703
1787
|
sourceReference: {
|
|
1704
1788
|
function: undefined,
|
|
1705
1789
|
contract: bytecode.contract.name,
|
|
1706
|
-
sourceName: inst.location
|
|
1707
|
-
sourceContent: inst.location
|
|
1708
|
-
line: inst.location
|
|
1790
|
+
sourceName: inst.location.file.sourceName,
|
|
1791
|
+
sourceContent: inst.location.file.content,
|
|
1792
|
+
line: inst.location.getStartingLineNumber(),
|
|
1709
1793
|
range: [
|
|
1710
|
-
inst.location
|
|
1711
|
-
inst.location
|
|
1794
|
+
inst.location.offset,
|
|
1795
|
+
inst.location.offset + inst.location.length,
|
|
1712
1796
|
],
|
|
1713
1797
|
},
|
|
1714
1798
|
functionType: ContractFunctionType.FUNCTION,
|
|
@@ -261,12 +261,22 @@ export class ContractFunction {
|
|
|
261
261
|
public readonly contract?: Contract,
|
|
262
262
|
public readonly visibility?: ContractFunctionVisibility,
|
|
263
263
|
public readonly isPayable?: boolean,
|
|
264
|
-
public selector?: Buffer
|
|
264
|
+
public selector?: Buffer,
|
|
265
|
+
public readonly paramTypes?: any[]
|
|
265
266
|
) {
|
|
266
267
|
if (contract !== undefined && !contract.location.contains(location)) {
|
|
267
268
|
throw new Error("Incompatible contract and function location");
|
|
268
269
|
}
|
|
269
270
|
}
|
|
271
|
+
|
|
272
|
+
public isValidCalldata(calldata: Buffer): boolean {
|
|
273
|
+
if (this.paramTypes === undefined) {
|
|
274
|
+
// if we don't know the param types, we just assume that the call is valid
|
|
275
|
+
return true;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
return AbiHelpers.isValidCalldata(this.paramTypes, calldata);
|
|
279
|
+
}
|
|
270
280
|
}
|
|
271
281
|
|
|
272
282
|
export class CustomError {
|
|
@@ -112,7 +112,6 @@ function encodeStackTraceEntry(
|
|
|
112
112
|
|
|
113
113
|
case StackTraceEntryType.CALLSTACK_ENTRY:
|
|
114
114
|
case StackTraceEntryType.REVERT_ERROR:
|
|
115
|
-
case StackTraceEntryType.PANIC_ERROR:
|
|
116
115
|
case StackTraceEntryType.CUSTOM_ERROR:
|
|
117
116
|
case StackTraceEntryType.FUNCTION_NOT_PAYABLE_ERROR:
|
|
118
117
|
case StackTraceEntryType.INVALID_PARAMS_ERROR:
|
|
@@ -122,7 +121,6 @@ function encodeStackTraceEntry(
|
|
|
122
121
|
case StackTraceEntryType.NONCONTRACT_ACCOUNT_CALLED_ERROR:
|
|
123
122
|
case StackTraceEntryType.CALL_FAILED_ERROR:
|
|
124
123
|
case StackTraceEntryType.DIRECT_LIBRARY_CALL_ERROR:
|
|
125
|
-
case StackTraceEntryType.UNMAPPED_SOLC_0_6_3_REVERT_ERROR:
|
|
126
124
|
return sourceReferenceToSolidityCallsite(stackTraceEntry.sourceReference);
|
|
127
125
|
|
|
128
126
|
case StackTraceEntryType.UNRECOGNIZED_CREATE_CALLSTACK_ENTRY:
|
|
@@ -188,6 +186,8 @@ function encodeStackTraceEntry(
|
|
|
188
186
|
|
|
189
187
|
case StackTraceEntryType.OTHER_EXECUTION_ERROR:
|
|
190
188
|
case StackTraceEntryType.CONTRACT_TOO_LARGE_ERROR:
|
|
189
|
+
case StackTraceEntryType.PANIC_ERROR:
|
|
190
|
+
case StackTraceEntryType.UNMAPPED_SOLC_0_6_3_REVERT_ERROR:
|
|
191
191
|
if (stackTraceEntry.sourceReference === undefined) {
|
|
192
192
|
return new SolidityCallSite(
|
|
193
193
|
undefined,
|
|
@@ -271,7 +271,9 @@ function getMessageFromLastStackTraceEntry(
|
|
|
271
271
|
}
|
|
272
272
|
|
|
273
273
|
if (!stackTraceEntry.message.isEmpty()) {
|
|
274
|
-
|
|
274
|
+
const returnData = stackTraceEntry.message.value.toString("hex");
|
|
275
|
+
|
|
276
|
+
return `VM Exception while processing transaction: reverted with an unrecognized custom error (return data: 0x${returnData})`;
|
|
275
277
|
}
|
|
276
278
|
|
|
277
279
|
if (stackTraceEntry.isInvalidOpcodeError) {
|
|
@@ -81,7 +81,7 @@ export interface RevertErrorStackTraceEntry {
|
|
|
81
81
|
export interface PanicErrorStackTraceEntry {
|
|
82
82
|
type: StackTraceEntryType.PANIC_ERROR;
|
|
83
83
|
errorCode: bigint;
|
|
84
|
-
sourceReference
|
|
84
|
+
sourceReference?: SourceReference;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
export interface CustomErrorStackTraceEntry {
|
|
@@ -93,7 +93,7 @@ export interface CustomErrorStackTraceEntry {
|
|
|
93
93
|
|
|
94
94
|
export interface UnmappedSolc063RevertErrorStackTraceEntry {
|
|
95
95
|
type: StackTraceEntryType.UNMAPPED_SOLC_0_6_3_REVERT_ERROR;
|
|
96
|
-
sourceReference
|
|
96
|
+
sourceReference?: SourceReference;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
export interface FunctionNotPayableErrorStackTraceEntry {
|
|
@@ -171,7 +171,10 @@ export class SolidityTracer {
|
|
|
171
171
|
const stacktrace: SolidityStackTrace = [];
|
|
172
172
|
|
|
173
173
|
let subtracesSeen = 0;
|
|
174
|
+
|
|
175
|
+
// There was a jump into a function according to the sourcemaps
|
|
174
176
|
let jumpedIntoFunction = false;
|
|
177
|
+
|
|
175
178
|
const functionJumpdests: Instruction[] = [];
|
|
176
179
|
|
|
177
180
|
let lastSubmessageData: SubmessageData | undefined;
|
|
@@ -222,7 +222,10 @@ export class VMDebugTracer {
|
|
|
222
222
|
);
|
|
223
223
|
|
|
224
224
|
// geth does this for some reason
|
|
225
|
-
if (
|
|
225
|
+
if (
|
|
226
|
+
rpcStructLogs.length > 0 &&
|
|
227
|
+
result.execResult.exceptionError?.error === "out of gas"
|
|
228
|
+
) {
|
|
226
229
|
rpcStructLogs[rpcStructLogs.length - 1].error = {};
|
|
227
230
|
}
|
|
228
231
|
|
|
@@ -36,16 +36,11 @@ if (HardhatContext.isCreated()) {
|
|
|
36
36
|
|
|
37
37
|
const { resolvedConfig, userConfig } = loadConfigAndTasks(hardhatArguments);
|
|
38
38
|
|
|
39
|
-
const artifactsExtensions = ctx.extendersManager
|
|
40
|
-
.getArtifactsExtenders()
|
|
41
|
-
.map((artifactsExtender) => artifactsExtender(resolvedConfig));
|
|
42
|
-
|
|
43
39
|
env = new Environment(
|
|
44
40
|
resolvedConfig,
|
|
45
41
|
hardhatArguments,
|
|
46
42
|
ctx.tasksDSL.getTaskDefinitions(),
|
|
47
|
-
ctx.extendersManager.
|
|
48
|
-
artifactsExtensions,
|
|
43
|
+
ctx.extendersManager.getExtenders(),
|
|
49
44
|
ctx.experimentalHardhatNetworkMessageTraceHooks,
|
|
50
45
|
userConfig
|
|
51
46
|
);
|
|
@@ -294,7 +294,7 @@ export class CompilerDownloader implements ICompilerDownloader {
|
|
|
294
294
|
build: CompilerBuild,
|
|
295
295
|
downloadPath: string
|
|
296
296
|
): Promise<boolean> {
|
|
297
|
-
const ethereumjsUtil =
|
|
297
|
+
const ethereumjsUtil = require("@nomicfoundation/ethereumjs-util");
|
|
298
298
|
const { keccak256 } = await import("../../util/keccak");
|
|
299
299
|
|
|
300
300
|
const expectedKeccak256 = build.keccak256;
|
|
@@ -328,7 +328,7 @@ export class CompilerDownloader implements ICompilerDownloader {
|
|
|
328
328
|
downloadPath.endsWith(".zip")
|
|
329
329
|
) {
|
|
330
330
|
// some window builds are zipped, some are not
|
|
331
|
-
const
|
|
331
|
+
const AdmZip = require("adm-zip");
|
|
332
332
|
|
|
333
333
|
const solcFolder = path.join(this._compilersDir, build.version);
|
|
334
334
|
await fsExtra.ensureDir(solcFolder);
|
|
@@ -347,7 +347,7 @@ export class CompilerDownloader implements ICompilerDownloader {
|
|
|
347
347
|
await fsExtra.createFile(this._getCompilerDoesntWorkFile(build));
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
-
private async _checkNativeSolc(build: CompilerBuild) {
|
|
350
|
+
private async _checkNativeSolc(build: CompilerBuild): Promise<boolean> {
|
|
351
351
|
const solcPath = this._getCompilerBinaryPathFromBuild(build);
|
|
352
352
|
const execFileP = promisify(execFile);
|
|
353
353
|
|
|
@@ -25,7 +25,7 @@ export class Compiler implements ICompiler {
|
|
|
25
25
|
return this._loadedSolc;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
const
|
|
28
|
+
const solcWrapper = require("solc/wrapper");
|
|
29
29
|
this._loadedSolc = solcWrapper(
|
|
30
30
|
this._loadCompilerSources(this._pathToSolcJs)
|
|
31
31
|
);
|
|
@@ -41,6 +41,14 @@ export class Compiler implements ICompiler {
|
|
|
41
41
|
*/
|
|
42
42
|
private _loadCompilerSources(compilerPath: string) {
|
|
43
43
|
const Module = module.constructor as any;
|
|
44
|
+
|
|
45
|
+
// if Hardhat is bundled (for example, in the vscode extension), then
|
|
46
|
+
// Module._extenions might be undefined. In that case, we just use a plain
|
|
47
|
+
// require.
|
|
48
|
+
if (Module._extensions === undefined) {
|
|
49
|
+
return require(compilerPath);
|
|
50
|
+
}
|
|
51
|
+
|
|
44
52
|
const previousHook = Module._extensions[".js"];
|
|
45
53
|
|
|
46
54
|
Module._extensions[".js"] = function (
|