Skip to content
Open
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
32 changes: 32 additions & 0 deletions src/core/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,20 @@ impl ClientSession {
}
}

// ── Payment interaction (CEP-8) ─────────────────────────────────────

/// CEP-8 payment interaction mode negotiated per session.
///
/// Serialized as `"transparent"` / `"explicit_gating"` on the wire.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum PaymentInteractionMode {
/// Side-band notifications; the request is still forwarded after payment.
Transparent,
/// Request is gated with a JSON-RPC error until paid.
ExplicitGating,
}

// ── JSON-RPC types ──────────────────────────────────────────────────
//
// MCP uses JSON-RPC 2.0. We define our own types here since there's
Expand Down Expand Up @@ -413,6 +427,24 @@ mod tests {
assert_eq!(parsed, mode);
}

#[test]
fn test_payment_interaction_mode_serde_roundtrip_transparent() {
let mode = PaymentInteractionMode::Transparent;
let s = serde_json::to_string(&mode).unwrap();
assert_eq!(s, "\"transparent\"");
let parsed: PaymentInteractionMode = serde_json::from_str(&s).unwrap();
assert_eq!(parsed, mode);
}

#[test]
fn test_payment_interaction_mode_serde_roundtrip_explicit_gating() {
let mode = PaymentInteractionMode::ExplicitGating;
let s = serde_json::to_string(&mode).unwrap();
assert_eq!(s, "\"explicit_gating\"");
let parsed: PaymentInteractionMode = serde_json::from_str(&s).unwrap();
assert_eq!(parsed, mode);
}

#[test]
fn test_gift_wrap_mode_serde_roundtrip_optional() {
let mode = GiftWrapMode::Optional;
Expand Down
7 changes: 4 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub use core::error::{Error, Result};
pub use core::types::{
CapabilityExclusion, ClientSession, EncryptionMode, GiftWrapMode, JsonRpcError,
JsonRpcErrorResponse, JsonRpcMessage, JsonRpcNotification, JsonRpcRequest, JsonRpcResponse,
ProfileMetadata, ServerInfo,
PaymentInteractionMode, ProfileMetadata, ServerInfo,
};

// ── Discovery ────────────────────────────────────────────────────────
Expand All @@ -83,8 +83,9 @@ pub use transport::discovery_tags::{DiscoveredPeerCapabilities, PeerCapabilities

// ── Transport (server) ──────────────────────────────────────────────
pub use transport::server::{
ClientPubkey, InboundEvent, IncomingRequest, NostrServerTransport, NostrServerTransportConfig,
RouteEntry, ServerEventRouteStore, SessionSnapshot, SessionStore,
ClientPubkey, InboundContext, InboundEvent, InboundMiddleware, IncomingRequest, Next,
NostrServerTransport, NostrServerTransportConfig, RouteEntry, ServerEventRouteStore,
SessionSnapshot, SessionStore,
};

// ── rmcp re-export ──────────────────────────────────────────────────
Expand Down
Loading
Loading