From 9b5df28b932bda8fe2ec44f4718a313c614375ae Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 29 Mar 2026 14:47:52 -0500 Subject: [PATCH] Fix naddr routing for replaceable events (kind 10000-19999) Replaceable events have no d-tag, so useAddrEvent must omit the #d filter for kinds in the 10000-19999 range. Without this, querying for a kind 10008 profile badges event via naddr would include '#d': [''] in the filter, which fails to match events without a d-tag. --- src/hooks/useEvent.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/hooks/useEvent.ts b/src/hooks/useEvent.ts index 4c3aebb4..d8978bb7 100644 --- a/src/hooks/useEvent.ts +++ b/src/hooks/useEvent.ts @@ -112,7 +112,14 @@ export function useAddrEvent(addr: AddrCoords | undefined, relays?: string[]) { queryKey: ['addr-event', addr?.kind ?? 0, addr?.pubkey ?? '', addr?.identifier ?? ''], queryFn: async () => { if (!addr) return null; - const filter: NostrFilter[] = [{ kinds: [addr.kind], authors: [addr.pubkey], '#d': [addr.identifier], limit: 1 }]; + // Replaceable events (10000-19999) are identified by kind+author only — no d-tag. + // Addressable events (30000-39999) additionally need the d-tag filter. + const isReplaceable = addr.kind >= 10000 && addr.kind < 20000; + const baseFilter: NostrFilter = { kinds: [addr.kind], authors: [addr.pubkey], limit: 1 }; + if (!isReplaceable) { + baseFilter['#d'] = [addr.identifier]; + } + const filter: NostrFilter[] = [baseFilter]; // For Zapstore kinds, try the canonical relay first for fastest results if (ZAPSTORE_KINDS.includes(addr.kind)) {