From e07cd92e275851ea050163f9e31d6ea995a44155 Mon Sep 17 00:00:00 2001 From: Tangem Date: Tue, 16 Sep 2025 17:39:08 +0500 Subject: [PATCH] Updated on 2026-08-14 --- .../wallet/child/wallet/model/WalletModel.kt | 4 +-- .../model/WalletsUpdateActionResolver.kt | 30 +++++++++++++++++-- .../common/preview/WalletScreenPreviewData.kt | 1 + .../domain/WalletAdditionalInfoFactory.kt | 15 ++++++++-- .../wallet/state/model/WalletState.kt | 8 +++++ .../InitializeWalletsTransformer.kt | 5 ++++ .../transformers/SetVisaInfoTransformer.kt | 5 +++- .../state/utils/WalletLoadingStateFactory.kt | 2 ++ 8 files changed, 61 insertions(+), 9 deletions(-) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt index f6338a48a4..291da9380e 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt @@ -432,7 +432,7 @@ internal class WalletModel @Inject constructor( is WalletsUpdateActionResolver.Action.RenameWallets -> { stateHolder.update(transformer = RenameWalletsTransformer(renamedWallets = action.renamedWallets)) } - is WalletsUpdateActionResolver.Action.ReloadWarningsForWallets -> { + is WalletsUpdateActionResolver.Action.ReloadWallets -> { reloadWarnings(action) } WalletsUpdateActionResolver.Action.EmptyWallets -> { @@ -444,7 +444,7 @@ internal class WalletModel @Inject constructor( } } - private fun reloadWarnings(action: WalletsUpdateActionResolver.Action.ReloadWarningsForWallets) { + private fun reloadWarnings(action: WalletsUpdateActionResolver.Action.ReloadWallets) { action.wallets.forEach { walletScreenContentLoader.load( userWallet = it, diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletsUpdateActionResolver.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletsUpdateActionResolver.kt index 562c8a99a8..6cce8840ea 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletsUpdateActionResolver.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletsUpdateActionResolver.kt @@ -64,6 +64,9 @@ internal class WalletsUpdateActionResolver @Inject constructor( selectedWallet: UserWallet, ): Action { return when { + isHotWalletUpgraded(state, wallets) -> { + getHotWalletsUpgradedAction(state, wallets) + } isWalletsCountChanged(state, wallets) -> { getChangeWalletsListAction(state, wallets, selectedWallet) } @@ -91,6 +94,19 @@ internal class WalletsUpdateActionResolver @Inject constructor( return walletsToUpdate.isNotEmpty() } + private fun isHotWalletUpgraded(state: WalletScreenState, wallets: List): Boolean { + val previousWallet = state + .wallets + .getOrNull(state.selectedWalletIndex) + return when (previousWallet) { + is WalletState.MultiCurrency -> { + val wallet = wallets.firstOrNull { it.walletId == previousWallet.walletCardState.id } + previousWallet.type == WalletState.MultiCurrency.WalletType.Hot && wallet is UserWallet.Cold + } + else -> false + } + } + private fun isWalletsCountChanged(state: WalletScreenState, wallets: List): Boolean { val prevWalletsSize = state.wallets.size val walletsSize = wallets.size @@ -160,14 +176,22 @@ internal class WalletsUpdateActionResolver @Inject constructor( private fun getHotWalletsBackedUpAction( state: WalletScreenState, wallets: List, - ): Action.ReloadWarningsForWallets { + ): Action.ReloadWallets { val incompleteActivationWalletIds = state.incompleteActivationWalletIds() val walletsToUpdate = wallets.filter { it is UserWallet.Hot && it.backedUp == incompleteActivationWalletIds.contains(it.walletId) } - return Action.ReloadWarningsForWallets(walletsToUpdate) + return Action.ReloadWallets(walletsToUpdate) + } + + private fun getHotWalletsUpgradedAction( + state: WalletScreenState, + wallets: List, + ): Action.ReloadWallets { + val walletsToUpdate = wallets.filter { it.walletId == state.getPrevSelectedWallet().id } + return Action.ReloadWallets(walletsToUpdate) } private fun getRenameWalletsAction(state: WalletScreenState, wallets: List): Action.RenameWallets { @@ -358,7 +382,7 @@ internal class WalletsUpdateActionResolver @Inject constructor( } } - data class ReloadWarningsForWallets( + data class ReloadWallets( val wallets: List, ) : Action() diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/preview/WalletScreenPreviewData.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/preview/WalletScreenPreviewData.kt index 8dee141518..cd5f108efd 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/preview/WalletScreenPreviewData.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/preview/WalletScreenPreviewData.kt @@ -159,6 +159,7 @@ internal object WalletScreenPreviewData { isFlickering = false, onItemClick = { }, ), + type = WalletState.MultiCurrency.WalletType.Cold, ) } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/WalletAdditionalInfoFactory.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/WalletAdditionalInfoFactory.kt index 134e5086fd..31fffb5d04 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/WalletAdditionalInfoFactory.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/WalletAdditionalInfoFactory.kt @@ -99,7 +99,10 @@ internal object WalletAdditionalInfoFactory { TextReference.EMPTY } - return WalletAdditionalInfo(hideable = false, content = content) + return WalletAdditionalInfo( + hideable = false, + content = content, + ) } private fun getBackupInfoTextReference(count: Int): TextReference { @@ -112,12 +115,18 @@ internal object WalletAdditionalInfoFactory { private fun UserWallet.Cold.resolveSingleCurrencyInfo(currencyAmount: BigDecimal?): WalletAdditionalInfo { return if (isLocked) { - WalletAdditionalInfo(hideable = false, content = TextReference.Res(R.string.common_locked)) + WalletAdditionalInfo( + hideable = false, + content = TextReference.Res(R.string.common_locked), + ) } else { val blockchain = scanResponse.cardTypesResolver.getBlockchain() val amount = currencyAmount?.format { crypto(blockchain.currency, blockchain.decimals()) } - WalletAdditionalInfo(hideable = true, content = TextReference.Str(value = amount.orEmpty())) + WalletAdditionalInfo( + hideable = true, + content = TextReference.Str(value = amount.orEmpty()), + ) } } } \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/model/WalletState.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/model/WalletState.kt index cd4ed81df9..86df278ce6 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/model/WalletState.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/model/WalletState.kt @@ -23,6 +23,7 @@ internal sealed interface WalletState : WalletStateHolder { abstract val tokensListState: WalletTokensListState abstract val nftState: WalletNFTItemUM + abstract val type: WalletType data class Content( override val pullToRefreshConfig: PullToRefreshConfig, @@ -32,12 +33,14 @@ internal sealed interface WalletState : WalletStateHolder { override val bottomSheetConfig: TangemBottomSheetConfig?, override val tokensListState: WalletTokensListState, override val nftState: WalletNFTItemUM, + override val type: WalletType, ) : MultiCurrency() data class Locked( override val walletCardState: WalletCardState, override val buttons: PersistentList, override val bottomSheetConfig: TangemBottomSheetConfig?, + override val type: WalletType, val onUnlockNotificationClick: () -> Unit, ) : MultiCurrency(), WalletStateHolder by LockedWalletStateHolder( @@ -50,6 +53,11 @@ internal sealed interface WalletState : WalletStateHolder { override val tokensListState = WalletTokensListState.ContentState.Locked override val nftState: WalletNFTItemUM = WalletNFTItemUM.Hidden } + + enum class WalletType { + Hot, + Cold, + } } sealed class SingleCurrency : WalletState, TxHistoryStateHolder { diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/InitializeWalletsTransformer.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/InitializeWalletsTransformer.kt index 8cac86072f..3c7788f3fd 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/InitializeWalletsTransformer.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/InitializeWalletsTransformer.kt @@ -9,6 +9,7 @@ import com.tangem.feature.wallet.presentation.wallet.state.model.* import com.tangem.feature.wallet.presentation.wallet.state.utils.WalletLoadingStateFactory import com.tangem.feature.wallet.presentation.wallet.state.utils.createStateByWalletType import com.tangem.feature.wallet.child.wallet.model.intents.WalletClickIntents +import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState.MultiCurrency.WalletType import kotlinx.collections.immutable.PersistentList import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.toImmutableList @@ -61,6 +62,10 @@ internal class InitializeWalletsTransformer( buttons = createMultiWalletEnabledButtons(userWallet), bottomSheetConfig = null, onUnlockNotificationClick = clickIntents::onOpenUnlockWalletsBottomSheetClick, + type = when (userWallet) { + is UserWallet.Cold -> WalletType.Cold + is UserWallet.Hot -> WalletType.Hot + }, ) }, singleCurrencyCreator = { diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/SetVisaInfoTransformer.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/SetVisaInfoTransformer.kt index 2435c086e7..18974cedeb 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/SetVisaInfoTransformer.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/SetVisaInfoTransformer.kt @@ -106,7 +106,10 @@ internal class SetVisaInfoTransformer( }, ) - return WalletAdditionalInfo(hideable = true, infoContent) + return WalletAdditionalInfo( + hideable = true, + content = infoContent, + ) } private fun getRefreshTokenExpiredState(prevState: WalletState.Visa.Content): WalletState { diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/utils/WalletLoadingStateFactory.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/utils/WalletLoadingStateFactory.kt index a475345feb..ea2b92e829 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/utils/WalletLoadingStateFactory.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/utils/WalletLoadingStateFactory.kt @@ -54,6 +54,7 @@ internal class WalletLoadingStateFactory( bottomSheetConfig = null, tokensListState = WalletTokensListState.ContentState.Loading, nftState = WalletNFTItemUM.Hidden, + type = WalletState.MultiCurrency.WalletType.Hot, ) } @@ -66,6 +67,7 @@ internal class WalletLoadingStateFactory( bottomSheetConfig = null, tokensListState = WalletTokensListState.ContentState.Loading, nftState = WalletNFTItemUM.Hidden, + type = WalletState.MultiCurrency.WalletType.Cold, ) }