solagent_plugin_helius/
transaction_parsing.rs1use serde::{Deserialize, Serialize};
16use serde_json::json;
17use solagent_core::SolanaAgentKit;
18
19#[derive(Debug, Serialize, Deserialize)]
20pub struct HeliusWebhookIdResponse {
21 pub wallet: String,
22 pub webhook_url: String,
23 pub transaction_types: Vec<String>,
24 pub account_addresses: Vec<String>,
25 pub webhook_type: String,
26}
27
28pub async fn transaction_parse(
37 agent: &SolanaAgentKit,
38 transaction_id: &str,
39) -> Result<serde_json::Value, Box<dyn std::error::Error>> {
40 let api_key = match agent.config.helius_api_key.as_ref() {
42 Some(key) => key,
43 None => return Err("Missing Helius API key in agent.config.HELIUS_API_KEY".into()),
44 };
45
46 let client = reqwest::Client::new();
47 let url = format!("https://api.helius.xyz/v0/transactions/?api-key={}", api_key);
48
49 let body = json!( {
50 "transactions": vec![transaction_id.to_string()],
51 });
52
53 let response = client.post(url).header("Content-Type", "application/json").json(&body).send().await?;
54
55 let data = response.json().await?;
56 Ok(data)
57}