@@ -242,12 +242,16 @@ impl<'a> TryInto<Transaction> for TransactionTraceAt<'a> {
242242 value,
243243 input : input. clone ( ) ,
244244 } ;
245- let signed_tx = Signed :: new_unchecked ( tx, signature, B256 :: ZERO ) ; // TODO(alloy_migration): extract actual transaction hash from trace
245+ let signed_tx = Signed :: new_unchecked (
246+ tx,
247+ signature,
248+ self . trace . hash . try_decode_proto ( "transaction hash" ) ?,
249+ ) ;
246250 TxEnvelope :: Legacy ( signed_tx)
247251 }
248252 TxType :: Eip2930 => {
249253 let tx = TxEip2930 {
250- chain_id : 1 , // TODO(alloy_migration): extract actual chain_id from trace
254+ chain_id : 0 , // TODO(alloy_migration): extract actual chain_id from trace (0 = placeholder)
251255 nonce,
252256 gas_price,
253257 gas_limit,
@@ -256,12 +260,16 @@ impl<'a> TryInto<Transaction> for TransactionTraceAt<'a> {
256260 access_list : access_list. clone ( ) , // Use actual access list from trace
257261 input : input. clone ( ) ,
258262 } ;
259- let signed_tx = Signed :: new_unchecked ( tx, signature, B256 :: ZERO ) ; // TODO(alloy_migration): extract actual transaction hash from trace
263+ let signed_tx = Signed :: new_unchecked (
264+ tx,
265+ signature,
266+ self . trace . hash . try_decode_proto ( "transaction hash" ) ?,
267+ ) ;
260268 TxEnvelope :: Eip2930 ( signed_tx)
261269 }
262270 TxType :: Eip1559 => {
263271 let tx = TxEip1559 {
264- chain_id : 1 , // TODO(alloy_migration): extract actual chain_id from trace
272+ chain_id : 0 , // TODO(alloy_migration): extract actual chain_id from trace (0 = placeholder)
265273 nonce,
266274 gas_limit,
267275 max_fee_per_gas : max_fee_per_gas_u128,
@@ -271,7 +279,11 @@ impl<'a> TryInto<Transaction> for TransactionTraceAt<'a> {
271279 access_list : access_list. clone ( ) , // Use actual access list from trace
272280 input : input. clone ( ) ,
273281 } ;
274- let signed_tx = Signed :: new_unchecked ( tx, signature, B256 :: ZERO ) ; // TODO(alloy_migration): extract actual transaction hash from trace
282+ let signed_tx = Signed :: new_unchecked (
283+ tx,
284+ signature,
285+ self . trace . hash . try_decode_proto ( "transaction hash" ) ?,
286+ ) ;
275287 TxEnvelope :: Eip1559 ( signed_tx)
276288 }
277289 TxType :: Eip4844 => {
@@ -280,20 +292,24 @@ impl<'a> TryInto<Transaction> for TransactionTraceAt<'a> {
280292 } ) ?;
281293
282294 let tx_eip4844 = TxEip4844 {
283- chain_id : 1 , // TODO(alloy_migration): extract actual chain_id from trace
295+ chain_id : 0 , // TODO(alloy_migration): extract actual chain_id from trace (0 = placeholder)
284296 nonce,
285297 gas_limit,
286298 max_fee_per_gas : max_fee_per_gas_u128,
287299 max_priority_fee_per_gas : max_priority_fee_per_gas_u128,
288300 to : to_address,
289301 value,
290302 access_list : access_list. clone ( ) , // Use actual access list from trace
291- blob_versioned_hashes : Vec :: new ( ) , // TODO(alloy_migration): extract actual blob hashes from trace
292- max_fee_per_blob_gas : 0u128 , // TODO(alloy_migration): extract actual blob gas fee from trace
303+ blob_versioned_hashes : Vec :: new ( ) , // TODO(alloy_migration): blob hashes not available in current protobuf definition
304+ max_fee_per_blob_gas : 0u128 , // TODO(alloy_migration): blob gas fee not available in current protobuf definition
293305 input : input. clone ( ) ,
294306 } ;
295307 let tx = TxEip4844Variant :: TxEip4844 ( tx_eip4844) ;
296- let signed_tx = Signed :: new_unchecked ( tx, signature, B256 :: ZERO ) ; // TODO(alloy_migration): extract actual transaction hash from trace
308+ let signed_tx = Signed :: new_unchecked (
309+ tx,
310+ signature,
311+ self . trace . hash . try_decode_proto ( "transaction hash" ) ?,
312+ ) ;
297313 TxEnvelope :: Eip4844 ( signed_tx)
298314 }
299315 TxType :: Eip7702 => {
@@ -302,18 +318,22 @@ impl<'a> TryInto<Transaction> for TransactionTraceAt<'a> {
302318 } ) ?;
303319
304320 let tx = TxEip7702 {
305- chain_id : 1 , // TODO(alloy_migration): extract actual chain_id from trace
321+ chain_id : 0 , // TODO(alloy_migration): extract actual chain_id from trace (0 = placeholder)
306322 nonce,
307323 gas_limit,
308324 max_fee_per_gas : max_fee_per_gas_u128,
309325 max_priority_fee_per_gas : max_priority_fee_per_gas_u128,
310326 to : to_address,
311327 value,
312328 access_list : access_list. clone ( ) , // Use actual access list from trace
313- authorization_list : Vec :: new ( ) , // TODO(alloy_migration): extract actual authorization list from trace
329+ authorization_list : Vec :: new ( ) , // TODO(alloy_migration): authorization list not available in current protobuf definition
314330 input : input. clone ( ) ,
315331 } ;
316- let signed_tx = Signed :: new_unchecked ( tx, signature, B256 :: ZERO ) ; // TODO(alloy_migration): extract actual transaction hash from trace
332+ let signed_tx = Signed :: new_unchecked (
333+ tx,
334+ signature,
335+ self . trace . hash . try_decode_proto ( "transaction hash" ) ?,
336+ ) ;
317337 TxEnvelope :: Eip7702 ( signed_tx)
318338 }
319339 } ;
@@ -325,7 +345,7 @@ impl<'a> TryInto<Transaction> for TransactionTraceAt<'a> {
325345 block_hash : Some ( block_hash) ,
326346 block_number : Some ( block_number) ,
327347 transaction_index,
328- effective_gas_price : if gas_price > 0 { Some ( gas_price) } else { None } , // TODO(alloy_migration): calculate actual effective gas price from trace
348+ effective_gas_price : if gas_price > 0 { Some ( gas_price) } else { None } , // gas_price already contains effective gas price per protobuf spec
329349 } )
330350 }
331351}
@@ -376,11 +396,11 @@ impl TryInto<AlloyBlock> for &Block {
376396 mix_hash : header. mix_hash . try_decode_proto ( "mix hash" ) ?,
377397 nonce : header. nonce . into ( ) ,
378398
379- withdrawals_root : None , // TODO(alloy_migration): extract from header if available
380- blob_gas_used : None , // TODO(alloy_migration): extract from header if available
381- excess_blob_gas : None , // TODO(alloy_migration): extract from header if available
382- parent_beacon_block_root : None , // TODO(alloy_migration): extract from header if available
383- requests_hash : None , // TODO(alloy_migration): extract from header if available
399+ withdrawals_root : None , // TODO(alloy_migration): not available in current protobuf definition
400+ blob_gas_used : None , // TODO(alloy_migration): not available in current protobuf definition
401+ excess_blob_gas : None , // TODO(alloy_migration): not available in current protobuf definition
402+ parent_beacon_block_root : None , // TODO(alloy_migration): not available in current protobuf definition
403+ requests_hash : None , // TODO(alloy_migration): not available in current protobuf definition
384404 } ;
385405
386406 let rpc_header = alloy:: rpc:: types:: Header {
@@ -553,9 +573,12 @@ fn transaction_trace_to_alloy_txn_reciept(
553573 contract_address,
554574 from : t. from . try_decode_proto ( "transaction from" ) ?,
555575 to : get_to_address ( t) ?,
556- effective_gas_price : 0 , // TODO(alloy_migration): calculate actual effective gas price from trace
557- blob_gas_used : None , // TODO(alloy_migration): extract blob gas used from trace if applicable
558- blob_gas_price : None , // TODO(alloy_migration): extract blob gas price from trace if applicable
576+ effective_gas_price : t. gas_price . as_ref ( ) . map_or ( 0u128 , |x| {
577+ let val: U256 = x. into ( ) ;
578+ val. to :: < u128 > ( )
579+ } ) , // gas_price already contains effective gas price per protobuf spec
580+ blob_gas_used : None , // TODO(alloy_migration): blob gas used not available in current protobuf definition
581+ blob_gas_price : None , // TODO(alloy_migration): blob gas price not available in current protobuf definition
559582 inner : envelope,
560583 } ) )
561584}
0 commit comments