Client: Support sending via nonblocking RpcClient
This commit is contained in:
parent
442c00634e
commit
2058b6461c
|
@ -535,13 +535,16 @@ impl<'a> RequestBuilder<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send(self) -> Result<Signature, ClientError> {
|
pub fn send(self) -> Result<Signature, ClientError> {
|
||||||
|
let rpc_client = RpcClient::new_with_commitment(self.cluster.clone(), self.options);
|
||||||
|
self.send_rpc(&rpc_client)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn send_rpc(self, rpc_client: &RpcClient) -> Result<Signature, ClientError> {
|
||||||
let instructions = self.instructions()?;
|
let instructions = self.instructions()?;
|
||||||
|
|
||||||
let mut signers = self.signers;
|
let mut signers = self.signers;
|
||||||
signers.push(&*self.payer);
|
signers.push(&*self.payer);
|
||||||
|
|
||||||
let rpc_client = RpcClient::new_with_commitment(self.cluster, self.options);
|
|
||||||
|
|
||||||
let tx = {
|
let tx = {
|
||||||
let latest_hash = rpc_client.get_latest_blockhash()?;
|
let latest_hash = rpc_client.get_latest_blockhash()?;
|
||||||
Transaction::new_signed_with_payer(
|
Transaction::new_signed_with_payer(
|
||||||
|
@ -557,6 +560,31 @@ impl<'a> RequestBuilder<'a> {
|
||||||
.map_err(Into::into)
|
.map_err(Into::into)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn send_rpc_async(
|
||||||
|
self,
|
||||||
|
rpc_client: &solana_client::nonblocking::rpc_client::RpcClient,
|
||||||
|
) -> Result<Signature, ClientError> {
|
||||||
|
let instructions = self.instructions()?;
|
||||||
|
|
||||||
|
let mut signers = self.signers;
|
||||||
|
signers.push(&*self.payer);
|
||||||
|
|
||||||
|
let tx = {
|
||||||
|
let latest_hash = rpc_client.get_latest_blockhash().await?;
|
||||||
|
Transaction::new_signed_with_payer(
|
||||||
|
&instructions,
|
||||||
|
Some(&self.payer.pubkey()),
|
||||||
|
&signers,
|
||||||
|
latest_hash,
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
rpc_client
|
||||||
|
.send_and_confirm_transaction(&tx)
|
||||||
|
.await
|
||||||
|
.map_err(Into::into)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn send_with_spinner_and_config(
|
pub fn send_with_spinner_and_config(
|
||||||
self,
|
self,
|
||||||
config: RpcSendTransactionConfig,
|
config: RpcSendTransactionConfig,
|
||||||
|
|
Loading…
Reference in New Issue