From 2c649e0fa61c727934dc540edac477c628294963 Mon Sep 17 00:00:00 2001 From: Siddharth Singh Date: Sat, 8 Jun 2024 00:26:36 +0530 Subject: [PATCH] support npubs in admin:role script --- scripts/admin-role.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/admin-role.ts b/scripts/admin-role.ts index 6e7bfc66..2a300a5d 100644 --- a/scripts/admin-role.ts +++ b/scripts/admin-role.ts @@ -5,11 +5,14 @@ import { Conf } from '@/config.ts'; import { AdminSigner } from '@/signers/AdminSigner.ts'; import { EventsDB } from '@/storages/EventsDB.ts'; import { nostrNow } from '@/utils.ts'; +import { nip19 } from 'nostr-tools'; const kysely = await DittoDB.getInstance(); const eventsDB = new EventsDB(kysely); -const [pubkey, role] = Deno.args; +const [pubkeyOrNpub, role] = Deno.args; +const pubkey = pubkeyOrNpub.startsWith('npub') ? + nip19.decode(pubkeyOrNpub).data as string : pubkeyOrNpub; if (!NSchema.id().safeParse(pubkey).success) { console.error('Invalid pubkey');