@@ -4,12 +4,15 @@ mod pbcodec;
44
55use anyhow:: format_err;
66use graph:: {
7+ alloy_todo,
78 blockchain:: {
89 self , Block as BlockchainBlock , BlockPtr , BlockTime , ChainStoreBlock , ChainStoreData ,
910 } ,
1011 prelude:: {
11- web3,
12- web3:: types:: { Bytes , H160 , H2048 , H256 , H64 , U256 , U64 } ,
12+ web3:: {
13+ self ,
14+ types:: { Bytes , H160 , H2048 , H256 , U256 , U64 } ,
15+ } ,
1316 BlockNumber , Error , EthereumBlock , EthereumBlockWithCalls , EthereumCall ,
1417 LightEthereumBlock ,
1518 } ,
@@ -225,64 +228,65 @@ impl TryInto<EthereumBlockWithCalls> for &Block {
225228 format_err ! ( "block header should always be present from gRPC Firehose" )
226229 } ) ?;
227230
228- let web3_block = web3:: types:: Block {
229- hash : Some ( self . hash . try_decode_proto ( "block hash" ) ?) ,
230- number : Some ( U64 :: from ( self . number ) ) ,
231- author : header. coinbase . try_decode_proto ( "author / coinbase" ) ?,
232- parent_hash : header. parent_hash . try_decode_proto ( "parent hash" ) ?,
233- uncles_hash : header. uncle_hash . try_decode_proto ( "uncle hash" ) ?,
234- state_root : header. state_root . try_decode_proto ( "state root" ) ?,
235- transactions_root : header
236- . transactions_root
237- . try_decode_proto ( "transactions root" ) ?,
238- receipts_root : header. receipt_root . try_decode_proto ( "receipt root" ) ?,
239- gas_used : U256 :: from ( header. gas_used ) ,
240- gas_limit : U256 :: from ( header. gas_limit ) ,
241- base_fee_per_gas : Some (
242- header
243- . base_fee_per_gas
244- . as_ref ( )
245- . map_or_else ( U256 :: default, |v| v. into ( ) ) ,
246- ) ,
247- extra_data : Bytes :: from ( header. extra_data . clone ( ) ) ,
248- logs_bloom : match & header. logs_bloom . len ( ) {
249- 0 => None ,
250- _ => Some ( header. logs_bloom . try_decode_proto ( "logs bloom" ) ?) ,
251- } ,
252- timestamp : header
253- . timestamp
254- . as_ref ( )
255- . map_or_else ( U256 :: default, |v| U256 :: from ( v. seconds ) ) ,
256- difficulty : header
257- . difficulty
258- . as_ref ( )
259- . map_or_else ( U256 :: default, |v| v. into ( ) ) ,
260- total_difficulty : Some (
261- header
262- . total_difficulty
263- . as_ref ( )
264- . map_or_else ( U256 :: default, |v| v. into ( ) ) ,
265- ) ,
266- // FIXME (SF): Firehose does not have seal fields, are they really used? Might be required for POA chains only also, I've seen that stuff on xDai (is this important?)
267- seal_fields : vec ! [ ] ,
268- uncles : self
269- . uncles
270- . iter ( )
271- . map ( |u| u. hash . try_decode_proto ( "uncle hash" ) )
272- . collect :: < Result < Vec < H256 > , _ > > ( ) ?,
273- transactions : self
274- . transaction_traces
275- . iter ( )
276- . map ( |t| TransactionTraceAt :: new ( t, self ) . try_into ( ) )
277- . collect :: < Result < Vec < web3:: types:: Transaction > , Error > > ( ) ?,
278- size : Some ( U256 :: from ( self . size ) ) ,
279- mix_hash : Some ( header. mix_hash . try_decode_proto ( "mix hash" ) ?) ,
280- nonce : Some ( H64 :: from_low_u64_be ( header. nonce ) ) ,
281- } ;
282-
231+ // let web3_block = web3::types::Block {
232+ // hash: Some(self.hash.try_decode_proto("block hash")?),
233+ // number: Some(U64::from(self.number)),
234+ // author: header.coinbase.try_decode_proto("author / coinbase")?,
235+ // parent_hash: header.parent_hash.try_decode_proto("parent hash")?,
236+ // uncles_hash: header.uncle_hash.try_decode_proto("uncle hash")?,
237+ // state_root: header.state_root.try_decode_proto("state root")?,
238+ // transactions_root: header
239+ // .transactions_root
240+ // .try_decode_proto("transactions root")?,
241+ // receipts_root: header.receipt_root.try_decode_proto("receipt root")?,
242+ // gas_used: U256::from(header.gas_used),
243+ // gas_limit: U256::from(header.gas_limit),
244+ // base_fee_per_gas: Some(
245+ // header
246+ // .base_fee_per_gas
247+ // .as_ref()
248+ // .map_or_else(U256::default, |v| v.into()),
249+ // ),
250+ // extra_data: Bytes::from(header.extra_data.clone()),
251+ // logs_bloom: match &header.logs_bloom.len() {
252+ // 0 => None,
253+ // _ => Some(header.logs_bloom.try_decode_proto("logs bloom")?),
254+ // },
255+ // timestamp: header
256+ // .timestamp
257+ // .as_ref()
258+ // .map_or_else(U256::default, |v| U256::from(v.seconds)),
259+ // difficulty: header
260+ // .difficulty
261+ // .as_ref()
262+ // .map_or_else(U256::default, |v| v.into()),
263+ // total_difficulty: Some(
264+ // header
265+ // .total_difficulty
266+ // .as_ref()
267+ // .map_or_else(U256::default, |v| v.into()),
268+ // ),
269+ // // FIXME (SF): Firehose does not have seal fields, are they really used? Might be required for POA chains only also, I've seen that stuff on xDai (is this important?)
270+ // seal_fields: vec![],
271+ // uncles: self
272+ // .uncles
273+ // .iter()
274+ // .map(|u| u.hash.try_decode_proto("uncle hash"))
275+ // .collect::<Result<Vec<H256>, _>>()?,
276+ // transactions: self
277+ // .transaction_traces
278+ // .iter()
279+ // .map(|t| TransactionTraceAt::new(t, self).try_into())
280+ // .collect::<Result<Vec<web3::types::Transaction>, Error>>()?,
281+ // size: Some(U256::from(self.size)),
282+ // mix_hash: Some(header.mix_hash.try_decode_proto("mix hash")?),
283+ // nonce: Some(H64::from_low_u64_be(header.nonce)),
284+ // };
285+
286+ #[ allow( unreachable_code) ]
283287 let block = EthereumBlockWithCalls {
284288 ethereum_block : EthereumBlock {
285- block : Arc :: new ( LightEthereumBlock :: new ( web3_block ) ) ,
289+ block : Arc :: new ( LightEthereumBlock :: new ( alloy_todo ! ( ) ) ) ,
286290 transaction_receipts : self
287291 . transaction_traces
288292 . iter ( )
0 commit comments