diff --git a/package-lock.json b/package-lock.json index 93e2a44..6e228a6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1473,18 +1473,7 @@ "node_modules/@nostrify/nostrify": { "version": "0.47.1", "resolved": "https://registry.npmjs.org/@nostrify/nostrify/-/nostrify-0.47.1.tgz", - "integrity": "sha512-8jdAeKIyyDK/UQN92WgrQn9+B067HYcjfW35TpIjNLAT9qYe+KYFHaC9O6PD+I1DvLHziJMxk4Q18Fu4fqOiAQ==", - "dependencies": { - "@nostrify/types": "0.36.7", - "@scure/base": "^1.2.6", - "@std/encoding": "npm:@jsr/std__encoding@^0.224.1", - "@types/node": "^24.1.0", - "lru-cache": "^10.2.0", - "nostr-tools": "^2.13.0", - "websocket-ts": "^2.2.1", - "ws": "^8.18.3", - "zod": "^3.23.8" - } + "integrity": "sha512-8jdAeKIyyDK/UQN92WgrQn9+B067HYcjfW35TpIjNLAT9qYe+KYFHaC9O6PD+I1DvLHziJMxk4Q18Fu4fqOiAQ==" }, "node_modules/@nostrify/nostrify/node_modules/@scure/base": { "version": "1.2.6", diff --git a/package.json b/package.json index 6a5431d..c2d8ff2 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "@noble/curves": "^2.0.1", "@noble/hashes": "^2.0.1", "@nostrify/nostrify": "^0.47.1", - "@nostrify/react": "^0.2.17", + "@nostrify/react": "0.2.17", "@radix-ui/react-accordion": "^1.2.0", "@radix-ui/react-alert-dialog": "^1.1.1", "@radix-ui/react-aspect-ratio": "^1.1.0", @@ -89,7 +89,7 @@ "lucide-react": "^0.462.0", "ngeohash": "^0.6.3", "nostr-signer-capacitor-plugin": "github:coracle-social/nostr-signer-capacitor-plugin#main", - "nostr-tools": "^2.13.0", + "nostr-tools": "2.13.0", "npubcash-sdk": "^0.2.0", "qrcode": "^1.5.4", "react": "^18.3.1", diff --git a/src/hooks/usePurchasePro.ts b/src/hooks/usePurchasePro.ts index c91cb9a..a6e6e13 100644 --- a/src/hooks/usePurchasePro.ts +++ b/src/hooks/usePurchasePro.ts @@ -16,7 +16,6 @@ import { useCallback, useState } from 'react'; import { useNostr } from '@nostrify/react'; -import { nip57 } from 'nostr-tools'; import { useCurrentUser } from '@/hooks/useCurrentUser'; import { useNWC } from '@/hooks/useNWCContext'; import { useWallet } from '@/hooks/useWallet'; @@ -132,16 +131,22 @@ export function usePurchasePro() { let invoice: string; if (providerPubkey) { - const zapRequest = nip57.makeZapRequest({ - profile: PLATFORM_PUBKEY, - event: null, - amount: amountMsats, - relays, - comment, - }); - // Tag the purchase so verification can read tier + expiry from the receipt. - zapRequest.tags.push(['pro-tier', tier.id]); - zapRequest.tags.push(['pro-expiry', String(expiry)]); + // Build the NIP-57 zap request event directly (profile zap, no event + // target). Constructed by hand rather than via nip57.makeZapRequest so + // we're not coupled to that helper's changing type signature. + const zapRequest = { + kind: 9734, + content: comment, + created_at: Math.floor(Date.now() / 1000), + tags: [ + ['relays', ...relays], + ['amount', String(amountMsats)], + ['p', PLATFORM_PUBKEY], + // Tag the purchase so verification can read tier + expiry from the receipt. + ['pro-tier', tier.id], + ['pro-expiry', String(expiry)], + ] as string[][], + }; const signed = await user.signer.signEvent(zapRequest); invoice = await getZapInvoiceFromLightningAddress({ lightningAddress: PRO_LIGHTNING_ADDRESS, diff --git a/src/hooks/useZaps.ts b/src/hooks/useZaps.ts index ec16d45..0677559 100644 --- a/src/hooks/useZaps.ts +++ b/src/hooks/useZaps.ts @@ -192,22 +192,35 @@ export function useZaps( return; } - // Create zap request - use appropriate event format based on kind - // For addressable events (30000-39999), pass the object to get 'a' tag - // For all other events, pass the ID string to get 'e' tag - const event = (actualTarget.kind >= 30000 && actualTarget.kind < 40000) - ? actualTarget - : actualTarget.id; - const zapAmount = amount * 1000; // convert to millisats - const zapRequest = nip57.makeZapRequest({ - profile: actualTarget.pubkey, - event: event, - amount: zapAmount, - relays: config.relayMetadata.relays.map(r => r.url), - comment - }); + // Build the NIP-57 zap request event directly. We construct it by hand + // (rather than nip57.makeZapRequest) so we're not coupled to that helper's + // changing type signature across nostr-tools versions, and so we can emit + // the correct target tag: + // - addressable events (30000-39999) → 'a' tag (kind:pubkey:dTag) + // - all other events → 'e' tag (event id) + const isAddressable = + actualTarget.kind >= 30000 && actualTarget.kind < 40000; + + const zapTags: string[][] = [ + ['relays', ...config.relayMetadata.relays.map(r => r.url)], + ['amount', String(zapAmount)], + ['p', actualTarget.pubkey], + ]; + if (isAddressable) { + const dTag = actualTarget.tags.find(([n]) => n === 'd')?.[1] ?? ''; + zapTags.push(['a', `${actualTarget.kind}:${actualTarget.pubkey}:${dTag}`]); + } else { + zapTags.push(['e', actualTarget.id]); + } + + const zapRequest = { + kind: 9734, + content: comment ?? '', + tags: zapTags, + created_at: Math.floor(Date.now() / 1000), + }; // Sign the zap request (but don't publish to relays - only send to LNURL endpoint) if (!user.signer) {