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
This commit is contained in:
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user