From 0b887ac49589b867a8f81527674c5f6f03313162 Mon Sep 17 00:00:00 2001 From: hzrd149 Date: Tue, 28 May 2024 09:13:16 -0500 Subject: [PATCH] verify zaps with wasm --- src/components/router/back-button.tsx | 5 +++++ src/helpers/nostr/zaps.ts | 5 +++-- src/views/dms/chat.tsx | 9 ++------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/components/router/back-button.tsx b/src/components/router/back-button.tsx index a19a13f74..09518a359 100644 --- a/src/components/router/back-button.tsx +++ b/src/components/router/back-button.tsx @@ -11,3 +11,8 @@ export default function BackButton({ ...props }: Omit ); } + +export function BackIconButton({ ...props }: Omit) { + const navigate = useNavigate(); + return } aria-label="Back" {...props} onClick={() => navigate(-1)} />; +} diff --git a/src/helpers/nostr/zaps.ts b/src/helpers/nostr/zaps.ts index a07b0e88c..a71bb52e0 100644 --- a/src/helpers/nostr/zaps.ts +++ b/src/helpers/nostr/zaps.ts @@ -3,7 +3,8 @@ import { isETag, isPTag, NostrEvent } from "../../types/nostr-event"; import { ParsedInvoice, parsePaymentRequest } from "../bolt11"; import { Kind0ParsedContent } from "./user-metadata"; -import { nip57, utils, validateEvent } from "nostr-tools"; +import { nip57, utils } from "nostr-tools"; +import verifyEvent from "../../services/verify-event"; // based on https://github.com/nbd-wtf/nostr-tools/blob/master/nip57.ts export async function getZapEndpoint(metadata: Kind0ParsedContent): Promise { @@ -102,7 +103,7 @@ export function parseZapEvent(event: NostrEvent): ParsedZap { if (error) throw new Error(error); const request = JSON.parse(zapRequestStr) as NostrEvent; - if (!validateEvent(request)) throw new Error("Invalid zap request"); + if (!verifyEvent(request)) throw new Error("Invalid zap request"); const payment = parsePaymentRequest(bolt11); return { diff --git a/src/views/dms/chat.tsx b/src/views/dms/chat.tsx index 83f56a3ac..308e5bf3f 100644 --- a/src/views/dms/chat.tsx +++ b/src/views/dms/chat.tsx @@ -27,6 +27,7 @@ import RelaySet from "../../classes/relay-set"; import useAppSettings from "../../hooks/use-app-settings"; import { truncateId } from "../../helpers/string"; import useRouterMarker from "../../hooks/use-router-marker"; +import BackButton, { BackIconButton } from "../../components/router/back-button"; /** This is broken out from DirectMessageChatPage for performance reasons. Don't use outside of file */ const ChatLog = memo(({ timeline }: { timeline: TimelineLoader }) => { @@ -121,13 +122,7 @@ function DirectMessageChatPage({ pubkey }: { pubkey: string }) { - } - aria-label="Back" - onClick={() => navigate(-1)} - hideFrom="xl" - /> +