Updated on 2026-08-14

This commit is contained in:
Tangem 2023-12-07 17:02:28 +03:00
parent 6303e0b5af
commit e2c5c7ec75
4 changed files with 20 additions and 12 deletions

View file

@ -2,6 +2,7 @@ package com.tangem.datasource.di
import android.content.Context
import com.squareup.moshi.Moshi
import com.tangem.datasource.BuildConfig
import com.tangem.datasource.api.common.response.ApiResponseCallAdapterFactory
import com.tangem.datasource.api.express.TangemExpressApi
import com.tangem.datasource.api.promotion.PromotionApi
@ -33,10 +34,15 @@ class NetworkModule {
@ApplicationContext context: Context,
expressAuthProvider: ExpressAuthProvider,
): TangemExpressApi {
val url = if (BuildConfig.ENVIRONMENT == "dev") {
DEV_EXPRESS_BASE_URL
} else {
PROD_EXPRESS_BASE_URL
}
return Retrofit.Builder()
.addConverterFactory(MoshiConverterFactory.create(moshi))
.addCallAdapterFactory(ApiResponseCallAdapterFactory.create())
.baseUrl(DEV_EXPRESS_BASE_URL)
.baseUrl(url)
.client(
OkHttpClient.Builder()
.addHeaders(Express(expressAuthProvider))

View file

@ -37,6 +37,6 @@
},
{
"name": "WALLETS_SCROLLING_PREVIEW_ENABLED",
"version": "5.4.0"
"version": "undefined"
}
]

View file

@ -74,10 +74,13 @@ internal class SwapInteractorImpl @Inject constructor(
val walletCurrencyStatuses = getMultiCryptoCurrencyStatusUseCase(selectedWallet.walletId)
.getOrElse { emptyList() }
val walletCurrencyStatusesExceptInitial = walletCurrencyStatuses.filter {
it.currency.network.backendId != currency.network.backendId ||
it.currency.getContractAddress() != currency.getContractAddress()
}
val walletCurrencyStatusesExceptInitial = walletCurrencyStatuses
.filter {
val currencyFilter = it.currency.network.backendId != currency.network.backendId ||
it.currency.getContractAddress() != currency.getContractAddress()
val statusFilter = it.value is CryptoCurrencyStatus.Loaded
statusFilter && currencyFilter
}
if (walletCurrencyStatusesExceptInitial.isEmpty()) {
return TokensDataStateExpress(
@ -128,10 +131,10 @@ internal class SwapInteractorImpl @Inject constructor(
tokenInfoForFilter(it).network == currency.network.backendId
}
val availableCryptoCurrencies = cryptoCurrenciesList.mapNotNull { pair ->
val providers = findProvidersForPair(pair, filteredPairs, tokenInfoForAvailable)
val availableCryptoCurrencies = cryptoCurrenciesList.mapNotNull { cryptoCurrencyStatus ->
val providers = findProvidersForPair(cryptoCurrencyStatus, filteredPairs, tokenInfoForAvailable)
if (providers != null) {
CryptoCurrencySwapInfo(pair, providers)
CryptoCurrencySwapInfo(cryptoCurrencyStatus, providers)
} else {
null
}

View file

@ -878,9 +878,8 @@ internal class SwapViewModel @Inject constructor(
if (it.key != bestRateEntry.key) {
val amount = it.value.toTokenInfo.tokenAmount.value
val percentDiff = BigDecimal.ONE.minus(
amount.divide(bestRate, RoundingMode.HALF_UP)
.multiply(hundredPercent),
)
amount.divide(bestRate, RoundingMode.HALF_UP),
).multiply(hundredPercent)
percentDiff.setScale(2, RoundingMode.HALF_UP).toFloat().absoluteValue
} else {
null