feat(jito): add API token authentication support

- Update Jito configuration to require API token
- Add authentication headers to Jito API requests
- Bump version to 0.2.13
- Update documentation and examples
This commit is contained in:
ysq
2025-08-04 21:11:06 +08:00
parent e976af6935
commit 281218b15e
6 changed files with 15 additions and 13 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ async fn test_create_solana_trade_client() -> AnyResult<SolanaTrade> {
fn create_swqos_configs(rpc_url: &str) -> Vec<SwqosConfig> {
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),
+4 -2
View File
@@ -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()
+3 -3
View File
@@ -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<SwqosClient> {
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)
}