Updated on 2026-08-14
This commit is contained in:
parent
8a3d05eac7
commit
b9ce4eeefc
14 changed files with 184 additions and 10 deletions
|
|
@ -80,6 +80,7 @@ dependencies {
|
|||
implementation(projects.domain.qrScanning)
|
||||
implementation(projects.domain.qrScanning.models)
|
||||
implementation(projects.domain.settings)
|
||||
implementation(projects.domain.notifications)
|
||||
|
||||
/** Feature modules */
|
||||
implementation(projects.features.send.api)
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ 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.notifications.GetTronFeeNotificationShowCountUseCase
|
||||
import com.tangem.domain.notifications.IncrementNotificationsShowCountUseCase
|
||||
import com.tangem.domain.qrscanning.models.SourceType
|
||||
import com.tangem.domain.qrscanning.usecases.ListenToQrScanningUseCase
|
||||
import com.tangem.domain.qrscanning.usecases.ParseQrCodeUseCase
|
||||
|
|
@ -115,6 +117,7 @@ internal class SendModel @Inject constructor(
|
|||
private val shareManager: ShareManager,
|
||||
private val txHistoryFeatureToggles: TxHistoryFeatureToggles,
|
||||
private val txHistoryContentUpdateEmitter: TxHistoryContentUpdateEmitter,
|
||||
private val incrementNotificationsShowCountUseCase: IncrementNotificationsShowCountUseCase,
|
||||
@DelayedWork private val coroutineScope: CoroutineScope,
|
||||
private val innerRouter: InnerSendRouter,
|
||||
appRouter: AppRouter,
|
||||
|
|
@ -123,6 +126,7 @@ internal class SendModel @Inject constructor(
|
|||
getCurrencyCheckUseCase: GetCurrencyCheckUseCase,
|
||||
isFeeApproximateUseCase: IsFeeApproximateUseCase,
|
||||
getBalanceNotEnoughForFeeWarningUseCase: GetBalanceNotEnoughForFeeWarningUseCase,
|
||||
getTronFeeNotificationShowCountUseCase: GetTronFeeNotificationShowCountUseCase,
|
||||
) : Model(), SendClickIntents {
|
||||
|
||||
private val params = paramsContainer.require<SendComponent.Params>()
|
||||
|
|
@ -195,6 +199,7 @@ internal class SendModel @Inject constructor(
|
|||
validateTransactionUseCase = validateTransactionUseCase,
|
||||
getCurrencyCheckUseCase = getCurrencyCheckUseCase,
|
||||
getBalanceNotEnoughForFeeWarningUseCase = getBalanceNotEnoughForFeeWarningUseCase,
|
||||
getTronFeeNotificationShowCountUseCase = getTronFeeNotificationShowCountUseCase,
|
||||
cryptoCurrencyStatusProvider = Provider { cryptoCurrencyStatus },
|
||||
feeCryptoCurrencyStatusProvider = Provider { feeCryptoCurrencyStatus },
|
||||
currentStateProvider = Provider { uiState.value },
|
||||
|
|
@ -528,16 +533,29 @@ internal class SendModel @Inject constructor(
|
|||
|
||||
uiState.value = stateFactory.syncEditStates(isFromEdit = isFromEdit)
|
||||
sendScreenAnalyticSender.send(currentState.type, uiState.value)
|
||||
when (currentState.type) {
|
||||
prepareNextState(currentState.type, isFromEdit)
|
||||
stateRouter.onNextClick()
|
||||
}
|
||||
|
||||
private fun prepareNextState(currentStateType: SendUiStateType, isFromEdit: Boolean) {
|
||||
when (currentStateType) {
|
||||
SendUiStateType.Fee,
|
||||
SendUiStateType.EditFee,
|
||||
-> if (onFeeNextIntercept(isFromEdit)) return
|
||||
SendUiStateType.Amount,
|
||||
SendUiStateType.Amount -> {
|
||||
loadFee()
|
||||
incrementNotificationsShowCounter()
|
||||
}
|
||||
SendUiStateType.EditAmount,
|
||||
-> loadFee()
|
||||
else -> Unit
|
||||
}
|
||||
stateRouter.onNextClick()
|
||||
}
|
||||
|
||||
private fun incrementNotificationsShowCounter() {
|
||||
modelScope.launch {
|
||||
incrementNotificationsShowCountUseCase(cryptoCurrency)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAmountNext() = onNextClick(stateRouter.isEditState)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.tangem.features.send.impl.presentation.state.confirm
|
|||
|
||||
import com.tangem.blockchain.common.transaction.Fee
|
||||
import com.tangem.blockchain.common.transaction.TransactionFee
|
||||
import com.tangem.common.ui.R
|
||||
import com.tangem.common.ui.amountScreen.models.AmountState
|
||||
import com.tangem.common.ui.notifications.NotificationUM
|
||||
import com.tangem.common.ui.notifications.NotificationsFactory.addDustWarningNotification
|
||||
|
|
@ -16,10 +17,13 @@ import com.tangem.common.ui.notifications.NotificationsFactory.addReserveAmountE
|
|||
import com.tangem.common.ui.notifications.NotificationsFactory.addTransactionLimitErrorNotification
|
||||
import com.tangem.common.ui.notifications.NotificationsFactory.addValidateTransactionNotifications
|
||||
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
import com.tangem.core.ui.utils.parseToBigDecimal
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.notifications.GetTronFeeNotificationShowCountUseCase
|
||||
import com.tangem.domain.tokens.GetBalanceNotEnoughForFeeWarningUseCase
|
||||
import com.tangem.domain.tokens.GetCurrencyCheckUseCase
|
||||
import com.tangem.domain.tokens.model.CryptoCurrency
|
||||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
import com.tangem.domain.tokens.model.warnings.CryptoCurrencyCheck
|
||||
import com.tangem.domain.transaction.error.GetFeeError
|
||||
|
|
@ -36,6 +40,7 @@ import com.tangem.features.send.impl.presentation.state.fee.*
|
|||
import com.tangem.lib.crypto.BlockchainUtils
|
||||
import com.tangem.lib.crypto.BlockchainUtils.getTezosThreshold
|
||||
import com.tangem.lib.crypto.BlockchainUtils.isTezos
|
||||
import com.tangem.lib.crypto.BlockchainUtils.isTron
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.extensions.orZero
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
|
|
@ -52,6 +57,7 @@ internal class SendNotificationFactory(
|
|||
private val validateTransactionUseCase: ValidateTransactionUseCase,
|
||||
private val getCurrencyCheckUseCase: GetCurrencyCheckUseCase,
|
||||
private val getBalanceNotEnoughForFeeWarningUseCase: GetBalanceNotEnoughForFeeWarningUseCase,
|
||||
private val getTronFeeNotificationShowCountUseCase: GetTronFeeNotificationShowCountUseCase,
|
||||
private val cryptoCurrencyStatusProvider: Provider<CryptoCurrencyStatus>,
|
||||
private val feeCryptoCurrencyStatusProvider: Provider<CryptoCurrencyStatus?>,
|
||||
private val currentStateProvider: Provider<SendUiState>,
|
||||
|
|
@ -125,9 +131,14 @@ internal class SendNotificationFactory(
|
|||
isFeeCoverage = isFeeCoverage,
|
||||
currencyCheck = currencyCheck,
|
||||
)
|
||||
addInfoNotifications()
|
||||
}.toImmutableList()
|
||||
}
|
||||
|
||||
private suspend fun MutableList<NotificationUM>.addInfoNotifications() {
|
||||
addTronNetworkFeesNotification()
|
||||
}
|
||||
|
||||
fun dismissNotificationState(clazz: Class<out NotificationUM>, isIgnored: Boolean = false): SendUiState {
|
||||
val state = currentStateProvider()
|
||||
val sendState = state.sendState ?: return state
|
||||
|
|
@ -341,4 +352,23 @@ internal class SendNotificationFactory(
|
|||
add(NotificationUM.Warning.TooHigh(diff))
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun MutableList<NotificationUM>.addTronNetworkFeesNotification() {
|
||||
val cryptoCurrency = cryptoCurrencyStatusProvider().currency
|
||||
val isTronToken = cryptoCurrency is CryptoCurrency.Token &&
|
||||
isTron(cryptoCurrency.network.id.value)
|
||||
|
||||
if (isTronToken && getTronFeeNotificationShowCountUseCase() <= TRON_FEE_NOTIFICATION_MAX_SHOW_COUNT) {
|
||||
add(
|
||||
NotificationUM.Info(
|
||||
title = resourceReference(R.string.tron_will_be_send_token_fee_title),
|
||||
subtitle = resourceReference(R.string.tron_will_be_send_token_fee_description),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TRON_FEE_NOTIFICATION_MAX_SHOW_COUNT = 3
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue