Skip to content

Commit 620b2d7

Browse files
committed
refactor: remove unnecessary files
1 parent c97cd1e commit 620b2d7

19 files changed

+67
-3013
lines changed

packages/hardhat-core/src/internal/hardhat-network/provider/PoolState.ts

-48
This file was deleted.

packages/hardhat-core/src/internal/hardhat-network/provider/context.ts

-14
This file was deleted.

packages/hardhat-core/src/internal/hardhat-network/provider/miner.ts

-37
This file was deleted.

packages/hardhat-core/src/internal/hardhat-network/provider/node-types.ts

-29
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
import type { ReturnData } from "./return-data";
2-
import type { RunBlockResult } from "./vm/vm-adapter";
3-
41
import { Block } from "@nomicfoundation/ethereumjs-block";
52
import { Address } from "@nomicfoundation/ethereumjs-util";
63

74
import { HARDHAT_MEMPOOL_SUPPORTED_ORDERS } from "../../constants";
85
import { BuildInfo, HardhatNetworkChainsConfig } from "../../../types";
9-
import { MessageTrace } from "../stack-traces/message-trace";
106

117
export type NodeConfig = LocalNodeConfig | ForkedNodeConfig;
128

@@ -133,31 +129,6 @@ export interface Snapshot {
133129
nextPrevRandao: Buffer;
134130
}
135131

136-
export type SendTransactionResult =
137-
| string
138-
| MineBlockResult
139-
| MineBlockResult[];
140-
141-
export interface MineBlockResult {
142-
block: Block;
143-
blockResult: RunBlockResult;
144-
traces: GatherTracesResult[];
145-
}
146-
147-
export interface RunCallResult extends GatherTracesResult {
148-
result: ReturnData;
149-
}
150-
151-
export interface EstimateGasResult extends GatherTracesResult {
152-
estimation: bigint;
153-
}
154-
155-
export interface GatherTracesResult {
156-
trace: MessageTrace | undefined;
157-
error?: Error;
158-
consoleLogMessages: string[];
159-
}
160-
161132
export interface FeeHistory {
162133
oldestBlock: bigint;
163134
baseFeePerGas: bigint[];

packages/hardhat-core/src/internal/hardhat-network/provider/output.ts

-85
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import type { RunTxResult } from "./vm/vm-adapter";
21
import { Block } from "@nomicfoundation/ethereumjs-block";
32
import { Common } from "@nomicfoundation/ethereumjs-common";
43
import { TypedTransaction } from "@nomicfoundation/ethereumjs-tx";
@@ -304,66 +303,6 @@ function getEffectiveGasPrice(tx: TypedTransaction, baseFeePerGas: bigint) {
304303
);
305304
}
306305

307-
export function getRpcReceiptOutputsFromLocalBlockExecution(
308-
block: Block,
309-
results: RunTxResult[],
310-
showTransactionType: boolean
311-
): RpcReceiptOutput[] {
312-
const receipts: RpcReceiptOutput[] = [];
313-
314-
let blockLogIndex = 0;
315-
316-
for (let i = 0; i < results.length; i += 1) {
317-
const tx = block.transactions[i];
318-
const { createdAddress, gasUsed, receipt } = results[i];
319-
320-
const logs = receipt.logs.map((log) => {
321-
const result = getRpcLogOutput(log, tx, block, i, blockLogIndex);
322-
blockLogIndex += 1;
323-
return result;
324-
});
325-
326-
const rpcReceipt: RpcReceiptOutput = {
327-
transactionHash: bufferToRpcData(tx.hash()),
328-
transactionIndex: numberToRpcQuantity(i),
329-
blockHash: bufferToRpcData(block.hash()),
330-
blockNumber: numberToRpcQuantity(block.header.number),
331-
from: bufferToRpcData(tx.getSenderAddress().toBuffer()),
332-
to: tx.to === undefined ? null : bufferToRpcData(tx.to.toBuffer()),
333-
cumulativeGasUsed: numberToRpcQuantity(receipt.cumulativeBlockGasUsed),
334-
gasUsed: numberToRpcQuantity(gasUsed),
335-
contractAddress:
336-
createdAddress !== undefined
337-
? bufferToRpcData(createdAddress.toBuffer())
338-
: null,
339-
logs,
340-
logsBloom: bufferToRpcData(receipt.bitvector),
341-
// There's no way to execute an EIP-2718 tx locally if we aren't in
342-
// an HF >= Berlin, so this check is enough
343-
type: showTransactionType ? numberToRpcQuantity(tx.type) : undefined,
344-
};
345-
346-
if ("stateRoot" in receipt) {
347-
rpcReceipt.root = bufferToRpcData(receipt.stateRoot);
348-
} else {
349-
rpcReceipt.status = numberToRpcQuantity(receipt.status);
350-
}
351-
352-
if (block.header.baseFeePerGas !== undefined) {
353-
const effectiveGasPrice = getEffectiveGasPrice(
354-
tx,
355-
block.header.baseFeePerGas
356-
);
357-
358-
rpcReceipt.effectiveGasPrice = numberToRpcQuantity(effectiveGasPrice);
359-
}
360-
361-
receipts.push(rpcReceipt);
362-
}
363-
364-
return receipts;
365-
}
366-
367306
export function remoteReceiptToRpcReceiptOutput(
368307
receipt: RpcTransactionReceipt,
369308
tx: TypedTransaction,
@@ -432,30 +371,6 @@ export function toRpcLogOutput(log: RpcLog): RpcLogOutput {
432371
};
433372
}
434373

435-
function getRpcLogOutput(
436-
log: any[],
437-
tx: TypedTransaction,
438-
block?: Block,
439-
transactionIndex?: number,
440-
logIndex?: number
441-
): RpcLogOutput {
442-
return {
443-
removed: false,
444-
logIndex: logIndex !== undefined ? numberToRpcQuantity(logIndex) : null,
445-
transactionIndex:
446-
transactionIndex !== undefined
447-
? numberToRpcQuantity(transactionIndex)
448-
: null,
449-
transactionHash: block !== undefined ? bufferToRpcData(tx.hash()) : null,
450-
blockHash: block !== undefined ? bufferToRpcData(block.hash()) : null,
451-
blockNumber:
452-
block !== undefined ? numberToRpcQuantity(block.header.number) : null,
453-
address: bufferToRpcData(log[0]),
454-
data: bufferToRpcData(log[2]),
455-
topics: log[1].map((topic: Buffer) => bufferToRpcData(topic)),
456-
};
457-
}
458-
459374
export function shouldShowTransactionTypeForHardfork(common: Common) {
460375
return common.gteHardfork(FIRST_HARDFORK_WITH_TRANSACTION_TYPE);
461376
}

0 commit comments

Comments
 (0)