From de40a2cfa6a803541124f01141a9e7f4aa97625f Mon Sep 17 00:00:00 2001 From: Norton Andreev Date: Thu, 14 Mar 2024 15:21:54 +0200 Subject: [PATCH] Updates --- .../dusk/components/Mnemonic/Mnemonic.svelte | 111 ++++++++++-------- web-wallet/src/lib/stores/index.js | 1 + .../lib/stores/mnemonicPhraseResetStore.js | 6 + .../src/routes/(welcome)/login/+page.svelte | 9 +- .../(welcome)/setup/restore/+page.svelte | 4 +- 5 files changed, 76 insertions(+), 55 deletions(-) create mode 100644 web-wallet/src/lib/stores/mnemonicPhraseResetStore.js diff --git a/web-wallet/src/lib/dusk/components/Mnemonic/Mnemonic.svelte b/web-wallet/src/lib/dusk/components/Mnemonic/Mnemonic.svelte index 769b789ffd..03d6892966 100644 --- a/web-wallet/src/lib/dusk/components/Mnemonic/Mnemonic.svelte +++ b/web-wallet/src/lib/dusk/components/Mnemonic/Mnemonic.svelte @@ -38,6 +38,9 @@ enteredMnemonicPhrase = Array(wordLimit).fill(""); } + const isTriggeredByLogin = + enteredMnemonicPhrase.some((word) => word !== "") && currentIndex === 0; + /** * @param {string} word * @param {string} index @@ -118,63 +121,67 @@
-
- {#if type === "authenticate" && shouldShowPaste} + {#if !isTriggeredByLogin} +
+ {#if type === "authenticate" && shouldShowPaste} +
+
+ {/if} -
- {#if type === "authenticate" && enteredWordIndex.includes("")} - - handleKeyDownOnAuthenticateTextbox(e, currentIndex.toString())} - maxlength={8} - type="text" - bind:value={currentInput} - /> - {#if suggestions.length} -
- {#each suggestions as suggestion, index (`${suggestion}-${index}`)} -
- {/if} - {:else} - {#each mnemonicPhrase as word, index (`${word}-${index}`)} -
+ {/if} + {:else} + {#each mnemonicPhrase as word, index (`${word}-${index}`)} +
+ {/if} diff --git a/web-wallet/src/lib/stores/index.js b/web-wallet/src/lib/stores/index.js index d2d1c8b98a..56c5cf1d5e 100644 --- a/web-wallet/src/lib/stores/index.js +++ b/web-wallet/src/lib/stores/index.js @@ -1,4 +1,5 @@ export { default as gasStore } from "./gasStore"; export { default as operationsStore } from "./operationsStore"; +export { default as mnemonicPhraseResetStore } from "./mnemonicPhraseResetStore"; export { default as settingsStore } from "./settingsStore"; export { default as walletStore } from "./walletStore"; diff --git a/web-wallet/src/lib/stores/mnemonicPhraseResetStore.js b/web-wallet/src/lib/stores/mnemonicPhraseResetStore.js new file mode 100644 index 0000000000..5d598a9686 --- /dev/null +++ b/web-wallet/src/lib/stores/mnemonicPhraseResetStore.js @@ -0,0 +1,6 @@ +import { writable } from "svelte/store"; + +/** @type {import('svelte/store').Writable} */ +const mnemonicPhraseResetStore = writable([]); + +export default mnemonicPhraseResetStore; diff --git a/web-wallet/src/routes/(welcome)/login/+page.svelte b/web-wallet/src/routes/(welcome)/login/+page.svelte index 1413f4c864..bd08755eb8 100644 --- a/web-wallet/src/routes/(welcome)/login/+page.svelte +++ b/web-wallet/src/routes/(welcome)/login/+page.svelte @@ -8,7 +8,11 @@ import { validateMnemonic } from "bip39"; import { goto } from "$lib/navigation"; - import { settingsStore, walletStore } from "$lib/stores"; + import { + mnemonicPhraseResetStore, + settingsStore, + walletStore, + } from "$lib/stores"; import { decryptMnemonic, getSeedFromMnemonic } from "$lib/wallet"; import loginInfoStorage from "$lib/services/loginInfoStorage"; import { getWallet } from "$lib/services/wallet"; @@ -31,6 +35,8 @@ const currentUserAddress = $settingsStore.userId; if (defaultAddress !== currentUserAddress) { + const enteredMnemonicPhrase = secretText.split(" "); + mnemonicPhraseResetStore.set(enteredMnemonicPhrase); await goto("/setup/restore"); throw new Error(existingWalletDetectedErrorMessage); } @@ -114,6 +120,7 @@ icon={{ path: mdiWalletOutline }} /> mnemonicPhraseResetStore.set([])} href="/setup/restore" variant="tertiary" text="Restore" diff --git a/web-wallet/src/routes/(welcome)/setup/restore/+page.svelte b/web-wallet/src/routes/(welcome)/setup/restore/+page.svelte index 56e62d220e..38eaeb31e0 100644 --- a/web-wallet/src/routes/(welcome)/setup/restore/+page.svelte +++ b/web-wallet/src/routes/(welcome)/setup/restore/+page.svelte @@ -8,7 +8,7 @@ import MnemonicAuthenticate from "./MnemonicAuthenticate.svelte"; import { Wizard, WizardStep } from "$lib/dusk/components"; import { ExistingWalletNotice } from "$lib/components"; - import { settingsStore } from "$lib/stores"; + import { mnemonicPhraseResetStore, settingsStore } from "$lib/stores"; import { initializeWallet, refreshLocalStoragePasswordInfo, @@ -34,7 +34,7 @@ let isValidMnemonic = false; /** @type {string[]} */ - let mnemonicPhrase = []; + let mnemonicPhrase = $mnemonicPhraseResetStore; const { userId } = $settingsStore;