From b1c489efdaee9d8122bf3df9b6a264fea6d929bc Mon Sep 17 00:00:00 2001 From: David Kathoh Date: Tue, 28 May 2024 12:29:37 +0200 Subject: [PATCH 1/9] add create_webhook example --- examples/create_webhook.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 examples/create_webhook.rs diff --git a/examples/create_webhook.rs b/examples/create_webhook.rs new file mode 100644 index 0000000..fccf29a --- /dev/null +++ b/examples/create_webhook.rs @@ -0,0 +1,26 @@ +use helius::types::{Cluster, WebhookType}; +use helius::{ + types::{CreateWebhookRequest, TransactionType}, + Helius, +}; + +#[tokio::main] +async fn main() { + let api_key: &str = "your_api_key"; + let cluster: Cluster = Cluster::MainnetBeta; + + let helius: Helius = Helius::new(api_key, cluster).unwrap(); + + let request = CreateWebhookRequest { + webhook_url: "your_webhook".to_string(), + transaction_types: vec![TransactionType::Any], + account_addresses: vec!["your_addresses".to_string()], + webhook_type: WebhookType::Enhanced, + auth_header: None, + txn_status: Default::default(), + encoding: Default::default(), + }; + + let response = helius.create_webhook(request).await; + println!("Webhook created {:?}", response); +} From 4ad8dd51753e47785ebcb93442135ff1271b26bc Mon Sep 17 00:00:00 2001 From: David Kathoh Date: Tue, 28 May 2024 12:31:21 +0200 Subject: [PATCH 2/9] add delete_webhook example --- examples/delete_webhook.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 examples/delete_webhook.rs diff --git a/examples/delete_webhook.rs b/examples/delete_webhook.rs new file mode 100644 index 0000000..7b0504a --- /dev/null +++ b/examples/delete_webhook.rs @@ -0,0 +1,15 @@ +use helius::types::Cluster; +use helius::Helius; + +#[tokio::main] +async fn main() { + let api_key: &str = "your_api_key"; + let cluster: Cluster = Cluster::MainnetBeta; + + let helius: Helius = Helius::new(api_key, cluster).unwrap(); + + let webhook_id = "your_webhook_id"; + + let response = helius.delete_webhook(webhook_id).await; + println!("Webhook deleted {:?}", response); +} From 3747b1f010319a7c05256bf378be4a09153b178c Mon Sep 17 00:00:00 2001 From: David Kathoh Date: Tue, 28 May 2024 12:32:11 +0200 Subject: [PATCH 3/9] add edit_webhook example --- examples/edit_webhook.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 examples/edit_webhook.rs diff --git a/examples/edit_webhook.rs b/examples/edit_webhook.rs new file mode 100644 index 0000000..f56c015 --- /dev/null +++ b/examples/edit_webhook.rs @@ -0,0 +1,23 @@ +use helius::types::{Cluster, EditWebhookRequest, TransactionType, WebhookType}; +use helius::Helius; + +#[tokio::main] +async fn main() { + let api_key: &str = "your_api_key"; + let cluster: Cluster = Cluster::MainnetBeta; + + let helius: Helius = Helius::new(api_key, cluster).unwrap(); + let request = EditWebhookRequest { + webhook_id: "your_webhook_id".to_string(), + webhook_url: "your_webhook".to_string(), + transaction_types: vec![TransactionType::Any], + account_addresses: vec!["your_addresses".to_string()], + webhook_type: WebhookType::Enhanced, + auth_header: None, + txn_status: Default::default(), + encoding: Default::default(), + }; + + let response = helius.edit_webhook(request).await; + println!("Webhook edited {:?}", response); +} From 3038296d4f2b30cbcb087d513d3e3f0d8cd03fe0 Mon Sep 17 00:00:00 2001 From: David Kathoh Date: Tue, 28 May 2024 12:32:59 +0200 Subject: [PATCH 4/9] add get_all_webhook example --- examples/get_all_webhooks.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 examples/get_all_webhooks.rs diff --git a/examples/get_all_webhooks.rs b/examples/get_all_webhooks.rs new file mode 100644 index 0000000..3a76195 --- /dev/null +++ b/examples/get_all_webhooks.rs @@ -0,0 +1,13 @@ +use helius::types::Cluster; +use helius::Helius; + +#[tokio::main] +async fn main() { + let api_key: &str = "your_api_key"; + let cluster: Cluster = Cluster::MainnetBeta; + + let helius: Helius = Helius::new(api_key, cluster).unwrap(); + + let response = helius.get_all_webhooks().await; + println!("Webhooks {:?}", response); +} From 53a6b5b5aa66f71da3f9df751aa34804da8bb9a7 Mon Sep 17 00:00:00 2001 From: David Kathoh Date: Tue, 28 May 2024 12:34:13 +0200 Subject: [PATCH 5/9] add get_webhook_by_id example --- examples/get_webhook_by_id.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 examples/get_webhook_by_id.rs diff --git a/examples/get_webhook_by_id.rs b/examples/get_webhook_by_id.rs new file mode 100644 index 0000000..784ea57 --- /dev/null +++ b/examples/get_webhook_by_id.rs @@ -0,0 +1,14 @@ +use helius::types::Cluster; +use helius::Helius; + +#[tokio::main] +async fn main() { + let api_key: &str = "your_api_key"; + let cluster: Cluster = Cluster::MainnetBeta; + + let helius: Helius = Helius::new(api_key, cluster).unwrap(); + + let webhook_id = "your_webhook_id"; + let response = helius.get_webhook_by_id(webhook_id).await; + println!("Webhook {:?}", response); +} From 6a5689430cd483e55573239daba3991ae0400930 Mon Sep 17 00:00:00 2001 From: David Kathoh Date: Tue, 28 May 2024 12:35:31 +0200 Subject: [PATCH 6/9] add remove_address_from_webhook example --- examples/remove_address_from_webhook.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 examples/remove_address_from_webhook.rs diff --git a/examples/remove_address_from_webhook.rs b/examples/remove_address_from_webhook.rs new file mode 100644 index 0000000..ee299a9 --- /dev/null +++ b/examples/remove_address_from_webhook.rs @@ -0,0 +1,17 @@ +use helius::types::Cluster; +use helius::Helius; + +#[tokio::main] +async fn main() { + let api_key: &str = "your_api_key"; + let cluster: Cluster = Cluster::MainnetBeta; + + let helius: Helius = Helius::new(api_key, cluster).unwrap(); + + let webhook_id = "your_webhook_id"; + let addresses_to_remove = ["your_address1".to_string(), "your_address2".to_string()]; + let response = helius + .remove_addresses_from_webhook(webhook_id, &addresses_to_remove) + .await; + println!("Addresses removed {:?}", response); +} From 60c4d27a536d079bc4dd449d9a1702ea8baac95b Mon Sep 17 00:00:00 2001 From: David Kathoh Date: Tue, 28 May 2024 12:36:23 +0200 Subject: [PATCH 7/9] add append_address_to_webhook example --- examples/append_address_to_webhook.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 examples/append_address_to_webhook.rs diff --git a/examples/append_address_to_webhook.rs b/examples/append_address_to_webhook.rs new file mode 100644 index 0000000..3c40eb2 --- /dev/null +++ b/examples/append_address_to_webhook.rs @@ -0,0 +1,15 @@ +use helius::types::Cluster; +use helius::Helius; + +#[tokio::main] +async fn main() { + let api_key: &str = "your_api_key"; + let cluster: Cluster = Cluster::MainnetBeta; + + let helius: Helius = Helius::new(api_key, cluster).unwrap(); + + let webhook_id = "your_webhook_id"; + let new_addresses = ["your_address1".to_string(), "your_address2".to_string()]; + let response = helius.append_addresses_to_webhook(webhook_id, &new_addresses).await; + println!("Addresses appended {:?}", response); +} From 1660499d70e8710eb19cd2c80b728a0df6f3654c Mon Sep 17 00:00:00 2001 From: David Kathoh Date: Wed, 29 May 2024 08:38:03 +0200 Subject: [PATCH 8/9] add explicit return type on responses and main --- examples/append_address_to_webhook.rs | 9 ++++++--- examples/create_webhook.rs | 8 +++++--- examples/delete_webhook.rs | 6 ++++-- examples/edit_webhook.rs | 8 +++++--- examples/get_all_webhooks.rs | 8 +++++--- examples/remove_address_from_webhook.rs | 9 ++++++--- 6 files changed, 31 insertions(+), 17 deletions(-) diff --git a/examples/append_address_to_webhook.rs b/examples/append_address_to_webhook.rs index 3c40eb2..14748b8 100644 --- a/examples/append_address_to_webhook.rs +++ b/examples/append_address_to_webhook.rs @@ -1,8 +1,9 @@ -use helius::types::Cluster; +use helius::error::HeliusError; +use helius::types::{Cluster, Webhook}; use helius::Helius; #[tokio::main] -async fn main() { +async fn main() -> Result<(), HeliusError> { let api_key: &str = "your_api_key"; let cluster: Cluster = Cluster::MainnetBeta; @@ -10,6 +11,8 @@ async fn main() { let webhook_id = "your_webhook_id"; let new_addresses = ["your_address1".to_string(), "your_address2".to_string()]; - let response = helius.append_addresses_to_webhook(webhook_id, &new_addresses).await; + let response: Result = helius.append_addresses_to_webhook(webhook_id, &new_addresses).await; println!("Addresses appended {:?}", response); + + Ok(()) } diff --git a/examples/create_webhook.rs b/examples/create_webhook.rs index fccf29a..fc5f763 100644 --- a/examples/create_webhook.rs +++ b/examples/create_webhook.rs @@ -1,11 +1,12 @@ -use helius::types::{Cluster, WebhookType}; +use helius::error::HeliusError; +use helius::types::{Cluster, Webhook, WebhookType}; use helius::{ types::{CreateWebhookRequest, TransactionType}, Helius, }; #[tokio::main] -async fn main() { +async fn main() -> Result<(), HeliusError> { let api_key: &str = "your_api_key"; let cluster: Cluster = Cluster::MainnetBeta; @@ -21,6 +22,7 @@ async fn main() { encoding: Default::default(), }; - let response = helius.create_webhook(request).await; + let response: Result = helius.create_webhook(request).await; println!("Webhook created {:?}", response); + Ok(()) } diff --git a/examples/delete_webhook.rs b/examples/delete_webhook.rs index 7b0504a..9bc941d 100644 --- a/examples/delete_webhook.rs +++ b/examples/delete_webhook.rs @@ -1,8 +1,9 @@ +use helius::error::HeliusError; use helius::types::Cluster; use helius::Helius; #[tokio::main] -async fn main() { +async fn main() -> Result<(), HeliusError> { let api_key: &str = "your_api_key"; let cluster: Cluster = Cluster::MainnetBeta; @@ -10,6 +11,7 @@ async fn main() { let webhook_id = "your_webhook_id"; - let response = helius.delete_webhook(webhook_id).await; + let response: Result<(), HeliusError> = helius.delete_webhook(webhook_id).await; println!("Webhook deleted {:?}", response); + Ok(()) } diff --git a/examples/edit_webhook.rs b/examples/edit_webhook.rs index f56c015..da234a6 100644 --- a/examples/edit_webhook.rs +++ b/examples/edit_webhook.rs @@ -1,8 +1,9 @@ -use helius::types::{Cluster, EditWebhookRequest, TransactionType, WebhookType}; +use helius::error::HeliusError; +use helius::types::{Cluster, EditWebhookRequest, TransactionType, Webhook, WebhookType}; use helius::Helius; #[tokio::main] -async fn main() { +async fn main() -> Result<(), HeliusError> { let api_key: &str = "your_api_key"; let cluster: Cluster = Cluster::MainnetBeta; @@ -18,6 +19,7 @@ async fn main() { encoding: Default::default(), }; - let response = helius.edit_webhook(request).await; + let response: Result = helius.edit_webhook(request).await; println!("Webhook edited {:?}", response); + Ok(()) } diff --git a/examples/get_all_webhooks.rs b/examples/get_all_webhooks.rs index 3a76195..158b423 100644 --- a/examples/get_all_webhooks.rs +++ b/examples/get_all_webhooks.rs @@ -1,13 +1,15 @@ -use helius::types::Cluster; +use helius::error::HeliusError; +use helius::types::{Cluster, Webhook}; use helius::Helius; #[tokio::main] -async fn main() { +async fn main() -> Result<(), HeliusError> { let api_key: &str = "your_api_key"; let cluster: Cluster = Cluster::MainnetBeta; let helius: Helius = Helius::new(api_key, cluster).unwrap(); - let response = helius.get_all_webhooks().await; + let response: Result, HeliusError> = helius.get_all_webhooks().await; println!("Webhooks {:?}", response); + Ok(()) } diff --git a/examples/remove_address_from_webhook.rs b/examples/remove_address_from_webhook.rs index ee299a9..3d67626 100644 --- a/examples/remove_address_from_webhook.rs +++ b/examples/remove_address_from_webhook.rs @@ -1,8 +1,9 @@ -use helius::types::Cluster; +use helius::error::HeliusError; +use helius::types::{Cluster, Webhook}; use helius::Helius; #[tokio::main] -async fn main() { +async fn main() -> Result<(), HeliusError> { let api_key: &str = "your_api_key"; let cluster: Cluster = Cluster::MainnetBeta; @@ -10,8 +11,10 @@ async fn main() { let webhook_id = "your_webhook_id"; let addresses_to_remove = ["your_address1".to_string(), "your_address2".to_string()]; - let response = helius + let response: Result = helius .remove_addresses_from_webhook(webhook_id, &addresses_to_remove) .await; println!("Addresses removed {:?}", response); + + Ok(()) } From ca0ad367c95cf7c29434cbaea49d3c1db46adf22 Mon Sep 17 00:00:00 2001 From: David Kathoh Date: Wed, 29 May 2024 14:53:25 +0200 Subject: [PATCH 9/9] used type alias from Sdk --- examples/append_address_to_webhook.rs | 6 +++--- examples/create_webhook.rs | 6 +++--- examples/delete_webhook.rs | 6 +++--- examples/edit_webhook.rs | 6 +++--- examples/get_all_webhooks.rs | 6 +++--- examples/get_webhook_by_id.rs | 9 ++++++--- examples/remove_address_from_webhook.rs | 6 +++--- 7 files changed, 24 insertions(+), 21 deletions(-) diff --git a/examples/append_address_to_webhook.rs b/examples/append_address_to_webhook.rs index 14748b8..63779cb 100644 --- a/examples/append_address_to_webhook.rs +++ b/examples/append_address_to_webhook.rs @@ -1,9 +1,9 @@ -use helius::error::HeliusError; +use helius::error::Result; use helius::types::{Cluster, Webhook}; use helius::Helius; #[tokio::main] -async fn main() -> Result<(), HeliusError> { +async fn main() -> Result<()> { let api_key: &str = "your_api_key"; let cluster: Cluster = Cluster::MainnetBeta; @@ -11,7 +11,7 @@ async fn main() -> Result<(), HeliusError> { let webhook_id = "your_webhook_id"; let new_addresses = ["your_address1".to_string(), "your_address2".to_string()]; - let response: Result = helius.append_addresses_to_webhook(webhook_id, &new_addresses).await; + let response: Result = helius.append_addresses_to_webhook(webhook_id, &new_addresses).await; println!("Addresses appended {:?}", response); Ok(()) diff --git a/examples/create_webhook.rs b/examples/create_webhook.rs index fc5f763..59e9856 100644 --- a/examples/create_webhook.rs +++ b/examples/create_webhook.rs @@ -1,4 +1,4 @@ -use helius::error::HeliusError; +use helius::error::Result; use helius::types::{Cluster, Webhook, WebhookType}; use helius::{ types::{CreateWebhookRequest, TransactionType}, @@ -6,7 +6,7 @@ use helius::{ }; #[tokio::main] -async fn main() -> Result<(), HeliusError> { +async fn main() -> Result<()> { let api_key: &str = "your_api_key"; let cluster: Cluster = Cluster::MainnetBeta; @@ -22,7 +22,7 @@ async fn main() -> Result<(), HeliusError> { encoding: Default::default(), }; - let response: Result = helius.create_webhook(request).await; + let response: Result = helius.create_webhook(request).await; println!("Webhook created {:?}", response); Ok(()) } diff --git a/examples/delete_webhook.rs b/examples/delete_webhook.rs index 9bc941d..4150168 100644 --- a/examples/delete_webhook.rs +++ b/examples/delete_webhook.rs @@ -1,9 +1,9 @@ -use helius::error::HeliusError; +use helius::error::Result; use helius::types::Cluster; use helius::Helius; #[tokio::main] -async fn main() -> Result<(), HeliusError> { +async fn main() -> Result<()> { let api_key: &str = "your_api_key"; let cluster: Cluster = Cluster::MainnetBeta; @@ -11,7 +11,7 @@ async fn main() -> Result<(), HeliusError> { let webhook_id = "your_webhook_id"; - let response: Result<(), HeliusError> = helius.delete_webhook(webhook_id).await; + let response: Result<()> = helius.delete_webhook(webhook_id).await; println!("Webhook deleted {:?}", response); Ok(()) } diff --git a/examples/edit_webhook.rs b/examples/edit_webhook.rs index da234a6..9782197 100644 --- a/examples/edit_webhook.rs +++ b/examples/edit_webhook.rs @@ -1,9 +1,9 @@ -use helius::error::HeliusError; +use helius::error::Result; use helius::types::{Cluster, EditWebhookRequest, TransactionType, Webhook, WebhookType}; use helius::Helius; #[tokio::main] -async fn main() -> Result<(), HeliusError> { +async fn main() -> Result<()> { let api_key: &str = "your_api_key"; let cluster: Cluster = Cluster::MainnetBeta; @@ -19,7 +19,7 @@ async fn main() -> Result<(), HeliusError> { encoding: Default::default(), }; - let response: Result = helius.edit_webhook(request).await; + let response: Result = helius.edit_webhook(request).await; println!("Webhook edited {:?}", response); Ok(()) } diff --git a/examples/get_all_webhooks.rs b/examples/get_all_webhooks.rs index 158b423..a15ecc1 100644 --- a/examples/get_all_webhooks.rs +++ b/examples/get_all_webhooks.rs @@ -1,15 +1,15 @@ -use helius::error::HeliusError; +use helius::error::Result; use helius::types::{Cluster, Webhook}; use helius::Helius; #[tokio::main] -async fn main() -> Result<(), HeliusError> { +async fn main() -> Result<()> { let api_key: &str = "your_api_key"; let cluster: Cluster = Cluster::MainnetBeta; let helius: Helius = Helius::new(api_key, cluster).unwrap(); - let response: Result, HeliusError> = helius.get_all_webhooks().await; + let response: Result> = helius.get_all_webhooks().await; println!("Webhooks {:?}", response); Ok(()) } diff --git a/examples/get_webhook_by_id.rs b/examples/get_webhook_by_id.rs index 784ea57..c9c53c9 100644 --- a/examples/get_webhook_by_id.rs +++ b/examples/get_webhook_by_id.rs @@ -1,14 +1,17 @@ -use helius::types::Cluster; +use helius::error::Result; +use helius::types::{Cluster, Webhook}; use helius::Helius; #[tokio::main] -async fn main() { +async fn main() -> Result<()> { let api_key: &str = "your_api_key"; let cluster: Cluster = Cluster::MainnetBeta; let helius: Helius = Helius::new(api_key, cluster).unwrap(); let webhook_id = "your_webhook_id"; - let response = helius.get_webhook_by_id(webhook_id).await; + let response: Result = helius.get_webhook_by_id(webhook_id).await; println!("Webhook {:?}", response); + + Ok(()) } diff --git a/examples/remove_address_from_webhook.rs b/examples/remove_address_from_webhook.rs index 3d67626..0d52619 100644 --- a/examples/remove_address_from_webhook.rs +++ b/examples/remove_address_from_webhook.rs @@ -1,9 +1,9 @@ -use helius::error::HeliusError; +use helius::error::Result; use helius::types::{Cluster, Webhook}; use helius::Helius; #[tokio::main] -async fn main() -> Result<(), HeliusError> { +async fn main() -> Result<()> { let api_key: &str = "your_api_key"; let cluster: Cluster = Cluster::MainnetBeta; @@ -11,7 +11,7 @@ async fn main() -> Result<(), HeliusError> { let webhook_id = "your_webhook_id"; let addresses_to_remove = ["your_address1".to_string(), "your_address2".to_string()]; - let response: Result = helius + let response: Result = helius .remove_addresses_from_webhook(webhook_id, &addresses_to_remove) .await; println!("Addresses removed {:?}", response);