@@ -5,7 +5,7 @@ use graph::data::subgraph::API_VERSION_0_0_2;
5
5
use graph:: data:: subgraph:: API_VERSION_0_0_6 ;
6
6
use graph:: data:: subgraph:: API_VERSION_0_0_7 ;
7
7
use graph:: data_source:: common:: DeclaredCall ;
8
- use graph:: prelude:: alloy:: consensus:: Transaction as TransactioTrait ;
8
+ use graph:: prelude:: alloy:: consensus:: Transaction as TransactionTrait ;
9
9
use graph:: prelude:: alloy:: primitives:: { Address , B256 , U256 } ;
10
10
use graph:: prelude:: alloy:: rpc:: types:: Log ;
11
11
use graph:: prelude:: alloy:: rpc:: types:: Transaction ;
@@ -483,13 +483,17 @@ impl<'a> EthereumBlockData<'a> {
483
483
#[ derive( Clone , Debug ) ]
484
484
pub struct EthereumTransactionData < ' a > {
485
485
tx : & ' a Transaction ,
486
+ base_fee_per_gas : Option < u64 > ,
486
487
}
487
488
488
489
impl < ' a > EthereumTransactionData < ' a > {
489
490
// We don't implement `From` because it causes confusion with the `from`
490
491
// accessor method
491
- fn new ( tx : & ' a Transaction ) -> EthereumTransactionData < ' a > {
492
- EthereumTransactionData { tx }
492
+ fn new ( tx : & ' a Transaction , base_fee_per_gas : Option < u64 > ) -> EthereumTransactionData < ' a > {
493
+ EthereumTransactionData {
494
+ tx,
495
+ base_fee_per_gas,
496
+ }
493
497
}
494
498
495
499
pub fn hash ( & self ) -> & B256 {
@@ -517,8 +521,7 @@ impl<'a> EthereumTransactionData<'a> {
517
521
}
518
522
519
523
pub fn gas_price ( & self ) -> u128 {
520
- // EIP-1559 made this optional.
521
- self . tx . inner . gas_price ( ) . unwrap_or ( 0 )
524
+ self . tx . effective_gas_price ( self . base_fee_per_gas )
522
525
}
523
526
524
527
pub fn input ( & self ) -> & [ u8 ] {
@@ -548,7 +551,7 @@ impl<'a> EthereumEventData<'a> {
548
551
) -> Self {
549
552
EthereumEventData {
550
553
block : EthereumBlockData :: from ( block) ,
551
- transaction : EthereumTransactionData :: new ( tx) ,
554
+ transaction : EthereumTransactionData :: new ( tx, block . base_fee_per_gas ( ) ) ,
552
555
log,
553
556
params,
554
557
}
@@ -598,7 +601,7 @@ impl<'a> EthereumCallData<'a> {
598
601
) -> EthereumCallData < ' a > {
599
602
EthereumCallData {
600
603
block : EthereumBlockData :: from ( block) ,
601
- transaction : EthereumTransactionData :: new ( transaction) ,
604
+ transaction : EthereumTransactionData :: new ( transaction, block . base_fee_per_gas ( ) ) ,
602
605
inputs,
603
606
outputs,
604
607
call,
0 commit comments