Updated on 2026-08-14
This commit is contained in:
parent
2c8c2cb579
commit
3f20fb5bac
12 changed files with 15 additions and 90 deletions
|
|
@ -37,6 +37,8 @@ import com.tangem.domain.walletmanager.WalletManagersFacade
|
|||
import com.tangem.domain.wallets.legacy.UserWalletsListManager
|
||||
import com.tangem.domain.wallets.legacy.WalletManagersRepository
|
||||
import com.tangem.domain.wallets.repository.WalletsRepository
|
||||
import com.tangem.features.managetokens.featuretoggles.ManageTokensFeatureToggles
|
||||
import com.tangem.features.send.api.featuretoggles.SendFeatureToggles
|
||||
import com.tangem.features.wallet.featuretoggles.WalletFeatureToggles
|
||||
import com.tangem.tap.common.analytics.AnalyticsFactory
|
||||
import com.tangem.tap.common.analytics.api.AnalyticsHandlerBuilder
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ internal class BiometricUserWalletsListManager(
|
|||
}
|
||||
}
|
||||
|
||||
private suspend fun unlockWithBiometryInternal(selectedWalletId: UserWalletId? = null): CompletionResult<Unit> {
|
||||
private suspend fun unlockWithBiometryInternal(): CompletionResult<Unit> {
|
||||
return keysRepository.getAll()
|
||||
.map { keys ->
|
||||
state.update { prevState ->
|
||||
|
|
@ -216,7 +216,7 @@ internal class BiometricUserWalletsListManager(
|
|||
)
|
||||
}
|
||||
}
|
||||
.flatMap { loadModels(selectedWalletId = selectedWalletId) }
|
||||
.flatMap { loadModels() }
|
||||
.map {
|
||||
state.update { prevState ->
|
||||
val hasLockedUserWallets = prevState.userWallets.any { it.isLocked }
|
||||
|
|
@ -225,24 +225,6 @@ internal class BiometricUserWalletsListManager(
|
|||
}
|
||||
}
|
||||
|
||||
private fun CompletionResult<Unit>.mapUnlockResult(): CompletionResult<UserWallet> {
|
||||
return this
|
||||
.mapFailure { error ->
|
||||
if (error is UserWalletsListError) {
|
||||
error
|
||||
} else {
|
||||
UserWalletsListError.UnableToUnlockUserWallets(cause = error)
|
||||
}
|
||||
}
|
||||
.map {
|
||||
selectedUserWalletSync.guard {
|
||||
throw UserWalletsListError.UnableToUnlockUserWallets(
|
||||
cause = IllegalStateException("No user wallet selected"),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun saveEncryptionKeyIfNotNull(userWallet: UserWallet): CompletionResult<ByteArray?> {
|
||||
val encryptionKey = userWallet.scanResponse.card.encryptionKey
|
||||
?.let { UserWalletEncryptionKey(userWallet.walletId, it) }
|
||||
|
|
@ -264,7 +246,7 @@ internal class BiometricUserWalletsListManager(
|
|||
}
|
||||
}
|
||||
|
||||
private suspend fun loadModels(selectedWalletId: UserWalletId? = null): CompletionResult<Unit> {
|
||||
private suspend fun loadModels(): CompletionResult<Unit> {
|
||||
return getSavedUserWallets()
|
||||
.map { userWallets ->
|
||||
if (userWallets.isNotEmpty()) {
|
||||
|
|
@ -274,7 +256,7 @@ internal class BiometricUserWalletsListManager(
|
|||
prevState.copy(
|
||||
userWallets = wallets,
|
||||
selectedUserWalletId = findOrSetSelectedUserWalletId(
|
||||
prevSelectedWalletId = selectedWalletId ?: prevState.selectedUserWalletId,
|
||||
prevSelectedWalletId = prevState.selectedUserWalletId,
|
||||
userWallets = wallets,
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import com.tangem.domain.tokens.model.CryptoCurrency
|
|||
import com.tangem.domain.tokens.model.Network
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.domain.wallets.usecase.GetSelectedWalletSyncUseCase
|
||||
import com.tangem.features.send.navigation.SendRouter
|
||||
import com.tangem.features.send.api.navigation.SendRouter
|
||||
import com.tangem.tap.di.DelayedWork
|
||||
import com.tangem.tap.features.send.redux.AmountAction
|
||||
import com.tangem.tap.proxy.AppStateHolder
|
||||
|
|
|
|||
|
|
@ -173,7 +173,6 @@ fun SecondaryButton(
|
|||
text: String,
|
||||
onClick: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
size: TangemButtonSize = TangemButtonSize.Default,
|
||||
showProgress: Boolean = false,
|
||||
enabled: Boolean = true,
|
||||
size: TangemButtonSize = TangemButtonSize.Default,
|
||||
|
|
|
|||
|
|
@ -362,15 +362,6 @@ private class TransactionItemStateProvider : CollectionPreviewParameterProvider<
|
|||
subtitle = TextReference.Str("33BddS...ga2B"),
|
||||
onClick = {},
|
||||
),
|
||||
TransactionState.Approve(
|
||||
txHash = UUID.randomUUID().toString(),
|
||||
address = TextReference.Str("33BddS...ga2B"),
|
||||
amount = "+0.500913 BTC",
|
||||
timestamp = "8:41",
|
||||
status = Status.Confirmed,
|
||||
direction = Direction.OUTGOING,
|
||||
onClick = {},
|
||||
),
|
||||
TransactionState.Content(
|
||||
txHash = UUID.randomUUID().toString(),
|
||||
amount = "+0.500913 BTC",
|
||||
|
|
|
|||
|
|
@ -113,13 +113,6 @@ interface UserWalletsListManager {
|
|||
*/
|
||||
suspend fun unlock(throwIfNotAllWalletsUnlocked: Boolean = false): CompletionResult<UserWallet>
|
||||
|
||||
/**
|
||||
* Unlock all [UserWallet]s and select passed [UserWalletId]
|
||||
*
|
||||
* @param selectedWalletId [UserWalletId] of [UserWallet] which must be selected
|
||||
*/
|
||||
suspend fun unlockAndSelect(selectedWalletId: UserWalletId): CompletionResult<UserWallet>
|
||||
|
||||
/** Remove [UserWallet]s from [userWallets] and set [isLocked] as true */
|
||||
fun lock()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ internal class SendViewModel @Inject constructor(
|
|||
userWalletId = userWalletId,
|
||||
currencyId = cryptoCurrency.id,
|
||||
derivationPath = cryptoCurrency.network.derivationPath,
|
||||
contractAddress = (cryptoCurrency as? CryptoCurrency.Token)?.contractAddress,
|
||||
isSingleWalletWithTokens = isSingleWallet,
|
||||
)
|
||||
.flowWithLifecycle(owner.lifecycle)
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ internal sealed class TokenDetailsNotification(val config: NotificationConfig) {
|
|||
iconResId = iconResId,
|
||||
buttonsState = buttonsState,
|
||||
),
|
||||
) {
|
||||
)
|
||||
|
||||
sealed class Informational(
|
||||
title: TextReference,
|
||||
|
|
@ -108,35 +108,5 @@ internal sealed class TokenDetailsNotification(val config: NotificationConfig) {
|
|||
id = R.string.warning_send_blocked_pending_transactions_message,
|
||||
formatArgs = wrappedList(coinSymbol),
|
||||
),
|
||||
) {
|
||||
data class RentInfo(
|
||||
private val rentInfo: CryptoCurrencyWarning.Rent,
|
||||
private val onCloseClick: () -> Unit,
|
||||
) : Informational(
|
||||
title = TextReference.Res(R.string.warning_rent_fee_title),
|
||||
subtitle = TextReference.Res(
|
||||
id = R.string.warning_solana_rent_fee_message,
|
||||
formatArgs = wrappedList(rentInfo.rent, rentInfo.exemptionAmount),
|
||||
),
|
||||
onCloseClick = onCloseClick,
|
||||
)
|
||||
|
||||
data class ExistentialDeposit(
|
||||
private val existentialInfo: CryptoCurrencyWarning.ExistentialDeposit,
|
||||
) : Informational(
|
||||
title = resourceReference(R.string.warning_existential_deposit_title),
|
||||
subtitle = TextReference.Res(
|
||||
id = R.string.warning_existential_deposit_message,
|
||||
formatArgs = wrappedList(existentialInfo.currencyName, existentialInfo.edStringValueWithSymbol),
|
||||
),
|
||||
)
|
||||
|
||||
class NetworksNoAccount(val network: String, val symbol: String, val amount: String) : Informational(
|
||||
title = resourceReference(R.string.warning_no_account_title),
|
||||
subtitle = resourceReference(
|
||||
R.string.no_account_generic,
|
||||
wrappedList(network, amount, symbol),
|
||||
),
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
@ -41,7 +41,7 @@ internal class TokenDetailsLoadedBalanceConverter(
|
|||
return state.copy(
|
||||
tokenBalanceBlockState = TokenDetailsBalanceBlockState.Error(state.tokenBalanceBlockState.actionButtons),
|
||||
marketPriceBlockState = MarketPriceBlockState.Error(state.marketPriceBlockState.currencySymbol),
|
||||
notifications = persistentListOf(TokenDetailsNotification.Warning.NetworksUnreachable),
|
||||
notifications = persistentListOf(TokenDetailsNotification.NetworksUnreachable),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,20 +19,20 @@ internal class TokenDetailsNotificationConverter(
|
|||
|
||||
fun removeRentInfo(currentState: TokenDetailsState): ImmutableList<TokenDetailsNotification> {
|
||||
val newNotifications = currentState.notifications.toMutableList()
|
||||
newNotifications.removeBy { it is TokenDetailsNotification.Informational.RentInfo }
|
||||
newNotifications.removeBy { it is TokenDetailsNotification.RentInfo }
|
||||
return newNotifications.toImmutableList()
|
||||
}
|
||||
|
||||
private fun mapToNotification(warning: CryptoCurrencyWarning): TokenDetailsNotification {
|
||||
return when (warning) {
|
||||
is CryptoCurrencyWarning.BalanceNotEnoughForFee -> TokenDetailsNotification.Warning.NetworkFee(
|
||||
is CryptoCurrencyWarning.BalanceNotEnoughForFee -> TokenDetailsNotification.NetworkFee(
|
||||
feeInfo = warning,
|
||||
onBuyClick = { clickIntents.onBuyCoinClick(warning.coinCurrency) },
|
||||
)
|
||||
is CryptoCurrencyWarning.ExistentialDeposit -> TokenDetailsNotification.Informational.ExistentialDeposit(
|
||||
is CryptoCurrencyWarning.ExistentialDeposit -> TokenDetailsNotification.ExistentialDeposit(
|
||||
existentialInfo = warning,
|
||||
)
|
||||
is CryptoCurrencyWarning.Rent -> TokenDetailsNotification.Informational.RentInfo(
|
||||
is CryptoCurrencyWarning.Rent -> TokenDetailsNotification.RentInfo(
|
||||
rentInfo = warning,
|
||||
onCloseClick = clickIntents::onCloseRentInfoNotification,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -159,18 +159,6 @@ internal class WalletNotificationsListFactory(
|
|||
addMissingAddressesNotification(maybeMissedAddressCurrencies)
|
||||
}
|
||||
|
||||
private fun MutableList<WalletNotification>.addInformationalNotifications(
|
||||
cardTypesResolver: CardTypesResolver,
|
||||
maybeMissedAddressCurrencies: Either<GetCurrenciesError, List<CryptoCurrency>>,
|
||||
) {
|
||||
addIf(
|
||||
element = WalletNotification.Informational.DemoCard,
|
||||
condition = isDemoCardUseCase(cardId = cardTypesResolver.getCardId()),
|
||||
)
|
||||
|
||||
addMissingAddressesNotification(maybeMissedAddressCurrencies)
|
||||
}
|
||||
|
||||
private fun MutableList<WalletNotification>.addIf(element: WalletNotification, condition: Boolean) {
|
||||
if (condition) {
|
||||
add(element = element)
|
||||
|
|
|
|||
|
|
@ -115,7 +115,6 @@ internal class WalletViewModel @Inject constructor(
|
|||
private val shouldShowSaveWalletScreenUseCase: ShouldShowSaveWalletScreenUseCase,
|
||||
private val canUseBiometryUseCase: CanUseBiometryUseCase,
|
||||
private val shouldSaveUserWalletsUseCase: ShouldSaveUserWalletsUseCase,
|
||||
private val isBalanceHiddenUseCase: IsBalanceHiddenUseCase,
|
||||
private val getBalanceHidingSettingsUseCase: GetBalanceHidingSettingsUseCase,
|
||||
private val listenToFlipsUseCase: ListenToFlipsUseCase,
|
||||
private val removeCurrencyUseCase: RemoveCurrencyUseCase,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue