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.
Files changed (406) hide show
  1. package/builtin-tasks/clean.js +2 -1
  2. package/builtin-tasks/clean.js.map +1 -1
  3. package/builtin-tasks/compile.js +52 -95
  4. package/builtin-tasks/compile.js.map +1 -1
  5. package/builtin-tasks/flatten.js +2 -21
  6. package/builtin-tasks/flatten.js.map +1 -1
  7. package/builtin-tasks/node.js +1 -1
  8. package/builtin-tasks/node.js.map +1 -1
  9. package/builtin-tasks/test.js +3 -3
  10. package/builtin-tasks/test.js.map +1 -1
  11. package/builtin-tasks/utils/solidity-files-cache.d.ts.map +1 -1
  12. package/builtin-tasks/utils/solidity-files-cache.js +5 -6
  13. package/builtin-tasks/utils/solidity-files-cache.js.map +1 -1
  14. package/internal/artifacts.d.ts +3 -11
  15. package/internal/artifacts.d.ts.map +1 -1
  16. package/internal/artifacts.js +266 -133
  17. package/internal/artifacts.js.map +1 -1
  18. package/internal/cli/cli.js +26 -12
  19. package/internal/cli/cli.js.map +1 -1
  20. package/internal/core/config/config-loading.js +2 -2
  21. package/internal/core/config/config-loading.js.map +1 -1
  22. package/internal/core/config/config-resolution.d.ts.map +1 -1
  23. package/internal/core/config/config-resolution.js +11 -31
  24. package/internal/core/config/config-resolution.js.map +1 -1
  25. package/internal/core/config/default-config.js +1 -1
  26. package/internal/core/config/default-config.js.map +1 -1
  27. package/internal/core/errors-list.d.ts +7 -0
  28. package/internal/core/errors-list.d.ts.map +1 -1
  29. package/internal/core/errors-list.js +28 -11
  30. package/internal/core/errors-list.js.map +1 -1
  31. package/internal/core/errors.d.ts +2 -1
  32. package/internal/core/errors.d.ts.map +1 -1
  33. package/internal/core/errors.js +5 -1
  34. package/internal/core/errors.js.map +1 -1
  35. package/internal/core/execution-mode.d.ts.map +1 -1
  36. package/internal/core/execution-mode.js +2 -21
  37. package/internal/core/execution-mode.js.map +1 -1
  38. package/internal/core/flamegraph.d.ts +4 -0
  39. package/internal/core/flamegraph.d.ts.map +1 -1
  40. package/internal/core/flamegraph.js +13 -3
  41. package/internal/core/flamegraph.js.map +1 -1
  42. package/internal/core/jsonrpc/types/base-types.d.ts.map +1 -1
  43. package/internal/core/jsonrpc/types/base-types.js +12 -12
  44. package/internal/core/jsonrpc/types/base-types.js.map +1 -1
  45. package/internal/core/params/hardhat-params.d.ts.map +1 -1
  46. package/internal/core/params/hardhat-params.js +18 -0
  47. package/internal/core/params/hardhat-params.js.map +1 -1
  48. package/internal/core/providers/accounts.js +9 -9
  49. package/internal/core/providers/accounts.js.map +1 -1
  50. package/internal/core/providers/construction.d.ts.map +1 -1
  51. package/internal/core/providers/construction.js +5 -6
  52. package/internal/core/providers/construction.js.map +1 -1
  53. package/internal/core/providers/gas-providers.d.ts +2 -2
  54. package/internal/core/providers/util.js +1 -1
  55. package/internal/core/providers/util.js.map +1 -1
  56. package/internal/core/runtime-environment.d.ts +6 -0
  57. package/internal/core/runtime-environment.d.ts.map +1 -1
  58. package/internal/core/runtime-environment.js +72 -6
  59. package/internal/core/runtime-environment.js.map +1 -1
  60. package/internal/core/typescript-support.d.ts +1 -1
  61. package/internal/core/typescript-support.d.ts.map +1 -1
  62. package/internal/core/typescript-support.js +6 -2
  63. package/internal/core/typescript-support.js.map +1 -1
  64. package/internal/hardhat-network/jsonrpc/client.d.ts +1 -1
  65. package/internal/hardhat-network/jsonrpc/client.d.ts.map +1 -1
  66. package/internal/hardhat-network/jsonrpc/client.js +10 -10
  67. package/internal/hardhat-network/jsonrpc/client.js.map +1 -1
  68. package/internal/hardhat-network/provider/BlockchainBase.d.ts +4 -4
  69. package/internal/hardhat-network/provider/BlockchainBase.d.ts.map +1 -1
  70. package/internal/hardhat-network/provider/BlockchainBase.js +31 -12
  71. package/internal/hardhat-network/provider/BlockchainBase.js.map +1 -1
  72. package/internal/hardhat-network/provider/BlockchainData.d.ts +3 -3
  73. package/internal/hardhat-network/provider/BlockchainData.d.ts.map +1 -1
  74. package/internal/hardhat-network/provider/BlockchainData.js +15 -15
  75. package/internal/hardhat-network/provider/BlockchainData.js.map +1 -1
  76. package/internal/hardhat-network/provider/HardhatBlockchain.d.ts +3 -3
  77. package/internal/hardhat-network/provider/HardhatBlockchain.d.ts.map +1 -1
  78. package/internal/hardhat-network/provider/HardhatBlockchain.js +2 -2
  79. package/internal/hardhat-network/provider/HardhatBlockchain.js.map +1 -1
  80. package/internal/hardhat-network/provider/PoolState.d.ts +1 -1
  81. package/internal/hardhat-network/provider/PoolState.d.ts.map +1 -1
  82. package/internal/hardhat-network/provider/PoolState.js +21 -2
  83. package/internal/hardhat-network/provider/PoolState.js.map +1 -1
  84. package/internal/hardhat-network/provider/TransactionQueue.d.ts +1 -1
  85. package/internal/hardhat-network/provider/TransactionQueue.d.ts.map +1 -1
  86. package/internal/hardhat-network/provider/TransactionQueue.js +22 -3
  87. package/internal/hardhat-network/provider/TransactionQueue.js.map +1 -1
  88. package/internal/hardhat-network/provider/TxPool.d.ts +4 -4
  89. package/internal/hardhat-network/provider/TxPool.d.ts.map +1 -1
  90. package/internal/hardhat-network/provider/TxPool.js +35 -16
  91. package/internal/hardhat-network/provider/TxPool.js.map +1 -1
  92. package/internal/hardhat-network/provider/ethereumjs-workarounds.js +4 -4
  93. package/internal/hardhat-network/provider/ethereumjs-workarounds.js.map +1 -1
  94. package/internal/hardhat-network/provider/filter.d.ts +1 -1
  95. package/internal/hardhat-network/provider/filter.d.ts.map +1 -1
  96. package/internal/hardhat-network/provider/filter.js +3 -3
  97. package/internal/hardhat-network/provider/filter.js.map +1 -1
  98. package/internal/hardhat-network/provider/fork/ForkBlockchain.d.ts +3 -3
  99. package/internal/hardhat-network/provider/fork/ForkBlockchain.d.ts.map +1 -1
  100. package/internal/hardhat-network/provider/fork/ForkBlockchain.js +13 -12
  101. package/internal/hardhat-network/provider/fork/ForkBlockchain.js.map +1 -1
  102. package/internal/hardhat-network/provider/fork/ForkStateManager.d.ts +3 -5
  103. package/internal/hardhat-network/provider/fork/ForkStateManager.d.ts.map +1 -1
  104. package/internal/hardhat-network/provider/fork/ForkStateManager.js +36 -40
  105. package/internal/hardhat-network/provider/fork/ForkStateManager.js.map +1 -1
  106. package/internal/hardhat-network/provider/fork/rpcToBlockData.d.ts +1 -1
  107. package/internal/hardhat-network/provider/fork/rpcToBlockData.d.ts.map +1 -1
  108. package/internal/hardhat-network/provider/fork/rpcToTxData.d.ts +2 -2
  109. package/internal/hardhat-network/provider/fork/rpcToTxData.d.ts.map +1 -1
  110. package/internal/hardhat-network/provider/fork/rpcToTxData.js.map +1 -1
  111. package/internal/hardhat-network/provider/modules/eth.d.ts +1 -1
  112. package/internal/hardhat-network/provider/modules/eth.d.ts.map +1 -1
  113. package/internal/hardhat-network/provider/modules/eth.js +22 -22
  114. package/internal/hardhat-network/provider/modules/eth.js.map +1 -1
  115. package/internal/hardhat-network/provider/modules/hardhat.d.ts +2 -0
  116. package/internal/hardhat-network/provider/modules/hardhat.d.ts.map +1 -1
  117. package/internal/hardhat-network/provider/modules/hardhat.js +20 -6
  118. package/internal/hardhat-network/provider/modules/hardhat.js.map +1 -1
  119. package/internal/hardhat-network/provider/modules/logger.d.ts +2 -2
  120. package/internal/hardhat-network/provider/modules/logger.d.ts.map +1 -1
  121. package/internal/hardhat-network/provider/modules/logger.js +14 -14
  122. package/internal/hardhat-network/provider/modules/logger.js.map +1 -1
  123. package/internal/hardhat-network/provider/modules/net.d.ts +1 -1
  124. package/internal/hardhat-network/provider/modules/net.d.ts.map +1 -1
  125. package/internal/hardhat-network/provider/modules/personal.js +3 -3
  126. package/internal/hardhat-network/provider/modules/personal.js.map +1 -1
  127. package/internal/hardhat-network/provider/modules/web3.d.ts.map +1 -1
  128. package/internal/hardhat-network/provider/modules/web3.js +4 -5
  129. package/internal/hardhat-network/provider/modules/web3.js.map +1 -1
  130. package/internal/hardhat-network/provider/node-types.d.ts +4 -4
  131. package/internal/hardhat-network/provider/node-types.d.ts.map +1 -1
  132. package/internal/hardhat-network/provider/node.d.ts +5 -4
  133. package/internal/hardhat-network/provider/node.d.ts.map +1 -1
  134. package/internal/hardhat-network/provider/node.js +71 -49
  135. package/internal/hardhat-network/provider/node.js.map +1 -1
  136. package/internal/hardhat-network/provider/output.d.ts +4 -4
  137. package/internal/hardhat-network/provider/output.d.ts.map +1 -1
  138. package/internal/hardhat-network/provider/output.js +24 -5
  139. package/internal/hardhat-network/provider/output.js.map +1 -1
  140. package/internal/hardhat-network/provider/provider.d.ts +2 -2
  141. package/internal/hardhat-network/provider/provider.d.ts.map +1 -1
  142. package/internal/hardhat-network/provider/provider.js +3 -3
  143. package/internal/hardhat-network/provider/provider.js.map +1 -1
  144. package/internal/hardhat-network/provider/return-data.d.ts +1 -1
  145. package/internal/hardhat-network/provider/return-data.d.ts.map +1 -1
  146. package/internal/hardhat-network/provider/return-data.js +5 -4
  147. package/internal/hardhat-network/provider/return-data.js.map +1 -1
  148. package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.d.ts +4 -4
  149. package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.d.ts.map +1 -1
  150. package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.js +8 -8
  151. package/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.js.map +1 -1
  152. package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.d.ts +3 -3
  153. package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.d.ts.map +1 -1
  154. package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.js +8 -8
  155. package/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.js.map +1 -1
  156. package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.d.ts +3 -3
  157. package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.d.ts.map +1 -1
  158. package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.js +5 -5
  159. package/internal/hardhat-network/provider/transactions/FakeSenderTransaction.js.map +1 -1
  160. package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.d.ts +4 -4
  161. package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.d.ts.map +1 -1
  162. package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.js +25 -6
  163. package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.js.map +1 -1
  164. package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.d.ts +3 -3
  165. package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.d.ts.map +1 -1
  166. package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.js +25 -6
  167. package/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.js.map +1 -1
  168. package/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.d.ts +3 -3
  169. package/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.d.ts.map +1 -1
  170. package/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.js +2 -2
  171. package/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.js.map +1 -1
  172. package/internal/hardhat-network/provider/types/HardhatBlockchainInterface.d.ts +2 -2
  173. package/internal/hardhat-network/provider/types/HardhatBlockchainInterface.d.ts.map +1 -1
  174. package/internal/hardhat-network/provider/utils/makeAccount.d.ts +1 -1
  175. package/internal/hardhat-network/provider/utils/makeAccount.d.ts.map +1 -1
  176. package/internal/hardhat-network/provider/utils/makeAccount.js +4 -4
  177. package/internal/hardhat-network/provider/utils/makeAccount.js.map +1 -1
  178. package/internal/hardhat-network/provider/utils/makeCommon.d.ts +1 -1
  179. package/internal/hardhat-network/provider/utils/makeCommon.d.ts.map +1 -1
  180. package/internal/hardhat-network/provider/utils/makeCommon.js +2 -2
  181. package/internal/hardhat-network/provider/utils/makeCommon.js.map +1 -1
  182. package/internal/hardhat-network/provider/utils/makeStateTrie.d.ts +1 -1
  183. package/internal/hardhat-network/provider/utils/makeStateTrie.d.ts.map +1 -1
  184. package/internal/hardhat-network/provider/utils/makeStateTrie.js +4 -4
  185. package/internal/hardhat-network/provider/utils/makeStateTrie.js.map +1 -1
  186. package/internal/hardhat-network/provider/utils/putGenesisBlock.d.ts +3 -3
  187. package/internal/hardhat-network/provider/utils/putGenesisBlock.d.ts.map +1 -1
  188. package/internal/hardhat-network/provider/utils/putGenesisBlock.js +4 -4
  189. package/internal/hardhat-network/provider/utils/putGenesisBlock.js.map +1 -1
  190. package/internal/hardhat-network/provider/utils/random.d.ts +2 -1
  191. package/internal/hardhat-network/provider/utils/random.d.ts.map +1 -1
  192. package/internal/hardhat-network/provider/utils/random.js +10 -9
  193. package/internal/hardhat-network/provider/utils/random.js.map +1 -1
  194. package/internal/hardhat-network/provider/utils/reorganizeTransactionsLists.js +21 -2
  195. package/internal/hardhat-network/provider/utils/reorganizeTransactionsLists.js.map +1 -1
  196. package/internal/hardhat-network/provider/utils/txMapToArray.d.ts +1 -1
  197. package/internal/hardhat-network/provider/utils/txMapToArray.d.ts.map +1 -1
  198. package/internal/hardhat-network/stack-traces/consoleLogger.js +45 -45
  199. package/internal/hardhat-network/stack-traces/consoleLogger.js.map +1 -1
  200. package/internal/hardhat-network/stack-traces/constants.d.ts +1 -1
  201. package/internal/hardhat-network/stack-traces/constants.d.ts.map +1 -1
  202. package/internal/hardhat-network/stack-traces/constants.js +1 -1
  203. package/internal/hardhat-network/stack-traces/constants.js.map +1 -1
  204. package/internal/hardhat-network/stack-traces/contracts-identifier.js +2 -2
  205. package/internal/hardhat-network/stack-traces/contracts-identifier.js.map +1 -1
  206. package/internal/hardhat-network/stack-traces/debug.js +13 -13
  207. package/internal/hardhat-network/stack-traces/debug.js.map +1 -1
  208. package/internal/hardhat-network/stack-traces/error-inferrer.js +2 -2
  209. package/internal/hardhat-network/stack-traces/error-inferrer.js.map +1 -1
  210. package/internal/hardhat-network/stack-traces/message-trace.d.ts +1 -1
  211. package/internal/hardhat-network/stack-traces/message-trace.d.ts.map +1 -1
  212. package/internal/hardhat-network/stack-traces/model.js +6 -6
  213. package/internal/hardhat-network/stack-traces/model.js.map +1 -1
  214. package/internal/hardhat-network/stack-traces/panic-errors.d.ts +1 -1
  215. package/internal/hardhat-network/stack-traces/panic-errors.js +9 -9
  216. package/internal/hardhat-network/stack-traces/panic-errors.js.map +1 -1
  217. package/internal/hardhat-network/stack-traces/solidity-errors.js +3 -3
  218. package/internal/hardhat-network/stack-traces/solidity-errors.js.map +1 -1
  219. package/internal/hardhat-network/stack-traces/solidity-stack-trace.d.ts +1 -1
  220. package/internal/hardhat-network/stack-traces/solidityTracer.d.ts +0 -2
  221. package/internal/hardhat-network/stack-traces/solidityTracer.d.ts.map +1 -1
  222. package/internal/hardhat-network/stack-traces/solidityTracer.js +2 -4
  223. package/internal/hardhat-network/stack-traces/solidityTracer.js.map +1 -1
  224. package/internal/hardhat-network/stack-traces/vm-debug-tracer.d.ts +1 -1
  225. package/internal/hardhat-network/stack-traces/vm-debug-tracer.d.ts.map +1 -1
  226. package/internal/hardhat-network/stack-traces/vm-debug-tracer.js +27 -25
  227. package/internal/hardhat-network/stack-traces/vm-debug-tracer.js.map +1 -1
  228. package/internal/hardhat-network/stack-traces/vm-tracer.d.ts +2 -2
  229. package/internal/hardhat-network/stack-traces/vm-tracer.d.ts.map +1 -1
  230. package/internal/hardhat-network/stack-traces/vm-tracer.js +15 -12
  231. package/internal/hardhat-network/stack-traces/vm-tracer.js.map +1 -1
  232. package/internal/lib/hardhat-lib.d.ts.map +1 -1
  233. package/internal/lib/hardhat-lib.js +0 -2
  234. package/internal/lib/hardhat-lib.js.map +1 -1
  235. package/internal/solidity/compilation-job.d.ts.map +1 -1
  236. package/internal/solidity/compilation-job.js +6 -7
  237. package/internal/solidity/compilation-job.js.map +1 -1
  238. package/internal/solidity/compiler/downloader.d.ts +66 -40
  239. package/internal/solidity/compiler/downloader.d.ts.map +1 -1
  240. package/internal/solidity/compiler/downloader.js +180 -154
  241. package/internal/solidity/compiler/downloader.js.map +1 -1
  242. package/internal/solidity/compiler/index.d.ts +8 -4
  243. package/internal/solidity/compiler/index.d.ts.map +1 -1
  244. package/internal/solidity/compiler/index.js +1 -1
  245. package/internal/solidity/compiler/index.js.map +1 -1
  246. package/internal/solidity/dependencyGraph.d.ts.map +1 -1
  247. package/internal/solidity/dependencyGraph.js +3 -5
  248. package/internal/solidity/dependencyGraph.js.map +1 -1
  249. package/internal/solidity/parse.d.ts.map +1 -1
  250. package/internal/solidity/parse.js +2 -58
  251. package/internal/solidity/parse.js.map +1 -1
  252. package/internal/solidity/resolver.d.ts +1 -0
  253. package/internal/solidity/resolver.d.ts.map +1 -1
  254. package/internal/solidity/resolver.js +33 -8
  255. package/internal/solidity/resolver.js.map +1 -1
  256. package/internal/util/bigint.d.ts +13 -24
  257. package/internal/util/bigint.d.ts.map +1 -1
  258. package/internal/util/bigint.js +22 -29
  259. package/internal/util/bigint.js.map +1 -1
  260. package/internal/util/download.d.ts.map +1 -1
  261. package/internal/util/download.js +1 -1
  262. package/internal/util/download.js.map +1 -1
  263. package/internal/util/fs-utils.d.ts +26 -9
  264. package/internal/util/fs-utils.d.ts.map +1 -1
  265. package/internal/util/fs-utils.js +111 -68
  266. package/internal/util/fs-utils.js.map +1 -1
  267. package/internal/util/glob.d.ts +13 -0
  268. package/internal/util/glob.d.ts.map +1 -1
  269. package/internal/util/glob.js +13 -0
  270. package/internal/util/glob.js.map +1 -1
  271. package/internal/util/keccak.d.ts +3 -0
  272. package/internal/util/keccak.d.ts.map +1 -0
  273. package/internal/util/keccak.js +12 -0
  274. package/internal/util/keccak.js.map +1 -0
  275. package/internal/util/scripts-runner.d.ts.map +1 -1
  276. package/internal/util/scripts-runner.js +7 -4
  277. package/internal/util/scripts-runner.js.map +1 -1
  278. package/package.json +15 -15
  279. package/register.js +1 -3
  280. package/register.js.map +1 -1
  281. package/sample-projects/javascript/contracts/Lock.sol +3 -3
  282. package/sample-projects/typescript/contracts/Lock.sol +3 -3
  283. package/src/builtin-tasks/clean.ts +9 -6
  284. package/src/builtin-tasks/compile.ts +96 -128
  285. package/src/builtin-tasks/flatten.ts +2 -3
  286. package/src/builtin-tasks/node.ts +2 -2
  287. package/src/builtin-tasks/test.ts +7 -3
  288. package/src/builtin-tasks/utils/solidity-files-cache.ts +9 -8
  289. package/src/internal/artifacts.ts +392 -182
  290. package/src/internal/cli/cli.ts +43 -17
  291. package/src/internal/core/config/config-loading.ts +1 -1
  292. package/src/internal/core/config/config-resolution.ts +12 -24
  293. package/src/internal/core/config/default-config.ts +1 -1
  294. package/src/internal/core/errors-list.ts +29 -13
  295. package/src/internal/core/errors.ts +10 -2
  296. package/src/internal/core/execution-mode.ts +2 -3
  297. package/src/internal/core/flamegraph.ts +270 -0
  298. package/src/internal/core/jsonrpc/types/base-types.ts +7 -3
  299. package/src/internal/core/params/hardhat-params.ts +18 -0
  300. package/src/internal/core/providers/accounts.ts +8 -8
  301. package/src/internal/core/providers/construction.ts +10 -8
  302. package/src/internal/core/providers/gas-providers.ts +2 -2
  303. package/src/internal/core/providers/util.ts +1 -1
  304. package/src/internal/core/runtime-environment.ts +103 -10
  305. package/src/internal/core/task-profiling.ts +56 -0
  306. package/src/internal/core/typescript-support.ts +11 -2
  307. package/src/internal/hardhat-network/jsonrpc/client.ts +1 -1
  308. package/src/internal/hardhat-network/provider/BlockchainBase.ts +6 -6
  309. package/src/internal/hardhat-network/provider/BlockchainData.ts +5 -5
  310. package/src/internal/hardhat-network/provider/HardhatBlockchain.ts +4 -4
  311. package/src/internal/hardhat-network/provider/PoolState.ts +2 -2
  312. package/src/internal/hardhat-network/provider/TransactionQueue.ts +2 -2
  313. package/src/internal/hardhat-network/provider/TxPool.ts +12 -5
  314. package/src/internal/hardhat-network/provider/ethereumjs-workarounds.ts +3 -3
  315. package/src/internal/hardhat-network/provider/filter.ts +2 -2
  316. package/src/internal/hardhat-network/provider/fork/ForkBlockchain.ts +10 -10
  317. package/src/internal/hardhat-network/provider/fork/ForkStateManager.ts +12 -18
  318. package/src/internal/hardhat-network/provider/fork/rpcToBlockData.ts +1 -1
  319. package/src/internal/hardhat-network/provider/fork/rpcToTxData.ts +5 -2
  320. package/src/internal/hardhat-network/provider/modules/eth.ts +10 -6
  321. package/src/internal/hardhat-network/provider/modules/hardhat.ts +25 -1
  322. package/src/internal/hardhat-network/provider/modules/logger.ts +3 -3
  323. package/src/internal/hardhat-network/provider/modules/net.ts +1 -1
  324. package/src/internal/hardhat-network/provider/modules/personal.ts +1 -1
  325. package/src/internal/hardhat-network/provider/modules/web3.ts +4 -6
  326. package/src/internal/hardhat-network/provider/node-types.ts +6 -6
  327. package/src/internal/hardhat-network/provider/node.ts +25 -12
  328. package/src/internal/hardhat-network/provider/output.ts +6 -6
  329. package/src/internal/hardhat-network/provider/provider.ts +7 -6
  330. package/src/internal/hardhat-network/provider/return-data.ts +9 -5
  331. package/src/internal/hardhat-network/provider/transactions/FakeSenderAccessListEIP2930Transaction.ts +9 -5
  332. package/src/internal/hardhat-network/provider/transactions/FakeSenderEIP1559Transaction.ts +8 -4
  333. package/src/internal/hardhat-network/provider/transactions/FakeSenderTransaction.ts +4 -4
  334. package/src/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP1559Transaction.ts +8 -5
  335. package/src/internal/hardhat-network/provider/transactions/ReadOnlyValidEIP2930Transaction.ts +4 -4
  336. package/src/internal/hardhat-network/provider/transactions/ReadOnlyValidTransaction.ts +3 -3
  337. package/src/internal/hardhat-network/provider/types/HardhatBlockchainInterface.ts +2 -2
  338. package/src/internal/hardhat-network/provider/utils/makeAccount.ts +6 -1
  339. package/src/internal/hardhat-network/provider/utils/makeCommon.ts +1 -1
  340. package/src/internal/hardhat-network/provider/utils/makeStateTrie.ts +7 -3
  341. package/src/internal/hardhat-network/provider/utils/putGenesisBlock.ts +6 -6
  342. package/src/internal/hardhat-network/provider/utils/random.ts +17 -14
  343. package/src/internal/hardhat-network/provider/utils/reorganizeTransactionsLists.ts +1 -1
  344. package/src/internal/hardhat-network/stack-traces/consoleLogger.ts +1 -1
  345. package/src/internal/hardhat-network/stack-traces/constants.ts +2 -0
  346. package/src/internal/hardhat-network/stack-traces/contracts-identifier.ts +1 -1
  347. package/src/internal/hardhat-network/stack-traces/debug.ts +1 -1
  348. package/src/internal/hardhat-network/stack-traces/error-inferrer.ts +3 -3
  349. package/src/internal/hardhat-network/stack-traces/message-trace.ts +1 -1
  350. package/src/internal/hardhat-network/stack-traces/model.ts +1 -1
  351. package/src/internal/hardhat-network/stack-traces/panic-errors.ts +11 -11
  352. package/src/internal/hardhat-network/stack-traces/solidity-errors.ts +1 -1
  353. package/src/internal/hardhat-network/stack-traces/solidity-stack-trace.ts +1 -1
  354. package/src/internal/hardhat-network/stack-traces/solidityTracer.ts +1 -4
  355. package/src/internal/hardhat-network/stack-traces/vm-debug-tracer.ts +31 -17
  356. package/src/internal/hardhat-network/stack-traces/vm-tracer.ts +29 -14
  357. package/src/internal/lib/hardhat-lib.ts +0 -3
  358. package/src/internal/solidity/compilation-job.ts +11 -11
  359. package/src/internal/solidity/compiler/downloader.ts +271 -243
  360. package/src/internal/solidity/compiler/index.ts +13 -7
  361. package/src/internal/solidity/dependencyGraph.ts +12 -8
  362. package/src/internal/solidity/parse.ts +4 -70
  363. package/src/internal/solidity/resolver.ts +36 -8
  364. package/src/internal/util/bigint.ts +25 -43
  365. package/src/internal/util/download.ts +2 -2
  366. package/src/internal/util/fs-utils.ts +223 -0
  367. package/src/internal/util/glob.ts +13 -0
  368. package/src/internal/util/keccak.ts +5 -0
  369. package/src/internal/util/scripts-runner.ts +13 -4
  370. package/src/internal/util/wei-values.ts +1 -1
  371. package/src/internal/{hardhat-network/vendor → vendor}/await-semaphore/index.ts +0 -0
  372. package/src/profiling.ts +37 -0
  373. package/src/register.ts +1 -4
  374. package/src/types/artifacts.ts +21 -0
  375. package/src/types/config.ts +7 -7
  376. package/src/types/runtime.ts +2 -0
  377. package/src/utils/source-names.ts +36 -26
  378. package/types/artifacts.d.ts +19 -0
  379. package/types/artifacts.d.ts.map +1 -1
  380. package/types/config.d.ts +7 -7
  381. package/types/runtime.d.ts +2 -0
  382. package/types/runtime.d.ts.map +1 -1
  383. package/utils/source-names.d.ts.map +1 -1
  384. package/utils/source-names.js +25 -36
  385. package/utils/source-names.js.map +1 -1
  386. package/internal/hardhat-network/provider/fork/random.d.ts +0 -7
  387. package/internal/hardhat-network/provider/fork/random.d.ts.map +0 -1
  388. package/internal/hardhat-network/provider/fork/random.js +0 -32
  389. package/internal/hardhat-network/provider/fork/random.js.map +0 -1
  390. package/internal/hardhat-network/provider/utils/bnToHex.d.ts +0 -3
  391. package/internal/hardhat-network/provider/utils/bnToHex.d.ts.map +0 -1
  392. package/internal/hardhat-network/provider/utils/bnToHex.js +0 -9
  393. package/internal/hardhat-network/provider/utils/bnToHex.js.map +0 -1
  394. package/internal/hardhat-network/provider/utils/makeForkCommon.d.ts +0 -4
  395. package/internal/hardhat-network/provider/utils/makeForkCommon.d.ts.map +0 -1
  396. package/internal/hardhat-network/provider/utils/makeForkCommon.js +0 -16
  397. package/internal/hardhat-network/provider/utils/makeForkCommon.js.map +0 -1
  398. package/internal/hardhat-network/vendor/await-semaphore/index.d.ts +0 -12
  399. package/internal/hardhat-network/vendor/await-semaphore/index.d.ts.map +0 -1
  400. package/internal/hardhat-network/vendor/await-semaphore/index.js +0 -64
  401. package/internal/hardhat-network/vendor/await-semaphore/index.js.map +0 -1
  402. package/internal/util/antlr-prototype-pollution-workaround.d.ts +0 -16
  403. package/internal/util/antlr-prototype-pollution-workaround.d.ts.map +0 -1
  404. package/internal/util/antlr-prototype-pollution-workaround.js +0 -22
  405. package/internal/util/antlr-prototype-pollution-workaround.js.map +0 -1
  406. package/src/internal/util/antlr-prototype-pollution-workaround.ts +0 -17
