Updated on 2026-08-14
This commit is contained in:
parent
1e19ce06b8
commit
3416b28b13
3 changed files with 19 additions and 7 deletions
|
|
@ -4,7 +4,6 @@ import com.tangem.blockchain.common.Blockchain
|
|||
import com.tangem.blockchain.common.IconsUtil
|
||||
import com.tangem.datasource.api.tangemTech.models.UserTokensResponse
|
||||
import com.tangem.domain.common.extensions.toCoinId
|
||||
import com.tangem.domain.common.extensions.toNetworkId
|
||||
import com.tangem.domain.tokens.model.CryptoCurrency
|
||||
import com.tangem.domain.tokens.model.CryptoCurrency.ID
|
||||
import com.tangem.domain.tokens.model.Network
|
||||
|
|
@ -55,8 +54,7 @@ internal fun getTokenIconUrl(blockchain: Blockchain, token: SdkToken): String? {
|
|||
internal fun getCoinIconUrl(blockchain: Blockchain): String? {
|
||||
val coinId = when (blockchain) {
|
||||
Blockchain.Unknown -> null
|
||||
Blockchain.TerraV1, Blockchain.TerraV2, Blockchain.Near -> blockchain.toCoinId()
|
||||
else -> blockchain.toNetworkId()
|
||||
else -> blockchain.toCoinId()
|
||||
}
|
||||
|
||||
return coinId?.let(::getTokenIconUrlFromDefaultHost)
|
||||
|
|
|
|||
|
|
@ -785,9 +785,14 @@ internal class SwapInteractorImpl @Inject constructor(
|
|||
userWalletId = userWalletId,
|
||||
cryptoCurrency = fromToken.currency,
|
||||
).firstOrNull()
|
||||
txFeeResult?.getOrNull()?.let { txFee ->
|
||||
return txFee.toTxFeeState(networkId)
|
||||
}
|
||||
return txFeeResult?.fold(
|
||||
ifLeft = {
|
||||
TxFeeState.Empty
|
||||
},
|
||||
ifRight = { txFee ->
|
||||
txFee.toTxFeeState(networkId)
|
||||
}
|
||||
) ?: TxFeeState.Empty
|
||||
}
|
||||
return TxFeeState.Empty
|
||||
}
|
||||
|
|
|
|||
|
|
@ -295,7 +295,7 @@ internal class SwapViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
private fun updateLoadedQuotes(state: Map<SwapProvider, SwapState>): Pair<SwapProvider, SwapState> {
|
||||
val selectedSwapProvider = dataState.selectedProvider ?: state.keys.first()
|
||||
val selectedSwapProvider = selectProvider(state)
|
||||
dataState = dataState.copy(
|
||||
selectedProvider = selectedSwapProvider,
|
||||
lastLoadedSwapStates = state,
|
||||
|
|
@ -303,6 +303,15 @@ internal class SwapViewModel @Inject constructor(
|
|||
return state.entries.first { it.key == selectedSwapProvider }.toPair()
|
||||
}
|
||||
|
||||
private fun selectProvider(state: Map<SwapProvider, SwapState>): SwapProvider {
|
||||
val currentSelected = dataState.selectedProvider
|
||||
return if (currentSelected != null && state.keys.contains(currentSelected)) {
|
||||
currentSelected
|
||||
} else {
|
||||
state.keys.first()
|
||||
}
|
||||
}
|
||||
|
||||
private fun fillLoadedDataState(
|
||||
state: SwapState.QuotesLoadedState,
|
||||
permissionState: PermissionDataState,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue