From b0694b67985897caab7cd7873d7df88a6dcf7465 Mon Sep 17 00:00:00 2001 From: Tangem Date: Tue, 26 Nov 2024 14:54:02 +0300 Subject: [PATCH] Updated on 2026-08-14 --- .../models/response/ExpressErrorResponse.kt | 6 ++++++ core/res/src/main/res/values-de/strings.xml | 5 +++-- core/res/src/main/res/values-es/strings.xml | 2 -- core/res/src/main/res/values-fr/strings.xml | 4 +--- core/res/src/main/res/values-ja/strings.xml | 8 +++++--- core/res/src/main/res/values-ru/strings.xml | 4 +--- .../res/src/main/res/values-uk-rUA/strings.xml | 2 -- core/res/src/main/res/values/strings.xml | 8 +++++--- .../swap/converters/ErrorsDataConverter.kt | 17 +++++++++++++++++ .../swap/domain/models/ExpressDataError.kt | 7 +++++++ .../com/tangem/feature/swap/ui/StateBuilder.kt | 18 ++++++++++++++---- .../com/tangem/feature/swap/utils/SwapUtils.kt | 7 +++++++ 12 files changed, 66 insertions(+), 22 deletions(-) diff --git a/core/datasource/src/main/java/com/tangem/datasource/api/express/models/response/ExpressErrorResponse.kt b/core/datasource/src/main/java/com/tangem/datasource/api/express/models/response/ExpressErrorResponse.kt index d3e2fd0694..183965a431 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/api/express/models/response/ExpressErrorResponse.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/api/express/models/response/ExpressErrorResponse.kt @@ -37,4 +37,10 @@ data class ExpressErrorValue( @Json(name = "expressFromDecimals") val expressFromDecimals: Int?, + + @Json(name = "fromAmount") + val fromAmount: String?, + + @Json(name = "fromAmountProvider") + val fromAmountProvider: String?, ) \ No newline at end of file diff --git a/core/res/src/main/res/values-de/strings.xml b/core/res/src/main/res/values-de/strings.xml index 79686ce460..e278f45b3c 100644 --- a/core/res/src/main/res/values-de/strings.xml +++ b/core/res/src/main/res/values-de/strings.xml @@ -6,8 +6,6 @@ Token nicht in Deinem Portfolio gefunden? Überprüfe die Märkte, um es für Swaps zu finden und hinzuzufügen Es gibt keine verfügbaren Token, die mit dem ausgewählten Token getauscht werden können. Bitte wähle einen anderen. Kein verfügbares Paar - Du möchtest erhalten - Du möchtest tauschen Netzwerk wählen Token anlegen Token verwalten @@ -590,8 +588,11 @@ Einstellungen Du hast keinen Zugriff auf deine Kamera gewährt Kamerazugriff verweigert + Kein Memo erforderlich %1$s ( %2$s ) im %3$s Netzwerk + Das Senden einer anderen Währung führt zu deren irreversiblem Verlust. Sende nur %s an diese Adresse. Der Versand einer anderen Währung führt zu ihrem unwiderruflichen Verlust. + Sende nur %s an diese Adresse. Überweise Geld von einem anderen Wallet oder einer anderen Börse Teilnehmen Die Informationen zum Empfehlungsprogramm konnten nicht geladen werden. Bitte versuche es später noch einmal. diff --git a/core/res/src/main/res/values-es/strings.xml b/core/res/src/main/res/values-es/strings.xml index 38c53c5104..24e4fe0863 100644 --- a/core/res/src/main/res/values-es/strings.xml +++ b/core/res/src/main/res/values-es/strings.xml @@ -6,8 +6,6 @@ ¿No encuentras el token en tu billetera? Consulte los mercados para encontrarlo y agregarlo al intercambio No hay tokens disponibles para intercambiar con el token seleccionado. Por favor elige otro. No hay par disponible - Desea recibir - Quiere intercambiar Elige red Agregue un token personalizado Gestionar tokens diff --git a/core/res/src/main/res/values-fr/strings.xml b/core/res/src/main/res/values-fr/strings.xml index d2e529b9cb..2b0fc6e1be 100644 --- a/core/res/src/main/res/values-fr/strings.xml +++ b/core/res/src/main/res/values-fr/strings.xml @@ -6,8 +6,6 @@ Jeton non trouvé dans votre portefeuille ? Consultez les marchés pour le trouver et l\'ajouter à l\'échange Il n\'y a pas de token disponible pour échanger avec le token sélectionné. Veuillez en choisir un autre. Aucune paire disponible - Vous souhaitez recevoir - Vous souhaitez échanger Choisissez le réseau Ajouter un jeton personnalisé Gérer les jetons @@ -370,7 +368,7 @@ Choisissez un portefeuille Le portefeuille ne prend pas en charge plus d\'un réseau Pour acheter, échanger ou recevoir cet actif, ajoutez-le à votre portefeuille - Cet actif n\'est plus pris en charge dans le portefeuille + Cet actif n\'est pas pris en charge dans le portefeuille Cet actif n\'est pas disponible pour ce portefeuille Ajouter au portfolio Ajoutez un jeton diff --git a/core/res/src/main/res/values-ja/strings.xml b/core/res/src/main/res/values-ja/strings.xml index 9f3c536b40..b3c7c07c53 100644 --- a/core/res/src/main/res/values-ja/strings.xml +++ b/core/res/src/main/res/values-ja/strings.xml @@ -6,8 +6,6 @@ ポートフォリオにトークンが見つかりませんか?マーケットから見つけ、スワップのために追加してください 選択したトークンと交換できるトークンがありません。別のトークンを選択してください。 利用可能なペアがありません - 受け取りたい - 交換したい ネットワークを選択 カスタムトークンの追加 トークンの管理 @@ -123,7 +121,7 @@ マーケット 遅い 速度と料金 - アドレスを取得する + アドレスを同期する プロバイダーへ移動 トークンへ移動 時間 @@ -557,6 +555,7 @@ アクセスコードの復元 同一のカード アクセスコード + プロバイダーは取引を促進し、スムーズで効率的なトークン交換を保証します 国で検索 利用不可 通貨で検索 @@ -582,8 +581,11 @@ 設定 カメラへのアクセスを許可していません。 カメラへのアクセスが拒否されました + メモ不要 %3$sネットワーク上の%1$s ( %2$s ) + 他の暗号資産を送信すると、取り返しのつかない損失が発生します。 このアドレスには%sのみを送金してください。他のトークンを送信すると、取り返しのつかない損失が発生します。 + このアドレスには%sのみを送信してください。 ウォレットや取引所から資金を送金する 参加する 紹介プログラムに関する情報を読み込めませんでした。しばらくしてからもう一度お試しください。 diff --git a/core/res/src/main/res/values-ru/strings.xml b/core/res/src/main/res/values-ru/strings.xml index dfbc4e21cc..6e9a779cef 100644 --- a/core/res/src/main/res/values-ru/strings.xml +++ b/core/res/src/main/res/values-ru/strings.xml @@ -3,8 +3,6 @@ Выберите токен Нет доступных токенов для обмена с выбранным токеном, пожалуйста, выберите другой. Нет доступных пар - Вы хотите получить - Вы хотите обменять Выберите сеть Добавить токен Валюты @@ -129,7 +127,7 @@ По рынку Медленно Скорость и комиссия - Получить ваши адреса + Синхронизировать адреса К провайдеру Перейти в токен час diff --git a/core/res/src/main/res/values-uk-rUA/strings.xml b/core/res/src/main/res/values-uk-rUA/strings.xml index 25e1a4419d..0422f45055 100644 --- a/core/res/src/main/res/values-uk-rUA/strings.xml +++ b/core/res/src/main/res/values-uk-rUA/strings.xml @@ -6,8 +6,6 @@ Токен не знайдено у вашому портфелі? Перевірте ринки, щоб знайти та додати його для обміну Немає доступних токенів для обміну з обраним токеном. Будь ласка, оберіть інший. Немає вільної пари - Ви хочете отримати - Ви хочете обміняти Оберіть мережу Додати токен Токени diff --git a/core/res/src/main/res/values/strings.xml b/core/res/src/main/res/values/strings.xml index 4f1dea27fa..1f7c527b60 100644 --- a/core/res/src/main/res/values/strings.xml +++ b/core/res/src/main/res/values/strings.xml @@ -6,8 +6,8 @@ Token not found in your portfolio? Check the Markets to find and add it for swap There are no available tokens to swap with the selected token. Please choose another one. No available pair - You want to Receive - You want to Swap + Choose the Token you want to Receive + Choose the Token you want to Swap Choose network Add custom token Manage tokens @@ -126,7 +126,7 @@ Market Slow Speed and fee - Get your addresses + Synchronize addresses Go to provider Go to token hour @@ -251,6 +251,7 @@ Tangem offers token swaps via 3rd-party providers according to each provider\'s terms Choose provider An error occurred. Code: %s + Error %1$s. The selected provider cannot process the specified transaction. Please round the value up to %2$s or change it Selected provider is unavailable at the moment. Please try again later. (Code: %s) Swaps are unavailable at the moment. Please try again later. (Code: %s) Estimated amount @@ -565,6 +566,7 @@ Access code restore Identical cards Access code + Providers facilitate transactions, ensuring smooth and efficient token exchanges Search by country Unavailable Search by currency diff --git a/features/swap/data/src/main/java/com/tangem/feature/swap/converters/ErrorsDataConverter.kt b/features/swap/data/src/main/java/com/tangem/feature/swap/converters/ErrorsDataConverter.kt index 9fc5d1725d..71196ab9a7 100644 --- a/features/swap/data/src/main/java/com/tangem/feature/swap/converters/ErrorsDataConverter.kt +++ b/features/swap/data/src/main/java/com/tangem/feature/swap/converters/ErrorsDataConverter.kt @@ -30,6 +30,7 @@ internal class ErrorsDataConverter( 2270 -> ExpressDataError.ExchangeNotEnoughBalanceError(code = error.code) 2280 -> ExpressDataError.ExchangeInvalidAddressError(code = error.code) 2290 -> tryParseExchangeInvalidFromDecimalsError(error = error) + 2320 -> tryParseProviderDifferentAmountError(error = error) else -> ExpressDataError.UnknownErrorWithCode(error.code) } } catch (e: Exception) { @@ -79,4 +80,20 @@ internal class ErrorsDataConverter( expressFromDecimals = expressFromDecimals, ) } + + private fun tryParseProviderDifferentAmountError(error: ExpressError): ExpressDataError { + val decimals = error.value?.decimals ?: return ExpressDataError.UnknownErrorWithCode(error.code) + + val fromAmount = error.value?.fromAmount?.toBigDecimalOrNull() + ?: return ExpressDataError.UnknownErrorWithCode(error.code) + val fromAmountProvider = error.value?.fromAmountProvider?.toBigDecimalOrNull() + ?: return ExpressDataError.UnknownErrorWithCode(error.code) + + return ExpressDataError.ProviderDifferentAmountError( + code = error.code, + decimals = decimals, + fromAmount = fromAmount, + fromProviderAmount = fromAmountProvider, + ) + } } \ No newline at end of file diff --git a/features/swap/domain/models/src/main/java/com/tangem/feature/swap/domain/models/ExpressDataError.kt b/features/swap/domain/models/src/main/java/com/tangem/feature/swap/domain/models/ExpressDataError.kt index b2ac31292d..1446dd81b2 100644 --- a/features/swap/domain/models/src/main/java/com/tangem/feature/swap/domain/models/ExpressDataError.kt +++ b/features/swap/domain/models/src/main/java/com/tangem/feature/swap/domain/models/ExpressDataError.kt @@ -39,6 +39,13 @@ sealed class ExpressDataError { val expressFromDecimals: Int, ) : ExpressDataError() + data class ProviderDifferentAmountError( + override val code: Int, + val fromAmount: BigDecimal, + val fromProviderAmount: BigDecimal, + val decimals: Int, + ) : ExpressDataError() + data class UnknownErrorWithCode(override val code: Int) : ExpressDataError() data class InvalidSignatureError(override val code: Int = 990) : ExpressDataError() diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/StateBuilder.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/StateBuilder.kt index 3e33131d7d..519dd8d27f 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/StateBuilder.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/StateBuilder.kt @@ -10,10 +10,7 @@ import com.tangem.core.ui.components.notifications.NotificationConfig import com.tangem.core.ui.event.consumedEvent import com.tangem.core.ui.event.triggeredEvent import com.tangem.core.ui.extensions.* -import com.tangem.core.ui.format.bigdecimal.anyDecimals -import com.tangem.core.ui.format.bigdecimal.crypto -import com.tangem.core.ui.format.bigdecimal.format -import com.tangem.core.ui.format.bigdecimal.uncapped +import com.tangem.core.ui.format.bigdecimal.* import com.tangem.core.ui.utils.BigDecimalFormatter import com.tangem.core.ui.utils.parseBigDecimal import com.tangem.domain.appcurrency.model.AppCurrency @@ -777,6 +774,19 @@ internal class StateBuilder( iconResId = R.drawable.ic_alert_circle_24, ), ) + is ExpressDataError.ProviderDifferentAmountError -> SwapWarning.GeneralError( + notificationConfig = NotificationConfig( + title = resourceReference(id = R.string.common_error), + subtitle = resourceReference( + R.string.express_error_provider_amount_roundup, + formatArgs = wrappedList( + expressDataError.code, + expressDataError.fromProviderAmount.format { simple(decimals = expressDataError.decimals) }, + ), + ), + iconResId = R.drawable.ic_alert_circle_24, + ), + ) else -> SwapWarning.GeneralWarning( notificationConfig = NotificationConfig( title = providerErrorTitle, diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/utils/SwapUtils.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/utils/SwapUtils.kt index 44c918c906..a0ef72bd20 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/utils/SwapUtils.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/utils/SwapUtils.kt @@ -28,6 +28,13 @@ internal fun getExpressErrorMessage(expressDataError: ExpressDataError): TextRef id = R.string.express_error_swap_pair_unavailable, formatArgs = wrappedList(expressDataError.code), ) + is ExpressDataError.ProviderDifferentAmountError -> resourceReference( + R.string.express_error_provider_amount_roundup, + formatArgs = wrappedList( + expressDataError.code, + expressDataError.fromProviderAmount.format { simple(decimals = expressDataError.decimals) }, + ), + ) else -> resourceReference(R.string.express_error_code, wrappedList(expressDataError.code.toString())) } }