@@ -4,7 +4,10 @@ use mp_receipt::{Event, L1Gas, MsgToL1};
44use serde:: { Deserialize , Serialize } ;
55use starknet_types_core:: felt:: Felt ;
66
7- use crate :: transaction:: { DeployAccountTransaction , DeployTransaction , L1HandlerTransaction , Transaction } ;
7+ use crate :: transaction:: {
8+ DeclareTransaction , DeployAccountTransaction , DeployTransaction , InvokeTransaction , L1HandlerTransaction ,
9+ Transaction ,
10+ } ;
811
912#[ derive( Clone , Debug , Deserialize , Serialize , PartialEq , Eq ) ]
1013#[ serde( deny_unknown_fields) ]
@@ -49,20 +52,20 @@ impl ConfirmedReceipt {
4952
5053 pub fn into_mp ( self , tx : & Transaction ) -> mp_receipt:: TransactionReceipt {
5154 match tx {
52- Transaction :: Invoke ( _ ) => mp_receipt:: TransactionReceipt :: Invoke ( self . into_mp_invoke ( ) ) ,
55+ Transaction :: Invoke ( tx ) => mp_receipt:: TransactionReceipt :: Invoke ( self . into_mp_invoke ( tx ) ) ,
5356 Transaction :: L1Handler ( tx) => mp_receipt:: TransactionReceipt :: L1Handler ( self . into_mp_l1_handler ( tx) ) ,
54- Transaction :: Declare ( _ ) => mp_receipt:: TransactionReceipt :: Declare ( self . into_mp_declare ( ) ) ,
57+ Transaction :: Declare ( tx ) => mp_receipt:: TransactionReceipt :: Declare ( self . into_mp_declare ( tx ) ) ,
5558 Transaction :: Deploy ( tx) => mp_receipt:: TransactionReceipt :: Deploy ( self . into_mp_deploy ( tx) ) ,
5659 Transaction :: DeployAccount ( tx) => {
5760 mp_receipt:: TransactionReceipt :: DeployAccount ( self . into_mp_deploy_account ( tx) )
5861 }
5962 }
6063 }
6164
62- fn into_mp_invoke ( self ) -> mp_receipt:: InvokeTransactionReceipt {
65+ fn into_mp_invoke ( self , tx : & InvokeTransaction ) -> mp_receipt:: InvokeTransactionReceipt {
6366 mp_receipt:: InvokeTransactionReceipt {
6467 transaction_hash : self . transaction_hash ,
65- actual_fee : self . actual_fee . into ( ) ,
68+ actual_fee : fee_payment ( self . actual_fee , tx . version ( ) ) ,
6669 messages_sent : self . l2_to_l1_messages ,
6770 events : self . events ,
6871 execution_resources : self . execution_resources . into ( ) ,
@@ -86,18 +89,18 @@ impl ConfirmedReceipt {
8689 mp_receipt:: L1HandlerTransactionReceipt {
8790 message_hash : message_hash. try_into ( ) . unwrap_or_default ( ) ,
8891 transaction_hash : self . transaction_hash ,
89- actual_fee : self . actual_fee . into ( ) ,
92+ actual_fee : fee_payment ( self . actual_fee , tx . version ( ) ) ,
9093 messages_sent : self . l2_to_l1_messages ,
9194 events : self . events ,
9295 execution_resources : self . execution_resources . into ( ) ,
9396 execution_result : execution_result ( self . execution_status , self . revert_error ) ,
9497 }
9598 }
9699
97- fn into_mp_declare ( self ) -> mp_receipt:: DeclareTransactionReceipt {
100+ fn into_mp_declare ( self , tx : & DeclareTransaction ) -> mp_receipt:: DeclareTransactionReceipt {
98101 mp_receipt:: DeclareTransactionReceipt {
99102 transaction_hash : self . transaction_hash ,
100- actual_fee : self . actual_fee . into ( ) ,
103+ actual_fee : fee_payment ( self . actual_fee , tx . version ( ) ) ,
101104 messages_sent : self . l2_to_l1_messages ,
102105 events : self . events ,
103106 execution_resources : self . execution_resources . into ( ) ,
@@ -108,7 +111,7 @@ impl ConfirmedReceipt {
108111 fn into_mp_deploy ( self , tx : & DeployTransaction ) -> mp_receipt:: DeployTransactionReceipt {
109112 mp_receipt:: DeployTransactionReceipt {
110113 transaction_hash : self . transaction_hash ,
111- actual_fee : self . actual_fee . into ( ) ,
114+ actual_fee : fee_payment ( self . actual_fee , tx . version ( ) ) ,
112115 messages_sent : self . l2_to_l1_messages ,
113116 events : self . events ,
114117 execution_resources : self . execution_resources . into ( ) ,
@@ -120,7 +123,7 @@ impl ConfirmedReceipt {
120123 fn into_mp_deploy_account ( self , tx : & DeployAccountTransaction ) -> mp_receipt:: DeployAccountTransactionReceipt {
121124 mp_receipt:: DeployAccountTransactionReceipt {
122125 transaction_hash : self . transaction_hash ,
123- actual_fee : self . actual_fee . into ( ) ,
126+ actual_fee : fee_payment ( self . actual_fee , tx . version ( ) ) ,
124127 messages_sent : self . l2_to_l1_messages ,
125128 events : self . events ,
126129 execution_resources : self . execution_resources . into ( ) ,
@@ -290,3 +293,10 @@ pub enum ExecutionStatus {
290293 Succeeded ,
291294 Reverted ,
292295}
296+
297+ fn fee_payment ( fee : Felt , tx_version : u8 ) -> mp_receipt:: FeePayment {
298+ mp_receipt:: FeePayment {
299+ amount : fee,
300+ unit : if tx_version < 3 { mp_receipt:: PriceUnit :: Wei } else { mp_receipt:: PriceUnit :: Fri } ,
301+ }
302+ }
0 commit comments