11use async_trait:: async_trait;
22use papyrus_network_types:: network_types:: BroadcastedMessageMetadata ;
33use starknet_api:: core:: ContractAddress ;
4- use starknet_api:: executable_transaction:: AccountTransaction ;
5- use starknet_api:: rpc_transaction:: {
6- RpcDeployAccountTransaction ,
7- RpcInvokeTransaction ,
8- RpcTransaction ,
9- } ;
4+ use starknet_api:: rpc_transaction:: InternalRpcTransaction ;
105use starknet_mempool_p2p_types:: communication:: SharedMempoolP2pPropagatorClient ;
116use starknet_mempool_types:: communication:: {
127 AddTransactionArgsWrapper ,
@@ -47,33 +42,20 @@ impl MempoolCommunicationWrapper {
4742 async fn send_tx_to_p2p (
4843 & self ,
4944 message_metadata : Option < BroadcastedMessageMetadata > ,
50- tx : AccountTransaction ,
45+ tx : InternalRpcTransaction ,
5146 ) -> MempoolResult < ( ) > {
5247 match message_metadata {
5348 Some ( message_metadata) => self
5449 . mempool_p2p_propagator_client
5550 . continue_propagation ( message_metadata)
5651 . await
57- . map_err ( |_| MempoolError :: P2pPropagatorClientError { tx_hash : tx. tx_hash ( ) } ) ,
52+ . map_err ( |_| MempoolError :: P2pPropagatorClientError { tx_hash : tx. tx_hash } ) ,
5853 None => {
59- let tx_hash = tx. tx_hash ( ) ;
60- match tx {
61- AccountTransaction :: Invoke ( invoke_tx) => self
62- . mempool_p2p_propagator_client
63- . add_transaction ( RpcTransaction :: Invoke ( RpcInvokeTransaction :: V3 (
64- invoke_tx. into ( ) ,
65- ) ) )
66- . await
67- . map_err ( |_| MempoolError :: P2pPropagatorClientError { tx_hash } ) ?,
68- AccountTransaction :: DeployAccount ( deploy_account_tx) => self
69- . mempool_p2p_propagator_client
70- . add_transaction ( RpcTransaction :: DeployAccount (
71- RpcDeployAccountTransaction :: V3 ( deploy_account_tx. into ( ) ) ,
72- ) )
73- . await
74- . map_err ( |_| MempoolError :: P2pPropagatorClientError { tx_hash } ) ?,
75- AccountTransaction :: Declare ( _) => { }
76- }
54+ let tx_hash = tx. tx_hash ;
55+ self . mempool_p2p_propagator_client
56+ . add_transaction ( tx)
57+ . await
58+ . map_err ( |_| MempoolError :: P2pPropagatorClientError { tx_hash } ) ?;
7759 Ok ( ( ) )
7860 }
7961 }
@@ -85,18 +67,14 @@ impl MempoolCommunicationWrapper {
8567 ) -> MempoolResult < ( ) > {
8668 self . mempool . add_tx ( args_wrapper. args . clone ( ) ) ?;
8769 // TODO(AlonH): Verify that only transactions that were added to the mempool are sent.
88- // TODO(AlonH): handle declare correctly and remove this match.
89- match args_wrapper. args . tx {
90- AccountTransaction :: Declare ( _) => Ok ( ( ) ) ,
91- _ => self . send_tx_to_p2p ( args_wrapper. p2p_message_metadata , args_wrapper. args . tx ) . await ,
92- }
70+ self . send_tx_to_p2p ( args_wrapper. p2p_message_metadata , args_wrapper. args . tx ) . await
9371 }
9472
9573 fn commit_block ( & mut self , args : CommitBlockArgs ) -> MempoolResult < ( ) > {
9674 self . mempool . commit_block ( args)
9775 }
9876
99- fn get_txs ( & mut self , n_txs : usize ) -> MempoolResult < Vec < AccountTransaction > > {
77+ fn get_txs ( & mut self , n_txs : usize ) -> MempoolResult < Vec < InternalRpcTransaction > > {
10078 self . mempool . get_txs ( n_txs)
10179 }
10280
0 commit comments