Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions crates/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1309,20 +1309,20 @@ Accessed as `qn.webhooks`. Creates webhooks from filter templates and manages th
| `HyperliquidWalletEventsFilter` | `hyperliquidWalletEventsFilter` |
| `StellarWalletTransactionsSourceAccountFilter` | `stellarWalletTransactionsSourceAccountFilter` |

`TemplateArgs` carries the arguments; construct one per template via the factory methods:
`TemplateArgs` carries the arguments. Each template supports two input forms — inline values or a reference to a pre-created list by name. Construct one per template via the variant + the appropriate input enum (`<Template>Input::Inline | ByList`):

| Factory | Argument struct | Fields |
| Variant | Inline struct (fields) | ByList struct (fields) |
|---|---|---|
| `evm_wallet_filter` | `EvmWalletFilterTemplate` | `wallets: string[]` |
| `evm_contract_events` | `EvmContractEventsTemplate` | `contracts: string[]`, `event_hashes?: string[]` |
| `evm_abi_filter` | `EvmAbiFilterTemplate` | `abi: string` (JSON), `contracts: string[]` |
| `solana_wallet_filter` | `SolanaWalletFilterTemplate` | `accounts: string[]` |
| `bitcoin_wallet_filter` | `BitcoinWalletFilterTemplate` | `wallets: string[]` |
| `xrpl_wallet_filter` | `XrplWalletFilterTemplate` | `wallets: string[]` |
| `hyperliquid_wallet_events_filter` | `HyperliquidWalletEventsFilterTemplate` | `wallets: string[]` |
| `stellar_wallet_transactions_filter` | `StellarWalletTransactionsFilterTemplate` | `source_accounts: string[]` |
| `EvmWalletFilter` | `EvmWalletFilterTemplate { wallets: string[] }` | `EvmWalletFilterByListTemplate { wallets_list_name: string }` |
| `EvmContractEvents` | `EvmContractEventsTemplate { contracts: string[], event_hashes: string[] }` | `EvmContractEventsByListTemplate { contracts_list_name: string, event_hashes_list_name?: string }` |
| `EvmAbiFilter` | `EvmAbiFilterTemplate { abi: string, contracts: string[] }` | `EvmAbiFilterByListTemplate { abi_json: string, contracts_list_name?: string }` |
| `SolanaWalletFilter` | `SolanaWalletFilterTemplate { accounts: string[] }` | `SolanaWalletFilterByListTemplate { accounts_list_name: string }` |
| `BitcoinWalletFilter` | `BitcoinWalletFilterTemplate { wallets: string[] }` | `BitcoinWalletFilterByListTemplate { wallets_list_name: string }` |
| `XrplWalletFilter` | `XrplWalletFilterTemplate { wallets: string[] }` | `XrplWalletFilterByListTemplate { wallets_list_name: string }` |
| `HyperliquidWalletEventsFilter` | `HyperliquidWalletEventsFilterTemplate { wallets: string[] }` | `HyperliquidWalletEventsFilterByListTemplate { wallets_list_name: string }` |
| `StellarWalletTransactionsSourceAccountFilter` | `StellarWalletTransactionsFilterTemplate { wallets: string[] }` | `StellarWalletTransactionsFilterByListTemplate { wallets_list_name: string }` |

`WebhookDestinationAttributes`: `url` (required), `security_token` (optionalauto-generated if omitted), `compression` (optional — `"none"` | `"gzip"`).
`WebhookDestinationAttributes`: `url` (required), `compression` (required`"none"` | `"gzip"`), `security_token` (optional — auto-generated if omitted).

`WebhookStartFrom`: `Last` (resume from last delivered block) or `Latest` (start from newest).

