feat: integrate ZapsModule and enhance zap payment handling
- Added ZapsModule to the application, integrating it into the main app and webhooks modules. - Introduced a new method in BTCPayService for processing payments to Lightning addresses, improving zap payout functionality. - Updated WebhooksService to handle zap payment events, allowing for seamless integration of zap transactions. - Enhanced UI components to display zap-related information, including zaps count and avatar stacks, improving user engagement. These changes enhance the overall zap payment experience and ensure better integration of zap functionalities across the application.
This commit is contained in:
@@ -28,6 +28,8 @@ export interface ContentStats {
|
||||
reviewCount: number
|
||||
zapCount: number
|
||||
zapAmountSats: number
|
||||
/** Pubkeys of recent zappers (for avatar stack on cards); max 5 */
|
||||
recentZapperPubkeys: string[]
|
||||
recentEvents: NostrEvent[]
|
||||
}
|
||||
|
||||
@@ -92,6 +94,7 @@ function rebuildStats() {
|
||||
reviewCount: 0,
|
||||
zapCount: 0,
|
||||
zapAmountSats: 0,
|
||||
recentZapperPubkeys: [],
|
||||
recentEvents: [],
|
||||
}
|
||||
map.set(id, stats)
|
||||
@@ -164,6 +167,22 @@ function rebuildStats() {
|
||||
if (sats > 0) stats.zapAmountSats += sats
|
||||
}
|
||||
|
||||
// Sender pubkey for avatar stack (NIP-57: in description zap request)
|
||||
let senderPubkey = event.pubkey
|
||||
const descTag = event.tags.find((t) => t[0] === 'description')?.[1]
|
||||
if (descTag) {
|
||||
try {
|
||||
const zapRequest = JSON.parse(descTag)
|
||||
if (zapRequest.pubkey) senderPubkey = zapRequest.pubkey
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
if (
|
||||
stats.recentZapperPubkeys.length < 5 &&
|
||||
!stats.recentZapperPubkeys.includes(senderPubkey)
|
||||
) {
|
||||
stats.recentZapperPubkeys.push(senderPubkey)
|
||||
}
|
||||
|
||||
stats.recentEvents.push(event)
|
||||
}
|
||||
}
|
||||
@@ -233,6 +252,7 @@ const EMPTY_STATS: ContentStats = {
|
||||
reviewCount: 0,
|
||||
zapCount: 0,
|
||||
zapAmountSats: 0,
|
||||
recentZapperPubkeys: [],
|
||||
recentEvents: [],
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user