From 59f5c9c042b54151abca61913626f2edbce7667a Mon Sep 17 00:00:00 2001 From: Adrien Hopkins Date: Wed, 28 Jan 2026 12:51:57 -0500 Subject: Add doc comments to my exported $lib methods --- src/lib/nip01.ts | 1 + src/lib/nip07.ts | 1 + src/lib/nip17.ts | 2 ++ src/lib/nip51.ts | 3 +++ 4 files changed, 7 insertions(+) (limited to 'src/lib') diff --git a/src/lib/nip01.ts b/src/lib/nip01.ts index f7653fa4..a5d3f4b5 100644 --- a/src/lib/nip01.ts +++ b/src/lib/nip01.ts @@ -5,6 +5,7 @@ const USERINFO_RELAYS = [ ...DM_RELAYS_LIST, PUBLIC_COINOS_RELAY ]; import { SimplePool } from 'nostr-tools/pool'; const pool = new SimplePool(); +// Returns the content of the kind-0 event of the provided pubkey. export const getNostrUserInfo = async (pubkey: string) => { const events = await pool.querySync( USERINFO_RELAYS, { kinds: [0], limit: 1, authors: [pubkey] } diff --git a/src/lib/nip07.ts b/src/lib/nip07.ts index 7191da33..9f675950 100644 --- a/src/lib/nip07.ts +++ b/src/lib/nip07.ts @@ -5,6 +5,7 @@ import { getPrivateKey } from '$lib/nostr'; import * as libnip44 from '$lib/nip44'; import { u } from '$lib/nip44'; +// Signs an event using NIP-07 if available, otherwise getPrivateKey() export const signEvent = async (event: object, user: object): object => { if (await window.nostr.getPublicKey() === user.pubkey) { return window.nostr.signEvent(event); diff --git a/src/lib/nip17.ts b/src/lib/nip17.ts index a8cadd2f..b128dab9 100644 --- a/src/lib/nip17.ts +++ b/src/lib/nip17.ts @@ -169,6 +169,8 @@ export const getMessageRumours = async (user: object): object[] => { return rumours; } +// Returns the preferred relays of the user with the provided pubkey, +// according to their kind-10050 event. export const getPreferredRelays = async (pubkey: string): string[] => { if (relayListCache.has(pubkey)) return relayListCache.get(pubkey); diff --git a/src/lib/nip51.ts b/src/lib/nip51.ts index 8d6f76db..b1b0b613 100644 --- a/src/lib/nip51.ts +++ b/src/lib/nip51.ts @@ -6,6 +6,7 @@ const pool = new SimplePool(); import { PUBLIC_DM_RELAYS } from '$env/static/public'; const DM_RELAYS_LIST = PUBLIC_DM_RELAYS.split(','); +// Mute the provided pubkey, as the provided user. export const mute = async (user: object, pubkey: string, hide: bool) => { let { shown, hidden } = await getMuteLists(user); if (hide) { @@ -19,6 +20,7 @@ export const mute = async (user: object, pubkey: string, hide: bool) => { const tagMatches = (tag: string[], pubkey: string): bool => tag.length >= 2 && tag[0] === "p" && tag[1] === pubkey; +// Unmute the provided pubkey, as the provided user. export const unmute = async (user: object, pubkey: string) => { let { shown, hidden } = await getMuteLists(user); shown = shown.filter(tag => !tagMatches(tag, pubkey)); @@ -26,6 +28,7 @@ export const unmute = async (user: object, pubkey: string) => { await publishMuteList(user, shown, hidden); } +// Returns a set of the provided user's muted accounts. export const mutedAccounts = async (user: object): Set => { const { shown, hidden } = await getMuteLists(user); let muted = new Set(); -- cgit v1.2.3