From 3b052d3eb656adc5ff87a114645b41ea22736466 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 17 Apr 2026 16:47:09 -0500 Subject: [PATCH] Fix naddr lookup for legacy replaceable kinds (0, 3, etc.) useAddrEvent only treated kinds in 10000-19999 as replaceable, so any naddr with a kind outside that range got a '#d' filter applied. For legacy replaceable kinds like 0 and 3, real events don't carry a 'd' tag, so the query matched nothing even when the relay had the event. Invert the check to only apply the '#d' filter for true addressable events (30000-39999). Legacy replaceable kinds and 10000-19999 are now queried by kind+author alone. Regression-of: 9b5df28b --- src/hooks/useEvent.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/hooks/useEvent.ts b/src/hooks/useEvent.ts index b0c27dfe..9b993d73 100644 --- a/src/hooks/useEvent.ts +++ b/src/hooks/useEvent.ts @@ -112,11 +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; - // 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; + // Only addressable events (30000-39999) use the d-tag for identification. + // Everything else — legacy replaceable kinds (0, 3, etc.) and NIP-01 + // replaceable events (10000-19999) — is identified by kind+author alone. + // Querying with `#d: [""]` against a non-addressable kind returns nothing, + // because real replaceable events don't carry an empty `d` tag. + const isAddressable = addr.kind >= 30000 && addr.kind < 40000; const baseFilter: NostrFilter = { kinds: [addr.kind], authors: [addr.pubkey], limit: 1 }; - if (!isReplaceable) { + if (isAddressable) { baseFilter['#d'] = [addr.identifier]; } const filter: NostrFilter[] = [baseFilter];