Skip to main content

solagent_rig_helius/
delete_webhook.rs

1use 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::delete_webhook;
11use std::sync::Arc;
12
13#[derive(Deserialize)]
14pub struct DeleteWebHookArgs {
15    webhook_id: String,
16}
17
18#[derive(Deserialize, Serialize)]
19pub struct DeleteWebHookOutput {
20    pub data: serde_json::Value,
21}
22
23#[derive(Debug, thiserror::Error)]
24#[error("DeleteWebHook error")]
25pub struct DeleteWebHookError;
26
27pub struct DeleteWebHook {
28    agent: Arc<SolanaAgentKit>,
29}
30
31impl DeleteWebHook {
32    pub fn new(agent: Arc<SolanaAgentKit>) -> Self {
33        DeleteWebHook { agent }
34    }
35}
36
37impl Tool for DeleteWebHook {
38    const NAME: &'static str = "delete_webhook";
39
40    type Error = DeleteWebHookError;
41    type Args = DeleteWebHookArgs;
42    type Output = DeleteWebHookOutput;
43
44    async fn definition(&self, _prompt: String) -> ToolDefinition {
45        ToolDefinition {
46            name: "delete_webhook".to_string(),
47            description: r#"
48            
49            Deletes 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 = delete_webhook(&self.agent, &args.webhook_id).await.expect("delete_webhook");
65
66        Ok(DeleteWebHookOutput { data })
67    }
68}