Expand Down Expand Up @@ -1376,7 +1376,7 @@ let params = CreateWebhookFromTemplateParams {
destination_attributes: WebhookDestinationAttributes {
url: "https://webhook.site/...".to_string(),
security_token: None,
compression: None,
compression: "none".to_string(),
},
template_args,
};
Expand Down
8 changes: 4 additions & 4 deletions crates/core/examples/webhooks_e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async fn main() {
destination_attributes: WebhookDestinationAttributes {
url: "https://webhook.site/ae19071a-2dcc-4035-9cdf-406dcb4719ef".to_string(),
security_token: None,
compression: None,
compression: "none".to_string(),
},
template_args,
};
Expand Down Expand Up @@ -102,9 +102,9 @@ async fn main() {
// `event_hashes` field. The API expects `eventHashes` on the wire.
let contract_events_args = TemplateArgs::EvmContractEvents(EvmContractEventsTemplate {
contracts: vec!["0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48".to_string()],
event_hashes: Some(vec![
event_hashes: vec![
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef".to_string(),
]),
],
});
let contract_events_params = CreateWebhookFromTemplateParams {
name: "E2E Test Webhook (evmContractEvents)".to_string(),
Expand All @@ -113,7 +113,7 @@ async fn main() {
destination_attributes: WebhookDestinationAttributes {
url: "https://webhook.site/ae19071a-2dcc-4035-9cdf-406dcb4719ef".to_string(),
security_token: None,
compression: None,
compression: "none".to_string(),
},
template_args: contract_events_args,
};
Expand Down
69 changes: 41 additions & 28 deletions crates/core/src/webhooks/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
pub mod webhook;

pub use webhook::{
ActivateWebhookParams, BitcoinWalletFilterTemplate, CreateWebhookFromTemplateParams,
EvmAbiFilterTemplate, EvmContractEventsTemplate, EvmWalletFilterTemplate, GetWebhooksParams,
HyperliquidWalletEventsFilterTemplate, ListWebhooksResponse, SolanaWalletFilterTemplate,
ActivateWebhookParams, BitcoinWalletFilterByListTemplate, BitcoinWalletFilterInput,
BitcoinWalletFilterTemplate, CreateWebhookFromTemplateParams, EvmAbiFilterByListTemplate,
EvmAbiFilterInput, EvmAbiFilterTemplate, EvmContractEventsByListTemplate,
EvmContractEventsInput, EvmContractEventsTemplate, EvmWalletFilterByListTemplate,
EvmWalletFilterInput, EvmWalletFilterTemplate, GetWebhooksParams,
HyperliquidWalletEventsFilterByListTemplate, HyperliquidWalletEventsFilterInput,
HyperliquidWalletEventsFilterTemplate, ListWebhooksResponse, SolanaWalletFilterByListTemplate,
SolanaWalletFilterInput, SolanaWalletFilterTemplate,
StellarWalletTransactionsFilterByListTemplate, StellarWalletTransactionsFilterInput,
StellarWalletTransactionsFilterTemplate, TemplateArgs, UpdateWebhookParams,
UpdateWebhookTemplateParams, Webhook, WebhookDestinationAttributes,
WebhookEnabledCountResponse, WebhookPageInfo, WebhookStartFrom, WebhookTemplateId,
XrplWalletFilterTemplate,
XrplWalletFilterByListTemplate, XrplWalletFilterInput, XrplWalletFilterTemplate,
};

use crate::{config::WebhooksConfig, errors::SdkError, SdkConfig};
Expand Down Expand Up @@ -255,8 +261,8 @@ impl WebhooksApiClient {

/// Creates a new webhook from a predefined filter template. Requires a
/// descriptive name, a target blockchain network, and destination
/// attributes (URL, optional security token — auto-generated when omitted,
/// and optional compression — `gzip` or `none`). `template_args` carries
/// attributes (URL, compression — `gzip` or `none`, and an optional
/// security token — auto-generated when omitted). `template_args` carries
/// template-specific configuration such as wallet addresses or contract
/// filters. An optional `notification_email` receives alerts if the
/// webhook terminates.
Expand Down Expand Up @@ -633,17 +639,18 @@ mod tests {
.mount(&server)
.await;
let sdk = make_sdk(format!("{}/", server.uri()));
let template_args = TemplateArgs::EvmWalletFilter(EvmWalletFilterTemplate {
wallets: vec!["0xabc".to_string()],
});
let template_args =
TemplateArgs::EvmWalletFilter(EvmWalletFilterInput::Inline(EvmWalletFilterTemplate {
wallets: vec!["0xabc".to_string()],
}));
let params = CreateWebhookFromTemplateParams {
name: "test-webhook".to_string(),
network: "ethereum-mainnet".to_string(),
notification_email: None,
destination_attributes: WebhookDestinationAttributes {
url: "https://example.com/hook".to_string(),
security_token: None,
compression: None,
compression: "none".to_string(),
},
template_args,
};
Expand All @@ -664,17 +671,18 @@ mod tests {
.mount(&server)
.await;
let sdk = make_sdk(format!("{}/", server.uri()));
let template_args = TemplateArgs::EvmWalletFilter(EvmWalletFilterTemplate {
wallets: vec!["0xabc".to_string()],
});
let template_args =
TemplateArgs::EvmWalletFilter(EvmWalletFilterInput::Inline(EvmWalletFilterTemplate {
wallets: vec!["0xabc".to_string()],
}));
let params = CreateWebhookFromTemplateParams {
name: "test-webhook".to_string(),
network: "ethereum-mainnet".to_string(),
notification_email: None,
destination_attributes: WebhookDestinationAttributes {
url: "https://example.com/hook".to_string(),
security_token: None,
compression: None,
compression: "none".to_string(),
},
template_args,
};
Expand All @@ -695,9 +703,10 @@ mod tests {
.mount(&server)
.await;
let sdk = make_sdk(format!("{}/", server.uri()));
let template_args = TemplateArgs::EvmWalletFilter(EvmWalletFilterTemplate {
wallets: vec!["0xabc".to_string()],
});
let template_args =
TemplateArgs::EvmWalletFilter(EvmWalletFilterInput::Inline(EvmWalletFilterTemplate {
wallets: vec!["0xabc".to_string()],
}));
let params = UpdateWebhookTemplateParams {
name: None,
notification_email: None,
Expand Down Expand Up @@ -725,9 +734,10 @@ mod tests {
.mount(&server)
.await;
let sdk = make_sdk(format!("{}/", server.uri()));
let template_args = TemplateArgs::EvmWalletFilter(EvmWalletFilterTemplate {
wallets: vec!["0xabc".to_string()],
});
let template_args =
TemplateArgs::EvmWalletFilter(EvmWalletFilterInput::Inline(EvmWalletFilterTemplate {
wallets: vec!["0xabc".to_string()],
}));
let params = UpdateWebhookTemplateParams {
name: Some("new-name".to_string()),
notification_email: None,
Expand Down Expand Up @@ -758,18 +768,20 @@ mod tests {
.mount(&server)
.await;
let sdk = make_sdk(format!("{}/", server.uri()));
let template_args = TemplateArgs::EvmContractEvents(EvmContractEventsTemplate {
contracts: vec!["0xa0b8".to_string()],
event_hashes: Some(vec!["0xabcd".to_string()]),
});
let template_args = TemplateArgs::EvmContractEvents(EvmContractEventsInput::Inline(
EvmContractEventsTemplate {
contracts: vec!["0xa0b8".to_string()],
event_hashes: vec!["0xabcd".to_string()],
},
));
let params = CreateWebhookFromTemplateParams {
name: "test-webhook".to_string(),
network: "ethereum-mainnet".to_string(),
notification_email: None,
destination_attributes: WebhookDestinationAttributes {
url: "https://example.com/hook".to_string(),
security_token: None,
compression: None,
compression: "none".to_string(),
},
template_args,
};
Expand All @@ -788,9 +800,10 @@ mod tests {
.mount(&server)
.await;
let sdk = make_sdk(format!("{}/", server.uri()));
let template_args = TemplateArgs::EvmWalletFilter(EvmWalletFilterTemplate {
wallets: vec!["0xabc".to_string()],
});
let template_args =
TemplateArgs::EvmWalletFilter(EvmWalletFilterInput::Inline(EvmWalletFilterTemplate {
wallets: vec!["0xabc".to_string()],
}));
let params = UpdateWebhookTemplateParams {
name: None,
notification_email: None,
Expand Down
Loading
Loading