chore: nostr-tools zap api breaking change. (#492)

This commit is contained in:
fiatjaf_
2025-08-24 22:12:14 -03:00
committed by GitHub
parent 6b88da3f03
commit 267065ef29
5 changed files with 21 additions and 20 deletions

View File

@@ -43,7 +43,7 @@ export default function TopZaps({ event }: { event: Event }) {
}
}}
pubkey={event.pubkey}
eventId={event.id}
event={event}
defaultAmount={zap.amount}
defaultComment={zap.comment}
/>

View File

@@ -51,7 +51,7 @@ export default function ZapButton({ event }: { event: Event }) {
event.pubkey,
defaultZapSats,
defaultZapComment,
event.id
event
)
// user canceled
if (!zapResult) {
@@ -159,7 +159,7 @@ export default function ZapButton({ event }: { event: Event }) {
setZapping(open)
}}
pubkey={event.pubkey}
eventId={event.id}
event={event}
/>
</>
)

View File

@@ -26,19 +26,20 @@ import { useTranslation } from 'react-i18next'
import { toast } from 'sonner'
import UserAvatar from '../UserAvatar'
import Username from '../Username'
import { NostrEvent } from 'nostr-tools'
export default function ZapDialog({
open,
setOpen,
pubkey,
eventId,
event,
defaultAmount,
defaultComment
}: {
open: boolean
setOpen: Dispatch<SetStateAction<boolean>>
pubkey: string
eventId?: string
event?: NostrEvent
defaultAmount?: number
defaultComment?: string
}) {
@@ -87,7 +88,7 @@ export default function ZapDialog({
open={open}
setOpen={setOpen}
recipient={pubkey}
eventId={eventId}
event={event}
defaultAmount={defaultAmount}
defaultComment={defaultComment}
/>
@@ -110,7 +111,7 @@ export default function ZapDialog({
open={open}
setOpen={setOpen}
recipient={pubkey}
eventId={eventId}
event={event}
defaultAmount={defaultAmount}
defaultComment={defaultComment}
/>
@@ -122,14 +123,14 @@ export default function ZapDialog({
function ZapDialogContent({
setOpen,
recipient,
eventId,
event,
defaultAmount,
defaultComment
}: {
open: boolean
setOpen: Dispatch<SetStateAction<boolean>>
recipient: string
eventId?: string
event?: NostrEvent
defaultAmount?: number
defaultComment?: string
}) {
@@ -146,15 +147,15 @@ function ZapDialogContent({
throw new Error('You need to be logged in to zap')
}
setZapping(true)
const zapResult = await lightning.zap(pubkey, recipient, sats, comment, eventId, () =>
const zapResult = await lightning.zap(pubkey, recipient, sats, comment, event, () =>
setOpen(false)
)
// user canceled
if (!zapResult) {
return
}
if (eventId) {
noteStatsService.addZap(pubkey, eventId, zapResult.invoice, sats, comment)
if (event) {
noteStatsService.addZap(pubkey, event?.id, zapResult.invoice, sats, comment)
}
} catch (error) {
toast.error(`${t('Zap failed')}: ${(error as Error).message}`)