feat: add nip46

This commit is contained in:
reya
2024-04-18 15:09:33 +07:00
parent cd31b99559
commit 89c36423ae
7 changed files with 189 additions and 65 deletions
+13 -13
View File
@@ -1,5 +1,5 @@
import { Spinner } from "@lume/ui";
import { createLazyFileRoute, useNavigate } from "@tanstack/react-router";
import { createLazyFileRoute } from "@tanstack/react-router";
import { useState } from "react";
import { toast } from "sonner";
@@ -9,7 +9,7 @@ export const Route = createLazyFileRoute("/auth/privkey")({
function Screen() {
const { ark } = Route.useRouteContext();
const navigate = useNavigate();
const navigate = Route.useNavigate();
const [key, setKey] = useState("");
const [password, setPassword] = useState("");
@@ -20,23 +20,23 @@ function Screen() {
return toast.warning(
"You need to enter a valid private key starts with nsec or ncryptsec",
);
if (key.length < 30)
return toast.warning("You need to enter a valid private key");
setLoading(true);
try {
setLoading(true);
const npub = await ark.save_account(key, password);
navigate({
to: "/auth/settings",
search: { account: npub, new: false },
replace: true,
});
if (npub) {
navigate({
to: "/auth/settings",
search: { account: npub },
replace: true,
});
}
} catch (e) {
setLoading(false);
toast.error(e);
}
setLoading(false);
};
return (