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

fix-mobile: max balance set undefined unit, and unit change validation #5521

Merged
merged 3 commits into from
Dec 31, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/mobile/components/inputs/RecipientInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
export let recipient: IAddressSubject
export let disabled: boolean = false
export let error: string = undefined
export let inputElement: HTMLInputElement = undefined

let addressPrefix: string
let value: string
Expand Down Expand Up @@ -46,6 +47,7 @@
<input
type="text"
{value}
bind:this={inputElement}
on:input={onInputChange}
class="w-full bg-white dark:bg-gray-800 text-gray-800 dark:text-white"
{disabled}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
}

$: bigAmount = convertToRawAmount(amount, unit, asset?.metadata)
$: amount, validate()
$: (amount, unit), validate()

onMount(() => {
if ($newTransactionDetails?.type === NewTransactionType.TokenTransfer) {
Expand Down Expand Up @@ -98,7 +98,7 @@
return
}
amount = asset?.balance.available.toString() ?? '0'
unit = undefined
unit = asset?.metadata?.unit
}

function onContinueClick(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@

let recipient: IAddressSubject
let recipientValidationError: string
let recipientInputElement: HTMLInputElement

onMount(() => {
recipientInputElement?.focus()
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
recipient = $newTransactionDetails?.recipient
Expand All @@ -23,7 +25,7 @@
</script>

<div class="w-full overflow-y-auto flex flex-col flex-auto h-1 justify-between">
<RecipientInput bind:recipient bind:error={recipientValidationError} />
<RecipientInput bind:recipient bind:error={recipientValidationError} bind:inputElement={recipientInputElement} />
<Button disabled={!!recipientValidationError} outline classes="w-full" onClick={onContinueClick}>
{recipientValidationError ?? localize('actions.continue')}
</Button>
Expand Down