diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f3a189da7..622d06b75d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ com/project-serum/anchor/pull/1841)). * cli: Add `b` and `t` aliases for `build` and `test` respectively ([#1823](https://github.com/project-serum/anchor/pull/1823)). * spl: Add `sync_native` token program CPI wrapper function ([#1833](https://github.com/project-serum/anchor/pull/1833)). * ts: Implement a coder for system program ([#1920](https://github.com/project-serum/anchor/pull/1920)). +* client: Add send_with_spinner_and_config function to RequestBuilder ([#1926](https://github.com/project-serum/anchor/pull/1926)) ### Fixes diff --git a/client/src/lib.rs b/client/src/lib.rs index 16f679f9e9..5bbf862aa1 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -12,8 +12,8 @@ use solana_client::client_error::ClientError as SolanaClientError; use solana_client::pubsub_client::{PubsubClient, PubsubClientError, PubsubClientSubscription}; use solana_client::rpc_client::RpcClient; use solana_client::rpc_config::{ - RpcAccountInfoConfig, RpcProgramAccountsConfig, RpcTransactionLogsConfig, - RpcTransactionLogsFilter, + RpcAccountInfoConfig, RpcProgramAccountsConfig, RpcSendTransactionConfig, + RpcTransactionLogsConfig, RpcTransactionLogsFilter, }; use solana_client::rpc_filter::{Memcmp, MemcmpEncodedBytes, RpcFilterType}; use solana_client::rpc_response::{Response as RpcResponse, RpcLogsResponse}; @@ -556,6 +556,36 @@ impl<'a> RequestBuilder<'a> { .send_and_confirm_transaction(&tx) .map_err(Into::into) } + + pub fn send_with_spinner_and_config( + self, + config: RpcSendTransactionConfig, + ) -> Result { + let instructions = self.instructions()?; + + let mut signers = self.signers; + signers.push(&*self.payer); + + let rpc_client = RpcClient::new_with_commitment(self.cluster, self.options); + + let tx = { + let latest_hash = rpc_client.get_latest_blockhash()?; + Transaction::new_signed_with_payer( + &instructions, + Some(&self.payer.pubkey()), + &signers, + latest_hash, + ) + }; + + rpc_client + .send_and_confirm_transaction_with_spinner_and_config( + &tx, + rpc_client.commitment(), + config, + ) + .map_err(Into::into) + } } #[cfg(test)]