Skip to content

Commit

Permalink
Add seed check
Browse files Browse the repository at this point in the history
  • Loading branch information
Swepool committed Mar 17, 2024
1 parent c24206c commit 233d013
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 9 deletions.
25 changes: 23 additions & 2 deletions src/routes/auth/backup-wallet/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,25 @@
{ "word": "" }
];
function checkAllWords() {
return randomNumbersArray.every((num, i) => checkArray[i].word === seedWordsArray[num - 1]);
}
async function validateAndProceed() {
if (checkAllWords()) {
toast.success("Success!", {
position: "top-right",
style: "border-radius: 5px; background: var(--toast-bg-color); border: 1px solid var(--toast-b-color); color: var(--toast-text-color);"
});
await goto('/wallet/dashboard'); // Use await if goto returns a promise
} else {
toast.error("Some words are incorrect. Please check and try again.", {
position: "top-right",
style: "border-radius: 5px; background: var(--toast-bg-color); border: 1px solid var(--toast-b-color); color: var(--toast-text-color);"
});
}
}
onMount(async () => {
seedWords = await window.api.getSeed();
seedWordsArray = seedWords.split(" ");
Expand Down Expand Up @@ -83,9 +102,11 @@
bind:value={checkArray[i].word}>
</div>
{/each}
<div></div>
<button class="card" style="margin-top: 1rem" on:click={() => step--}>Back</button>
<button class="card" style="margin-top: 1rem" on:click={() => goto('/wallet/dashboard')}>Continue</button>
<div />
<button class="card" style="margin-top: 1rem" on:click={() => goto('/wallet/dashboard')}>Skip</button>
<button class="card" style="margin-top: 1rem" on:click={validateAndProceed}>Check
</button>
</div>
</section>
{/if}
Expand Down
29 changes: 22 additions & 7 deletions src/routes/auth/login-wallet/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
password = '';
loading = false;
//Set stored balance to avoid showing zero balance while loading
$wallet.balance = [localStorage.getItem('balance'), 0] ?? [0, 0];
$wallet.balance = [parseInt(localStorage.getItem('balance')), 0] ?? [0, 0];
$wallet.started = true;
});
});
Expand Down Expand Up @@ -106,7 +106,7 @@
<NodeSelector on:connect={(e) => handleNodeChange(e.detail.node)} />
{:else}
<div
style="display: flex; flex-direction: column; gap: 4rem; align-items: center"
style="display: flex; flex-direction: column; gap: 2rem; align-items: center"
in:fade={{ duration: 200, delay: 400, easing: quadIn }}
>
<div />
Expand All @@ -120,12 +120,14 @@
{/if}
</button>
</div>
<div>
<div class="info">
<div style="text-align: center">
<p>{$wallet.currentWallet}.wallet</p>
{#if !$wallet.started}
<p class="import" on:click={() => openFromFile()}>Open another wallet</p>
{/if}
</div>
<p style="opacity: 50%">v1.0.0</p>
<p>{$wallet.currentWallet}.wallet</p>
{#if !$wallet.started}
<p class="import" on:click={() => openFromFile()}>Open another wallet</p>
{/if}
<input
bind:this={fileList}
Expand Down Expand Up @@ -201,4 +203,17 @@
.open {
opacity: 0;
}
.info {
position: absolute;
bottom: 0;
display: flex;
flex-direction: column;
gap: 1rem;
align-items: center;
p{
margin: 0;
}
}
</style>

0 comments on commit 233d013

Please sign in to comment.