diff --git a/CHANGELOG.md b/CHANGELOG.md index 6feef269ce..2210d84caa 100644 --- a/CHANGELOG.md +++ b/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)). - 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 `async_rpc` a method which returns a nonblocking solana rpc client ([2322](https://github.com/coral-xyz/anchor/pull/2322)). ### Fixes diff --git a/client/src/lib.rs b/client/src/lib.rs index 51906397ce..477914a6a1 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -9,6 +9,7 @@ use anchor_lang::{AccountDeserialize, Discriminator, InstructionData, ToAccountM use regex::Regex; use solana_account_decoder::UiAccountEncoding; 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::rpc_client::RpcClient; use solana_client::rpc_config::{ @@ -166,6 +167,13 @@ impl + Clone> Program { ) } + 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 { self.program_id }