Skip to content

Commit

Permalink
add async_rpc method (#2322)
Browse files Browse the repository at this point in the history
  • Loading branch information
cavemanloverboy authored Feb 6, 2023
1 parent 020b644 commit cd63049
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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 {
self.program_id
}
Expand Down

1 comment on commit cd63049

@vercel
Copy link

@vercel vercel bot commented on cd63049 Feb 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

anchor-docs – ./

anchor-docs-200ms.vercel.app
anchor-docs-git-master-200ms.vercel.app
www.anchor-lang.com
anchor-lang.com

Please sign in to comment.