Updated on 2026-08-14

This commit is contained in:
Tangem 2025-05-29 17:08:18 +03:00
commit 1bac8466b1
990 changed files with 22183 additions and 7489 deletions

View file

@ -6,7 +6,7 @@ import com.tangem.core.ui.format.bigdecimal.crypto
import com.tangem.core.ui.format.bigdecimal.format
import com.tangem.core.ui.utils.BigDecimalFormatter
import com.tangem.domain.appcurrency.model.AppCurrency
import com.tangem.domain.tokens.model.CryptoCurrency
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
import com.tangem.feature.swap.domain.models.domain.CryptoCurrencySwapInfo
import com.tangem.feature.swap.models.CurrenciesGroupWithFromCurrency

View file

@ -28,16 +28,19 @@ import com.tangem.domain.feedback.SaveBlockchainErrorUseCase
import com.tangem.domain.feedback.SendFeedbackEmailUseCase
import com.tangem.domain.feedback.models.BlockchainErrorInfo
import com.tangem.domain.feedback.models.FeedbackEmailType
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.network.Network
import com.tangem.domain.promo.GetStoryContentUseCase
import com.tangem.domain.promo.ShouldShowStoriesUseCase
import com.tangem.domain.promo.models.StoryContentIds
import com.tangem.domain.settings.usercountry.GetUserCountryUseCase
import com.tangem.domain.settings.usercountry.models.UserCountry
import com.tangem.domain.settings.usercountry.models.needApplyFCARestrictions
import com.tangem.domain.tokens.*
import com.tangem.domain.tokens.model.CryptoCurrency
import com.tangem.domain.tokens.GetFeePaidCryptoCurrencyStatusSyncUseCase
import com.tangem.domain.tokens.GetMinimumTransactionAmountSyncUseCase
import com.tangem.domain.tokens.GetSingleCryptoCurrencyStatusUseCase
import com.tangem.domain.tokens.UpdateDelayedNetworkStatusUseCase
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
import com.tangem.domain.tokens.model.Network
import com.tangem.domain.txhistory.usecase.GetExplorerTransactionUrlUseCase
import com.tangem.domain.wallets.models.UserWallet
import com.tangem.domain.wallets.models.UserWalletId
@ -86,9 +89,8 @@ internal class SwapModel @Inject constructor(
private val analyticsEventHandler: AnalyticsEventHandler,
private val analyticsErrorEventHandler: AnalyticsErrorHandler,
private val getSelectedAppCurrencyUseCase: GetSelectedAppCurrencyUseCase,
private val getCryptoCurrencyStatusUseCase: GetCryptoCurrencyStatusSyncUseCase,
private val updateDelayedCurrencyStatusUseCase: UpdateDelayedNetworkStatusUseCase,
private val getCurrencyStatusUpdatesUseCase: GetCurrencyStatusUpdatesUseCase,
private val getSingleCryptoCurrencyStatusUseCase: GetSingleCryptoCurrencyStatusUseCase,
private val getFeePaidCryptoCurrencyStatusSyncUseCase: GetFeePaidCryptoCurrencyStatusSyncUseCase,
private val getUserWalletUseCase: GetUserWalletUseCase,
private val getCardInfoUseCase: GetCardInfoUseCase,
@ -98,7 +100,7 @@ internal class SwapModel @Inject constructor(
private val getExplorerTransactionUrlUseCase: GetExplorerTransactionUrlUseCase,
private val shouldShowStoriesUseCase: ShouldShowStoriesUseCase,
private val getStoryContentUseCase: GetStoryContentUseCase,
private val getUserCountryUseCase: GetUserCountryUseCase,
getUserCountryUseCase: GetUserCountryUseCase,
getBalanceHidingSettingsUseCase: GetBalanceHidingSettingsUseCase,
swapInteractorFactory: SwapInteractor.Factory,
private val urlOpener: UrlOpener,
@ -176,8 +178,12 @@ internal class SwapModel @Inject constructor(
}
modelScope.launch(dispatchers.io) {
val fromStatus = getCryptoCurrencyStatusUseCase(userWalletId, initialCurrencyFrom.id).getOrNull()
val toStatus = initialCurrencyTo?.let { getCryptoCurrencyStatusUseCase(userWalletId, it.id).getOrNull() }
val fromStatus =
getSingleCryptoCurrencyStatusUseCase.invokeMultiWalletSync(userWalletId, initialCurrencyFrom.id)
.getOrNull()
val toStatus = initialCurrencyTo?.let {
getSingleCryptoCurrencyStatusUseCase.invokeMultiWalletSync(userWalletId, it.id).getOrNull()
}
val wallet = getUserWalletUseCase(userWalletId).getOrNull()
if (fromStatus == null || wallet == null) {
@ -861,7 +867,7 @@ internal class SwapModel @Inject constructor(
) {
Timber.d("Subscribe to ${coin.id} balance updates")
getCurrencyStatusUpdatesUseCase(
getSingleCryptoCurrencyStatusUseCase.invokeMultiWallet(
userWalletId = userWalletId,
currencyId = coin.id,
isSingleWalletWithTokens = false,
@ -1311,7 +1317,6 @@ internal class SwapModel @Inject constructor(
userWalletId = userWalletId,
network = network,
delayMillis = UPDATE_BALANCE_DELAY_MILLIS,
refresh = true,
)
}
@ -1348,7 +1353,7 @@ internal class SwapModel @Inject constructor(
saveBlockchainErrorUseCase(
error = BlockchainErrorInfo(
errorMessage = errorMessage,
blockchainId = network.id.value,
blockchainId = network.rawId,
derivationPath = network.derivationPath.value,
destinationAddress = transaction?.txTo.orEmpty(),
tokenSymbol = fromCurrencyStatus.currency.symbol,
@ -1370,7 +1375,7 @@ internal class SwapModel @Inject constructor(
private fun CryptoCurrency.getNetworkInfo(): NetworkInfo {
return NetworkInfo(
name = this.network.name,
blockchainId = this.network.id.value,
blockchainId = this.network.rawId,
)
}

View file

@ -10,7 +10,7 @@ import com.tangem.core.ui.extensions.TextReference
import com.tangem.core.ui.format.bigdecimal.crypto
import com.tangem.core.ui.format.bigdecimal.format
import com.tangem.core.ui.utils.parseBigDecimal
import com.tangem.domain.tokens.model.CryptoCurrency
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
import com.tangem.feature.swap.domain.models.ExpressDataError
import com.tangem.feature.swap.domain.models.SwapAmount
@ -154,7 +154,7 @@ internal class SwapNotificationsFactory(
}
is TxFeeState.SingleFeeState -> feeState.fee
}
val isCardano = BlockchainUtils.isCardano(fromCurrencyStatus.currency.network.id.value)
val isCardano = BlockchainUtils.isCardano(fromCurrencyStatus.currency.network.rawId)
// blockchain specific
addExistentialWarningNotification(
@ -305,7 +305,7 @@ internal class SwapNotificationsFactory(
fromAmount: SwapAmount,
onReduceByAmount: (SwapAmount, BigDecimal) -> Unit,
) {
val isTezos = isTezos(cryptoCurrencyStatus.currency.network.id.value)
val isTezos = isTezos(cryptoCurrencyStatus.currency.network.rawId)
val balance = cryptoCurrencyStatus.value.amount ?: BigDecimal.ZERO
val threshold = getTezosThreshold()
val isTotalBalance = fromAmount.value >= balance && balance > threshold

View file

@ -1,6 +1,6 @@
package com.tangem.feature.swap.models
import com.tangem.domain.tokens.model.CryptoCurrency
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.feature.swap.domain.models.ui.CurrenciesGroup
data class CurrenciesGroupWithFromCurrency(

View file

@ -1,7 +1,7 @@
package com.tangem.feature.swap.models
import com.tangem.common.ui.bottomsheet.permission.state.ApproveType
import com.tangem.domain.tokens.model.CryptoCurrency
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.feature.swap.domain.models.SwapAmount
import com.tangem.feature.swap.domain.models.ui.TxFee
import java.math.BigDecimal

View file

@ -7,7 +7,7 @@ import com.tangem.core.ui.extensions.TextReference
import com.tangem.core.ui.extensions.networkIconResId
import com.tangem.core.ui.extensions.resourceReference
import com.tangem.core.ui.extensions.wrappedList
import com.tangem.domain.tokens.model.CryptoCurrency
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.feature.swap.domain.models.ExpressDataError
import com.tangem.feature.swap.utils.getExpressErrorMessage
import com.tangem.feature.swap.utils.getExpressErrorTitle

View file

@ -5,7 +5,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import com.tangem.common.routing.AppRoute
import com.tangem.common.routing.AppRouter
import com.tangem.domain.tokens.model.CryptoCurrency
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.wallets.models.UserWalletId
internal class SwapRouter(

View file

@ -17,8 +17,8 @@ import com.tangem.core.ui.format.bigdecimal.format
import com.tangem.core.ui.utils.BigDecimalFormatter
import com.tangem.core.ui.utils.parseBigDecimal
import com.tangem.domain.appcurrency.model.AppCurrency
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.promo.models.StoryContent
import com.tangem.domain.tokens.model.CryptoCurrency
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
import com.tangem.feature.swap.converters.SwapTransactionErrorStateConverter
import com.tangem.feature.swap.converters.TokensDataConverter
@ -93,7 +93,7 @@ internal class StateBuilder(
canSelectAnotherToken = false,
isNotNativeToken = initialCurrencyFrom is CryptoCurrency.Token,
balance = "",
networkIconRes = getActiveIconRes(initialCurrencyFrom.network.id.value),
networkIconRes = getActiveIconRes(initialCurrencyFrom.network.rawId),
isBalanceHidden = true,
),
receiveCardData = SwapCardState.SwapCardData(
@ -106,7 +106,7 @@ internal class StateBuilder(
canSelectAnotherToken = false,
balance = "",
isNotNativeToken = initialCurrencyTo is CryptoCurrency.Token,
networkIconRes = initialCurrencyTo?.let { getActiveIconRes(it.network.id.value) },
networkIconRes = initialCurrencyTo?.let { getActiveIconRes(it.network.rawId) },
coinId = initialCurrencyTo?.network?.backendId,
isBalanceHidden = true,
),
@ -153,7 +153,7 @@ internal class StateBuilder(
tokenCurrency = uiStateHolder.sendCardData.tokenCurrency,
canSelectAnotherToken = uiStateHolder.sendCardData.canSelectAnotherToken,
balance = fromToken.getFormattedAmount(isNeedSymbol = false),
networkIconRes = getActiveIconRes(fromToken.currency.network.id.value),
networkIconRes = getActiveIconRes(fromToken.currency.network.rawId),
isBalanceHidden = isBalanceHiddenProvider(),
),
receiveCardData = SwapCardState.Empty(
@ -206,7 +206,7 @@ internal class StateBuilder(
isNotNativeToken = fromToken is CryptoCurrency.Token,
canSelectAnotherToken = canSelectSendToken,
balance = if (!canSelectSendToken) uiStateHolder.sendCardData.balance else "",
networkIconRes = getActiveIconRes(fromToken.network.id.value),
networkIconRes = getActiveIconRes(fromToken.network.rawId),
isBalanceHidden = isBalanceHiddenProvider(),
),
receiveCardData = SwapCardState.SwapCardData(
@ -220,7 +220,7 @@ internal class StateBuilder(
isNotNativeToken = toToken is CryptoCurrency.Token,
canSelectAnotherToken = canSelectReceiveToken,
balance = if (!canSelectReceiveToken) uiStateHolder.receiveCardData.balance else "",
networkIconRes = getActiveIconRes(toToken.network.id.value),
networkIconRes = getActiveIconRes(toToken.network.rawId),
isBalanceHidden = isBalanceHiddenProvider(),
),
notifications = persistentListOf(),