-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
web-wallet: Show current block height on Wallet Creation
- Loading branch information
1 parent
9f44c59
commit 6b020c5
Showing
8 changed files
with
116 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
web-wallet/src/lib/dusk/components/CopyField/CopyField.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<script> | ||
import { mdiContentCopy } from "@mdi/js"; | ||
import { Button, Textbox } from "$lib/dusk/components"; | ||
import { toast } from "$lib/dusk/components/Toast/store"; | ||
/** @type {string} */ | ||
export let name; | ||
/** @type {string} */ | ||
export let displayValue; | ||
/** @type {string} */ | ||
export let rawValue; | ||
function copyToClipboard() { | ||
navigator.clipboard.writeText(rawValue); | ||
toast("success", `${name} copied`, mdiContentCopy); | ||
} | ||
</script> | ||
|
||
<div class="copy-field"> | ||
<Textbox | ||
className="copy-field__content" | ||
value={displayValue} | ||
type="text" | ||
readOnly | ||
/> | ||
<Button | ||
aria-label="Copy Address" | ||
className="copy-field__button" | ||
icon={{ path: mdiContentCopy }} | ||
on:click={copyToClipboard} | ||
variant="primary" | ||
/> | ||
</div> | ||
|
||
<style lang="postcss"> | ||
.copy-field { | ||
display: flex; | ||
align-items: center; | ||
gap: 1em; | ||
} | ||
:global { | ||
.copy-field__content { | ||
flex: 1; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Creates a locale aware number formatter | ||
* | ||
* @param {String} locale A BCP 47 language tag | ||
* @param {Number|Undefined} digits The minimum fraction digits that should display | ||
* @returns {(value: number | bigint) => string} | ||
*/ | ||
const createNumberFormatter = (locale, digits = undefined) => { | ||
const formatter = new Intl.NumberFormat(locale, { | ||
style: "decimal", | ||
maximumFractionDigits: digits, | ||
}); | ||
|
||
return (value) => formatter.format(value); | ||
}; | ||
|
||
export default createNumberFormatter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as createNumberFormatter } from "./createNumberFormatter"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
web-wallet/src/routes/(welcome)/setup/create/NetworkSync.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<script> | ||
import { AppAnchor } from "$lib/components"; | ||
import { Card, CopyField } from "$lib/dusk/components"; | ||
import { createNumberFormatter } from "$lib/dusk/number"; | ||
import { settingsStore, walletStore } from "$lib/stores"; | ||
$: ({ language } = $settingsStore); | ||
$: currentBlock = 0; | ||
walletStore.getCurrentBlockHeight().then((block) => { | ||
currentBlock = block; | ||
}); | ||
const numberFormatter = createNumberFormatter(language); | ||
</script> | ||
|
||
<Card heading="Current Block Height"> | ||
<p> | ||
Store the current block height in case you want to resync from it next time | ||
you reset your wallet. This can significantly reduce the sync time. | ||
</p> | ||
|
||
<CopyField | ||
name="Block Height" | ||
displayValue={numberFormatter(currentBlock)} | ||
rawValue={String(currentBlock)} | ||
></CopyField> | ||
|
||
<small> | ||
This can later be retrieved from Settings. Find out more in our <AppAnchor | ||
href="#" | ||
rel="noopener noreferrer" | ||
target="_blank">docs</AppAnchor | ||
>. | ||
</small> | ||
</Card> |