@@ -1,9 +1,7 @@
1
- import debug from "debug";
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
- let result;
33
- try {
34
- const parser = require("@solidity-parser/parser");
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
- return this._resolveLocalSourceName(sourceName);
90
+ resolvedFile = await this._resolveLocalSourceName(sourceName);
91
+ } else {
92
+ resolvedFile = await this._resolveLibrarySourceName(sourceName);
81
93
  }
82
94
 
83
- return this._resolveLibrarySourceName(sourceName);
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
- if (!this._isRelativeImport(imported)) {
120
- return await this.resolveSourceName(normalizeSourceName(imported));
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 sourceName = await this._relativeImportToSourceName(from, imported);
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
- return await this._resolveLocalSourceName(sourceName);
157
+ resolvedFile = await this._resolveLocalSourceName(sourceName);
158
+ } else {
159
+ resolvedFile = await this.resolveSourceName(sourceName);
133
160
  }
134
161
 
135
- return await this.resolveSourceName(sourceName);
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 fsExtra.realpath(path.join(nodeModulesPath, sourceName)),
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
- function mapNumberToBigInt<T>(x: number | T): bigint | T {
35
- if (typeof x === "number") {
36
- return BigInt(x);
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 toWord(x: bigint | number): string {
51
- return x.toString(16).padStart(64, "0");
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(x: BigIntLike | undefined): bigint | undefined {
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
- return bufferToHex(toBuffer(x));
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
- export const BigIntUtils = {
74
- min,
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);
@@ -0,0 +1,5 @@
1
+ import createKeccakHash from "keccak";
2
+
3
+ export function keccak256(data: Buffer): Buffer {
4
+ return createKeccakHash("keccak256").update(data).digest();
5
+ }
@@ -20,7 +20,10 @@ export async function runScript(
20
20
 
21
21
  const nodeArgs = [
22
22
  ...processExecArgv,
23
- ...getTsNodeArgsIfNeeded(scriptPath),
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(scriptPath: string): string[] {
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 ["--require", "ts-node/register"];
112
+ return [
113
+ "--require",
114
+ `ts-node/register${shouldTypecheck ? "" : "/transpile-only"}`,
115
+ ];
107
116
  }
108
117
 
109
118
  return [];
@@ -17,7 +17,7 @@ export function weiToHumanReadableString(wei: bigint | number): string {
17
17
  return "0 ETH";
18
18
  }
19
19
 
20
- if (wei < 10_0000n) {
20
+ if (wei < 100_000n) {
21
21
  return `${wei.toString()} wei`;
22
22
  }
23
23
 
@@ -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);