Updated on 2026-08-14
This commit is contained in:
parent
8a3d05eac7
commit
b9ce4eeefc
14 changed files with 184 additions and 10 deletions
|
|
@ -156,6 +156,7 @@ dependencies {
|
||||||
implementation(projects.data.networks)
|
implementation(projects.data.networks)
|
||||||
implementation(projects.data.quotes)
|
implementation(projects.data.quotes)
|
||||||
implementation(projects.data.blockaid)
|
implementation(projects.data.blockaid)
|
||||||
|
implementation(projects.data.notifications)
|
||||||
|
|
||||||
/** Features */
|
/** Features */
|
||||||
implementation(projects.features.referral.impl)
|
implementation(projects.features.referral.impl)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
package com.tangem.tap.di.domain
|
package com.tangem.tap.di.domain
|
||||||
|
|
||||||
import com.tangem.domain.notifications.GetApplicationIdUseCase
|
import com.tangem.domain.notifications.GetApplicationIdUseCase
|
||||||
|
import com.tangem.domain.notifications.GetTronFeeNotificationShowCountUseCase
|
||||||
|
import com.tangem.domain.notifications.IncrementNotificationsShowCountUseCase
|
||||||
import com.tangem.domain.notifications.SendPushTokenUseCase
|
import com.tangem.domain.notifications.SendPushTokenUseCase
|
||||||
import com.tangem.domain.notifications.repository.NotificationsRepository
|
import com.tangem.domain.notifications.repository.NotificationsRepository
|
||||||
import com.tangem.utils.notifications.PushNotificationsTokenProvider
|
import com.tangem.utils.notifications.PushNotificationsTokenProvider
|
||||||
|
|
@ -16,10 +18,11 @@ internal object NotificationsDomainModule {
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
fun providesGetApplicationIdUseCase(notificationsRepository: NotificationsRepository): GetApplicationIdUseCase =
|
fun providesGetApplicationIdUseCase(notificationsRepository: NotificationsRepository): GetApplicationIdUseCase {
|
||||||
GetApplicationIdUseCase(
|
return GetApplicationIdUseCase(
|
||||||
notificationsRepository = notificationsRepository,
|
notificationsRepository = notificationsRepository,
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
|
|
@ -27,9 +30,31 @@ internal object NotificationsDomainModule {
|
||||||
notificationsRepository: NotificationsRepository,
|
notificationsRepository: NotificationsRepository,
|
||||||
getApplicationIdUseCase: GetApplicationIdUseCase,
|
getApplicationIdUseCase: GetApplicationIdUseCase,
|
||||||
pushNotificationsTokenProvider: PushNotificationsTokenProvider,
|
pushNotificationsTokenProvider: PushNotificationsTokenProvider,
|
||||||
): SendPushTokenUseCase = SendPushTokenUseCase(
|
): SendPushTokenUseCase {
|
||||||
notificationsRepository = notificationsRepository,
|
return SendPushTokenUseCase(
|
||||||
getApplicationIdUseCase = getApplicationIdUseCase,
|
notificationsRepository = notificationsRepository,
|
||||||
pushNotificationsTokenProvider = pushNotificationsTokenProvider,
|
getApplicationIdUseCase = getApplicationIdUseCase,
|
||||||
)
|
pushNotificationsTokenProvider = pushNotificationsTokenProvider,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun providesGetTronFeeNotificationShowCountUseCase(
|
||||||
|
notificationsRepository: NotificationsRepository,
|
||||||
|
): GetTronFeeNotificationShowCountUseCase {
|
||||||
|
return GetTronFeeNotificationShowCountUseCase(
|
||||||
|
notificationsRepository = notificationsRepository,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun providesIncrementTronFeeNotificationShowCountUseCase(
|
||||||
|
notificationsRepository: NotificationsRepository,
|
||||||
|
): IncrementNotificationsShowCountUseCase {
|
||||||
|
return IncrementNotificationsShowCountUseCase(
|
||||||
|
notificationsRepository = notificationsRepository,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4,6 +4,7 @@ import com.tangem.blockchain.common.BlockchainSdkError
|
||||||
import com.tangem.common.ui.R
|
import com.tangem.common.ui.R
|
||||||
import com.tangem.common.ui.amountScreen.models.AmountFieldModel
|
import com.tangem.common.ui.amountScreen.models.AmountFieldModel
|
||||||
import com.tangem.common.ui.amountScreen.utils.getFiatString
|
import com.tangem.common.ui.amountScreen.utils.getFiatString
|
||||||
|
import com.tangem.common.ui.notifications.NotificationUM.Warning
|
||||||
import com.tangem.core.ui.extensions.networkIconResId
|
import com.tangem.core.ui.extensions.networkIconResId
|
||||||
import com.tangem.core.ui.format.bigdecimal.crypto
|
import com.tangem.core.ui.format.bigdecimal.crypto
|
||||||
import com.tangem.core.ui.format.bigdecimal.format
|
import com.tangem.core.ui.format.bigdecimal.format
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,10 @@ object PreferencesKeys {
|
||||||
val NOTIFICATIONS_APPLICATION_ID_KEY by lazy { stringPreferencesKey(name = "notificationsApplicationId") }
|
val NOTIFICATIONS_APPLICATION_ID_KEY by lazy { stringPreferencesKey(name = "notificationsApplicationId") }
|
||||||
|
|
||||||
val NOTIFICATIONS_ENABLED_STATES_KEY by lazy { stringPreferencesKey(name = "notificationsEnabledStates") }
|
val NOTIFICATIONS_ENABLED_STATES_KEY by lazy { stringPreferencesKey(name = "notificationsEnabledStates") }
|
||||||
|
|
||||||
|
val TRON_NETWORK_FEE_NOTIFICATION_SHOW_COUNT_KEY by lazy {
|
||||||
|
intPreferencesKey(name = "tronNetworkFeeNotificationShowCount")
|
||||||
|
}
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
// region Promo
|
// region Promo
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,23 @@ internal class DefaultNotificationsRepository @Inject constructor(
|
||||||
return appPreferencesStore.getSyncOrNull(PreferencesKeys.NOTIFICATIONS_APPLICATION_ID_KEY)
|
return appPreferencesStore.getSyncOrNull(PreferencesKeys.NOTIFICATIONS_APPLICATION_ID_KEY)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override suspend fun incrementTronTokenFeeNotificationShowCounter() {
|
||||||
|
appPreferencesStore.editData { preferences ->
|
||||||
|
val count = preferences.getOrDefault(
|
||||||
|
key = PreferencesKeys.TRON_NETWORK_FEE_NOTIFICATION_SHOW_COUNT_KEY,
|
||||||
|
default = 0,
|
||||||
|
)
|
||||||
|
preferences[PreferencesKeys.TRON_NETWORK_FEE_NOTIFICATION_SHOW_COUNT_KEY] = count + 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun getTronTokenFeeNotificationShowCounter(): Int {
|
||||||
|
return appPreferencesStore.getSyncOrDefault(
|
||||||
|
key = PreferencesKeys.TRON_NETWORK_FEE_NOTIFICATION_SHOW_COUNT_KEY,
|
||||||
|
default = 0,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
override suspend fun associateApplicationIdWithWallets(appId: String, wallets: List<String>) =
|
override suspend fun associateApplicationIdWithWallets(appId: String, wallets: List<String>) =
|
||||||
withContext(dispatchers.io) {
|
withContext(dispatchers.io) {
|
||||||
tangemTechApi.associateApplicationIdWithWallets(
|
tangemTechApi.associateApplicationIdWithWallets(
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,10 @@ dependencies {
|
||||||
implementation(projects.core.utils)
|
implementation(projects.core.utils)
|
||||||
implementation(projects.domain.core)
|
implementation(projects.domain.core)
|
||||||
implementation(projects.domain.wallets.models)
|
implementation(projects.domain.wallets.models)
|
||||||
|
implementation(projects.domain.tokens.models)
|
||||||
implementation(projects.domain.notifications.models)
|
implementation(projects.domain.notifications.models)
|
||||||
implementation(projects.domain.wallets)
|
implementation(projects.domain.wallets)
|
||||||
|
implementation(projects.libs.crypto)
|
||||||
|
|
||||||
// region DI
|
// region DI
|
||||||
implementation(deps.hilt.android)
|
implementation(deps.hilt.android)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.tangem.domain.notifications
|
||||||
|
|
||||||
|
import com.tangem.domain.notifications.repository.NotificationsRepository
|
||||||
|
|
||||||
|
class GetTronFeeNotificationShowCountUseCase(
|
||||||
|
private val notificationsRepository: NotificationsRepository,
|
||||||
|
) {
|
||||||
|
|
||||||
|
suspend operator fun invoke(): Int {
|
||||||
|
return notificationsRepository.getTronTokenFeeNotificationShowCounter()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.tangem.domain.notifications
|
||||||
|
|
||||||
|
import com.tangem.domain.notifications.repository.NotificationsRepository
|
||||||
|
import com.tangem.domain.tokens.model.CryptoCurrency
|
||||||
|
import com.tangem.lib.crypto.BlockchainUtils.isTron
|
||||||
|
|
||||||
|
class IncrementNotificationsShowCountUseCase(
|
||||||
|
private val notificationsRepository: NotificationsRepository,
|
||||||
|
) {
|
||||||
|
|
||||||
|
suspend operator fun invoke(cryptoCurrency: CryptoCurrency) {
|
||||||
|
val isTronToken = cryptoCurrency is CryptoCurrency.Token &&
|
||||||
|
isTron(cryptoCurrency.network.id.value)
|
||||||
|
|
||||||
|
if (isTronToken) {
|
||||||
|
notificationsRepository.incrementTronTokenFeeNotificationShowCounter()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -11,6 +11,10 @@ interface NotificationsRepository {
|
||||||
|
|
||||||
suspend fun getApplicationId(): String?
|
suspend fun getApplicationId(): String?
|
||||||
|
|
||||||
|
suspend fun getTronTokenFeeNotificationShowCounter(): Int
|
||||||
|
|
||||||
|
suspend fun incrementTronTokenFeeNotificationShowCounter()
|
||||||
|
|
||||||
@Throws
|
@Throws
|
||||||
suspend fun associateApplicationIdWithWallets(appId: String, wallets: List<String>)
|
suspend fun associateApplicationIdWithWallets(appId: String, wallets: List<String>)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,8 @@ dependencies {
|
||||||
implementation(projects.domain.balanceHiding.models)
|
implementation(projects.domain.balanceHiding.models)
|
||||||
implementation(projects.domain.balanceHiding)
|
implementation(projects.domain.balanceHiding)
|
||||||
implementation(projects.domain.nft.models)
|
implementation(projects.domain.nft.models)
|
||||||
|
implementation(projects.domain.notifications)
|
||||||
|
|
||||||
|
|
||||||
/** Compose libraries */
|
/** Compose libraries */
|
||||||
implementation(deps.compose.foundation)
|
implementation(deps.compose.foundation)
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import arrow.core.getOrElse
|
||||||
import com.tangem.blockchain.common.transaction.Fee
|
import com.tangem.blockchain.common.transaction.Fee
|
||||||
import com.tangem.common.routing.AppRoute
|
import com.tangem.common.routing.AppRoute
|
||||||
import com.tangem.common.routing.AppRouter
|
import com.tangem.common.routing.AppRouter
|
||||||
|
import com.tangem.common.ui.R
|
||||||
import com.tangem.common.ui.amountScreen.converters.AmountReduceByTransformer.ReduceByData
|
import com.tangem.common.ui.amountScreen.converters.AmountReduceByTransformer.ReduceByData
|
||||||
import com.tangem.common.ui.notifications.NotificationUM
|
import com.tangem.common.ui.notifications.NotificationUM
|
||||||
import com.tangem.common.ui.notifications.NotificationsFactory.addDustWarningNotification
|
import com.tangem.common.ui.notifications.NotificationsFactory.addDustWarningNotification
|
||||||
|
|
@ -23,6 +24,9 @@ import com.tangem.core.analytics.api.AnalyticsEventHandler
|
||||||
import com.tangem.core.decompose.di.ModelScoped
|
import com.tangem.core.decompose.di.ModelScoped
|
||||||
import com.tangem.core.decompose.model.Model
|
import com.tangem.core.decompose.model.Model
|
||||||
import com.tangem.core.decompose.model.ParamsContainer
|
import com.tangem.core.decompose.model.ParamsContainer
|
||||||
|
import com.tangem.core.ui.extensions.resourceReference
|
||||||
|
import com.tangem.domain.notifications.GetTronFeeNotificationShowCountUseCase
|
||||||
|
import com.tangem.domain.notifications.IncrementNotificationsShowCountUseCase
|
||||||
import com.tangem.domain.tokens.GetBalanceNotEnoughForFeeWarningUseCase
|
import com.tangem.domain.tokens.GetBalanceNotEnoughForFeeWarningUseCase
|
||||||
import com.tangem.domain.tokens.GetCurrencyCheckUseCase
|
import com.tangem.domain.tokens.GetCurrencyCheckUseCase
|
||||||
import com.tangem.domain.tokens.IsAmountSubtractAvailableUseCase
|
import com.tangem.domain.tokens.IsAmountSubtractAvailableUseCase
|
||||||
|
|
@ -40,6 +44,7 @@ import com.tangem.features.send.v2.subcomponents.notifications.NotificationsComp
|
||||||
import com.tangem.features.send.v2.subcomponents.notifications.NotificationsUpdateTrigger
|
import com.tangem.features.send.v2.subcomponents.notifications.NotificationsUpdateTrigger
|
||||||
import com.tangem.features.send.v2.subcomponents.notifications.analytics.NotificationsAnalyticEvents
|
import com.tangem.features.send.v2.subcomponents.notifications.analytics.NotificationsAnalyticEvents
|
||||||
import com.tangem.lib.crypto.BlockchainUtils
|
import com.tangem.lib.crypto.BlockchainUtils
|
||||||
|
import com.tangem.lib.crypto.BlockchainUtils.isTron
|
||||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||||
import com.tangem.utils.extensions.orZero
|
import com.tangem.utils.extensions.orZero
|
||||||
import kotlinx.collections.immutable.ImmutableList
|
import kotlinx.collections.immutable.ImmutableList
|
||||||
|
|
@ -64,6 +69,8 @@ internal class NotificationsModel @Inject constructor(
|
||||||
private val getCurrencyCheckUseCase: GetCurrencyCheckUseCase,
|
private val getCurrencyCheckUseCase: GetCurrencyCheckUseCase,
|
||||||
private val getBalanceNotEnoughForFeeWarningUseCase: GetBalanceNotEnoughForFeeWarningUseCase,
|
private val getBalanceNotEnoughForFeeWarningUseCase: GetBalanceNotEnoughForFeeWarningUseCase,
|
||||||
private val validateTransactionUseCase: ValidateTransactionUseCase,
|
private val validateTransactionUseCase: ValidateTransactionUseCase,
|
||||||
|
private val getTronFeeNotificationShowCountUseCase: GetTronFeeNotificationShowCountUseCase,
|
||||||
|
private val incrementNotificationsShowCountUseCase: IncrementNotificationsShowCountUseCase,
|
||||||
private val sendFeeReloadTrigger: SendFeeReloadTrigger,
|
private val sendFeeReloadTrigger: SendFeeReloadTrigger,
|
||||||
private val sendAmountReduceTrigger: SendAmountReduceTrigger,
|
private val sendAmountReduceTrigger: SendAmountReduceTrigger,
|
||||||
private val notificationsUpdateTrigger: NotificationsUpdateTrigger,
|
private val notificationsUpdateTrigger: NotificationsUpdateTrigger,
|
||||||
|
|
@ -89,6 +96,7 @@ internal class NotificationsModel @Inject constructor(
|
||||||
init {
|
init {
|
||||||
subscribeToNotificationUpdateTrigger()
|
subscribeToNotificationUpdateTrigger()
|
||||||
checkIfSubtractAvailable()
|
checkIfSubtractAvailable()
|
||||||
|
incrementNotificationsShowCount()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun subscribeToNotificationUpdateTrigger() {
|
private fun subscribeToNotificationUpdateTrigger() {
|
||||||
|
|
@ -104,6 +112,12 @@ internal class NotificationsModel @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun incrementNotificationsShowCount() {
|
||||||
|
modelScope.launch {
|
||||||
|
incrementNotificationsShowCountUseCase(cryptoCurrencyStatus.currency)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private suspend fun updateState(data: NotificationData) {
|
private suspend fun updateState(data: NotificationData) {
|
||||||
notificationData = data
|
notificationData = data
|
||||||
buildNotifications()
|
buildNotifications()
|
||||||
|
|
@ -193,6 +207,7 @@ internal class NotificationsModel @Inject constructor(
|
||||||
isFeeCoverage = isFeeCoverage,
|
isFeeCoverage = isFeeCoverage,
|
||||||
currencyCheck = currencyCheck,
|
currencyCheck = currencyCheck,
|
||||||
)
|
)
|
||||||
|
addInfoNotifications()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getFeeCurrencyBalanceAfterTx(sendingAmount: BigDecimal, feeValue: BigDecimal): BigDecimal? {
|
private fun getFeeCurrencyBalanceAfterTx(sendingAmount: BigDecimal, feeValue: BigDecimal): BigDecimal? {
|
||||||
|
|
@ -352,4 +367,27 @@ internal class NotificationsModel @Inject constructor(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private suspend fun MutableList<NotificationUM>.addInfoNotifications() {
|
||||||
|
addTronNetworkFeesNotification()
|
||||||
|
}
|
||||||
|
|
||||||
|
private suspend fun MutableList<NotificationUM>.addTronNetworkFeesNotification() {
|
||||||
|
val cryptoCurrency = cryptoCurrencyStatus.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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -80,6 +80,7 @@ dependencies {
|
||||||
implementation(projects.domain.qrScanning)
|
implementation(projects.domain.qrScanning)
|
||||||
implementation(projects.domain.qrScanning.models)
|
implementation(projects.domain.qrScanning.models)
|
||||||
implementation(projects.domain.settings)
|
implementation(projects.domain.settings)
|
||||||
|
implementation(projects.domain.notifications)
|
||||||
|
|
||||||
/** Feature modules */
|
/** Feature modules */
|
||||||
implementation(projects.features.send.api)
|
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.SendFeedbackEmailUseCase
|
||||||
import com.tangem.domain.feedback.models.BlockchainErrorInfo
|
import com.tangem.domain.feedback.models.BlockchainErrorInfo
|
||||||
import com.tangem.domain.feedback.models.FeedbackEmailType
|
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.models.SourceType
|
||||||
import com.tangem.domain.qrscanning.usecases.ListenToQrScanningUseCase
|
import com.tangem.domain.qrscanning.usecases.ListenToQrScanningUseCase
|
||||||
import com.tangem.domain.qrscanning.usecases.ParseQrCodeUseCase
|
import com.tangem.domain.qrscanning.usecases.ParseQrCodeUseCase
|
||||||
|
|
@ -115,6 +117,7 @@ internal class SendModel @Inject constructor(
|
||||||
private val shareManager: ShareManager,
|
private val shareManager: ShareManager,
|
||||||
private val txHistoryFeatureToggles: TxHistoryFeatureToggles,
|
private val txHistoryFeatureToggles: TxHistoryFeatureToggles,
|
||||||
private val txHistoryContentUpdateEmitter: TxHistoryContentUpdateEmitter,
|
private val txHistoryContentUpdateEmitter: TxHistoryContentUpdateEmitter,
|
||||||
|
private val incrementNotificationsShowCountUseCase: IncrementNotificationsShowCountUseCase,
|
||||||
@DelayedWork private val coroutineScope: CoroutineScope,
|
@DelayedWork private val coroutineScope: CoroutineScope,
|
||||||
private val innerRouter: InnerSendRouter,
|
private val innerRouter: InnerSendRouter,
|
||||||
appRouter: AppRouter,
|
appRouter: AppRouter,
|
||||||
|
|
@ -123,6 +126,7 @@ internal class SendModel @Inject constructor(
|
||||||
getCurrencyCheckUseCase: GetCurrencyCheckUseCase,
|
getCurrencyCheckUseCase: GetCurrencyCheckUseCase,
|
||||||
isFeeApproximateUseCase: IsFeeApproximateUseCase,
|
isFeeApproximateUseCase: IsFeeApproximateUseCase,
|
||||||
getBalanceNotEnoughForFeeWarningUseCase: GetBalanceNotEnoughForFeeWarningUseCase,
|
getBalanceNotEnoughForFeeWarningUseCase: GetBalanceNotEnoughForFeeWarningUseCase,
|
||||||
|
getTronFeeNotificationShowCountUseCase: GetTronFeeNotificationShowCountUseCase,
|
||||||
) : Model(), SendClickIntents {
|
) : Model(), SendClickIntents {
|
||||||
|
|
||||||
private val params = paramsContainer.require<SendComponent.Params>()
|
private val params = paramsContainer.require<SendComponent.Params>()
|
||||||
|
|
@ -195,6 +199,7 @@ internal class SendModel @Inject constructor(
|
||||||
validateTransactionUseCase = validateTransactionUseCase,
|
validateTransactionUseCase = validateTransactionUseCase,
|
||||||
getCurrencyCheckUseCase = getCurrencyCheckUseCase,
|
getCurrencyCheckUseCase = getCurrencyCheckUseCase,
|
||||||
getBalanceNotEnoughForFeeWarningUseCase = getBalanceNotEnoughForFeeWarningUseCase,
|
getBalanceNotEnoughForFeeWarningUseCase = getBalanceNotEnoughForFeeWarningUseCase,
|
||||||
|
getTronFeeNotificationShowCountUseCase = getTronFeeNotificationShowCountUseCase,
|
||||||
cryptoCurrencyStatusProvider = Provider { cryptoCurrencyStatus },
|
cryptoCurrencyStatusProvider = Provider { cryptoCurrencyStatus },
|
||||||
feeCryptoCurrencyStatusProvider = Provider { feeCryptoCurrencyStatus },
|
feeCryptoCurrencyStatusProvider = Provider { feeCryptoCurrencyStatus },
|
||||||
currentStateProvider = Provider { uiState.value },
|
currentStateProvider = Provider { uiState.value },
|
||||||
|
|
@ -528,16 +533,29 @@ internal class SendModel @Inject constructor(
|
||||||
|
|
||||||
uiState.value = stateFactory.syncEditStates(isFromEdit = isFromEdit)
|
uiState.value = stateFactory.syncEditStates(isFromEdit = isFromEdit)
|
||||||
sendScreenAnalyticSender.send(currentState.type, uiState.value)
|
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.Fee,
|
||||||
SendUiStateType.EditFee,
|
SendUiStateType.EditFee,
|
||||||
-> if (onFeeNextIntercept(isFromEdit)) return
|
-> if (onFeeNextIntercept(isFromEdit)) return
|
||||||
SendUiStateType.Amount,
|
SendUiStateType.Amount -> {
|
||||||
|
loadFee()
|
||||||
|
incrementNotificationsShowCounter()
|
||||||
|
}
|
||||||
SendUiStateType.EditAmount,
|
SendUiStateType.EditAmount,
|
||||||
-> loadFee()
|
-> loadFee()
|
||||||
else -> Unit
|
else -> Unit
|
||||||
}
|
}
|
||||||
stateRouter.onNextClick()
|
}
|
||||||
|
|
||||||
|
private fun incrementNotificationsShowCounter() {
|
||||||
|
modelScope.launch {
|
||||||
|
incrementNotificationsShowCountUseCase(cryptoCurrency)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAmountNext() = onNextClick(stateRouter.isEditState)
|
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.Fee
|
||||||
import com.tangem.blockchain.common.transaction.TransactionFee
|
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.amountScreen.models.AmountState
|
||||||
import com.tangem.common.ui.notifications.NotificationUM
|
import com.tangem.common.ui.notifications.NotificationUM
|
||||||
import com.tangem.common.ui.notifications.NotificationsFactory.addDustWarningNotification
|
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.addTransactionLimitErrorNotification
|
||||||
import com.tangem.common.ui.notifications.NotificationsFactory.addValidateTransactionNotifications
|
import com.tangem.common.ui.notifications.NotificationsFactory.addValidateTransactionNotifications
|
||||||
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
||||||
|
import com.tangem.core.ui.extensions.resourceReference
|
||||||
import com.tangem.core.ui.utils.parseToBigDecimal
|
import com.tangem.core.ui.utils.parseToBigDecimal
|
||||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||||
|
import com.tangem.domain.notifications.GetTronFeeNotificationShowCountUseCase
|
||||||
import com.tangem.domain.tokens.GetBalanceNotEnoughForFeeWarningUseCase
|
import com.tangem.domain.tokens.GetBalanceNotEnoughForFeeWarningUseCase
|
||||||
import com.tangem.domain.tokens.GetCurrencyCheckUseCase
|
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.CryptoCurrencyStatus
|
||||||
import com.tangem.domain.tokens.model.warnings.CryptoCurrencyCheck
|
import com.tangem.domain.tokens.model.warnings.CryptoCurrencyCheck
|
||||||
import com.tangem.domain.transaction.error.GetFeeError
|
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
|
||||||
import com.tangem.lib.crypto.BlockchainUtils.getTezosThreshold
|
import com.tangem.lib.crypto.BlockchainUtils.getTezosThreshold
|
||||||
import com.tangem.lib.crypto.BlockchainUtils.isTezos
|
import com.tangem.lib.crypto.BlockchainUtils.isTezos
|
||||||
|
import com.tangem.lib.crypto.BlockchainUtils.isTron
|
||||||
import com.tangem.utils.Provider
|
import com.tangem.utils.Provider
|
||||||
import com.tangem.utils.extensions.orZero
|
import com.tangem.utils.extensions.orZero
|
||||||
import kotlinx.collections.immutable.ImmutableList
|
import kotlinx.collections.immutable.ImmutableList
|
||||||
|
|
@ -52,6 +57,7 @@ internal class SendNotificationFactory(
|
||||||
private val validateTransactionUseCase: ValidateTransactionUseCase,
|
private val validateTransactionUseCase: ValidateTransactionUseCase,
|
||||||
private val getCurrencyCheckUseCase: GetCurrencyCheckUseCase,
|
private val getCurrencyCheckUseCase: GetCurrencyCheckUseCase,
|
||||||
private val getBalanceNotEnoughForFeeWarningUseCase: GetBalanceNotEnoughForFeeWarningUseCase,
|
private val getBalanceNotEnoughForFeeWarningUseCase: GetBalanceNotEnoughForFeeWarningUseCase,
|
||||||
|
private val getTronFeeNotificationShowCountUseCase: GetTronFeeNotificationShowCountUseCase,
|
||||||
private val cryptoCurrencyStatusProvider: Provider<CryptoCurrencyStatus>,
|
private val cryptoCurrencyStatusProvider: Provider<CryptoCurrencyStatus>,
|
||||||
private val feeCryptoCurrencyStatusProvider: Provider<CryptoCurrencyStatus?>,
|
private val feeCryptoCurrencyStatusProvider: Provider<CryptoCurrencyStatus?>,
|
||||||
private val currentStateProvider: Provider<SendUiState>,
|
private val currentStateProvider: Provider<SendUiState>,
|
||||||
|
|
@ -125,9 +131,14 @@ internal class SendNotificationFactory(
|
||||||
isFeeCoverage = isFeeCoverage,
|
isFeeCoverage = isFeeCoverage,
|
||||||
currencyCheck = currencyCheck,
|
currencyCheck = currencyCheck,
|
||||||
)
|
)
|
||||||
|
addInfoNotifications()
|
||||||
}.toImmutableList()
|
}.toImmutableList()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private suspend fun MutableList<NotificationUM>.addInfoNotifications() {
|
||||||
|
addTronNetworkFeesNotification()
|
||||||
|
}
|
||||||
|
|
||||||
fun dismissNotificationState(clazz: Class<out NotificationUM>, isIgnored: Boolean = false): SendUiState {
|
fun dismissNotificationState(clazz: Class<out NotificationUM>, isIgnored: Boolean = false): SendUiState {
|
||||||
val state = currentStateProvider()
|
val state = currentStateProvider()
|
||||||
val sendState = state.sendState ?: return state
|
val sendState = state.sendState ?: return state
|
||||||
|
|
@ -341,4 +352,23 @@ internal class SendNotificationFactory(
|
||||||
add(NotificationUM.Warning.TooHigh(diff))
|
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