@@ -242,12 +242,16 @@ impl<'a> TryInto<Transaction> for TransactionTraceAt<'a> {
242
242
value,
243
243
input : input. clone ( ) ,
244
244
} ;
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
+ ) ;
246
250
TxEnvelope :: Legacy ( signed_tx)
247
251
}
248
252
TxType :: Eip2930 => {
249
253
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)
251
255
nonce,
252
256
gas_price,
253
257
gas_limit,
@@ -256,12 +260,16 @@ impl<'a> TryInto<Transaction> for TransactionTraceAt<'a> {
256
260
access_list : access_list. clone ( ) , // Use actual access list from trace
257
261
input : input. clone ( ) ,
258
262
} ;
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
+ ) ;
260
268
TxEnvelope :: Eip2930 ( signed_tx)
261
269
}
262
270
TxType :: Eip1559 => {
263
271
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)
265
273
nonce,
266
274
gas_limit,
267
275
max_fee_per_gas : max_fee_per_gas_u128,
@@ -271,7 +279,11 @@ impl<'a> TryInto<Transaction> for TransactionTraceAt<'a> {
271
279
access_list : access_list. clone ( ) , // Use actual access list from trace
272
280
input : input. clone ( ) ,
273
281
} ;
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
+ ) ;
275
287
TxEnvelope :: Eip1559 ( signed_tx)
276
288
}
277
289
TxType :: Eip4844 => {
@@ -280,20 +292,24 @@ impl<'a> TryInto<Transaction> for TransactionTraceAt<'a> {
280
292
} ) ?;
281
293
282
294
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)
284
296
nonce,
285
297
gas_limit,
286
298
max_fee_per_gas : max_fee_per_gas_u128,
287
299
max_priority_fee_per_gas : max_priority_fee_per_gas_u128,
288
300
to : to_address,
289
301
value,
290
302
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
293
305
input : input. clone ( ) ,
294
306
} ;
295
307
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
+ ) ;
297
313
TxEnvelope :: Eip4844 ( signed_tx)
298
314
}
299
315
TxType :: Eip7702 => {
@@ -302,18 +318,22 @@ impl<'a> TryInto<Transaction> for TransactionTraceAt<'a> {
302
318
} ) ?;
303
319
304
320
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)
306
322
nonce,
307
323
gas_limit,
308
324
max_fee_per_gas : max_fee_per_gas_u128,
309
325
max_priority_fee_per_gas : max_priority_fee_per_gas_u128,
310
326
to : to_address,
311
327
value,
312
328
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
314
330
input : input. clone ( ) ,
315
331
} ;
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
+ ) ;
317
337
TxEnvelope :: Eip7702 ( signed_tx)
318
338
}
319
339
} ;
@@ -325,7 +345,7 @@ impl<'a> TryInto<Transaction> for TransactionTraceAt<'a> {
325
345
block_hash : Some ( block_hash) ,
326
346
block_number : Some ( block_number) ,
327
347
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
329
349
} )
330
350
}
331
351
}
@@ -376,11 +396,11 @@ impl TryInto<AlloyBlock> for &Block {
376
396
mix_hash : header. mix_hash . try_decode_proto ( "mix hash" ) ?,
377
397
nonce : header. nonce . into ( ) ,
378
398
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
384
404
} ;
385
405
386
406
let rpc_header = alloy:: rpc:: types:: Header {
@@ -553,9 +573,12 @@ fn transaction_trace_to_alloy_txn_reciept(
553
573
contract_address,
554
574
from : t. from . try_decode_proto ( "transaction from" ) ?,
555
575
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
559
582
inner : envelope,
560
583
} ) )
561
584
}
0 commit comments