Updated on 2026-08-14
This commit is contained in:
parent
f086d6bb74
commit
40fe8bb5cb
56 changed files with 82 additions and 1491 deletions
|
|
@ -36,8 +36,6 @@ dependencies {
|
|||
api(projects.domain.visa)
|
||||
// endregion
|
||||
|
||||
implementation(projects.features.tangempay.details.api) // Remove after TANGEM_PAY_ACCOUNTS_REFACTOR_ENABLED
|
||||
|
||||
// region Project - Data
|
||||
implementation(projects.data.common)
|
||||
// endregion
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import com.tangem.domain.common.wallets.getSyncStrict
|
|||
import com.tangem.domain.core.flow.FlowProducerTools
|
||||
import com.tangem.domain.models.account.Account
|
||||
import com.tangem.domain.models.wallet.UserWallet
|
||||
import com.tangem.features.tangempay.TangemPayFeatureToggles
|
||||
import com.tangem.hot.sdk.model.HotWalletId
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import dagger.assisted.Assisted
|
||||
|
|
@ -36,7 +35,6 @@ internal class DefaultSingleAccountListProducer @AssistedInject constructor(
|
|||
@Assisted val params: SingleAccountListProducer.Params,
|
||||
override val flowProducerTools: FlowProducerTools,
|
||||
private val walletAccountListFlowFactory: WalletAccountListFlowFactory,
|
||||
private val tangemPayFeatureToggles: TangemPayFeatureToggles,
|
||||
private val userWalletsListRepository: UserWalletsListRepository,
|
||||
private val dispatchers: CoroutineDispatcherProvider,
|
||||
) : SingleAccountListProducer {
|
||||
|
|
@ -45,16 +43,6 @@ internal class DefaultSingleAccountListProducer @AssistedInject constructor(
|
|||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
override fun produce(): Flow<AccountList> {
|
||||
val accountListFlow: Flow<AccountList> = if (tangemPayFeatureToggles.isTangemPayAccountsRefactorEnabled) {
|
||||
combineWithPaymentAccount()
|
||||
} else {
|
||||
walletAccountListFlowFactory.create(userWalletId = params.userWalletId)
|
||||
}
|
||||
|
||||
return accountListFlow.flowOn(dispatchers.default)
|
||||
}
|
||||
|
||||
private fun combineWithPaymentAccount(): Flow<AccountList> {
|
||||
return walletAccountListFlowFactory.create(params.userWalletId)
|
||||
.map { accountList ->
|
||||
val userWallet = userWalletsListRepository.getSyncStrict(id = params.userWalletId)
|
||||
|
|
@ -66,6 +54,7 @@ internal class DefaultSingleAccountListProducer @AssistedInject constructor(
|
|||
accountList
|
||||
}
|
||||
}
|
||||
.flowOn(dispatchers.default)
|
||||
}
|
||||
|
||||
private fun UserWallet.isPaymentAccountSupported(): Boolean = when (this) {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import com.tangem.domain.core.flow.FlowProducerTools
|
|||
import com.tangem.domain.models.TokensSortType
|
||||
import com.tangem.domain.models.wallet.UserWallet
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import com.tangem.features.tangempay.TangemPayFeatureToggles
|
||||
import com.tangem.hot.sdk.model.HotWalletId
|
||||
import com.tangem.test.core.getEmittedValues
|
||||
import com.tangem.utils.coroutines.TestingCoroutineDispatcherProvider
|
||||
import io.mockk.*
|
||||
|
|
@ -31,21 +31,22 @@ class DefaultSingleAccountListProducerTest {
|
|||
|
||||
private val userWalletId = UserWalletId("011")
|
||||
private val flowProducerTools: FlowProducerTools = mockk()
|
||||
private val tangemPayFeatureToggles = mockk<TangemPayFeatureToggles> {
|
||||
every { this@mockk.isTangemPayAccountsRefactorEnabled } returns false
|
||||
private val userWallet = mockk<UserWallet.Hot> {
|
||||
every { walletId } returns userWalletId
|
||||
every { hotWalletId } returns mockk {
|
||||
every { authType } returns HotWalletId.AuthType.NoPassword
|
||||
}
|
||||
}
|
||||
private val userWalletsListRepository = mockk<UserWalletsListRepository>()
|
||||
private val userWallet = mockk<UserWallet> {
|
||||
every { this@mockk.walletId } returns userWalletId
|
||||
private val userWalletsListRepository = mockk<UserWalletsListRepository> {
|
||||
every { userWallets } returns MutableStateFlow<List<UserWallet>?>(value = listOf(userWallet))
|
||||
}
|
||||
|
||||
private val producer = DefaultSingleAccountListProducer(
|
||||
params = SingleAccountListProducer.Params(userWalletId = userWalletId),
|
||||
walletAccountListFlowFactory = walletAccountListFlowFactory,
|
||||
dispatchers = TestingCoroutineDispatcherProvider(),
|
||||
flowProducerTools = flowProducerTools,
|
||||
tangemPayFeatureToggles = tangemPayFeatureToggles,
|
||||
userWalletsListRepository = userWalletsListRepository,
|
||||
dispatchers = TestingCoroutineDispatcherProvider(),
|
||||
)
|
||||
|
||||
@AfterEach
|
||||
|
|
@ -56,8 +57,6 @@ class DefaultSingleAccountListProducerTest {
|
|||
@Test
|
||||
fun produce() = runTest {
|
||||
// Arrange
|
||||
MutableStateFlow(listOf(userWallet))
|
||||
|
||||
val accountList = AccountList.empty(userWalletId)
|
||||
every { walletAccountListFlowFactory.create(userWalletId) } returns flowOf(accountList)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue