Updated on 2026-08-14

This commit is contained in:
Tangem 2026-02-24 18:24:23 +04:00
parent 319fd373b5
commit 80c1b5ba20

View file

@ -510,14 +510,7 @@ internal class SwapModel @Inject constructor(
dataState.fromCryptoCurrency
}
fromCryptoCurrency?.let { cryptoCurrency ->
dataState = dataState.copy(
feePaidCryptoCurrency = getFeePaidCryptoCurrencyStatusSyncUseCase(
userWalletId = userWalletId,
cryptoCurrencyStatus = cryptoCurrency,
).getOrNull(),
)
}
if (fromCryptoCurrency != null) updateFeePaidCryptoCurrencyFor(fromCryptoCurrency)
subscribeToCoinBalanceUpdatesIfNeeded()
}.onFailure { error ->
@ -754,6 +747,15 @@ internal class SwapModel @Inject constructor(
}
}
private suspend fun updateFeePaidCryptoCurrencyFor(fromToken: CryptoCurrencyStatus) {
dataState = dataState.copy(
feePaidCryptoCurrency = getFeePaidCryptoCurrencyStatusSyncUseCase(
userWalletId = userWalletId,
cryptoCurrencyStatus = fromToken,
).getOrNull(),
)
}
private fun loadQuotesTask(
fromToken: CryptoCurrencyStatus,
fromAccount: Account.CryptoPortfolio?,
@ -1402,6 +1404,9 @@ internal class SwapModel @Inject constructor(
toAccount = toAccount,
selectedProvider = null,
)
modelScope.launch {
updateFeePaidCryptoCurrencyFor(fromToken)
}
startLoadingQuotes(
fromToken = fromToken,
fromAccount = fromAccount,
@ -1544,6 +1549,7 @@ internal class SwapModel @Inject constructor(
toAccount = newToAccount,
)
isOrderReversed = !isOrderReversed
updateFeePaidCryptoCurrencyFor(newFromToken)
dataState.tokensDataState?.let { tokensDataState ->
updateTokensState(tokensDataState)
}