Updated on 2026-08-14
This commit is contained in:
parent
61958c0c63
commit
8c2e30f9bf
2 changed files with 15 additions and 0 deletions
|
|
@ -26,6 +26,7 @@ dependencies {
|
|||
|
||||
// region Project - Domain
|
||||
implementation(projects.domain.account)
|
||||
implementation(projects.domain.common)
|
||||
implementation(projects.domain.dynamicAddresses)
|
||||
implementation(projects.domain.dynamicAddresses.models)
|
||||
implementation(projects.domain.models)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.tangem.data.dynamicaddresses
|
||||
|
||||
import com.tangem.domain.common.wallets.UserWalletsListRepository
|
||||
import com.tangem.domain.common.wallets.getSyncOrNull
|
||||
import com.tangem.domain.dynamicaddresses.DynamicAddressesFeatureToggles
|
||||
import com.tangem.domain.dynamicaddresses.DynamicAddressesSupportedBlockchains
|
||||
import com.tangem.domain.dynamicaddresses.GetDerivedXpubUseCase
|
||||
|
|
@ -7,6 +9,7 @@ import com.tangem.domain.dynamicaddresses.model.DynamicAddressesStatus
|
|||
import com.tangem.domain.dynamicaddresses.repository.DynamicAddressesRepository
|
||||
import com.tangem.domain.models.network.Network
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import com.tangem.domain.models.wallet.isMultiCurrency
|
||||
import com.tangem.utils.logging.TangemLogger
|
||||
import kotlinx.coroutines.flow.firstOrNull
|
||||
import javax.inject.Inject
|
||||
|
|
@ -21,11 +24,22 @@ class DynamicAddressesInitializer @Inject constructor(
|
|||
private val dynamicAddressesRepository: DynamicAddressesRepository,
|
||||
private val dynamicAddressesFeatureToggles: DynamicAddressesFeatureToggles,
|
||||
private val getDerivedXpubUseCase: GetDerivedXpubUseCase,
|
||||
private val userWalletsListRepository: UserWalletsListRepository,
|
||||
) {
|
||||
|
||||
suspend fun getXpubs(userWalletId: UserWalletId, networks: Set<Network>): Map<Network, String> {
|
||||
if (!dynamicAddressesFeatureToggles.isDynamicAddressesEnabled) return emptyMap()
|
||||
|
||||
/*
|
||||
* Dynamic addresses rely on the server-side wallet accounts list, which is populated only for
|
||||
* multi-currency wallets. Single-currency wallets (Note, s2c, etc.) never populate it, so
|
||||
* DynamicAddressesRepository.getStatus() — backed by WalletAccountsFetcher.get() — would never
|
||||
* emit and firstOrNull() below would suspend forever, hanging the whole balance fetch and leaving
|
||||
* the currency stuck in Loading. Skip such wallets entirely. ([REDACTED_TASK_KEY])
|
||||
*/
|
||||
val userWallet = userWalletsListRepository.getSyncOrNull(userWalletId)
|
||||
if (userWallet == null || !userWallet.isMultiCurrency) return emptyMap()
|
||||
|
||||
val result = mutableMapOf<Network, String>()
|
||||
for (network in networks) {
|
||||
if (!DynamicAddressesSupportedBlockchains.isSupportedByNetworkId(network.rawId)) continue
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue