|
1 |
| -import type { RunTxResult } from "./vm/vm-adapter"; |
2 | 1 | import { Block } from "@nomicfoundation/ethereumjs-block";
|
3 | 2 | import { Common } from "@nomicfoundation/ethereumjs-common";
|
4 | 3 | import { TypedTransaction } from "@nomicfoundation/ethereumjs-tx";
|
@@ -304,66 +303,6 @@ function getEffectiveGasPrice(tx: TypedTransaction, baseFeePerGas: bigint) {
|
304 | 303 | );
|
305 | 304 | }
|
306 | 305 |
|
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 |
| - |
367 | 306 | export function remoteReceiptToRpcReceiptOutput(
|
368 | 307 | receipt: RpcTransactionReceipt,
|
369 | 308 | tx: TypedTransaction,
|
@@ -432,30 +371,6 @@ export function toRpcLogOutput(log: RpcLog): RpcLogOutput {
|
432 | 371 | };
|
433 | 372 | }
|
434 | 373 |
|
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 |
| - |
459 | 374 | export function shouldShowTransactionTypeForHardfork(common: Common) {
|
460 | 375 | return common.gteHardfork(FIRST_HARDFORK_WITH_TRANSACTION_TYPE);
|
461 | 376 | }
|
|
0 commit comments