@@ -6,7 +6,10 @@ use papyrus_network_types::network_types::BroadcastedMessageMetadata;
66use starknet_api:: executable_transaction:: AccountTransaction ;
77use starknet_api:: rpc_transaction:: RpcTransaction ;
88use starknet_api:: transaction:: TransactionHash ;
9- use starknet_class_manager_types:: transaction_converter:: TransactionConverter ;
9+ use starknet_class_manager_types:: transaction_converter:: {
10+ TransactionConverter ,
11+ TransactionConverterTrait ,
12+ } ;
1013use starknet_class_manager_types:: SharedClassManagerClient ;
1114use starknet_gateway_types:: errors:: GatewaySpecError ;
1215use starknet_mempool_types:: communication:: { AddTransactionArgsWrapper , SharedMempoolClient } ;
@@ -23,7 +26,6 @@ use crate::state_reader::StateReaderFactory;
2326use crate :: stateful_transaction_validator:: StatefulTransactionValidator ;
2427use crate :: stateless_transaction_validator:: StatelessTransactionValidator ;
2528use crate :: sync_state_reader:: SyncStateReaderFactory ;
26- use crate :: utils:: compile_contract_and_build_executable_tx;
2729
2830#[ cfg( test) ]
2931#[ path = "gateway_test.rs" ]
@@ -80,7 +82,8 @@ impl Gateway {
8082 . map_err ( |join_err| {
8183 error ! ( "Failed to process tx: {}" , join_err) ;
8284 GatewaySpecError :: UnexpectedError { data : "Internal server error" . to_owned ( ) }
83- } ) ??;
85+ } ) ?
86+ . await ?;
8487
8588 let tx_hash = add_tx_args. tx . tx_hash ( ) ;
8689
@@ -97,10 +100,13 @@ struct ProcessTxBlockingTask {
97100 stateless_tx_validator : Arc < StatelessTransactionValidator > ,
98101 stateful_tx_validator : Arc < StatefulTransactionValidator > ,
99102 state_reader_factory : Arc < dyn StateReaderFactory > ,
103+ // TODO(noamsp): remove gatewayCompiler from here and erase it
104+ #[ allow( dead_code) ]
100105 gateway_compiler : Arc < GatewayCompiler > ,
101106 mempool_client : SharedMempoolClient ,
102107 chain_info : ChainInfo ,
103108 tx : RpcTransaction ,
109+ transaction_converter : TransactionConverter ,
104110}
105111
106112impl ProcessTxBlockingTask {
@@ -113,20 +119,32 @@ impl ProcessTxBlockingTask {
113119 mempool_client : gateway. mempool_client . clone ( ) ,
114120 chain_info : gateway. chain_info . clone ( ) ,
115121 tx,
122+ transaction_converter : gateway. transaction_converter . clone ( ) ,
116123 }
117124 }
118125
119- fn process_tx ( self ) -> GatewayResult < AddTransactionArgs > {
126+ async fn process_tx ( self ) -> GatewayResult < AddTransactionArgs > {
120127 // TODO(Arni, 1/5/2024): Perform congestion control.
121128
122129 // Perform stateless validations.
123130 self . stateless_tx_validator . validate ( & self . tx ) ?;
124131
125- let executable_tx = compile_contract_and_build_executable_tx (
126- self . tx ,
127- self . gateway_compiler . as_ref ( ) ,
128- & self . chain_info . chain_id ,
129- ) ?;
132+ let internal_tx =
133+ self . transaction_converter . convert_rpc_tx_to_internal_rpc_tx ( self . tx ) . await . map_err (
134+ |err| {
135+ error ! (
136+ "Failed to convert internal RPC transaction to executable transaction: {}" ,
137+ err
138+ ) ;
139+ GatewaySpecError :: UnexpectedError { data : "Internal server error." . to_owned ( ) }
140+ } ,
141+ ) ?;
142+
143+ let executable_tx = self
144+ . transaction_converter
145+ . convert_internal_rpc_tx_to_executable_tx ( internal_tx. clone ( ) )
146+ . await
147+ . unwrap ( ) ;
130148
131149 // Perform post compilation validations.
132150 if let AccountTransaction :: Declare ( executable_declare_tx) = & executable_tx {
@@ -152,6 +170,7 @@ impl ProcessTxBlockingTask {
152170 ) ?;
153171
154172 // TODO(Arni): Add the Sierra and the Casm to the mempool input.
173+ // TODO(noamsp): put internal_tx instead of executable_tx
155174 Ok ( AddTransactionArgs { tx : executable_tx, account_state : AccountState { address, nonce } } )
156175 }
157176}
0 commit comments