From 4b016c908dda2019f3bf89e5a3d2eae535e5fbd2 Mon Sep 17 00:00:00 2001 From: polwex Date: Thu, 18 Sep 2025 00:24:39 +0700 Subject: oioi --- front/src/logic/nostrill.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'front/src/logic/nostrill.ts') diff --git a/front/src/logic/nostrill.ts b/front/src/logic/nostrill.ts index bf9212d..bd5fc9c 100644 --- a/front/src/logic/nostrill.ts +++ b/front/src/logic/nostrill.ts @@ -1,6 +1,9 @@ import type { Event } from "@/types/nostr"; import type { Content, FC, Poast } from "@/types/trill"; import { engagementBunt, openLock } from "./bunts"; +import type { UserType } from "@/types/nostrill"; +import type { Result } from "@/types/ui"; +import { isValidPatp } from "urbit-ob"; export function eventsToFc(postEvents: Event[]): FC { const fc = postEvents.reduce( (acc: FC, event: Event) => { @@ -66,6 +69,24 @@ export function eventToPoast(event: Event): Poast | null { return poast; } +export function userToString(user: UserType): Result { + if ("urbit" in user) { + const isValid = isValidPatp(user.urbit); + if (isValid) return { ok: user.urbit }; + else return { error: "invalid @p" }; + } else if ("nostr" in user) return { ok: user.nostr }; + else return { error: "unknown user" }; +} +export function isValidNostrPubkey(pubkey: string): boolean { + // TODO + if (pubkey.length !== 64) return false; + try { + BigInt("0x" + pubkey); + return true; + } catch (_e) { + return false; + } +} // NOTE common tags: // imeta // client -- cgit v1.2.3