Updated on 2026-08-14

This commit is contained in:
Tangem 2024-05-22 15:48:14 +05:00
parent a204ef0bd6
commit 6d8bb28f02
6 changed files with 39 additions and 15 deletions

View file

@ -1,6 +1,7 @@
package com.tangem.features.send.impl.presentation.domain
import androidx.compose.runtime.Immutable
import com.tangem.domain.tokens.model.CryptoCurrency
import com.tangem.domain.wallets.models.UserWalletId
/**
@ -15,4 +16,5 @@ data class AvailableWallet(
val name: String,
val userWalletId: UserWalletId,
val address: String,
val cryptoCurrency: CryptoCurrency,
)

View file

@ -418,8 +418,11 @@ internal class SendViewModel @Inject constructor(
}
}
private suspend fun List<UserWallet>.toAvailableWallets(): List<AvailableWallet> =
filterNot { it.walletId == userWalletId || it.isLocked }
private suspend fun List<UserWallet>.toAvailableWallets(): List<AvailableWallet> {
val currentAddress: String = kotlin.runCatching {
cryptoCurrencyStatus.value.networkAddress?.defaultAddress?.value
}.getOrNull().orEmpty()
return filterNot { it.isLocked }
.mapNotNull { wallet ->
val addresses = if (!wallet.isMultiCurrency) {
getCryptoCurrencyUseCase(wallet.walletId).getOrNull()?.let {
@ -432,14 +435,18 @@ internal class SendViewModel @Inject constructor(
} else {
getNetworkAddressesUseCase.invokeSync(wallet.walletId, cryptoCurrency.network)
}
addresses?.map { address ->
AvailableWallet(
name = wallet.name,
address = address,
userWalletId = wallet.walletId,
)
}?.fastDistinctBy { it.address }
addresses
?.filter { it.address != currentAddress }
?.map { (cryptoCurrency, address) ->
AvailableWallet(
name = wallet.name,
address = address,
cryptoCurrency = cryptoCurrency,
userWalletId = wallet.walletId,
)
}?.fastDistinctBy { it.address }
}.flatten()
}
private suspend fun getTxHistory() {
val txHistoryList = getFixedTxHistoryItemsUseCase.getSync(