hardhat 2.12.1 → 2.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/internal/artifacts.d.ts +5 -0
  2. package/internal/artifacts.d.ts.map +1 -1
  3. package/internal/artifacts.js +23 -0
  4. package/internal/artifacts.js.map +1 -1
  5. package/internal/core/errors-list.d.ts +7 -0
  6. package/internal/core/errors-list.d.ts.map +1 -1
  7. package/internal/core/errors-list.js +9 -0
  8. package/internal/core/errors-list.js.map +1 -1
  9. package/internal/core/jsonrpc/types/output/metadata.d.ts +13 -0
  10. package/internal/core/jsonrpc/types/output/metadata.d.ts.map +1 -0
  11. package/internal/core/jsonrpc/types/output/metadata.js +3 -0
  12. package/internal/core/jsonrpc/types/output/metadata.js.map +1 -0
  13. package/internal/core/providers/accounts.d.ts.map +1 -1
  14. package/internal/core/providers/accounts.js +4 -1
  15. package/internal/core/providers/accounts.js.map +1 -1
  16. package/internal/hardhat-network/provider/fork/ForkBlockchain.d.ts.map +1 -1
  17. package/internal/hardhat-network/provider/fork/ForkBlockchain.js +9 -1
  18. package/internal/hardhat-network/provider/fork/ForkBlockchain.js.map +1 -1
  19. package/internal/hardhat-network/provider/modules/hardhat.d.ts +2 -0
  20. package/internal/hardhat-network/provider/modules/hardhat.d.ts.map +1 -1
  21. package/internal/hardhat-network/provider/modules/hardhat.js +9 -0
  22. package/internal/hardhat-network/provider/modules/hardhat.js.map +1 -1
  23. package/internal/hardhat-network/provider/modules/web3.d.ts +3 -0
  24. package/internal/hardhat-network/provider/modules/web3.d.ts.map +1 -1
  25. package/internal/hardhat-network/provider/modules/web3.js +4 -4
  26. package/internal/hardhat-network/provider/modules/web3.js.map +1 -1
  27. package/internal/hardhat-network/provider/node.d.ts +5 -0
  28. package/internal/hardhat-network/provider/node.d.ts.map +1 -1
  29. package/internal/hardhat-network/provider/node.js +40 -3
  30. package/internal/hardhat-network/provider/node.js.map +1 -1
  31. package/internal/hardhat-network/provider/output.d.ts +1 -1
  32. package/internal/hardhat-network/provider/output.d.ts.map +1 -1
  33. package/internal/hardhat-network/provider/output.js +1 -1
  34. package/internal/hardhat-network/provider/output.js.map +1 -1
  35. package/internal/hardhat-network/provider/provider.js +1 -1
  36. package/internal/hardhat-network/provider/provider.js.map +1 -1
  37. package/internal/hardhat-network/provider/transactions/ReadOnlyValidUnknownTypeTransaction.d.ts +32 -0
  38. package/internal/hardhat-network/provider/transactions/ReadOnlyValidUnknownTypeTransaction.d.ts.map +1 -0
  39. package/internal/hardhat-network/provider/transactions/ReadOnlyValidUnknownTypeTransaction.js +87 -0
  40. package/internal/hardhat-network/provider/transactions/ReadOnlyValidUnknownTypeTransaction.js.map +1 -0
  41. package/internal/hardhat-network/provider/utils/makeForkClient.d.ts +1 -0
  42. package/internal/hardhat-network/provider/utils/makeForkClient.d.ts.map +1 -1
  43. package/internal/hardhat-network/provider/utils/makeForkClient.js +4 -1
  44. package/internal/hardhat-network/provider/utils/makeForkClient.js.map +1 -1
  45. package/internal/hardhat-network/stack-traces/vm-debug-tracer.d.ts.map +1 -1
  46. package/internal/hardhat-network/stack-traces/vm-debug-tracer.js +2 -1
  47. package/internal/hardhat-network/stack-traces/vm-debug-tracer.js.map +1 -1
  48. package/internal/solidity/compiler/compiler-input.d.ts.map +1 -1
  49. package/internal/solidity/compiler/compiler-input.js +5 -1
  50. package/internal/solidity/compiler/compiler-input.js.map +1 -1
  51. package/internal/solidity/resolver.d.ts.map +1 -1
  52. package/internal/solidity/resolver.js +8 -0
  53. package/internal/solidity/resolver.js.map +1 -1
  54. package/internal/util/keys-derivation.d.ts.map +1 -1
  55. package/internal/util/keys-derivation.js +4 -1
  56. package/internal/util/keys-derivation.js.map +1 -1
  57. package/internal/util/packageInfo.d.ts +1 -0
  58. package/internal/util/packageInfo.d.ts.map +1 -1
  59. package/internal/util/packageInfo.js +10 -1
  60. package/internal/util/packageInfo.js.map +1 -1
  61. package/package.json +1 -1
  62. package/recommended-gitignore.txt +1 -1
  63. package/src/internal/artifacts.ts +38 -0
  64. package/src/internal/core/errors-list.ts +10 -0
  65. package/src/internal/core/jsonrpc/types/output/metadata.ts +32 -0
  66. package/src/internal/core/providers/accounts.ts +5 -2
  67. package/src/internal/hardhat-network/provider/fork/ForkBlockchain.ts +15 -3
  68. package/src/internal/hardhat-network/provider/modules/hardhat.ts +14 -0
  69. package/src/internal/hardhat-network/provider/modules/web3.ts +4 -4
  70. package/src/internal/hardhat-network/provider/node.ts +58 -0
  71. package/src/internal/hardhat-network/provider/output.ts +2 -2
  72. package/src/internal/hardhat-network/provider/provider.ts +1 -1
  73. package/src/internal/hardhat-network/provider/transactions/ReadOnlyValidUnknownTypeTransaction.ts +162 -0
  74. package/src/internal/hardhat-network/provider/utils/makeForkClient.ts +10 -1
  75. package/src/internal/hardhat-network/stack-traces/vm-debug-tracer.ts +4 -1
  76. package/src/internal/solidity/compiler/compiler-input.ts +7 -1
  77. package/src/internal/solidity/resolver.ts +10 -0
  78. package/src/internal/util/keys-derivation.ts +4 -1
  79. package/src/internal/util/packageInfo.ts +9 -0
  80. package/src/types/artifacts.ts +5 -0
  81. package/src/utils/source-names.ts +15 -0
  82. package/types/artifacts.d.ts +4 -0
  83. package/types/artifacts.d.ts.map +1 -1
  84. package/utils/source-names.d.ts +5 -0
  85. package/utils/source-names.d.ts.map +1 -1
  86. package/utils/source-names.js +14 -1
  87. package/utils/source-names.js.map +1 -1
