Updated on 2026-08-14

This commit is contained in:
Tangem 2026-07-21 12:37:44 +04:00
parent 64b094c8e7
commit e6faa0a588
5 changed files with 123 additions and 1 deletions

View file

@ -842,7 +842,8 @@ internal class SwapModel @Inject constructor(
fromTokenAmount: String,
) {
val feePaidCryptoCurrency = dataState.feePaidCryptoCurrency
val selectedFee = getSelectedSwapFee()?.fee
val selectedSwapFee = getSelectedSwapFee()
val selectedFee = selectedSwapFee?.fee
val swapState = swapTransferInteractor.updateTransfer(
fromSwapCurrencyStatus = fromSwapCurrencyStatus,
toSwapCurrencyStatus = toSwapCurrencyStatus,
@ -864,6 +865,7 @@ internal class SwapModel @Inject constructor(
uiStateHolder = uiState,
feePaidCryptoCurrencyStatus = feePaidCryptoCurrency,
feeSelectorUM = feeSelectorRepository.state.value,
isHighNetworkFee = isHighNetworkFee(selectedSwapFee),
)
when {
uiState.successState != null -> Unit
@ -912,6 +914,7 @@ internal class SwapModel @Inject constructor(
fee = fee,
isTangemPayWithdrawal = isTangemPayWithdrawal(),
feeSelectorUM = feeSelectorRepository.state.value,
isHighNetworkFee = isHighNetworkFee(getSelectedSwapFee()),
)
}
}

View file

@ -40,6 +40,7 @@ internal class SwapTransferNotificationsFactory @Inject constructor() {
feeSelectorUM: FeeSelectorUM?,
feeCryptoCurrencyStatus: CryptoCurrencyStatus?,
actions: UiActions,
isHighNetworkFee: Boolean = false,
): ImmutableList<NotificationUM> {
// The fee selector exposes a single sealed state; narrow it here so call sites pass the raw
// FeeSelectorUM and this factory owns the Content/Error/Loading discrimination.
@ -71,9 +72,16 @@ internal class SwapTransferNotificationsFactory @Inject constructor() {
feeError = getFeeError,
actions = actions,
)
maybeAddHighNetworkFeeWarning(isHighNetworkFee)
}.toPersistentList()
}
private fun MutableList<NotificationUM>.maybeAddHighNetworkFeeWarning(isHighNetworkFee: Boolean) {
if (isHighNetworkFee) {
add(NotificationUM.Warning.HighNetworkFee)
}
}
private fun MutableList<NotificationUM>.maybeAddDomainWarnings(
state: SwapState.Transfer,
feeCryptoCurrencyStatus: CryptoCurrencyStatus?,

View file

@ -60,6 +60,7 @@ internal class SwapTransferStateBuilder @Inject constructor(
uiStateHolder: SwapStateHolder,
feePaidCryptoCurrencyStatus: CryptoCurrencyStatus?,
feeSelectorUM: FeeSelectorUM?,
isHighNetworkFee: Boolean = false,
): SwapStateHolder {
val fromTokenSwapInfo = transferState.fromTokenInfo
val isInsufficientBalance = transferState.isInsufficientBalance
@ -70,6 +71,7 @@ internal class SwapTransferStateBuilder @Inject constructor(
feeSelectorUM = feeSelectorUM,
feeCryptoCurrencyStatus = feePaidCryptoCurrencyStatus,
actions = actions,
isHighNetworkFee = isHighNetworkFee,
)
return uiStateHolder.copy(
sendCardData = createSendSwapCardState(
@ -343,12 +345,14 @@ internal class SwapTransferStateBuilder @Inject constructor(
fee: Fee?,
isTangemPayWithdrawal: Boolean,
feeSelectorUM: FeeSelectorUM?,
isHighNetworkFee: Boolean = false,
): SwapStateHolder {
val notifications = notificationsFactory.getNotifications(
transferState = transferState,
feeCryptoCurrencyStatus = feePaidCryptoCurrencyStatus,
feeSelectorUM = feeSelectorUM,
actions = actions,
isHighNetworkFee = isHighNetworkFee,
)
return uiStateHolder.copy(
notifications = notifications,