From 2324f9548e8d2fc7d63d73bbf9155c32140b8ba6 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Thu, 16 Feb 2023 13:55:40 -0300 Subject: [PATCH] fail on null amount on zaprequest creation. --- nip57.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nip57.ts b/nip57.ts index 5fd8ca7..0a00180 100644 --- a/nip57.ts +++ b/nip57.ts @@ -50,17 +50,20 @@ export function makeZapRequest({ }: { profile: string event: string | null - amount: string + amount: number comment: string relays: string[] }): EventTemplate { + if (!amount) throw new Error('amount not given') + if (!profile) throw new Error('profile not given') + let zr = { kind: 9734, created_at: Math.round(Date.now() / 1000), content: comment, tags: [ ['p', profile], - ['amount', amount], + ['amount', amount.toString()], ['relays', ...relays] ] }