@@ -24,6 +24,7 @@ import { ReadOnlyValidTransaction } from "../transactions/ReadOnlyValidTransacti
24
24
  import { HardhatBlockchainInterface } from "../types/HardhatBlockchainInterface";
25
25
 
26
26
  import { ReadOnlyValidEIP1559Transaction } from "../transactions/ReadOnlyValidEIP1559Transaction";
27
+ import { ReadOnlyValidUnknownTypeTransaction } from "../transactions/ReadOnlyValidUnknownTypeTransaction";
27
28
  import { rpcToBlockData } from "./rpcToBlockData";
28
29
  import { rpcToTxData } from "./rpcToTxData";
29
30
 
@@ -297,9 +298,20 @@ export class ForkBlockchain
297
298
  rpcToTxData(transaction) as FeeMarketEIP1559TxData
298
299
  );
299
300
  } else {
300
- throw new InternalError(
301
- `Unknown transaction type ${transaction.type.toString()}`
302
- );
301
+ // we try to interpret unknown txs as legacy transactions, to support
302
+ // networks like Arbitrum that have non-standards tx types
303
+ try {
304
+ tx = new ReadOnlyValidUnknownTypeTransaction(
305
+ new Address(transaction.from),
306
+ Number(transaction.type),
307
+ rpcToTxData(transaction)
308
+ );
309
+ } catch (e: any) {
310
+ throw new InternalError(
311
+ `Could not process transaction with type ${transaction.type.toString()}`,
312
+ e
313
+ );
314
+ }
303
315
  }
304
316
 
305
317
  block.transactions.push(tx);
@@ -22,6 +22,7 @@ import {
22
22
  rpcCompilerOutput,
23
23
  } from "../../../core/jsonrpc/types/input/solc";
24
24
  import { validateParams } from "../../../core/jsonrpc/types/input/validation";
