@@ -11,7 +11,8 @@ use starknet_api::rpc_transaction::{
1111 RpcDeployAccountTransaction ,
1212 RpcTransaction ,
1313} ;
14- use starknet_api:: transaction:: CalculateContractAddress ;
14+ use starknet_api:: transaction:: fields:: Fee ;
15+ use starknet_api:: transaction:: { CalculateContractAddress , TransactionHasher , TransactionVersion } ;
1516use starknet_api:: { executable_transaction, transaction, StarknetApiError } ;
1617use thiserror:: Error ;
1718
@@ -64,16 +65,32 @@ pub struct TransactionConverter {
6465impl TransactionConverterTrait for TransactionConverter {
6566 async fn convert_internal_consensus_tx_to_consensus_tx (
6667 & self ,
67- _tx : InternalConsensusTransaction ,
68+ tx : InternalConsensusTransaction ,
6869 ) -> TransactionConverterResult < ConsensusTransaction > {
69- todo ! ( )
70+ match tx {
71+ InternalConsensusTransaction :: RpcTransaction ( tx) => self
72+ . convert_internal_rpc_tx_to_rpc_tx ( tx)
73+ . await
74+ . map ( ConsensusTransaction :: RpcTransaction ) ,
75+ InternalConsensusTransaction :: L1Handler ( tx) => {
76+ Ok ( ConsensusTransaction :: L1Handler ( tx. tx ) )
77+ }
78+ }
7079 }
7180
7281 async fn convert_consensus_tx_to_internal_consensus_tx (
7382 & self ,
74- _tx : ConsensusTransaction ,
83+ tx : ConsensusTransaction ,
7584 ) -> TransactionConverterResult < InternalConsensusTransaction > {
76- todo ! ( )
85+ match tx {
86+ ConsensusTransaction :: RpcTransaction ( tx) => self
87+ . convert_rpc_tx_to_internal_rpc_tx ( tx)
88+ . await
89+ . map ( InternalConsensusTransaction :: RpcTransaction ) ,
90+ ConsensusTransaction :: L1Handler ( tx) => self
91+ . convert_consensus_l1_handler_to_internal_l1_handler ( tx)
92+ . map ( InternalConsensusTransaction :: L1Handler ) ,
93+ }
7794 }
7895
7996 async fn convert_internal_rpc_tx_to_rpc_tx (
@@ -142,17 +159,17 @@ impl TransactionConverterTrait for TransactionConverter {
142159 }
143160}
144161
145- // TODO(alonl): remove this once the conversion functions are implemented.
146- # [ allow ( dead_code ) ]
147- fn convert_consensus_l1_handler_to_internal_l1_handler (
148- _tx : transaction:: L1HandlerTransaction ,
149- ) -> executable_transaction:: L1HandlerTransaction {
150- todo ! ( )
151- }
152-
153- # [ allow ( dead_code ) ]
154- fn convert_internal_l1_handler_to_consensus_l1_handler (
155- _tx : executable_transaction :: L1HandlerTransaction ,
156- ) -> transaction :: L1HandlerTransaction {
157- todo ! ( )
162+ impl TransactionConverter {
163+ fn convert_consensus_l1_handler_to_internal_l1_handler (
164+ & self ,
165+ tx : transaction:: L1HandlerTransaction ,
166+ ) -> TransactionConverterResult < executable_transaction:: L1HandlerTransaction > {
167+ let tx_hash = tx . calculate_transaction_hash ( & self . chain_id , & TransactionVersion :: ZERO ) ? ;
168+ Ok ( executable_transaction :: L1HandlerTransaction {
169+ tx ,
170+ tx_hash ,
171+ // TODO(Gilad): Change this once we put real value in paid_fee_on_l1.
172+ paid_fee_on_l1 : Fee ( 1 ) ,
173+ } )
174+ }
158175}
0 commit comments