Updated on 2026-08-14
This commit is contained in:
parent
f00760c977
commit
93db763fe8
6 changed files with 21 additions and 30 deletions
|
|
@ -15,6 +15,7 @@ import com.tangem.domain.models.scan.ScanResponse
|
|||
import com.tangem.operations.attestation.Attestation
|
||||
import com.tangem.tap.common.analytics.events.Basic
|
||||
import com.tangem.tap.common.extensions.dispatchOnMain
|
||||
import com.tangem.tap.common.extensions.dispatchWithMain
|
||||
import com.tangem.tap.common.extensions.setContext
|
||||
import com.tangem.tap.common.redux.global.GlobalAction
|
||||
import com.tangem.tap.domain.model.UserWallet
|
||||
|
|
@ -94,6 +95,7 @@ class TapWalletManager(
|
|||
Timber.d("Wallet stores fetched for ${userWallet.walletId}")
|
||||
store.dispatchOnMain(WalletAction.LoadData.Success)
|
||||
store.state.globalState.topUpController?.loadDataSuccess()
|
||||
store.dispatchWithMain(WalletAction.Warnings.CheckHashesCount.VerifyOnlineIfNeeded)
|
||||
}
|
||||
.doOnFailure { error ->
|
||||
val errorAction = when (error) {
|
||||
|
|
|
|||
|
|
@ -52,6 +52,8 @@ class WarningMessagesManager {
|
|||
warningsList.removeBy { it.messageResId == messageRes }
|
||||
}
|
||||
|
||||
fun containsWarning(warning: WarningMessage) = warning in warningsList
|
||||
|
||||
private fun sortByPriority() {
|
||||
warningsList.sortBy { it.priority.ordinal }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,9 +45,11 @@ sealed class WalletAction : Action {
|
|||
|
||||
sealed class Warnings : WalletAction() {
|
||||
object CheckHashesCount : Warnings() {
|
||||
object CheckHashesCountOnline : Warnings()
|
||||
object NeedToCheckHashesCountOnline : Warnings()
|
||||
object ConfirmHashesCount : Warnings()
|
||||
|
||||
/**
|
||||
* Start online verification of signed hashes for single currency wallets if the warning not displayed
|
||||
* */
|
||||
object VerifyOnlineIfNeeded : Warnings()
|
||||
object SaveCardId : Warnings()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ data class WalletState(
|
|||
val state: ProgressState = ProgressState.Done,
|
||||
val error: ErrorType? = null,
|
||||
val cardImage: Artwork? = null,
|
||||
val hashesCountVerified: Boolean? = null,
|
||||
val mainWarningsList: List<WarningMessage> = mutableListOf(),
|
||||
val walletsStores: List<WalletStoreModel> = listOf(),
|
||||
val isMultiwalletAllowed: Boolean = false,
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ class WarningsMiddleware {
|
|||
val readyToShow = preferencesStorage.appRatingLaunchObserver.isReadyToShow()
|
||||
if (readyToShow) addWarningMessage(warning = WarningMessagesManager.appRatingWarning, autoUpdate = true)
|
||||
}
|
||||
is WalletAction.Warnings.CheckHashesCount.CheckHashesCountOnline -> checkHashesCountOnline()
|
||||
|
||||
is WalletAction.Warnings.CheckHashesCount.VerifyOnlineIfNeeded -> checkHashesCountOnlineIfNeeded()
|
||||
is WalletAction.Warnings.CheckHashesCount.SaveCardId -> {
|
||||
val cardId = globalState?.scanResponse?.card?.cardId
|
||||
cardId?.let { preferencesStorage.usedCardsPrefStorage.scanned(it) }
|
||||
|
|
@ -57,8 +58,6 @@ class WarningsMiddleware {
|
|||
}
|
||||
is WalletAction.Warnings.AppRating,
|
||||
is WalletAction.Warnings.CheckHashesCount,
|
||||
is WalletAction.Warnings.CheckHashesCount.ConfirmHashesCount,
|
||||
is WalletAction.Warnings.CheckHashesCount.NeedToCheckHashesCountOnline,
|
||||
is WalletAction.Warnings.Set,
|
||||
-> Unit
|
||||
}
|
||||
|
|
@ -120,22 +119,18 @@ class WarningsMiddleware {
|
|||
}
|
||||
}
|
||||
|
||||
val validator = store.state.walletState.walletManagers.firstOrNull() as? SignatureCountValidator
|
||||
return if (validator == null) {
|
||||
if (scanResponse.card.hasSignedHashes()) {
|
||||
WarningMessagesManager.alreadySignedHashesWarning
|
||||
} else {
|
||||
store.dispatch(WalletAction.Warnings.CheckHashesCount.SaveCardId)
|
||||
null
|
||||
}
|
||||
return if (scanResponse.card.hasSignedHashes()) {
|
||||
WarningMessagesManager.alreadySignedHashesWarning
|
||||
} else {
|
||||
store.dispatch(WalletAction.Warnings.CheckHashesCount.NeedToCheckHashesCountOnline)
|
||||
store.dispatch(WalletAction.Warnings.CheckHashesCount.SaveCardId)
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkHashesCountOnline() {
|
||||
if (store.state.walletState.hashesCountVerified != false) return
|
||||
private fun checkHashesCountOnlineIfNeeded() {
|
||||
val alreadySignedHashesWarning = WarningMessagesManager.alreadySignedHashesWarning
|
||||
val manager = store.state.globalState.warningManager ?: return
|
||||
if (manager.containsWarning(alreadySignedHashesWarning)) return
|
||||
|
||||
val networkConnectionManager = store.state.daggerGraphState.get(DaggerGraphState::networkConnectionManager)
|
||||
if (!networkConnectionManager.isOnline) return
|
||||
|
|
@ -156,14 +151,13 @@ class WarningsMiddleware {
|
|||
withContext(Dispatchers.Main) {
|
||||
when (result) {
|
||||
SimpleResult.Success -> {
|
||||
store.dispatch(WalletAction.Warnings.CheckHashesCount.ConfirmHashesCount)
|
||||
store.dispatch(WalletAction.Warnings.CheckHashesCount.SaveCardId)
|
||||
}
|
||||
is SimpleResult.Failure ->
|
||||
if (result.error is BlockchainSdkError.SignatureCountNotMatched) {
|
||||
addWarningMessage(WarningMessagesManager.alreadySignedHashesWarning, true)
|
||||
addWarningMessage(alreadySignedHashesWarning, true)
|
||||
} else if (signedHashes > 0) {
|
||||
addWarningMessage(WarningMessagesManager.alreadySignedHashesWarning, true)
|
||||
addWarningMessage(alreadySignedHashesWarning, true)
|
||||
}
|
||||
null -> Unit
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,11 +8,7 @@ import com.tangem.tap.domain.TapError
|
|||
import com.tangem.tap.domain.model.WalletDataModel
|
||||
import com.tangem.tap.domain.model.WalletStoreModel
|
||||
import com.tangem.tap.features.wallet.models.Currency
|
||||
import com.tangem.tap.features.wallet.redux.Artwork
|
||||
import com.tangem.tap.features.wallet.redux.ErrorType
|
||||
import com.tangem.tap.features.wallet.redux.ProgressState
|
||||
import com.tangem.tap.features.wallet.redux.WalletAction
|
||||
import com.tangem.tap.features.wallet.redux.WalletState
|
||||
import com.tangem.tap.features.wallet.redux.*
|
||||
import com.tangem.tap.proxy.AppStateHolder
|
||||
import com.tangem.tap.userWalletsListManager
|
||||
import org.rekotlin.Action
|
||||
|
|
@ -166,10 +162,6 @@ fun Wallet.createAddressesData(): List<WalletDataModel.AddressData> {
|
|||
|
||||
private fun handleCheckSignedHashesActions(action: WalletAction.Warnings, state: WalletState): WalletState {
|
||||
return when (action) {
|
||||
WalletAction.Warnings.CheckHashesCount.ConfirmHashesCount -> state.copy(hashesCountVerified = true)
|
||||
WalletAction.Warnings.CheckHashesCount.NeedToCheckHashesCountOnline -> state.copy(
|
||||
hashesCountVerified = false,
|
||||
)
|
||||
is WalletAction.Warnings.Set -> state.copy(mainWarningsList = action.warningList)
|
||||
else -> state
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue