Updated on 2026-08-14

This commit is contained in:
Tangem 2023-02-07 10:56:56 +03:00
parent e4e6499d4d
commit e5876470de
4 changed files with 11 additions and 10 deletions

View file

@ -144,7 +144,7 @@ class SingleWalletView : WalletView() {
WalletAction.DialogAction.ChooseTradeActionDialog(
buyAllowed = walletData.isAvailableToBuy(exchangeManager),
sellAllowed = walletData.isAvailableToSell(exchangeManager),
swapAllowed = false, //always disable for single wallet
swapAllowed = false, // always disable for single wallet
),
)
}

View file

@ -102,7 +102,6 @@ class UserWalletManagerImpl(
}
val mainStore = requireNotNull(appStateHolder.mainStore) { "mainStore is null" }
mainStore.dispatchOnMain(action)
mainStore.dispatchOnMain(WalletAction.LoadData.Refresh)
}
override fun getWalletAddress(networkId: String): String {

View file

@ -51,7 +51,7 @@ class OneInchApisModule {
}
companion object {
private const val ONE_INCH_BASE_URL = "https://api.1inch.io/v5.0/"
private const val ONE_INCH_BASE_URL = "https://api-tangem.1inch.io/v5.0/"
private const val ONE_INCH_ETH_PATH = "1/"
private const val ONE_INCH_BSC_PATH = "56/"
private const val ONE_INCH_POLYGON_PATH = "137/"

View file

@ -9,16 +9,18 @@ package com.tangem.core.ui.utils
* result string 123.46377372
*/
fun getValidatedNumberWithFixedDecimals(text: String, decimals: Int): String {
val filteredChars = text.replace(",", ".").filterIndexed { index, c ->
val isOneOrZeroPoint = c == '.' && index != 0 && text.count { it == '.' } <= 1
val isIndexPointIndex = c == '.' && index != 0 && text.indexOf('.') == index
val comma = ','
val dot = ','
val filteredChars = text.replace(comma, dot).filterIndexed { index, c ->
val isOneOrZeroPoint = c == dot && index != 0 && text.count { it == dot } <= 1
val isIndexPointIndex = c == dot && index != 0 && text.indexOf(dot) == index
c.isDigit() || isIndexPointIndex || isOneOrZeroPoint
}
// If dot is present, take first 3 digits before decimal and first decimals digits after decimal
return if (filteredChars.count { it == '.' } == 1) {
val beforeDecimal = filteredChars.substringBefore('.')
val afterDecimal = filteredChars.substringAfter('.')
beforeDecimal + "." + afterDecimal.take(decimals)
return if (filteredChars.count { it == dot } == 1) {
val beforeDecimal = filteredChars.substringBefore(dot)
val afterDecimal = filteredChars.substringAfter(dot)
beforeDecimal + dot + afterDecimal.take(decimals)
}
// If there is no dot, just take all digits
else {