Updated on 2026-08-14

This commit is contained in:
Tangem 2023-11-14 12:35:45 +03:00
parent ff2da3ec3e
commit 42cb399a12
3 changed files with 18 additions and 2 deletions

View file

@ -17,6 +17,12 @@ class DefaultMarketCryptoCurrencyRepository(
return userMarketCoinsStore.getSyncOrNull(userWalletId)?.coins
?.firstOrNull { it.id == cryptoCurrencyId.rawCurrencyId }
?.networks
?.firstOrNull { it.networkId == apiNetworkId }?.exchangeable ?: false
?.firstOrNull {
if (it.contractAddress != null) {
it.networkId == apiNetworkId && it.contractAddress == cryptoCurrencyId.contractAddress
} else {
it.networkId == apiNetworkId
}
}?.exchangeable ?: false
}
}

View file

@ -94,6 +94,8 @@ sealed class CryptoCurrency : Parcelable {
/** Represents a raw cryptocurrency ID. If it is a custom token, the value will be `null`. */
val rawCurrencyId: String? get() = (suffix as? Suffix.RawID)?.rawId
val contractAddress: String? get() = (suffix as? Suffix.RawID)?.contractAddress
/** Represents a raw cryptocurrency's network ID. */
val rawNetworkId: String
get() = when (body) {

View file

@ -23,6 +23,7 @@ import timber.log.Timber
import java.math.BigDecimal
import java.math.RoundingMode
import javax.inject.Inject
import com.tangem.lib.crypto.models.Currency as LibCurrency
@Suppress("LargeClass", "LongParameterList")
internal class SwapInteractorImpl @Inject constructor(
@ -70,7 +71,14 @@ internal class SwapInteractorImpl @Inject constructor(
isExcludeCustom = true,
)
.map { token ->
allLoadedTokens.firstOrNull { it.symbol == token.symbol }?.let {
val contractAddress = (token as? LibCurrency.NonNativeToken)?.contractAddress
allLoadedTokens.firstOrNull {
if (it is Currency.NonNativeToken) {
it.symbol == token.symbol && it.contractAddress == contractAddress
} else {
it.symbol == token.symbol
}
}?.let {
loadedOnWalletsMap.add(it.symbol)
it
} ?: swapCurrencyConverter.convertBack(token)