25
+ import { HardhatMetadata } from "../../../core/jsonrpc/types/output/metadata";
25
26
  import {
26
27
  InvalidInputError,
27
28
  MethodNotFoundError,
@@ -93,6 +94,9 @@ export class HardhatModule {
93
94
  ...this._dropTransactionParams(params)
94
95
  );
95
96
 
97
+ case "hardhat_metadata":
98
+ return this._metadataAction(...this._metadataParams(params));
99
+
96
100
  case "hardhat_setBalance":
97
101
  return this._setBalanceAction(...this._setBalanceParams(params));
98
102
 
@@ -272,6 +276,16 @@ export class HardhatModule {
272
276
  return this._node.dropTransaction(hash);
273
277
  }
274
278
 
279
+ // hardhat_metadata
280
+
281
+ private _metadataParams(params: any[]): [] {
282
+ return validateParams(params);
283
+ }
284
+
285
+ private async _metadataAction(): Promise<HardhatMetadata> {
286
+ return this._node.getMetadata();
287
+ }
288
+
275
289
  // hardhat_setBalance
276
290
 
277
291
  private _setBalanceParams(params: any[]): [Buffer, bigint] {
@@ -5,11 +5,13 @@ import {
5
5
  import { validateParams } from "../../../core/jsonrpc/types/input/validation";
6
6
  import { MethodNotFoundError } from "../../../core/providers/errors";
7
7
  import { keccak256 } from "../../../util/keccak";
8
- import { getPackageJson } from "../../../util/packageInfo";
8
+ import { HardhatNode } from "../node";
9
9
 
10
10
  /* eslint-disable @nomiclabs/hardhat-internal-rules/only-hardhat-error */
11
11
 
12
12
  export class Web3Module {
13
+ constructor(private readonly _node: HardhatNode) {}
14
+
13
15
  public async processRequest(
14
16
  method: string,
15
17
  params: any[] = []
@@ -32,9 +34,7 @@ export class Web3Module {
32
34
  }
33
35
 
34
36
  private async _clientVersionAction(): Promise<string> {
35
- const hardhatPackage = await getPackageJson();
36
- const ethereumjsVMPackage = require("@nomicfoundation/ethereumjs-vm/package.json");
37
- return `HardhatNetwork/${hardhatPackage.version}/@nomicfoundation/ethereumjs-vm/${ethereumjsVMPackage.version}`;
37
+ return this._node.getClientVersion();
38
38
  }
39
39
 
40
40
  // web3_sha3
@@ -16,6 +16,7 @@ import {
16
16
  privateToAddress,
17
17
  setLengthLeft,
18
18
  toBuffer,
19
+ bufferToBigInt,
19
20
  } from "@nomicfoundation/ethereumjs-util";
20
21
  import {
21
22
  Bloom,
@@ -32,6 +33,7 @@ import {
32
33
  } from "@nomicfoundation/ethereumjs-statemanager";
33
34
  import { SignTypedDataVersion, signTypedData } from "@metamask/eth-sig-util";
34
35
  import chalk from "chalk";
36
+ import { randomBytes } from "crypto";
35
37
  import debug from "debug";
36
38
  import EventEmitter from "events";
37
39
 
@@ -51,6 +53,7 @@ import {
51
53
  InvalidInputError,
52
54
  TransactionExecutionError,
53
55
  } from "../../core/providers/errors";
56
+ import { HardhatMetadata } from "../../core/jsonrpc/types/output/metadata";
54
57
  import { Reporter } from "../../sentry/reporter";
55
58
  import { getDifferenceInSeconds } from "../../util/date";
56
59
  import {
@@ -58,6 +61,7 @@ import {
58
61
  hardforkGte,
59
62
  HardforkName,
60
63
  } from "../../util/hardforks";
64
+ import { getPackageJson } from "../../util/packageInfo";
61
65
  import { createModelsAndDecodeBytecodes } from "../stack-traces/compiler-to-model";
62
66
  import { ConsoleLogger } from "../stack-traces/consoleLogger";
63
67
  import { ContractsIdentifier } from "../stack-traces/contracts-identifier";
@@ -150,6 +154,7 @@ export class HardhatNode extends EventEmitter {
150
154
  let nextBlockBaseFeePerGas: bigint | undefined;
151
155
  let forkNetworkId: number | undefined;
152
156
  let forkBlockNum: bigint | undefined;
157
+ let forkBlockHash: string | undefined;
153
158
  let hardforkActivations: HardforkHistoryConfig = new Map();
154
159
 
155
160
  const initialBaseFeePerGasConfig =
@@ -168,11 +173,13 @@ export class HardhatNode extends EventEmitter {
168
173
  forkClient: _forkClient,
169
174
  forkBlockNumber,
170
175
  forkBlockTimestamp,
176
+ forkBlockHash: _forkBlockHash,
171
177
  } = await makeForkClient(config.forkConfig, config.forkCachePath);
172
178
  forkClient = _forkClient;
173
179
 
174
180
  forkNetworkId = forkClient.getNetworkId();
175
181
  forkBlockNum = forkBlockNumber;
182
+ forkBlockHash = _forkBlockHash;
176
183
 
177
184
  this._validateHardforks(
178
185
  config.forkConfig.blockNumber,
@@ -267,8 +274,11 @@ export class HardhatNode extends EventEmitter {
267
274
  blockchain,
268
275
  });
269
276
 
277
+ const instanceId = bufferToBigInt(randomBytes(32));
278
+
270
279
  const node = new HardhatNode(
271
280
  vm,
281
+ instanceId,
272
282
  stateManager,
273
283
  blockchain,
274
284
  txPool,
@@ -286,6 +296,7 @@ export class HardhatNode extends EventEmitter {
286
296
  tracingConfig,
287
297
  forkNetworkId,
288
298
  forkBlockNum,
299
+ forkBlockHash,
289
300
  nextBlockBaseFeePerGas,
290
301
  forkClient
291
302
  );
@@ -352,6 +363,7 @@ Hardhat Network's forking functionality only works with blocks from at least spu
352
363
 
353
364
  private constructor(
354
365
  private readonly _vm: VM,
366
+ private readonly _instanceId: bigint,
355
367
  private readonly _stateManager: StateManager,
356
368
  private readonly _blockchain: HardhatBlockchainInterface,
357
369
  private readonly _txPool: TxPool,
@@ -369,6 +381,7 @@ Hardhat Network's forking functionality only works with blocks from at least spu
369
381
  tracingConfig?: TracingConfig,
370
382
  private _forkNetworkId?: number,
371
383
  private _forkBlockNumber?: bigint,
384
+ private _forkBlockHash?: string,
372
385
  nextBlockBaseFee?: bigint,
373
386
  private _forkClient?: JsonRpcClient
374
387
  ) {
@@ -2519,6 +2532,51 @@ Hardhat Network's forking functionality only works with blocks from at least spu
2519
2532
  this._mixHashGenerator.setNext(prevRandao);
2520
2533
  }
2521
2534
 
2535
+ public async getClientVersion(): Promise<string> {
2536
+ const hardhatPackage = await getPackageJson();
2537
+ const ethereumjsVMPackage = require("@nomicfoundation/ethereumjs-vm/package.json");
2538
+ return `HardhatNetwork/${hardhatPackage.version}/@nomicfoundation/ethereumjs-vm/${ethereumjsVMPackage.version}`;
2539
+ }
2540
+
2541
+ public async getMetadata(): Promise<HardhatMetadata> {
2542
+ const clientVersion = await this.getClientVersion();
2543
+
2544
+ const instanceIdHex = BigIntUtils.toEvmWord(this._instanceId);
2545
+ const instanceId = `0x${instanceIdHex}`;
2546
+
2547
+ const latestBlock = await this.getLatestBlock();
2548
+
2549
+ const latestBlockHashHex = latestBlock.header.hash().toString("hex");
2550
+ const latestBlockHash = `0x${latestBlockHashHex}`;
2551
+
2552
+ const metadata: HardhatMetadata = {
2553
+ clientVersion,
2554
+ chainId: this._configChainId,
2555
+ instanceId,
2556
+ latestBlockNumber: Number(latestBlock.header.number),
2557
+ latestBlockHash,
2558
+ };
2559
+
2560
+ if (this._forkBlockNumber !== undefined) {
2561
+ assertHardhatInvariant(
2562
+ this._forkNetworkId !== undefined,
2563
+ "this._forkNetworkId should be defined if this._forkBlockNumber is defined"
2564
+ );
2565
+ assertHardhatInvariant(
2566
+ this._forkBlockHash !== undefined,
2567
+ "this._forkBlockhash should be defined if this._forkBlockNumber is defined"
2568
+ );
2569
+
2570
+ metadata.forkedNetwork = {
2571
+ chainId: this._forkNetworkId,
2572
+ forkBlockNumber: Number(this._forkBlockNumber),
2573
+ forkBlockHash: this._forkBlockHash,
2574
+ };
2575
+ }
2576
+
2577
+ return metadata;
2578
+ }
2579
+
2522
2580
  private _getNextMixHash(): Buffer {
2523
2581
  return this._mixHashGenerator.next();
2524
2582
  }
@@ -24,7 +24,7 @@ export interface RpcBlockOutput {
24
24
  gasLimit: string;
25
25
  gasUsed: string;
26
26
  hash: string | null;
27
- logsBloom: string | null;
27
+ logsBloom: string;
28
28
  miner: string;
29
29
  mixHash: string | null;
30
30
  nonce: string | null;
@@ -171,7 +171,7 @@ export function getRpcBlock(
171
171
  nonce: pending ? null : bufferToRpcData(block.header.nonce, 8),
172
172
  mixHash: pending ? null : bufferToRpcData(block.header.mixHash, 32),
173
173
  sha3Uncles: bufferToRpcData(block.header.uncleHash),
174
- logsBloom: pending ? null : bufferToRpcData(block.header.logsBloom),
174
+ logsBloom: bufferToRpcData(block.header.logsBloom),
175
175
  transactionsRoot: bufferToRpcData(block.header.transactionsTrie),
176
176
  stateRoot: bufferToRpcData(block.header.stateRoot),
177
177
  receiptsRoot: bufferToRpcData(block.header.receiptTrie),
@@ -265,7 +265,7 @@ export class HardhatNetworkProvider
265
265
  const miningTimer = this._makeMiningTimer();
266
266
 
267
267
  this._netModule = new NetModule(common);
268
- this._web3Module = new Web3Module();
268
+ this._web3Module = new Web3Module(node);
269
269
  this._evmModule = new EvmModule(
270
270
  node,
271
271
  miningTimer,
@@ -0,0 +1,162 @@
1
+ import { Common } from "@nomicfoundation/ethereumjs-common";
2
+ import { Transaction, TxData, TxOptions } from "@nomicfoundation/ethereumjs-tx";
3
+ import { Address } from "@nomicfoundation/ethereumjs-util";
4
+
5
+ import { InternalError } from "../../../core/providers/errors";
6
+
7
+ /* eslint-disable @nomiclabs/hardhat-internal-rules/only-hardhat-error */
8
+
9
+ /**
10
+ * This class is like `ReadOnlyValidTransaction` but for
11
+ * a transaction with an unknown tx type.
12
+ */
13
+ export class ReadOnlyValidUnknownTypeTransaction extends Transaction {
14
+ public static fromTxData(_txData: TxData, _opts?: TxOptions): never {
15
+ throw new InternalError(
16
+ "`fromTxData` is not implemented in ReadOnlyValidUnknownTypeTransaction"
17
+ );
18
+ }
19
+
20
+ public static fromSerializedTx(
21
+ _serialized: Buffer,
22
+ _opts?: TxOptions
23
+ ): never {
24
+ throw new InternalError(
25
+ "`fromSerializedTx` is not implemented in ReadOnlyValidUnknownTypeTransaction"
26
+ );
27
+ }
28
+
29
+ public static fromRlpSerializedTx(
30
+ _serialized: Buffer,
31
+ _opts?: TxOptions
32
+ ): never {
33
+ throw new InternalError(
34
+ "`fromRlpSerializedTx` is not implemented in ReadOnlyValidUnknownTypeTransaction"
35
+ );
36
+ }
37
+
38
+ public static fromValuesArray(_values: Buffer[], _opts?: TxOptions): never {
39
+ throw new InternalError(
40
+ "`fromRlpSerializedTx` is not implemented in ReadOnlyValidUnknownTypeTransaction"
41
+ );
42
+ }
43
+
44
+ public readonly common: Common;
45
+
46
+ private readonly _sender: Address;
47
+ private readonly _actualType: number;
48
+
49
+ constructor(sender: Address, type: number, data: TxData = {}) {
50
+ super(data, { freeze: false });
51
+
52
+ this.common = this._getCommon();
53
+ this._sender = sender;
54
+ this._actualType = type;
55
+ }
56
+
57
+ public get type(): number {
58
+ return this._actualType;
59
+ }
60
+
61
+ public verifySignature(): boolean {
62
+ return true;
63
+ }
64
+
65
+ public getSenderAddress(): Address {
66
+ return this._sender;
67
+ }
68
+
69
+ public sign(): never {
70
+ throw new InternalError(
71
+ "`sign` is not implemented in ReadOnlyValidUnknownTypeTransaction"
72
+ );
73
+ }
74
+
75
+ public getDataFee(): never {
76
+ throw new InternalError(
77
+ "`getDataFee` is not implemented in ReadOnlyValidUnknownTypeTransaction"
78
+ );
79
+ }
80
+
81
+ public getBaseFee(): never {
82
+ throw new InternalError(
83
+ "`getBaseFee` is not implemented in ReadOnlyValidUnknownTypeTransaction"
84
+ );
85
+ }
86
+
87
+ public getUpfrontCost(): never {
88
+ throw new InternalError(
89
+ "`getUpfrontCost` is not implemented in ReadOnlyValidUnknownTypeTransaction"
90
+ );
91
+ }
92
+
93
+ public validate(_stringError?: false): never;
94
+ public validate(_stringError: true): never;
95
+ public validate(_stringError: boolean = false): never {
96
+ throw new InternalError(
97
+ "`validate` is not implemented in ReadOnlyValidUnknownTypeTransaction"
98
+ );
99
+ }
100
+
101
+ public toCreationAddress(): never {
102
+ throw new InternalError(
103
+ "`toCreationAddress` is not implemented in ReadOnlyValidUnknownTypeTransaction"
104
+ );
105
+ }
106
+
107
+ public getSenderPublicKey(): never {
108
+ throw new InternalError(
109
+ "`getSenderPublicKey` is not implemented in ReadOnlyValidUnknownTypeTransaction"
110
+ );
111
+ }
112
+
113
+ public getMessageToVerifySignature(): never {
114
+ throw new InternalError(
115
+ "`getMessageToVerifySignature` is not implemented in ReadOnlyValidUnknownTypeTransaction"
116
+ );
117
+ }
118
+
119
+ public getMessageToSign(): never {
120
+ throw new InternalError(
121
+ "`getMessageToSign` is not implemented in ReadOnlyValidUnknownTypeTransaction"
122
+ );
123
+ }
124
+ }
125
+
126
+ // Override private methods
127
+
128
+ const ReadOnlyValidUnknownTypeTransactionPrototype: any =
129
+ ReadOnlyValidUnknownTypeTransaction.prototype;
130
+
131
+ ReadOnlyValidUnknownTypeTransactionPrototype._validateTxV = function (
132
+ _v: any,
133
+ common: any
134
+ ) {
135
+ return this._getCommon(common);
136
+ };
137
+
138
+ ReadOnlyValidUnknownTypeTransactionPrototype._signedTxImplementsEIP155 =
139
+ function () {
140
+ throw new InternalError(
141
+ "`_signedTxImplementsEIP155` is not implemented in ReadOnlyValidUnknownTypeTransaction"
142
+ );
143
+ };
144
+
145
+ ReadOnlyValidUnknownTypeTransactionPrototype._unsignedTxImplementsEIP155 =
146
+ function () {
147
+ throw new InternalError(
148
+ "`_unsignedTxImplementsEIP155` is not implemented in ReadOnlyValidUnknownTypeTransaction"
149
+ );
150
+ };
151
+
152
+ ReadOnlyValidUnknownTypeTransactionPrototype._getMessageToSign = function () {
153
+ throw new InternalError(
154
+ "`_getMessageToSign` is not implemented in ReadOnlyValidUnknownTypeTransaction"
155
+ );
156
+ };
157
+
158
+ ReadOnlyValidUnknownTypeTransactionPrototype._processSignature = function () {
159
+ throw new InternalError(
160
+ "`_processSignature` is not implemented in ReadOnlyValidUnknownTypeTransaction"
161
+ );
162
+ };
@@ -1,6 +1,7 @@
1
1
  import chalk from "chalk";
2
2
 
3
3
  import { HARDHAT_NETWORK_NAME } from "../../../constants";
4
+ import { assertHardhatInvariant } from "../../../core/errors";
4
5
  import {
5
6
  numberToRpcQuantity,
6
7
  rpcQuantityToNumber,
@@ -29,6 +30,7 @@ export async function makeForkClient(
29
30
  forkClient: JsonRpcClient;
30
31
  forkBlockNumber: bigint;
31
32
  forkBlockTimestamp: number;
33
+ forkBlockHash: string;
32
34
  }> {
33
35
  const provider = new HttpProvider(
34
36
  forkConfig.jsonRpcUrl,
@@ -88,7 +90,14 @@ Please use block number ${lastSafeBlock} or wait for the block to get ${
88
90
  cacheToDiskEnabled ? forkCachePath : undefined
89
91
  );
90
92
 
91
- return { forkClient, forkBlockNumber, forkBlockTimestamp };
93
+ const forkBlockHash = block.hash;
94
+
95
+ assertHardhatInvariant(
96
+ forkBlockHash !== null,
97
+ "Forked block should have a hash"
98
+ );
99
+
100
+ return { forkClient, forkBlockNumber, forkBlockTimestamp, forkBlockHash };
92
101
  }
93
102
 
94
103
  async function getBlockByNumber(
@@ -222,7 +222,10 @@ export class VMDebugTracer {
222
222
  );
223
223
 
224
224
  // geth does this for some reason
225
- if (result.execResult.exceptionError?.error === "out of gas") {
225
+ if (
226
+ rpcStructLogs.length > 0 &&
227
+ result.execResult.exceptionError?.error === "out of gas"
228
+ ) {
226
229
  rpcStructLogs[rpcStructLogs.length - 1].error = {};
227
230
  }
228
231
 
@@ -4,7 +4,13 @@ export function getInputFromCompilationJob(
4
4
  compilationJob: CompilationJob
5
5
  ): CompilerInput {
6
6
  const sources: { [sourceName: string]: { content: string } } = {};
7
- for (const file of compilationJob.getResolvedFiles()) {
7
+
8
+ // we sort the files so that we always get the same compilation input
9
+ const resolvedFiles = compilationJob
10
+ .getResolvedFiles()
11
+ .sort((a, b) => a.sourceName.localeCompare(b.sourceName));
12
+
13
+ for (const file of resolvedFiles) {
8
14
  sources[file.sourceName] = {
9
15
  content: file.content.rawContent,
10
16
  };
@@ -8,6 +8,7 @@ import {
8
8
  ResolvedFile as IResolvedFile,
9
9
  } from "../../types/builtin-tasks";
10
10
  import {
11
+ includesOwnPackageName,
11
12
  isAbsolutePathSourceName,
12
13
  isLocalSourceName,
13
14
  normalizeSourceName,
@@ -128,6 +129,15 @@ export class Resolver {
128
129
  });
129
130
  }
130
131
 
132
+ // Edge-case where an import can contain the current package's name in monorepos.
133
+ // The path can be resolved because there's a symlink in the node modules.
134
+ if (await includesOwnPackageName(imported)) {
135
+ throw new HardhatError(ERRORS.RESOLVER.INCLUDES_OWN_PACKAGE_NAME, {
136
+ from: from.sourceName,
137
+ imported,
138
+ });
139
+ }
140
+
131
141
  try {
132
142
  let sourceName: string;
133
143
 
@@ -11,7 +11,10 @@ export function deriveKeyFromMnemonicAndPath(
11
11
  }: {
12
12
  mnemonicToSeedSync: typeof mnemonicToSeedSyncT;
13
13
  } = require("ethereum-cryptography/bip39");
14
- const seed = mnemonicToSeedSync(mnemonic, passphrase);
14
+ // NOTE: If mnemonic has space or newline at the beginning or end, it will be trimmed.
15
+ // This is because mnemonic containing them may generate different private keys.
16
+ const trimmedMnemonic = mnemonic.trim();
17
+ const seed = mnemonicToSeedSync(trimmedMnemonic, passphrase);
15
18
 
16
19
  const {
17
20
  HDKey,
@@ -24,6 +24,15 @@ export function findClosestPackageJson(file: string): string | null {
24
24
  return findup.sync("package.json", { cwd: path.dirname(file) });
25
25
  }
26
26
 
27
+ export async function getPackageName(file: string): Promise<string> {
28
+ const packageJsonPath = findClosestPackageJson(file);
29
+ if (packageJsonPath !== null && packageJsonPath !== "") {
30
+ const packageJson: PackageJson = await fsExtra.readJSON(packageJsonPath);
31
+ return packageJson.name;
32
+ }
33
+ return "";
34
+ }
35
+
27
36
  export async function getPackageJson(): Promise<PackageJson> {
28
37
  const root = getPackageRoot();
29
38
  return fsExtra.readJSON(path.join(root, "package.json"));
@@ -41,6 +41,11 @@ export interface Artifacts {
41
41
  */
42
42
  getBuildInfo(fullyQualifiedName: string): Promise<BuildInfo | undefined>;
43
43
 
44
+ /**
45
+ * Synchronous version of getBuildInfo.
46
+ */
47
+ getBuildInfoSync(fullyQualifiedName: string): BuildInfo | undefined;
48
+
44
49
  /**
45
50
  * Returns an array with the absolute paths of all the existing artifacts.
46
51
  *
@@ -3,6 +3,7 @@ import path from "path";
3
3
  import { HardhatError } from "../internal/core/errors";
4
4
  import { ERRORS } from "../internal/core/errors-list";
5
5
  import { FileNotFoundError, getFileTrueCase } from "../internal/util/fs-utils";
6
+ import { getPackageName } from "../internal/util/packageInfo";
6
7
 
7
8
  const NODE_MODULES = "node_modules";
8
9
 
@@ -228,3 +229,17 @@ async function getSourceNameTrueCase(
228
229
  throw error;
229
230
  }
230
231
  }
232
+
233
+ /**
234
+ * This function returns true if the sourceName contains the current package's name
235
+ * as a substring
236
+ */
237
+ export async function includesOwnPackageName(
238
+ sourceName: string
239
+ ): Promise<boolean> {
240
+ const packageName = await getPackageName(sourceName);
241
+ if (packageName !== "") {
242
+ return sourceName.startsWith(`${packageName}/`);
243
+ }
244
+ return false;
245
+ }
@@ -36,6 +36,10 @@ export interface Artifacts {
36
36
  * can return undefined.
37
37
  */
38
38
  getBuildInfo(fullyQualifiedName: string): Promise<BuildInfo | undefined>;
39
+ /**
40
+ * Synchronous version of getBuildInfo.
41
+ */
42
+ getBuildInfoSync(fullyQualifiedName: string): BuildInfo | undefined;
39
43
  /**
40
44
  * Returns an array with the absolute paths of all the existing artifacts.
41
45
  *
@@ -1 +1 @@
1
- {"version":3,"file":"artifacts.d.ts","sourceRoot":"","sources":["../src/types/artifacts.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB;;;;;;;;;;OAUG;IACH,YAAY,CAAC,gCAAgC,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE1E;;OAEG;IACH,gB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,EAAE;QACpB,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KACzD,CAAC;CACH"}
@@ -52,4 +52,9 @@ export declare function isAbsolutePathSourceName(sourceName: string): boolean;
52
52
  * Note that a source name must not contain backslashes.
53
53
  */
54
54
  export declare function replaceBackslashes(str: string): string;
55
+ /**
56
+ * This function returns true if the sourceName contains the current package's name
57
+ * as a substring
58
+ */
59
+ export declare function includesOwnPackageName(sourceName: string): Promise<boolean>;
55
60
  //# sourceMappingURL=source-names.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"source-names.d.ts","sourceRoot":"","sources":["../src/utils/source-names.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,QAmC1D;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,OAAO,CAAC,CA4BlB;AAED;;;;;GAKG;AACH,wBAAsB,oCAAoC,CACxD,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,iBAUnB;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,WAAW,EAAE,MAAM,EACnB,qBAAqB,EAAE,MAAM,GAC5B,OAAO,CAAC,MAAM,CAAC,CAiBjB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GACjB,MAAM,CAER;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAEpE;AAWD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAUtD"}
1
+ {"version":3,"file":"source-names.d.ts","sourceRoot":"","sources":["../src/utils/source-names.ts"],"names":[],"mappings":"AASA;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,QAmC1D;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,OAAO,CAAC,CA4BlB;AAED;;;;;GAKG;AACH,wBAAsB,oCAAoC,CACxD,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,iBAUnB;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,WAAW,EAAE,MAAM,EACnB,qBAAqB,EAAE,MAAM,GAC5B,OAAO,CAAC,MAAM,CAAC,CAiBjB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GACjB,MAAM,CAER;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAEpE;AAWD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAUtD;AAqCD;;;GAGG;AACH,wBAAsB,sBAAsB,CAC1C,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,OAAO,CAAC,CAMlB"}
@@ -3,11 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.replaceBackslashes = exports.isAbsolutePathSourceName = exports.normalizeSourceName = exports.localSourceNameToPath = exports.localPathToSourceName = exports.validateSourceNameExistenceAndCasing = exports.isLocalSourceName = exports.validateSourceNameFormat = void 0;
6
+ exports.includesOwnPackageName = exports.replaceBackslashes = exports.isAbsolutePathSourceName = exports.normalizeSourceName = exports.localSourceNameToPath = exports.localPathToSourceName = exports.validateSourceNameExistenceAndCasing = exports.isLocalSourceName = exports.validateSourceNameFormat = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const errors_1 = require("../internal/core/errors");
9
9
  const errors_list_1 = require("../internal/core/errors-list");
10
10
  const fs_utils_1 = require("../internal/util/fs-utils");
11
+ const packageInfo_1 = require("../internal/util/packageInfo");
11
12
  const NODE_MODULES = "node_modules";
12
13
  /**
13
14
  * This function validates the source name's format.
@@ -185,4 +186,16 @@ async function getSourceNameTrueCase(fromDir, p) {
185
186
  throw error;
186
187
  }
187
188
  }
189
+ /**
190
+ * This function returns true if the sourceName contains the current package's name
191
+ * as a substring
192
+ */
193
+ async function includesOwnPackageName(sourceName) {
194
+ const packageName = await (0, packageInfo_1.getPackageName)(sourceName);
195
+ if (packageName !== "") {
196
+ return sourceName.startsWith(`${packageName}/`);
197
+ }
198
+ return false;
199
+ }
200
+ exports.includesOwnPackageName = includesOwnPackageName;
188
201
  //# sourceMappingURL=source-names.js.map