From d5f48ba0961a70da0f831a5c0c32ac02564e5078 Mon Sep 17 00:00:00 2001 From: cpl121 Date: Tue, 27 Feb 2024 18:14:17 +0100 Subject: [PATCH] feat: display hint with ed25519 address when low mana generation in implicit account creation --- .../FundConfirmationView.svelte | 32 ++++++++++++++++--- .../events-handlers/handleNewOutputEvent.ts | 8 ++++- packages/shared/locales/en.json | 7 +++- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/packages/desktop/views/dashboard/wallet/views/implicit-account-creation-multistep/FundConfirmationView.svelte b/packages/desktop/views/dashboard/wallet/views/implicit-account-creation-multistep/FundConfirmationView.svelte index 7afb6fb988..82d1190052 100644 --- a/packages/desktop/views/dashboard/wallet/views/implicit-account-creation-multistep/FundConfirmationView.svelte +++ b/packages/desktop/views/dashboard/wallet/views/implicit-account-creation-multistep/FundConfirmationView.svelte @@ -5,11 +5,15 @@ import { implicitAccountCreationRouter } from '@core/router' import { IWalletState, formatTokenAmountBestMatch, selectedWallet, selectedWalletAssets } from '@core/wallet' import { OutputData } from '@iota/sdk' - import { Button, FontWeight, KeyValueBox, Text, TextType } from '@ui' + import { Button, FontWeight, KeyValueBox, Text, TextType, TextHint, TextHintVariant, CopyableBox } from '@ui' import { onDestroy, onMount } from 'svelte' export let outputId: string | undefined + // TODO: update when mana generation is available + const isLowManaGeneration = false + let walletAddress: string = '' + $: baseCoin = $selectedWalletAssets?.[$activeProfile?.network?.id]?.baseCoin $: selectedOutput = getSelectedOutput($selectedWallet, outputId) @@ -44,7 +48,7 @@ } function getImplicitAccountsMana(implicitAccountOutputs: OutputData[], excludeIds: string[] | undefined): number { - return implicitAccountOutputs.reduce((acc: number, outputData: OutputData) => { + return implicitAccountOutputs?.reduce((acc: number, outputData: OutputData) => { if (excludeIds && excludeIds.includes(outputData.outputId)) { const totalMana = getPassiveManaForOutput(outputData) return totalMana ? acc + totalMana : acc @@ -62,7 +66,8 @@ $: timeRemaining = `${seconds}s remaining` - onMount(() => { + onMount(async () => { + walletAddress = await $selectedWallet?.address() countdownInterval = setInterval(() => { seconds -= 1 @@ -77,14 +82,14 @@ clearInterval(countdownInterval) }) - const onTimeout = () => { + const onTimeout = (): void => { $implicitAccountCreationRouter.next() } // ---------------------------------------------------------------- -
+
+ {#if isLowManaGeneration} +
+ + + {walletAddress} + +
+ {/if}
diff --git a/packages/shared/lib/core/wallet/actions/events-handlers/handleNewOutputEvent.ts b/packages/shared/lib/core/wallet/actions/events-handlers/handleNewOutputEvent.ts index a2d00a8990..5cc9a2609a 100644 --- a/packages/shared/lib/core/wallet/actions/events-handlers/handleNewOutputEvent.ts +++ b/packages/shared/lib/core/wallet/actions/events-handlers/handleNewOutputEvent.ts @@ -49,7 +49,13 @@ export async function handleNewOutputEventInternal(walletId: string, payload: Ne const address = outputData.address ? getBech32AddressFromAddressTypes(outputData.address) : undefined - if ((address && wallet?.depositAddress === address && !outputData?.remainder) || isAccountOutput(outputData)) { + // The basic outputs of the faucet dont have an address + const isBasicOutput = output.type === OutputType.Basic + if ( + (address && wallet?.depositAddress === address && !outputData?.remainder) || + isAccountOutput(outputData) || + isBasicOutput + ) { await syncBalance(wallet.id, true) const walletOutputs = await wallet.outputs() const accountOutputs = await wallet.accounts() diff --git a/packages/shared/locales/en.json b/packages/shared/locales/en.json index aadf07342d..9a48995eee 100644 --- a/packages/shared/locales/en.json +++ b/packages/shared/locales/en.json @@ -669,7 +669,12 @@ "generatedMana": "Generated Mana:", "title": "Funds arrived:", "subtitle": "Generating mana...", - "action": "Activate Account" + "action": "Activate Account", + "walletAddress": { + "description": "Send funds to your wallet address to speed up the mana generation", + "show": "Show Address", + "copy": "Copy" + } } }, "step3": {