From e35af6d399cefeb2e2ed619364af0cf2666927f1 Mon Sep 17 00:00:00 2001 From: Evan <0xIchigo@protonmail.com> Date: Thu, 28 Nov 2024 15:59:08 -0500 Subject: [PATCH] Formattooorrr --- examples/async_config_based_creation.rs | 9 +++++--- src/config.rs | 30 +++++++++++-------------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/examples/async_config_based_creation.rs b/examples/async_config_based_creation.rs index c32ae8d..e23b543 100644 --- a/examples/async_config_based_creation.rs +++ b/examples/async_config_based_creation.rs @@ -1,6 +1,6 @@ +use helius::config::Config; use helius::error::Result; use helius::types::Cluster; -use helius::config::Config; use helius::Helius; /// Demonstrates creating a Helius client with async Solana capabilities using the config-based approach @@ -11,9 +11,12 @@ async fn main() -> Result<()> { let config: Config = Config::new(api_key, cluster)?; let async_client: Helius = config.create_client_with_async()?; - + if let Ok(async_conn) = async_client.async_connection() { - println!("Async client - Get Block Height: {:?}", async_conn.get_block_height().await); + println!( + "Async client - Get Block Height: {:?}", + async_conn.get_block_height().await + ); } Ok(()) diff --git a/src/config.rs b/src/config.rs index 575d93c..1700980 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,12 +1,12 @@ use crate::error::{HeliusError, Result}; +use crate::rpc_client::RpcClient; use crate::types::{Cluster, HeliusEndpoints, MintApiAuthority}; -use crate::websocket::{ EnhancedWebsocket, ENHANCED_WEBSOCKET_URL }; +use crate::websocket::{EnhancedWebsocket, ENHANCED_WEBSOCKET_URL}; use crate::Helius; -use crate::rpc_client::RpcClient; -use std::sync::Arc; use reqwest::Client; -use url::{ParseError, Url}; use solana_client::nonblocking::rpc_client::RpcClient as AsyncSolanaRpcClient; +use std::sync::Arc; +use url::{ParseError, Url}; /// Configuration settings for the Helius client /// @@ -77,9 +77,8 @@ impl Config { let client: Client = Client::builder().build().map_err(HeliusError::ReqwestError)?; let mut rpc_url: Url = Url::parse(&self.endpoints.rpc) .map_err(|e: ParseError| HeliusError::InvalidInput(format!("Invalid RPC URL: {}", e)))?; - - rpc_url.query_pairs_mut() - .append_pair("api-key", &self.api_key); + + rpc_url.query_pairs_mut().append_pair("api-key", &self.api_key); let async_solana_client: Arc = Arc::new(AsyncSolanaRpcClient::new(rpc_url.to_string())); let rpc_client: Arc = Arc::new(self.rpc_client_with_reqwest_client(client.clone())?); @@ -108,11 +107,10 @@ impl Config { ) -> Result { let client: Client = Client::builder().build().map_err(HeliusError::ReqwestError)?; let rpc_client: Arc = Arc::new(self.rpc_client_with_reqwest_client(client.clone())?); - + let wss: String = format!("{}{}", ENHANCED_WEBSOCKET_URL, self.api_key); - let ws_client: Arc = Arc::new( - EnhancedWebsocket::new(&wss, ping_interval_secs, pong_timeout_secs).await? - ); + let ws_client: Arc = + Arc::new(EnhancedWebsocket::new(&wss, ping_interval_secs, pong_timeout_secs).await?); Ok(Helius { config: Arc::new(self), @@ -138,19 +136,17 @@ impl Config { ) -> Result { let client: Client = Client::builder().build().map_err(HeliusError::ReqwestError)?; let rpc_client: Arc = Arc::new(self.rpc_client_with_reqwest_client(client.clone())?); - + // Setup async client let mut rpc_url: Url = Url::parse(&self.endpoints.rpc) .map_err(|e: ParseError| HeliusError::InvalidInput(format!("Invalid RPC URL: {}", e)))?; - rpc_url.query_pairs_mut() - .append_pair("api-key", &self.api_key); + rpc_url.query_pairs_mut().append_pair("api-key", &self.api_key); let async_solana_client = Arc::new(AsyncSolanaRpcClient::new(rpc_url.to_string())); // Setup websocket let wss: String = format!("{}{}", ENHANCED_WEBSOCKET_URL, self.api_key); - let ws_client: Arc = Arc::new( - EnhancedWebsocket::new(&wss, ping_interval_secs, pong_timeout_secs).await? - ); + let ws_client: Arc = + Arc::new(EnhancedWebsocket::new(&wss, ping_interval_secs, pong_timeout_secs).await?); Ok(Helius { config: Arc::new(self),