hardhat 2.11.0-dev.0 → 2.11.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/builtin-tasks/clean.js +2 -1
- package/builtin-tasks/clean.js.map +1 -1
- package/builtin-tasks/compile.js +52 -95
- package/builtin-tasks/compile.js.map +1 -1
- package/builtin-tasks/flatten.js +2 -21
- package/builtin-tasks/flatten.js.map +1 -1
- package/builtin-tasks/node.js +1 -1
- package/builtin-tasks/node.js.map +1 -1
- package/builtin-tasks/test.js +3 -3
- package/builtin-tasks/test.js.map +1 -1
- package/builtin-tasks/utils/solidity-files-cache.d.ts.map +1 -1
- package/builtin-tasks/utils/solidity-files-cache.js +5 -6
- package/builtin-tasks/utils/solidity-files-cache.js.map +1 -1
- package/internal/artifacts.d.ts +3 -11
- package/internal/artifacts.d.ts.map +1 -1
- package/internal/artifacts.js +266 -133
- package/internal/artifacts.js.map +1 -1
- package/internal/cli/cli.js +26 -12
- package/internal/cli/cli.js.map +1 -1
- package/internal/core/config/config-loading.js +2 -2
- 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 +11 -31
- package/internal/core/config/config-resolution.js.map +1 -1
- package/internal/core/config/default-config.js +1 -1
- package/internal/core/config/default-config.js.map +1 -1
- package/internal/core/errors-list.d.ts +7 -0
- package/internal/core/errors-list.d.ts.map +1 -1
- package/internal/core/errors-list.js +28 -11
- package/internal/core/errors-list.js.map +1 -1
- package/internal/core/errors.d.ts +2 -1
- package/internal/core/errors.d.ts.map +1 -1
- package/internal/core/errors.js +5 -1
- package/internal/core/errors.js.map +1 -1
- package/internal/core/execution-mode.d.ts.map +1 -1
- package/internal/core/execution-mode.js +2 -21
- package/internal/core/execution-mode.js.map +1 -1
- package/internal/core/flamegraph.d.ts +4 -0
- package/internal/core/flamegraph.d.ts.map +1 -1
- package/internal/core/flamegraph.js +13 -3
- package/internal/core/flamegraph.js.map +1 -1
- package/internal/core/jsonrpc/types/base-types.d.ts.map +1 -1
- package/internal/core/jsonrpc/types/base-types.js +12 -12
- package/internal/core/jsonrpc/types/base-types.js.map +1 -1
- package/internal/core/params/hardhat-params.d.ts.map +1 -1
- package/internal/core/params/hardhat-params.js +18 -0
- package/internal/core/params/hardhat-params.js.map +1 -1
- package/internal/core/providers/accounts.js +9 -9
- package/internal/core/providers/accounts.js.map +1 -1
- package/internal/core/providers/construction.d.ts.map +1 -1
- package/internal/core/providers/construction.js +5 -6
- package/internal/core/providers/construction.js.map +1 -1
- package/internal/core/providers/gas-providers.d.ts +2 -2
- package/internal/core/providers/util.js +1 -1
- package/internal/core/providers/util.js.map +1 -1
- package/internal/core/runtime-environment.d.ts +6 -0
- package/internal/core/runtime-environment.d.ts.map +1 -1
- package/internal/core/runtime-environment.js +72 -6
- package/internal/core/runtime-environment.js.map +1 -1
- package/internal/core/typescript-support.d.ts +1 -1
- package/internal/core/typescript-support.d.ts.map +1 -1
- package/internal/core/typescript-support.js +6 -2
- package/internal/core/typescript-support.js.map +1 -1
- package/internal/hardhat-network/jsonrpc/client.d.ts +1 -1
- package/internal/hardhat-network/jsonrpc/client.d.ts.map +1 -1
- package/internal/hardhat-network/jsonrpc/client.js +10 -10
- package/internal/hardhat-network/jsonrpc/client.js.map +1 -1
- package/internal/hardhat-network/provider/BlockchainBase.d.ts +4 -4
- package/internal/hardhat-network/provider/BlockchainBase.d.ts.map +1 -1
- package/internal/hardhat-network/provider/BlockchainBase.js +31 -12
- package/internal/hardhat-network/provider/BlockchainBase.js.map +1 -1
- package/internal/hardhat-network/provider/BlockchainData.d.ts +3 -3
- package/internal/hardhat-network/provider/BlockchainData.d.ts.map +1 -1
- package/internal/hardhat-network/provider/BlockchainData.js +15 -15
- package/internal/hardhat-network/provider/BlockchainData.js.map +1 -1
- package/internal/hardhat-network/provider/HardhatBlockchain.d.ts +3 -3
- package/internal/hardhat-network/provider/HardhatBlockchain.d.ts.map +1 -1
- package/internal/hardhat-network/provider/HardhatBlockchain.js +2 -2
- package/internal/hardhat-network/provider/HardhatBlockchain.js.map +1 -1
- package/internal/hardhat-network/provider/PoolState.d.ts +1 -1
- package/internal/hardhat-network/provider/PoolState.d.ts.map +1 -1
- package/internal/hardhat-network/provider/PoolState.js +21 -2
- package/internal/hardhat-network/provider/PoolState.js.map +1 -1
- package/internal/hardhat-network/provider/TransactionQueue.d.ts +1 -1
- package/internal/hardhat-network/provider/TransactionQueue.d.ts.map +1 -1
- package/internal/hardhat-network/provider/TransactionQueue.js +22 -3
- package/internal/hardhat-network/provider/TransactionQueue.js.map +1 -1
- package/internal/hardhat-network/provider/TxPool.d.ts +4 -4
- package/internal/hardhat-network/provider/TxPool.d.ts.map +1 -1
- package/internal/hardhat-network/provider/TxPool.js +35 -16
- package/internal/hardhat-network/provider/TxPool.js.map +1 -1
- package/internal/hardhat-network/provider/ethereumjs-workarounds.js +4 -4
- package/internal/hardhat-network/provider/ethereumjs-workarounds.js.map +1 -1
- package/internal/hardhat-network/provider/filter.d.ts +1 -1
- package/internal/hardhat-network/provider/filter.d.ts.map +1 -1
- package/internal/hardhat-network/provider/filter.js +3 -3
- package/internal/hardhat-network/provider/filter.js.map +1 -1
- package/internal/hardhat-network/provider/fork/ForkBlockchain.d.ts +3 -3
- package/internal/hardhat-network/provider/fork/ForkBlockchain.d.ts.map +1 -1
- package/internal/hardhat-network/provider/fork/ForkBlockchain.js +13 -12
- package/internal/hardhat-network/provider/fork/ForkBlockchain.js.map +1 -1
- package/internal/hardhat-network/provider/fork/ForkStateManager.d.ts +3 -5
- package/internal/hardhat-network/provider/fork/ForkStateManager.d.ts.map +1 -1
- package/internal/hardhat-network/provider/fork/ForkStateManager.js +36 -40
- package/internal/hardhat-network/provider/fork/ForkStateManager.js.map +1 -1
- package/internal/hardhat-network/provider/fork/rpcToBlockData.d.ts +1 -1
- package/internal/hardhat-network/provider/fork/rpcToBlockData.d.ts.map +1 -1
- package/internal/hardhat-network/provider/fork/rpcToTxData.d.ts +2 -2
- package/internal/hardhat-network/provider/fork/rpcToTxData.d.ts.map +1 -1
- package/internal/hardhat-network/provider/fork/rpcToTxData.js.map +1 -1
- package/internal/hardhat-network/provider/modules/eth.d.ts +1 -1
- package/internal/hardhat-network/provider/modules/eth.d.ts.map +1 -1
- package/internal/hardhat-network/provider/modules/eth.js +22 -22
- package/internal/hardhat-network/provider/modules/eth.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 +20 -6
- package/internal/hardhat-network/provider/modules/hardhat.js.map +1 -1
- package/internal/hardhat-network/provider/modules/logger.d.ts +2 -2
- package/internal/hardhat-network/provider/modules/logger.d.ts.map +1 -1
- package/internal/hardhat-network/provider/modules/logger.js +14 -14
- package/internal/hardhat-network/provider/modules/logger.js.map +1 -1
- package/internal/hardhat-network/provider/modules/net.d.ts +1 -1
- package/internal/hardhat-network/provider/modules/net.d.ts.map +1 -1
- package/internal/hardhat-network/provider/modules/personal.js +3 -3
- package/internal/hardhat-network/provider/modules/personal.js.map +1 -1
- package/internal/hardhat-network/provider/modules/web3.d.ts.map +1 -1
- package/internal/hardhat-network/provider/modules/web3.js +4 -5
- package/internal/hardhat-network/provider/modules/web3.js.map +1 -1
- package/internal/hardhat-network/provider/node-types.d.ts +4 -4
- package/internal/hardhat-network/provider/node-types.d.ts.map +1 -1
- package/internal/hardhat-network/provider/node.d.ts +5 -4
- package/internal/hardhat-network/provider/node.d.ts.map +1 -1
- package/internal/hardhat-network/provider/node.js +71 -49
- package/internal/hardhat-network/provider/node.js.map +1 -1
- package/internal/hardhat-network/provider/output.d.ts +4 -4
- package/internal/hardhat-network/provider/output.d.ts.map +1 -1
- package/internal/hardhat-network/provider/output.js +24 -5
- package/internal/hardhat-network/provider/output.js.map +1 -1
- package/internal/hardhat-network/provider/provider.d.ts +2 -2
- package/internal/hardhat-network/provider/provider.d.ts.map +1 -1
- package/internal/hardhat-network/provider/provider.js +3 -3
- package/internal/hardhat-network/provider/provider.js.map +1 -1
- package/internal/hardhat-network/provider/return-data.d.ts +1 -1
- package/internal/hardhat-network/provider/return-data.d.ts.map +1 -1
- package/internal/hardhat-network/provider/return-data.js +5 -4
- package/internal/hardhat-network/provider/return-data.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.d.ts +4 -4
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.js +8 -8
- package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.d.ts +3 -3
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.js +8 -8
- package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.d.ts +3 -3
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.js +5 -5
- package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.d.ts +4 -4
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.js +25 -6
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.d.ts +3 -3
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.js +25 -6
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.js.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.d.ts +3 -3
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.d.ts.map +1 -1
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.js +2 -2
- package/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.js.map +1 -1
- package/internal/hardhat-network/provider/types/HardhatBlockchainInterface.d.ts +2 -2
- package/internal/hardhat-network/provider/types/HardhatBlockchainInterface.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/makeAccount.d.ts +1 -1
- package/internal/hardhat-network/provider/utils/makeAccount.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/makeAccount.js +4 -4
- package/internal/hardhat-network/provider/utils/makeAccount.js.map +1 -1
- package/internal/hardhat-network/provider/utils/makeCommon.d.ts +1 -1
- package/internal/hardhat-network/provider/utils/makeCommon.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/makeCommon.js +2 -2
- package/internal/hardhat-network/provider/utils/makeCommon.js.map +1 -1
- package/internal/hardhat-network/provider/utils/makeStateTrie.d.ts +1 -1
- package/internal/hardhat-network/provider/utils/makeStateTrie.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/makeStateTrie.js +4 -4
- package/internal/hardhat-network/provider/utils/makeStateTrie.js.map +1 -1
- package/internal/hardhat-network/provider/utils/putGenesisBlock.d.ts +3 -3
- package/internal/hardhat-network/provider/utils/putGenesisBlock.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/putGenesisBlock.js +4 -4
- package/internal/hardhat-network/provider/utils/putGenesisBlock.js.map +1 -1
- package/internal/hardhat-network/provider/utils/random.d.ts +2 -1
- package/internal/hardhat-network/provider/utils/random.d.ts.map +1 -1
- package/internal/hardhat-network/provider/utils/random.js +10 -9
- package/internal/hardhat-network/provider/utils/random.js.map +1 -1
- package/internal/hardhat-network/provider/utils/reorganizeTransactionsLists.js +21 -2
- package/internal/hardhat-network/provider/utils/reorganizeTransactionsLists.js.map +1 -1
- package/internal/hardhat-network/provider/utils/txMapToArray.d.ts +1 -1
- package/internal/hardhat-network/provider/utils/txMapToArray.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/consoleLogger.js +45 -45
- 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.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/constants.js +1 -1
- package/internal/hardhat-network/stack-traces/constants.js.map +1 -1
- package/internal/hardhat-network/stack-traces/contracts-identifier.js +2 -2
- package/internal/hardhat-network/stack-traces/contracts-identifier.js.map +1 -1
- package/internal/hardhat-network/stack-traces/debug.js +13 -13
- package/internal/hardhat-network/stack-traces/debug.js.map +1 -1
- package/internal/hardhat-network/stack-traces/error-inferrer.js +2 -2
- package/internal/hardhat-network/stack-traces/error-inferrer.js.map +1 -1
- package/internal/hardhat-network/stack-traces/message-trace.d.ts +1 -1
- package/internal/hardhat-network/stack-traces/message-trace.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/model.js +6 -6
- package/internal/hardhat-network/stack-traces/model.js.map +1 -1
- package/internal/hardhat-network/stack-traces/panic-errors.d.ts +1 -1
- package/internal/hardhat-network/stack-traces/panic-errors.js +9 -9
- package/internal/hardhat-network/stack-traces/panic-errors.js.map +1 -1
- package/internal/hardhat-network/stack-traces/solidity-errors.js +3 -3
- package/internal/hardhat-network/stack-traces/solidity-errors.js.map +1 -1
- package/internal/hardhat-network/stack-traces/solidity-stack-trace.d.ts +1 -1
- package/internal/hardhat-network/stack-traces/solidityTracer.d.ts +0 -2
- package/internal/hardhat-network/stack-traces/solidityTracer.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/solidityTracer.js +2 -4
- package/internal/hardhat-network/stack-traces/solidityTracer.js.map +1 -1
- package/internal/hardhat-network/stack-traces/vm-debug-tracer.d.ts +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 +27 -25
- package/internal/hardhat-network/stack-traces/vm-debug-tracer.js.map +1 -1
- package/internal/hardhat-network/stack-traces/vm-tracer.d.ts +2 -2
- package/internal/hardhat-network/stack-traces/vm-tracer.d.ts.map +1 -1
- package/internal/hardhat-network/stack-traces/vm-tracer.js +15 -12
- package/internal/hardhat-network/stack-traces/vm-tracer.js.map +1 -1
- package/internal/lib/hardhat-lib.d.ts.map +1 -1
- package/internal/lib/hardhat-lib.js +0 -2
- package/internal/lib/hardhat-lib.js.map +1 -1
- package/internal/solidity/compilation-job.d.ts.map +1 -1
- package/internal/solidity/compilation-job.js +6 -7
- package/internal/solidity/compilation-job.js.map +1 -1
- package/internal/solidity/compiler/downloader.d.ts +66 -40
- package/internal/solidity/compiler/downloader.d.ts.map +1 -1
- package/internal/solidity/compiler/downloader.js +180 -154
- package/internal/solidity/compiler/downloader.js.map +1 -1
- package/internal/solidity/compiler/index.d.ts +8 -4
- package/internal/solidity/compiler/index.d.ts.map +1 -1
- package/internal/solidity/compiler/index.js +1 -1
- package/internal/solidity/compiler/index.js.map +1 -1
- package/internal/solidity/dependencyGraph.d.ts.map +1 -1
- package/internal/solidity/dependencyGraph.js +3 -5
- package/internal/solidity/dependencyGraph.js.map +1 -1
- package/internal/solidity/parse.d.ts.map +1 -1
- package/internal/solidity/parse.js +2 -58
- package/internal/solidity/parse.js.map +1 -1
- package/internal/solidity/resolver.d.ts +1 -0
- package/internal/solidity/resolver.d.ts.map +1 -1
- package/internal/solidity/resolver.js +33 -8
- package/internal/solidity/resolver.js.map +1 -1
- package/internal/util/bigint.d.ts +13 -24
- package/internal/util/bigint.d.ts.map +1 -1
- package/internal/util/bigint.js +22 -29
- package/internal/util/bigint.js.map +1 -1
- package/internal/util/download.d.ts.map +1 -1
- package/internal/util/download.js +1 -1
- package/internal/util/download.js.map +1 -1
- package/internal/util/fs-utils.d.ts +26 -9
- package/internal/util/fs-utils.d.ts.map +1 -1
- package/internal/util/fs-utils.js +111 -68
- package/internal/util/fs-utils.js.map +1 -1
- package/internal/util/glob.d.ts +13 -0
- package/internal/util/glob.d.ts.map +1 -1
- package/internal/util/glob.js +13 -0
- package/internal/util/glob.js.map +1 -1
- package/internal/util/keccak.d.ts +3 -0
- package/internal/util/keccak.d.ts.map +1 -0
- package/internal/util/keccak.js +12 -0
- package/internal/util/keccak.js.map +1 -0
- package/internal/util/scripts-runner.d.ts.map +1 -1
- package/internal/util/scripts-runner.js +7 -4
- package/internal/util/scripts-runner.js.map +1 -1
- package/package.json +15 -15
- package/register.js +1 -3
- package/register.js.map +1 -1
- package/sample-projects/javascript/contracts/Lock.sol +3 -3
- package/sample-projects/typescript/contracts/Lock.sol +3 -3
- package/src/builtin-tasks/clean.ts +9 -6
- package/src/builtin-tasks/compile.ts +96 -128
- package/src/builtin-tasks/flatten.ts +2 -3
- package/src/builtin-tasks/node.ts +2 -2
- package/src/builtin-tasks/test.ts +7 -3
- package/src/builtin-tasks/utils/solidity-files-cache.ts +9 -8
- package/src/internal/artifacts.ts +392 -182
- package/src/internal/cli/cli.ts +43 -17
- package/src/internal/core/config/config-loading.ts +1 -1
- package/src/internal/core/config/config-resolution.ts +12 -24
- package/src/internal/core/config/default-config.ts +1 -1
- package/src/internal/core/errors-list.ts +29 -13
- package/src/internal/core/errors.ts +10 -2
- package/src/internal/core/execution-mode.ts +2 -3
- package/src/internal/core/flamegraph.ts +270 -0
- package/src/internal/core/jsonrpc/types/base-types.ts +7 -3
- package/src/internal/core/params/hardhat-params.ts +18 -0
- package/src/internal/core/providers/accounts.ts +8 -8
- package/src/internal/core/providers/construction.ts +10 -8
- package/src/internal/core/providers/gas-providers.ts +2 -2
- package/src/internal/core/providers/util.ts +1 -1
- package/src/internal/core/runtime-environment.ts +103 -10
- package/src/internal/core/task-profiling.ts +56 -0
- package/src/internal/core/typescript-support.ts +11 -2
- package/src/internal/hardhat-network/jsonrpc/client.ts +1 -1
- package/src/internal/hardhat-network/provider/BlockchainBase.ts +6 -6
- package/src/internal/hardhat-network/provider/BlockchainData.ts +5 -5
- package/src/internal/hardhat-network/provider/HardhatBlockchain.ts +4 -4
- package/src/internal/hardhat-network/provider/PoolState.ts +2 -2
- package/src/internal/hardhat-network/provider/TransactionQueue.ts +2 -2
- package/src/internal/hardhat-network/provider/TxPool.ts +12 -5
- package/src/internal/hardhat-network/provider/ethereumjs-workarounds.ts +3 -3
- package/src/internal/hardhat-network/provider/filter.ts +2 -2
- package/src/internal/hardhat-network/provider/fork/ForkBlockchain.ts +10 -10
- package/src/internal/hardhat-network/provider/fork/ForkStateManager.ts +12 -18
- package/src/internal/hardhat-network/provider/fork/rpcToBlockData.ts +1 -1
- package/src/internal/hardhat-network/provider/fork/rpcToTxData.ts +5 -2
- package/src/internal/hardhat-network/provider/modules/eth.ts +10 -6
- package/src/internal/hardhat-network/provider/modules/hardhat.ts +25 -1
- package/src/internal/hardhat-network/provider/modules/logger.ts +3 -3
- package/src/internal/hardhat-network/provider/modules/net.ts +1 -1
- package/src/internal/hardhat-network/provider/modules/personal.ts +1 -1
- package/src/internal/hardhat-network/provider/modules/web3.ts +4 -6
- package/src/internal/hardhat-network/provider/node-types.ts +6 -6
- package/src/internal/hardhat-network/provider/node.ts +25 -12
- package/src/internal/hardhat-network/provider/output.ts +6 -6
- package/src/internal/hardhat-network/provider/provider.ts +7 -6
- package/src/internal/hardhat-network/provider/return-data.ts +9 -5
- package/src/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.ts +9 -5
- package/src/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.ts +8 -4
- package/src/internal/hardhat-network/provider/transactions/FakeSenderTransaction.ts +4 -4
- package/src/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.ts +8 -5
- package/src/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.ts +4 -4
- package/src/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.ts +3 -3
- package/src/internal/hardhat-network/provider/types/HardhatBlockchainInterface.ts +2 -2
- package/src/internal/hardhat-network/provider/utils/makeAccount.ts +6 -1
- package/src/internal/hardhat-network/provider/utils/makeCommon.ts +1 -1
- package/src/internal/hardhat-network/provider/utils/makeStateTrie.ts +7 -3
- package/src/internal/hardhat-network/provider/utils/putGenesisBlock.ts +6 -6
- package/src/internal/hardhat-network/provider/utils/random.ts +17 -14
- package/src/internal/hardhat-network/provider/utils/reorganizeTransactionsLists.ts +1 -1
- package/src/internal/hardhat-network/stack-traces/consoleLogger.ts +1 -1
- package/src/internal/hardhat-network/stack-traces/constants.ts +2 -0
- package/src/internal/hardhat-network/stack-traces/contracts-identifier.ts +1 -1
- package/src/internal/hardhat-network/stack-traces/debug.ts +1 -1
- package/src/internal/hardhat-network/stack-traces/error-inferrer.ts +3 -3
- package/src/internal/hardhat-network/stack-traces/message-trace.ts +1 -1
- package/src/internal/hardhat-network/stack-traces/model.ts +1 -1
- package/src/internal/hardhat-network/stack-traces/panic-errors.ts +11 -11
- package/src/internal/hardhat-network/stack-traces/solidity-errors.ts +1 -1
- package/src/internal/hardhat-network/stack-traces/solidity-stack-trace.ts +1 -1
- package/src/internal/hardhat-network/stack-traces/solidityTracer.ts +1 -4
- package/src/internal/hardhat-network/stack-traces/vm-debug-tracer.ts +31 -17
- package/src/internal/hardhat-network/stack-traces/vm-tracer.ts +29 -14
- package/src/internal/lib/hardhat-lib.ts +0 -3
- package/src/internal/solidity/compilation-job.ts +11 -11
- package/src/internal/solidity/compiler/downloader.ts +271 -243
- package/src/internal/solidity/compiler/index.ts +13 -7
- package/src/internal/solidity/dependencyGraph.ts +12 -8
- package/src/internal/solidity/parse.ts +4 -70
- package/src/internal/solidity/resolver.ts +36 -8
- package/src/internal/util/bigint.ts +25 -43
- package/src/internal/util/download.ts +2 -2
- package/src/internal/util/fs-utils.ts +223 -0
- package/src/internal/util/glob.ts +13 -0
- package/src/internal/util/keccak.ts +5 -0
- package/src/internal/util/scripts-runner.ts +13 -4
- package/src/internal/util/wei-values.ts +1 -1
- package/src/internal/{hardhat-network/vendor → vendor}/await-semaphore/index.ts +0 -0
- package/src/profiling.ts +37 -0
- package/src/register.ts +1 -4
- package/src/types/artifacts.ts +21 -0
- package/src/types/config.ts +7 -7
- package/src/types/runtime.ts +2 -0
- package/src/utils/source-names.ts +36 -26
- package/types/artifacts.d.ts +19 -0
- package/types/artifacts.d.ts.map +1 -1
- package/types/config.d.ts +7 -7
- package/types/runtime.d.ts +2 -0
- package/types/runtime.d.ts.map +1 -1
- package/utils/source-names.d.ts.map +1 -1
- package/utils/source-names.js +25 -36
- package/utils/source-names.js.map +1 -1
- package/internal/hardhat-network/provider/fork/random.d.ts +0 -7
- package/internal/hardhat-network/provider/fork/random.d.ts.map +0 -1
- package/internal/hardhat-network/provider/fork/random.js +0 -32
- package/internal/hardhat-network/provider/fork/random.js.map +0 -1
- package/internal/hardhat-network/provider/utils/bnToHex.d.ts +0 -3
- package/internal/hardhat-network/provider/utils/bnToHex.d.ts.map +0 -1
- package/internal/hardhat-network/provider/utils/bnToHex.js +0 -9
- package/internal/hardhat-network/provider/utils/bnToHex.js.map +0 -1
- package/internal/hardhat-network/provider/utils/makeForkCommon.d.ts +0 -4
- package/internal/hardhat-network/provider/utils/makeForkCommon.d.ts.map +0 -1
- package/internal/hardhat-network/provider/utils/makeForkCommon.js +0 -16
- package/internal/hardhat-network/provider/utils/makeForkCommon.js.map +0 -1
- package/internal/hardhat-network/vendor/await-semaphore/index.d.ts +0 -12
- package/internal/hardhat-network/vendor/await-semaphore/index.d.ts.map +0 -1
- package/internal/hardhat-network/vendor/await-semaphore/index.js +0 -64
- package/internal/hardhat-network/vendor/await-semaphore/index.js.map +0 -1
- package/internal/util/antlr-prototype-pollution-workaround.d.ts +0 -16
- package/internal/util/antlr-prototype-pollution-workaround.d.ts.map +0 -1
- package/internal/util/antlr-prototype-pollution-workaround.js +0 -22
- package/internal/util/antlr-prototype-pollution-workaround.js.map +0 -1
- package/src/internal/util/antlr-prototype-pollution-workaround.ts +0 -17
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type SolidityAnalyzerT from "@nomicfoundation/solidity-analyzer";
|
|
2
2
|
|
|
3
3
|
import { SolidityFilesCache } from "../../builtin-tasks/utils/solidity-files-cache";
|
|
4
4
|
|
|
5
|
-
const log = debug("hardhat:core:solidity:imports");
|
|
6
|
-
|
|
7
5
|
interface ParsedData {
|
|
8
6
|
imports: string[];
|
|
9
7
|
versionPragmas: string[];
|
|
@@ -29,34 +27,9 @@ export class Parser {
|
|
|
29
27
|
return cacheResult;
|
|
30
28
|
}
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const ast = parser.parse(fileContent, { tolerant: true });
|
|
36
|
-
|
|
37
|
-
const imports: string[] = [];
|
|
38
|
-
const versionPragmas: string[] = [];
|
|
39
|
-
|
|
40
|
-
parser.visit(ast, {
|
|
41
|
-
ImportDirective: (node: { path: string }) => imports.push(node.path),
|
|
42
|
-
PragmaDirective: (node: { name: string; value: string }) => {
|
|
43
|
-
if (node.name === "solidity") {
|
|
44
|
-
versionPragmas.push(node.value);
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
result = { imports, versionPragmas };
|
|
50
|
-
} catch (error) {
|
|
51
|
-
log(
|
|
52
|
-
"Failed to parse Solidity file to extract its imports, using regex fallback\n",
|
|
53
|
-
error
|
|
54
|
-
);
|
|
55
|
-
result = {
|
|
56
|
-
imports: findImportsWithRegexps(fileContent),
|
|
57
|
-
versionPragmas: findVersionPragmasWithRegexps(fileContent),
|
|
58
|
-
};
|
|
59
|
-
}
|
|
30
|
+
const { analyze } =
|
|
31
|
+
require("@nomicfoundation/solidity-analyzer") as typeof SolidityAnalyzerT;
|
|
32
|
+
const result = analyze(fileContent);
|
|
60
33
|
|
|
61
34
|
this._cache.set(contentHash, result);
|
|
62
35
|
|
|
@@ -94,42 +67,3 @@ export class Parser {
|
|
|
94
67
|
return { imports, versionPragmas };
|
|
95
68
|
}
|
|
96
69
|
}
|
|
97
|
-
|
|
98
|
-
function findImportsWithRegexps(fileContent: string): string[] {
|
|
99
|
-
const importsRegexp: RegExp =
|
|
100
|
-
/import\s+(?:(?:"([^;]*)"|'([^;]*)')(?:;|\s+as\s+[^;]*;)|.+from\s+(?:"(.*)"|'(.*)');)/g;
|
|
101
|
-
|
|
102
|
-
let imports: string[] = [];
|
|
103
|
-
let result: RegExpExecArray | null;
|
|
104
|
-
|
|
105
|
-
while (true) {
|
|
106
|
-
result = importsRegexp.exec(fileContent);
|
|
107
|
-
if (result === null) {
|
|
108
|
-
return imports;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
imports = [
|
|
112
|
-
...imports,
|
|
113
|
-
...result.slice(1).filter((m: any) => m !== undefined),
|
|
114
|
-
];
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function findVersionPragmasWithRegexps(fileContent: string): string[] {
|
|
119
|
-
const versionPragmasRegexp: RegExp = /pragma\s+solidity\s+(.+?);/g;
|
|
120
|
-
|
|
121
|
-
let versionPragmas: string[] = [];
|
|
122
|
-
let result: RegExpExecArray | null;
|
|
123
|
-
|
|
124
|
-
while (true) {
|
|
125
|
-
result = versionPragmasRegexp.exec(fileContent);
|
|
126
|
-
if (result === null) {
|
|
127
|
-
return versionPragmas;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
versionPragmas = [
|
|
131
|
-
...versionPragmas,
|
|
132
|
-
...result.slice(1).filter((m: any) => m !== undefined),
|
|
133
|
-
];
|
|
134
|
-
}
|
|
135
|
-
}
|
|
@@ -19,6 +19,7 @@ import { assertHardhatInvariant, HardhatError } from "../core/errors";
|
|
|
19
19
|
import { ERRORS } from "../core/errors-list";
|
|
20
20
|
import { createNonCryptographicHashBasedIdentifier } from "../util/hash";
|
|
21
21
|
|
|
22
|
+
import { getRealPath } from "../util/fs-utils";
|
|
22
23
|
import { Parser } from "./parse";
|
|
23
24
|
|
|
24
25
|
export interface ResolvedFilesMap {
|
|
@@ -62,6 +63,8 @@ export class ResolvedFile implements IResolvedFile {
|
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
export class Resolver {
|
|
66
|
+
private readonly _cache: Map<string, ResolvedFile> = new Map();
|
|
67
|
+
|
|
65
68
|
constructor(
|
|
66
69
|
private readonly _projectRoot: string,
|
|
67
70
|
private readonly _parser: Parser,
|
|
@@ -74,13 +77,23 @@ export class Resolver {
|
|
|
74
77
|
* @param sourceName The source name as it would be provided to solc.
|
|
75
78
|
*/
|
|
76
79
|
public async resolveSourceName(sourceName: string): Promise<ResolvedFile> {
|
|
80
|
+
const cached = this._cache.get(sourceName);
|
|
81
|
+
if (cached !== undefined) {
|
|
82
|
+
return cached;
|
|
83
|
+
}
|
|
84
|
+
|
|
77
85
|
validateSourceNameFormat(sourceName);
|
|
78
86
|
|
|
87
|
+
let resolvedFile: ResolvedFile;
|
|
88
|
+
|
|
79
89
|
if (await isLocalSourceName(this._projectRoot, sourceName)) {
|
|
80
|
-
|
|
90
|
+
resolvedFile = await this._resolveLocalSourceName(sourceName);
|
|
91
|
+
} else {
|
|
92
|
+
resolvedFile = await this._resolveLibrarySourceName(sourceName);
|
|
81
93
|
}
|
|
82
94
|
|
|
83
|
-
|
|
95
|
+
this._cache.set(sourceName, resolvedFile);
|
|
96
|
+
return resolvedFile;
|
|
84
97
|
}
|
|
85
98
|
|
|
86
99
|
/**
|
|
@@ -116,23 +129,38 @@ export class Resolver {
|
|
|
116
129
|
}
|
|
117
130
|
|
|
118
131
|
try {
|
|
119
|
-
|
|
120
|
-
|
|
132
|
+
let sourceName: string;
|
|
133
|
+
|
|
134
|
+
const isRelativeImport = this._isRelativeImport(imported);
|
|
135
|
+
|
|
136
|
+
if (isRelativeImport) {
|
|
137
|
+
sourceName = await this._relativeImportToSourceName(from, imported);
|
|
138
|
+
} else {
|
|
139
|
+
sourceName = normalizeSourceName(imported);
|
|
121
140
|
}
|
|
122
141
|
|
|
123
|
-
const
|
|
142
|
+
const cached = this._cache.get(sourceName);
|
|
143
|
+
if (cached !== undefined) {
|
|
144
|
+
return cached;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
let resolvedFile: ResolvedFile;
|
|
124
148
|
|
|
125
149
|
// We have this special case here, because otherwise local relative
|
|
126
150
|
// imports can be treated as library imports. For example if
|
|
127
151
|
// `contracts/c.sol` imports `../non-existent/a.sol`
|
|
128
152
|
if (
|
|
129
153
|
from.library === undefined &&
|
|
154
|
+
isRelativeImport &&
|
|
130
155
|
!this._isRelativeImportToLibrary(from, imported)
|
|
131
156
|
) {
|
|
132
|
-
|
|
157
|
+
resolvedFile = await this._resolveLocalSourceName(sourceName);
|
|
158
|
+
} else {
|
|
159
|
+
resolvedFile = await this.resolveSourceName(sourceName);
|
|
133
160
|
}
|
|
134
161
|
|
|
135
|
-
|
|
162
|
+
this._cache.set(sourceName, resolvedFile);
|
|
163
|
+
return resolvedFile;
|
|
136
164
|
} catch (error) {
|
|
137
165
|
if (
|
|
138
166
|
HardhatError.isHardhatErrorType(
|
|
@@ -252,7 +280,7 @@ export class Resolver {
|
|
|
252
280
|
return this._resolveFile(
|
|
253
281
|
sourceName,
|
|
254
282
|
// We resolve to the real path here, as we may be resolving a linked library
|
|
255
|
-
await
|
|
283
|
+
await getRealPath(path.join(nodeModulesPath, sourceName)),
|
|
256
284
|
libraryName,
|
|
257
285
|
libraryVersion
|
|
258
286
|
);
|
|
@@ -1,23 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BigIntLike,
|
|
3
|
-
bufferToBigInt,
|
|
4
|
-
bufferToHex,
|
|
5
|
-
toBuffer,
|
|
6
|
-
} from "@ignored/util";
|
|
1
|
+
import { assertHardhatInvariant } from "../core/errors";
|
|
7
2
|
|
|
8
|
-
function min(x: bigint, y: bigint): bigint {
|
|
3
|
+
export function min(x: bigint, y: bigint): bigint {
|
|
9
4
|
return x < y ? x : y;
|
|
10
5
|
}
|
|
11
6
|
|
|
12
|
-
function max(x: bigint, y: bigint): bigint {
|
|
7
|
+
export function max(x: bigint, y: bigint): bigint {
|
|
13
8
|
return x > y ? x : y;
|
|
14
9
|
}
|
|
15
10
|
|
|
16
|
-
function isBigInt(x: unknown): x is bigint {
|
|
11
|
+
export function isBigInt(x: unknown): x is bigint {
|
|
17
12
|
return typeof x === "bigint";
|
|
18
13
|
}
|
|
19
14
|
|
|
20
|
-
function divUp(x: bigint, y: bigint): bigint {
|
|
15
|
+
export function divUp(x: bigint, y: bigint): bigint {
|
|
21
16
|
let result = x / y;
|
|
22
17
|
|
|
23
18
|
if (x % y !== 0n) {
|
|
@@ -27,31 +22,26 @@ function divUp(x: bigint, y: bigint): bigint {
|
|
|
27
22
|
return result;
|
|
28
23
|
}
|
|
29
24
|
|
|
30
|
-
function cmp(a: bigint, b: bigint): number {
|
|
25
|
+
export function cmp(a: bigint, b: bigint): number {
|
|
31
26
|
return a < b ? -1 : a > b ? 1 : 0;
|
|
32
27
|
}
|
|
33
28
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return x;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function mapBigIntToNumber<T>(x: bigint | T): number | T {
|
|
43
|
-
if (typeof x === "bigint") {
|
|
44
|
-
return Number(x);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return x;
|
|
29
|
+
/**
|
|
30
|
+
* Converts the number to a hexadecimal string with a length of 32
|
|
31
|
+
* bytes. This hex string is NOT 0x-prefixed.
|
|
32
|
+
*/
|
|
33
|
+
export function toEvmWord(x: bigint | number): string {
|
|
34
|
+
return x.toString(16).padStart(64, "0");
|
|
48
35
|
}
|
|
49
36
|
|
|
50
|
-
function
|
|
51
|
-
|
|
37
|
+
function bufferToBigInt(x: Buffer): bigint {
|
|
38
|
+
const hex = `0x${x.toString("hex")}`;
|
|
39
|
+
return hex === "0x" ? 0n : BigInt(hex);
|
|
52
40
|
}
|
|
53
41
|
|
|
54
|
-
function fromBigIntLike(
|
|
42
|
+
export function fromBigIntLike(
|
|
43
|
+
x: string | number | bigint | Buffer | undefined
|
|
44
|
+
): bigint | undefined {
|
|
55
45
|
if (x === undefined || typeof x === "bigint") {
|
|
56
46
|
return x;
|
|
57
47
|
}
|
|
@@ -66,19 +56,11 @@ function fromBigIntLike(x: BigIntLike | undefined): bigint | undefined {
|
|
|
66
56
|
return exhaustiveCheck;
|
|
67
57
|
}
|
|
68
58
|
|
|
69
|
-
function toHex(x: number | bigint): string {
|
|
70
|
-
|
|
71
|
-
|
|
59
|
+
export function toHex(x: number | bigint): string {
|
|
60
|
+
assertHardhatInvariant(
|
|
61
|
+
x >= 0,
|
|
62
|
+
`toHex can only be used with non-negative numbers, but received ${x}`
|
|
63
|
+
);
|
|
72
64
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
max,
|
|
76
|
-
isBigInt,
|
|
77
|
-
divUp,
|
|
78
|
-
cmp,
|
|
79
|
-
mapNumberToBigInt,
|
|
80
|
-
mapBigIntToNumber,
|
|
81
|
-
toWord,
|
|
82
|
-
fromBigIntLike,
|
|
83
|
-
toHex,
|
|
84
|
-
};
|
|
65
|
+
return `0x${x.toString(16)}`;
|
|
66
|
+
}
|
|
@@ -7,8 +7,6 @@ import { getHardhatVersion } from "./packageInfo";
|
|
|
7
7
|
|
|
8
8
|
const TEMP_FILE_PREFIX = "tmp-";
|
|
9
9
|
|
|
10
|
-
const hardhatVersion = getHardhatVersion();
|
|
11
|
-
|
|
12
10
|
function resolveTempFileName(filePath: string): string {
|
|
13
11
|
const { dir, ext, name } = path.parse(filePath);
|
|
14
12
|
|
|
@@ -40,6 +38,8 @@ export async function download(
|
|
|
40
38
|
return getGlobalDispatcher();
|
|
41
39
|
}
|
|
42
40
|
|
|
41
|
+
const hardhatVersion = getHardhatVersion();
|
|
42
|
+
|
|
43
43
|
// Fetch the url
|
|
44
44
|
const response = await request(url, {
|
|
45
45
|
dispatcher: chooseDispatcher(),
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import fsPromises from "fs/promises";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { CustomError } from "../core/errors";
|
|
5
|
+
|
|
6
|
+
// We use this error to encapsulate any other error possibly thrown by node's
|
|
7
|
+
// fs apis, as sometimes their errors don't have stack traces.
|
|
8
|
+
export class FileSystemAccessError extends CustomError {}
|
|
9
|
+
|
|
10
|
+
export class FileNotFoundError extends CustomError {
|
|
11
|
+
constructor(filePath: string, parent?: Error) {
|
|
12
|
+
super(`File ${filePath} not found`, parent);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export class InvalidDirectoryError extends CustomError {
|
|
16
|
+
constructor(filePath: string, parent: Error) {
|
|
17
|
+
super(`Invalid directory ${filePath}`, parent);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Returns the real path of absolutePath, resolving symlinks.
|
|
23
|
+
*
|
|
24
|
+
* @throws FileNotFoundError if absolutePath doesn't exist.
|
|
25
|
+
*/
|
|
26
|
+
export async function getRealPath(absolutePath: string): Promise<string> {
|
|
27
|
+
try {
|
|
28
|
+
// This method returns the actual casing.
|
|
29
|
+
// Please read Node.js' docs to learn more.
|
|
30
|
+
return await fsPromises.realpath(path.normalize(absolutePath));
|
|
31
|
+
} catch (e: any) {
|
|
32
|
+
if (e.code === "ENOENT") {
|
|
33
|
+
// eslint-disable-next-line @nomiclabs/hardhat-internal-rules/only-hardhat-error
|
|
34
|
+
throw new FileNotFoundError(absolutePath, e);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// eslint-disable-next-line @nomiclabs/hardhat-internal-rules/only-hardhat-error
|
|
38
|
+
throw new FileSystemAccessError(e.message, e);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Sync version of getRealPath
|
|
44
|
+
*
|
|
45
|
+
* @see getRealCase
|
|
46
|
+
*/
|
|
47
|
+
export function getRealPathSync(absolutePath: string): string {
|
|
48
|
+
try {
|
|
49
|
+
// This method returns the actual casing.
|
|
50
|
+
// Please read Node.js' docs to learn more.
|
|
51
|
+
return fs.realpathSync.native(path.normalize(absolutePath));
|
|
52
|
+
} catch (e: any) {
|
|
53
|
+
if (e.code === "ENOENT") {
|
|
54
|
+
// eslint-disable-next-line @nomiclabs/hardhat-internal-rules/only-hardhat-error
|
|
55
|
+
throw new FileNotFoundError(absolutePath, e);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// eslint-disable-next-line @nomiclabs/hardhat-internal-rules/only-hardhat-error
|
|
59
|
+
throw new FileSystemAccessError(e.message, e);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Returns an array of files (not dirs) that match a condition.
|
|
65
|
+
*
|
|
66
|
+
* @param absolutePathToDir A directory. If it doesn't exist `[]` is returned.
|
|
67
|
+
* @param matches A function to filter files (not directories)
|
|
68
|
+
* @returns An An array of absolute paths. Each file has its true case, except
|
|
69
|
+
* for the initial absolutePathToDir part, which preserves the given casing.
|
|
70
|
+
* No order is guaranteed.
|
|
71
|
+
*/
|
|
72
|
+
export async function getAllFilesMatching(
|
|
73
|
+
absolutePathToDir: string,
|
|
74
|
+
matches?: (absolutePathToFile: string) => boolean
|
|
75
|
+
): Promise<string[]> {
|
|
76
|
+
const dir = await readdir(absolutePathToDir);
|
|
77
|
+
|
|
78
|
+
const results = await Promise.all(
|
|
79
|
+
dir.map(async (file) => {
|
|
80
|
+
const absolutePathToFile = path.join(absolutePathToDir, file);
|
|
81
|
+
const stats = await fsPromises.stat(absolutePathToFile);
|
|
82
|
+
if (stats.isDirectory()) {
|
|
83
|
+
const files = await getAllFilesMatching(absolutePathToFile, matches);
|
|
84
|
+
return files.flat();
|
|
85
|
+
} else if (matches === undefined || matches(absolutePathToFile)) {
|
|
86
|
+
return absolutePathToFile;
|
|
87
|
+
} else {
|
|
88
|
+
return [];
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
return results.flat();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Sync version of getAllFilesMatching
|
|
98
|
+
*
|
|
99
|
+
* @see getAllFilesMatching
|
|
100
|
+
*/
|
|
101
|
+
export function getAllFilesMatchingSync(
|
|
102
|
+
absolutePathToDir: string,
|
|
103
|
+
matches?: (absolutePathToFile: string) => boolean
|
|
104
|
+
): string[] {
|
|
105
|
+
const dir = readdirSync(absolutePathToDir);
|
|
106
|
+
|
|
107
|
+
const results = dir.map((file) => {
|
|
108
|
+
const absolutePathToFile = path.join(absolutePathToDir, file);
|
|
109
|
+
const stats = fs.statSync(absolutePathToFile);
|
|
110
|
+
if (stats.isDirectory()) {
|
|
111
|
+
return getAllFilesMatchingSync(absolutePathToFile, matches).flat();
|
|
112
|
+
} else if (matches === undefined || matches(absolutePathToFile)) {
|
|
113
|
+
return absolutePathToFile;
|
|
114
|
+
} else {
|
|
115
|
+
return [];
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
return results.flat();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Returns the true case relative path of `relativePath` from `from`, without
|
|
124
|
+
* resolving symlinks.
|
|
125
|
+
*/
|
|
126
|
+
export async function getFileTrueCase(
|
|
127
|
+
from: string,
|
|
128
|
+
relativePath: string
|
|
129
|
+
): Promise<string> {
|
|
130
|
+
const dirEntries = await readdir(from);
|
|
131
|
+
|
|
132
|
+
const parts = relativePath.split(path.sep);
|
|
133
|
+
const nextDirLowerCase = parts[0].toLowerCase();
|
|
134
|
+
|
|
135
|
+
for (const dirEntry of dirEntries) {
|
|
136
|
+
if (dirEntry.toLowerCase() === nextDirLowerCase) {
|
|
137
|
+
if (parts.length === 1) {
|
|
138
|
+
return dirEntry;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return path.join(
|
|
142
|
+
dirEntry,
|
|
143
|
+
await getFileTrueCase(
|
|
144
|
+
path.join(from, dirEntry),
|
|
145
|
+
path.relative(parts[0], relativePath)
|
|
146
|
+
)
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// eslint-disable-next-line @nomiclabs/hardhat-internal-rules/only-hardhat-error
|
|
152
|
+
throw new FileNotFoundError(path.join(from, relativePath));
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Sync version of getFileTrueCase
|
|
157
|
+
*
|
|
158
|
+
* @see getFileTrueCase
|
|
159
|
+
*/
|
|
160
|
+
export function getFileTrueCaseSync(
|
|
161
|
+
from: string,
|
|
162
|
+
relativePath: string
|
|
163
|
+
): string {
|
|
164
|
+
const dirEntries = readdirSync(from);
|
|
165
|
+
|
|
166
|
+
const parts = relativePath.split(path.sep);
|
|
167
|
+
const nextDirLowerCase = parts[0].toLowerCase();
|
|
168
|
+
|
|
169
|
+
for (const dirEntry of dirEntries) {
|
|
170
|
+
if (dirEntry.toLowerCase() === nextDirLowerCase) {
|
|
171
|
+
if (parts.length === 1) {
|
|
172
|
+
return dirEntry;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return path.join(
|
|
176
|
+
dirEntry,
|
|
177
|
+
getFileTrueCaseSync(
|
|
178
|
+
path.join(from, dirEntry),
|
|
179
|
+
path.relative(parts[0], relativePath)
|
|
180
|
+
)
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// eslint-disable-next-line @nomiclabs/hardhat-internal-rules/only-hardhat-error
|
|
186
|
+
throw new FileNotFoundError(path.join(from, relativePath));
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
async function readdir(absolutePathToDir: string) {
|
|
190
|
+
try {
|
|
191
|
+
return await fsPromises.readdir(absolutePathToDir);
|
|
192
|
+
} catch (e: any) {
|
|
193
|
+
if (e.code === "ENOENT") {
|
|
194
|
+
return [];
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (e.code === "ENOTDIR") {
|
|
198
|
+
// eslint-disable-next-line @nomiclabs/hardhat-internal-rules/only-hardhat-error
|
|
199
|
+
throw new InvalidDirectoryError(absolutePathToDir, e);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// eslint-disable-next-line @nomiclabs/hardhat-internal-rules/only-hardhat-error
|
|
203
|
+
throw new FileSystemAccessError(e.message, e);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function readdirSync(absolutePathToDir: string) {
|
|
208
|
+
try {
|
|
209
|
+
return fs.readdirSync(absolutePathToDir);
|
|
210
|
+
} catch (e: any) {
|
|
211
|
+
if (e.code === "ENOENT") {
|
|
212
|
+
return [];
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (e.code === "ENOTDIR") {
|
|
216
|
+
// eslint-disable-next-line @nomiclabs/hardhat-internal-rules/only-hardhat-error
|
|
217
|
+
throw new InvalidDirectoryError(absolutePathToDir, e);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// eslint-disable-next-line @nomiclabs/hardhat-internal-rules/only-hardhat-error
|
|
221
|
+
throw new FileSystemAccessError(e.message, e);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
@@ -3,6 +3,15 @@ import type { IOptions as GlobOptions } from "glob";
|
|
|
3
3
|
import * as path from "path";
|
|
4
4
|
import util from "util";
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* DO NOT USE THIS FUNCTION. It's SLOW and its semantics are optimized for
|
|
8
|
+
* user-facing CLI globs, not traversing the FS.
|
|
9
|
+
*
|
|
10
|
+
* It's not removed because unfortunately some plugins used it, like the truffle
|
|
11
|
+
* ones.
|
|
12
|
+
*
|
|
13
|
+
* @deprecated
|
|
14
|
+
*/
|
|
6
15
|
export async function glob(
|
|
7
16
|
pattern: string,
|
|
8
17
|
options: GlobOptions = {}
|
|
@@ -12,6 +21,10 @@ export async function glob(
|
|
|
12
21
|
return files.map(path.normalize);
|
|
13
22
|
}
|
|
14
23
|
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated
|
|
26
|
+
* @see glob
|
|
27
|
+
*/
|
|
15
28
|
export function globSync(pattern: string, options: GlobOptions = {}): string[] {
|
|
16
29
|
const files = require("glob").sync(pattern, options);
|
|
17
30
|
return files.map(path.normalize);
|
|
@@ -20,7 +20,10 @@ export async function runScript(
|
|
|
20
20
|
|
|
21
21
|
const nodeArgs = [
|
|
22
22
|
...processExecArgv,
|
|
23
|
-
...getTsNodeArgsIfNeeded(
|
|
23
|
+
...getTsNodeArgsIfNeeded(
|
|
24
|
+
scriptPath,
|
|
25
|
+
extraEnvVars.HARDHAT_TYPECHECK === "true"
|
|
26
|
+
),
|
|
24
27
|
...extraNodeArgs,
|
|
25
28
|
];
|
|
26
29
|
|
|
@@ -33,7 +36,7 @@ export async function runScript(
|
|
|
33
36
|
});
|
|
34
37
|
|
|
35
38
|
childProcess.once("close", (status) => {
|
|
36
|
-
log(`Script ${scriptPath} exited with status code ${status}`);
|
|
39
|
+
log(`Script ${scriptPath} exited with status code ${status ?? "null"}`);
|
|
37
40
|
|
|
38
41
|
resolve(status as number);
|
|
39
42
|
});
|
|
@@ -90,7 +93,10 @@ function withFixedInspectArg(argv: string[]) {
|
|
|
90
93
|
return argv.map(fixIfInspectArg);
|
|
91
94
|
}
|
|
92
95
|
|
|
93
|
-
function getTsNodeArgsIfNeeded(
|
|
96
|
+
function getTsNodeArgsIfNeeded(
|
|
97
|
+
scriptPath: string,
|
|
98
|
+
shouldTypecheck: boolean
|
|
99
|
+
): string[] {
|
|
94
100
|
if (process.execArgv.includes("ts-node/register")) {
|
|
95
101
|
return [];
|
|
96
102
|
}
|
|
@@ -103,7 +109,10 @@ function getTsNodeArgsIfNeeded(scriptPath: string): string[] {
|
|
|
103
109
|
|
|
104
110
|
// If the script we are going to run is .ts we need ts-node
|
|
105
111
|
if (/\.tsx?$/i.test(scriptPath)) {
|
|
106
|
-
return [
|
|
112
|
+
return [
|
|
113
|
+
"--require",
|
|
114
|
+
`ts-node/register${shouldTypecheck ? "" : "/transpile-only"}`,
|
|
115
|
+
];
|
|
107
116
|
}
|
|
108
117
|
|
|
109
118
|
return [];
|
|
File without changes
|
package/src/profiling.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { assertHardhatInvariant } from "./internal/core/errors";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Utility to create ad-hoc profiles when computing flamegraphs. You can think
|
|
5
|
+
* of these as virtual tasks that execute the function `f`.
|
|
6
|
+
*
|
|
7
|
+
* This is an **unstable** feature, only meant for development. DO NOT use in
|
|
8
|
+
* production code nor plugins.
|
|
9
|
+
*
|
|
10
|
+
* @param name The name of the profile. Think of it as a virtual task name.
|
|
11
|
+
* @param f The function you want to profile.
|
|
12
|
+
*/
|
|
13
|
+
export async function adhocProfile<T>(
|
|
14
|
+
name: string,
|
|
15
|
+
f: () => Promise<T>
|
|
16
|
+
): Promise<T> {
|
|
17
|
+
const globalAsAny = global as any;
|
|
18
|
+
assertHardhatInvariant(
|
|
19
|
+
"adhocProfile" in globalAsAny,
|
|
20
|
+
"adhocProfile is missing. Are you running with --flamegraph?"
|
|
21
|
+
);
|
|
22
|
+
return globalAsAny.adhocProfile(name, f);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Sync version of adhocProfile
|
|
27
|
+
*
|
|
28
|
+
* @see adhocProfile
|
|
29
|
+
*/
|
|
30
|
+
export function adhocProfileSync<T>(name: string, f: () => T): T {
|
|
31
|
+
const globalAsAny = global as any;
|
|
32
|
+
assertHardhatInvariant(
|
|
33
|
+
"adhocProfileSync" in globalAsAny,
|
|
34
|
+
"adhocProfileSync is missing. Are you running with --flamegraph?"
|
|
35
|
+
);
|
|
36
|
+
return globalAsAny.adhocProfileSync(name, f);
|
|
37
|
+
}
|
package/src/register.ts
CHANGED
|
@@ -13,9 +13,6 @@ import {
|
|
|
13
13
|
disableReplWriterShowProxy,
|
|
14
14
|
isNodeCalledWithoutAScript,
|
|
15
15
|
} from "./internal/util/console";
|
|
16
|
-
import { applyWorkaround } from "./internal/util/antlr-prototype-pollution-workaround";
|
|
17
|
-
|
|
18
|
-
applyWorkaround();
|
|
19
16
|
|
|
20
17
|
if (!HardhatContext.isCreated()) {
|
|
21
18
|
require("source-map-support/register");
|
|
@@ -36,7 +33,7 @@ if (!HardhatContext.isCreated()) {
|
|
|
36
33
|
}
|
|
37
34
|
|
|
38
35
|
if (willRunWithTypescript(hardhatArguments.config)) {
|
|
39
|
-
loadTsNode(hardhatArguments.tsconfig);
|
|
36
|
+
loadTsNode(hardhatArguments.tsconfig, hardhatArguments.typecheck);
|
|
40
37
|
}
|
|
41
38
|
|
|
42
39
|
const { resolvedConfig, userConfig } = loadConfigAndTasks(hardhatArguments);
|