From aea182b3b9a56bd95df7586e047477772a48df28 Mon Sep 17 00:00:00 2001 From: aniketfuryrocks Date: Tue, 6 Dec 2022 17:12:46 +0530 Subject: [PATCH] client --- src/client.rs | 33 +++++++++++++++++++++++++++++++++ src/main.rs | 1 + 2 files changed, 34 insertions(+) create mode 100644 src/client.rs diff --git a/src/client.rs b/src/client.rs new file mode 100644 index 00000000..47ba08d3 --- /dev/null +++ b/src/client.rs @@ -0,0 +1,33 @@ +use std::ops::{Deref, DerefMut}; + +use solana_client::nonblocking::rpc_client::RpcClient; +use solana_client::rpc_request::RpcRequest; + +pub struct LiteClient(pub RpcClient); + +impl Deref for LiteClient { + type Target = RpcClient; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl DerefMut for LiteClient { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } +} + +impl LiteClient { + pub async fn confirm_transaction(&self, signature: String) -> bool { + self.send( + RpcRequest::Custom { + method: "confirmTransaction", + }, + serde_json::json!([signature]), + ) + .await + .unwrap() + } +} diff --git a/src/main.rs b/src/main.rs index e5ebe977..49baa07c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,6 +13,7 @@ use crate::rpc::{ LightRpcRequestProcessor, }; mod cli; +mod client; mod context; mod pubsub; mod rpc;