diff --git a/common/ui/src/main/java/com/tangem/common/ui/account/AccountPortfolioItemUMConverter.kt b/common/ui/src/main/java/com/tangem/common/ui/account/AccountPortfolioItemUMConverter.kt index 6bb24f24e3..150bc43608 100644 --- a/common/ui/src/main/java/com/tangem/common/ui/account/AccountPortfolioItemUMConverter.kt +++ b/common/ui/src/main/java/com/tangem/common/ui/account/AccountPortfolioItemUMConverter.kt @@ -48,7 +48,6 @@ class AccountPortfolioItemUMConverter( ) UserWalletItemUM.Information.Loaded(text) } - is Account.Payment -> TODO("[REDACTED_JIRA]") } private fun getImageState(account: Account.CryptoPortfolio) = when (account) { @@ -56,7 +55,6 @@ class AccountPortfolioItemUMConverter( name = account.accountName.toUM().value, icon = CryptoPortfolioIconConverter.convert(account.icon), ) - is Account.Payment -> TODO("[REDACTED_JIRA]") } private fun getBalanceInfo(): UserWalletItemUM.Balance { diff --git a/common/ui/src/main/java/com/tangem/common/ui/account/PortfolioSelectRow.kt b/common/ui/src/main/java/com/tangem/common/ui/account/PortfolioSelectRow.kt index e4575a197c..f45c250868 100644 --- a/common/ui/src/main/java/com/tangem/common/ui/account/PortfolioSelectRow.kt +++ b/common/ui/src/main/java/com/tangem/common/ui/account/PortfolioSelectRow.kt @@ -82,7 +82,7 @@ fun PortfolioSelectRow( @Immutable data class PortfolioSelectUM( - val icon: AccountIconUM.CryptoPortfolio?, + val icon: AccountIconUM?, val name: TextReference, val isAccountMode: Boolean, val isMultiChoice: Boolean, diff --git a/common/ui/src/main/java/com/tangem/common/ui/amountScreen/converters/AmountAccountConverter.kt b/common/ui/src/main/java/com/tangem/common/ui/amountScreen/converters/AmountAccountConverter.kt index ea09230bd7..d347bf2908 100644 --- a/common/ui/src/main/java/com/tangem/common/ui/amountScreen/converters/AmountAccountConverter.kt +++ b/common/ui/src/main/java/com/tangem/common/ui/amountScreen/converters/AmountAccountConverter.kt @@ -1,5 +1,6 @@ package com.tangem.common.ui.amountScreen.converters +import com.tangem.common.ui.account.AccountIconUM import com.tangem.common.ui.account.AccountTitleUM import com.tangem.common.ui.account.CryptoPortfolioIconConverter import com.tangem.common.ui.account.toUM @@ -11,12 +12,12 @@ class AmountAccountConverter( private val prefixText: TextReference, private val isAccountsMode: Boolean, private val walletTitle: TextReference, -) : Converter { - override fun convert(value: Account.CryptoPortfolio?): AccountTitleUM { +) : Converter { + override fun convert(value: Account?): AccountTitleUM { return if (value != null && isAccountsMode) { AccountTitleUM.Account( name = value.accountName.toUM().value, - icon = CryptoPortfolioIconConverter.convert(value.icon), + icon = getAccountIcon(account = value), prefixText = prefixText, ) } else { @@ -25,4 +26,11 @@ class AmountAccountConverter( ) } } + + private fun getAccountIcon(account: Account): AccountIconUM { + return when (account) { + is Account.CryptoPortfolio -> CryptoPortfolioIconConverter.convert(account.icon) + is Account.Payment -> AccountIconUM.Payment + } + } } \ No newline at end of file diff --git a/data/account/src/main/kotlin/com/tangem/data/account/producer/DefaultSingleAccountProducer.kt b/data/account/src/main/kotlin/com/tangem/data/account/producer/DefaultSingleAccountProducer.kt index 3471f7c173..b9bacb8d41 100644 --- a/data/account/src/main/kotlin/com/tangem/data/account/producer/DefaultSingleAccountProducer.kt +++ b/data/account/src/main/kotlin/com/tangem/data/account/producer/DefaultSingleAccountProducer.kt @@ -33,10 +33,10 @@ internal class DefaultSingleAccountProducer @AssistedInject constructor( private val dispatchers: CoroutineDispatcherProvider, ) : SingleAccountProducer { - override val fallback: Option + override val fallback: Option get() = none() - override fun produce(): Flow { + override fun produce(): Flow { return singleAccountListSupplier( params = SingleAccountListProducer.Params(userWalletId = params.accountId.userWalletId), ) diff --git a/data/account/src/test/java/com/tangem/data/account/repository/DefaultAccountsCRUDRepositoryTest.kt b/data/account/src/test/java/com/tangem/data/account/repository/DefaultAccountsCRUDRepositoryTest.kt index 0adcc20b4a..17a2f87acb 100644 --- a/data/account/src/test/java/com/tangem/data/account/repository/DefaultAccountsCRUDRepositoryTest.kt +++ b/data/account/src/test/java/com/tangem/data/account/repository/DefaultAccountsCRUDRepositoryTest.kt @@ -19,6 +19,7 @@ import com.tangem.datasource.api.tangemTech.models.account.WalletAccountDTO import com.tangem.datasource.local.datastore.RuntimeStateStore import com.tangem.domain.account.models.AccountList import com.tangem.domain.account.models.ArchivedAccount +import com.tangem.domain.models.account.Account import com.tangem.domain.models.account.Account.CryptoPortfolio import com.tangem.domain.models.account.AccountId import com.tangem.domain.models.account.AccountName diff --git a/data/swap/src/main/java/com/tangem/data/swap/DefaultSwapTransactionRepository.kt b/data/swap/src/main/java/com/tangem/data/swap/DefaultSwapTransactionRepository.kt index cbcb56f715..3734069fb2 100644 --- a/data/swap/src/main/java/com/tangem/data/swap/DefaultSwapTransactionRepository.kt +++ b/data/swap/src/main/java/com/tangem/data/swap/DefaultSwapTransactionRepository.kt @@ -60,8 +60,8 @@ internal class DefaultSwapTransactionRepository( userWalletId: UserWalletId, fromCryptoCurrency: CryptoCurrency, toCryptoCurrency: CryptoCurrency, - fromAccount: Account.CryptoPortfolio?, - toAccount: Account.CryptoPortfolio?, + fromAccount: Account?, + toAccount: Account?, transaction: SwapTransactionModel, ) { transaction.status?.let { swapTxList -> @@ -244,8 +244,8 @@ internal class DefaultSwapTransactionRepository( userWalletId: UserWalletId, fromCryptoCurrency: CryptoCurrency, toCryptoCurrency: CryptoCurrency, - fromAccount: Account.CryptoPortfolio?, - toAccount: Account.CryptoPortfolio?, + fromAccount: Account?, + toAccount: Account?, transactions: List, ): List { return addOrReplace( diff --git a/data/swap/src/main/java/com/tangem/data/swap/converter/transaction/SavedSwapTransactionListConverter.kt b/data/swap/src/main/java/com/tangem/data/swap/converter/transaction/SavedSwapTransactionListConverter.kt index 552341da60..aa9d27b4b7 100644 --- a/data/swap/src/main/java/com/tangem/data/swap/converter/transaction/SavedSwapTransactionListConverter.kt +++ b/data/swap/src/main/java/com/tangem/data/swap/converter/transaction/SavedSwapTransactionListConverter.kt @@ -101,8 +101,8 @@ internal class SavedSwapTransactionListConverter( userWalletId: UserWalletId, fromCryptoCurrency: CryptoCurrency, toCryptoCurrency: CryptoCurrency, - fromAccount: Account.CryptoPortfolio?, - toAccount: Account.CryptoPortfolio?, + fromAccount: Account?, + toAccount: Account?, tokenTransactions: List, ) = SwapTransactionListDTO( userWalletId = userWalletId.stringValue, diff --git a/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/sessions/DefaultWcSessionsManager.kt b/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/sessions/DefaultWcSessionsManager.kt index 848442eff1..8f37e4e4a1 100644 --- a/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/sessions/DefaultWcSessionsManager.kt +++ b/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/sessions/DefaultWcSessionsManager.kt @@ -9,6 +9,7 @@ import com.tangem.core.analytics.api.AnalyticsEventHandler import com.tangem.data.walletconnect.utils.* import com.tangem.datasource.local.walletconnect.WalletConnectStore import com.tangem.domain.account.featuretoggle.AccountsFeatureToggles +import com.tangem.domain.models.account.Account import com.tangem.domain.models.account.AccountId import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.walletconnect.WcAnalyticEvents @@ -116,7 +117,7 @@ internal class DefaultWcSessionsManager( val wcSessions = savedPending.plus(inStore).mapNotNull { storeSession -> val wallet = wallets.find { it.walletId == storeSession.walletId } ?: return@mapNotNull null val sdkSession = inSdk.find { it.topic == storeSession.topic } ?: return@mapNotNull null - val account = storeSession.accountId?.let { wcNetworksConverter.getAccount(it) } + val account = storeSession.accountId?.let { wcNetworksConverter.getAccount(it) } as? Account.CryptoPortfolio if (accountsFeatureToggles.isFeatureEnabled && account == null) { return@mapNotNull null } diff --git a/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/sign/WcSignUseCaseDelegate.kt b/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/sign/WcSignUseCaseDelegate.kt index 346ba94376..ebf56dafcf 100644 --- a/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/sign/WcSignUseCaseDelegate.kt +++ b/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/sign/WcSignUseCaseDelegate.kt @@ -5,7 +5,6 @@ import com.tangem.core.analytics.api.AnalyticsEventHandler import com.tangem.data.walletconnect.sign.SignStateConverter.toPreSign import com.tangem.data.walletconnect.sign.SignStateConverter.toResult import com.tangem.data.walletconnect.sign.SignStateConverter.toSigning -import com.tangem.domain.models.account.derivationIndex import com.tangem.domain.walletconnect.WcAnalyticEvents import com.tangem.domain.walletconnect.model.WcRequestError import com.tangem.domain.walletconnect.model.WcRequestError.Companion.code diff --git a/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/utils/WcNetworksConverter.kt b/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/utils/WcNetworksConverter.kt index 82a5b0beb2..d4b19d974a 100644 --- a/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/utils/WcNetworksConverter.kt +++ b/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/utils/WcNetworksConverter.kt @@ -13,6 +13,7 @@ import com.tangem.domain.account.supplier.SingleAccountSupplier import com.tangem.domain.models.account.Account import com.tangem.domain.models.account.AccountId import com.tangem.domain.models.account.AccountStatus +import com.tangem.domain.models.account.filterCryptoPortfolio import com.tangem.domain.models.currency.CryptoCurrency import com.tangem.domain.models.network.Network import com.tangem.domain.models.wallet.UserWallet @@ -146,10 +147,12 @@ internal class WcNetworksConverter @Inject constructor( .filterIsInstance().map(CryptoCurrency.Coin::network) } - private suspend fun getAccountStatus(accountId: AccountId): AccountStatus? { + private suspend fun getAccountStatus(accountId: AccountId): AccountStatus.CryptoPortfolio? { return singleAccountStatusListSupplier.getSyncOrNull( SingleAccountStatusListProducer.Params(accountId.userWalletId), - )?.accountStatuses?.find { it.account.accountId == accountId } + )?.accountStatuses + ?.filterCryptoPortfolio() + ?.find { it.account.accountId == accountId } } suspend fun getAccountNetworks(accountId: AccountId): List { diff --git a/domain/account/src/main/java/com/tangem/domain/account/models/AccountStatusList.kt b/domain/account/src/main/java/com/tangem/domain/account/models/AccountStatusList.kt index 8309ed3403..cc3b4c4204 100644 --- a/domain/account/src/main/java/com/tangem/domain/account/models/AccountStatusList.kt +++ b/domain/account/src/main/java/com/tangem/domain/account/models/AccountStatusList.kt @@ -5,6 +5,7 @@ import com.tangem.domain.models.TokensGroupType import com.tangem.domain.models.TokensSortType import com.tangem.domain.models.TotalFiatBalance import com.tangem.domain.models.account.AccountStatus +import com.tangem.domain.models.account.filterCryptoPortfolio import com.tangem.domain.models.currency.CryptoCurrencyStatus import com.tangem.domain.models.wallet.UserWalletId import kotlinx.serialization.Serializable @@ -33,13 +34,16 @@ data class AccountStatusList( ) { val mainAccount: AccountStatus.CryptoPortfolio - get() = accountStatuses.first { accountStatus -> - when (accountStatus) { - is AccountStatus.CryptoPortfolio -> accountStatus.account.isMainAccount + get() = accountStatuses + .filterCryptoPortfolio() + .first { accountStatus -> + when (accountStatus) { + is AccountStatus.CryptoPortfolio -> accountStatus.account.isMainAccount + } } - } as AccountStatus.CryptoPortfolio fun flattenCurrencies(): List = accountStatuses + .filterCryptoPortfolio() .map { accountStatus -> accountStatus.flattenCurrencies() } .flatten() diff --git a/domain/account/src/main/java/com/tangem/domain/account/producer/SingleAccountProducer.kt b/domain/account/src/main/java/com/tangem/domain/account/producer/SingleAccountProducer.kt index 541ce35936..76a318a696 100644 --- a/domain/account/src/main/java/com/tangem/domain/account/producer/SingleAccountProducer.kt +++ b/domain/account/src/main/java/com/tangem/domain/account/producer/SingleAccountProducer.kt @@ -5,10 +5,10 @@ import com.tangem.domain.models.account.Account import com.tangem.domain.models.account.AccountId /** - * Produces a flow of [Account.CryptoPortfolio] for a single account identified by [Params.accountId]. + * Produces a flow of [Account] for a single account identified by [Params.accountId]. * The flow emits updates whenever the account's portfolio changes. */ -interface SingleAccountProducer : FlowProducer { +interface SingleAccountProducer : FlowProducer { data class Params(val accountId: AccountId) diff --git a/domain/account/src/main/java/com/tangem/domain/account/repository/AccountsCRUDRepository.kt b/domain/account/src/main/java/com/tangem/domain/account/repository/AccountsCRUDRepository.kt index 59048e8fab..5e76e84653 100644 --- a/domain/account/src/main/java/com/tangem/domain/account/repository/AccountsCRUDRepository.kt +++ b/domain/account/src/main/java/com/tangem/domain/account/repository/AccountsCRUDRepository.kt @@ -28,7 +28,7 @@ interface AccountsCRUDRepository { * Retrieves a specific account by its unique identifier * * @param accountId the unique identifier of the account - * @return an [Option] containing the [Account.CryptoPortfolio] if found, or `Option.None` if not + * @return an [Option] containing the [Account] if found, or `Option.None` if not */ suspend fun getAccountSync(accountId: AccountId): Option diff --git a/domain/account/src/main/java/com/tangem/domain/account/supplier/SingleAccountSupplier.kt b/domain/account/src/main/java/com/tangem/domain/account/supplier/SingleAccountSupplier.kt index 527a32f557..2a87c8b14e 100644 --- a/domain/account/src/main/java/com/tangem/domain/account/supplier/SingleAccountSupplier.kt +++ b/domain/account/src/main/java/com/tangem/domain/account/supplier/SingleAccountSupplier.kt @@ -3,9 +3,12 @@ package com.tangem.domain.account.supplier import com.tangem.domain.account.producer.SingleAccountProducer import com.tangem.domain.core.flow.FlowCachingSupplier import com.tangem.domain.models.account.Account +import com.tangem.domain.models.account.AccountId +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.filterIsInstance /** - * Supplies instances of [SingleAccountProducer] that produce flows of [Account.CryptoPortfolio] + * Supplies instances of [SingleAccountProducer] that produce flows of [Account] * for individual accounts. Each producer is uniquely identified by its [SingleAccountProducer.Params]. * * @property factory A factory to create instances of [SingleAccountProducer]. @@ -14,4 +17,9 @@ import com.tangem.domain.models.account.Account abstract class SingleAccountSupplier( override val factory: SingleAccountProducer.Factory, override val keyCreator: (SingleAccountProducer.Params) -> String, -) : FlowCachingSupplier() \ No newline at end of file +) : FlowCachingSupplier() { + + fun filterPaymentAccount(accountId: AccountId): Flow { + return invoke(params = SingleAccountProducer.Params(accountId)).filterIsInstance() + } +} \ No newline at end of file diff --git a/domain/account/status/src/main/java/com/tangem/domain/account/status/producer/DefaultSingleAccountStatusListProducer.kt b/domain/account/status/src/main/java/com/tangem/domain/account/status/producer/DefaultSingleAccountStatusListProducer.kt index 956cc9e4ce..db4baa88fa 100644 --- a/domain/account/status/src/main/java/com/tangem/domain/account/status/producer/DefaultSingleAccountStatusListProducer.kt +++ b/domain/account/status/src/main/java/com/tangem/domain/account/status/producer/DefaultSingleAccountStatusListProducer.kt @@ -294,6 +294,7 @@ internal class DefaultSingleAccountStatusListProducer @AssistedInject constructo return map { accountStatus -> when (accountStatus) { is AccountStatus.CryptoPortfolio -> accountStatus.tokenList.totalFiatBalance + is AccountStatus.Payment -> accountStatus.totalFiatBalance } } } diff --git a/domain/account/status/src/main/java/com/tangem/domain/account/status/usecase/ArchiveCryptoPortfolioUseCase.kt b/domain/account/status/src/main/java/com/tangem/domain/account/status/usecase/ArchiveCryptoPortfolioUseCase.kt index 7a0c57b6ac..de9a515a80 100644 --- a/domain/account/status/src/main/java/com/tangem/domain/account/status/usecase/ArchiveCryptoPortfolioUseCase.kt +++ b/domain/account/status/src/main/java/com/tangem/domain/account/status/usecase/ArchiveCryptoPortfolioUseCase.kt @@ -9,7 +9,7 @@ import com.tangem.domain.account.repository.AccountsCRUDRepository import com.tangem.domain.account.status.producer.SingleAccountStatusListProducer import com.tangem.domain.account.status.supplier.SingleAccountStatusListSupplier import com.tangem.domain.models.account.AccountId -import com.tangem.domain.models.account.AccountStatus +import com.tangem.domain.models.account.filterCryptoPortfolio import com.tangem.domain.models.currency.CryptoCurrency import com.tangem.domain.models.wallet.UserWalletId import com.tangem.domain.referral.ReferralRepository @@ -68,7 +68,7 @@ class ArchiveCryptoPortfolioUseCase( val account = accountStatusList.accountStatuses .asSequence() - .filterIsInstance() + .filterCryptoPortfolio() .firstOrNull { it.accountId == accountId } ensureNotNull(account) { diff --git a/domain/account/status/src/main/java/com/tangem/domain/account/status/usecase/ToggleTokenListGroupingUseCaseV2.kt b/domain/account/status/src/main/java/com/tangem/domain/account/status/usecase/ToggleTokenListGroupingUseCaseV2.kt index 3583eee3d2..32e1b28366 100644 --- a/domain/account/status/src/main/java/com/tangem/domain/account/status/usecase/ToggleTokenListGroupingUseCaseV2.kt +++ b/domain/account/status/src/main/java/com/tangem/domain/account/status/usecase/ToggleTokenListGroupingUseCaseV2.kt @@ -48,10 +48,12 @@ class ToggleTokenListGroupingUseCaseV2( account.copy(tokenList = account.tokenList.reverseGroupType()) } + val updatedCryptoAccount = + updatedAccountList.firstOrNull { it is AccountStatus.CryptoPortfolio } as? AccountStatus.CryptoPortfolio accountStatusList.copy( accountStatuses = updatedAccountList, - groupType = when (updatedAccountList.firstOrNull()?.getCryptoTokenList()) { + groupType = when (updatedCryptoAccount?.tokenList) { is TokenList.GroupedByNetwork -> TokensGroupType.NETWORK is TokenList.Ungrouped -> TokensGroupType.NONE else -> accountStatusList.groupType diff --git a/domain/account/status/src/main/java/com/tangem/domain/account/status/utils/AccountCryptoCurrencyStatusFinder.kt b/domain/account/status/src/main/java/com/tangem/domain/account/status/utils/AccountCryptoCurrencyStatusFinder.kt index dc33b171dd..fe5daf41d0 100644 --- a/domain/account/status/src/main/java/com/tangem/domain/account/status/utils/AccountCryptoCurrencyStatusFinder.kt +++ b/domain/account/status/src/main/java/com/tangem/domain/account/status/utils/AccountCryptoCurrencyStatusFinder.kt @@ -7,6 +7,7 @@ import com.tangem.domain.account.status.model.AccountCryptoCurrencyStatuses import com.tangem.domain.models.account.Account import com.tangem.domain.models.account.AccountStatus import com.tangem.domain.models.account.DerivationIndex +import com.tangem.domain.models.account.filterCryptoPortfolio import com.tangem.domain.models.currency.CryptoCurrency import com.tangem.domain.models.network.Network import com.tangem.lib.crypto.derivation.AccountNodeRecognizer @@ -49,7 +50,7 @@ internal object AccountCryptoCurrencyStatusFinder { ): AccountCryptoCurrencyStatus? { return accountStatusList.getExpectedAccountStatuses(network) .asSequence() - .filterIsInstance() + .filterCryptoPortfolio() .mapNotNull { accountStatus -> val status = accountStatus.flattenCurrencies().firstOrNull { it.currency.id == currencyId } ?: return@mapNotNull null @@ -78,7 +79,7 @@ internal object AccountCryptoCurrencyStatusFinder { return accountStatusList.getExpectedAccountStatuses(networks) .asSequence() - .filterIsInstance() + .filterCryptoPortfolio() .associate { accountStatus -> val statuses = accountStatus.flattenCurrencies() .filter { it.currency.id in currencyIds } @@ -108,7 +109,7 @@ internal object AccountCryptoCurrencyStatusFinder { derivationPath = derivationPath, ) .asSequence() - .filterIsInstance() + .filterCryptoPortfolio() .mapNotNull { accountStatus -> val status = accountStatus.flattenCurrencies().firstOrNull { val currency = it.currency @@ -156,8 +157,8 @@ internal object AccountCryptoCurrencyStatusFinder { DerivationIndex.Main.value -> listOf(mainAccount) // currency only in the account with specific derivation index or in the main account else -> { - val accountStatus = accountStatuses.firstOrNull { - val cryptoPortfolio = it.account as? Account.CryptoPortfolio ?: return@firstOrNull false + val accountStatus = accountStatuses.firstOrNull { accountStatus -> + val cryptoPortfolio = accountStatus.account as? Account.CryptoPortfolio ?: return@firstOrNull false cryptoPortfolio.derivationIndex.value == possibleAccountIndex } @@ -172,8 +173,8 @@ internal object AccountCryptoCurrencyStatusFinder { if (possibleAccountIndexes.isEmpty()) return this@getExpectedAccountStatuses.accountStatuses - val accountStatuses = this@getExpectedAccountStatuses.accountStatuses.filter { - val cryptoPortfolio = it.account as? Account.CryptoPortfolio ?: return@filter false + val accountStatuses = this@getExpectedAccountStatuses.accountStatuses.filter { accountStatus -> + val cryptoPortfolio = accountStatus.account as? Account.CryptoPortfolio ?: return@filter false cryptoPortfolio.derivationIndex.value in possibleAccountIndexes } diff --git a/domain/models/src/main/kotlin/com/tangem/domain/models/account/Account.kt b/domain/models/src/main/kotlin/com/tangem/domain/models/account/Account.kt index 851c25e463..017f431065 100644 --- a/domain/models/src/main/kotlin/com/tangem/domain/models/account/Account.kt +++ b/domain/models/src/main/kotlin/com/tangem/domain/models/account/Account.kt @@ -109,7 +109,7 @@ sealed interface Account { raise(AccountNameError(cause = it)) } - val derivationIndex = DerivationIndex(value = derivationIndex).getOrElse { + val index = DerivationIndex(value = derivationIndex).getOrElse { raise(DerivationIndexError(cause = it)) } @@ -117,7 +117,7 @@ sealed interface Account { accountId = accountId, accountName = accountName, icon = icon, - derivationIndex = derivationIndex, + derivationIndex = index, cryptoCurrencies = cryptoCurrencies, ) } @@ -175,11 +175,12 @@ sealed interface Account { } } - class Payment : Account { - override val accountId: AccountId - get() = TODO("Not yet implemented") - override val accountName: AccountName - get() = TODO("Not yet implemented") + @Serializable + data class Payment( + override val accountId: AccountId, + override val accountName: AccountName, + val cryptoCurrencies: List, + ) : Account { init { error("Not yet implemented") @@ -190,5 +191,5 @@ sealed interface Account { val Account.derivationIndex: DerivationIndex? get() = when (this) { is Account.CryptoPortfolio -> derivationIndex - is Account.Payment -> TODO("[REDACTED_JIRA]") + is Account.Payment -> null } \ No newline at end of file diff --git a/domain/models/src/main/kotlin/com/tangem/domain/models/account/AccountId.kt b/domain/models/src/main/kotlin/com/tangem/domain/models/account/AccountId.kt index bffd56a6c4..0c65375595 100644 --- a/domain/models/src/main/kotlin/com/tangem/domain/models/account/AccountId.kt +++ b/domain/models/src/main/kotlin/com/tangem/domain/models/account/AccountId.kt @@ -71,5 +71,9 @@ data class AccountId private constructor( return AccountId(value = value, userWalletId = userWalletId) } + + fun forPaymentAccount(userWalletId: UserWalletId): AccountId { + return AccountId(value = "payment_$userWalletId", userWalletId = userWalletId) + } } } \ No newline at end of file diff --git a/domain/models/src/main/kotlin/com/tangem/domain/models/account/AccountStatus.kt b/domain/models/src/main/kotlin/com/tangem/domain/models/account/AccountStatus.kt index b04e872b58..31df2e7281 100644 --- a/domain/models/src/main/kotlin/com/tangem/domain/models/account/AccountStatus.kt +++ b/domain/models/src/main/kotlin/com/tangem/domain/models/account/AccountStatus.kt @@ -1,6 +1,7 @@ package com.tangem.domain.models.account import com.tangem.domain.core.lce.Lce +import com.tangem.domain.models.TotalFiatBalance import com.tangem.domain.models.currency.CryptoCurrencyStatus import com.tangem.domain.models.quote.PriceChange import com.tangem.domain.models.tokenlist.TokenList @@ -33,13 +34,23 @@ sealed interface AccountStatus { override val account: Account.CryptoPortfolio, val tokenList: TokenList, val priceChangeLce: Lce, + ) : AccountStatus { + fun flattenCurrencies(): List { + return tokenList.flattenCurrencies() + } + } + + @Serializable + data class Payment( + override val account: Account.Payment, + val totalFiatBalance: TotalFiatBalance, ) : AccountStatus +} - fun flattenCurrencies(): List = when (this) { - is CryptoPortfolio -> tokenList.flattenCurrencies() - } +fun Iterable.filterCryptoPortfolio(): List { + return filterIsInstance() +} - fun getCryptoTokenList(): TokenList = when (this) { - is CryptoPortfolio -> tokenList - } +fun Sequence.filterCryptoPortfolio(): Sequence { + return filterIsInstance() } \ No newline at end of file diff --git a/domain/swap/models/src/main/java/com/tangem/domain/swap/models/SwapTransactionListModel.kt b/domain/swap/models/src/main/java/com/tangem/domain/swap/models/SwapTransactionListModel.kt index 89edac21b3..5c8e52d327 100644 --- a/domain/swap/models/src/main/java/com/tangem/domain/swap/models/SwapTransactionListModel.kt +++ b/domain/swap/models/src/main/java/com/tangem/domain/swap/models/SwapTransactionListModel.kt @@ -14,8 +14,8 @@ data class SwapTransactionListModel( val toCryptoCurrencyId: String, val fromCryptoCurrency: CryptoCurrency, val toCryptoCurrency: CryptoCurrency, - val fromAccount: Account.CryptoPortfolio?, - val toAccount: Account.CryptoPortfolio?, + val fromAccount: Account?, + val toAccount: Account?, val transactions: List, ) diff --git a/domain/swap/src/main/java/com/tangem/domain/swap/SwapTransactionRepository.kt b/domain/swap/src/main/java/com/tangem/domain/swap/SwapTransactionRepository.kt index 7fe9292ea2..3e22c172a7 100644 --- a/domain/swap/src/main/java/com/tangem/domain/swap/SwapTransactionRepository.kt +++ b/domain/swap/src/main/java/com/tangem/domain/swap/SwapTransactionRepository.kt @@ -30,8 +30,8 @@ interface SwapTransactionRepository { userWalletId: UserWalletId, fromCryptoCurrency: CryptoCurrency, toCryptoCurrency: CryptoCurrency, - fromAccount: Account.CryptoPortfolio?, - toAccount: Account.CryptoPortfolio?, + fromAccount: Account?, + toAccount: Account?, transaction: SwapTransactionModel, ) diff --git a/domain/swap/src/main/java/com/tangem/domain/swap/usecase/SwapTransactionSentUseCase.kt b/domain/swap/src/main/java/com/tangem/domain/swap/usecase/SwapTransactionSentUseCase.kt index 92fcc325e3..70c9811d57 100644 --- a/domain/swap/src/main/java/com/tangem/domain/swap/usecase/SwapTransactionSentUseCase.kt +++ b/domain/swap/src/main/java/com/tangem/domain/swap/usecase/SwapTransactionSentUseCase.kt @@ -22,8 +22,8 @@ class SwapTransactionSentUseCase( userWallet: UserWallet, fromCryptoCurrencyStatus: CryptoCurrencyStatus, toCryptoCurrencyStatus: CryptoCurrencyStatus, - fromAccount: Account.CryptoPortfolio?, - toAccount: Account.CryptoPortfolio?, + fromAccount: Account?, + toAccount: Account?, swapDataTransactionModel: SwapDataTransactionModel, provider: ExpressProvider, txHash: String, diff --git a/domain/wallet-connect/models/src/main/java/com/tangem/domain/walletconnect/model/WcSession.kt b/domain/wallet-connect/models/src/main/java/com/tangem/domain/walletconnect/model/WcSession.kt index 49ae45531a..cf3f4c9f37 100644 --- a/domain/wallet-connect/models/src/main/java/com/tangem/domain/walletconnect/model/WcSession.kt +++ b/domain/wallet-connect/models/src/main/java/com/tangem/domain/walletconnect/model/WcSession.kt @@ -8,7 +8,7 @@ import com.tangem.domain.models.wallet.UserWallet data class WcSession( val wallet: UserWallet, - val account: Account?, + val account: Account.CryptoPortfolio?, val networks: Set, val sdkModel: WcSdkSession, val securityStatus: CheckDAppResult, diff --git a/features/account/api/src/main/java/com/tangem/features/account/PortfolioSelectorComponent.kt b/features/account/api/src/main/java/com/tangem/features/account/PortfolioSelectorComponent.kt index 50c01a8d05..7d8627e929 100644 --- a/features/account/api/src/main/java/com/tangem/features/account/PortfolioSelectorComponent.kt +++ b/features/account/api/src/main/java/com/tangem/features/account/PortfolioSelectorComponent.kt @@ -60,5 +60,7 @@ interface PortfolioSelectorController { suspend fun isAccountModeSync(): Boolean fun selectAccount(accountId: AccountId?) - fun selectedAccountWithData(portfolioFetcher: PortfolioFetcher): Flow?> + fun selectedAccountWithData( + portfolioFetcher: PortfolioFetcher, + ): Flow?> } \ No newline at end of file diff --git a/features/account/impl/src/main/java/com/tangem/features/account/selector/DefaultPortfolioSelectorController.kt b/features/account/impl/src/main/java/com/tangem/features/account/selector/DefaultPortfolioSelectorController.kt index fe9a055c3f..c125505737 100644 --- a/features/account/impl/src/main/java/com/tangem/features/account/selector/DefaultPortfolioSelectorController.kt +++ b/features/account/impl/src/main/java/com/tangem/features/account/selector/DefaultPortfolioSelectorController.kt @@ -3,6 +3,7 @@ package com.tangem.features.account.selector import com.tangem.domain.account.usecase.IsAccountsModeEnabledUseCase import com.tangem.domain.models.account.AccountId import com.tangem.domain.models.account.AccountStatus +import com.tangem.domain.models.account.filterCryptoPortfolio import com.tangem.domain.models.wallet.UserWallet import com.tangem.features.account.PortfolioFetcher import com.tangem.features.account.PortfolioSelectorController @@ -35,21 +36,23 @@ internal class DefaultPortfolioSelectorController @Inject constructor( _selectedAccount.tryEmit(accountId) } - override fun selectedAccountWithData(portfolioFetcher: PortfolioFetcher): Flow?> = - combine( - flow = _selectedAccount, - flow2 = portfolioFetcher.data, - transform = { accountId, data -> - accountId ?: return@combine null - var result: Pair? = null + override fun selectedAccountWithData( + portfolioFetcher: PortfolioFetcher, + ): Flow?> = combine( + flow = _selectedAccount, + flow2 = portfolioFetcher.data, + transform = { accountId, data -> + accountId ?: return@combine null + var result: Pair? = null - data.balances.forEach { wallet, balance -> - val accountStatuses = balance.accountsBalance.accountStatuses - .find { accountId == it.account.accountId } - if (accountStatuses != null) result = balance.userWallet to accountStatuses - } + data.balances.forEach { wallet, balance -> + val accountStatuses = balance.accountsBalance.accountStatuses + .filterCryptoPortfolio() + .find { accountId == it.account.accountId } + if (accountStatuses != null) result = balance.userWallet to accountStatuses + } - return@combine result - }, - ) + return@combine result + }, + ) } \ No newline at end of file diff --git a/features/account/impl/src/main/java/com/tangem/features/account/selector/PortfolioSelectorModel.kt b/features/account/impl/src/main/java/com/tangem/features/account/selector/PortfolioSelectorModel.kt index fc13e4df56..d7e351ff96 100644 --- a/features/account/impl/src/main/java/com/tangem/features/account/selector/PortfolioSelectorModel.kt +++ b/features/account/impl/src/main/java/com/tangem/features/account/selector/PortfolioSelectorModel.kt @@ -184,6 +184,7 @@ internal class PortfolioSelectorModel @Inject constructor( val account = accountStatus.account val accountBalance = when (accountStatus) { is AccountStatus.CryptoPortfolio -> accountStatus.tokenList.totalFiatBalance + is AccountStatus.Payment -> accountStatus.totalFiatBalance } val accountItemUM = AccountPortfolioItemUMConverter( onClick = { selectorController.selectAccount(account.accountId) }, diff --git a/features/feed/impl/src/main/kotlin/com/tangem/features/feed/components/market/details/portfolio/add/impl/model/AddToPortfolioModel.kt b/features/feed/impl/src/main/kotlin/com/tangem/features/feed/components/market/details/portfolio/add/impl/model/AddToPortfolioModel.kt index a06d46878d..e234d1d2f6 100644 --- a/features/feed/impl/src/main/kotlin/com/tangem/features/feed/components/market/details/portfolio/add/impl/model/AddToPortfolioModel.kt +++ b/features/feed/impl/src/main/kotlin/com/tangem/features/feed/components/market/details/portfolio/add/impl/model/AddToPortfolioModel.kt @@ -325,6 +325,7 @@ internal class AddToPortfolioModel @Inject constructor( ): CryptoCurrency? { val accountIndex = when (val accountStatus = account.account) { is AccountStatus.CryptoPortfolio -> accountStatus.account.derivationIndex + is AccountStatus.Payment -> TODO("[REDACTED_JIRA]") } return getTokenMarketCryptoCurrency( userWalletId = userWallet.walletId, diff --git a/features/feed/impl/src/main/kotlin/com/tangem/features/feed/components/market/details/portfolio/add/impl/model/AddToPortfolioPreselectedDataModel.kt b/features/feed/impl/src/main/kotlin/com/tangem/features/feed/components/market/details/portfolio/add/impl/model/AddToPortfolioPreselectedDataModel.kt index c6b6d1b45a..8beb2880d3 100644 --- a/features/feed/impl/src/main/kotlin/com/tangem/features/feed/components/market/details/portfolio/add/impl/model/AddToPortfolioPreselectedDataModel.kt +++ b/features/feed/impl/src/main/kotlin/com/tangem/features/feed/components/market/details/portfolio/add/impl/model/AddToPortfolioPreselectedDataModel.kt @@ -174,6 +174,7 @@ internal class AddToPortfolioPreselectedDataModel @Inject constructor( val availableToAddAccounts = accounts.mapNotNull { accountStatus -> val accountIndex = when (accountStatus) { is AccountStatus.CryptoPortfolio -> accountStatus.account.derivationIndex + is AccountStatus.Payment -> TODO("[REDACTED_JIRA]") } val cryptoCurrency = getTokenMarketCryptoCurrency( @@ -220,6 +221,7 @@ internal class AddToPortfolioPreselectedDataModel @Inject constructor( ): CryptoCurrency? { val accountIndex = when (val accountStatus = account.account) { is AccountStatus.CryptoPortfolio -> accountStatus.account.derivationIndex + is AccountStatus.Payment -> TODO("[REDACTED_JIRA]") } return getTokenMarketCryptoCurrency( userWalletId = userWallet.walletId, diff --git a/features/feed/impl/src/main/kotlin/com/tangem/features/feed/components/market/details/portfolio/add/impl/model/AddTokenUiBuilder.kt b/features/feed/impl/src/main/kotlin/com/tangem/features/feed/components/market/details/portfolio/add/impl/model/AddTokenUiBuilder.kt index 5d5c7e379e..2055a204ab 100644 --- a/features/feed/impl/src/main/kotlin/com/tangem/features/feed/components/market/details/portfolio/add/impl/model/AddTokenUiBuilder.kt +++ b/features/feed/impl/src/main/kotlin/com/tangem/features/feed/components/market/details/portfolio/add/impl/model/AddTokenUiBuilder.kt @@ -13,7 +13,7 @@ import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.iconResId import com.tangem.core.ui.extensions.resourceReference import com.tangem.core.ui.extensions.stringReference -import com.tangem.domain.models.account.AccountStatus +import com.tangem.domain.models.account.AccountStatus.* import com.tangem.features.feed.components.market.details.portfolio.add.SelectedNetwork import com.tangem.features.feed.components.market.details.portfolio.add.SelectedPortfolio import com.tangem.features.feed.components.market.details.portfolio.add.impl.AddTokenComponent @@ -36,7 +36,7 @@ internal class AddTokenUiBuilder @Inject constructor( } private fun createPortfolio(selectedPortfolio: SelectedPortfolio): PortfolioSelectUM { - val accountIcon: AccountIconUM.CryptoPortfolio? + val accountIcon: AccountIconUM? val portfolioName: TextReference when (selectedPortfolio.isAccountMode) { false -> { @@ -47,7 +47,8 @@ internal class AddTokenUiBuilder @Inject constructor( val accountStatus = selectedPortfolio.account.account portfolioName = accountStatus.account.accountName.toUM().value accountIcon = when (accountStatus) { - is AccountStatus.CryptoPortfolio -> CryptoPortfolioIconConverter.convert(accountStatus.account.icon) + is CryptoPortfolio -> CryptoPortfolioIconConverter.convert(accountStatus.account.icon) + is Payment -> AccountIconUM.Payment } } } diff --git a/features/feed/impl/src/main/kotlin/com/tangem/features/feed/components/market/details/portfolio/impl/model/NewMarketsPortfolioDelegate.kt b/features/feed/impl/src/main/kotlin/com/tangem/features/feed/components/market/details/portfolio/impl/model/NewMarketsPortfolioDelegate.kt index 21a34d471c..2df91aab47 100644 --- a/features/feed/impl/src/main/kotlin/com/tangem/features/feed/components/market/details/portfolio/impl/model/NewMarketsPortfolioDelegate.kt +++ b/features/feed/impl/src/main/kotlin/com/tangem/features/feed/components/market/details/portfolio/impl/model/NewMarketsPortfolioDelegate.kt @@ -202,6 +202,7 @@ internal class NewMarketsPortfolioDelegate @AssistedInject constructor( val currencyId = status.currency.id.rawCurrencyId ?: return@filter false getTokenIdIfL2Network(currencyId.value) == currencyRawId.value } + is AccountStatus.Payment -> TODO("[REDACTED_JIRA]") } return accountStatuses.map { accountStatus -> AccountWithAdded( diff --git a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/model/CustomTokenSelectorModel.kt b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/model/CustomTokenSelectorModel.kt index 2cbfe3dc7a..7aa77b2a2b 100644 --- a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/model/CustomTokenSelectorModel.kt +++ b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/model/CustomTokenSelectorModel.kt @@ -214,9 +214,10 @@ internal class CustomTokenSelectorModel @Inject constructor( val accounts = singleAccountStatusListSupplier(mode.userWalletId) .first().accountStatuses - val accountStatus = accounts.find { - when (it) { - is AccountStatus.CryptoPortfolio -> it.sameNodeAndNotMain() + val accountStatus = accounts.find { account -> + when (account) { + is AccountStatus.CryptoPortfolio -> account.sameNodeAndNotMain() + is AccountStatus.Payment -> TODO("[REDACTED_JIRA]") } } diff --git a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/utils/list/ManageTokensUseCasesFacade.kt b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/utils/list/ManageTokensUseCasesFacade.kt index c3fe0bf606..7bf8e67db0 100644 --- a/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/utils/list/ManageTokensUseCasesFacade.kt +++ b/features/manage-tokens/impl/src/main/kotlin/com/tangem/features/managetokens/utils/list/ManageTokensUseCasesFacade.kt @@ -12,6 +12,7 @@ import com.tangem.domain.managetokens.model.CurrencyUnsupportedState import com.tangem.domain.managetokens.model.ManageTokensListConfig import com.tangem.domain.managetokens.model.ManagedCryptoCurrency import com.tangem.domain.managetokens.repository.CustomTokensRepository +import com.tangem.domain.models.account.Account import com.tangem.domain.models.currency.CryptoCurrency import com.tangem.domain.models.network.Network import com.tangem.domain.models.wallet.UserWalletId @@ -88,7 +89,7 @@ internal class ManageTokensUseCasesFacade @AssistedInject constructor( val account = singleAccountSupplier.getSyncOrNull( params = SingleAccountProducer.Params(accountId = mode.accountId), - ) + ) as? Account.CryptoPortfolio ?: return IllegalStateException("Account not found").left() (account.cryptoCurrencies + added - removed).any { diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/model/AddToPortfolioModel.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/model/AddToPortfolioModel.kt index 6b0fd6a169..142c66cf7a 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/model/AddToPortfolioModel.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/model/AddToPortfolioModel.kt @@ -315,6 +315,7 @@ internal class AddToPortfolioModel @Inject constructor( ): CryptoCurrency? { val accountIndex = when (account.account) { is AccountStatus.CryptoPortfolio -> account.account.account.derivationIndex + is AccountStatus.Payment -> TODO("[REDACTED_JIRA]") } return getTokenMarketCryptoCurrency( userWalletId = userWallet.walletId, diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/model/AddTokenUiBuilder.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/model/AddTokenUiBuilder.kt index 107c7a8c3b..ec88d88216 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/model/AddTokenUiBuilder.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/add/impl/model/AddTokenUiBuilder.kt @@ -13,7 +13,7 @@ import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.iconResId import com.tangem.core.ui.extensions.resourceReference import com.tangem.core.ui.extensions.stringReference -import com.tangem.domain.models.account.AccountStatus +import com.tangem.domain.models.account.AccountStatus.* import com.tangem.features.markets.impl.R import com.tangem.features.markets.portfolio.add.api.SelectedNetwork import com.tangem.features.markets.portfolio.add.api.SelectedPortfolio @@ -36,7 +36,7 @@ internal class AddTokenUiBuilder @Inject constructor( } private fun createPortfolio(selectedPortfolio: SelectedPortfolio): PortfolioSelectUM { - val accountIcon: AccountIconUM.CryptoPortfolio? + val accountIcon: AccountIconUM? val portfolioName: TextReference when (selectedPortfolio.isAccountMode) { false -> { @@ -47,7 +47,8 @@ internal class AddTokenUiBuilder @Inject constructor( val accountStatus = selectedPortfolio.account.account portfolioName = accountStatus.account.accountName.toUM().value accountIcon = when (accountStatus) { - is AccountStatus.CryptoPortfolio -> CryptoPortfolioIconConverter.convert(accountStatus.account.icon) + is CryptoPortfolio -> CryptoPortfolioIconConverter.convert(accountStatus.account.icon) + is Payment -> AccountIconUM.Payment } } } diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/NewMarketsPortfolioDelegate.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/NewMarketsPortfolioDelegate.kt index 286e1dc18e..17acbaf94a 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/NewMarketsPortfolioDelegate.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/NewMarketsPortfolioDelegate.kt @@ -203,6 +203,7 @@ internal class NewMarketsPortfolioDelegate @AssistedInject constructor( val currencyId = status.currency.id.rawCurrencyId ?: return@filter false getTokenIdIfL2Network(currencyId.value) == currencyRawId.value } + is AccountStatus.Payment -> TODO("[REDACTED_JIRA]") } return accountStatuses.map { accountStatus -> AccountWithAdded( diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/hottokens/model/HotCryptoPortfolioDataLoader.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/hottokens/model/HotCryptoPortfolioDataLoader.kt index 961019b158..d49f018ad2 100644 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/hottokens/model/HotCryptoPortfolioDataLoader.kt +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/hottokens/model/HotCryptoPortfolioDataLoader.kt @@ -45,6 +45,7 @@ internal class HotCryptoPortfolioDataLoader @Inject constructor( val accountsWithHotCrypto = walletAccounts.accountStatuses.map { accountStatus -> val account: AccountStatus.CryptoPortfolio = when (accountStatus) { is AccountStatus.CryptoPortfolio -> accountStatus + is AccountStatus.Payment -> TODO("[REDACTED_JIRA]") } val addedHotCrypto = mapOfAddedCurrencies[account.account].orEmpty() HotCryptoPortfolioData.Account( diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/hottokens/portfolio/entity/OnrampAddTokenUiBuilder.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/hottokens/portfolio/entity/OnrampAddTokenUiBuilder.kt index a7b415212a..ac1f747c49 100644 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/hottokens/portfolio/entity/OnrampAddTokenUiBuilder.kt +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/hottokens/portfolio/entity/OnrampAddTokenUiBuilder.kt @@ -37,7 +37,7 @@ internal class OnrampAddTokenUiBuilder @Inject constructor( } private suspend fun createPortfolio(tokenToAdd: AddHotCryptoData): PortfolioSelectUM { - val accountIcon: AccountIconUM.CryptoPortfolio? + val accountIcon: AccountIconUM? val portfolioName: TextReference val isAccountMode = isAccountsModeEnabledUseCase.invokeSync() when (isAccountMode) { @@ -50,6 +50,7 @@ internal class OnrampAddTokenUiBuilder @Inject constructor( portfolioName = accountStatus.account.accountName.toUM().value accountIcon = when (accountStatus) { is AccountStatus.CryptoPortfolio -> CryptoPortfolioIconConverter.convert(accountStatus.account.icon) + is AccountStatus.Payment -> AccountIconUM.Payment } } } diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/swap/availablepairs/entity/converters/LoadingAccountTokenItemConverter.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/swap/availablepairs/entity/converters/LoadingAccountTokenItemConverter.kt index 9489858928..8040f59244 100644 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/swap/availablepairs/entity/converters/LoadingAccountTokenItemConverter.kt +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/swap/availablepairs/entity/converters/LoadingAccountTokenItemConverter.kt @@ -23,7 +23,9 @@ internal class LoadingAccountTokenItemConverter( ).convert(TotalFiatBalance.Failed), isExpanded = true, isCollapsable = false, - tokens = currencies.flattenCurrencies().map(LoadingTokenListItemConverter::convert).toPersistentList(), + tokens = currencies.flattenCurrencies() + .map { LoadingTokenListItemConverter.convert(it.currency) } + .toPersistentList(), ) } } \ No newline at end of file diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/swap/availablepairs/entity/converters/LoadingTokenListItemConverter.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/swap/availablepairs/entity/converters/LoadingTokenListItemConverter.kt index 55e336791d..68932d0f66 100644 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/swap/availablepairs/entity/converters/LoadingTokenListItemConverter.kt +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/swap/availablepairs/entity/converters/LoadingTokenListItemConverter.kt @@ -3,6 +3,7 @@ package com.tangem.features.onramp.swap.availablepairs.entity.converters import com.tangem.core.ui.components.currency.icon.CurrencyIconState import com.tangem.core.ui.components.token.state.TokenItemState import com.tangem.core.ui.components.tokenlist.state.TokensListItemUM +import com.tangem.domain.models.currency.CryptoCurrency import com.tangem.domain.models.currency.CryptoCurrencyStatus import com.tangem.utils.converter.Converter @@ -11,12 +12,12 @@ import com.tangem.utils.converter.Converter * [REDACTED_AUTHOR] */ -internal object LoadingTokenListItemConverter : Converter { +internal object LoadingTokenListItemConverter : Converter { - override fun convert(value: CryptoCurrencyStatus): TokensListItemUM.Token { + override fun convert(value: CryptoCurrency): TokensListItemUM.Token { return TokensListItemUM.Token( state = TokenItemState.Loading( - id = value.currency.id.value, + id = value.id.value, iconState = CurrencyIconState.Loading, titleState = TokenItemState.TitleState.Loading, subtitleState = TokenItemState.SubtitleState.Loading, diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/swap/availablepairs/entity/transformers/SetLoadingTokenItemsTransformer.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/swap/availablepairs/entity/transformers/SetLoadingTokenItemsTransformer.kt index ccf527232b..02b9d632dc 100644 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/swap/availablepairs/entity/transformers/SetLoadingTokenItemsTransformer.kt +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/swap/availablepairs/entity/transformers/SetLoadingTokenItemsTransformer.kt @@ -18,7 +18,9 @@ internal class SetLoadingTokenItemsTransformer( override fun transform(prevState: TokenListUM): TokenListUM { return prevState.copy( - availableItems = LoadingTokenListItemConverter.convertList(input = statuses).toImmutableList(), + availableItems = LoadingTokenListItemConverter.convertList( + input = statuses.map(CryptoCurrencyStatus::currency), + ).toImmutableList(), unavailableItems = persistentListOf(), warning = null, ) diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/swap/availablepairs/model/AvailableSwapPairsModel.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/swap/availablepairs/model/AvailableSwapPairsModel.kt index 84d7dc9a8f..5466084880 100644 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/swap/availablepairs/model/AvailableSwapPairsModel.kt +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/swap/availablepairs/model/AvailableSwapPairsModel.kt @@ -21,6 +21,7 @@ import com.tangem.domain.core.utils.lceLoading import com.tangem.domain.markets.GetMarketsTokenListFlowUseCase import com.tangem.domain.models.account.Account import com.tangem.domain.models.account.AccountStatus +import com.tangem.domain.models.account.filterCryptoPortfolio import com.tangem.domain.models.currency.CryptoCurrency import com.tangem.domain.models.currency.CryptoCurrencyStatus import com.tangem.domain.models.tokenlist.TokenList @@ -287,7 +288,7 @@ internal class AvailableSwapPairsModel @Inject constructor( ): TokenListUMTransformer { val (appCurrency, isBalanceHidden) = appCurrencyAndBalanceHiding - val filterByQueryAccountList = accountList + val filterByQueryAccountList: Map> = accountList .associate { accountStatus -> when (accountStatus) { is AccountStatus.CryptoPortfolio -> { @@ -300,6 +301,7 @@ internal class AvailableSwapPairsModel @Inject constructor( accountStatus.account to statuses } + is AccountStatus.Payment -> TODO("[REDACTED_JIRA]") } } .filterValues { it.isNotEmpty() } @@ -360,7 +362,7 @@ internal class AvailableSwapPairsModel @Inject constructor( onRefresh = { modelScope.launch { if (networkInfo != null) { - accountList.filterIsInstance() + accountList.filterCryptoPortfolio() .forEach { (_, currencies) -> updateAvailablePairs(networkInfo, currencies.flattenCurrencies()) } @@ -384,7 +386,7 @@ internal class AvailableSwapPairsModel @Inject constructor( val accountList = accountListFlow.firstOrNull() ?: return@collectLatest updateAvailablePairs( networkInfo = networkInfo, - statuses = accountList.filterIsInstance() + statuses = accountList.filterCryptoPortfolio() .flatMap { accountStatus -> accountStatus.flattenCurrencies() }.toSet().toList(), diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/tokenlist/entity/transformer/SetLoadingAccountTokenListTransformer.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/tokenlist/entity/transformer/SetLoadingAccountTokenListTransformer.kt index b3a75c9a89..a7ca52c790 100644 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/tokenlist/entity/transformer/SetLoadingAccountTokenListTransformer.kt +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/tokenlist/entity/transformer/SetLoadingAccountTokenListTransformer.kt @@ -2,6 +2,8 @@ package com.tangem.features.onramp.tokenlist.entity.transformer import com.tangem.domain.appcurrency.model.AppCurrency import com.tangem.domain.models.account.AccountStatus +import com.tangem.domain.models.account.filterCryptoPortfolio +import com.tangem.domain.models.currency.CryptoCurrencyStatus import com.tangem.features.onramp.swap.availablepairs.entity.converters.LoadingAccountTokenItemConverter import com.tangem.features.onramp.swap.availablepairs.entity.converters.LoadingTokenListItemConverter import com.tangem.features.onramp.tokenlist.entity.TokenListUM @@ -22,6 +24,7 @@ internal class SetLoadingAccountTokenListTransformer( val totalTokensCount = accountList.sumOf { account -> when (account) { is AccountStatus.CryptoPortfolio -> account.tokenList.flattenCurrencies().size + is AccountStatus.Payment -> TODO("[REDACTED_JIRA]") } } @@ -31,7 +34,7 @@ internal class SetLoadingAccountTokenListTransformer( tokensListData = if (isAccountsMode) { TokenListUMData.AccountList( tokensList = accountListItemConverter.convertList( - accountList.filterIsInstance(), + accountList.filterCryptoPortfolio(), ).toPersistentList(), totalTokensCount = totalTokensCount, ) @@ -40,8 +43,9 @@ internal class SetLoadingAccountTokenListTransformer( tokensList = accountList.flatMap { account -> when (account) { is AccountStatus.CryptoPortfolio -> LoadingTokenListItemConverter.convertList( - account.tokenList.flattenCurrencies(), + account.tokenList.flattenCurrencies().map(CryptoCurrencyStatus::currency), ) + is AccountStatus.Payment -> TODO("[REDACTED_JIRA]") } }.toPersistentList(), totalTokensCount = totalTokensCount, diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/tokenlist/model/OnrampTokenListModel.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/tokenlist/model/OnrampTokenListModel.kt index e36eabad90..a90f9e6e25 100644 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/tokenlist/model/OnrampTokenListModel.kt +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/tokenlist/model/OnrampTokenListModel.kt @@ -295,13 +295,16 @@ internal class OnrampTokenListModel @Inject constructor( ) } - private fun AccountStatusList.filterAccountsByQuery(query: String) = accountStatuses.asSequence() + private fun AccountStatusList.filterAccountsByQuery( + query: String, + ): Map> = accountStatuses.asSequence() .associate { accountStatus -> when (accountStatus) { is AccountStatus.CryptoPortfolio -> { val filteredList = accountStatus.tokenList.flattenCurrencies().filterByQuery(query = query) accountStatus.account to filteredList } + is AccountStatus.Payment -> TODO("[REDACTED_JIRA]") } }.filter { (_, value) -> value.isNotEmpty() } diff --git a/features/referral/domain/src/main/java/com/tangem/feature/referral/domain/ReferralInteractorImpl.kt b/features/referral/domain/src/main/java/com/tangem/feature/referral/domain/ReferralInteractorImpl.kt index c7f8ef28fe..cfbdeea741 100644 --- a/features/referral/domain/src/main/java/com/tangem/feature/referral/domain/ReferralInteractorImpl.kt +++ b/features/referral/domain/src/main/java/com/tangem/feature/referral/domain/ReferralInteractorImpl.kt @@ -6,6 +6,7 @@ import com.tangem.domain.account.producer.SingleAccountProducer import com.tangem.domain.account.status.usecase.ManageCryptoCurrenciesUseCase import com.tangem.domain.account.supplier.SingleAccountSupplier import com.tangem.domain.models.PortfolioId +import com.tangem.domain.models.account.Account import com.tangem.domain.models.account.DerivationIndex import com.tangem.domain.models.currency.CryptoCurrency import com.tangem.domain.models.wallet.UserWalletId @@ -55,7 +56,10 @@ internal class ReferralInteractorImpl( ) ?: error("Account not found: ${portfolioId.accountId}") - account.derivationIndex + when (account) { + is Account.CryptoPortfolio -> account.derivationIndex + is Account.Payment -> TODO("[REDACTED_JIRA]") + } } is PortfolioId.Wallet -> null } diff --git a/features/referral/impl/src/main/java/com/tangem/feature/referral/model/ReferralModel.kt b/features/referral/impl/src/main/java/com/tangem/feature/referral/model/ReferralModel.kt index 46ce302791..eddb1e949d 100644 --- a/features/referral/impl/src/main/java/com/tangem/feature/referral/model/ReferralModel.kt +++ b/features/referral/impl/src/main/java/com/tangem/feature/referral/model/ReferralModel.kt @@ -127,6 +127,7 @@ internal class ReferralModel @Inject constructor( val cryptoPortfolio = when (selectedAccount) { is AccountStatus.CryptoPortfolio -> selectedAccount + is AccountStatus.Payment -> TODO("[REDACTED_JIRA]") } val awardCryptoCurrency = referralInteractor.getCryptoCurrency( diff --git a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/DefaultSendComponent.kt b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/DefaultSendComponent.kt index 2230676a18..83fb037866 100644 --- a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/DefaultSendComponent.kt +++ b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/DefaultSendComponent.kt @@ -21,6 +21,7 @@ import com.tangem.core.decompose.model.getOrCreateModel import com.tangem.core.decompose.navigation.inner.InnerRouter import com.tangem.core.ui.decompose.ComposableContentComponent import com.tangem.core.ui.extensions.resourceReference +import com.tangem.domain.models.account.derivationIndex import com.tangem.domain.models.currency.CryptoCurrencyStatus import com.tangem.features.send.v2.api.FeeSelectorBlockComponent import com.tangem.features.send.v2.api.SendComponent diff --git a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/analytics/SendAnalyticHelper.kt b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/analytics/SendAnalyticHelper.kt index 5626f5a93c..7ddfee6d8f 100644 --- a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/analytics/SendAnalyticHelper.kt +++ b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/analytics/SendAnalyticHelper.kt @@ -22,14 +22,17 @@ internal class SendAnalyticHelper @Inject constructor( cryptoCurrency: CryptoCurrency, sendUM: SendUM, feeToken: CryptoCurrency, - account: Account.CryptoPortfolio?, + account: Account?, ) { val destinationUM = sendUM.destinationUM as? DestinationUM.Content val feeSelectorUM = sendUM.feeSelectorUM as? FeeSelectorUM.Content ?: return val feeType = feeSelectorUM.toAnalyticType() val feeTokenSymbol = feeToken.symbol - val isNotMainAccount = account != null && !account.isMainAccount - val derivationIndex = if (isNotMainAccount) account.derivationIndex.value else null + val derivationIndex = when (account) { + is Account.CryptoPortfolio -> if (!account.isMainAccount) account.derivationIndex else null + is Account.Payment -> null + null -> null + } analyticsEventHandler.send( SendAnalyticEvents.TransactionScreenOpened( token = cryptoCurrency.symbol, @@ -37,7 +40,7 @@ internal class SendAnalyticHelper @Inject constructor( blockchain = cryptoCurrency.network.name, isNonceNotEmpty = feeSelectorUM.feeNonce is FeeNonce.Nonce, ensStatus = getEnsStatus(sendUM), - derivationIndex = derivationIndex, + derivationIndex = derivationIndex?.value, feeToken = feeTokenSymbol, ), ) diff --git a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/confirm/SendConfirmComponent.kt b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/confirm/SendConfirmComponent.kt index 423fc07b00..7bdbc5bb26 100644 --- a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/confirm/SendConfirmComponent.kt +++ b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/confirm/SendConfirmComponent.kt @@ -158,7 +158,7 @@ internal class SendConfirmComponent( val feeCryptoCurrencyStatus: CryptoCurrencyStatus, val cryptoCurrencyStatusFlow: StateFlow, val feeCryptoCurrencyStatusFlow: StateFlow, - val accountFlow: StateFlow, + val accountFlow: StateFlow, val isAccountModeFlow: StateFlow, val appCurrency: AppCurrency, val callback: ModelCallback, diff --git a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/model/SendModel.kt b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/model/SendModel.kt index 2f0b7ffd83..c8eeee19df 100644 --- a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/model/SendModel.kt +++ b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/model/SendModel.kt @@ -147,7 +147,7 @@ internal class SendModel @Inject constructor( ), ) - val accountFlow: StateFlow + val accountFlow: StateFlow field = MutableStateFlow(null) val isAccountModeFlow: StateFlow field = MutableStateFlow(false) diff --git a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/amount/SendAmountComponentParams.kt b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/amount/SendAmountComponentParams.kt index d776414db6..73eac2a41a 100644 --- a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/amount/SendAmountComponentParams.kt +++ b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/amount/SendAmountComponentParams.kt @@ -24,7 +24,7 @@ internal sealed class SendAmountComponentParams { abstract val cryptoCurrency: CryptoCurrency abstract val cryptoCurrencyStatusFlow: StateFlow abstract val isBalanceHidingFlow: StateFlow - abstract val accountFlow: StateFlow + abstract val accountFlow: StateFlow abstract val isAccountModeFlow: StateFlow data class AmountParams( @@ -37,7 +37,7 @@ internal sealed class SendAmountComponentParams { override val cryptoCurrencyStatusFlow: StateFlow, override val isBalanceHidingFlow: StateFlow, override val analyticsSendSource: CommonSendAnalyticEvents.CommonSendSource, - override val accountFlow: StateFlow, + override val accountFlow: StateFlow, override val isAccountModeFlow: StateFlow, val callback: ModelCallback, val currentRoute: StateFlow, @@ -53,7 +53,7 @@ internal sealed class SendAmountComponentParams { override val cryptoCurrencyStatusFlow: StateFlow, override val isBalanceHidingFlow: StateFlow, override val analyticsSendSource: CommonSendAnalyticEvents.CommonSendSource, - override val accountFlow: StateFlow, + override val accountFlow: StateFlow, override val isAccountModeFlow: StateFlow, val userWallet: UserWallet, val blockClickEnableFlow: StateFlow, diff --git a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/amount/model/SendAmountModel.kt b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/amount/model/SendAmountModel.kt index bc73a06d62..21fdc47353 100644 --- a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/amount/model/SendAmountModel.kt +++ b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/amount/model/SendAmountModel.kt @@ -149,7 +149,7 @@ internal class SendAmountModel @Inject constructor( private suspend fun initMinBoundary( cryptoCurrencyStatus: CryptoCurrencyStatus, - account: Account.CryptoPortfolio?, + account: Account?, isAccountsMode: Boolean, ) { minAmountBoundary = getMinimumTransactionAmountSyncUseCase( @@ -178,11 +178,7 @@ internal class SendAmountModel @Inject constructor( } } - private fun initialState( - cryptoCurrencyStatus: CryptoCurrencyStatus, - account: Account.CryptoPortfolio?, - isAccountsMode: Boolean, - ) { + private fun initialState(cryptoCurrencyStatus: CryptoCurrencyStatus, account: Account?, isAccountsMode: Boolean) { val userWallet = userWallet if (uiState.value is AmountState.Empty && userWallet != null) { val isOnlyOneWallet = getWalletsUseCase.invokeSync().size == 1 diff --git a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/destination/model/SendDestinationModel.kt b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/destination/model/SendDestinationModel.kt index ba2ab8f1b1..95e67b5de3 100644 --- a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/destination/model/SendDestinationModel.kt +++ b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/destination/model/SendDestinationModel.kt @@ -14,7 +14,7 @@ import com.tangem.core.ui.extensions.resourceReference import com.tangem.domain.account.featuretoggle.AccountsFeatureToggles import com.tangem.domain.account.status.supplier.MultiAccountStatusListSupplier import com.tangem.domain.account.usecase.IsAccountsModeEnabledUseCase -import com.tangem.domain.models.account.Account +import com.tangem.domain.models.account.filterCryptoPortfolio import com.tangem.domain.models.network.CryptoCurrencyAddress import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.models.wallet.isLocked @@ -272,36 +272,40 @@ internal class SendDestinationModel @Inject constructor( return combine( flow = getWalletsUseCase().conflate(), flow2 = multiAccountStatusListSupplier().conflate(), - ) { wallets, accountList -> + ) { wallets, accountStatusLists -> val cryptoCurrencyNetwork = cryptoCurrency.network coroutineScope { - accountList.mapNotNull { accountStatusList -> - val wallet = - wallets.filterNot { it.isLocked }.firstOrNull { it.walletId == accountStatusList.userWalletId } - ?: return@mapNotNull null + accountStatusLists.mapNotNull { accountStatusList -> + val wallet = wallets + .filterNot { it.isLocked } + .firstOrNull { it.walletId == accountStatusList.userWalletId } + ?: return@mapNotNull null async { - accountStatusList.accountStatuses.map { accountStatus -> - async { - accountStatus.flattenCurrencies() - .filter { it.currency.network.rawId == cryptoCurrencyNetwork.rawId } - .mapNotNull { cryptoCurrencyStatus -> - val address = cryptoCurrencyStatus.value.networkAddress?.defaultAddress?.value - ?: return@mapNotNull null + accountStatusList.flattenCurrencies() + .filter { it.currency.network.rawId == cryptoCurrencyNetwork.rawId } + .mapNotNull { cryptoCurrencyStatus -> + val address = cryptoCurrencyStatus.value.networkAddress?.defaultAddress?.value + ?: return@mapNotNull null - async { - DestinationWalletUM( - name = wallet.name, - address = address, - cryptoCurrency = cryptoCurrencyStatus.currency, - userWalletId = wallet.walletId, - account = accountStatus.account as? Account.CryptoPortfolio, - ) - } - }.awaitAll() + // Find the corresponding account from accountStatuses + val account = accountStatusList.accountStatuses + .filterCryptoPortfolio() + .firstOrNull { accountStatus -> + accountStatus.tokenList + .flattenCurrencies() + .any { it.currency.id == cryptoCurrencyStatus.currency.id } + }?.account + + DestinationWalletUM( + name = wallet.name, + address = address, + cryptoCurrency = cryptoCurrencyStatus.currency, + userWalletId = wallet.walletId, + account = account, + ) } - }.awaitAll().flatten() } }.awaitAll().flatten() } diff --git a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/destination/model/converters/SendRecipientWalletListConverter.kt b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/destination/model/converters/SendRecipientWalletListConverter.kt index c70c805b16..5b47c7de51 100644 --- a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/destination/model/converters/SendRecipientWalletListConverter.kt +++ b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/destination/model/converters/SendRecipientWalletListConverter.kt @@ -1,9 +1,11 @@ package com.tangem.features.send.v2.subcomponents.destination.model.converters +import com.tangem.common.ui.account.AccountIconUM import com.tangem.common.ui.account.AccountTitleUM import com.tangem.common.ui.account.CryptoPortfolioIconConverter import com.tangem.common.ui.account.toUM import com.tangem.core.ui.extensions.stringReference +import com.tangem.domain.models.account.Account import com.tangem.domain.models.currency.CryptoCurrency import com.tangem.features.send.v2.api.subcomponents.destination.entity.DestinationRecipientListUM import com.tangem.features.send.v2.subcomponents.destination.model.transformers.WALLET_DEFAULT_COUNT @@ -59,7 +61,12 @@ internal class SendRecipientWalletListConverter( accountTitleUM = if (account != null && isAccountsMode) { AccountTitleUM.Account( name = account.accountName.toUM().value, - icon = CryptoPortfolioIconConverter.convert(account.icon), + icon = when (account) { + is Account.CryptoPortfolio -> CryptoPortfolioIconConverter.convert( + account.icon, + ) + is Account.Payment -> AccountIconUM.Payment + }, prefixText = stringReference(StringsSigns.DOT), ) } else { diff --git a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/destination/ui/state/DestinationWalletUM.kt b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/destination/ui/state/DestinationWalletUM.kt index f9f611393b..7cdbd207a8 100644 --- a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/destination/ui/state/DestinationWalletUM.kt +++ b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/destination/ui/state/DestinationWalletUM.kt @@ -20,5 +20,5 @@ data class DestinationWalletUM( val userWalletId: UserWalletId, val address: String, val cryptoCurrency: CryptoCurrency, - val account: Account.CryptoPortfolio? = null, + val account: Account? = null, ) \ No newline at end of file diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/SwapAmountComponentParams.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/SwapAmountComponentParams.kt index a2f39e1550..bee0732784 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/SwapAmountComponentParams.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/SwapAmountComponentParams.kt @@ -24,7 +24,7 @@ internal sealed class SwapAmountComponentParams { abstract val primaryCryptoCurrencyStatusFlow: StateFlow abstract val secondaryCryptoCurrency: CryptoCurrency? abstract val filterProviderTypes: List - abstract val accountFlow: StateFlow + abstract val accountFlow: StateFlow abstract val isAccountModeFlow: StateFlow data class AmountParams( @@ -37,7 +37,7 @@ internal sealed class SwapAmountComponentParams { override val secondaryCryptoCurrency: CryptoCurrency?, override val filterProviderTypes: List = emptyList(), override val analyticsSendSource: CommonSendAnalyticEvents.CommonSendSource, - override val accountFlow: StateFlow, + override val accountFlow: StateFlow, override val isAccountModeFlow: StateFlow, val title: TextReference, val callback: SwapAmountComponent.ModelCallback, @@ -54,7 +54,7 @@ internal sealed class SwapAmountComponentParams { override val secondaryCryptoCurrency: CryptoCurrency?, override val filterProviderTypes: List = emptyList(), override val analyticsSendSource: CommonSendAnalyticEvents.CommonSendSource, - override val accountFlow: StateFlow, + override val accountFlow: StateFlow, override val isAccountModeFlow: StateFlow, val blockClickEnableFlow: StateFlow, ) : SwapAmountComponentParams() diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/converter/SwapAmountFieldConverter.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/converter/SwapAmountFieldConverter.kt index 9dd4198d6b..ae17646047 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/converter/SwapAmountFieldConverter.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/converter/SwapAmountFieldConverter.kt @@ -30,7 +30,7 @@ internal class SwapAmountFieldConverter( private val clickIntents: AmountScreenClickIntents, private val isSingleWallet: Boolean, private val isAccountsMode: Boolean, - private val account: Account.CryptoPortfolio?, + private val account: Account?, ) { private val iconStateConverter = CryptoCurrencyToIconStateConverter() diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountBalanceHiddenTransformer.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountBalanceHiddenTransformer.kt index 3febeaf504..56a7fab934 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountBalanceHiddenTransformer.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountBalanceHiddenTransformer.kt @@ -21,7 +21,7 @@ internal class SwapAmountBalanceHiddenTransformer( private val swapDirection: SwapDirection, private val clickIntents: AmountScreenClickIntents, private val isAccountsMode: Boolean, - private val account: Account.CryptoPortfolio?, + private val account: Account?, ) : Transformer { override fun transform(prevState: SwapAmountUM): SwapAmountUM { diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountPrimaryReadyStateTransformer.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountPrimaryReadyStateTransformer.kt index ca25cc3fda..aa09d11164 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountPrimaryReadyStateTransformer.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountPrimaryReadyStateTransformer.kt @@ -27,7 +27,7 @@ internal class SwapAmountPrimaryReadyStateTransformer( private val isShowBestRateAnimation: Boolean, private val isSingleWallet: Boolean, private val isAccountsMode: Boolean, - private val account: Account.CryptoPortfolio?, + private val account: Account?, ) : Transformer { private val amountFieldConverter = SwapAmountFieldConverter( diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountSecondaryReadyStateTransformer.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountSecondaryReadyStateTransformer.kt index 298b11ad75..f8f8600421 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountSecondaryReadyStateTransformer.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/amount/model/transformers/SwapAmountSecondaryReadyStateTransformer.kt @@ -28,7 +28,7 @@ internal class SwapAmountSecondaryReadyStateTransformer( private val isShowBestRateAnimation: Boolean, private val isSingleWallet: Boolean, private val isAccountsMode: Boolean, - private val account: Account.CryptoPortfolio?, + private val account: Account?, ) : Transformer { private val amountFieldConverter = SwapAmountFieldConverter( diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/common/ConfirmData.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/common/ConfirmData.kt index b825e3f9e7..e0fd2912f4 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/common/ConfirmData.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/common/ConfirmData.kt @@ -18,7 +18,7 @@ internal data class ConfirmData( val feeError: GetFeeError?, val fromCryptoCurrencyStatus: CryptoCurrencyStatus?, val toCryptoCurrencyStatus: CryptoCurrencyStatus?, - val fromAccount: Account.CryptoPortfolio?, + val fromAccount: Account?, val quote: SwapQuoteUM?, val rateType: ExpressRateType?, ) \ No newline at end of file diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/DefaultSendWithSwapComponent.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/DefaultSendWithSwapComponent.kt index 300dd949eb..b6d57e6d09 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/DefaultSendWithSwapComponent.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/DefaultSendWithSwapComponent.kt @@ -20,6 +20,7 @@ import com.tangem.core.decompose.navigation.inner.InnerRouter import com.tangem.core.navigation.url.UrlOpener import com.tangem.core.ui.decompose.ComposableContentComponent import com.tangem.core.ui.extensions.resourceReference +import com.tangem.domain.models.account.Account import com.tangem.domain.swap.models.R import com.tangem.domain.swap.models.SwapDirection import com.tangem.features.send.v2.api.analytics.CommonSendAnalyticEvents @@ -110,8 +111,11 @@ internal class DefaultSendWithSwapComponent @AssistedInject constructor( } is SendWithSwapConfirmComponent -> { val fromCurrency = params.currency - val fromDerivationIndex = model.accountFlow.value?.derivationIndex?.value - .takeIf { model.isAccountModeFlow.value } + val fromDerivationIndex = when (val account = model.accountFlow.value) { + is Account.CryptoPortfolio -> account.derivationIndex.value + is Account.Payment -> TODO("[REDACTED_JIRA]") + null -> null + }.takeIf { model.isAccountModeFlow.value } analyticsEventHandler.send( CommonSendAnalyticEvents.ConfirmationScreenOpened( categoryName = model.analyticCategoryName, diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/SendWithSwapConfirmComponent.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/SendWithSwapConfirmComponent.kt index 9bae584628..aac3bb92dd 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/SendWithSwapConfirmComponent.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/SendWithSwapConfirmComponent.kt @@ -181,7 +181,7 @@ internal class SendWithSwapConfirmComponent @AssistedInject constructor( val isBalanceHidingFlow: StateFlow, val primaryCryptoCurrencyStatusFlow: StateFlow, val primaryFeePaidCurrencyStatusFlow: StateFlow, // doesn't change if select gasless fee - val accountFlow: StateFlow, + val accountFlow: StateFlow, val isAccountModeFlow: StateFlow, val callback: ModelCallback, ) diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SendWithSwapConfirmModel.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SendWithSwapConfirmModel.kt index 4c22e6b47c..9de68cfb9a 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SendWithSwapConfirmModel.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SendWithSwapConfirmModel.kt @@ -24,6 +24,7 @@ import com.tangem.core.ui.extensions.resourceReference import com.tangem.core.ui.extensions.wrappedList import com.tangem.domain.express.models.ExpressOperationType import com.tangem.domain.express.models.ExpressProviderType +import com.tangem.domain.models.account.derivationIndex import com.tangem.domain.models.currency.CryptoCurrency import com.tangem.domain.models.currency.CryptoCurrencyStatus import com.tangem.domain.models.wallet.isHotWallet diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SwapTransactionSender.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SwapTransactionSender.kt index 7a166639ff..3618110f82 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SwapTransactionSender.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SwapTransactionSender.kt @@ -129,7 +129,7 @@ internal class SwapTransactionSender @AssistedInject constructor( fromAmount: BigDecimal, fromStatus: CryptoCurrencyStatus, toStatus: CryptoCurrencyStatus, - fromAccount: Account.CryptoPortfolio?, + fromAccount: Account?, fee: Fee, feeExtended: TransactionFeeExtended?, provider: ExpressProvider, diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/model/SendWithSwapModel.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/model/SendWithSwapModel.kt index 629d37898d..31b4ba8651 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/model/SendWithSwapModel.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/model/SendWithSwapModel.kt @@ -96,7 +96,7 @@ internal class SendWithSwapModel @Inject constructor( ), ) - val accountFlow: StateFlow + val accountFlow: StateFlow field = MutableStateFlow(null) val isAccountModeFlow: StateFlow diff --git a/features/swap/api/src/main/kotlin/com/tangem/features/swap/SwapComponent.kt b/features/swap/api/src/main/kotlin/com/tangem/features/swap/SwapComponent.kt index d2ef17de45..ed9144cac3 100644 --- a/features/swap/api/src/main/kotlin/com/tangem/features/swap/SwapComponent.kt +++ b/features/swap/api/src/main/kotlin/com/tangem/features/swap/SwapComponent.kt @@ -18,7 +18,7 @@ interface SwapComponent : ComposableContentComponent { val screenSource: String, val tangemPayInput: TangemPayInput? = null, val preselectedToToken: CryptoCurrencyStatus? = null, - val preselectedAccount: Account.CryptoPortfolio? = null, + val preselectedAccount: Account? = null, ) { data class TangemPayInput( val cryptoAmount: BigDecimal, diff --git a/features/swap/data/src/main/java/com/tangem/feature/swap/DefaultSwapTransactionRepository.kt b/features/swap/data/src/main/java/com/tangem/feature/swap/DefaultSwapTransactionRepository.kt index fb7b9d0ed1..a04749322a 100644 --- a/features/swap/data/src/main/java/com/tangem/feature/swap/DefaultSwapTransactionRepository.kt +++ b/features/swap/data/src/main/java/com/tangem/feature/swap/DefaultSwapTransactionRepository.kt @@ -47,8 +47,8 @@ internal class DefaultSwapTransactionRepository( userWalletId: UserWalletId, fromCryptoCurrency: CryptoCurrency, toCryptoCurrency: CryptoCurrency, - fromAccount: Account.CryptoPortfolio?, - toAccount: Account.CryptoPortfolio?, + fromAccount: Account?, + toAccount: Account?, transaction: SavedSwapTransactionModel, ) { transaction.status?.let { status -> @@ -248,8 +248,8 @@ internal class DefaultSwapTransactionRepository( userWalletId: UserWalletId, fromCryptoCurrency: CryptoCurrency, toCryptoCurrency: CryptoCurrency, - fromAccount: Account.CryptoPortfolio?, - toAccount: Account.CryptoPortfolio?, + fromAccount: Account?, + toAccount: Account?, transactions: List, ): List { return addOrReplace( diff --git a/features/swap/data/src/main/java/com/tangem/feature/swap/converters/SavedSwapTransactionListConverter.kt b/features/swap/data/src/main/java/com/tangem/feature/swap/converters/SavedSwapTransactionListConverter.kt index 5c0b55b780..2b50f90d14 100644 --- a/features/swap/data/src/main/java/com/tangem/feature/swap/converters/SavedSwapTransactionListConverter.kt +++ b/features/swap/data/src/main/java/com/tangem/feature/swap/converters/SavedSwapTransactionListConverter.kt @@ -120,8 +120,8 @@ internal class SavedSwapTransactionListConverter( userWalletId: UserWalletId, fromCryptoCurrency: CryptoCurrency, toCryptoCurrency: CryptoCurrency, - fromAccount: Account.CryptoPortfolio?, - toAccount: Account.CryptoPortfolio?, + fromAccount: Account?, + toAccount: Account?, tokenTransactions: List, ) = SavedSwapTransactionListModelInner( userWalletId = userWalletId.stringValue, @@ -161,10 +161,7 @@ internal class SavedSwapTransactionListConverter( } } - private fun findAccountByDerivationIndex( - accountList: AccountList?, - derivationIndex: DerivationIndex?, - ): Account.CryptoPortfolio? { + private fun findAccountByDerivationIndex(accountList: AccountList?, derivationIndex: DerivationIndex?): Account? { return accountList?.accounts?.asSequence()?.filterIsInstance() ?.firstOrNull { it.derivationIndex == derivationIndex } } diff --git a/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractor.kt b/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractor.kt index 1c31e6c77a..244a784b00 100644 --- a/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractor.kt +++ b/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractor.kt @@ -80,8 +80,8 @@ interface SwapInteractor { swapData: SwapDataModel?, currencyToSend: CryptoCurrencyStatus, currencyToGet: CryptoCurrencyStatus, - fromAccount: Account.CryptoPortfolio?, - toAccount: Account.CryptoPortfolio?, + fromAccount: Account?, + toAccount: Account?, amountToSwap: String, includeFeeInAmount: IncludeFeeInAmount, fee: TxFee?, @@ -129,8 +129,8 @@ interface SwapInteractor { suspend fun storeSwapTransaction( currencyToSend: CryptoCurrencyStatus, currencyToGet: CryptoCurrencyStatus, - fromAccount: Account.CryptoPortfolio?, - toAccount: Account.CryptoPortfolio?, + fromAccount: Account?, + toAccount: Account?, amount: SwapAmount, swapProvider: SwapProvider, swapDataModel: SwapDataModel, @@ -154,9 +154,9 @@ interface SwapInteractor { @Suppress("LongParameterList") suspend fun loadFeeForSwapTransaction( fromToken: CryptoCurrencyStatus, - fromAccount: Account.CryptoPortfolio?, + fromAccount: Account?, toToken: CryptoCurrencyStatus, - toAccount: Account.CryptoPortfolio?, + toAccount: Account?, amount: String, reduceBalanceBy: BigDecimal, provider: SwapProvider, @@ -176,9 +176,9 @@ interface SwapInteractor { @Suppress("LongParameterList") suspend fun loadFeeForSwapTransaction( fromToken: CryptoCurrencyStatus, - fromAccount: Account.CryptoPortfolio?, + fromAccount: Account?, toToken: CryptoCurrencyStatus, - toAccount: Account.CryptoPortfolio?, + toAccount: Account?, amount: String, reduceBalanceBy: BigDecimal, provider: SwapProvider, diff --git a/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractorImpl.kt b/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractorImpl.kt index 046dc76c7f..060390b7a6 100644 --- a/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractorImpl.kt +++ b/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractorImpl.kt @@ -29,6 +29,7 @@ import com.tangem.domain.demo.IsDemoCardUseCase import com.tangem.domain.exchange.RampStateManager import com.tangem.domain.express.models.ExpressOperationType import com.tangem.domain.models.account.Account +import com.tangem.domain.models.account.AccountStatus import com.tangem.domain.models.currency.CryptoCurrency import com.tangem.domain.models.currency.CryptoCurrencyStatus import com.tangem.domain.models.network.Network @@ -180,17 +181,11 @@ internal class SwapInteractorImpl @AssistedInject constructor( SingleAccountStatusListProducer.Params(userWalletId), )?.accountStatuses.orEmpty() - val walletAccountCurrencyStatusesExceptInitial = walletAccountCurrencyStatuses - .mapNotNull { accountStatus -> - val filteredCurrencies = accountStatus.flattenCurrencies().filter { status -> - val isDifferentCurrency = status.currency.network.backendId != currency.network.backendId || - status.currency.getContractAddress() != currency.getContractAddress() - - val hasValidStatus = - status.value is CryptoCurrencyStatus.Loaded || status.value is CryptoCurrencyStatus.NoAccount - val isNotCustomToken = !status.currency.isCustom - - hasValidStatus && isDifferentCurrency && isNotCustomToken + val walletAccountCurrencyStatusesExceptInitial: Map> = + walletAccountCurrencyStatuses.mapNotNull { accountStatus -> + val filteredCurrencies = when (accountStatus) { + is AccountStatus.CryptoPortfolio -> accountStatus.flattenCurrencies().filterCurrencies(currency) + is AccountStatus.Payment -> TODO("[REDACTED_JIRA]") } if (filteredCurrencies.isNotEmpty()) { @@ -234,6 +229,17 @@ internal class SwapInteractorImpl @AssistedInject constructor( ) } + private fun List.filterCurrencies(currency: CryptoCurrency) = this.filter { status -> + val isDifferentCurrency = status.currency.network.backendId != currency.network.backendId || + status.currency.getContractAddress() != currency.getContractAddress() + + val hasValidStatus = + status.value is CryptoCurrencyStatus.Loaded || status.value is CryptoCurrencyStatus.NoAccount + val isNotCustomToken = !status.currency.isCustom + + hasValidStatus && isDifferentCurrency && isNotCustomToken + } + private suspend fun getToCurrenciesGroup( currency: CryptoCurrency, leastPairs: List, @@ -293,7 +299,7 @@ internal class SwapInteractorImpl @AssistedInject constructor( val isUnavailable = providers.isNullOrEmpty() AccountSwapCurrency( isAvailable = !isUnavailable, - account = cryptoPortfolio, + account = accountEntry, cryptoCurrencyStatus = currencyStatus, providers = providers.orEmpty(), ) @@ -400,7 +406,9 @@ internal class SwapInteractorImpl @AssistedInject constructor( """ Find the best quote |- fromToken: $fromToken + |- fromAccount: $fromAccount |- toToken: $toToken + |- toAccount: $toAccount |- providers: $providers |- amountToSwap: $amountToSwap |- selectedFee: $txFeeSealedState @@ -767,8 +775,8 @@ internal class SwapInteractorImpl @AssistedInject constructor( swapData: SwapDataModel?, currencyToSend: CryptoCurrencyStatus, currencyToGet: CryptoCurrencyStatus, - fromAccount: Account.CryptoPortfolio?, - toAccount: Account.CryptoPortfolio?, + fromAccount: Account?, + toAccount: Account?, amountToSwap: String, includeFeeInAmount: IncludeFeeInAmount, fee: TxFee?, @@ -848,8 +856,8 @@ internal class SwapInteractorImpl @AssistedInject constructor( swapData: SwapDataModel, currencyToSendStatus: CryptoCurrencyStatus, currencyToGetStatus: CryptoCurrencyStatus, - fromAccount: Account.CryptoPortfolio?, - toAccount: Account.CryptoPortfolio?, + fromAccount: Account?, + toAccount: Account?, amountToSwap: String, txFee: TxFee, ): SwapTransactionState { @@ -890,8 +898,8 @@ internal class SwapInteractorImpl @AssistedInject constructor( swapData: SwapDataModel, currencyToSendStatus: CryptoCurrencyStatus, currencyToGetStatus: CryptoCurrencyStatus, - fromAccount: Account.CryptoPortfolio?, - toAccount: Account.CryptoPortfolio?, + fromAccount: Account?, + toAccount: Account?, amountToSwap: String, ): SwapTransactionState { val dexTransaction = swapData.transaction as? ExpressTransactionModel.DEX @@ -919,8 +927,8 @@ internal class SwapInteractorImpl @AssistedInject constructor( swapData: SwapDataModel, currencyToSendStatus: CryptoCurrencyStatus, currencyToGetStatus: CryptoCurrencyStatus, - fromAccount: Account.CryptoPortfolio?, - toAccount: Account.CryptoPortfolio?, + fromAccount: Account?, + toAccount: Account?, amount: SwapAmount, txData: TransactionData, payInAddress: String, @@ -988,8 +996,8 @@ internal class SwapInteractorImpl @AssistedInject constructor( private suspend fun onSwapCex( currencyToSend: CryptoCurrencyStatus, currencyToGet: CryptoCurrencyStatus, - fromAccount: Account.CryptoPortfolio?, - toAccount: Account.CryptoPortfolio?, + fromAccount: Account?, + toAccount: Account?, amount: SwapAmount, txFee: TxFee?, swapProvider: SwapProvider, @@ -1150,8 +1158,8 @@ internal class SwapInteractorImpl @AssistedInject constructor( override suspend fun storeSwapTransaction( currencyToSend: CryptoCurrencyStatus, currencyToGet: CryptoCurrencyStatus, - fromAccount: Account.CryptoPortfolio?, - toAccount: Account.CryptoPortfolio?, + fromAccount: Account?, + toAccount: Account?, amount: SwapAmount, swapProvider: SwapProvider, swapDataModel: SwapDataModel, @@ -1187,9 +1195,9 @@ internal class SwapInteractorImpl @AssistedInject constructor( @Suppress("LongParameterList") override suspend fun loadFeeForSwapTransaction( fromToken: CryptoCurrencyStatus, - fromAccount: Account.CryptoPortfolio?, + fromAccount: Account?, toToken: CryptoCurrencyStatus, - toAccount: Account.CryptoPortfolio?, + toAccount: Account?, amount: String, reduceBalanceBy: BigDecimal, provider: SwapProvider, @@ -1225,9 +1233,9 @@ internal class SwapInteractorImpl @AssistedInject constructor( override suspend fun loadFeeForSwapTransaction( fromToken: CryptoCurrencyStatus, - fromAccount: Account.CryptoPortfolio?, + fromAccount: Account?, toToken: CryptoCurrencyStatus, - toAccount: Account.CryptoPortfolio?, + toAccount: Account?, amount: String, reduceBalanceBy: BigDecimal, provider: SwapProvider, diff --git a/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapTransactionRepository.kt b/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapTransactionRepository.kt index 122d227590..0720aa7abf 100644 --- a/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapTransactionRepository.kt +++ b/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapTransactionRepository.kt @@ -17,8 +17,8 @@ interface SwapTransactionRepository { userWalletId: UserWalletId, fromCryptoCurrency: CryptoCurrency, toCryptoCurrency: CryptoCurrency, - fromAccount: Account.CryptoPortfolio?, - toAccount: Account.CryptoPortfolio?, + fromAccount: Account?, + toAccount: Account?, transaction: SavedSwapTransactionModel, ) diff --git a/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/models/domain/SavedSwapTransactionListModel.kt b/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/models/domain/SavedSwapTransactionListModel.kt index f25e4b1c1a..31236c6313 100644 --- a/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/models/domain/SavedSwapTransactionListModel.kt +++ b/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/models/domain/SavedSwapTransactionListModel.kt @@ -13,8 +13,8 @@ data class SavedSwapTransactionListModel( val toCryptoCurrencyId: String, val fromCryptoCurrency: CryptoCurrency, val toCryptoCurrency: CryptoCurrency, - val fromAccount: Account.CryptoPortfolio?, - val toAccount: Account.CryptoPortfolio?, + val fromAccount: Account?, + val toAccount: Account?, val transactions: List, ) diff --git a/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/models/ui/SwapTransactionState.kt b/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/models/ui/SwapTransactionState.kt index 7ad787a146..4619adf9ab 100644 --- a/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/models/ui/SwapTransactionState.kt +++ b/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/models/ui/SwapTransactionState.kt @@ -36,8 +36,8 @@ sealed class SwapTransactionState { data class StoreTransactionData( val currencyToSend: CryptoCurrencyStatus, val currencyToGet: CryptoCurrencyStatus, - val fromAccount: Account.CryptoPortfolio?, - val toAccount: Account.CryptoPortfolio?, + val fromAccount: Account?, + val toAccount: Account?, val amount: SwapAmount, val swapProvider: SwapProvider, val swapDataModel: SwapDataModel, diff --git a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/utils/AccountItemsDelegate.kt b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/utils/AccountItemsDelegate.kt index aa4c1a4b46..6c53807de1 100644 --- a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/utils/AccountItemsDelegate.kt +++ b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/utils/AccountItemsDelegate.kt @@ -22,6 +22,7 @@ import com.tangem.domain.balancehiding.GetBalanceHidingSettingsUseCase import com.tangem.domain.models.account.Account import com.tangem.domain.models.account.AccountId import com.tangem.domain.models.account.AccountStatus +import com.tangem.domain.models.account.filterCryptoPortfolio import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.models.wallet.UserWalletId import com.tangem.domain.wallets.analytics.WalletSettingsAnalyticEvents @@ -84,11 +85,11 @@ internal class AccountItemsDelegate @Inject constructor( return WalletSettingsAccountsUM.Account(state = accountItemUM) } - fun mapAccount(account: AccountStatus): WalletSettingsAccountsUM = when (account) { + fun mapAccount(account: AccountStatus.CryptoPortfolio): WalletSettingsAccountsUM = when (account) { is AccountStatus.CryptoPortfolio -> account.mapCryptoPortfolio() } - val accounts = accountStatusList.accountStatuses + val accounts = accountStatusList.accountStatuses.filterCryptoPortfolio() val header = WalletSettingsAccountsUM.Header( id = "accounts_header", diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/organizetokens/utils/CryptoCurrenciesIdsResolver.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/organizetokens/utils/CryptoCurrenciesIdsResolver.kt index d62385f7be..770ada3985 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/organizetokens/utils/CryptoCurrenciesIdsResolver.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/organizetokens/utils/CryptoCurrenciesIdsResolver.kt @@ -2,7 +2,7 @@ package com.tangem.feature.wallet.presentation.organizetokens.utils import com.tangem.domain.account.models.AccountStatusList import com.tangem.domain.account.status.model.AccountCryptoCurrencies -import com.tangem.domain.models.account.Account +import com.tangem.domain.models.account.filterCryptoPortfolio import com.tangem.domain.models.currency.CryptoCurrency import com.tangem.domain.models.tokenlist.TokenList import com.tangem.feature.wallet.presentation.organizetokens.model.DraggableItem @@ -34,6 +34,7 @@ internal class CryptoCurrenciesIdsResolver { } } + @Suppress("UseOrEmpty") fun resolveV2(tokensListUM: OrganizeTokensListUM, accountStatusList: AccountStatusList?): AccountCryptoCurrencies { val draggableTokens = when (tokensListUM) { OrganizeTokensListUM.EmptyList -> return emptyMap() @@ -43,10 +44,11 @@ internal class CryptoCurrenciesIdsResolver { } return accountStatusList?.accountStatuses - ?.filter { it.getCryptoTokenList() != TokenList.Empty } + ?.filterCryptoPortfolio() + ?.filter { it.tokenList != TokenList.Empty } ?.associate { accountStatus -> val currencies = accountStatus.flattenCurrencies() - accountStatus.account as Account.CryptoPortfolio to draggableTokens + accountStatus.account to draggableTokens .asSequence() .filter { it.accountId == accountStatus.account.accountId.value } .mapNotNull { sortedToken -> diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/organizetokens/utils/converter/TokenListToStateConverterV2.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/organizetokens/utils/converter/TokenListToStateConverterV2.kt index 75e1c92282..279d59f8ed 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/organizetokens/utils/converter/TokenListToStateConverterV2.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/organizetokens/utils/converter/TokenListToStateConverterV2.kt @@ -6,7 +6,7 @@ import com.tangem.domain.appcurrency.model.AppCurrency import com.tangem.domain.models.TokensGroupType import com.tangem.domain.models.TokensSortType import com.tangem.domain.models.TotalFiatBalance -import com.tangem.domain.models.account.AccountStatus +import com.tangem.domain.models.account.filterCryptoPortfolio import com.tangem.domain.models.tokenlist.TokenList import com.tangem.feature.wallet.presentation.organizetokens.model.DraggableItem import com.tangem.feature.wallet.presentation.organizetokens.model.OrganizeTokensListUM @@ -61,7 +61,7 @@ internal class AccountTokenItemConverter( isGrouped = isGrouping, items = value.accountStatuses .asSequence() - .filterIsInstance() + .filterCryptoPortfolio() .flatMap { accountStatus -> if (accountStatus.tokenList != TokenList.Empty) { buildList { diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/organizetokens/utils/converter/items/OrganizedTokenListConverter.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/organizetokens/utils/converter/items/OrganizedTokenListConverter.kt index 295848f5f4..c0938d2748 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/organizetokens/utils/converter/items/OrganizedTokenListConverter.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/organizetokens/utils/converter/items/OrganizedTokenListConverter.kt @@ -2,7 +2,6 @@ package com.tangem.feature.wallet.presentation.organizetokens.utils.converter.it import com.tangem.domain.account.status.model.AccountCryptoCurrencyStatus import com.tangem.domain.appcurrency.model.AppCurrency -import com.tangem.domain.models.account.Account import com.tangem.domain.models.account.AccountStatus import com.tangem.domain.models.tokenlist.TokenList import com.tangem.feature.wallet.presentation.organizetokens.model.DraggableItem @@ -13,27 +12,26 @@ import kotlinx.collections.immutable.toPersistentList internal class OrganizedTokenListConverter( private val appCurrency: AppCurrency, -) : Converter> { +) : Converter> { private val tokensConverter by lazy { CryptoCurrencyToDraggableItemConverterV2(appCurrency) } private val groupsConverter by lazy { NetworkGroupToDraggableItemsConverterV2(tokensConverter) } - override fun convert(value: AccountStatus): PersistentList { - val cryptoAccount = value.account as? Account.CryptoPortfolio ?: return persistentListOf() - return when (val tokenList = value.getCryptoTokenList()) { + override fun convert(value: AccountStatus.CryptoPortfolio): PersistentList { + return when (val tokenList = value.tokenList) { is TokenList.GroupedByNetwork -> groupsConverter.convertList( - tokenList.groups.map { cryptoAccount to it }, + tokenList.groups.map { value.account to it }, ) .flatten() .toPersistentList() is TokenList.Ungrouped -> tokensConverter.convertList( - value.flattenCurrencies().map { + value.flattenCurrencies().map { cryptoCurrencyStatus -> AccountCryptoCurrencyStatus( - account = cryptoAccount, - status = it, + account = value.account, + status = cryptoCurrencyStatus, ) }, ).toPersistentList() diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/GetSingleWalletWarningsFactory.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/GetSingleWalletWarningsFactory.kt index 38197dbb07..c7fe144bd9 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/GetSingleWalletWarningsFactory.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/GetSingleWalletWarningsFactory.kt @@ -241,10 +241,11 @@ internal class GetSingleWalletWarningsFactory @Inject constructor( } } - private fun getAccountStatusFlow(userWallet: UserWallet): Flow { + private fun getAccountStatusFlow(userWallet: UserWallet): Flow { val accountId = AccountId.forMainCryptoPortfolio(userWalletId = userWallet.walletId) return singleAccountStatusSupplier(SingleAccountStatusProducer.Params(accountId)) + .filterIsInstance() .distinctUntilChanged() .conflate() } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/converter/TokenListStateConverter.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/converter/TokenListStateConverter.kt index 1a6b19c186..1847ff842f 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/converter/TokenListStateConverter.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/converter/TokenListStateConverter.kt @@ -14,6 +14,7 @@ import com.tangem.domain.models.TotalFiatBalance import com.tangem.domain.models.account.Account import com.tangem.domain.models.account.AccountId import com.tangem.domain.models.account.AccountStatus +import com.tangem.domain.models.account.filterCryptoPortfolio import com.tangem.domain.models.currency.CryptoCurrency import com.tangem.domain.models.currency.CryptoCurrencyStatus import com.tangem.domain.models.tokenlist.TokenList @@ -144,6 +145,7 @@ internal class TokenListStateConverter( } val accountItems = accountList.accountStatuses + .filterCryptoPortfolio() .map { accountStatus -> when (accountStatus) { is AccountStatus.CryptoPortfolio -> accountStatus.map() diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/subscribers/BasicWalletSubscriber.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/subscribers/BasicWalletSubscriber.kt index 585a48c0b0..b169aba32c 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/subscribers/BasicWalletSubscriber.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/subscribers/BasicWalletSubscriber.kt @@ -4,6 +4,7 @@ import com.tangem.domain.account.models.AccountStatusList import com.tangem.domain.account.status.producer.SingleAccountStatusListProducer import com.tangem.domain.account.status.supplier.SingleAccountStatusListSupplier import com.tangem.domain.models.account.AccountStatus +import com.tangem.domain.models.account.filterCryptoPortfolio import com.tangem.domain.models.currency.CryptoCurrencyStatus import com.tangem.domain.models.wallet.UserWallet import kotlinx.coroutines.flow.Flow @@ -45,11 +46,9 @@ internal abstract class BasicWalletSubscriber : WalletSubscriber() { protected fun getMainAccountStatusFlow(): Flow { return getAccountStatusListFlow() .mapNotNull { accountStatusList -> - accountStatusList.accountStatuses.find { accountStatus -> - when (accountStatus) { - is AccountStatus.CryptoPortfolio -> accountStatus.account.isMainAccount - } - } as? AccountStatus.CryptoPortfolio + accountStatusList.accountStatuses + .filterCryptoPortfolio() + .find { accountStatus -> accountStatus.account.isMainAccount } } .distinctUntilChanged() .conflate() diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/model/WcPairModel.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/model/WcPairModel.kt index f9fefde39c..d686883940 100644 --- a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/model/WcPairModel.kt +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/model/WcPairModel.kt @@ -27,7 +27,6 @@ import com.tangem.domain.account.supplier.SingleAccountListSupplier import com.tangem.domain.account.usecase.IsAccountsModeEnabledUseCase import com.tangem.domain.models.account.Account import com.tangem.domain.models.account.AccountStatus -import com.tangem.domain.models.account.derivationIndex import com.tangem.domain.models.network.Network import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.models.wallet.UserWalletId @@ -105,7 +104,7 @@ internal class WcPairModel @Inject constructor( private val selectedUserWalletFlow: MutableStateFlow by lazy { MutableStateFlow(getWalletsUseCase.invokeSync().first { it.walletId == params.userWalletId }) } - private val selectedPortfolio = MutableSharedFlow>( + private val selectedPortfolio = MutableSharedFlow>( replay = 1, onBufferOverflow = BufferOverflow.DROP_OLDEST, ) @@ -171,7 +170,7 @@ internal class WcPairModel @Inject constructor( private suspend fun handlePairState( pairState: WcPairState, portfolios: PortfolioFetcher.Data? = null, - selected: Pair? = null, + selected: Pair? = null, isAccountMode: Boolean? = null, ) { when (pairState) { @@ -206,7 +205,7 @@ internal class WcPairModel @Inject constructor( private suspend fun handleProposalState( pairState: WcPairState.Proposal, portfolios: PortfolioFetcher.Data? = null, - selected: Pair? = null, + selected: Pair? = null, ) { val availableWallets = pairState.dAppSession.proposalNetwork.keys .filter { !it.isLocked && it.isMultiCurrency } @@ -266,7 +265,7 @@ internal class WcPairModel @Inject constructor( } private suspend fun tryToCreatePortfolioSelectRow( - selectedPortfolio: Pair?, + selectedPortfolio: Pair?, portfolios: PortfolioFetcher.Data?, ): PortfolioSelectUM? { selectedPortfolio ?: return null @@ -274,7 +273,6 @@ internal class WcPairModel @Inject constructor( val (wallet, portfolioAccount) = selectedPortfolio val account = when (val account = portfolioAccount.account) { is Account.CryptoPortfolio -> account - is Account.Payment -> TODO("[REDACTED_JIRA]") } val isAccountMode = selectorController.isAccountMode.first() val icon: AccountIconUM.CryptoPortfolio? diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/model/transformers/WcSessionsAccountModeTransformer.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/model/transformers/WcSessionsAccountModeTransformer.kt index fa672da841..f3991ee130 100644 --- a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/model/transformers/WcSessionsAccountModeTransformer.kt +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/model/transformers/WcSessionsAccountModeTransformer.kt @@ -48,7 +48,7 @@ internal class WcSessionsAccountModeTransformer( ) items.add(walletHeader) - accountList.accounts.forEach accountsForEach@{ account -> + accountList.accounts.filterIsInstance().forEach accountsForEach@{ account -> val accountSessions = sessions.filter { it.account?.accountId == account.accountId } if (accountSessions.isEmpty()) return@accountsForEach val connectedApps = accountSessions.map { dappSession -> @@ -65,7 +65,6 @@ internal class WcSessionsAccountModeTransformer( } val accountIcon = when (account) { is Account.CryptoPortfolio -> account.icon - is Account.Payment -> TODO("[REDACTED_JIRA]") } val accountTitle = AccountTitleUM.Account( diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/converter/WcPortfolioNameDelegate.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/converter/WcPortfolioNameDelegate.kt index 5df48f4e4d..cad34dfe8e 100644 --- a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/converter/WcPortfolioNameDelegate.kt +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/converter/WcPortfolioNameDelegate.kt @@ -19,13 +19,12 @@ internal class WcPortfolioNameDelegate @AssistedInject constructor( isAccountsModeEnabledUseCase: IsAccountsModeEnabledUseCase, @Assisted private val scope: CoroutineScope, ) { - val isAccountMode = isAccountsModeEnabledUseCase.invoke() + private val isAccountMode = isAccountsModeEnabledUseCase.invoke() .stateIn(scope = scope, started = SharingStarted.Eagerly, initialValue = false) fun createAccountTitleUM(value: WcSession): AccountTitleUM? { val account = when (val account = value.account) { is Account.CryptoPortfolio -> account - is Account.Payment -> TODO("[REDACTED_JIRA]") null -> null } diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/model/WcAddNetworkModel.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/model/WcAddNetworkModel.kt index 7f74dc7dca..11fba2839f 100644 --- a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/model/WcAddNetworkModel.kt +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/model/WcAddNetworkModel.kt @@ -11,7 +11,6 @@ import com.tangem.core.decompose.model.ParamsContainer import com.tangem.core.decompose.navigation.Router import com.tangem.core.decompose.ui.UiMessageSender import com.tangem.core.ui.clipboard.ClipboardManager -import com.tangem.domain.models.account.derivationIndex import com.tangem.domain.walletconnect.WcAnalyticEvents import com.tangem.domain.walletconnect.WcRequestUseCaseFactory import com.tangem.domain.walletconnect.usecase.method.WcAddNetworkUseCase diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/model/WcSendTransactionModel.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/model/WcSendTransactionModel.kt index 9eaceb4978..a156c5a69c 100644 --- a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/model/WcSendTransactionModel.kt +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/model/WcSendTransactionModel.kt @@ -23,7 +23,6 @@ import com.tangem.core.ui.components.bottomsheets.message.MessageBottomSheetUMV2 import com.tangem.core.ui.extensions.resourceReference import com.tangem.core.ui.extensions.wrappedList import com.tangem.domain.core.lce.Lce -import com.tangem.domain.models.account.derivationIndex import com.tangem.domain.models.currency.CryptoCurrencyStatus import com.tangem.domain.models.network.Network import com.tangem.domain.models.wallet.UserWallet diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/model/WcSignTransactionModel.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/model/WcSignTransactionModel.kt index 1e97be37f4..7a0a21fe7f 100644 --- a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/model/WcSignTransactionModel.kt +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/model/WcSignTransactionModel.kt @@ -12,7 +12,6 @@ import com.tangem.core.decompose.model.ParamsContainer import com.tangem.core.decompose.navigation.Router import com.tangem.core.decompose.ui.UiMessageSender import com.tangem.core.ui.clipboard.ClipboardManager -import com.tangem.domain.models.account.derivationIndex import com.tangem.domain.walletconnect.WcAnalyticEvents import com.tangem.domain.walletconnect.WcRequestUseCaseFactory import com.tangem.domain.walletconnect.model.WcEthMethod