@@ -2,9 +2,10 @@ import { RLP } from '@ethereumjs/rlp'
22import { Trie } from '@ethereumjs/trie'
33import {
44 type TxOptions ,
5+ createTx ,
56 createTxFromBlockBodyData ,
6- createTxFromSerializedData ,
7- createTxFromTxData ,
7+ createTxFromExecutionPayloadTx ,
8+ createTxFromRLP ,
89 normalizeTxParams ,
910} from '@ethereumjs/tx'
1011import {
@@ -25,7 +26,13 @@ import {
2526} from '@ethereumjs/util'
2627
2728import { generateCliqueBlockExtraData } from '../consensus/clique.js'
28- import { genRequestsTrieRoot , genTransactionsSszRoot , genTransactionsTrieRoot , genWithdrawalsSszRoot , genWithdrawalsTrieRoot } from '../helpers.js'
29+ import {
30+ genRequestsTrieRoot ,
31+ genTransactionsSszRoot ,
32+ genTransactionsTrieRoot ,
33+ genWithdrawalsSszRoot ,
34+ genWithdrawalsTrieRoot ,
35+ } from '../helpers.js'
2936import {
3037 Block ,
3138 createBlockHeader ,
@@ -46,6 +53,7 @@ import type {
4653 RequestsBytes ,
4754 WithdrawalsBytes ,
4855} from '../types.js'
56+ import type { Common } from '@ethereumjs/common'
4957import type { TypedTransaction } from '@ethereumjs/tx'
5058import type {
5159 CLRequest ,
@@ -55,7 +63,6 @@ import type {
5563 RequestBytes ,
5664 WithdrawalBytes ,
5765} from '@ethereumjs/util'
58- import type { Common } from '@ethereumjs/common'
5966
6067/**
6168 * Static constructor to create a block from a block data dictionary
@@ -78,7 +85,7 @@ export function createBlock(blockData: BlockData = {}, opts?: BlockOptions) {
7885 // parse transactions
7986 const transactions = [ ]
8087 for ( const txData of txsData ?? [ ] ) {
81- const tx = createTxFromTxData ( txData , {
88+ const tx = createTx ( txData , {
8289 ...opts ,
8390 // Use header common in case of setHardfork being activated
8491 common : header . common ,
@@ -289,7 +296,7 @@ export function createBlockFromRPC(
289296 const opts = { common : header . common }
290297 for ( const _txParams of blockParams . transactions ?? [ ] ) {
291298 const txParams = normalizeTxParams ( _txParams )
292- const tx = createTxFromTxData ( txParams , opts )
299+ const tx = createTx ( txParams , opts )
293300 transactions . push ( tx )
294301 }
295302
@@ -374,7 +381,7 @@ export const createBlockFromJSONRPCProvider = async (
374381 */
375382export async function createBlockFromExecutionPayload (
376383 payload : ExecutionPayload ,
377- opts : BlockOptions & { common : Common } ,
384+ opts : BlockOptions & { common : Common } ,
378385) : Promise < Block > {
379386 const {
380387 blockNumber : number ,
@@ -392,19 +399,19 @@ export async function createBlockFromExecutionPayload(
392399 const txs = [ ]
393400 for ( const [ index , serializedTxOrPayload ] of transactions . entries ( ) ) {
394401 try {
395- let tx ;
402+ let tx
396403 if ( opts . common . isActivatedEIP ( 6493 ) ) {
397404 if ( typeof serializedTxOrPayload === 'string' ) {
398405 throw Error ( 'EIP 6493 activated for transaction bytes' )
399406 }
400- tx = createTxFromExecutionPayloadTx ( hexToBytes ( serializedTxOrPayload ) , {
407+ tx = createTxFromExecutionPayloadTx ( serializedTxOrPayload , {
401408 common : opts ?. common ,
402409 } )
403- } else {
410+ } else {
404411 if ( typeof serializedTxOrPayload !== 'string' ) {
405412 throw Error ( 'EIP 6493 not activated for transaction payload' )
406413 }
407- tx = createTxFromSerializedData ( hexToBytes ( serializedTxOrPayload as PrefixedHexString ) , {
414+ tx = createTxFromRLP ( hexToBytes ( serializedTxOrPayload as PrefixedHexString ) , {
408415 common : opts ?. common ,
409416 } )
410417 }
@@ -415,10 +422,14 @@ export async function createBlockFromExecutionPayload(
415422 }
416423 }
417424
418- const transactionsTrie = opts . common . isActivatedEIP ( 6493 ) ? await genTransactionsSszRoot ( txs ) : await genTransactionsTrieRoot ( txs , new Trie ( { common : opts ?. common } ) )
425+ const transactionsTrie = opts . common . isActivatedEIP ( 6493 )
426+ ? await genTransactionsSszRoot ( txs )
427+ : await genTransactionsTrieRoot ( txs , new Trie ( { common : opts ?. common } ) )
419428 const withdrawals = withdrawalsData ?. map ( ( wData ) => createWithdrawal ( wData ) )
420429 const withdrawalsRoot = withdrawals
421- ? opts . common . isActivatedEIP ( 6493 ) ? genWithdrawalsSszRoot ( withdrawals ) : await genWithdrawalsTrieRoot ( withdrawals , new Trie ( { common : opts ?. common } ) )
430+ ? opts . common . isActivatedEIP ( 6493 )
431+ ? genWithdrawalsSszRoot ( withdrawals )
432+ : await genWithdrawalsTrieRoot ( withdrawals , new Trie ( { common : opts ?. common } ) )
422433 : undefined
423434
424435 const hasDepositRequests = depositRequests !== undefined && depositRequests !== null
0 commit comments