Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"lru-cache": "^11.0.2",
"lucide-react": "^0.469.0",
"next-themes": "^0.4.6",
"nostr-tools": "^2.13.0",
"nostr-tools": "^2.16.2",
"nstart-modal": "^2.0.0",
"path-to-regexp": "^8.2.0",
"qr-code-styling": "^1.9.2",
Expand Down
2 changes: 1 addition & 1 deletion src/components/NoteStats/TopZaps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
/>
Expand Down
4 changes: 2 additions & 2 deletions src/components/NoteStats/ZapButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function ZapButton({ event }: { event: Event }) {
event.pubkey,
defaultZapSats,
defaultZapComment,
event.id
event
)
// user canceled
if (!zapResult) {
Expand Down Expand Up @@ -159,7 +159,7 @@ export default function ZapButton({ event }: { event: Event }) {
setZapping(open)
}}
pubkey={event.pubkey}
eventId={event.id}
event={event}
/>
</>
)
Expand Down
19 changes: 10 additions & 9 deletions src/components/ZapDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
}) {
Expand Down Expand Up @@ -87,7 +88,7 @@ export default function ZapDialog({
open={open}
setOpen={setOpen}
recipient={pubkey}
eventId={eventId}
event={event}
defaultAmount={defaultAmount}
defaultComment={defaultComment}
/>
Expand All @@ -110,7 +111,7 @@ export default function ZapDialog({
open={open}
setOpen={setOpen}
recipient={pubkey}
eventId={eventId}
event={event}
defaultAmount={defaultAmount}
defaultComment={defaultComment}
/>
Expand All @@ -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
}) {
Expand All @@ -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}`)
Expand Down
14 changes: 7 additions & 7 deletions src/services/lightning.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Invoice } from '@getalby/lightning-tools'
import { bech32 } from '@scure/base'
import { WebLNProvider } from '@webbtc/webln-types'
import dayjs from 'dayjs'
import { Filter, kinds } from 'nostr-tools'
import { Filter, kinds, NostrEvent } from 'nostr-tools'
import { SubCloser } from 'nostr-tools/abstract-pool'
import { makeZapRequest } from 'nostr-tools/nip57'
import { utf8Decoder } from 'nostr-tools/utils'
Expand Down Expand Up @@ -46,7 +46,7 @@ class LightningService {
recipient: string,
sats: number,
comment: string,
eventId?: string,
event?: NostrEvent,
closeOuterModel?: () => void
): Promise<{ preimage: string; invoice: string } | null> {
if (!client.signer) {
Expand All @@ -70,8 +70,8 @@ class LightningService {
const { callback, lnurl } = zapEndpoint
const amount = sats * 1000
const zapRequestDraft = makeZapRequest({
profile: recipient,
event: eventId ?? null,
event: event,
pubkey: recipient,
amount,
relays: receiptRelayList.read
.slice(0, 4)
Expand Down Expand Up @@ -133,8 +133,8 @@ class LightningService {
'#p': [recipient],
since: dayjs().subtract(1, 'minute').unix()
}
if (eventId) {
filter['#e'] = [eventId]
if (event) {
filter['#e'] = [event.id]
}
subCloser = client.subscribe(
senderRelayList.write.concat(BIG_RELAY_URLS).slice(0, 4),
Expand Down Expand Up @@ -226,7 +226,7 @@ class LightningService {
const [name, domain] = profile.lightningAddress.split('@')
lnurl = new URL(`/.well-known/lnurlp/${name}`, `https://${domain}`).toString()
} else {
const { words } = bech32.decode(profile.lightningAddress, 1000)
const { words } = bech32.decode(profile.lightningAddress as any, 1000)
const data = bech32.fromWords(words)
lnurl = utf8Decoder.decode(data)
}
Expand Down