migrate to ndk

This commit is contained in:
Ren Amamiya
2023-06-08 18:09:36 +07:00
parent 75a33d205a
commit 0ba9877785
53 changed files with 2749 additions and 930 deletions

15
src/libs/ndk.tsx Normal file
View File

@@ -0,0 +1,15 @@
import NDK, { NDKConstructorParams } from "@nostr-dev-kit/ndk";
import { FULL_RELAYS } from "@stores/constants";
export async function initNDK(
relays?: string[],
cache?: boolean,
): Promise<NDK> {
const opts: NDKConstructorParams = {};
opts.explicitRelayUrls = relays || FULL_RELAYS;
const ndk = new NDK(opts);
await ndk.connect();
return ndk;
}