@@ -60,6 +60,8 @@ pub struct AppState {
6060 tx_commitment : CommitmentConfig ,
6161 /// default sub_account_id to use if not provided
6262 default_subaccount_id : u16 ,
63+ /// skip tx preflight on send or not (default: false)
64+ skip_tx_preflight : bool ,
6365}
6466
6567impl AppState {
@@ -85,6 +87,7 @@ impl AppState {
8587 wallet : Wallet ,
8688 commitment : Option < ( CommitmentConfig , CommitmentConfig ) > ,
8789 default_subaccount_id : Option < u16 > ,
90+ skip_tx_preflight : bool ,
8891 ) -> Self {
8992 let ( state_commitment, tx_commitment) =
9093 commitment. unwrap_or ( ( CommitmentConfig :: confirmed ( ) , CommitmentConfig :: confirmed ( ) ) ) ;
@@ -113,6 +116,7 @@ impl AppState {
113116 dlob_client : DLOBClient :: new ( dlob_endpoint) ,
114117 tx_commitment,
115118 default_subaccount_id : default_subaccount_id. unwrap_or ( 0 ) ,
119+ skip_tx_preflight,
116120 }
117121 }
118122
@@ -519,17 +523,16 @@ impl AppState {
519523 . await
520524 . map_err ( SdkError :: from) ?;
521525 let tx = self . wallet . sign_tx ( tx, recent_block_hash) ?;
526+ let tx_config = RpcSendTransactionConfig {
527+ max_retries : Some ( 0 ) ,
528+ preflight_commitment : Some ( self . tx_commitment . commitment ) ,
529+ skip_preflight : self . skip_tx_preflight ,
530+ ..Default :: default ( )
531+ } ;
522532 let result = self
523533 . client
524534 . inner ( )
525- . send_transaction_with_config (
526- & tx,
527- RpcSendTransactionConfig {
528- max_retries : Some ( 0 ) ,
529- preflight_commitment : Some ( self . tx_commitment . commitment ) ,
530- ..Default :: default ( )
531- } ,
532- )
535+ . send_transaction_with_config ( & tx, tx_config)
533536 . await
534537 . map ( |s| {
535538 debug ! ( target: LOG_TARGET , "sent tx ({reason}): {s}" ) ;
@@ -547,18 +550,10 @@ impl AppState {
547550
548551 // double send the tx to help chances of landing
549552 let client = Arc :: clone ( & self . client ) ;
550- let commitment = self . tx_commitment . commitment ;
551553 tokio:: spawn ( async move {
552554 if let Err ( err) = client
553555 . inner ( )
554- . send_transaction_with_config (
555- & tx,
556- RpcSendTransactionConfig {
557- max_retries : Some ( 0 ) ,
558- preflight_commitment : Some ( commitment) ,
559- ..Default :: default ( )
560- } ,
561- )
556+ . send_transaction_with_config ( & tx, tx_config)
562557 . await
563558 {
564559 warn ! ( target: LOG_TARGET , "retry tx failed: {err:?}" ) ;
0 commit comments