blob: 10440357aa09c0ffb49aead8d61eb706eadbe264 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
<script>
import { run, preventDefault } from 'svelte/legacy';
import { goto } from "$app/navigation";
import { mnemonic } from "$lib/store";
import { fail, focus, 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.js";
let el = $state(), pasted = $state(), text = $state();
let paste = async () => {
text = await navigator.clipboard.readText();
pasted = true;
};
let submit = () => {
text = text.replace(/,/g, " ").trim();
let valid = validateMnemonic(text, wordlist);
if (valid) {
$mnemonic = text;
goto("/account/pass");
} else {
fail("Failed to validate seed phrase");
}
};
run(() => {
if (browser && pasted && text) form.submit() && (pasted = false);
});
</script>
<div class="space-y-5">
<h1 class="text-center text-3xl font-semibold">{$t("accounts.import")}</h1>
<div class="container w-full mx-auto text-lg px-4 max-w-xl space-y-2">
<form onsubmit={preventDefault(submit)} class="space-y-2">
<textarea
use:focus
name="text"
placeholder={$t("accounts.enterSeed")}
class="w-full p-4 border rounded-xl h-48 text-xl"
bind:value={text}
autocapitalize="none"
></textarea>
<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>
|