solagent_rig_helius/
get_webhook.rs1use serde::{Deserialize, Serialize};
2use solagent_core::{
3 rig::{
4 completion::ToolDefinition,
5 tool::Tool,
6 },
7 SolanaAgentKit,
8};
9use solagent_parameters::parameters;
10use solagent_plugin_helius::{get_webhook, HeliusWebhookIdResponse};
11use std::sync::Arc;
12
13#[derive(Deserialize)]
14pub struct GetWebHookArgs {
15 webhook_id: String,
16}
17
18#[derive(Deserialize, Serialize)]
19pub struct GetWebHookOutput {
20 pub data: HeliusWebhookIdResponse,
21}
22
23#[derive(Debug, thiserror::Error)]
24#[error("GetWebHook error")]
25pub struct GetWebHookError;
26
27pub struct GetWebHook {
28 agent: Arc<SolanaAgentKit>,
29}
30
31impl GetWebHook {
32 pub fn new(agent: Arc<SolanaAgentKit>) -> Self {
33 GetWebHook { agent }
34 }
35}
36
37impl Tool for GetWebHook {
38 const NAME: &'static str = "get_webhook";
39
40 type Error = GetWebHookError;
41 type Args = GetWebHookArgs;
42 type Output = GetWebHookOutput;
43
44 async fn definition(&self, _prompt: String) -> ToolDefinition {
45 ToolDefinition {
46 name: "get_webhook".to_string(),
47 description: r#"
48
49 Retrieves details of a Helius webhook by its unique ID
50
51 input: {
52 webhook_id: "webhook_123",
53 },
54
55 "#
56 .to_string(),
57 parameters: parameters!(
58 webhook_id: String,
59 ),
60 }
61 }
62
63 async fn call(&self, args: Self::Args) -> Result<Self::Output, Self::Error> {
64 let data = get_webhook(&self.agent, &args.webhook_id).await.expect("get_webhook");
65
66 Ok(GetWebHookOutput { data })
67 }
68}