diff --git a/i18n/locales/en/payment.json b/i18n/locales/en/payment.json index 155c2a7c..79dc1d0b 100644 --- a/i18n/locales/en/payment.json +++ b/i18n/locales/en/payment.json @@ -38,6 +38,7 @@ "not-enough-funds": "Not enough funds.", "invalid-destination": "Expected a public key or stellar address.", "invalid-price": "Invalid amount.", - "integer-memo-required": "Memo must be an integer." + "integer-memo-required": "Memo must be an integer.", + "asset-missing": "No asset selected." } } diff --git a/i18n/locales/es/payment.json b/i18n/locales/es/payment.json index 471e3d99..93842e10 100644 --- a/i18n/locales/es/payment.json +++ b/i18n/locales/es/payment.json @@ -35,6 +35,7 @@ "not-enough-funds": "Fondos insuficientes.", "invalid-destination": "Se esperaba una llave pública o una dirección Stellar.", "invalid-price": "Monto no válido.", - "integer-memo-required": "El Memo debe ser un número entero" + "integer-memo-required": "El Memo debe ser un número entero", + "asset-missing": "Ningún activo seleccionado." } } diff --git a/i18n/locales/it/payment.json b/i18n/locales/it/payment.json index 7a91e060..2e1f3432 100755 --- a/i18n/locales/it/payment.json +++ b/i18n/locales/it/payment.json @@ -35,6 +35,7 @@ "not-enough-funds": "Fondi insufficienti.", "invalid-destination": "Attesa una chiave pubblica o un indirizzo stellare.", "invalid-price": "Importo non valido.", - "integer-memo-required": "Il memo deve essere un numero intero." + "integer-memo-required": "Il memo deve essere un numero intero.", + "asset-missing": "Nessuna risorsa selezionata." } } diff --git a/i18n/locales/ru/payment.json b/i18n/locales/ru/payment.json index 5d027e08..06354855 100644 --- a/i18n/locales/ru/payment.json +++ b/i18n/locales/ru/payment.json @@ -38,6 +38,7 @@ "not-enough-funds": "Недостаточно средств.", "invalid-destination": "Ожидается публичный ключ или stellar адрес.", "invalid-price": "Неверная сумма.", - "integer-memo-required": "Заметка должна быть числом." + "integer-memo-required": "Заметка должна быть числом.", + "asset-missing": "Не выбран актив." } } diff --git a/src/Generic/lib/stellar.ts b/src/Generic/lib/stellar.ts index 685c14d9..17d3ffbf 100644 --- a/src/Generic/lib/stellar.ts +++ b/src/Generic/lib/stellar.ts @@ -122,7 +122,8 @@ export function getAssetsFromBalances(balances: BalanceLine[]) { ) } -export function findMatchingBalanceLine(balances: AccountData["balances"], asset: Asset): BalanceLine | undefined { +export function findMatchingBalanceLine(balances: AccountData["balances"], asset?: Asset): BalanceLine | undefined { + if (!asset) return undefined return balances.find((balance): balance is BalanceLine => balancelineToAsset(balance).equals(asset)) } diff --git a/src/Payment/components/PaymentForm.tsx b/src/Payment/components/PaymentForm.tsx index 252ce2fd..f74f2aee 100644 --- a/src/Payment/components/PaymentForm.tsx +++ b/src/Payment/components/PaymentForm.tsx @@ -80,7 +80,7 @@ const PaymentForm = React.memo(function PaymentForm(props: PaymentFormProps) { const form = useForm({ defaultValues: { amount: "", - asset: Asset.native(), + asset: undefined, destination: "", memoValue: "" } @@ -216,6 +216,9 @@ const PaymentForm = React.memo(function PaymentForm(props: PaymentFormProps) { inputRef={form.register({ required: t("payment.validation.no-price"), validate: value => { + if (!form.getValues()["asset"]) { + return t("payment.validation.asset-missing") + } if (!isValidAmount(value) || FormBigNumber(value).eq(0)) { return t("payment.validation.invalid-price") } else if (FormBigNumber(value).gt(spendableBalance)) {