From b5861588fefd874f6ea0acc62e64620e1aa6431f Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 19 Jan 2026 10:36:45 +0000 Subject: [PATCH] refactor: move eventPointer to ZapConfig for NIP-53 adapter - Add eventPointer field to ZapConfig interface for message e-tag - NIP-53 adapter now returns eventPointer from getZapConfig - ChatMessageContextMenu uses eventPointer from zapConfig directly - Remove goal logic from NIP-53 zap config (simplify for now) This gives the adapter full control over zap configuration, including which event to reference in the e-tag. --- .../chat/ChatMessageContextMenu.tsx | 4 +-- src/lib/chat/adapters/base-adapter.ts | 6 +++++ src/lib/chat/adapters/nip-53-adapter.ts | 25 ++++++++----------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/components/chat/ChatMessageContextMenu.tsx b/src/components/chat/ChatMessageContextMenu.tsx index c997c43..6c23fca 100644 --- a/src/components/chat/ChatMessageContextMenu.tsx +++ b/src/components/chat/ChatMessageContextMenu.tsx @@ -153,9 +153,7 @@ export function ChatMessageContextMenu({ addWindow("zap", { recipientPubkey: zapConfig.recipientPubkey, - // Include the message event as context for zap preview (e-tag) - eventPointer: { id: event.id, author: event.pubkey }, - // Include addressable event context if provided (a-tag, e.g., live activity) + eventPointer: zapConfig.eventPointer, addressPointer: zapConfig.addressPointer, customTags: zapConfig.customTags, relays: zapConfig.relays, diff --git a/src/lib/chat/adapters/base-adapter.ts b/src/lib/chat/adapters/base-adapter.ts index cd9cc7f..4747f32 100644 --- a/src/lib/chat/adapters/base-adapter.ts +++ b/src/lib/chat/adapters/base-adapter.ts @@ -28,6 +28,12 @@ export interface ZapConfig { unsupportedReason?: string; /** Recipient pubkey (who receives the sats) */ recipientPubkey: string; + /** Event being zapped for e-tag (e.g., chat message) */ + eventPointer?: { + id: string; + author?: string; + relays?: string[]; + }; /** Addressable event context for a-tag (e.g., live activity) */ addressPointer?: { kind: number; diff --git a/src/lib/chat/adapters/nip-53-adapter.ts b/src/lib/chat/adapters/nip-53-adapter.ts index c60e3e8..67ae01a 100644 --- a/src/lib/chat/adapters/nip-53-adapter.ts +++ b/src/lib/chat/adapters/nip-53-adapter.ts @@ -558,16 +558,15 @@ export class Nip53Adapter extends ChatProtocolAdapter { * Get zap configuration for a message in a live activity * * NIP-53 zap tagging rules: - * - Always include: p-tag (message author), a-tag (live activity) - * - If zapping the host AND stream has a goal: also e-tag the goal + * - p-tag: message author (recipient) + * - e-tag: message event being zapped + * - a-tag: live activity context */ getZapConfig(message: Message, conversation: Conversation): ZapConfig { const activityAddress = conversation.metadata?.activityAddress; const liveActivity = conversation.metadata?.liveActivity as | { relays?: string[]; - hostPubkey?: string; - goal?: string; } | undefined; @@ -580,8 +579,6 @@ export class Nip53Adapter extends ChatProtocolAdapter { } const { pubkey: activityPubkey, identifier } = activityAddress; - const hostPubkey = liveActivity?.hostPubkey; - const goal = liveActivity?.goal; // Get relays const relays = @@ -591,6 +588,13 @@ export class Nip53Adapter extends ChatProtocolAdapter { ? [conversation.metadata.relayUrl] : []; + // Build eventPointer for the message being zapped (e-tag) + const eventPointer = { + id: message.id, + author: message.author, + relays, + }; + // Build addressPointer for the live activity (a-tag) const addressPointer = { kind: 30311, @@ -599,18 +603,11 @@ export class Nip53Adapter extends ChatProtocolAdapter { relays, }; - // Build custom tags for special cases only - // If zapping the host AND stream has a goal, e-tag the goal - const customTags: string[][] = []; - if (message.author === hostPubkey && goal) { - customTags.push(["e", goal, relays[0] || ""]); - } - return { supported: true, recipientPubkey: message.author, + eventPointer, addressPointer, - customTags: customTags.length > 0 ? customTags : undefined, relays, }; }