@@ -32,6 +32,10 @@ use tracing::{debug, trace};
3232use crate :: cartridge:: { encode_calls, VrfService } ;
3333use crate :: starknet:: { PendingBlockProvider , StarknetApi } ;
3434
35+ const STARKNET_ESTIMATE_FEE : & str = "starknet_estimateFee" ;
36+ const CARTRIDGE_ADD_EXECUTE_FROM_OUTSIDE : & str = "cartridge_addExecuteFromOutside" ;
37+ const CARTRIDGE_ADD_EXECUTE_FROM_OUTSIDE_TX : & str = "cartridge_addExecuteOutsideTransaction" ;
38+
3539#[ derive( Debug ) ]
3640pub struct ControllerDeploymentLayer < Pool , PP , PF >
3741where
6670
6771impl < S , Pool , PoolTx , PP , PF > ControllerDeploymentService < S , Pool , PP , PF >
6872where
73+ S : RpcServiceT + Send + Sync + Clone + ' static ,
6974 S : RpcServiceT < MethodResponse = MethodResponse > ,
70- Pool : TransactionPool < Transaction = PoolTx > + Send + Sync + ' static ,
75+ Pool : TransactionPool < Transaction = PoolTx > + ' static ,
7176 PoolTx : From < BroadcastedTxWithChainId > ,
7277 PP : PendingBlockProvider ,
7378 PF : ProviderFactory ,
@@ -78,18 +83,19 @@ where
7883 // extras results from estimate_fees to be
7984 // sure to return the same number of result than the number
8085 // of transactions in the request.
81- async fn handle_estimate_fee < ' a > (
86+ async fn starknet_estimate_fee < ' a > (
8287 & self ,
8388 params : EstimateFeeParams ,
8489 request : Request < ' a > ,
8590 ) -> S :: MethodResponse {
91+ let request_id = request. id ( ) . clone ( ) ;
8692 match self . handle_estimate_fee_inner ( params, request) . await {
8793 Ok ( response) => response,
88- Err ( err) => MethodResponse :: error ( request . id ( ) . clone ( ) , ErrorObjectOwned :: from ( err) ) ,
94+ Err ( err) => MethodResponse :: error ( request_id , ErrorObjectOwned :: from ( err) ) ,
8995 }
9096 }
9197
92- async fn handle_execute_outside < ' a > (
98+ async fn cartridge_add_execute_from_outside < ' a > (
9399 & self ,
94100 params : AddExecuteOutsideParams ,
95101 request : Request < ' a > ,
@@ -150,7 +156,7 @@ where
150156 let response = self . service . call ( new_request) . await ;
151157
152158 let res = response. as_json ( ) . get ( ) ;
153- let mut res = serde_json:: from_str :: < Response < Vec < FeeEstimate > > > ( res) . unwrap ( ) ;
159+ let res = serde_json:: from_str :: < Response < Vec < FeeEstimate > > > ( res) . unwrap ( ) ;
154160
155161 match res. payload {
156162 ResponsePayload :: Success ( mut estimates) => {
@@ -295,7 +301,7 @@ impl<S, Pool, PoolTx, PP, PF> RpcServiceT for ControllerDeploymentService<S, Poo
295301where
296302 S : RpcServiceT + Send + Sync + Clone + ' static ,
297303 S : RpcServiceT < MethodResponse = MethodResponse > ,
298- Pool : TransactionPool < Transaction = PoolTx > + Send + Sync + ' static ,
304+ Pool : TransactionPool < Transaction = PoolTx > + ' static ,
299305 PoolTx : From < BroadcastedTxWithChainId > ,
300306 PP : PendingBlockProvider ,
301307 PF : ProviderFactory ,
@@ -315,17 +321,17 @@ where
315321 let method = request. method_name ( ) ;
316322
317323 match method {
318- "starknet_estimateFee" => {
324+ STARKNET_ESTIMATE_FEE => {
319325 trace ! ( %method, "Intercepting JSON-RPC method." ) ;
320326 if let Some ( params) = parse_estimate_fee_params ( & request) {
321- return this. handle_estimate_fee ( params, request) . await ;
327+ return this. starknet_estimate_fee ( params, request) . await ;
322328 }
323329 }
324330
325- "addExecuteOutsideTransaction" | "addExecuteFromOutside" => {
331+ CARTRIDGE_ADD_EXECUTE_FROM_OUTSIDE | CARTRIDGE_ADD_EXECUTE_FROM_OUTSIDE_TX => {
326332 trace ! ( %method, "Intercepting JSON-RPC method." ) ;
327333 if let Some ( params) = parse_execute_outside_params ( & request) {
328- return this. handle_execute_outside ( params, request) . await ;
334+ return this. cartridge_add_execute_from_outside ( params, request) . await ;
329335 }
330336 }
331337
0 commit comments