wip: migrate to ark

This commit is contained in:
2023-12-08 09:32:48 +07:00
parent 5f90bd0d22
commit 68886ad584
26 changed files with 441 additions and 349 deletions

View File

@@ -1,29 +1,19 @@
import { NDKEvent, NDKKind, NDKUser } from '@nostr-dev-kit/ndk';
import { useState } from 'react';
import { toast } from 'sonner';
import { MediaUploader } from '@app/chats/components/mediaUploader';
import { useNDK } from '@libs/ndk/provider';
import { useArk } from '@libs/ark';
import { EnterIcon } from '@shared/icons';
export function ChatForm({ receiverPubkey }: { receiverPubkey: string }) {
const { ndk } = useNDK();
const { ark } = useArk();
const [value, setValue] = useState('');
const submit = async () => {
try {
const recipient = new NDKUser({ pubkey: receiverPubkey });
const message = await ndk.signer.encrypt(recipient, value);
const event = new NDKEvent(ndk);
event.content = message;
event.kind = NDKKind.EncryptedDirectMessage;
event.tag(recipient);
const publish = await event.publish();
const publish = await ark.nip04Encrypt({ content: value, pubkey: receiverPubkey });
if (publish) setValue('');
} catch (e) {
toast.error(e);