cavemanloverboy 2 жил өмнө
parent
commit
cd63049c40

+ 1 - 0
CHANGELOG.md

@@ -18,6 +18,7 @@ The minor version will be incremented upon a breaking change and the patch versi
 - cli: `idl init` now supports very large IDL files ([#2329](https://github.com/coral-xyz/anchor/pull/2329)).
 - cli: `idl init` now supports very large IDL files ([#2329](https://github.com/coral-xyz/anchor/pull/2329)).
 - spl: Add `transfer_checked` function ([#2353](https://github.com/coral-xyz/anchor/pull/2353)).
 - spl: Add `transfer_checked` function ([#2353](https://github.com/coral-xyz/anchor/pull/2353)).
 - client: Add support for multithreading to the rust client: use flag `--multithreaded` ([#2321](https://github.com/coral-xyz/anchor/pull/2321)).
 - client: Add support for multithreading to the rust client: use flag `--multithreaded` ([#2321](https://github.com/coral-xyz/anchor/pull/2321)).
+- client: Add `async_rpc` a method which returns a nonblocking solana rpc client ([2322](https://github.com/coral-xyz/anchor/pull/2322)).
 
 
 ### Fixes
 ### Fixes
 
 

+ 8 - 0
client/src/lib.rs

@@ -9,6 +9,7 @@ use anchor_lang::{AccountDeserialize, Discriminator, InstructionData, ToAccountM
 use regex::Regex;
 use regex::Regex;
 use solana_account_decoder::UiAccountEncoding;
 use solana_account_decoder::UiAccountEncoding;
 use solana_client::client_error::ClientError as SolanaClientError;
 use solana_client::client_error::ClientError as SolanaClientError;
+use solana_client::nonblocking::rpc_client::RpcClient as AsyncRpcClient;
 use solana_client::pubsub_client::{PubsubClient, PubsubClientError, PubsubClientSubscription};
 use solana_client::pubsub_client::{PubsubClient, PubsubClientError, PubsubClientSubscription};
 use solana_client::rpc_client::RpcClient;
 use solana_client::rpc_client::RpcClient;
 use solana_client::rpc_config::{
 use solana_client::rpc_config::{
@@ -166,6 +167,13 @@ impl<C: Deref<Target = impl Signer> + Clone> Program<C> {
         )
         )
     }
     }
 
 
+    pub fn async_rpc(&self) -> AsyncRpcClient {
+        AsyncRpcClient::new_with_commitment(
+            self.cfg.cluster.url().to_string(),
+            self.cfg.options.unwrap_or_default(),
+        )
+    }
+
     pub fn id(&self) -> Pubkey {
     pub fn id(&self) -> Pubkey {
         self.program_id
         self.program_id
     }
     }