diff --git a/Cargo.toml b/Cargo.toml index b5a5acd..5ff6c7e 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sol-trade-sdk" -version = "0.2.12" +version = "0.2.13" edition = "2021" authors = ["William ", "sgxiang ", "wei <1415121722@qq.com>"] repository = "https://github.com/0xfnzero/sol-trade-sdk" diff --git a/README.md b/README.md index b901ad7..ad5dc0d 100755 --- a/README.md +++ b/README.md @@ -31,14 +31,14 @@ Add the dependency to your `Cargo.toml`: ```toml # Add to your Cargo.toml -sol-trade-sdk = { path = "./sol-trade-sdk", version = "0.2.12" } +sol-trade-sdk = { path = "./sol-trade-sdk", version = "0.2.13" } ``` ### Use crates.io ```toml # Add to your Cargo.toml -sol-trade-sdk = "0.2.12" +sol-trade-sdk = "0.2.13" ``` ## Usage Examples @@ -233,7 +233,7 @@ async fn test_create_solana_trade_client() -> AnyResult { // Configure various SWQOS services let swqos_configs = vec![ - SwqosConfig::Jito(SwqosRegion::Frankfurt), + SwqosConfig::Jito("your api_token".to_string(), SwqosRegion::Frankfurt), SwqosConfig::NextBlock("your api_token".to_string(), SwqosRegion::Frankfurt), SwqosConfig::Bloxroute("your api_token".to_string(), SwqosRegion::Frankfurt), SwqosConfig::ZeroSlot("your api_token".to_string(), SwqosRegion::Frankfurt), diff --git a/README_CN.md b/README_CN.md index 741aedf..58aaefb 100755 --- a/README_CN.md +++ b/README_CN.md @@ -31,14 +31,14 @@ git clone https://github.com/0xfnzero/sol-trade-sdk ```toml # 添加到您的 Cargo.toml -sol-trade-sdk = { path = "./sol-trade-sdk", version = "0.2.12" } +sol-trade-sdk = { path = "./sol-trade-sdk", version = "0.2.13" } ``` ### 使用 crates.io ```toml # 添加到您的 Cargo.toml -sol-trade-sdk = "0.2.12" +sol-trade-sdk = "0.2.13" ``` ## 使用示例 @@ -233,7 +233,7 @@ async fn test_create_solana_trade_client() -> AnyResult { // 配置各种 SWQOS 服务 let swqos_configs = vec![ - SwqosConfig::Jito(SwqosRegion::Frankfurt), + SwqosConfig::Jito("your api_token".to_string(), SwqosRegion::Frankfurt), SwqosConfig::NextBlock("your api_token".to_string(), SwqosRegion::Frankfurt), SwqosConfig::Bloxroute("your api_token".to_string(), SwqosRegion::Frankfurt), SwqosConfig::ZeroSlot("your api_token".to_string(), SwqosRegion::Frankfurt), diff --git a/src/main.rs b/src/main.rs index 388d023..c6b3ead 100755 --- a/src/main.rs +++ b/src/main.rs @@ -55,7 +55,7 @@ async fn test_create_solana_trade_client() -> AnyResult { fn create_swqos_configs(rpc_url: &str) -> Vec { vec![ - SwqosConfig::Jito(SwqosRegion::Frankfurt), + SwqosConfig::Jito("your api_token".to_string(), SwqosRegion::Frankfurt), SwqosConfig::NextBlock("your api_token".to_string(), SwqosRegion::Frankfurt), SwqosConfig::Bloxroute("your api_token".to_string(), SwqosRegion::Frankfurt), SwqosConfig::ZeroSlot("your api_token".to_string(), SwqosRegion::Frankfurt), diff --git a/src/swqos/jito.rs b/src/swqos/jito.rs index e4a43bf..a4b45ee 100755 --- a/src/swqos/jito.rs +++ b/src/swqos/jito.rs @@ -78,10 +78,11 @@ impl JitoClient { ] }))?; - let endpoint = format!("{}/api/v1/transactions", self.endpoint); + let endpoint = format!("{}/api/v1/transactions?uuid={}", self.endpoint, self.auth_token); let response_text = self.http_client.post(&endpoint) .body(request_body) .header("Content-Type", "application/json") + .header("x-jito-auth", &self.auth_token) .send() .await? .text() @@ -119,10 +120,11 @@ impl JitoClient { "id": 1, }); - let endpoint = format!("{}/api/v1/bundles", self.endpoint); + let endpoint = format!("{}/api/v1/bundles?uuid={}", self.endpoint, self.auth_token); let response_text = self.http_client.post(&endpoint) .body(body.to_string()) .header("Content-Type", "application/json") + .header("x-jito-auth", &self.auth_token) .send() .await? .text() diff --git a/src/swqos/mod.rs b/src/swqos/mod.rs index 5a3a2f5..c715b60 100755 --- a/src/swqos/mod.rs +++ b/src/swqos/mod.rs @@ -74,7 +74,7 @@ pub enum SwqosRegion { #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum SwqosConfig { Default(String), - Jito(SwqosRegion), + Jito(String, SwqosRegion), NextBlock(String, SwqosRegion), Bloxroute(String, SwqosRegion), Temporal(String, SwqosRegion), @@ -95,12 +95,12 @@ impl SwqosConfig { pub fn get_swqos_client(rpc_url: String, commitment: CommitmentConfig, swqos_config: SwqosConfig) -> Arc { match swqos_config { - SwqosConfig::Jito(region) => { + SwqosConfig::Jito(auth_token, region) => { let endpoint = SwqosConfig::get_endpoint(SwqosType::Jito, region); let jito_client = JitoClient::new( rpc_url.clone(), endpoint, - "".to_string() + auth_token ); Arc::new(jito_client) }