hardhat 2.6.5 → 2.7.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 (144) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/builtin-tasks/compile.js +9 -0
  3. package/builtin-tasks/compile.js.map +1 -1
  4. package/builtin-tasks/node.js +26 -9
  5. package/builtin-tasks/node.js.map +1 -1
  6. package/internal/artifacts.d.ts +49 -0
  7. package/internal/artifacts.d.ts.map +1 -1
  8. package/internal/artifacts.js +191 -55
  9. package/internal/artifacts.js.map +1 -1
  10. package/internal/cli/analytics.js +2 -2
  11. package/internal/cli/analytics.js.map +1 -1
  12. package/internal/cli/cli.js +3 -1
  13. package/internal/cli/cli.js.map +1 -1
  14. package/internal/constants.d.ts +2 -0
  15. package/internal/constants.d.ts.map +1 -1
  16. package/internal/constants.js +3 -1
  17. package/internal/constants.js.map +1 -1
  18. package/internal/core/config/config-loading.d.ts.map +1 -1
  19. package/internal/core/config/config-loading.js +16 -2
  20. package/internal/core/config/config-loading.js.map +1 -1
  21. package/internal/core/config/config-resolution.d.ts.map +1 -1
  22. package/internal/core/config/config-resolution.js +21 -0
  23. package/internal/core/config/config-resolution.js.map +1 -1
  24. package/internal/core/config/config-validation.d.ts +1 -0
  25. package/internal/core/config/config-validation.d.ts.map +1 -1
  26. package/internal/core/config/config-validation.js +88 -13
  27. package/internal/core/config/config-validation.js.map +1 -1
  28. package/internal/core/config/default-config.d.ts +1 -0
  29. package/internal/core/config/default-config.d.ts.map +1 -1
  30. package/internal/core/config/default-config.js +11 -4
  31. package/internal/core/config/default-config.js.map +1 -1
  32. package/internal/core/errors-list.d.ts +14 -0
  33. package/internal/core/errors-list.d.ts.map +1 -1
  34. package/internal/core/errors-list.js +21 -2
  35. package/internal/core/errors-list.js.map +1 -1
  36. package/internal/core/jsonrpc/types/output/log.d.ts +1 -0
  37. package/internal/core/jsonrpc/types/output/log.d.ts.map +1 -1
  38. package/internal/core/jsonrpc/types/output/log.js +1 -0
  39. package/internal/core/jsonrpc/types/output/log.js.map +1 -1
  40. package/internal/core/jsonrpc/types/output/receipt.d.ts +1 -0
  41. package/internal/core/jsonrpc/types/output/receipt.d.ts.map +1 -1
  42. package/internal/core/params/hardhat-params.js +2 -2
  43. package/internal/core/params/hardhat-params.js.map +1 -1
  44. package/internal/core/providers/accounts.d.ts.map +1 -1
  45. package/internal/core/providers/accounts.js +14 -0
  46. package/internal/core/providers/accounts.js.map +1 -1
  47. package/internal/core/providers/construction.d.ts.map +1 -1
  48. package/internal/core/providers/construction.js +4 -2
  49. package/internal/core/providers/construction.js.map +1 -1
  50. package/internal/core/providers/gas-providers.d.ts.map +1 -1
  51. package/internal/core/providers/gas-providers.js +1 -1
  52. package/internal/core/providers/gas-providers.js.map +1 -1
  53. package/internal/core/typescript-support.d.ts +1 -1
  54. package/internal/core/typescript-support.d.ts.map +1 -1
  55. package/internal/core/typescript-support.js +4 -1
  56. package/internal/core/typescript-support.js.map +1 -1
  57. package/internal/hardhat-network/jsonrpc/client.d.ts +2 -0
  58. package/internal/hardhat-network/jsonrpc/client.d.ts.map +1 -1
  59. package/internal/hardhat-network/provider/TransactionQueue.d.ts +2 -1
  60. package/internal/hardhat-network/provider/TransactionQueue.d.ts.map +1 -1
  61. package/internal/hardhat-network/provider/TransactionQueue.js +16 -2
  62. package/internal/hardhat-network/provider/TransactionQueue.js.map +1 -1
  63. package/internal/hardhat-network/provider/fork/ForkBlockchain.d.ts.map +1 -1
  64. package/internal/hardhat-network/provider/fork/ForkBlockchain.js +1 -3
  65. package/internal/hardhat-network/provider/fork/ForkBlockchain.js.map +1 -1
  66. package/internal/hardhat-network/provider/modules/hardhat.d.ts +3 -0
  67. package/internal/hardhat-network/provider/modules/hardhat.d.ts.map +1 -1
  68. package/internal/hardhat-network/provider/modules/hardhat.js +16 -0
  69. package/internal/hardhat-network/provider/modules/hardhat.js.map +1 -1
  70. package/internal/hardhat-network/provider/modules/personal.d.ts +9 -0
  71. package/internal/hardhat-network/provider/modules/personal.d.ts.map +1 -0
  72. package/internal/hardhat-network/provider/modules/personal.js +31 -0
  73. package/internal/hardhat-network/provider/modules/personal.js.map +1 -0
  74. package/internal/hardhat-network/provider/node-types.d.ts +5 -0
  75. package/internal/hardhat-network/provider/node-types.d.ts.map +1 -1
  76. package/internal/hardhat-network/provider/node-types.js.map +1 -1
  77. package/internal/hardhat-network/provider/node.d.ts +4 -1
  78. package/internal/hardhat-network/provider/node.d.ts.map +1 -1
  79. package/internal/hardhat-network/provider/node.js +42 -17
  80. package/internal/hardhat-network/provider/node.js.map +1 -1
  81. package/internal/hardhat-network/provider/output.d.ts +1 -1
  82. package/internal/hardhat-network/provider/output.d.ts.map +1 -1
  83. package/internal/hardhat-network/provider/output.js +9 -6
  84. package/internal/hardhat-network/provider/output.js.map +1 -1
  85. package/internal/hardhat-network/provider/provider.d.ts +6 -2
  86. package/internal/hardhat-network/provider/provider.d.ts.map +1 -1
  87. package/internal/hardhat-network/provider/provider.js +12 -2
  88. package/internal/hardhat-network/provider/provider.js.map +1 -1
  89. package/internal/hardhat-network/stack-traces/error-inferrer.d.ts.map +1 -1
  90. package/internal/hardhat-network/stack-traces/error-inferrer.js +14 -0
  91. package/internal/hardhat-network/stack-traces/error-inferrer.js.map +1 -1
  92. package/internal/hardhat-network/stack-traces/solidityTracer.d.ts +1 -1
  93. package/internal/hardhat-network/stack-traces/solidityTracer.js +1 -1
  94. package/internal/lib/hardhat-lib.d.ts.map +1 -1
  95. package/internal/lib/hardhat-lib.js +2 -0
  96. package/internal/lib/hardhat-lib.js.map +1 -1
  97. package/internal/util/antlr-prototype-pollution-workaround.d.ts +16 -0
  98. package/internal/util/antlr-prototype-pollution-workaround.d.ts.map +1 -0
  99. package/internal/util/antlr-prototype-pollution-workaround.js +22 -0
  100. package/internal/util/antlr-prototype-pollution-workaround.js.map +1 -0
  101. package/package.json +5 -5
  102. package/register.js +3 -1
  103. package/register.js.map +1 -1
  104. package/src/builtin-tasks/compile.ts +14 -0
  105. package/src/builtin-tasks/node.ts +41 -9
  106. package/src/internal/artifacts.ts +268 -71
  107. package/src/internal/cli/analytics.ts +1 -1
  108. package/src/internal/cli/cli.ts +4 -1
  109. package/src/internal/constants.ts +3 -0
  110. package/src/internal/core/config/config-loading.ts +24 -2
  111. package/src/internal/core/config/config-resolution.ts +28 -0
  112. package/src/internal/core/config/config-validation.ts +147 -15
  113. package/src/internal/core/config/default-config.ts +9 -2
  114. package/src/internal/core/errors-list.ts +21 -2
  115. package/src/internal/core/jsonrpc/types/output/log.ts +1 -0
  116. package/src/internal/core/params/hardhat-params.ts +2 -2
  117. package/src/internal/core/providers/accounts.ts +19 -0
  118. package/src/internal/core/providers/construction.ts +8 -2
  119. package/src/internal/core/providers/gas-providers.ts +1 -1
  120. package/src/internal/core/typescript-support.ts +5 -1
  121. package/src/internal/hardhat-network/provider/TransactionQueue.ts +31 -4
  122. package/src/internal/hardhat-network/provider/fork/ForkBlockchain.ts +1 -3
  123. package/src/internal/hardhat-network/provider/modules/hardhat.ts +23 -0
  124. package/src/internal/hardhat-network/provider/modules/personal.ts +39 -0
  125. package/src/internal/hardhat-network/provider/node-types.ts +6 -0
  126. package/src/internal/hardhat-network/provider/node.ts +45 -15
  127. package/src/internal/hardhat-network/provider/output.ts +9 -9
  128. package/src/internal/hardhat-network/provider/provider.ts +15 -1
  129. package/src/internal/hardhat-network/stack-traces/error-inferrer.ts +19 -0
  130. package/src/internal/hardhat-network/stack-traces/solidityTracer.ts +1 -1
  131. package/src/internal/lib/hardhat-lib.ts +3 -0
  132. package/src/internal/util/antlr-prototype-pollution-workaround.ts +17 -0
  133. package/src/register.ts +4 -1
  134. package/src/types/config.ts +14 -0
  135. package/src/utils/contract-names.ts +112 -0
  136. package/src/utils/source-names.ts +1 -1
  137. package/types/config.d.ts +10 -0
  138. package/types/config.d.ts.map +1 -1
  139. package/utils/contract-names.d.ts +10 -0
  140. package/utils/contract-names.d.ts.map +1 -1
  141. package/utils/contract-names.js +92 -1
  142. package/utils/contract-names.js.map +1 -1
  143. package/utils/source-names.d.ts +1 -1
  144. package/utils/source-names.js +1 -1
