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.
This commit is contained in:
Alex Gleason
2026-03-29 14:47:52 -05:00
parent e876e290da
commit 9b5df28b93
+8 -1
View File
@@ -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)) {