1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//! # stateset-a2a
//!
//! Agent-to-Agent (A2A) commerce service layer for the StateSet iCommerce platform.
//!
//! This crate provides the business logic for multi-party split payments,
//! recurring subscriptions, conditional escrow, HMAC-signed webhooks,
//! SSRF protection, and SSE event stream filtering.
//!
//! ## Modules
//!
//! - [`splits`] — Multi-party payment splitting with rounding drift prevention.
//! - [`subscriptions`] — Recurring billing with trial periods and state machine.
//! - [`escrow`] — Conditional fund holding with four condition types.
//! - [`notifications`] — HMAC-SHA256 webhook signing and SSRF URL validation.
//! - [`events`] — Event type filtering with wildcard/prefix matching.
//!
//! ## Example: Percentage Split
//!
//! ```
//! use rust_decimal_macros::dec;
//! use stateset_a2a::splits::{Recipient, calculate_percentage_split};
//!
//! let recipients = vec![
//! Recipient { address: "0xAlice".into(), percent: Some(dec!(50)), amount: None },
//! Recipient { address: "0xBob".into(), percent: Some(dec!(30)), amount: None },
//! Recipient { address: "0xCharlie".into(), percent: Some(dec!(20)), amount: None },
//! ];
//!
//! let result = calculate_percentage_split(dec!(100), dec!(2.5), &recipients).unwrap();
//! assert_eq!(result.total_distributed, dec!(100));
//! ```
//!
//! ## Example: HMAC Webhook
//!
//! ```
//! use stateset_a2a::notifications::{sign_webhook, verify_webhook};
//!
//! let signature = sign_webhook(b"whsec_abc123", b"{\"event\":\"payment.completed\"}");
//! assert!(verify_webhook(b"whsec_abc123", b"{\"event\":\"payment.completed\"}", &signature));
//! ```
// Re-export top-level error type for convenience.
pub use ;