import { createAccount, createBlock } from "@libs/storage"; import { Button } from "@shared/button"; import { EyeOffIcon, EyeOnIcon } from "@shared/icons"; import { useMutation, useQueryClient } from "@tanstack/react-query"; import { generatePrivateKey, getPublicKey, nip19 } from "nostr-tools"; import { useMemo, useState } from "react"; import { useNavigate } from "react-router-dom"; export function CreateStep1Screen() { const navigate = useNavigate(); const queryClient = useQueryClient(); const [type, setType] = useState("password"); const privkey = useMemo(() => generatePrivateKey(), []); const pubkey = getPublicKey(privkey); const npub = nip19.npubEncode(pubkey); const nsec = nip19.nsecEncode(privkey); // toggle private key const showPrivateKey = () => { if (type === "password") { setType("text"); } else { setType("password"); } }; const account = useMutation({ mutationFn: (data: any) => createAccount(data.npub, data.pubkey, data.privkey, null, 1), onSuccess: () => { createBlock( 0, "Preserve your freedom", "https://void.cat/d/949GNg7ZjSLHm2eTR3jZqv", ); queryClient.invalidateQueries({ queryKey: ["currentAccount"] }); // redirect to next step navigate("/auth/create/step-2", { replace: true }); }, }); const submit = async () => { account.mutate({ npub, pubkey, privkey, follows: null, is_active: 1, }); }; return (

Lume is auto-generated key for you

); }