Updated on 2026-08-14

This commit is contained in:
Tangem 2023-12-08 18:05:57 +03:00
parent 1d0d2aab1c
commit d74f3191bb
7 changed files with 40 additions and 20 deletions

View file

@ -60,7 +60,7 @@ internal class SwapRepositoryImpl @Inject constructor(
override suspend fun getPairs(
initialCurrency: LeastTokenInfo,
currencyList: List<CryptoCurrency>,
): List<SwapPairLeast> {
): PairsWithProviders {
return withContext(coroutineDispatcher.io) {
val initial = NetworkLeastTokenInfo(
contractAddress = initialCurrency.contractAddress,

View file

@ -2,18 +2,20 @@ package com.tangem.feature.swap.converters
import com.tangem.datasource.api.express.models.response.*
import com.tangem.feature.swap.domain.models.domain.LeastTokenInfo
import com.tangem.feature.swap.domain.models.domain.PairsWithProviders
import com.tangem.feature.swap.domain.models.domain.SwapProvider
import com.tangem.utils.converter.Converter
import com.tangem.feature.swap.domain.models.domain.ExchangeProviderType as ExchangeProviderTypeDomain
import com.tangem.feature.swap.domain.models.domain.SwapPairLeast as SwapPairDomain
import com.tangem.feature.swap.domain.models.domain.SwapProvider as SwapPairProviderDomain
class SwapPairInfoConverter : Converter<SwapPairsWithProviders, List<SwapPairDomain>> {
class SwapPairInfoConverter : Converter<SwapPairsWithProviders, PairsWithProviders> {
private val rateTypeConverter = RateTypeConverter()
override fun convert(value: SwapPairsWithProviders): List<SwapPairDomain> {
override fun convert(value: SwapPairsWithProviders): PairsWithProviders {
val providersAdditionalMap = value.providers.associateBy { it.id }
return value.swapPair.map { pair ->
val pairs = value.swapPair.map { pair ->
SwapPairDomain(
from = LeastTokenInfo(
contractAddress = pair.from.contractAddress,
@ -28,6 +30,20 @@ class SwapPairInfoConverter : Converter<SwapPairsWithProviders, List<SwapPairDom
},
)
}
return PairsWithProviders(
pairs = pairs,
allProviders = value.providers.map { convertLeastProvider(it) },
)
}
private fun convertLeastProvider(exchangeProvider: ExchangeProvider): SwapProvider {
return SwapProvider(
providerId = exchangeProvider.id,
rateTypes = emptyList(),
name = exchangeProvider.name,
type = convertExchangeType(exchangeProvider.type),
imageLarge = exchangeProvider.imageLargeUrl,
)
}
private fun convertProvider(