Updated on 2026-08-14
This commit is contained in:
parent
f76731e166
commit
8aa158cdb6
7 changed files with 40 additions and 21 deletions
|
|
@ -222,10 +222,21 @@ object TokensMiddleware {
|
|||
) {
|
||||
val config = CardConfig.createConfig(scanResponse.card)
|
||||
val derivationDataList = currencyList.mapNotNull { currency ->
|
||||
config.primaryCurve(blockchain = Blockchain.fromId(currency.network.id.value))
|
||||
?.let { curve -> getNewDerivations(curve, scanResponse, currency) }
|
||||
val curve = config.primaryCurve(blockchain = Blockchain.fromId(currency.network.id.value))
|
||||
curve?.let { getNewDerivations(curve, scanResponse, currency) }
|
||||
}
|
||||
val derivations = derivationDataList.associate(DerivationData::derivations)
|
||||
val derivations = buildMap<ByteArrayKey, MutableList<DerivationPath>> {
|
||||
derivationDataList.forEach {
|
||||
val current = this[it.derivations.first]
|
||||
if (current != null) {
|
||||
current.addAll(it.derivations.second)
|
||||
current.distinct()
|
||||
} else {
|
||||
this[it.derivations.first] = it.derivations.second.toMutableList()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (derivations.isEmpty()) {
|
||||
onSuccess(scanResponse)
|
||||
return
|
||||
|
|
@ -371,10 +382,10 @@ object TokensMiddleware {
|
|||
)
|
||||
|
||||
currenciesRepository.addCurrencies(userWalletId = userWalletId, currencies = currencyList)
|
||||
val networks = currencyList.map { it.network }.toSet()
|
||||
|
||||
networksRepository.getNetworkStatusesSync(
|
||||
userWalletId = userWalletId,
|
||||
networks = networks,
|
||||
networks = currencyList.map(CryptoCurrency::network).toSet(),
|
||||
refresh = true,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class GetMissedAddressesCryptoCurrenciesUseCase(private val currenciesRepository
|
|||
|
||||
operator fun invoke(userWalletId: UserWalletId): Flow<Either<GetCurrenciesError, List<CryptoCurrency>>> {
|
||||
return currenciesRepository.getMissedAddressesCryptoCurrencies(userWalletId)
|
||||
.map<List<CryptoCurrency>, Either<GetCurrenciesError, List<CryptoCurrency>>> { it.right() }
|
||||
.map<List<CryptoCurrency>, Either<GetCurrenciesError, List<CryptoCurrency>>>(List<CryptoCurrency>::right)
|
||||
.catch { emit(GetCurrenciesError.DataError(it).left()) }
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,6 @@ package com.tangem.feature.wallet.presentation.common.component.token
|
|||
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.animation.AnimatedContent
|
||||
import androidx.compose.animation.ExperimentalAnimationApi
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material3.Icon
|
||||
|
|
@ -19,7 +18,6 @@ import com.tangem.feature.wallet.presentation.common.state.TokenItemState
|
|||
import org.burnoutcrew.reorderable.ReorderableLazyListState
|
||||
import org.burnoutcrew.reorderable.detectReorder
|
||||
|
||||
@OptIn(ExperimentalAnimationApi::class)
|
||||
@Composable
|
||||
internal fun NonFiatContentBlock(
|
||||
state: TokenItemState,
|
||||
|
|
@ -30,6 +28,7 @@ internal fun NonFiatContentBlock(
|
|||
targetState = state,
|
||||
label = "Update non content fiat block",
|
||||
modifier = modifier,
|
||||
contentKey = { it::class.java },
|
||||
) { animatedState ->
|
||||
when (animatedState) {
|
||||
is TokenItemState.Draggable -> DraggableImage(reorderableTokenListState = reorderableTokenListState)
|
||||
|
|
|
|||
|
|
@ -74,23 +74,25 @@ internal sealed interface WalletCardState {
|
|||
/**
|
||||
* Wallet card error state
|
||||
*
|
||||
* @property id wallet id
|
||||
* @property title wallet name
|
||||
* @property imageResId wallet image resource id
|
||||
* @property onRenameClick lambda be invoked when Rename button is clicked
|
||||
* @property onDeleteClick lambda be invoked when Delete button is clicked
|
||||
* @property id wallet id
|
||||
* @property title wallet name
|
||||
* @property imageResId wallet image resource id
|
||||
* @property onRenameClick lambda be invoked when Rename button is clicked
|
||||
* @property onDeleteClick lambda be invoked when Delete button is clicked
|
||||
*/
|
||||
data class Error(
|
||||
override val id: UserWalletId,
|
||||
override val title: String,
|
||||
override val additionalInfo: WalletAdditionalInfo? = defaultAdditionalInfo,
|
||||
override val imageResId: Int?,
|
||||
override val onRenameClick: (UserWalletId, String) -> Unit,
|
||||
override val onDeleteClick: (UserWalletId) -> Unit,
|
||||
) : WalletCardState {
|
||||
override val additionalInfo: WalletAdditionalInfo = WalletAdditionalInfo(
|
||||
hideable = true,
|
||||
content = EMPTY_BALANCE_TEXT,
|
||||
)
|
||||
|
||||
private companion object {
|
||||
val defaultAdditionalInfo: WalletAdditionalInfo
|
||||
get() = WalletAdditionalInfo(hideable = true, content = EMPTY_BALANCE_TEXT)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ internal class FiatBalanceToWalletCardConverter(
|
|||
return WalletCardState.Error(
|
||||
id = id,
|
||||
title = title,
|
||||
additionalInfo = additionalInfo,
|
||||
imageResId = imageResId,
|
||||
onDeleteClick = onDeleteClick,
|
||||
onRenameClick = onRenameClick,
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import kotlinx.collections.immutable.ImmutableList
|
|||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.conflate
|
||||
|
||||
/**
|
||||
* Wallet notifications list factory
|
||||
|
|
@ -45,10 +46,10 @@ internal class WalletNotificationsListFactory(
|
|||
cryptoCurrencyList: List<CryptoCurrencyStatus>,
|
||||
): Flow<ImmutableList<WalletNotification>> {
|
||||
return combine(
|
||||
flow = wasCardScannedUseCase(cardTypesResolver.getCardId()),
|
||||
flow2 = isReadyToShowRateAppUseCase(),
|
||||
flow3 = isNeedToBackupUseCase(selectedWalletId),
|
||||
flow4 = getMissedAddressCryptoCurrenciesUseCase(selectedWalletId),
|
||||
flow = wasCardScannedUseCase(cardTypesResolver.getCardId()).conflate(),
|
||||
flow2 = isReadyToShowRateAppUseCase().conflate(),
|
||||
flow3 = isNeedToBackupUseCase(selectedWalletId).conflate(),
|
||||
flow4 = getMissedAddressCryptoCurrenciesUseCase(selectedWalletId).conflate(),
|
||||
) { wasCardScanned, isReadyToShowRating, isNeedToBackup, maybeMissedAddressCurrencies ->
|
||||
readyForRateAppNotification = true
|
||||
buildList {
|
||||
|
|
|
|||
|
|
@ -1014,6 +1014,7 @@ internal class WalletViewModel @Inject constructor(
|
|||
initAndSetupWc(tokenListFlow, wallet)
|
||||
|
||||
tokenListFlow
|
||||
.conflate()
|
||||
.distinctUntilChanged()
|
||||
.onEach { maybeTokenList ->
|
||||
uiState = stateFactory.getStateByTokensList(maybeTokenList.getTokenListWithWallet(wallet))
|
||||
|
|
@ -1119,6 +1120,7 @@ internal class WalletViewModel @Inject constructor(
|
|||
private fun getSingleCurrencyContent(index: Int) {
|
||||
val wallet = getWallet(index)
|
||||
getPrimaryCurrencyStatusUpdatesUseCase(wallet.walletId)
|
||||
.conflate()
|
||||
.distinctUntilChanged()
|
||||
.onEach { maybeCryptoCurrencyStatus ->
|
||||
uiState = stateFactory.getSingleCurrencyLoadedBalanceState(maybeCryptoCurrencyStatus)
|
||||
|
|
@ -1159,6 +1161,7 @@ internal class WalletViewModel @Inject constructor(
|
|||
val wallet = getWallet(walletIndex)
|
||||
|
||||
getCardTokensListUseCase(userWalletId = state.walletsListConfig.wallets[walletIndex].id)
|
||||
.conflate()
|
||||
.distinctUntilChanged()
|
||||
.onEach { maybeTokenList ->
|
||||
uiState = stateFactory.getStateByTokensList(maybeTokenList.getTokenListWithWallet(wallet))
|
||||
|
|
@ -1225,6 +1228,7 @@ internal class WalletViewModel @Inject constructor(
|
|||
|
||||
private fun updateButtons(userWalletId: UserWalletId, currencyStatus: CryptoCurrencyStatus) {
|
||||
getCryptoCurrencyActionsUseCase(userWalletId = userWalletId, cryptoCurrencyStatus = currencyStatus)
|
||||
.conflate()
|
||||
.distinctUntilChanged()
|
||||
.onEach { uiState = stateFactory.getSingleCurrencyManageButtonsState(actionsState = it) }
|
||||
.flowOn(dispatchers.io)
|
||||
|
|
@ -1249,6 +1253,7 @@ internal class WalletViewModel @Inject constructor(
|
|||
listOfNotNull(singleWalletCryptoCurrencyStatus)
|
||||
},
|
||||
)
|
||||
.conflate()
|
||||
.distinctUntilChanged()
|
||||
.onEach { uiState = stateFactory.getStateByNotifications(notifications = it) }
|
||||
.flowOn(dispatchers.io)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue