Skip to content

Commit

Permalink
Change nostr keys on the fly
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman authored and futurepaul committed Apr 10, 2024
1 parent 115f11a commit 183449e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/components/ImportNsecForm.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { MutinyWallet } from "@mutinywallet/mutiny-wasm";
import { useNavigate } from "@solidjs/router";
import { SecureStoragePlugin } from "capacitor-secure-storage-plugin";
import { createSignal, Show } from "solid-js";

import { Button, InfoBox, SimpleInput } from "~/components";
import { useMegaStore } from "~/state/megaStore";

export function ImportNsecForm() {
const [state, _actions] = useMegaStore();
const navigate = useNavigate();
const [nsec, setNsec] = createSignal("");
const [saving, setSaving] = createSignal(false);
const [error, setError] = createSignal<string | undefined>();
Expand All @@ -19,8 +23,13 @@ export function ImportNsecForm() {
throw new Error("Invalid nsec");
}
await SecureStoragePlugin.set({ key: "nsec", value: trimmedNsec });
// TODO: right now we need a reload to set the nsec
window.location.href = "/";

const new_npub = await state.mutiny_wallet?.change_nostr_keys(
trimmedNsec,
undefined
);
console.log("Changed to new npub: ", new_npub);
navigate("/");
} catch (e) {
console.error(e);
setError("Invalid nsec");
Expand Down

0 comments on commit 183449e

Please sign in to comment.