verify zaps with wasm

This commit is contained in:
hzrd149 2024-05-28 09:13:16 -05:00
parent 1ba399c3aa
commit 0b887ac495
3 changed files with 10 additions and 9 deletions

View File

@ -11,3 +11,8 @@ export default function BackButton({ ...props }: Omit<IconButtonProps, "onClick"
</IconButton>
);
}
export function BackIconButton({ ...props }: Omit<IconButtonProps, "onClick" | "children" | "aria-label">) {
const navigate = useNavigate();
return <IconButton icon={<ChevronLeftIcon />} aria-label="Back" {...props} onClick={() => navigate(-1)} />;
}

View File

@ -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<null | string> {
@ -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 {

View File

@ -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 }) {
<IntersectionObserverProvider callback={callback}>
<Card size="sm" flexShrink={0} p="2" flexDirection="row">
<Flex gap="2" alignItems="center">
<IconButton
variant="ghost"
icon={<ChevronLeftIcon />}
aria-label="Back"
onClick={() => navigate(-1)}
hideFrom="xl"
/>
<BackIconButton />
<UserAvatar pubkey={pubkey} size="sm" />
<UserLink pubkey={pubkey} fontWeight="bold" />
<UserDnsIdentity pubkey={pubkey} onlyIcon />