@@ -7,15 +7,15 @@ use graph::{
77 blockchain:: {
88 self , Block as BlockchainBlock , BlockPtr , BlockTime , ChainStoreBlock , ChainStoreData ,
99 } ,
10+ components:: ethereum:: { AnyBlock , AnyHeader , AnyRpcHeader , AnyRpcTransaction , AnyTxEnvelope } ,
1011 prelude:: {
1112 alloy:: {
1213 self ,
13- consensus:: { ReceiptEnvelope , ReceiptWithBloom , TxEnvelope , TxType } ,
14+ consensus:: { ReceiptWithBloom , TxEnvelope , TxType } ,
15+ network:: AnyReceiptEnvelope ,
1416 primitives:: { aliases:: B2048 , Address , Bloom , Bytes , LogData , B256 , U256 } ,
15- rpc:: types:: {
16- AccessList , AccessListItem , Block as AlloyBlock , Transaction ,
17- TransactionReceipt as AlloyTransactionReceipt ,
18- } ,
17+ rpc:: types:: { self as alloy_rpc_types, AccessList , AccessListItem , Transaction } ,
18+ serde:: WithOtherFields ,
1919 } ,
2020 BlockNumber , Error , EthereumBlock , EthereumBlockWithCalls , EthereumCall ,
2121 LightEthereumBlock ,
@@ -378,10 +378,10 @@ impl TryInto<BlockFinality> for &Block {
378378 }
379379}
380380
381- impl TryInto < AlloyBlock > for & Block {
381+ impl TryInto < AnyBlock > for & Block {
382382 type Error = Error ;
383383
384- fn try_into ( self ) -> Result < AlloyBlock , Self :: Error > {
384+ fn try_into ( self ) -> Result < AnyBlock , Self :: Error > {
385385 let header = self . header ( ) ;
386386
387387 let block_hash = self . hash . try_decode_proto ( "block hash" ) ?;
@@ -466,19 +466,31 @@ impl TryInto<AlloyBlock> for &Block {
466466 . map ( |u| u. hash . try_decode_proto ( "uncle hash" ) )
467467 . collect :: < Result < Vec < B256 > , _ > > ( ) ?;
468468
469- Ok ( AlloyBlock :: new (
470- rpc_header,
471- alloy:: rpc:: types:: BlockTransactions :: Full ( transactions) ,
472- )
473- . with_uncles ( uncles) )
469+ use alloy:: rpc:: types:: Block ;
470+
471+ let any_header: AnyRpcHeader = rpc_header. map ( AnyHeader :: from) ;
472+
473+ let any_transactions: Vec < AnyRpcTransaction > = transactions
474+ . into_iter ( )
475+ . map ( |tx| AnyRpcTransaction :: new ( WithOtherFields :: new ( tx. map ( AnyTxEnvelope :: Ethereum ) ) ) )
476+ . collect ( ) ;
477+
478+ let any_block = Block {
479+ header : any_header,
480+ transactions : alloy:: rpc:: types:: BlockTransactions :: Full ( any_transactions) ,
481+ uncles,
482+ withdrawals : None ,
483+ } ;
484+
485+ Ok ( AnyBlock :: new ( WithOtherFields :: new ( any_block) ) )
474486 }
475487}
476488
477489impl TryInto < EthereumBlockWithCalls > for & Block {
478490 type Error = Error ;
479491
480492 fn try_into ( self ) -> Result < EthereumBlockWithCalls , Self :: Error > {
481- let alloy_block: AlloyBlock = self . try_into ( ) ?;
493+ let alloy_block: AnyBlock = self . try_into ( ) ?;
482494
483495 let transaction_receipts = self
484496 . transaction_traces
@@ -494,7 +506,7 @@ impl TryInto<EthereumBlockWithCalls> for &Block {
494506 #[ allow( unreachable_code) ]
495507 let block = EthereumBlockWithCalls {
496508 ethereum_block : EthereumBlock {
497- block : Arc :: new ( LightEthereumBlock :: new ( alloy_block. into ( ) ) ) ,
509+ block : Arc :: new ( LightEthereumBlock :: new ( alloy_block) ) ,
498510 transaction_receipts,
499511 } ,
500512 // Comment (437a9f17-67cc-478f-80a3-804fe554b227): This Some() will avoid calls in the triggers_in_block
@@ -521,7 +533,7 @@ impl TryInto<EthereumBlockWithCalls> for &Block {
521533fn transaction_trace_to_alloy_txn_reciept (
522534 t : & TransactionTrace ,
523535 block : & Block ,
524- ) -> Result < Option < AlloyTransactionReceipt < ReceiptEnvelope < alloy:: rpc :: types :: Log > > > , Error > {
536+ ) -> Result < Option < alloy:: network :: AnyTransactionReceipt > , Error > {
525537 use alloy:: consensus:: { Eip658Value , Receipt } ;
526538 let r = t. receipt . as_ref ( ) ;
527539
@@ -600,15 +612,20 @@ fn transaction_trace_to_alloy_txn_reciept(
600612 )
601613 } ) ?;
602614
603- let envelope = match tx_type {
604- TxType :: Legacy => ReceiptEnvelope :: Legacy ( receipt_with_bloom) ,
605- TxType :: Eip2930 => ReceiptEnvelope :: Eip2930 ( receipt_with_bloom) ,
606- TxType :: Eip1559 => ReceiptEnvelope :: Eip1559 ( receipt_with_bloom) ,
607- TxType :: Eip4844 => ReceiptEnvelope :: Eip4844 ( receipt_with_bloom) ,
608- TxType :: Eip7702 => ReceiptEnvelope :: Eip7702 ( receipt_with_bloom) ,
615+ let ty = match tx_type {
616+ TxType :: Legacy => 0 ,
617+ TxType :: Eip2930 => 1 ,
618+ TxType :: Eip1559 => 2 ,
619+ TxType :: Eip4844 => 3 ,
620+ TxType :: Eip7702 => 4 ,
621+ } ;
622+
623+ let any_envelope = AnyReceiptEnvelope {
624+ inner : receipt_with_bloom,
625+ r#type : ty,
609626 } ;
610627
611- Ok ( Some ( AlloyTransactionReceipt {
628+ let receipt = alloy_rpc_types :: TransactionReceipt {
612629 transaction_hash : t. hash . try_decode_proto ( "transaction hash" ) ?,
613630 transaction_index : Some ( t. index as u64 ) ,
614631 block_hash : Some ( block. hash . try_decode_proto ( "transaction block hash" ) ?) ,
@@ -626,8 +643,10 @@ fn transaction_trace_to_alloy_txn_reciept(
626643 let val: U256 = x. into ( ) ;
627644 val. to :: < u128 > ( )
628645 } ) ,
629- inner : envelope,
630- } ) )
646+ inner : any_envelope,
647+ } ;
648+
649+ Ok ( Some ( WithOtherFields :: new ( receipt) ) )
631650}
632651
633652impl BlockHeader {
0 commit comments