@@ -189,13 +189,13 @@ impl JsonRpcHandler {
189189 Ok ( client. execute ( request) . await ?)
190190 }
191191
192- // TODO: Temporary dynode override for older app versions. Remove after clients send matching preflightCommitment .
193- fn override_solana_send_transaction ( call : & JsonRpcCall ) -> JsonRpcCall {
192+ // TODO: Temporary dynode override for older app versions. Remove after clients send matching commitment .
193+ fn override_solana_get_latest_blockhash ( call : & JsonRpcCall ) -> JsonRpcCall {
194194 let mut call = call. clone ( ) ;
195195 if let serde_json:: Value :: Array ( items) = & mut call. params
196- && let Some ( serde_json:: Value :: Object ( config) ) = items. get_mut ( 1 )
196+ && let Some ( serde_json:: Value :: Object ( config) ) = items. get_mut ( 0 )
197197 {
198- config. insert ( "preflightCommitment " . to_string ( ) , "confirmed " . into ( ) ) ;
198+ config. insert ( "commitment " . to_string ( ) , "finalized " . into ( ) ) ;
199199 }
200200 call
201201 }
@@ -208,8 +208,8 @@ impl JsonRpcHandler {
208208 client : & reqwest:: Client ,
209209 forward_headers : & HeaderMap ,
210210 ) -> Result < ( JsonRpcResult , u16 , Vec < u8 > ) , Box < dyn std:: error:: Error + Send + Sync > > {
211- let upstream_call = if request. chain == Chain :: Solana && call. method == "sendTransaction " {
212- Self :: override_solana_send_transaction ( call)
211+ let upstream_call = if request. chain == Chain :: Solana && call. method == "getLatestBlockhash " {
212+ Self :: override_solana_get_latest_blockhash ( call)
213213 } else {
214214 call. clone ( )
215215 } ;
@@ -307,38 +307,34 @@ mod tests {
307307 }
308308
309309 #[ test]
310- fn test_override_solana_send_transaction ( ) {
311- let old_client = JsonRpcCall {
310+ fn test_override_solana_get_latest_blockhash ( ) {
311+ let confirmed_client = JsonRpcCall {
312312 jsonrpc : "2.0" . into ( ) ,
313- method : "sendTransaction " . into ( ) ,
314- params : json ! ( [ "tx" , { "encoding " : "base64" , "skipPreflight" : false } ] ) ,
313+ method : "getLatestBlockhash " . into ( ) ,
314+ params : json ! ( [ { "commitment " : "confirmed" } ] ) ,
315315 id : 1 ,
316316 } ;
317- let result = JsonRpcHandler :: override_solana_send_transaction ( & old_client) ;
318- assert_eq ! ( result. params[ 0 ] , "tx" ) ;
319- assert_eq ! ( result. params[ 1 ] [ "encoding" ] , "base64" ) ;
320- assert_eq ! ( result. params[ 1 ] [ "skipPreflight" ] , false ) ;
321- assert_eq ! ( result. params[ 1 ] [ "preflightCommitment" ] , "confirmed" ) ;
317+ let result = JsonRpcHandler :: override_solana_get_latest_blockhash ( & confirmed_client) ;
318+ assert_eq ! ( result. params[ 0 ] [ "commitment" ] , "finalized" ) ;
322319
323- let new_client = JsonRpcCall {
320+ let processed_client = JsonRpcCall {
324321 jsonrpc : "2.0" . into ( ) ,
325- method : "sendTransaction " . into ( ) ,
326- params : json ! ( [ "tx" , { "encoding " : "base64 " , "skipPreflight " : false , "preflightCommitment" : "finalized" } ] ) ,
322+ method : "getLatestBlockhash " . into ( ) ,
323+ params : json ! ( [ { "commitment " : "processed " , "minContextSlot " : 100 } ] ) ,
327324 id : 1 ,
328325 } ;
329- let result = JsonRpcHandler :: override_solana_send_transaction ( & new_client) ;
330- assert_eq ! ( result. params[ 1 ] [ "encoding" ] , "base64" ) ;
331- assert_eq ! ( result. params[ 1 ] [ "skipPreflight" ] , false ) ;
332- assert_eq ! ( result. params[ 1 ] [ "preflightCommitment" ] , "confirmed" ) ;
326+ let result = JsonRpcHandler :: override_solana_get_latest_blockhash ( & processed_client) ;
327+ assert_eq ! ( result. params[ 0 ] [ "commitment" ] , "finalized" ) ;
328+ assert_eq ! ( result. params[ 0 ] [ "minContextSlot" ] , 100 ) ;
333329
334- let no_config = JsonRpcCall {
330+ let no_params = JsonRpcCall {
335331 jsonrpc : "2.0" . into ( ) ,
336- method : "sendTransaction " . into ( ) ,
337- params : json ! ( [ "tx" ] ) ,
332+ method : "getLatestBlockhash " . into ( ) ,
333+ params : json ! ( [ ] ) ,
338334 id : 1 ,
339335 } ;
340- let result = JsonRpcHandler :: override_solana_send_transaction ( & no_config ) ;
341- assert_eq ! ( result. params, json!( [ "tx" ] ) ) ;
336+ let result = JsonRpcHandler :: override_solana_get_latest_blockhash ( & no_params ) ;
337+ assert_eq ! ( result. params, json!( [ ] ) ) ;
342338 }
343339
344340 #[ test]
0 commit comments