From 30fd6b62159a2ae2025efa74066f1b9044f8dce0 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sat, 6 May 2023 18:03:00 -0500 Subject: [PATCH] nip57: use Kind enum instead of using the number directly --- nip57.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/nip57.ts b/nip57.ts index 77f0c12..971acc0 100644 --- a/nip57.ts +++ b/nip57.ts @@ -1,6 +1,6 @@ import {bech32} from '@scure/base' -import {Event, EventTemplate, validateEvent, verifySignature} from './event' +import {Event, EventTemplate, validateEvent, verifySignature, Kind} from './event' import {utf8Decoder} from './utils' var _fetch: any @@ -13,7 +13,7 @@ export function useFetchImplementation(fetchImplementation: any) { _fetch = fetchImplementation } -export async function getZapEndpoint(metadata: Event<0>): Promise { +export async function getZapEndpoint(metadata: Event): Promise { try { let lnurl: string = '' let {lud06, lud16} = JSON.parse(metadata.content) @@ -53,11 +53,11 @@ export function makeZapRequest({ amount: number comment: string relays: string[] -}): EventTemplate<9734> { +}): EventTemplate { if (!amount) throw new Error('amount not given') if (!profile) throw new Error('profile not given') - let zr: EventTemplate<9734> = { + let zr: EventTemplate = { kind: 9734, created_at: Math.round(Date.now() / 1000), content: comment, @@ -113,13 +113,13 @@ export function makeZapReceipt({ preimage: string | null bolt11: string paidAt: Date -}): EventTemplate<9735> { - let zr: Event<9734> = JSON.parse(zapRequest) +}): EventTemplate { + let zr: Event = JSON.parse(zapRequest) let tagsFromZapRequest = zr.tags.filter( ([t]) => t === 'e' || t === 'p' || t === 'a' ) - let zap: EventTemplate<9735> = { + let zap: EventTemplate = { kind: 9735, created_at: Math.round(paidAt.getTime() / 1000), content: '',