@@ -5,7 +5,7 @@ use graph::data::subgraph::API_VERSION_0_0_2;
55use graph:: data:: subgraph:: API_VERSION_0_0_6 ;
66use graph:: data:: subgraph:: API_VERSION_0_0_7 ;
77use graph:: data_source:: common:: DeclaredCall ;
8- use graph:: prelude:: alloy:: consensus:: Transaction as TransactioTrait ;
8+ use graph:: prelude:: alloy:: consensus:: Transaction as TransactionTrait ;
99use graph:: prelude:: alloy:: primitives:: { Address , B256 , U256 } ;
1010use graph:: prelude:: alloy:: rpc:: types:: Log ;
1111use graph:: prelude:: alloy:: rpc:: types:: Transaction ;
@@ -483,13 +483,17 @@ impl<'a> EthereumBlockData<'a> {
483483#[ derive( Clone , Debug ) ]
484484pub struct EthereumTransactionData < ' a > {
485485 tx : & ' a Transaction ,
486+ base_fee_per_gas : Option < u64 > ,
486487}
487488
488489impl < ' a > EthereumTransactionData < ' a > {
489490 // We don't implement `From` because it causes confusion with the `from`
490491 // 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+ }
493497 }
494498
495499 pub fn hash ( & self ) -> & B256 {
@@ -517,8 +521,7 @@ impl<'a> EthereumTransactionData<'a> {
517521 }
518522
519523 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 )
522525 }
523526
524527 pub fn input ( & self ) -> & [ u8 ] {
@@ -548,7 +551,7 @@ impl<'a> EthereumEventData<'a> {
548551 ) -> Self {
549552 EthereumEventData {
550553 block : EthereumBlockData :: from ( block) ,
551- transaction : EthereumTransactionData :: new ( tx) ,
554+ transaction : EthereumTransactionData :: new ( tx, block . base_fee_per_gas ( ) ) ,
552555 log,
553556 params,
554557 }
@@ -598,7 +601,7 @@ impl<'a> EthereumCallData<'a> {
598601 ) -> EthereumCallData < ' a > {
599602 EthereumCallData {
600603 block : EthereumBlockData :: from ( block) ,
601- transaction : EthereumTransactionData :: new ( transaction) ,
604+ transaction : EthereumTransactionData :: new ( transaction, block . base_fee_per_gas ( ) ) ,
602605 inputs,
603606 outputs,
604607 call,
0 commit comments