diff options
| author | Adam Soltys <[email protected]> | 2024-09-18 21:05:49 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-09-18 21:05:49 -0700 |
| commit | 072cb81c886d7461a6e1ffce9d658d1463ca6315 (patch) | |
| tree | 8dece5563e9fa25111fbe0953b5de1868964f26d | |
| parent | f893043b00750ad693fc886eb77184598b9c8317 (diff) | |
| download | coinos-ui-072cb81c886d7461a6e1ffce9d658d1463ca6315.tar.gz coinos-ui-072cb81c886d7461a6e1ffce9d658d1463ca6315.zip | |
import page
| -rw-r--r-- | src/lib/nostr.ts | 2 | ||||
| -rw-r--r-- | src/routes/(app)/account/import/+page.svelte | 53 | ||||
| -rw-r--r-- | src/routes/(app)/account/pass/+page.svelte | 9 |
3 files changed, 56 insertions, 8 deletions
diff --git a/src/lib/nostr.ts b/src/lib/nostr.ts index bd2e65fe..62853f09 100644 --- a/src/lib/nostr.ts +++ b/src/lib/nostr.ts @@ -19,7 +19,7 @@ import { import { mnemonicToEntropy, entropyToMnemonic } from "@scure/bip39"; import { bech32m } from "@scure/base"; - import { wordlist } from "@scure/bip39/wordlists/english"; +import { wordlist } from "@scure/bip39/wordlists/english"; import { generateSeedWords, privateKeyFromSeedWords } from "nostr-tools/nip06"; diff --git a/src/routes/(app)/account/import/+page.svelte b/src/routes/(app)/account/import/+page.svelte new file mode 100644 index 00000000..1e28f9df --- /dev/null +++ b/src/routes/(app)/account/import/+page.svelte @@ -0,0 +1,53 @@ +<script> + import { versions } from "$lib/utils"; + import { t } from "$lib/translations"; + import { browser } from "$app/environment"; + import Icon from "$comp/Icon.svelte"; + import { validateMnemonic } from "@scure/bip39"; + import { wordlist } from "@scure/bip39/wordlists/english"; + import { HDKey } from "@scure/bip32"; + + let el, pasted, text; + + let paste = async () => { + text = await navigator.clipboard.readText(); + pasted = true; + }; + + let submit = () => { + let valid = validateMnemonic(text, wordlist); + let v2 = HDKey.fromExtendedKey(text, versions); + + console.log(valid); + console.log(v2); + }; + + $: if (browser && pasted && text) form.submit() && (pasted = false); +</script> + +<div class="space-y-5"> + <h1 class="text-center text-3xl font-semibold">Import</h1> + + <div class="container w-full mx-auto text-lg px-4 max-w-xl space-y-2"> + <div class="space-y-5"> + <form on:submit|preventDefault={submit}> + <textarea + use:focus + name="text" + placeholder="Enter a seed phrase or extended key" + class="w-full p-4 border rounded-xl h-48 text-xl" + bind:value={text} + autocapitalize="none" + /> + <button + bind:this={el} + type="submit" + class="flex bg-black text-white border rounded-2xl px-6 py-5 w-full font-bold gap-2 justify-center" + > + <Icon icon="send" style="w-8 my-auto invert" /> + <div class="my-auto">{$t("user.send.next")}</div> + </button> + </form> + </div> + </div> +</div> diff --git a/src/routes/(app)/account/pass/+page.svelte b/src/routes/(app)/account/pass/+page.svelte index b6c7f339..ee29d2c3 100644 --- a/src/routes/(app)/account/pass/+page.svelte +++ b/src/routes/(app)/account/pass/+page.svelte @@ -21,7 +21,7 @@ let confirm, password; onMount(() => { - if (!$mnemonic) goto("/account/savings"); + if (!$mnemonic) goto("/account/savings"); }); let submit = async () => { @@ -71,12 +71,7 @@ </p> <input use:focus type="text" placeholder="Password" bind:value={password} /> - <input - use:focus - type="text" - placeholder="Confirm password" - bind:value={confirm} - /> + <input type="text" placeholder="Confirm password" bind:value={confirm} /> <button class="bg-black text-white w-full px-5 py-6 text-xl rounded-2xl font-bold" |