@@ -10,6 +10,8 @@ import {
10
10
  HardhatNetworkForkingConfig,
11
11
  HardhatNetworkMiningConfig,
12
12
  HardhatNetworkMiningUserConfig,
13
+ HardhatNetworkMempoolConfig,
14
+ HardhatNetworkMempoolUserConfig,
13
15
  HardhatNetworkUserConfig,
14
16
  HardhatUserConfig,
15
17
  HDAccountsUserConfig,
@@ -228,10 +230,12 @@ function resolveHttpNetworkConfig(
228
230
  function resolveMiningConfig(
229
231
  userConfig: HardhatNetworkMiningUserConfig | undefined
230
232
  ): HardhatNetworkMiningConfig {
233
+ const mempool = resolveMempoolConfig(userConfig?.mempool);
231
234
  if (userConfig === undefined) {
232
235
  return {
233
236
  auto: true,
234
237
  interval: 0,
238
+ mempool,
235
239
  };
236
240
  }
237
241
 
@@ -241,6 +245,7 @@ function resolveMiningConfig(
241
245
  return {
242
246
  auto: true,
243
247
  interval: 0,
248
+ mempool,
244
249
  };
245
250
  }
246
251
 
@@ -248,6 +253,7 @@ function resolveMiningConfig(
248
253
  return {
249
254
  auto: false,
250
255
  interval,
256
+ mempool,
251
257
  };
252
258
  }
253
259
 
@@ -255,6 +261,7 @@ function resolveMiningConfig(
255
261
  return {
256
262
  auto,
257
263
  interval: 0,
264
+ mempool,
258
265
  };
259
266
  }
260
267
 
@@ -262,9 +269,30 @@ function resolveMiningConfig(
262
269
  return {
263
270
  auto: auto!,
264
271
  interval: interval!,
272
+ mempool,
265
273
  };
266
274
  }
267
275
 
276
+ function resolveMempoolConfig(
277
+ userConfig: HardhatNetworkMempoolUserConfig | undefined
278
+ ): HardhatNetworkMempoolConfig {
279
+ if (userConfig === undefined) {
280
+ return {
281
+ order: "priority",
282
+ };
283
+ }
284
+
285
+ if (userConfig.order === undefined) {
286
+ return {
287
+ order: "priority",
288
+ };
289
+ }
290
+
291
+ return {
292
+ order: userConfig.order,
293
+ } as HardhatNetworkMempoolConfig;
294
+ }
295
+
268
296
  function resolveSolidityConfig(userConfig: HardhatUserConfig): SolidityConfig {
269
297
  const userSolidityConfig = userConfig.solidity ?? DEFAULT_SOLC_VERSION;
270
298
 
@@ -3,6 +3,7 @@ import { Context, getFunctionName, ValidationError } from "io-ts/lib";
3
3
  import { Reporter } from "io-ts/lib/Reporter";
4
4
 
5
5
  import {
6
+ HARDHAT_MEMPOOL_SUPPORTED_ORDERS,
6
7
  HARDHAT_NETWORK_NAME,
7
8
  HARDHAT_NETWORK_SUPPORTED_HARDFORKS,
8
9
  } from "../../constants";
@@ -53,6 +54,59 @@ function getErrorMessage(path: string, value: any, expectedType: string) {
53
54
  )} for ${path} - Expected a value of type ${expectedType}.`;
54
55
  }
55
56
 
57
+ function getPrivateKeyError(index: number, network: string, message: string) {
58
+ return `Invalid account: #${index} for network: ${network} - ${message}`;
59
+ }
60
+
61
+ function validatePrivateKey(
62
+ privateKey: unknown,
63
+ index: number,
64
+ network: string,
65
+ errors: string[]
66
+ ) {
67
+ if (typeof privateKey !== "string") {
68
+ errors.push(
69
+ getPrivateKeyError(
70
+ index,
71
+ network,
72
+ `Expected string, received ${typeof privateKey}`
73
+ )
74
+ );
75
+ } else {
76
+ // private key validation
77
+ const pkWithPrefix = /^0x/.test(privateKey)
78
+ ? privateKey
79
+ : `0x${privateKey}`;
80
+
81
+ // 32 bytes = 64 characters + 2 char prefix = 66
82
+ if (pkWithPrefix.length < 66) {
83
+ errors.push(
84
+ getPrivateKeyError(
85
+ index,
86
+ network,
87
+ "private key too short, expected 32 bytes"
88
+ )
89
+ );
90
+ } else if (pkWithPrefix.length > 66) {
91
+ errors.push(
92
+ getPrivateKeyError(
93
+ index,
94
+ network,
95
+ "private key too long, expected 32 bytes"
96
+ )
97
+ );
98
+ } else if (hexString.decode(pkWithPrefix).isLeft()) {
99
+ errors.push(
100
+ getPrivateKeyError(
101
+ index,
102
+ network,
103
+ "invalid hex character(s) found in string"
104
+ )
105
+ );
106
+ }
107
+ }
108
+ }
109
+
56
110
  export function failure(es: ValidationError[]): string[] {
57
111
  return es.map(getMessage);
58
112
  }
@@ -91,6 +145,27 @@ export const hexString = new t.Type<string>(
91
145
  t.identity
92
146
  );
93
147
 
148
+ function isAddress(v: unknown): v is string {
149
+ if (typeof v !== "string") {
150
+ return false;
151
+ }
152
+
153
+ const trimmed = v.trim();
154
+
155
+ return (
156
+ trimmed.match(HEX_STRING_REGEX) !== null &&
157
+ trimmed.startsWith("0x") &&
158
+ trimmed.length === 42
159
+ );
160
+ }
161
+
162
+ export const address = new t.Type<string>(
163
+ "address",
164
+ isAddress,
165
+ (u, c) => (isAddress(u) ? t.success(u) : t.failure(u, c)),
166
+ t.identity
167
+ );
168
+
94
169
  export const decimalString = new t.Type<string>(
95
170
  "decimal string",
96
171
  isDecimalString,
@@ -123,6 +198,22 @@ const HardhatNetworkForkingConfig = t.type({
123
198
  blockNumber: optional(t.number),
124
199
  });
125
200
 
201
+ const HardhatNetworkMempoolConfig = t.type({
202
+ order: optional(
203
+ t.keyof(
204
+ fromEntries(
205
+ HARDHAT_MEMPOOL_SUPPORTED_ORDERS.map((order) => [order, null])
206
+ )
207
+ )
208
+ ),
209
+ });
210
+
211
+ const HardhatNetworkMiningConfig = t.type({
212
+ auto: optional(t.boolean),
213
+ interval: optional(t.union([t.number, t.tuple([t.number, t.number])])),
214
+ mempool: optional(HardhatNetworkMempoolConfig),
215
+ });
216
+
126
217
  const commonNetworkConfigFields = {
127
218
  chainId: optional(t.number),
128
219
  from: optional(t.string),
@@ -149,6 +240,8 @@ const HardhatNetworkConfig = t.type({
149
240
  initialDate: optional(t.string),
150
241
  loggingEnabled: optional(t.boolean),
151
242
  forking: optional(HardhatNetworkForkingConfig),
243
+ mining: optional(HardhatNetworkMiningConfig),
244
+ coinbase: optional(address),
152
245
  });
153
246
 
154
247
  const HDAccountsConfig = t.type({
@@ -224,7 +317,7 @@ export function validateConfig(config: any) {
224
317
  }
225
318
 
226
319
  export function getValidationErrors(config: any): string[] {
227
- const errors = [];
320
+ const errors: string[] = [];
228
321
 
229
322
  // These can't be validated with io-ts
230
323
  if (config !== undefined && typeof config.networks === "object") {
@@ -237,8 +330,7 @@ export function getValidationErrors(config: any): string[] {
237
330
  }
238
331
 
239
332
  // Validating the accounts with io-ts leads to very confusing errors messages
240
- const configExceptAccounts = { ...hardhatNetwork };
241
- delete configExceptAccounts.accounts;
333
+ const { accounts, ...configExceptAccounts } = hardhatNetwork;
242
334
 
243
335
  const netConfigResult = HardhatNetworkConfig.decode(configExceptAccounts);
244
336
  if (netConfigResult.isLeft()) {
@@ -251,31 +343,37 @@ export function getValidationErrors(config: any): string[] {
251
343
  );
252
344
  }
253
345
 
254
- if (Array.isArray(hardhatNetwork.accounts)) {
255
- for (const account of hardhatNetwork.accounts) {
256
- if (typeof account.privateKey !== "string") {
346
+ // manual validation of accounts
347
+ if (Array.isArray(accounts)) {
348
+ for (const [index, account] of accounts.entries()) {
349
+ if (typeof account !== "object") {
257
350
  errors.push(
258
- getErrorMessage(
259
- `HardhatConfig.networks.${HARDHAT_NETWORK_NAME}.accounts[].privateKey`,
260
- account.privateKey,
261
- "string"
351
+ getPrivateKeyError(
352
+ index,
353
+ HARDHAT_NETWORK_NAME,
354
+ `Expected object, received ${typeof account}`
262
355
  )
263
356
  );
357
+ continue;
264
358
  }
265
359
 
266
- if (typeof account.balance !== "string") {
360
+ const { privateKey, balance } = account;
361
+
362
+ validatePrivateKey(privateKey, index, HARDHAT_NETWORK_NAME, errors);
363
+
364
+ if (typeof balance !== "string") {
267
365
  errors.push(
268
366
  getErrorMessage(
269
367
  `HardhatConfig.networks.${HARDHAT_NETWORK_NAME}.accounts[].balance`,
270
- account.balance,
368
+ balance,
271
369
  "string"
272
370
  )
273
371
  );
274
- } else if (decimalString.decode(account.balance).isLeft()) {
372
+ } else if (decimalString.decode(balance).isLeft()) {
275
373
  errors.push(
276
374
  getErrorMessage(
277
375
  `HardhatConfig.networks.${HARDHAT_NETWORK_NAME}.accounts[].balance`,
278
- account.balance,
376
+ balance,
279
377
  "decimal(wei)"
280
378
  )
281
379
  );
@@ -340,7 +438,9 @@ export function getValidationErrors(config: any): string[] {
340
438
  }
341
439
  }
342
440
 
343
- const netConfigResult = HttpNetworkConfig.decode(netConfig);
441
+ const { accounts, ...configExceptAccounts } = netConfig;
442
+
443
+ const netConfigResult = HttpNetworkConfig.decode(configExceptAccounts);
344
444
  if (netConfigResult.isLeft()) {
345
445
  errors.push(
346
446
  getErrorMessage(
@@ -350,6 +450,38 @@ export function getValidationErrors(config: any): string[] {
350
450
  )
351
451
  );
352
452
  }
453
+
454
+ // manual validation of accounts
455
+ if (Array.isArray(accounts)) {
456
+ accounts.forEach((privateKey, index) =>
457
+ validatePrivateKey(privateKey, index, networkName, errors)
458
+ );
459
+ } else if (typeof accounts === "object") {
460
+ const hdConfigResult = HDAccountsConfig.decode(accounts);
461
+ if (hdConfigResult.isLeft()) {
462
+ errors.push(
463
+ getErrorMessage(
464
+ `HardhatConfig.networks.${networkName}`,
465
+ accounts,
466
+ "HttpNetworkHDAccountsConfig"
467
+ )
468
+ );
469
+ }
470
+ } else if (typeof accounts === "string") {
471
+ if (accounts !== "remote") {
472
+ errors.push(
473
+ `Invalid 'accounts' entry for network '${networkName}': expected an array of accounts or the string 'remote', but got the string '${accounts}'`
474
+ );
475
+ }
476
+ } else if (accounts !== undefined) {
477
+ errors.push(
478
+ getErrorMessage(
479
+ `HardhatConfig.networks.${networkName}.accounts`,
480
+ accounts,
481
+ '"remote" | string[] | HttpNetworkHDAccountsConfig | undefined'
482
+ )
483
+ );
484
+ }
353
485
  }
354
486
  }
355
487
 
@@ -7,7 +7,7 @@ export const DEFAULT_SOLC_VERSION = "0.7.3";
7
7
  export const HARDHAT_NETWORK_DEFAULT_GAS_PRICE = "auto";
8
8
  export const HARDHAT_NETWORK_DEFAULT_MAX_PRIORITY_FEE_PER_GAS = 1e9;
9
9
  export const HARDHAT_NETWORK_DEFAULT_INITIAL_BASE_FEE_PER_GAS = 1e9;
10
- const HARDHAT_NETWORK_MNEMONIC =
10
+ export const HARDHAT_NETWORK_MNEMONIC =
11
11
  "test test test test test test test test test test test junk";
12
12
  export const DEFAULT_HARDHAT_NETWORK_BALANCE = "10000000000000000000000";
13
13
 
@@ -42,7 +42,13 @@ export const defaultHardhatNetworkParams: Omit<
42
42
  throwOnTransactionFailures: true,
43
43
  throwOnCallFailures: true,
44
44
  allowUnlimitedContractSize: false,
45
- mining: { auto: true, interval: 0 },
45
+ mining: {
46
+ auto: true,
47
+ interval: 0,
48
+ mempool: {
49
+ order: "priority",
50
+ },
51
+ },
46
52
  accounts: defaultHardhatNetworkHdAccountsConfigParams,
47
53
  loggingEnabled: false,
48
54
  gasMultiplier: DEFAULT_GAS_MULTIPLIER,
@@ -69,6 +75,7 @@ export const defaultSolcOutputSelection = {
69
75
  "evm.bytecode",
70
76
  "evm.deployedBytecode",
71
77
  "evm.methodIdentifiers",
78
+ "metadata",
72
79
  ],
73
80
  "": ["ast"],
74
81
  },
@@ -360,6 +360,15 @@ Please double check your transactions' parameters.`,
360
360
  Please double check your transactions' parameters.`,
361
361
  shouldBeReported: false,
362
362
  },
363
+ PERSONALSIGN_MISSING_ADDRESS_PARAM: {
364
+ number: 116,
365
+ message: 'Missing "address" param when calling personal_sign.',
366
+ title: "Missing `address` param when calling personal_sign.",
367
+ description: `You called \`personal_sign\` with incorrect parameters.
368
+
369
+ Please check that you are sending an \`address\` parameter.`,
370
+ shouldBeReported: false,
371
+ },
363
372
  },
364
373
  TASK_DEFINITIONS: {
365
374
  PARAM_AFTER_VARIADIC: {
@@ -562,7 +571,7 @@ Please double check how you invoked Hardhat or ran your task.`,
562
571
  },
563
572
  MISSING_TASK_ARGUMENT: {
564
573
  number: 306,
565
- message: "Missing task argument %param%",
574
+ message: "The '%param%' parameter expects a value, but none was passed.",
566
575
  title: "Missing task argument",
567
576
  description: `You tried to run a task, but one of its required arguments was missing.
568
577
 
@@ -861,11 +870,21 @@ To start the JSON-RPC server, retry the command without the --network parameter.
861
870
  if the URL of the JSON-RPC wasn't set.`,
862
871
  shouldBeReported: false,
863
872
  },
873
+ COMPILE_TASK_UNSUPPORTED_SOLC_VERSION: {
874
+ number: 608,
875
+ message: `Version %version% is not supported by Hardhat.
876
+
877
+ The first supported version is %firstSupportedVersion%`,
878
+ title: "Unsupported solc version",
879
+ description: `This version of solidity is not supported by Hardhtat.
880
+ Please use a newer, supported version.`,
881
+ shouldBeReported: true,
882
+ },
864
883
  },
865
884
  ARTIFACTS: {
866
885
  NOT_FOUND: {
867
886
  number: 700,
868
- message: 'Artifact for contract "%contractName%" not found.',
887
+ message: 'Artifact for contract "%contractName%" not found. %suggestion%',
869
888
  title: "Artifact not found",
870
889
  description: `Tried to import a nonexistent artifact.
871
890
 
@@ -6,6 +6,7 @@ import { rpcAddress, rpcData, rpcHash, rpcQuantity } from "../base-types";
6
6
  export type RpcLog = t.TypeOf<typeof rpcLog>;
7
7
  export const rpcLog = t.type(
8
8
  {
9
+ logIndex: nullable(rpcQuantity),
9
10
  transactionIndex: nullable(rpcQuantity),
10
11
  transactionHash: nullable(rpcHash),
11
12
  blockHash: nullable(rpcHash),
@@ -78,8 +78,8 @@ export const HARDHAT_PARAM_DEFINITIONS: HardhatParamDefinitions = {
78
78
  tsconfig: {
79
79
  name: "tsconfig",
80
80
  defaultValue: undefined,
81
- description: "Reserved hardhat argument -- Has no effect.",
82
- type: types.string,
81
+ description: "A TypeScript config file.",
82
+ type: types.inputFile,
83
83
  isOptional: true,
84
84
  isFlag: false,
85
85
  isVariadic: false,
@@ -74,6 +74,25 @@ export class LocalAccountsProvider extends ProviderWrapperWithChainId {
74
74
  }
75
75
  }
76
76
 
77
+ if (args.method === "personal_sign") {
78
+ if (params.length > 0) {
79
+ const [data, address] = validateParams(params, rpcData, rpcAddress);
80
+
81
+ if (data !== undefined) {
82
+ if (address === undefined) {
83
+ throw new HardhatError(
84
+ ERRORS.NETWORK.PERSONALSIGN_MISSING_ADDRESS_PARAM
85
+ );
86
+ }
87
+
88
+ const privateKey = this._getPrivateKeyForAddress(address);
89
+ const messageHash = hashPersonalMessage(toBuffer(data));
90
+ const signature = ecsign(messageHash, privateKey);
91
+ return toRpcSig(signature.v, signature.r, signature.s);
92
+ }
93
+ }
94
+ }
95
+
77
96
  if (args.method === "eth_signTypedData_v4") {
78
97
  const [address, data] = validateParams(params, rpcAddress, t.any);
79
98
 
@@ -13,7 +13,10 @@ import type {
13
13
  } from "../../../types";
14
14
  import { HARDHAT_NETWORK_NAME } from "../../constants";
15
15
  import { ModulesLogger } from "../../hardhat-network/provider/modules/logger";
16
- import { ForkConfig } from "../../hardhat-network/provider/node-types";
16
+ import {
17
+ ForkConfig,
18
+ MempoolOrder,
19
+ } from "../../hardhat-network/provider/node-types";
17
20
  import { getForkCacheDirPath } from "../../hardhat-network/provider/utils/disk-cache";
18
21
  import { parseDateString } from "../../util/date";
19
22
 
@@ -88,6 +91,8 @@ export function createProvider(
88
91
  hardhatNetConfig.throwOnCallFailures,
89
92
  hardhatNetConfig.mining.auto,
90
93
  hardhatNetConfig.mining.interval,
94
+ // This cast is valid because of the config validation and resolution
95
+ hardhatNetConfig.mining.mempool.order as MempoolOrder,
91
96
  new ModulesLogger(hardhatNetConfig.loggingEnabled),
92
97
  accounts,
93
98
  artifacts,
@@ -97,7 +102,8 @@ export function createProvider(
97
102
  : undefined,
98
103
  experimentalHardhatNetworkMessageTraceHooks,
99
104
  forkConfig,
100
- paths !== undefined ? getForkCacheDirPath(paths) : undefined
105
+ paths !== undefined ? getForkCacheDirPath(paths) : undefined,
106
+ hardhatNetConfig.coinbase
101
107
  );
102
108
  } else {
103
109
  const HttpProvider = importProvider<
@@ -142,7 +142,7 @@ export class AutomaticGasPriceProvider extends ProviderWrapper {
142
142
  public static readonly EIP1559_BASE_FEE_MAX_FULL_BLOCKS_PREFERENCE: number = 3;
143
143
 
144
144
  // See eth_feeHistory for an explanation of what this means
145
- public static readonly EIP1559_REWARD_PERCENTILE: number = 0.5;
145
+ public static readonly EIP1559_REWARD_PERCENTILE: number = 50;
146
146
 
147
147
  private _nodeHasFeeHistory?: boolean;
148
148
  private _nodeSupportsEIP1559?: boolean;
@@ -38,7 +38,7 @@ export function isTypescriptSupported() {
38
38
  return cachedIsTypescriptSupported;
39
39
  }
40
40
 
41
- export function loadTsNode() {
41
+ export function loadTsNode(tsConfigPath?: string) {
42
42
  try {
43
43
  require.resolve("typescript");
44
44
  } catch (error) {
@@ -58,6 +58,10 @@ export function loadTsNode() {
58
58
  return;
59
59
  }
60
60
 
61
+ if (tsConfigPath !== undefined) {
62
+ process.env.TS_NODE_PROJECT = tsConfigPath;
63
+ }
64
+
61
65
  // See: https://github.com/nomiclabs/hardhat/issues/265
62
66
  if (process.env.TS_NODE_FILES === undefined) {
63
67
  process.env.TS_NODE_FILES = "true";
@@ -2,7 +2,8 @@ import { TypedTransaction } from "@ethereumjs/tx";
2
2
  import { BN } from "ethereumjs-util";
3
3
  import Heap from "mnemonist/heap";
4
4
 
5
- import { InternalError } from "../../core/providers/errors";
5
+ import { InternalError, InvalidInputError } from "../../core/providers/errors";
6
+ import { MempoolOrder } from "./node-types";
6
7
  import { OrderedTransaction } from "./PoolState";
7
8
 
8
9
  function getEffectiveMinerFee(tx: OrderedTransaction, baseFee?: BN): BN {
@@ -38,6 +39,33 @@ function decreasingOrderEffectiveMinerFeeComparator(
38
39
  // in increasing order by orderId.
39
40
  return left.orderId - right.orderId;
40
41
  }
42
+
43
+ function decreasingOrderComparator(
44
+ left: OrderedTransaction,
45
+ right: OrderedTransaction
46
+ ) {
47
+ return left.orderId - right.orderId;
48
+ }
49
+
50
+ function getOrderedTransactionHeap(
51
+ mempoolOrder: MempoolOrder,
52
+ baseFee?: BN
53
+ ): Heap<OrderedTransaction> {
54
+ switch (mempoolOrder) {
55
+ case "priority":
56
+ return new Heap<OrderedTransaction>((a, b) =>
57
+ decreasingOrderEffectiveMinerFeeComparator(a, b, baseFee)
58
+ );
59
+ case "fifo":
60
+ return new Heap<OrderedTransaction>((a, b) =>
61
+ decreasingOrderComparator(a, b)
62
+ );
63
+ default:
64
+ // eslint-disable-next-line @nomiclabs/hardhat-internal-rules/only-hardhat-error
65
+ throw new InvalidInputError(`Invalid mempool order: ${mempoolOrder}`);
66
+ }
67
+ }
68
+
41
69
  /**
42
70
  * A queue of transactions in the order that they could be mined in the next
43
71
  * block.
@@ -67,11 +95,10 @@ export class TransactionQueue {
67
95
  */
68
96
  constructor(
69
97
  pendingTransactions: Map<string, OrderedTransaction[]>,
98
+ mempoolOrder: MempoolOrder,
70
99
  baseFee?: BN
71
100
  ) {
72
- this._heap = new Heap<OrderedTransaction>((a, b) =>
73
- decreasingOrderEffectiveMinerFeeComparator(a, b, baseFee)
74
- );
101
+ this._heap = getOrderedTransactionHeap(mempoolOrder, baseFee);
75
102
 
76
103
  for (const [address, txList] of pendingTransactions) {
77
104
  if (baseFee === undefined && txList.some((tx) => tx.data.type === 2)) {
@@ -215,9 +215,7 @@ export class ForkBlockchain implements HardhatBlockchainInterface {
215
215
  : filterParams.addresses,
216
216
  topics: filterParams.normalizedTopics,
217
217
  });
218
- return remoteLogs
219
- .map((log, index) => toRpcLogOutput(log, index))
220
- .concat(localLogs);
218
+ return remoteLogs.map(toRpcLogOutput).concat(localLogs);
221
219
  }
222
220
  return this._data.getLogs(filterParams);
223
221
  }
@@ -66,6 +66,9 @@ export class HardhatModule {
66
66
  case "hardhat_intervalMine":
67
67
  return this._intervalMineAction(...this._intervalMineParams(params));
68
68
 
69
+ case "hardhat_getAutomine":
70
+ return this._getAutomine();
71
+
69
72
  case "hardhat_stopImpersonatingAccount":
70
73
  return this._stopImpersonatingAction(
71
74
  ...this._stopImpersonatingParams(params)
@@ -105,6 +108,9 @@ export class HardhatModule {
105
108
  return this._setNextBlockBaseFeePerGasAction(
106
109
  ...this._setNextBlockBaseFeePerGasParams(params)
107
110
  );
111
+
112
+ case "hardhat_setCoinbase":
113
+ return this._setCoinbaseAction(...this._setCoinbaseParams(params));
108
114
  }
109
115
 
110
116
  throw new MethodNotFoundError(`Method ${method} not found`);
@@ -184,6 +190,12 @@ export class HardhatModule {
184
190
  return true;
185
191
  }
186
192
 
193
+ // hardhat_getAutomine
194
+
195
+ private async _getAutomine(): Promise<boolean> {
196
+ return this._node.getAutomine();
197
+ }
198
+
187
199
  // hardhat_stopImpersonatingAccount
188
200
 
189
201
  private _stopImpersonatingParams(params: any[]): [Buffer] {
@@ -337,6 +349,17 @@ export class HardhatModule {
337
349
  return true;
338
350
  }
339
351
 
352
+ // hardhat_setCoinbase
353
+
354
+ private _setCoinbaseParams(params: any[]): [Buffer] {
355
+ return validateParams(params, rpcAddress);
356
+ }
357
+
358
+ private async _setCoinbaseAction(address: Buffer) {
359
+ await this._node.setCoinbase(new Address(address));
360
+ return true;
361
+ }
362
+
340
363
  private async _logBlock(result: MineBlockResult) {
341
364
  const { block, traces } = result;
342
365
 
@@ -0,0 +1,39 @@
1
+ import { Address, toRpcSig } from "ethereumjs-util";
2
+ import { rpcAddress, rpcData } from "../../../core/jsonrpc/types/base-types";
3
+ import { validateParams } from "../../../core/jsonrpc/types/input/validation";
4
+ import { MethodNotFoundError } from "../../../core/providers/errors";
5
+ import { HardhatNode } from "../node";
6
+
7
+ /* eslint-disable @nomiclabs/hardhat-internal-rules/only-hardhat-error */
8
+
9
+ export class PersonalModule {
10
+ constructor(private readonly _node: HardhatNode) {}
11
+
12
+ public async processRequest(
13
+ method: string,
14
+ params: any[] = []
15
+ ): Promise<any> {
16
+ switch (method) {
17
+ case "personal_sign": {
18
+ return this._signAction(...this._signParams(params));
19
+ }
20
+ }
21
+
22
+ throw new MethodNotFoundError(`Method ${method} not found`);
23
+ }
24
+
25
+ // personal_sign
26
+
27
+ private _signParams(params: any[]): [Buffer, Buffer] {
28
+ return validateParams(params, rpcData, rpcAddress);
29
+ }
30
+
31
+ private async _signAction(data: Buffer, address: Buffer): Promise<string> {
32
+ const signature = await this._node.signPersonalMessage(
33
+ new Address(address),
34
+ data
35
+ );
36
+
37
+ return toRpcSig(signature.v, signature.r, signature.s);
38
+ }
39
+ }