Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: display hint with ed25519 address when low mana generation in implicit account creation #8102

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -62,7 +66,8 @@

$: timeRemaining = `${seconds}s remaining`

onMount(() => {
onMount(async () => {
walletAddress = await $selectedWallet?.address()
countdownInterval = setInterval(() => {
seconds -= 1

Expand All @@ -77,14 +82,14 @@
clearInterval(countdownInterval)
})

const onTimeout = () => {
const onTimeout = (): void => {
$implicitAccountCreationRouter.next()
}
// ----------------------------------------------------------------
</script>

<step-content class="flex flex-col items-center justify-between h-full pt-20">
<div class="flex flex-col h-full justify-between space-y-8">
<div class="flex flex-col h-full justify-between space-y-8 items-center">
<div class="flex flex-col text-center space-y-4 max-w-md">
<div class="flex items-center justify-center mb-7">
<img
Expand Down Expand Up @@ -118,6 +123,23 @@
/>
</div>
</div>
{#if isLowManaGeneration}
<div class="flex flex-col space-y-4 w-2/3">
<TextHint
variant={TextHintVariant.Warning}
text={localize('views.implicit-account-creation.steps.step2.view.walletAddress.description')}
/>
<CopyableBox value={walletAddress} isCopyable>
<Text
type={TextType.pre}
fontSize="13"
fontWeight={FontWeight.medium}
color="gray-900"
darkColor="white">{walletAddress}</Text
>
</CopyableBox>
</div>
{/if}
<Button disabled>{localize('views.implicit-account-creation.steps.step2.view.action')}</Button>
</div>
</step-content>
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
7 changes: 6 additions & 1 deletion packages/shared/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
Loading