Closed dskvr closed 7 months ago
Thank you for reporting the issue, and sorry for late reply.
I tested @nostr-fetch/adapter-ndk@0.13.1 with @nostr-dev-kit/ndk@2.0.5, and even ndk@2.2.0 (the latest version as of today) with the code below, but it seems to work as expected (except a type error, discussed later).
import NDK from "@nostr-dev-kit/ndk"; // 2.0.5 or 2.2.0
import { ndkAdapter } from "@nostr-fetch/adapter-ndk"; // 0.13.1
import { NostrFetcher } from "nostr-fetch"; // 0.13.1
import "websocket-polyfill";
const nHoursAgo = (hrs: number): number =>
Math.floor((Date.now() - hrs * 60 * 60 * 1000) / 1000);
const main = async () => {
const relays = [
"wss://relay.damus.io/",
"wss://nsotr-pub.wellorder.net/",
"wss://nostr.mom/"
];
const ndk = new NDK();
await ndk.connect();
const fetcher = NostrFetcher.withCustomPool(ndkAdapter(ndk), { minLogLevel: "verbose" });
const evs = await fetcher.fetchAllEvents(
relays,
{ kinds: [2, 3, 10002] },
{ since: nHoursAgo(1) },
{ sort: true },
);
console.log(evs.length);
fetcher.shutdown();
};
main()
.then(() => console.log("fin"))
.catch((e) => {
console.error(e);
process.exit(1);
});
If you don't mind, can you share complete code to reproduce the issue?
BTW, seems that the type of
It has been done in 0.14.1.NDK
in v0 and in v1/v2 are incompatible due to a removal of a property, so I'll bump the minimum supported version of NDK in next release.
Sorry for the delay, I moved to the nostr-tools
adapter so I cannot provide the code.
I'll close this for now.
Having issues with this adapter and noticed a peer dependency of
^0.8.4
inadapter-ndk
.ndk
is presently2.0.5
, didn't look into your testing suite but possible it has fallen out of sync.When using
fetchAllEvents
with the adapter, as according to the docsI get the following errors for confirmed-online relays.
When I use ndk directly as a drop-in on existing logic with same data, I get successful connections.
If the adapter needs to be updated, would be willing to take a look. Let me know if you have some knowledge to drop before I dive in