Browse Source

fix: remove skip preflight from cli (#2492)

---------

Co-authored-by: acheron <acheroncrypto@gmail.com>
Pierre 2 years ago
parent
commit
b7bada148c
2 changed files with 7 additions and 31 deletions
  1. 1 0
      CHANGELOG.md
  2. 6 31
      cli/src/lib.rs

+ 1 - 0
CHANGELOG.md

@@ -22,6 +22,7 @@ The minor version will be incremented upon a breaking change and the patch versi
 - ts: Narrowed `AccountClient` type to it's appropriate account type ([#2440](https://github.com/coral-xyz/anchor/pull/2440))
 - lang: Fix inability to use identifiers `program_id`, `accounts`, `ix_data`, `remaining_accounts` in instruction arguments ([#2464](https://github.com/coral-xyz/anchor/pull/2464))
 - cli: Fix incorrect `metadata.address` generation in IDL after deploying with a custom keypair ([#2485](https://github.com/coral-xyz/anchor/pull/2485))
+- cli: IDL commands no longer hang when the payer doesn't have funds to pay for the transaction fee ([#2492](https://github.com/coral-xyz/anchor/pull/2492))
 
 ### Breaking
 

+ 6 - 31
cli/src/lib.rs

@@ -20,7 +20,6 @@ use semver::{Version, VersionReq};
 use serde::{Deserialize, Serialize};
 use serde_json::{json, Map, Value as JsonValue};
 use solana_client::rpc_client::RpcClient;
-use solana_client::rpc_config::RpcSendTransactionConfig;
 use solana_program::instruction::{AccountMeta, Instruction};
 use solana_sdk::account_utils::StateMut;
 use solana_sdk::bpf_loader;
@@ -1931,13 +1930,9 @@ fn idl_set_buffer(cfg_override: &ConfigOverride, program_id: Pubkey, buffer: Pub
         );
 
         // Send the transaction.
-        client.send_and_confirm_transaction_with_spinner_and_config(
+        client.send_and_confirm_transaction_with_spinner_and_commitment(
             &tx,
             CommitmentConfig::confirmed(),
-            RpcSendTransactionConfig {
-                skip_preflight: true,
-                ..RpcSendTransactionConfig::default()
-            },
         )?;
 
         Ok(())
@@ -2020,13 +2015,9 @@ fn idl_set_authority(
             &[&keypair],
             latest_hash,
         );
-        client.send_and_confirm_transaction_with_spinner_and_config(
+        client.send_and_confirm_transaction_with_spinner_and_commitment(
             &tx,
             CommitmentConfig::confirmed(),
-            RpcSendTransactionConfig {
-                skip_preflight: true,
-                ..RpcSendTransactionConfig::default()
-            },
         )?;
 
         println!("Authority update complete.");
@@ -2077,13 +2068,9 @@ fn idl_close_account(cfg: &Config, program_id: &Pubkey, idl_address: Pubkey) ->
         &[&keypair],
         latest_hash,
     );
-    client.send_and_confirm_transaction_with_spinner_and_config(
+    client.send_and_confirm_transaction_with_spinner_and_commitment(
         &tx,
         CommitmentConfig::confirmed(),
-        RpcSendTransactionConfig {
-            skip_preflight: true,
-            ..RpcSendTransactionConfig::default()
-        },
     )?;
 
     Ok(())
@@ -2141,13 +2128,9 @@ fn idl_write(cfg: &Config, program_id: &Pubkey, idl: &Idl, idl_address: Pubkey)
             &[&keypair],
             latest_hash,
         );
-        client.send_and_confirm_transaction_with_spinner_and_config(
+        client.send_and_confirm_transaction_with_spinner_and_commitment(
             &tx,
             CommitmentConfig::confirmed(),
-            RpcSendTransactionConfig {
-                skip_preflight: true,
-                ..RpcSendTransactionConfig::default()
-            },
         )?;
         offset += MAX_WRITE_SIZE;
     }
@@ -3175,13 +3158,9 @@ fn create_idl_account(
             &[&keypair],
             latest_hash,
         );
-        client.send_and_confirm_transaction_with_spinner_and_config(
+        client.send_and_confirm_transaction_with_spinner_and_commitment(
             &tx,
             CommitmentConfig::finalized(),
-            RpcSendTransactionConfig {
-                skip_preflight: true,
-                ..RpcSendTransactionConfig::default()
-            },
         )?;
     }
 
@@ -3243,13 +3222,9 @@ fn create_idl_buffer(
     );
 
     // Send the transaction.
-    client.send_and_confirm_transaction_with_spinner_and_config(
+    client.send_and_confirm_transaction_with_spinner_and_commitment(
         &tx,
         CommitmentConfig::confirmed(),
-        RpcSendTransactionConfig {
-            skip_preflight: true,
-            ..RpcSendTransactionConfig::default()
-        },
     )?;
 
     Ok(buffer.pubkey())