diff --git a/packages/mobile/components/inputs/RecipientInput.svelte b/packages/mobile/components/inputs/RecipientInput.svelte index f6354b3e74f..a88dfb93f86 100644 --- a/packages/mobile/components/inputs/RecipientInput.svelte +++ b/packages/mobile/components/inputs/RecipientInput.svelte @@ -3,17 +3,18 @@ import { networkHrp } from '@core/network/stores' import { BECH32_ADDRESS_LENGTH } from '@core/utils/constants' import { validateBech32Address } from '@core/utils/crypto' - import { IAddressSubject } from '@core/wallet/interfaces' + import { IAccountSubject, IAddressSubject } from '@core/wallet/interfaces' - export let recipient: IAddressSubject + export let recipient: IAddressSubject | IAccountSubject export let disabled: boolean = false export let error: string = undefined + export let inputElement: HTMLInputElement = undefined let addressPrefix: string let value: string $: addressPrefix = $networkHrp - $: value = recipient?.address ?? '' + $: value = recipient?.type === 'address' ? recipient?.address ?? '' : recipient?.account?.name ?? '' $: value, validateValue() function onInputChange(e: Event): void { @@ -23,19 +24,26 @@ function validateValue(): void { error = null - if (!value?.length) { - error = localize('general.enterAddress') - } else if (value?.length !== BECH32_ADDRESS_LENGTH + addressPrefix.length) { - error = localize('error.send.addressLength', { - values: { - length: BECH32_ADDRESS_LENGTH + addressPrefix.length, - }, - }) - } else { - try { - validateBech32Address(addressPrefix, value) - } catch (err) { - error = err?.message ?? err + if (recipient?.type === 'address') { + localize('error.send.recipientRequired') + if (!value?.length) { + error = localize('general.enterAddress') + } else if (value?.length !== BECH32_ADDRESS_LENGTH + addressPrefix.length) { + error = localize('error.send.addressLength', { + values: { + length: BECH32_ADDRESS_LENGTH + addressPrefix.length, + }, + }) + } else { + try { + validateBech32Address(addressPrefix, value) + } catch (err) { + error = err?.message ?? err + } + } + } else if (recipient?.type === 'account') { + if (!recipient?.account?.depositAddress?.length) { + error = localize('error.send.recipientRequired') } } } @@ -46,6 +54,7 @@ { if ($newTransactionDetails?.type === NewTransactionType.TokenTransfer) { @@ -98,7 +101,7 @@ return } amount = asset?.balance.available.toString() ?? '0' - unit = undefined + unit = asset?.metadata?.unit } function onContinueClick(): void { @@ -112,23 +115,26 @@
{unit}
-{unit}
+