diff --git a/app/src/main/java/com/tangem/tap/data/UserWalletsStoreRepositoryProxy.kt b/app/src/main/java/com/tangem/tap/data/UserWalletsStoreRepositoryProxy.kt deleted file mode 100644 index f167597c1a..0000000000 --- a/app/src/main/java/com/tangem/tap/data/UserWalletsStoreRepositoryProxy.kt +++ /dev/null @@ -1,53 +0,0 @@ -package com.tangem.tap.data - -import com.tangem.common.CompletionResult -import com.tangem.common.catching -import com.tangem.datasource.local.userwallet.UserWalletsStore -import com.tangem.domain.common.wallets.UserWalletsListRepository -import com.tangem.domain.models.wallet.UserWallet -import com.tangem.domain.models.wallet.UserWalletId -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flow - -class UserWalletsStoreRepositoryProxy( - private val userWalletsListRepository: UserWalletsListRepository, -) : UserWalletsStore { - - override val selectedUserWalletOrNull: UserWallet? - get() = userWalletsListRepository.selectedUserWallet.value - - override val userWallets: Flow> - get() = flow { - userWalletsListRepository.load() - userWalletsListRepository.userWallets.collect { - emit(requireNotNull(it)) - } - } - - override val userWalletsSync: List - get() = userWalletsListRepository.userWallets.value.orEmpty() - - override fun getSyncOrNull(key: UserWalletId): UserWallet? { - return userWalletsListRepository.userWallets.value?.find { it.walletId == key } - } - - override fun getSyncStrict(key: UserWalletId): UserWallet { - return requireNotNull(getSyncOrNull(key)) { "Unable to find user wallet with provided ID: $key" } - } - - override suspend fun update( - userWalletId: UserWalletId, - update: suspend (UserWallet) -> UserWallet, - ): CompletionResult { - return catching { - val userWallet = userWalletsListRepository.userWallets.value?.find { it.walletId == userWalletId } - requireNotNull(userWallet) { "Unable to find user wallet with provided ID: $userWalletId" } - val updatedUserWallet = update(userWallet) - userWalletsListRepository.saveWithoutLock( - userWallet = updatedUserWallet, - canOverride = true, - ) - updatedUserWallet - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/di/data/UserWalletsStoreModule.kt b/app/src/main/java/com/tangem/tap/di/data/UserWalletsStoreModule.kt deleted file mode 100644 index 8b9dae8020..0000000000 --- a/app/src/main/java/com/tangem/tap/di/data/UserWalletsStoreModule.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.tangem.tap.di.data - -import com.tangem.datasource.local.userwallet.UserWalletsStore -import com.tangem.domain.common.wallets.UserWalletsListRepository -import com.tangem.tap.data.UserWalletsStoreRepositoryProxy -import dagger.Module -import dagger.Provides -import dagger.hilt.InstallIn -import dagger.hilt.components.SingletonComponent -import javax.inject.Singleton - -@Module -@InstallIn(SingletonComponent::class) -internal object UserWalletsStoreModule { - - @Provides - @Singleton - fun provideUserWalletsStore(userWalletsListRepository: UserWalletsListRepository): UserWalletsStore { - return UserWalletsStoreRepositoryProxy(userWalletsListRepository) - } -} \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/DefaultUserWalletsListRepository.kt b/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/DefaultUserWalletsListRepository.kt index d9541b317a..a45ca9387a 100644 --- a/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/DefaultUserWalletsListRepository.kt +++ b/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/DefaultUserWalletsListRepository.kt @@ -38,9 +38,7 @@ import com.tangem.utils.coroutines.runSuspendCatching import com.tangem.utils.extensions.addOrReplace import com.tangem.utils.extensions.indexOfFirstOrNull import kotlinx.coroutines.NonCancellable -import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.update import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock @@ -69,14 +67,6 @@ internal class DefaultUserWalletsListRepository( private val mutex = Mutex() - override fun getSyncOrNull(id: UserWalletId): UserWallet? { - return userWallets.value?.find { it.walletId == id } - } - - override fun getSyncStrict(id: UserWalletId): UserWallet { - return requireNotNull(getSyncOrNull(id)) { "Unable to find user wallet with provided ID: $id" } - } - override suspend fun load() { mutex.withLock { if (userWallets.value != null) return @@ -111,13 +101,6 @@ internal class DefaultUserWalletsListRepository( } } - override fun loadAndGet(): Flow> = flow { - load() - userWallets.collect { - emit(requireNotNull(it)) - } - } - override suspend fun userWalletsSync(): List { load() return requireNotNull(userWallets.value) { diff --git a/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/UserWalletsKeysRepository.kt b/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/UserWalletsKeysRepository.kt deleted file mode 100644 index 0c196308db..0000000000 --- a/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/UserWalletsKeysRepository.kt +++ /dev/null @@ -1,39 +0,0 @@ -package com.tangem.tap.domain.userWalletList.repository - -import com.tangem.common.CompletionResult -import com.tangem.domain.models.wallet.UserWalletId -import com.tangem.tap.domain.userWalletList.model.UserWalletEncryptionKey - -internal interface UserWalletsKeysRepository { - /** - * Obtaining the encryption keys of all user wallets from the biometric vault. Biometric authentication required - * If that operation runs more than biometric cipher key expiration time then the user will not receive all - * encryption keys - * @return [CompletionResult] of operation with stored [UserWalletEncryptionKey] list - * */ - suspend fun getAll(): CompletionResult> - - /** - * Save the encryption key for user wallet. Biometric authentication not required - * @param encryptionKey [UserWalletEncryptionKey] to save - * @return [CompletionResult] of operation - * */ - suspend fun save(encryptionKey: UserWalletEncryptionKey): CompletionResult - - /** - * Delete encryption keys for user wallets. Biometric authentication not required - * @param userWalletsIds List of [UserWalletId] whose encryption keys will be deleted - * */ - suspend fun delete(userWalletsIds: List) - - /** - * Clear all encryption keys for user wallets. Biometric authentication not required - * */ - suspend fun clear() - - /** - * Determine if the user has saved user wallets - * @return [Boolean] true if user has saved wallets - * */ - fun hasSavedEncryptionKeys(): Boolean -} \ No newline at end of file diff --git a/core/datasource/src/main/java/com/tangem/datasource/local/userwallet/UserWalletsStore.kt b/core/datasource/src/main/java/com/tangem/datasource/local/userwallet/UserWalletsStore.kt deleted file mode 100644 index 8f00255449..0000000000 --- a/core/datasource/src/main/java/com/tangem/datasource/local/userwallet/UserWalletsStore.kt +++ /dev/null @@ -1,28 +0,0 @@ -package com.tangem.datasource.local.userwallet - -import com.tangem.common.CompletionResult -import com.tangem.domain.models.wallet.UserWallet -import com.tangem.domain.models.wallet.UserWalletId -import kotlinx.coroutines.flow.Flow - -@Deprecated( - message = "Use UserWalletsListRepository instead", - replaceWith = ReplaceWith("UserWalletsListRepository"), -) -interface UserWalletsStore { - - val selectedUserWalletOrNull: UserWallet? - - val userWallets: Flow> - - val userWalletsSync: List - - fun getSyncOrNull(key: UserWalletId): UserWallet? - - fun getSyncStrict(key: UserWalletId): UserWallet - - suspend fun update( - userWalletId: UserWalletId, - update: suspend (UserWallet) -> UserWallet, - ): CompletionResult -} \ No newline at end of file diff --git a/data/account/src/main/kotlin/com/tangem/data/account/converter/AccountConverterFactoryContainer.kt b/data/account/src/main/kotlin/com/tangem/data/account/converter/AccountConverterFactoryContainer.kt index 95de2c8111..44a347b369 100644 --- a/data/account/src/main/kotlin/com/tangem/data/account/converter/AccountConverterFactoryContainer.kt +++ b/data/account/src/main/kotlin/com/tangem/data/account/converter/AccountConverterFactoryContainer.kt @@ -1,6 +1,7 @@ package com.tangem.data.account.converter import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.getSyncStrict import com.tangem.domain.models.wallet.UserWalletId import javax.inject.Inject diff --git a/data/account/src/main/kotlin/com/tangem/data/account/producer/AccountListCryptoCurrenciesProducer.kt b/data/account/src/main/kotlin/com/tangem/data/account/producer/AccountListCryptoCurrenciesProducer.kt index 305d08e560..795c6dbc37 100644 --- a/data/account/src/main/kotlin/com/tangem/data/account/producer/AccountListCryptoCurrenciesProducer.kt +++ b/data/account/src/main/kotlin/com/tangem/data/account/producer/AccountListCryptoCurrenciesProducer.kt @@ -5,6 +5,7 @@ import arrow.core.some import com.tangem.data.account.store.AccountsResponseStoreFactory import com.tangem.data.common.currency.ResponseCryptoCurrenciesFactory import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.getSyncStrict import com.tangem.domain.core.flow.FlowProducerTools import com.tangem.domain.models.account.DerivationIndex import com.tangem.domain.models.currency.CryptoCurrency diff --git a/data/account/src/main/kotlin/com/tangem/data/account/producer/DefaultMultiAccountListProducer.kt b/data/account/src/main/kotlin/com/tangem/data/account/producer/DefaultMultiAccountListProducer.kt index 39dc1c5d19..ac2bb1b720 100644 --- a/data/account/src/main/kotlin/com/tangem/data/account/producer/DefaultMultiAccountListProducer.kt +++ b/data/account/src/main/kotlin/com/tangem/data/account/producer/DefaultMultiAccountListProducer.kt @@ -5,6 +5,7 @@ import arrow.core.some import com.tangem.domain.account.models.AccountList import com.tangem.domain.account.producer.MultiAccountListProducer import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.loadAndGet import com.tangem.domain.core.flow.FlowProducerTools import com.tangem.domain.models.wallet.UserWallet import com.tangem.utils.coroutines.CoroutineDispatcherProvider diff --git a/data/account/src/main/kotlin/com/tangem/data/account/producer/DefaultMultiWalletCryptoCurrenciesProducer.kt b/data/account/src/main/kotlin/com/tangem/data/account/producer/DefaultMultiWalletCryptoCurrenciesProducer.kt index 6476babc80..16fa1c9e44 100644 --- a/data/account/src/main/kotlin/com/tangem/data/account/producer/DefaultMultiWalletCryptoCurrenciesProducer.kt +++ b/data/account/src/main/kotlin/com/tangem/data/account/producer/DefaultMultiWalletCryptoCurrenciesProducer.kt @@ -5,6 +5,7 @@ import arrow.core.some import com.tangem.data.common.currency.ResponseCryptoCurrenciesFactory import com.tangem.datasource.local.token.UserTokensResponseStore import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.getSyncStrict import com.tangem.domain.core.flow.FlowProducerTools import com.tangem.domain.models.account.DerivationIndex import com.tangem.domain.models.currency.CryptoCurrency diff --git a/data/account/src/main/kotlin/com/tangem/data/account/producer/WalletAccountListFlowFactory.kt b/data/account/src/main/kotlin/com/tangem/data/account/producer/WalletAccountListFlowFactory.kt index 624eeb6679..a53f2c2e6d 100644 --- a/data/account/src/main/kotlin/com/tangem/data/account/producer/WalletAccountListFlowFactory.kt +++ b/data/account/src/main/kotlin/com/tangem/data/account/producer/WalletAccountListFlowFactory.kt @@ -7,6 +7,7 @@ import com.tangem.data.common.currency.CardCryptoCurrencyFactory import com.tangem.domain.account.models.AccountList import com.tangem.domain.card.common.util.cardTypesResolver import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.getSyncStrict import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.models.wallet.UserWalletId import com.tangem.domain.models.wallet.isMultiCurrency diff --git a/data/account/src/main/kotlin/com/tangem/data/account/utils/DefaultWalletAccountsResponseFactory.kt b/data/account/src/main/kotlin/com/tangem/data/account/utils/DefaultWalletAccountsResponseFactory.kt index e49529c64f..8712b7eae6 100644 --- a/data/account/src/main/kotlin/com/tangem/data/account/utils/DefaultWalletAccountsResponseFactory.kt +++ b/data/account/src/main/kotlin/com/tangem/data/account/utils/DefaultWalletAccountsResponseFactory.kt @@ -8,6 +8,7 @@ import com.tangem.datasource.api.tangemTech.models.account.GetWalletAccountsResp import com.tangem.datasource.api.tangemTech.models.account.WalletAccountDTO import com.tangem.domain.account.models.AccountList import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.getSyncOrNull import com.tangem.domain.models.account.Account import com.tangem.domain.models.account.AccountId import com.tangem.domain.models.account.DerivationIndex diff --git a/data/account/src/test/java/com/tangem/data/account/producer/DefaultMultiAccountListProducerTest.kt b/data/account/src/test/java/com/tangem/data/account/producer/DefaultMultiAccountListProducerTest.kt index d080bf325f..5a3723c4ad 100644 --- a/data/account/src/test/java/com/tangem/data/account/producer/DefaultMultiAccountListProducerTest.kt +++ b/data/account/src/test/java/com/tangem/data/account/producer/DefaultMultiAccountListProducerTest.kt @@ -27,7 +27,7 @@ import org.junit.jupiter.api.TestInstance @TestInstance(TestInstance.Lifecycle.PER_CLASS) class DefaultMultiAccountListProducerTest { - private val userWalletsListRepository: UserWalletsListRepository = mockk() + private val userWalletsListRepository: UserWalletsListRepository = mockk(relaxUnitFun = true) private val walletAccountListFlowFactory: WalletAccountListFlowFactory = mockk() private val flowProducerTools: FlowProducerTools = mockk() @@ -53,7 +53,7 @@ class DefaultMultiAccountListProducerTest { fun produce() = runTest { // Arrange val userWalletsFlow = MutableStateFlow(value = listOf(userWallet)) - every { userWalletsListRepository.loadAndGet() } returns userWalletsFlow + every { userWalletsListRepository.userWallets } returns userWalletsFlow val accountList = AccountList.empty(userWalletId) every { walletAccountListFlowFactory.create(userWalletId) } returns flowOf(accountList) @@ -65,8 +65,9 @@ class DefaultMultiAccountListProducerTest { val expected = listOf(accountList) Truth.assertThat(actual).containsExactly(expected) - coVerify(ordering = Ordering.SEQUENCE) { - userWalletsListRepository.loadAndGet() + coVerifySequence { + userWalletsListRepository.load() + userWalletsListRepository.userWallets walletAccountListFlowFactory.create(userWalletId) } } @@ -75,7 +76,7 @@ class DefaultMultiAccountListProducerTest { fun `flow will updated if factoryFlow is updated`() = runTest { // Arrange val userWalletsFlow = MutableStateFlow(value = listOf(userWallet)) - every { userWalletsListRepository.loadAndGet() } returns userWalletsFlow + every { userWalletsListRepository.userWallets } returns userWalletsFlow val accountList = AccountList.empty(userWalletId) val updatedAccountList = AccountList.empty(userWalletId = userWalletId, sortType = TokensSortType.NONE) @@ -97,10 +98,12 @@ class DefaultMultiAccountListProducerTest { // Assert (second emission) Truth.assertThat(secondEmission).containsExactly(listOf(updatedAccountList)) - coVerify(ordering = Ordering.SEQUENCE) { - userWalletsListRepository.loadAndGet() + coVerifySequence { + userWalletsListRepository.load() + userWalletsListRepository.userWallets walletAccountListFlowFactory.create(userWalletId) - userWalletsListRepository.loadAndGet() + userWalletsListRepository.load() + userWalletsListRepository.userWallets walletAccountListFlowFactory.create(userWalletId) } } @@ -109,7 +112,7 @@ class DefaultMultiAccountListProducerTest { fun `flow is filtered the same response`() = runTest { // Arrange val userWalletsFlow = MutableStateFlow(value = listOf(userWallet)) - every { userWalletsListRepository.loadAndGet() } returns userWalletsFlow + every { userWalletsListRepository.userWallets } returns userWalletsFlow val accountList = AccountList.empty(userWalletId) val factoryFlow = MutableStateFlow(null) @@ -130,10 +133,12 @@ class DefaultMultiAccountListProducerTest { // Assert (second emission) Truth.assertThat(secondEmission).containsExactly(listOf(accountList)) - coVerify(ordering = Ordering.SEQUENCE) { - userWalletsListRepository.loadAndGet() + coVerifySequence { + userWalletsListRepository.load() + userWalletsListRepository.userWallets walletAccountListFlowFactory.create(userWalletId) - userWalletsListRepository.loadAndGet() + userWalletsListRepository.load() + userWalletsListRepository.userWallets walletAccountListFlowFactory.create(userWalletId) } } @@ -143,7 +148,7 @@ class DefaultMultiAccountListProducerTest { fun `flow returns empty list if factory throws exception`() = runTest { // Arrange val userWalletsFlow = MutableStateFlow(value = listOf(userWallet)) - every { userWalletsListRepository.loadAndGet() } returns userWalletsFlow + every { userWalletsListRepository.userWallets } returns userWalletsFlow val exception = RuntimeException("Converter error") every { walletAccountListFlowFactory.create(userWalletId) } throws exception @@ -155,8 +160,9 @@ class DefaultMultiAccountListProducerTest { val expected = emptyList() Truth.assertThat(actual).containsExactly(expected) - coVerify(ordering = Ordering.SEQUENCE) { - userWalletsListRepository.loadAndGet() + coVerifySequence { + userWalletsListRepository.load() + userWalletsListRepository.userWallets walletAccountListFlowFactory.create(userWalletId) } } @@ -164,8 +170,8 @@ class DefaultMultiAccountListProducerTest { @Test fun `flow is empty if userWalletsFlow returns empty flow`() = runTest { // Arrange - val userWalletsFlow = emptyFlow>() - every { userWalletsListRepository.loadAndGet() } returns userWalletsFlow + val userWalletsFlow = MutableStateFlow>(emptyList()) + every { userWalletsListRepository.userWallets } returns userWalletsFlow // Act val actual = producer.produce().let(::getEmittedValues) @@ -173,7 +179,10 @@ class DefaultMultiAccountListProducerTest { // Assert Truth.assertThat(actual).isEmpty() // no emissions - coVerify(exactly = 1) { userWalletsListRepository.loadAndGet() } + coVerify(exactly = 1) { + userWalletsListRepository.load() + userWalletsListRepository.userWallets + } coVerify(inverse = true) { walletAccountListFlowFactory.create(any()) } } @@ -181,7 +190,7 @@ class DefaultMultiAccountListProducerTest { fun `flow is empty if factory returns empty flow`() = runTest { // Arrange val userWalletsFlow = MutableStateFlow(value = listOf(userWallet)) - every { userWalletsListRepository.loadAndGet() } returns userWalletsFlow + every { userWalletsListRepository.userWallets } returns userWalletsFlow every { walletAccountListFlowFactory.create(userWalletId) } returns emptyFlow() @@ -191,8 +200,9 @@ class DefaultMultiAccountListProducerTest { // Assert Truth.assertThat(actual).isEmpty() // no emissions - coVerify(ordering = Ordering.SEQUENCE) { - userWalletsListRepository.loadAndGet() + coVerifySequence { + userWalletsListRepository.load() + userWalletsListRepository.userWallets walletAccountListFlowFactory.create(userWalletId) } } @@ -206,7 +216,7 @@ class DefaultMultiAccountListProducerTest { } val userWalletsFlow = MutableStateFlow(listOf(userWallet, userWallet2)) - every { userWalletsListRepository.loadAndGet() } returns userWalletsFlow + every { userWalletsListRepository.userWallets } returns userWalletsFlow val accountList = AccountList.empty(userWalletId) every { walletAccountListFlowFactory.create(userWalletId) } returns flowOf(accountList) @@ -218,8 +228,9 @@ class DefaultMultiAccountListProducerTest { // Assert Truth.assertThat(actual).isEmpty() // no emissions - coVerify(ordering = Ordering.SEQUENCE) { - userWalletsListRepository.loadAndGet() + coVerifySequence { + userWalletsListRepository.load() + userWalletsListRepository.userWallets walletAccountListFlowFactory.create(userWalletId) walletAccountListFlowFactory.create(userWalletId2) } diff --git a/data/account/src/test/java/com/tangem/data/account/producer/DefaultMultiWalletCryptoCurrenciesProducerTest.kt b/data/account/src/test/java/com/tangem/data/account/producer/DefaultMultiWalletCryptoCurrenciesProducerTest.kt index a923d82c5c..d1df425b53 100644 --- a/data/account/src/test/java/com/tangem/data/account/producer/DefaultMultiWalletCryptoCurrenciesProducerTest.kt +++ b/data/account/src/test/java/com/tangem/data/account/producer/DefaultMultiWalletCryptoCurrenciesProducerTest.kt @@ -59,7 +59,9 @@ internal class DefaultMultiWalletCryptoCurrenciesProducerTest { // Arrange val userTokensResponseFlow = flowOf(null) - every { userWalletsListRepository.getSyncStrict(params.userWalletId) } returns userWallet + val userWalletsFlow = MutableStateFlow(listOf(userWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow every { userTokensResponseStore.get(params.userWalletId) } returns userTokensResponseFlow // Act @@ -72,7 +74,7 @@ internal class DefaultMultiWalletCryptoCurrenciesProducerTest { Truth.assertThat(actual.first()).isEqualTo(expected) verifyOrder { - userWalletsListRepository.getSyncStrict(params.userWalletId) + userWalletsListRepository.userWallets userTokensResponseStore.get(params.userWalletId) } @@ -113,7 +115,9 @@ internal class DefaultMultiWalletCryptoCurrenciesProducerTest { cryptoCurrencyFactory.createCoin(Blockchain.Bitcoin), ) - every { userWalletsListRepository.getSyncStrict(params.userWalletId) } returns userWallet + val userWalletsFlow = MutableStateFlow(listOf(userWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow every { userTokensResponseStore.get(params.userWalletId) } returns userTokensResponseFlow every { @@ -146,7 +150,7 @@ internal class DefaultMultiWalletCryptoCurrenciesProducerTest { Truth.assertThat(actual1.first()).isEqualTo(expected1) verifyOrder { - userWalletsListRepository.getSyncStrict(params.userWalletId) + userWalletsListRepository.userWallets userTokensResponseStore.get(params.userWalletId) responseCryptoCurrenciesFactory.createCurrencies( response = userTokensResponse, @@ -188,7 +192,9 @@ internal class DefaultMultiWalletCryptoCurrenciesProducerTest { val cryptoCurrencies = emptySet() - every { userWalletsListRepository.getSyncStrict(params.userWalletId) } returns userWallet + val userWalletsFlow = MutableStateFlow(listOf(userWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow every { userTokensResponseStore.get(params.userWalletId) } returns userTokensResponseFlow every { @@ -213,7 +219,7 @@ internal class DefaultMultiWalletCryptoCurrenciesProducerTest { Truth.assertThat(actual1.first()).isEqualTo(expected1) verifyOrder { - userWalletsListRepository.getSyncStrict(params.userWalletId) + userWalletsListRepository.userWallets userTokensResponseStore.get(params.userWalletId) responseCryptoCurrenciesFactory.createCurrencies( response = userTokensResponse, @@ -257,7 +263,9 @@ internal class DefaultMultiWalletCryptoCurrenciesProducerTest { } .buffer(capacity = 5) - every { userWalletsListRepository.getSyncStrict(params.userWalletId) } returns userWallet + val userWalletsFlow = MutableStateFlow(listOf(userWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow every { userTokensResponseStore.get(params.userWalletId) } returns userTokensResponseFlow every { @@ -279,7 +287,7 @@ internal class DefaultMultiWalletCryptoCurrenciesProducerTest { Truth.assertThat(actual1.first()).isEqualTo(expected1) verifyOrder { - userWalletsListRepository.getSyncStrict(params.userWalletId) + userWalletsListRepository.userWallets userTokensResponseStore.get(params.userWalletId) } @@ -304,7 +312,9 @@ internal class DefaultMultiWalletCryptoCurrenciesProducerTest { @Test fun `flow is empty if store returns empty flow`() = runTest { // Arrange - every { userWalletsListRepository.getSyncStrict(params.userWalletId) } returns userWallet + val userWalletsFlow = MutableStateFlow(listOf(userWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow every { userTokensResponseStore.get(params.userWalletId) } returns emptyFlow() // Act @@ -316,7 +326,7 @@ internal class DefaultMultiWalletCryptoCurrenciesProducerTest { Truth.assertThat(actual.first()).isEqualTo(expected) verifyOrder { - userWalletsListRepository.getSyncStrict(params.userWalletId) + userWalletsListRepository.userWallets userTokensResponseStore.get(params.userWalletId) } @@ -329,10 +339,13 @@ internal class DefaultMultiWalletCryptoCurrenciesProducerTest { fun `produce throws exception if UserWallet isn't multi-currency wallet`() = runTest { // Arrange val mockUserWallet = mockk { + every { walletId } returns userWallet.walletId every { isMultiCurrency } returns false } - every { userWalletsListRepository.getSyncStrict(params.userWalletId) } returns mockUserWallet + val userWalletsFlow = MutableStateFlow(listOf(mockUserWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow // Act val actual = runCatching { producer.produce() }.exceptionOrNull() @@ -345,7 +358,7 @@ internal class DefaultMultiWalletCryptoCurrenciesProducerTest { Truth.assertThat(actual).isInstanceOf(expected::class.java) Truth.assertThat(actual).hasMessageThat().isEqualTo(expected.message) - verifyOrder { userWalletsListRepository.getSyncStrict(params.userWalletId) } + verifyOrder { userWalletsListRepository.userWallets } verify(inverse = true) { userTokensResponseStore.get(any()) diff --git a/data/account/src/test/java/com/tangem/data/account/producer/WalletAccountListFlowFactoryTest.kt b/data/account/src/test/java/com/tangem/data/account/producer/WalletAccountListFlowFactoryTest.kt index 61d285462f..e0abc97e2a 100644 --- a/data/account/src/test/java/com/tangem/data/account/producer/WalletAccountListFlowFactoryTest.kt +++ b/data/account/src/test/java/com/tangem/data/account/producer/WalletAccountListFlowFactoryTest.kt @@ -70,7 +70,9 @@ class WalletAccountListFlowFactoryTest { every { this@mockk.isMultiCurrency } returns true } - every { userWalletsListRepository.getSyncStrict(userWalletId) } returns userWallet + val userWalletsFlow = MutableStateFlow(listOf(userWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow val accountsResponse = createGetWalletAccountsResponse(userWalletId) every { accountsResponseStoreFactory.create(userWalletId) } returns accountsResponseStore @@ -88,7 +90,8 @@ class WalletAccountListFlowFactoryTest { val expected = accountList Truth.assertThat(actual).containsExactly(expected) - coVerify(ordering = Ordering.SEQUENCE) { + coVerifySequence { + userWalletsListRepository.userWallets accountsResponseStoreFactory.create(userWalletId) accountsResponseStore.data accountListConverterFactory.create(userWallet) @@ -105,7 +108,9 @@ class WalletAccountListFlowFactoryTest { fun `create for single wallet`() = runTest { val userWallet = MockUserWalletFactory.create().copy(isMultiCurrency = false) - every { userWalletsListRepository.getSyncStrict(userWallet.walletId) } returns userWallet + val userWalletsFlow = MutableStateFlow(listOf(userWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow val currency = cryptoCurrencyFactory.ethereum every { cardCryptoCurrencyFactory.createPrimaryCurrencyForSingleCurrencyCard(userWallet) } returns currency @@ -117,11 +122,12 @@ class WalletAccountListFlowFactoryTest { val expected = AccountList.empty(userWalletId = userWallet.walletId, cryptoCurrencies = setOf(currency)) Truth.assertThat(actual).containsExactly(expected) - coVerify(ordering = Ordering.SEQUENCE) { + coVerifySequence { cardCryptoCurrencyFactory.createPrimaryCurrencyForSingleCurrencyCard(userWallet) } coVerify(inverse = true) { + userWalletsListRepository.userWallets cardCryptoCurrencyFactory.createCurrenciesForSingleCurrencyCardWithToken(userWallet = any()) accountsResponseStoreFactory.create(any()) accountsResponseStore.data @@ -134,7 +140,9 @@ class WalletAccountListFlowFactoryTest { fun `flow is created for single wallet with token`() = runTest { val nodl = MockUserWalletFactory.createSingleWalletWithToken() - every { userWalletsListRepository.getSyncStrict(nodl.walletId) } returns nodl + val userWalletsFlow = MutableStateFlow(listOf(nodl)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow val currencies = cryptoCurrencyFactory.ethereumAndStellar.toSet() every { @@ -148,7 +156,8 @@ class WalletAccountListFlowFactoryTest { val expected = AccountList.empty(userWalletId = nodl.walletId, cryptoCurrencies = currencies) Truth.assertThat(actual).containsExactly(expected) - coVerify(ordering = Ordering.SEQUENCE) { + coVerifySequence { + userWalletsListRepository.userWallets cardCryptoCurrencyFactory.createCurrenciesForSingleCurrencyCardWithToken(userWallet = nodl) } diff --git a/data/account/src/test/java/com/tangem/data/account/utils/DefaultWalletAccountsResponseFactoryTest.kt b/data/account/src/test/java/com/tangem/data/account/utils/DefaultWalletAccountsResponseFactoryTest.kt index 6ed7920120..afb50f75c3 100644 --- a/data/account/src/test/java/com/tangem/data/account/utils/DefaultWalletAccountsResponseFactoryTest.kt +++ b/data/account/src/test/java/com/tangem/data/account/utils/DefaultWalletAccountsResponseFactoryTest.kt @@ -13,7 +13,11 @@ import com.tangem.domain.common.wallets.UserWalletsListRepository import com.tangem.domain.models.account.Account import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.models.wallet.UserWalletId -import io.mockk.* +import io.mockk.clearMocks +import io.mockk.coVerifyOrder +import io.mockk.every +import io.mockk.mockk +import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.test.runTest import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.BeforeEach @@ -63,7 +67,9 @@ class DefaultWalletAccountsResponseFactoryTest { tokens = emptyList(), ) - coEvery { userWalletsListRepository.getSyncOrNull(userWalletId) } returns null + val userWalletsFlow = MutableStateFlow?>(null) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow every { userTokensResponseFactory.createDefaultResponse( userWallet = null, @@ -89,7 +95,7 @@ class DefaultWalletAccountsResponseFactoryTest { Truth.assertThat(actual).isEqualTo(expected) coVerifyOrder { - userWalletsListRepository.getSyncOrNull(userWalletId) + userWalletsListRepository.userWallets userTokensResponseFactory.createDefaultResponse( userWallet = null, networkFactory = networkFactory, @@ -105,7 +111,9 @@ class DefaultWalletAccountsResponseFactoryTest { every { walletId } returns userWalletId } - coEvery { userWalletsListRepository.getSyncOrNull(userWalletId) } returns userWallet + val userWalletsFlow = MutableStateFlow(listOf(userWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow val accounts = AccountList.empty(userWallet.walletId).accounts .filterIsInstance() @@ -145,7 +153,7 @@ class DefaultWalletAccountsResponseFactoryTest { Truth.assertThat(actual).isEqualTo(expected) coVerifyOrder { - userWalletsListRepository.getSyncOrNull(userWalletId) + userWalletsListRepository.userWallets cryptoPortfolioConverter.convertListBack(accounts) userTokensResponseFactory.createDefaultResponse( userWallet = userWallet, @@ -165,7 +173,9 @@ class DefaultWalletAccountsResponseFactoryTest { val accounts = AccountList.empty(userWallet.walletId).accounts .filterIsInstance() - coEvery { userWalletsListRepository.getSyncOrNull(userWalletId) } returns userWallet + val userWalletsFlow = MutableStateFlow(listOf(userWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow val defaultResponse = UserTokensResponse( group = UserTokensResponse.GroupType.NETWORK, @@ -206,7 +216,9 @@ class DefaultWalletAccountsResponseFactoryTest { val userWallet = mockk(relaxed = true) { every { walletId } returns userWalletId } - coEvery { userWalletsListRepository.getSyncOrNull(userWalletId) } returns userWallet + val userWalletsFlow = MutableStateFlow(listOf(userWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow val userTokensResponse = UserTokensResponse( group = UserTokensResponse.GroupType.NETWORK, diff --git a/data/common/src/main/kotlin/com/tangem/data/common/currency/DefaultCardCryptoCurrencyFactory.kt b/data/common/src/main/kotlin/com/tangem/data/common/currency/DefaultCardCryptoCurrencyFactory.kt index c10ff92538..a55c9c0da8 100644 --- a/data/common/src/main/kotlin/com/tangem/data/common/currency/DefaultCardCryptoCurrencyFactory.kt +++ b/data/common/src/main/kotlin/com/tangem/data/common/currency/DefaultCardCryptoCurrencyFactory.kt @@ -9,6 +9,7 @@ import com.tangem.datasource.local.token.UserTokensResponseStore import com.tangem.domain.account.featuretoggle.AccountsFeatureToggles import com.tangem.domain.card.common.util.cardTypesResolver import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.getSyncStrict import com.tangem.domain.demo.models.DemoConfig import com.tangem.domain.models.account.DerivationIndex import com.tangem.domain.models.currency.CryptoCurrency diff --git a/data/common/src/main/kotlin/com/tangem/data/common/currency/UserTokensSaver.kt b/data/common/src/main/kotlin/com/tangem/data/common/currency/UserTokensSaver.kt index f203b6bb3c..cff0ae1d6d 100644 --- a/data/common/src/main/kotlin/com/tangem/data/common/currency/UserTokensSaver.kt +++ b/data/common/src/main/kotlin/com/tangem/data/common/currency/UserTokensSaver.kt @@ -13,6 +13,7 @@ import com.tangem.datasource.local.appsflyer.AppsFlyerStore import com.tangem.datasource.local.token.UserTokensResponseStore import com.tangem.domain.account.featuretoggle.AccountsFeatureToggles import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.getSyncOrNull import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.models.wallet.UserWalletId import com.tangem.utils.coroutines.CoroutineDispatcherProvider diff --git a/data/common/src/main/kotlin/com/tangem/data/common/wallet/DefaultWalletServerBinder.kt b/data/common/src/main/kotlin/com/tangem/data/common/wallet/DefaultWalletServerBinder.kt index ee977ee128..57272ffb53 100644 --- a/data/common/src/main/kotlin/com/tangem/data/common/wallet/DefaultWalletServerBinder.kt +++ b/data/common/src/main/kotlin/com/tangem/data/common/wallet/DefaultWalletServerBinder.kt @@ -5,6 +5,7 @@ import com.tangem.datasource.api.tangemTech.TangemTechApi import com.tangem.datasource.api.tangemTech.converters.WalletIdBodyConverter import com.tangem.datasource.local.appsflyer.AppsFlyerStore import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.getSyncOrNull import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.models.wallet.UserWalletId import com.tangem.utils.coroutines.CoroutineDispatcherProvider diff --git a/data/common/src/test/kotlin/com/tangem/data/common/currency/DefaultCardCryptoCurrencyFactoryTest.kt b/data/common/src/test/kotlin/com/tangem/data/common/currency/DefaultCardCryptoCurrencyFactoryTest.kt index 28aafd0069..eb90a1efb0 100644 --- a/data/common/src/test/kotlin/com/tangem/data/common/currency/DefaultCardCryptoCurrencyFactoryTest.kt +++ b/data/common/src/test/kotlin/com/tangem/data/common/currency/DefaultCardCryptoCurrencyFactoryTest.kt @@ -24,6 +24,7 @@ import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.models.wallet.UserWalletId import com.tangem.test.core.ProvideTestModels import io.mockk.* +import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.test.runTest import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Nested @@ -78,11 +79,12 @@ internal class DefaultCardCryptoCurrencyFactoryTest { fun `create currencies in ETH for multi-currency wallet`(model: CreateTestModel.MultiWallet) = runTest { // Arrange val userWallet = createMultiWallet() + val userWalletsFlow = MutableStateFlow(listOf(userWallet)) val userTokensResponse = model.userTokensResponse val network = ethereum.network every { accountsFeatureToggles.isFeatureEnabled } returns false - coEvery { userWalletsListRepository.getSyncStrict(id = userWallet.walletId) } returns userWallet + every { userWalletsListRepository.userWallets } returns userWalletsFlow coEvery { userTokensResponseStore.getSyncOrNull(userWallet.walletId) } returns userTokensResponse // Act @@ -94,7 +96,7 @@ internal class DefaultCardCryptoCurrencyFactoryTest { Truth.assertThat(actual).isEqualTo(expected) coVerifyOrder { - userWalletsListRepository.getSyncStrict(id = userWallet.walletId) + userWalletsListRepository.userWallets userTokensResponseStore.getSyncOrNull(userWalletId = userWallet.walletId) } } @@ -130,8 +132,9 @@ internal class DefaultCardCryptoCurrencyFactoryTest { fun `create currencies for single-currency wallet (ETH)`(model: CreateTestModel.SingleWallet) = runTest { // Arrange val userWallet = createSingleWallet() + val userWalletsFlow = MutableStateFlow(listOf(userWallet)) - coEvery { userWalletsListRepository.getSyncStrict(id = userWallet.walletId) } returns userWallet + every { userWalletsListRepository.userWallets } returns userWalletsFlow // Act val actual = factory.create(userWalletId = userWallet.walletId, network = model.network) @@ -142,7 +145,7 @@ internal class DefaultCardCryptoCurrencyFactoryTest { Truth.assertThat(actual).isEqualTo(expected) coVerifyOrder { - userWalletsListRepository.getSyncStrict(id = userWallet.walletId) + userWalletsListRepository.userWallets userWallet.scanResponse.cardTypesResolver.getBlockchain() } @@ -168,8 +171,9 @@ internal class DefaultCardCryptoCurrencyFactoryTest { ) = runTest { // Arrange val userWallet = MockUserWalletFactory.createSingleWalletWithToken() + val userWalletsFlow = MutableStateFlow(listOf(userWallet)) - coEvery { userWalletsListRepository.getSyncStrict(id = userWallet.walletId) } returns userWallet + every { userWalletsListRepository.userWallets } returns userWalletsFlow // Act val actual = factory.create(userWalletId = userWallet.walletId, network = model.network) @@ -186,7 +190,7 @@ internal class DefaultCardCryptoCurrencyFactoryTest { Truth.assertThat(actual).isEqualTo(expected) coVerifyOrder { - userWalletsListRepository.getSyncStrict(id = userWallet.walletId) + userWalletsListRepository.userWallets userWallet.scanResponse.cardTypesResolver.getBlockchain() } diff --git a/data/common/src/test/kotlin/com/tangem/data/common/currency/UserTokensSaverTest.kt b/data/common/src/test/kotlin/com/tangem/data/common/currency/UserTokensSaverTest.kt index 9623d72208..16bb9deefe 100644 --- a/data/common/src/test/kotlin/com/tangem/data/common/currency/UserTokensSaverTest.kt +++ b/data/common/src/test/kotlin/com/tangem/data/common/currency/UserTokensSaverTest.kt @@ -14,6 +14,7 @@ import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.models.wallet.UserWalletId import com.tangem.utils.coroutines.TestingCoroutineDispatcherProvider import io.mockk.* +import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.test.runTest import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -118,8 +119,10 @@ class UserTokensSaverTest { val error = ApiResponseError.UnknownException(Exception("API Error")) var onFailSendCalled = false + val userWalletsFlow = MutableStateFlow(listOf(userWallet)) + every { accountsFeatureToggles.isFeatureEnabled } returns true - coEvery { userWalletsListRepository.getSyncOrNull(userWalletId) } returns userWallet + every { userWalletsListRepository.userWallets } returns userWalletsFlow coEvery { enricher(userWalletId, response) } returns enrichedResponse coEvery { tangemTechApi.saveTokens(any(), any()) } returns ApiResponse.Error(error) as ApiResponse @@ -132,6 +135,7 @@ class UserTokensSaverTest { // THEN coVerifyOrder { + userWalletsListRepository.userWallets enricher(userWalletId, response) tangemTechApi.saveTokens(userWalletId.stringValue, enrichedResponse) } @@ -165,7 +169,9 @@ class UserTokensSaverTest { walletType = WalletType.COLD, ) - coEvery { userWalletsListRepository.getSyncOrNull(userWalletId) } returns userWallet + val userWalletsFlow = MutableStateFlow(listOf(userWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow coEvery { enricher(userWalletId, response) } returns enrichedResponse coEvery { tangemTechApi.saveTokens(userWalletId.stringValue, enrichedResponse) @@ -177,6 +183,7 @@ class UserTokensSaverTest { // THEN coVerifyOrder { enricher(userWalletId, response) + userWalletsListRepository.userWallets tangemTechApi.saveTokens(userWalletId.stringValue, enrichedResponse) } } diff --git a/data/common/src/test/kotlin/com/tangem/data/common/wallet/DefaultWalletServerBinderTest.kt b/data/common/src/test/kotlin/com/tangem/data/common/wallet/DefaultWalletServerBinderTest.kt index e599ae0254..c1c4e5ceef 100644 --- a/data/common/src/test/kotlin/com/tangem/data/common/wallet/DefaultWalletServerBinderTest.kt +++ b/data/common/src/test/kotlin/com/tangem/data/common/wallet/DefaultWalletServerBinderTest.kt @@ -14,6 +14,7 @@ import com.tangem.domain.wallets.models.AppsFlyerConversionData import com.tangem.utils.coroutines.CoroutineDispatcherProvider import com.tangem.utils.coroutines.TestingCoroutineDispatcherProvider import io.mockk.* +import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.test.runTest import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.Nested @@ -65,7 +66,9 @@ internal class DefaultWalletServerBinderTest { ) val apiResponse = ApiResponse.Success(Unit) - coEvery { userWalletsListRepository.getSyncOrNull(userWalletId) } returns userWallet + val userWalletsFlow = MutableStateFlow(listOf(userWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow coEvery { appsFlyerStore.get() } returns conversionData coEvery { tangemTechApi.createWallet(requestBody) } returns apiResponse @@ -74,7 +77,7 @@ internal class DefaultWalletServerBinderTest { Truth.assertThat(actual).isEqualTo(apiResponse) coVerifyOrder { - userWalletsListRepository.getSyncOrNull(userWalletId) + userWalletsListRepository.userWallets appsFlyerStore.get() tangemTechApi.createWallet(requestBody) } @@ -82,15 +85,15 @@ internal class DefaultWalletServerBinderTest { @Test fun `bind will skipped if userWalletsListRepository returns null`() = runTest { - coEvery { userWalletsListRepository.getSyncOrNull(userWalletId) } returns null + val userWalletsFlow = MutableStateFlow?>(null) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow val actual = binder.bind(userWalletId = userWalletId) Truth.assertThat(actual).isEqualTo(null) - coVerifyOrder { - userWalletsListRepository.getSyncOrNull(userWalletId) - } + coVerifyOrder { userWalletsListRepository.userWallets } coVerify(inverse = true) { appsFlyerStore.get() @@ -107,7 +110,9 @@ internal class DefaultWalletServerBinderTest { ) val apiResponse = ApiResponse.Success(Unit) - coEvery { userWalletsListRepository.getSyncOrNull(userWalletId) } returns userWallet + val userWalletsFlow = MutableStateFlow(listOf(userWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow coEvery { appsFlyerStore.get() } returns null coEvery { tangemTechApi.createWallet(requestBody) } returns apiResponse @@ -116,7 +121,7 @@ internal class DefaultWalletServerBinderTest { Truth.assertThat(actual).isEqualTo(apiResponse) coVerifyOrder { - userWalletsListRepository.getSyncOrNull(userWalletId) + userWalletsListRepository.userWallets appsFlyerStore.get() tangemTechApi.createWallet(requestBody) } @@ -133,7 +138,9 @@ internal class DefaultWalletServerBinderTest { ) val apiResponse = ApiResponse.Error(ApiResponseError.TimeoutException()) as ApiResponse - coEvery { userWalletsListRepository.getSyncOrNull(userWalletId) } returns userWallet + val userWalletsFlow = MutableStateFlow(listOf(userWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow coEvery { appsFlyerStore.get() } returns conversionData coEvery { tangemTechApi.createWallet(requestBody) } returns apiResponse @@ -142,7 +149,7 @@ internal class DefaultWalletServerBinderTest { Truth.assertThat(actual).isEqualTo(apiResponse) coVerifyOrder { - userWalletsListRepository.getSyncOrNull(userWalletId) + userWalletsListRepository.userWallets appsFlyerStore.get() tangemTechApi.createWallet(requestBody) } diff --git a/data/express/src/main/java/com/tangem/data/express/DefaultExpressServiceFetcher.kt b/data/express/src/main/java/com/tangem/data/express/DefaultExpressServiceFetcher.kt index cb16c2ef93..6e97e2c7b5 100644 --- a/data/express/src/main/java/com/tangem/data/express/DefaultExpressServiceFetcher.kt +++ b/data/express/src/main/java/com/tangem/data/express/DefaultExpressServiceFetcher.kt @@ -11,6 +11,7 @@ import com.tangem.datasource.exchangeservice.swap.ExpressUtils.getRefCode import com.tangem.datasource.local.preferences.AppPreferencesStore import com.tangem.datasource.local.token.ExpressAssetsStore import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.getSyncStrict import com.tangem.domain.core.lce.Lce import com.tangem.domain.core.utils.catchOn import com.tangem.domain.core.utils.lceContent diff --git a/data/manage-tokens/src/main/kotlin/com/tangem/data/managetokens/DefaultCustomTokensRepository.kt b/data/manage-tokens/src/main/kotlin/com/tangem/data/managetokens/DefaultCustomTokensRepository.kt index 2617383978..7725874819 100644 --- a/data/manage-tokens/src/main/kotlin/com/tangem/data/managetokens/DefaultCustomTokensRepository.kt +++ b/data/manage-tokens/src/main/kotlin/com/tangem/data/managetokens/DefaultCustomTokensRepository.kt @@ -18,6 +18,7 @@ import com.tangem.domain.card.common.extensions.hotWalletExcludedBlockchains import com.tangem.domain.card.common.extensions.supportedBlockchains import com.tangem.domain.card.common.util.cardTypesResolver import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.getSyncStrict import com.tangem.domain.managetokens.model.AddCustomTokenForm import com.tangem.domain.managetokens.model.ManagedCryptoCurrency import com.tangem.domain.managetokens.repository.CustomTokensRepository diff --git a/data/manage-tokens/src/main/kotlin/com/tangem/data/managetokens/DefaultManageTokensRepository.kt b/data/manage-tokens/src/main/kotlin/com/tangem/data/managetokens/DefaultManageTokensRepository.kt index 4786abe9db..98f8097fbc 100644 --- a/data/manage-tokens/src/main/kotlin/com/tangem/data/managetokens/DefaultManageTokensRepository.kt +++ b/data/manage-tokens/src/main/kotlin/com/tangem/data/managetokens/DefaultManageTokensRepository.kt @@ -27,6 +27,7 @@ import com.tangem.domain.card.common.TapWorkarounds.isTestCard import com.tangem.domain.card.common.extensions.* import com.tangem.domain.card.common.util.cardTypesResolver import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.getSyncStrict import com.tangem.domain.managetokens.model.* import com.tangem.domain.managetokens.model.ManagedCryptoCurrency.SourceNetwork import com.tangem.domain.managetokens.repository.ManageTokensRepository diff --git a/data/markets/src/main/java/com/tangem/data/markets/DefaultMarketsTokenRepository.kt b/data/markets/src/main/java/com/tangem/data/markets/DefaultMarketsTokenRepository.kt index f3a58f68e2..834c80a691 100644 --- a/data/markets/src/main/java/com/tangem/data/markets/DefaultMarketsTokenRepository.kt +++ b/data/markets/src/main/java/com/tangem/data/markets/DefaultMarketsTokenRepository.kt @@ -21,6 +21,7 @@ import com.tangem.datasource.api.markets.models.response.TokenMarketExchangesRes import com.tangem.datasource.local.datastore.RuntimeStateStore import com.tangem.domain.appcurrency.model.AppCurrency import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.getSyncStrict import com.tangem.domain.markets.* import com.tangem.domain.markets.repositories.MarketsTokenRepository import com.tangem.domain.models.account.DerivationIndex diff --git a/data/networks/src/main/java/com/tangem/data/networks/multi/DefaultMultiNetworkStatusProducer.kt b/data/networks/src/main/java/com/tangem/data/networks/multi/DefaultMultiNetworkStatusProducer.kt index f0546b2d68..8406342ea9 100644 --- a/data/networks/src/main/java/com/tangem/data/networks/multi/DefaultMultiNetworkStatusProducer.kt +++ b/data/networks/src/main/java/com/tangem/data/networks/multi/DefaultMultiNetworkStatusProducer.kt @@ -5,6 +5,7 @@ import arrow.core.some import com.tangem.data.common.network.NetworkFactory import com.tangem.data.networks.store.NetworksStatusesStore import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.getSyncOrNull import com.tangem.domain.core.flow.FlowProducerTools import com.tangem.domain.models.network.NetworkStatus import com.tangem.domain.networks.multi.MultiNetworkStatusProducer diff --git a/data/networks/src/test/java/com/tangem/data/networks/multi/DefaultMultiNetworkStatusProducerTest.kt b/data/networks/src/test/java/com/tangem/data/networks/multi/DefaultMultiNetworkStatusProducerTest.kt index f677f10935..4b35a6fa71 100644 --- a/data/networks/src/test/java/com/tangem/data/networks/multi/DefaultMultiNetworkStatusProducerTest.kt +++ b/data/networks/src/test/java/com/tangem/data/networks/multi/DefaultMultiNetworkStatusProducerTest.kt @@ -11,6 +11,7 @@ import com.tangem.data.networks.store.NetworksStatusesStore import com.tangem.data.networks.toSimple import com.tangem.domain.card.configs.GenericCardConfig import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.getSyncOrNull import com.tangem.domain.core.flow.FlowProducerTools import com.tangem.domain.models.network.NetworkStatus import com.tangem.domain.networks.multi.MultiNetworkStatusProducer @@ -65,7 +66,9 @@ internal class DefaultMultiNetworkStatusProducerTest { val networksStatusesFlow = flowOf(simpleStatuses) every { networksStatusesStore.get(params.userWalletId) } returns networksStatusesFlow - every { userWalletsListRepository.getSyncOrNull(params.userWalletId) } returns userWallet + val userWalletsFlow = MutableStateFlow(listOf(userWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow every { networkFactory.create( @@ -94,7 +97,7 @@ internal class DefaultMultiNetworkStatusProducerTest { verifyOrder { networksStatusesStore.get(params.userWalletId) - userWalletsListRepository.getSyncOrNull(params.userWalletId) + userWalletsListRepository.userWallets networkFactory.create( networkId = simpleStatuses.first().id, derivationPath = simpleStatuses.first().id.derivationPath, @@ -129,7 +132,9 @@ internal class DefaultMultiNetworkStatusProducerTest { // region every every { networksStatusesStore.get(params.userWalletId) } returns networksStatusesFlow - every { userWalletsListRepository.getSyncOrNull(params.userWalletId) } returns userWallet + val userWalletsFlow = MutableStateFlow(listOf(userWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow every { networkFactory.create( networkId = simpleStatuses.first().id, @@ -177,7 +182,7 @@ internal class DefaultMultiNetworkStatusProducerTest { Truth.assertThat(actual1.first()).isEqualTo(expected1) verifyOrder { - userWalletsListRepository.getSyncOrNull(params.userWalletId) + userWalletsListRepository.userWallets networkFactory.create( networkId = simpleStatuses.first().id, derivationPath = simpleStatuses.first().id.derivationPath, @@ -202,7 +207,7 @@ internal class DefaultMultiNetworkStatusProducerTest { Truth.assertThat(actual2).isEqualTo(expected2) verifyOrder { - userWalletsListRepository.getSyncOrNull(params.userWalletId) + userWalletsListRepository.userWallets networkFactory.create( networkId = updatedSimpleStatuses.first().id, derivationPath = updatedSimpleStatuses.first().id.derivationPath, @@ -230,7 +235,9 @@ internal class DefaultMultiNetworkStatusProducerTest { // region every every { networksStatusesStore.get(params.userWalletId) } returns networksStatusesFlow - every { userWalletsListRepository.getSyncOrNull(params.userWalletId) } returns userWallet + val userWalletsFlow = MutableStateFlow(listOf(userWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow every { networkFactory.create( @@ -263,7 +270,7 @@ internal class DefaultMultiNetworkStatusProducerTest { Truth.assertThat(actual1.first()).isEqualTo(expected1) verifyOrder { - userWalletsListRepository.getSyncOrNull(params.userWalletId) + userWalletsListRepository.userWallets networkFactory.create( networkId = simpleStatuses.first().id, derivationPath = simpleStatuses.first().id.derivationPath, @@ -312,7 +319,9 @@ internal class DefaultMultiNetworkStatusProducerTest { // region every every { networksStatusesStore.get(params.userWalletId) } returns networksStatusesFlow - every { userWalletsListRepository.getSyncOrNull(params.userWalletId) } returns userWallet + val userWalletsFlow = MutableStateFlow(listOf(userWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow every { networkFactory.create( networkId = simpleStatuses.first().id, @@ -354,7 +363,7 @@ internal class DefaultMultiNetworkStatusProducerTest { Truth.assertThat(actual2.first()).isEqualTo(expected2) verifyOrder { - userWalletsListRepository.getSyncOrNull(params.userWalletId) + userWalletsListRepository.userWallets networkFactory.create( networkId = simpleStatuses.first().id, derivationPath = simpleStatuses.first().id.derivationPath, @@ -382,7 +391,7 @@ internal class DefaultMultiNetworkStatusProducerTest { Truth.assertThat(actual.first()).isEqualTo(expected) verify { networksStatusesStore.get(params.userWalletId) } - verify(inverse = true) { userWalletsListRepository.getSyncOrNull(params.userWalletId) } + verify(inverse = true) { userWalletsListRepository.userWallets } } @Test @@ -398,7 +407,9 @@ internal class DefaultMultiNetworkStatusProducerTest { val networksStatusesFlow = flowOf(simpleStatuses) every { networksStatusesStore.get(params.userWalletId) } returns networksStatusesFlow - every { userWalletsListRepository.getSyncOrNull(params.userWalletId) } returns userWallet + val userWalletsFlow = MutableStateFlow(listOf(userWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow coEvery { networkFactory.create(networkId = any(), any(), any()) } returns null // Act @@ -411,7 +422,7 @@ internal class DefaultMultiNetworkStatusProducerTest { verifyOrder { networksStatusesStore.get(params.userWalletId) - userWalletsListRepository.getSyncOrNull(params.userWalletId) + userWalletsListRepository.userWallets networkFactory.create( networkId = simpleStatuses.first().id, derivationPath = simpleStatuses.first().id.derivationPath, diff --git a/data/nft/src/main/kotlin/com/tangem/data/nft/DefaultNFTRepository.kt b/data/nft/src/main/kotlin/com/tangem/data/nft/DefaultNFTRepository.kt index b16adf3821..7b022349ef 100644 --- a/data/nft/src/main/kotlin/com/tangem/data/nft/DefaultNFTRepository.kt +++ b/data/nft/src/main/kotlin/com/tangem/data/nft/DefaultNFTRepository.kt @@ -18,6 +18,7 @@ import com.tangem.datasource.local.nft.converter.NFTSdkCollectionConverter import com.tangem.datasource.local.nft.converter.NFTSdkCollectionIdentifierConverter import com.tangem.domain.card.common.extensions.canHandleToken import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.getSyncStrict import com.tangem.domain.models.StatusSource import com.tangem.domain.models.currency.CryptoCurrency import com.tangem.domain.models.network.Network diff --git a/data/onramp/src/main/java/com/tangem/data/onramp/DefaultHotCryptoRepository.kt b/data/onramp/src/main/java/com/tangem/data/onramp/DefaultHotCryptoRepository.kt index aa5a415297..6501990863 100644 --- a/data/onramp/src/main/java/com/tangem/data/onramp/DefaultHotCryptoRepository.kt +++ b/data/onramp/src/main/java/com/tangem/data/onramp/DefaultHotCryptoRepository.kt @@ -22,6 +22,8 @@ import com.tangem.domain.account.featuretoggle.AccountsFeatureToggles import com.tangem.domain.card.common.extensions.canHandleBlockchain import com.tangem.domain.card.common.extensions.canHandleToken import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.getSyncStrict +import com.tangem.domain.common.wallets.loadAndGet import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.models.wallet.UserWalletId import com.tangem.domain.onramp.model.HotCryptoCurrency @@ -89,8 +91,7 @@ internal class DefaultHotCryptoRepository( .map { it[userWalletId] } .filterNotNull() .map { response -> - val userWallet = userWalletsListRepository.getSyncOrNull(userWalletId) - ?: error("UserWalletId [$userWalletId] not found") + val userWallet = userWalletsListRepository.getSyncStrict(userWalletId) HotCryptoCurrencyConverter( userWallet = userWallet, diff --git a/data/staking/src/main/java/com/tangem/data/staking/multi/DefaultMultiStakingBalanceFetcher.kt b/data/staking/src/main/java/com/tangem/data/staking/multi/DefaultMultiStakingBalanceFetcher.kt index a8c3926c66..c957ac3d12 100644 --- a/data/staking/src/main/java/com/tangem/data/staking/multi/DefaultMultiStakingBalanceFetcher.kt +++ b/data/staking/src/main/java/com/tangem/data/staking/multi/DefaultMultiStakingBalanceFetcher.kt @@ -18,6 +18,7 @@ import com.tangem.datasource.api.stakekit.models.response.model.YieldDTO import com.tangem.datasource.local.token.P2PEthPoolVaultsStore import com.tangem.datasource.local.token.StakingYieldsStore import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.getSyncOrNull import com.tangem.domain.core.utils.catchOn import com.tangem.domain.models.staking.StakingID import com.tangem.domain.models.wallet.UserWallet diff --git a/data/staking/src/test/kotlin/com/tangem/data/staking/multi/DefaultMultiStakingBalanceFetcherTest.kt b/data/staking/src/test/kotlin/com/tangem/data/staking/multi/DefaultMultiStakingBalanceFetcherTest.kt index d37c4d2c87..3290286794 100644 --- a/data/staking/src/test/kotlin/com/tangem/data/staking/multi/DefaultMultiStakingBalanceFetcherTest.kt +++ b/data/staking/src/test/kotlin/com/tangem/data/staking/multi/DefaultMultiStakingBalanceFetcherTest.kt @@ -16,12 +16,12 @@ import com.tangem.datasource.local.token.P2PEthPoolVaultsStore import com.tangem.datasource.local.token.StakingYieldsStore import com.tangem.domain.common.wallets.UserWalletsListRepository import com.tangem.domain.models.staking.StakingID -import com.tangem.domain.models.wallet.UserWalletId import com.tangem.domain.staking.multi.MultiStakingBalanceFetcher import com.tangem.test.core.assertEitherLeft import com.tangem.test.core.assertEitherRight import com.tangem.utils.coroutines.TestingCoroutineDispatcherProvider import io.mockk.* +import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.test.runTest import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -62,7 +62,9 @@ internal class DefaultMultiStakingBalanceFetcherTest { // Arrange val params = MultiStakingBalanceFetcher.Params(userWalletId = userWalletId, stakingIds = tonAndSolanaIds) - coEvery { userWalletsListRepository.getSyncOrNull(params.userWalletId) } returns userWallet + val userWalletsFlow = MutableStateFlow(listOf(userWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow val yields = listOf(MockYieldDTOFactory.create(tonId), MockYieldDTOFactory.create(solanaId)) coEvery { stakingYieldsStore.getSyncWithTimeout() } returns yields @@ -80,7 +82,7 @@ internal class DefaultMultiStakingBalanceFetcherTest { // Assert coVerifyOrder { - userWalletsListRepository.getSyncOrNull(params.userWalletId) + userWalletsListRepository.userWallets stakeKitBalancesStore.refresh(userWalletId = params.userWalletId, stakingIds = tonAndSolanaIds) stakingYieldsStore.getSyncWithTimeout() stakeKitApi.getMultipleYieldBalances(requests) @@ -97,7 +99,9 @@ internal class DefaultMultiStakingBalanceFetcherTest { // Arrange val params = MultiStakingBalanceFetcher.Params(userWalletId = userWalletId, stakingIds = tonAndSolanaIds) - coEvery { userWalletsListRepository.getSyncOrNull(params.userWalletId) } returns userWallet + val userWalletsFlow = MutableStateFlow(listOf(userWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow val yields = listOf(MockYieldDTOFactory.create(tonId)) coEvery { stakingYieldsStore.getSyncWithTimeout() } returns yields @@ -112,7 +116,7 @@ internal class DefaultMultiStakingBalanceFetcherTest { // Assert coVerifyOrder { - userWalletsListRepository.getSyncOrNull(params.userWalletId) + userWalletsListRepository.userWallets stakeKitBalancesStore.refresh(userWalletId = params.userWalletId, stakingIds = tonAndSolanaIds) stakingYieldsStore.getSyncWithTimeout() stakeKitBalancesStore.storeError(userWalletId = userWalletId, stakingIds = setOf(solanaId)) @@ -129,13 +133,15 @@ internal class DefaultMultiStakingBalanceFetcherTest { val params = MultiStakingBalanceFetcher.Params(userWalletId = userWalletId, stakingIds = tonAndSolanaIds) val userWallet = MockUserWalletFactory.create().copy(isMultiCurrency = false) - coEvery { userWalletsListRepository.getSyncOrNull(params.userWalletId) } returns userWallet + val userWalletsFlow = MutableStateFlow(listOf(userWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow // Actual val actual = fetcher.invoke(params) // Assert - coVerifyOrder { userWalletsListRepository.getSyncOrNull(params.userWalletId) } + coVerifyOrder { userWalletsListRepository.userWallets } coVerify(inverse = true) { stakeKitBalancesStore.refresh(userWalletId = any(), stakingIds = any()) @@ -155,13 +161,14 @@ internal class DefaultMultiStakingBalanceFetcherTest { // Arrange val params = MultiStakingBalanceFetcher.Params(userWalletId = userWalletId, stakingIds = tonAndSolanaIds) - coEvery { userWalletsListRepository.getSyncOrNull(params.userWalletId) } returns null + val userWalletsFlow = MutableStateFlow(null) + coEvery { userWalletsListRepository.userWallets } returns userWalletsFlow // Actual val actual = fetcher.invoke(params) // Assert - coVerifyOrder { userWalletsListRepository.getSyncOrNull(params.userWalletId) } + coVerifyOrder { userWalletsListRepository.userWallets } coVerify(inverse = true) { stakeKitBalancesStore.refresh(userWalletId = any(), stakingIds = any()) @@ -181,7 +188,9 @@ internal class DefaultMultiStakingBalanceFetcherTest { // Arrange val params = MultiStakingBalanceFetcher.Params(userWalletId = userWalletId, stakingIds = tonAndSolanaIds) - coEvery { userWalletsListRepository.getSyncOrNull(params.userWalletId) } returns userWallet + val userWalletsFlow = MutableStateFlow(listOf(userWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow coEvery { stakingYieldsStore.getSyncWithTimeout() } returns null // Actual @@ -189,7 +198,7 @@ internal class DefaultMultiStakingBalanceFetcherTest { // Assert coVerifyOrder { - userWalletsListRepository.getSyncOrNull(params.userWalletId) + userWalletsListRepository.userWallets stakeKitBalancesStore.refresh(params.userWalletId, tonAndSolanaIds) stakingYieldsStore.getSyncWithTimeout() stakeKitBalancesStore.storeError(userWalletId, tonAndSolanaIds) @@ -210,7 +219,9 @@ internal class DefaultMultiStakingBalanceFetcherTest { // Arrange val params = MultiStakingBalanceFetcher.Params(userWalletId = userWalletId, stakingIds = tonAndSolanaIds) - coEvery { userWalletsListRepository.getSyncOrNull(params.userWalletId) } returns userWallet + val userWalletsFlow = MutableStateFlow(listOf(userWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow coEvery { stakingYieldsStore.getSyncWithTimeout() } returns emptyList() // Actual @@ -218,7 +229,7 @@ internal class DefaultMultiStakingBalanceFetcherTest { // Assert coVerifyOrder { - userWalletsListRepository.getSyncOrNull(params.userWalletId) + userWalletsListRepository.userWallets stakeKitBalancesStore.refresh(userWalletId = params.userWalletId, stakingIds = tonAndSolanaIds) stakingYieldsStore.getSyncWithTimeout() stakeKitBalancesStore.storeError(userWalletId, tonAndSolanaIds) @@ -239,7 +250,9 @@ internal class DefaultMultiStakingBalanceFetcherTest { // Arrange val params = MultiStakingBalanceFetcher.Params(userWalletId = userWalletId, stakingIds = tonAndSolanaIds) - coEvery { userWalletsListRepository.getSyncOrNull(params.userWalletId) } returns userWallet + val userWalletsFlow = MutableStateFlow(listOf(userWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow val yields = listOf( MockYieldDTOFactory.create(tonId).copy(id = null), @@ -252,7 +265,7 @@ internal class DefaultMultiStakingBalanceFetcherTest { // Assert coVerifyOrder { - userWalletsListRepository.getSyncOrNull(params.userWalletId) + userWalletsListRepository.userWallets stakeKitBalancesStore.refresh(userWalletId = params.userWalletId, stakingIds = tonAndSolanaIds) stakingYieldsStore.getSyncWithTimeout() stakeKitBalancesStore.storeError(userWalletId, tonAndSolanaIds) @@ -273,7 +286,9 @@ internal class DefaultMultiStakingBalanceFetcherTest { // Arrange val params = MultiStakingBalanceFetcher.Params(userWalletId = userWalletId, stakingIds = tonAndSolanaIds) - coEvery { userWalletsListRepository.getSyncOrNull(params.userWalletId) } returns userWallet + val userWalletsFlow = MutableStateFlow(listOf(userWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow val yields = listOf(MockYieldDTOFactory.create(StakingID(integrationId = "polygon", address = "0x1"))) coEvery { stakingYieldsStore.getSyncWithTimeout() } returns yields @@ -283,7 +298,7 @@ internal class DefaultMultiStakingBalanceFetcherTest { // Assert coVerifyOrder { - userWalletsListRepository.getSyncOrNull(params.userWalletId) + userWalletsListRepository.userWallets stakeKitBalancesStore.refresh(userWalletId = params.userWalletId, stakingIds = tonAndSolanaIds) stakingYieldsStore.getSyncWithTimeout() stakeKitBalancesStore.storeError(userWalletId, tonAndSolanaIds) @@ -310,7 +325,9 @@ internal class DefaultMultiStakingBalanceFetcherTest { // Arrange val params = MultiStakingBalanceFetcher.Params(userWalletId = userWalletId, stakingIds = tonAndSolanaIds) - coEvery { userWalletsListRepository.getSyncOrNull(params.userWalletId) } returns userWallet + val userWalletsFlow = MutableStateFlow(listOf(userWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow val yields = listOf(MockYieldDTOFactory.create(tonId), MockYieldDTOFactory.create(solanaId)) coEvery { stakingYieldsStore.getSyncWithTimeout() } returns yields @@ -328,7 +345,7 @@ internal class DefaultMultiStakingBalanceFetcherTest { // Assert coVerifyOrder { - userWalletsListRepository.getSyncOrNull(params.userWalletId) + userWalletsListRepository.userWallets stakeKitBalancesStore.refresh(userWalletId = params.userWalletId, stakingIds = tonAndSolanaIds) stakingYieldsStore.getSyncWithTimeout() stakeKitApi.getMultipleYieldBalances(requests) @@ -343,8 +360,8 @@ internal class DefaultMultiStakingBalanceFetcherTest { } private companion object { - val userWalletId = UserWalletId("011") val userWallet = MockUserWalletFactory.create() + val userWalletId = userWallet.walletId val tonId = MockYieldBalanceWrapperDTOFactory.defaultStakingId val solanaId = StakingID( diff --git a/data/tokens/src/main/kotlin/com/tangem/data/tokens/AccountListCryptoCurrenciesFetcher.kt b/data/tokens/src/main/kotlin/com/tangem/data/tokens/AccountListCryptoCurrenciesFetcher.kt index 2eb230d05d..642add41ce 100644 --- a/data/tokens/src/main/kotlin/com/tangem/data/tokens/AccountListCryptoCurrenciesFetcher.kt +++ b/data/tokens/src/main/kotlin/com/tangem/data/tokens/AccountListCryptoCurrenciesFetcher.kt @@ -5,6 +5,7 @@ import arrow.core.right import com.tangem.data.common.account.WalletAccountsFetcher import com.tangem.datasource.api.tangemTech.models.account.flattenTokens import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.getSyncStrict import com.tangem.domain.core.utils.catchOn import com.tangem.domain.express.ExpressServiceFetcher import com.tangem.domain.express.models.ExpressAsset diff --git a/data/tokens/src/main/kotlin/com/tangem/data/tokens/DefaultMultiWalletCryptoCurrenciesFetcher.kt b/data/tokens/src/main/kotlin/com/tangem/data/tokens/DefaultMultiWalletCryptoCurrenciesFetcher.kt index 8e1b04b9bb..4b563eb468 100644 --- a/data/tokens/src/main/kotlin/com/tangem/data/tokens/DefaultMultiWalletCryptoCurrenciesFetcher.kt +++ b/data/tokens/src/main/kotlin/com/tangem/data/tokens/DefaultMultiWalletCryptoCurrenciesFetcher.kt @@ -11,6 +11,7 @@ import com.tangem.datasource.api.tangemTech.TangemTechApi import com.tangem.datasource.api.tangemTech.models.UserTokensResponse import com.tangem.datasource.local.token.UserTokensResponseStore import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.getSyncStrict import com.tangem.domain.core.utils.catchOn import com.tangem.domain.demo.models.DemoConfig import com.tangem.domain.express.ExpressServiceFetcher diff --git a/data/tokens/src/main/kotlin/com/tangem/data/tokens/repository/DefaultCurrenciesRepository.kt b/data/tokens/src/main/kotlin/com/tangem/data/tokens/repository/DefaultCurrenciesRepository.kt index c8755050b6..b2ec4a4968 100644 --- a/data/tokens/src/main/kotlin/com/tangem/data/tokens/repository/DefaultCurrenciesRepository.kt +++ b/data/tokens/src/main/kotlin/com/tangem/data/tokens/repository/DefaultCurrenciesRepository.kt @@ -17,6 +17,8 @@ import com.tangem.domain.account.featuretoggle.AccountsFeatureToggles import com.tangem.domain.card.CardTypesResolver import com.tangem.domain.card.common.util.cardTypesResolver import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.getSyncStrict +import com.tangem.domain.common.wallets.loadAndGet import com.tangem.domain.core.error.DataError import com.tangem.domain.demo.models.DemoConfig import com.tangem.domain.express.ExpressServiceFetcher diff --git a/data/tokens/src/test/kotlin/com/tangem/data/tokens/AccountListCryptoCurrenciesFetcherTest.kt b/data/tokens/src/test/kotlin/com/tangem/data/tokens/AccountListCryptoCurrenciesFetcherTest.kt index 3e544d681b..3f95f270ca 100644 --- a/data/tokens/src/test/kotlin/com/tangem/data/tokens/AccountListCryptoCurrenciesFetcherTest.kt +++ b/data/tokens/src/test/kotlin/com/tangem/data/tokens/AccountListCryptoCurrenciesFetcherTest.kt @@ -14,6 +14,7 @@ import com.tangem.test.core.assertEither import com.tangem.test.core.assertEitherRight import com.tangem.utils.coroutines.TestingCoroutineDispatcherProvider import io.mockk.* +import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.test.runTest import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -43,8 +44,13 @@ internal class AccountListCryptoCurrenciesFetcherTest { fun `returns failure if wallet is not multi-currency`() = runTest { // Arrange val params = MultiWalletCryptoCurrenciesFetcher.Params(userWalletId = userWalletId) - val mockUserWallet = mockk { every { isMultiCurrency } returns false } - every { userWalletsListRepository.getSyncStrict(id = params.userWalletId) } returns mockUserWallet + val mockUserWallet = mockk { + every { walletId } returns userWalletId + every { isMultiCurrency } returns false + } + val userWalletsFlow = MutableStateFlow(listOf(mockUserWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow // Act val actual = fetcher(params) @@ -55,7 +61,7 @@ internal class AccountListCryptoCurrenciesFetcherTest { ).left() assertEither(actual, expected) - verify { userWalletsListRepository.getSyncStrict(id = params.userWalletId) } + verify { userWalletsListRepository.userWallets } coVerify(inverse = true) { walletAccountsFetcher.fetch(any()) } } @@ -63,10 +69,15 @@ internal class AccountListCryptoCurrenciesFetcherTest { fun `returns accounts if wallet is multi-currency`() = runTest { // Arrange val params = MultiWalletCryptoCurrenciesFetcher.Params(userWalletId = userWalletId) - val mockUserWallet = mockk { every { isMultiCurrency } returns true } + val mockUserWallet = mockk { + every { walletId } returns userWalletId + every { isMultiCurrency } returns true + } val response = mockk(relaxed = true) - every { userWalletsListRepository.getSyncStrict(id = params.userWalletId) } returns mockUserWallet + val userWalletsFlow = MutableStateFlow(listOf(mockUserWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow coEvery { walletAccountsFetcher.fetch(userWalletId = params.userWalletId) } returns response coEvery { expressServiceFetcher.fetch(userWallet = mockUserWallet, assetIds = emptySet()) } returns Unit.right() @@ -77,7 +88,7 @@ internal class AccountListCryptoCurrenciesFetcherTest { assertEitherRight(actual) coVerify(ordering = Ordering.SEQUENCE) { - userWalletsListRepository.getSyncStrict(id = params.userWalletId) + userWalletsListRepository.userWallets walletAccountsFetcher.fetch(userWalletId = params.userWalletId) expressServiceFetcher.fetch(userWallet = mockUserWallet, assetIds = emptySet()) } @@ -87,10 +98,15 @@ internal class AccountListCryptoCurrenciesFetcherTest { fun `returns error if walletAccountsFetcher returns error`() = runTest { // Arrange val params = MultiWalletCryptoCurrenciesFetcher.Params(userWalletId = userWalletId) - val mockUserWallet = mockk { every { isMultiCurrency } returns true } + val mockUserWallet = mockk { + every { walletId } returns userWalletId + every { isMultiCurrency } returns true + } val error = RuntimeException("fetch error") - every { userWalletsListRepository.getSyncStrict(id = params.userWalletId) } returns mockUserWallet + val userWalletsFlow = MutableStateFlow(listOf(mockUserWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow coEvery { walletAccountsFetcher.fetch(userWalletId = params.userWalletId) } throws error // Act @@ -101,7 +117,7 @@ internal class AccountListCryptoCurrenciesFetcherTest { assertEither(actual, expected) coVerify(ordering = Ordering.SEQUENCE) { - userWalletsListRepository.getSyncStrict(id = params.userWalletId) + userWalletsListRepository.userWallets walletAccountsFetcher.fetch(userWalletId = params.userWalletId) } } diff --git a/data/tokens/src/test/kotlin/com/tangem/data/tokens/DefaultMultiWalletCryptoCurrenciesFetcherTest.kt b/data/tokens/src/test/kotlin/com/tangem/data/tokens/DefaultMultiWalletCryptoCurrenciesFetcherTest.kt index b0a5170a5a..1b649ebbe0 100644 --- a/data/tokens/src/test/kotlin/com/tangem/data/tokens/DefaultMultiWalletCryptoCurrenciesFetcherTest.kt +++ b/data/tokens/src/test/kotlin/com/tangem/data/tokens/DefaultMultiWalletCryptoCurrenciesFetcherTest.kt @@ -24,6 +24,7 @@ import com.tangem.domain.tokens.MultiWalletCryptoCurrenciesFetcher import com.tangem.test.core.assertEither import com.tangem.utils.coroutines.TestingCoroutineDispatcherProvider import io.mockk.* +import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.test.runTest import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -76,10 +77,13 @@ internal class DefaultMultiWalletCryptoCurrenciesFetcherTest { val params = MultiWalletCryptoCurrenciesFetcher.Params(userWalletId = userWalletId) val mockUserWallet = mockk { + every { walletId } returns userWalletId every { isMultiCurrency } returns false } - every { userWalletsListRepository.getSyncStrict(params.userWalletId) } returns mockUserWallet + val userWalletsFlow = MutableStateFlow(listOf(mockUserWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow // Act val actual = fetcher(params) @@ -90,7 +94,7 @@ internal class DefaultMultiWalletCryptoCurrenciesFetcherTest { ).left() assertEither(actual, expected) - verifyOrder { userWalletsListRepository.getSyncStrict(id = params.userWalletId) } + verifyOrder { userWalletsListRepository.userWallets } coVerify(inverse = true) { userTokensResponseStore.getSyncOrNull(any()) } @@ -121,7 +125,9 @@ internal class DefaultMultiWalletCryptoCurrenciesFetcherTest { ), ) - every { userWalletsListRepository.getSyncStrict(params.userWalletId) } returns mockUserWallet + val userWalletsFlow = MutableStateFlow(listOf(mockUserWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow coEvery { userTokensResponseStore.getSyncOrNull(userWalletId = params.userWalletId) } returns null every { cardCryptoCurrencyFactory.createDefaultCoinsForMultiCurrencyWallet(mockUserWallet) @@ -145,7 +151,7 @@ internal class DefaultMultiWalletCryptoCurrenciesFetcherTest { assertEither(actual, expected) coVerifyOrder { - userWalletsListRepository.getSyncStrict(id = params.userWalletId) + userWalletsListRepository.userWallets userTokensResponseStore.getSyncOrNull(userWalletId = params.userWalletId) cardCryptoCurrencyFactory.createDefaultCoinsForMultiCurrencyWallet(mockUserWallet) customTokensMerger.mergeIfPresented(userWalletId = params.userWalletId, response = userTokensResponse) @@ -169,7 +175,9 @@ internal class DefaultMultiWalletCryptoCurrenciesFetcherTest { data = defaultResponse.copy(group = UserTokensResponse.GroupType.TOKEN), ) - every { userWalletsListRepository.getSyncStrict(params.userWalletId) } returns mockUserWallet + val userWalletsFlow = MutableStateFlow(listOf(mockUserWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow coEvery { userTokensResponseStore.getSyncOrNull(userWalletId = params.userWalletId) } returns defaultResponse coEvery { tangemTechApi.getUserTokens(userId = params.userWalletId.stringValue) } returns apiResponse coEvery { @@ -191,7 +199,7 @@ internal class DefaultMultiWalletCryptoCurrenciesFetcherTest { assertEither(actual, expected) coVerifyOrder { - userWalletsListRepository.getSyncStrict(id = params.userWalletId) + userWalletsListRepository.userWallets userTokensResponseStore.getSyncOrNull(userWalletId = params.userWalletId) tangemTechApi.getUserTokens(userId = params.userWalletId.stringValue) customTokensMerger.mergeIfPresented(userWalletId = params.userWalletId, response = apiResponse.data) @@ -219,7 +227,9 @@ internal class DefaultMultiWalletCryptoCurrenciesFetcherTest { data = defaultResponse.copy(group = UserTokensResponse.GroupType.TOKEN), ) - every { userWalletsListRepository.getSyncStrict(params.userWalletId) } returns mockUserWallet + val userWalletsFlow = MutableStateFlow(listOf(mockUserWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow coEvery { tangemTechApi.getUserTokens(userId = params.userWalletId.stringValue) } returns apiResponse coEvery { customTokensMerger.mergeIfPresented(userWalletId = params.userWalletId, response = apiResponse.data) @@ -240,7 +250,7 @@ internal class DefaultMultiWalletCryptoCurrenciesFetcherTest { assertEither(actual, expected) coVerifyOrder { - userWalletsListRepository.getSyncStrict(id = params.userWalletId) + userWalletsListRepository.userWallets tangemTechApi.getUserTokens(userId = params.userWalletId.stringValue) customTokensMerger.mergeIfPresented(userWalletId = params.userWalletId, response = apiResponse.data) userTokensSaver.store(userWalletId = params.userWalletId, response = apiResponse.data) @@ -283,7 +293,9 @@ internal class DefaultMultiWalletCryptoCurrenciesFetcherTest { ), ) - every { userWalletsListRepository.getSyncStrict(params.userWalletId) } returns mockUserWallet + val userWalletsFlow = MutableStateFlow(listOf(mockUserWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow coEvery { tangemTechApi.getUserTokens(userId = params.userWalletId.stringValue) } returns apiResponse coEvery { userTokensResponseStore.getSyncOrNull(userWalletId = userWalletId) } returns null coEvery { @@ -308,7 +320,7 @@ internal class DefaultMultiWalletCryptoCurrenciesFetcherTest { assertEither(actual, expected) coVerifyOrder { - userWalletsListRepository.getSyncStrict(id = params.userWalletId) + userWalletsListRepository.userWallets tangemTechApi.getUserTokens(userId = params.userWalletId.stringValue) userTokensResponseStore.getSyncOrNull(userWalletId = userWalletId) customTokensMerger.mergeIfPresented(userWalletId = params.userWalletId, response = userTokensResponse) @@ -337,7 +349,9 @@ internal class DefaultMultiWalletCryptoCurrenciesFetcherTest { cause = ApiResponseError.TimeoutException(), ) as ApiResponse - every { userWalletsListRepository.getSyncStrict(params.userWalletId) } returns mockUserWallet + val userWalletsFlow = MutableStateFlow(listOf(mockUserWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow coEvery { tangemTechApi.getUserTokens(userId = params.userWalletId.stringValue) } returns apiResponse coEvery { userTokensResponseStore.getSyncOrNull(userWalletId = userWalletId) } returns defaultResponse coEvery { @@ -359,7 +373,7 @@ internal class DefaultMultiWalletCryptoCurrenciesFetcherTest { assertEither(actual, expected) coVerifyOrder { - userWalletsListRepository.getSyncStrict(id = params.userWalletId) + userWalletsListRepository.userWallets tangemTechApi.getUserTokens(userId = params.userWalletId.stringValue) userTokensResponseStore.getSyncOrNull(userWalletId = userWalletId) customTokensMerger.mergeIfPresented(userWalletId = params.userWalletId, response = defaultResponse) @@ -407,7 +421,9 @@ internal class DefaultMultiWalletCryptoCurrenciesFetcherTest { ), ) - every { userWalletsListRepository.getSyncStrict(params.userWalletId) } returns mockUserWallet + val userWalletsFlow = MutableStateFlow(listOf(mockUserWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow coEvery { tangemTechApi.getUserTokens(userId = params.userWalletId.stringValue) } returns apiResponse coEvery { userTokensResponseStore.getSyncOrNull(userWalletId = userWalletId) } returns null coEvery { @@ -432,7 +448,7 @@ internal class DefaultMultiWalletCryptoCurrenciesFetcherTest { assertEither(actual, expected) coVerifyOrder { - userWalletsListRepository.getSyncStrict(id = params.userWalletId) + userWalletsListRepository.userWallets tangemTechApi.getUserTokens(userId = params.userWalletId.stringValue) userTokensResponseStore.getSyncOrNull(userWalletId = userWalletId) cardCryptoCurrencyFactory.createDefaultCoinsForMultiCurrencyWallet(mockUserWallet) @@ -463,7 +479,9 @@ internal class DefaultMultiWalletCryptoCurrenciesFetcherTest { ), ) as ApiResponse - every { userWalletsListRepository.getSyncStrict(params.userWalletId) } returns mockUserWallet + val userWalletsFlow = MutableStateFlow(listOf(mockUserWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow coEvery { tangemTechApi.getUserTokens(userId = params.userWalletId.stringValue) } returns apiResponse coEvery { userTokensResponseStore.getSyncOrNull(userWalletId = userWalletId) } returns defaultResponse coEvery { @@ -485,7 +503,7 @@ internal class DefaultMultiWalletCryptoCurrenciesFetcherTest { assertEither(actual, expected) coVerifyOrder { - userWalletsListRepository.getSyncStrict(id = params.userWalletId) + userWalletsListRepository.userWallets tangemTechApi.getUserTokens(userId = params.userWalletId.stringValue) userTokensResponseStore.getSyncOrNull(userWalletId = userWalletId) userTokensSaver.push(userWalletId = params.userWalletId, response = defaultResponse) diff --git a/data/txhistory/src/main/kotlin/com/tangem/data/txhistory/repository/DefaultTxHistoryRepository.kt b/data/txhistory/src/main/kotlin/com/tangem/data/txhistory/repository/DefaultTxHistoryRepository.kt index 8c026a475d..23761f8743 100644 --- a/data/txhistory/src/main/kotlin/com/tangem/data/txhistory/repository/DefaultTxHistoryRepository.kt +++ b/data/txhistory/src/main/kotlin/com/tangem/data/txhistory/repository/DefaultTxHistoryRepository.kt @@ -9,6 +9,7 @@ import com.tangem.data.common.cache.CacheRegistry import com.tangem.data.txhistory.repository.paging.TxHistoryPagingSource import com.tangem.datasource.local.txhistory.TxHistoryItemsStore import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.getSyncStrict import com.tangem.domain.models.currency.CryptoCurrency import com.tangem.domain.models.network.TxInfo import com.tangem.domain.models.wallet.UserWalletId diff --git a/data/visa/src/main/kotlin/com/tangem/data/visa/DefaultVisaRepository.kt b/data/visa/src/main/kotlin/com/tangem/data/visa/DefaultVisaRepository.kt index 978d392878..d095101533 100644 --- a/data/visa/src/main/kotlin/com/tangem/data/visa/DefaultVisaRepository.kt +++ b/data/visa/src/main/kotlin/com/tangem/data/visa/DefaultVisaRepository.kt @@ -18,6 +18,7 @@ import com.tangem.datasource.api.visa.VisaApi import com.tangem.datasource.api.visa.models.response.VisaTxHistoryResponse import com.tangem.domain.card.common.util.cardTypesResolver import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.getSyncStrict import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.models.wallet.UserWalletId import com.tangem.domain.models.wallet.requireColdWallet diff --git a/data/visa/src/main/kotlin/com/tangem/data/visa/utils/VisaApiRequestMaker.kt b/data/visa/src/main/kotlin/com/tangem/data/visa/utils/VisaApiRequestMaker.kt index ce95f24b90..eb91e4a601 100644 --- a/data/visa/src/main/kotlin/com/tangem/data/visa/utils/VisaApiRequestMaker.kt +++ b/data/visa/src/main/kotlin/com/tangem/data/visa/utils/VisaApiRequestMaker.kt @@ -9,6 +9,7 @@ import com.tangem.datasource.api.pay.models.request.RefreshTokenByCardWalletRequ import com.tangem.datasource.api.visa.VisaApi import com.tangem.domain.card.common.util.cardTypesResolver import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.getSyncStrict import com.tangem.domain.common.wallets.update import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.models.wallet.UserWalletId diff --git a/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/DefaultWalletConnectRepository.kt b/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/DefaultWalletConnectRepository.kt index 0aa06feafc..4d908dbb8b 100644 --- a/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/DefaultWalletConnectRepository.kt +++ b/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/DefaultWalletConnectRepository.kt @@ -1,6 +1,7 @@ package com.tangem.data.walletconnect import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.getSyncStrict import com.tangem.domain.models.wallet.UserWalletId import com.tangem.domain.models.wallet.isMultiCurrency import com.tangem.domain.walletconnect.repository.WalletConnectRepository diff --git a/data/wallet-manager/src/main/java/com/tangem/data/walletmanager/DefaultWalletManagersFacade.kt b/data/wallet-manager/src/main/java/com/tangem/data/walletmanager/DefaultWalletManagersFacade.kt index cd3223e10a..d10812bf6b 100644 --- a/data/wallet-manager/src/main/java/com/tangem/data/walletmanager/DefaultWalletManagersFacade.kt +++ b/data/wallet-manager/src/main/java/com/tangem/data/walletmanager/DefaultWalletManagersFacade.kt @@ -30,6 +30,7 @@ import com.tangem.data.walletmanager.utils.* import com.tangem.datasource.asset.loader.AssetLoader import com.tangem.datasource.local.walletmanager.WalletManagersStore import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.getSyncStrict import com.tangem.domain.demo.models.DemoConfig import com.tangem.domain.models.currency.CryptoCurrency import com.tangem.domain.models.network.Network diff --git a/data/wallets/src/main/java/com/tangem/data/wallets/DefaultWalletsRepository.kt b/data/wallets/src/main/java/com/tangem/data/wallets/DefaultWalletsRepository.kt index b6f5329aa5..83af408c47 100644 --- a/data/wallets/src/main/java/com/tangem/data/wallets/DefaultWalletsRepository.kt +++ b/data/wallets/src/main/java/com/tangem/data/wallets/DefaultWalletsRepository.kt @@ -26,6 +26,8 @@ import com.tangem.datasource.local.preferences.utils.getSyncOrNull import com.tangem.datasource.local.preferences.utils.store import com.tangem.domain.account.featuretoggle.AccountsFeatureToggles import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.getSyncOrNull +import com.tangem.domain.common.wallets.getSyncStrict import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.models.wallet.UserWalletId import com.tangem.domain.wallets.models.SeedPhraseNotificationsStatus diff --git a/data/wallets/src/main/java/com/tangem/data/wallets/derivations/DefaultDerivationsRepository.kt b/data/wallets/src/main/java/com/tangem/data/wallets/derivations/DefaultDerivationsRepository.kt index e355e23257..534b16cb36 100644 --- a/data/wallets/src/main/java/com/tangem/data/wallets/derivations/DefaultDerivationsRepository.kt +++ b/data/wallets/src/main/java/com/tangem/data/wallets/derivations/DefaultDerivationsRepository.kt @@ -4,6 +4,7 @@ import arrow.core.getOrElse import com.tangem.common.extensions.ByteArrayKey import com.tangem.crypto.hdWallet.DerivationPath import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.getSyncStrict import com.tangem.domain.models.account.DerivationIndex import com.tangem.domain.models.currency.CryptoCurrency import com.tangem.domain.models.network.Network diff --git a/data/wallets/src/main/java/com/tangem/data/wallets/hot/DefaultHotMapDerivationsRepository.kt b/data/wallets/src/main/java/com/tangem/data/wallets/hot/DefaultHotMapDerivationsRepository.kt index 0484eb18f6..8d0f7ec5d1 100644 --- a/data/wallets/src/main/java/com/tangem/data/wallets/hot/DefaultHotMapDerivationsRepository.kt +++ b/data/wallets/src/main/java/com/tangem/data/wallets/hot/DefaultHotMapDerivationsRepository.kt @@ -8,6 +8,7 @@ import com.tangem.crypto.hdWallet.DerivationPath import com.tangem.data.common.network.NetworkFactory import com.tangem.data.wallets.derivations.MissedDerivationsFinder import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.getSyncStrict import com.tangem.domain.models.account.DerivationIndex import com.tangem.domain.models.currency.CryptoCurrency import com.tangem.domain.models.network.Network diff --git a/data/wallets/src/test/java/com/tangem/data/wallets/derivations/DefaultDerivationsRepositoryTest.kt b/data/wallets/src/test/java/com/tangem/data/wallets/derivations/DefaultDerivationsRepositoryTest.kt index 08a0df11ed..3f759cd81e 100644 --- a/data/wallets/src/test/java/com/tangem/data/wallets/derivations/DefaultDerivationsRepositoryTest.kt +++ b/data/wallets/src/test/java/com/tangem/data/wallets/derivations/DefaultDerivationsRepositoryTest.kt @@ -12,6 +12,7 @@ import com.tangem.domain.models.wallet.UserWalletId import com.tangem.domain.wallets.derivations.ColdMapDerivationsRepository import com.tangem.utils.coroutines.TestingCoroutineDispatcherProvider import io.mockk.* +import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.test.runTest import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.Test @@ -51,15 +52,21 @@ internal class DefaultDerivationsRepositoryTest { @Test fun `error if userWalletId not found`() = runTest { val currencies = MockCryptoCurrencyFactory(defaultUserWallet).ethereum.let(::listOf) - coEvery { userWalletsListRepository.getSyncStrict(defaultUserWalletId) } throws IllegalStateException() + val userWalletsFlow = MutableStateFlow?>(null) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow runCatching { repository.derivePublicKeys(userWalletId = defaultUserWalletId, currencies = currencies) } .onSuccess { error("Should throws exception") } - .onFailure { Truth.assertThat(it).isInstanceOf(IllegalStateException::class.java) } + .onFailure { + Truth.assertThat(it).isInstanceOf(IllegalArgumentException::class.java) + Truth.assertThat(it).hasMessageThat() + .isEqualTo("Unable to find user wallet with provided ID: $defaultUserWalletId") + } - coVerify(exactly = 1) { userWalletsListRepository.getSyncStrict(defaultUserWalletId) } + coVerify(exactly = 1) { userWalletsListRepository.userWallets } coVerify(inverse = true) { coldDerivationsRepository.derivePublicKeysByNetworks(any(), any()) userWalletsListRepository.saveWithoutLock(any(), any()) @@ -71,7 +78,7 @@ internal class DefaultDerivationsRepositoryTest { repository.derivePublicKeys(userWalletId = defaultUserWalletId, currencies = emptyList()) coVerify(inverse = true) { - userWalletsListRepository.getSyncStrict(any()) + userWalletsListRepository.userWallets coldDerivationsRepository.derivePublicKeysByNetworks(any(), any()) userWalletsListRepository.saveWithoutLock(any(), any()) } @@ -80,8 +87,10 @@ internal class DefaultDerivationsRepositoryTest { @Test fun `error if coldDerivationsRepository throws exception`() = runTest { val currencies = MockCryptoCurrencyFactory(defaultUserWallet).ethereum.let(::listOf) + val userWalletsFlow = MutableStateFlow(listOf(defaultUserWallet)) + + every { userWalletsListRepository.userWallets } returns userWalletsFlow - coEvery { userWalletsListRepository.getSyncStrict(defaultUserWalletId) } returns defaultUserWallet coEvery { coldDerivationsRepository.derivePublicKeysByNetworks( userWallet = defaultUserWallet, @@ -96,7 +105,7 @@ internal class DefaultDerivationsRepositoryTest { .onFailure { Truth.assertThat(it).isInstanceOf(IllegalStateException::class.java) } coVerifyOrder { - userWalletsListRepository.getSyncStrict(defaultUserWalletId) + userWalletsListRepository.userWallets coldDerivationsRepository.derivePublicKeysByNetworks( userWallet = defaultUserWallet, networks = currencies.map(CryptoCurrency.Coin::network), @@ -109,9 +118,11 @@ internal class DefaultDerivationsRepositoryTest { @Test fun `success case`() = runTest { val currencies = MockCryptoCurrencyFactory(defaultUserWallet).ethereum.let(::listOf) + val userWalletsFlow = MutableStateFlow(listOf(defaultUserWallet)) val updatedWallet = defaultUserWallet.copy(cardsInWallet = setOf("AC01")) - coEvery { userWalletsListRepository.getSyncStrict(defaultUserWalletId) } returns defaultUserWallet + every { userWalletsListRepository.userWallets } returns userWalletsFlow + coEvery { coldDerivationsRepository.derivePublicKeysByNetworks( userWallet = defaultUserWallet, @@ -125,7 +136,7 @@ internal class DefaultDerivationsRepositoryTest { repository.derivePublicKeys(userWalletId = defaultUserWalletId, currencies = currencies) coVerifyOrder { - userWalletsListRepository.getSyncStrict(defaultUserWalletId) + userWalletsListRepository.userWallets coldDerivationsRepository.derivePublicKeysByNetworks( userWallet = defaultUserWallet, networks = currencies.map(CryptoCurrency.Coin::network), diff --git a/domain/account/src/main/java/com/tangem/domain/account/usecase/IsAccountsModeEnabledUseCase.kt b/domain/account/src/main/java/com/tangem/domain/account/usecase/IsAccountsModeEnabledUseCase.kt index f374e1867d..2a0bfba4d0 100644 --- a/domain/account/src/main/java/com/tangem/domain/account/usecase/IsAccountsModeEnabledUseCase.kt +++ b/domain/account/src/main/java/com/tangem/domain/account/usecase/IsAccountsModeEnabledUseCase.kt @@ -5,6 +5,7 @@ import arrow.core.getOrElse import com.tangem.domain.account.featuretoggle.AccountsFeatureToggles import com.tangem.domain.account.repository.AccountsCRUDRepository import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.loadAndGet import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.models.wallet.isMultiCurrency import kotlinx.coroutines.ExperimentalCoroutinesApi diff --git a/domain/account/src/test/kotlin/com/tangem/domain/account/usecase/IsAccountsModeEnabledUseCaseTest.kt b/domain/account/src/test/kotlin/com/tangem/domain/account/usecase/IsAccountsModeEnabledUseCaseTest.kt index 9b9f38a4c6..750b29926b 100644 --- a/domain/account/src/test/kotlin/com/tangem/domain/account/usecase/IsAccountsModeEnabledUseCaseTest.kt +++ b/domain/account/src/test/kotlin/com/tangem/domain/account/usecase/IsAccountsModeEnabledUseCaseTest.kt @@ -10,7 +10,7 @@ import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.models.wallet.UserWalletId import com.tangem.domain.models.wallet.isMultiCurrency import io.mockk.* -import kotlinx.coroutines.flow.emptyFlow +import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.firstOrNull import kotlinx.coroutines.flow.flowOf @@ -25,7 +25,7 @@ import org.junit.jupiter.api.TestInstance class IsAccountsModeEnabledUseCaseTest { private val accountsCRUDRepository: AccountsCRUDRepository = mockk() - private val userWalletsListRepository: UserWalletsListRepository = mockk() + private val userWalletsListRepository: UserWalletsListRepository = mockk(relaxUnitFun = true) private val featureToggles: AccountsFeatureToggles = mockk() private val useCase = IsAccountsModeEnabledUseCase( @@ -55,27 +55,10 @@ class IsAccountsModeEnabledUseCaseTest { Truth.assertThat(actual).isFalse() verify(exactly = 1) { featureToggles.isFeatureEnabled } - verify(inverse = true) { userWalletsListRepository.loadAndGet() } - } - - @Test - fun `returns false when loadAndGet emits empty flow`() = runTest { - // Arrange - every { featureToggles.isFeatureEnabled } returns true - every { userWalletsListRepository.loadAndGet() } returns emptyFlow() - - // Act - val actual = useCase.invoke().firstOrNull() - - // Assert - Truth.assertThat(actual).isFalse() - - verifyOrder { - featureToggles.isFeatureEnabled - userWalletsListRepository.loadAndGet() + coVerify(inverse = true) { + userWalletsListRepository.load() + userWalletsListRepository.userWallets } - - verify(inverse = true) { accountsCRUDRepository.getTotalActiveAccountsCount(any()) } } @Test @@ -84,7 +67,7 @@ class IsAccountsModeEnabledUseCaseTest { val wallet = createUserWallet(isMultiCurrency = false) every { featureToggles.isFeatureEnabled } returns true - every { userWalletsListRepository.loadAndGet() } returns flowOf(listOf(wallet)) + every { userWalletsListRepository.userWallets } returns MutableStateFlow(listOf(wallet)) // Act val actual = useCase.invoke().first() @@ -92,9 +75,10 @@ class IsAccountsModeEnabledUseCaseTest { // Assert Truth.assertThat(actual).isFalse() - verifyOrder { + coVerifyOrder { featureToggles.isFeatureEnabled - userWalletsListRepository.loadAndGet() + userWalletsListRepository.load() + userWalletsListRepository.userWallets } verify(inverse = true) { accountsCRUDRepository.getTotalActiveAccountsCount(any()) } @@ -106,7 +90,7 @@ class IsAccountsModeEnabledUseCaseTest { val wallet = createUserWallet(isMultiCurrency = true) every { featureToggles.isFeatureEnabled } returns true - every { userWalletsListRepository.loadAndGet() } returns flowOf(listOf(wallet)) + every { userWalletsListRepository.userWallets } returns MutableStateFlow(listOf(wallet)) every { accountsCRUDRepository.getTotalActiveAccountsCount(wallet.walletId) } returns flowOf(2.some()) // Act @@ -115,9 +99,10 @@ class IsAccountsModeEnabledUseCaseTest { // Assert Truth.assertThat(actual).isTrue() - verifyOrder { + coVerifyOrder { featureToggles.isFeatureEnabled - userWalletsListRepository.loadAndGet() + userWalletsListRepository.load() + userWalletsListRepository.userWallets accountsCRUDRepository.getTotalActiveAccountsCount(wallet.walletId) } } @@ -128,7 +113,7 @@ class IsAccountsModeEnabledUseCaseTest { val wallet = createUserWallet(isMultiCurrency = true) every { featureToggles.isFeatureEnabled } returns true - every { userWalletsListRepository.loadAndGet() } returns flowOf(listOf(wallet)) + every { userWalletsListRepository.userWallets } returns MutableStateFlow(listOf(wallet)) every { accountsCRUDRepository.getTotalActiveAccountsCount(wallet.walletId) } returns flowOf(none()) // Act @@ -137,9 +122,10 @@ class IsAccountsModeEnabledUseCaseTest { // Assert Truth.assertThat(actual).isFalse() - verifyOrder { + coVerifyOrder { featureToggles.isFeatureEnabled - userWalletsListRepository.loadAndGet() + userWalletsListRepository.load() + userWalletsListRepository.userWallets accountsCRUDRepository.getTotalActiveAccountsCount(wallet.walletId) } } @@ -151,7 +137,7 @@ class IsAccountsModeEnabledUseCaseTest { val wallet2 = createUserWallet(isMultiCurrency = true) every { featureToggles.isFeatureEnabled } returns true - every { userWalletsListRepository.loadAndGet() } returns flowOf(listOf(wallet1, wallet2)) + every { userWalletsListRepository.userWallets } returns MutableStateFlow(listOf(wallet1, wallet2)) every { accountsCRUDRepository.getTotalActiveAccountsCount(wallet2.walletId) } returns flowOf(2.some()) // Act @@ -160,9 +146,10 @@ class IsAccountsModeEnabledUseCaseTest { // Assert Truth.assertThat(actual).isTrue() - verifyOrder { + coVerifyOrder { featureToggles.isFeatureEnabled - userWalletsListRepository.loadAndGet() + userWalletsListRepository.load() + userWalletsListRepository.userWallets accountsCRUDRepository.getTotalActiveAccountsCount(wallet2.walletId) } diff --git a/domain/account/status/src/main/java/com/tangem/domain/account/status/producer/DefaultMultiAccountStatusListProducer.kt b/domain/account/status/src/main/java/com/tangem/domain/account/status/producer/DefaultMultiAccountStatusListProducer.kt index e5c1ecf871..edecc9f2c4 100644 --- a/domain/account/status/src/main/java/com/tangem/domain/account/status/producer/DefaultMultiAccountStatusListProducer.kt +++ b/domain/account/status/src/main/java/com/tangem/domain/account/status/producer/DefaultMultiAccountStatusListProducer.kt @@ -5,6 +5,7 @@ import arrow.core.some import com.tangem.domain.account.models.AccountStatusList import com.tangem.domain.account.status.supplier.SingleAccountStatusListSupplier import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.loadAndGet import com.tangem.domain.core.flow.FlowProducerTools import com.tangem.utils.coroutines.CoroutineDispatcherProvider import dagger.assisted.Assisted 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 db4baa88fa..be5c3f927d 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 @@ -9,6 +9,7 @@ import com.tangem.domain.account.models.AccountList import com.tangem.domain.account.models.AccountStatusList import com.tangem.domain.account.supplier.SingleAccountListSupplier import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.getSyncStrict import com.tangem.domain.core.flow.FlowProducerTools import com.tangem.domain.core.utils.lceContent import com.tangem.domain.core.utils.lceLoading diff --git a/domain/account/status/src/main/java/com/tangem/domain/account/status/usecase/GetCryptoCurrencyActionsUseCaseV2.kt b/domain/account/status/src/main/java/com/tangem/domain/account/status/usecase/GetCryptoCurrencyActionsUseCaseV2.kt index 9ec1d14e63..c0148890fb 100644 --- a/domain/account/status/src/main/java/com/tangem/domain/account/status/usecase/GetCryptoCurrencyActionsUseCaseV2.kt +++ b/domain/account/status/src/main/java/com/tangem/domain/account/status/usecase/GetCryptoCurrencyActionsUseCaseV2.kt @@ -4,6 +4,7 @@ import com.tangem.domain.account.status.producer.SingleAccountStatusListProducer import com.tangem.domain.account.status.supplier.SingleAccountStatusListSupplier import com.tangem.domain.account.status.utils.AccountCryptoCurrencyStatusFinder import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.getSyncStrict import com.tangem.domain.models.account.AccountId import com.tangem.domain.models.currency.CryptoCurrency import com.tangem.domain.tokens.GetCryptoCurrencyActionsUseCase diff --git a/domain/account/status/src/test/kotlin/com/tangem/domain/account/status/producer/DefaultMultiAccountStatusListProducerTest.kt b/domain/account/status/src/test/kotlin/com/tangem/domain/account/status/producer/DefaultMultiAccountStatusListProducerTest.kt index 48ecd270a8..67ed61d8e6 100644 --- a/domain/account/status/src/test/kotlin/com/tangem/domain/account/status/producer/DefaultMultiAccountStatusListProducerTest.kt +++ b/domain/account/status/src/test/kotlin/com/tangem/domain/account/status/producer/DefaultMultiAccountStatusListProducerTest.kt @@ -9,7 +9,10 @@ import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.models.wallet.UserWalletId import com.tangem.test.core.getEmittedValues import com.tangem.utils.coroutines.TestingCoroutineDispatcherProvider -import io.mockk.* +import io.mockk.clearMocks +import io.mockk.coVerifySequence +import io.mockk.every +import io.mockk.mockk import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.runTest @@ -21,7 +24,7 @@ import org.junit.jupiter.api.TestInstance @TestInstance(TestInstance.Lifecycle.PER_CLASS) class DefaultMultiAccountStatusListProducerTest { - private val userWalletsListRepository: UserWalletsListRepository = mockk() + private val userWalletsListRepository: UserWalletsListRepository = mockk(relaxUnitFun = true) private val singleAccountStatusListSupplier: SingleAccountStatusListSupplier = mockk() private val dispatchers = TestingCoroutineDispatcherProvider() private val flowProducerTools: FlowProducerTools = mockk() @@ -55,7 +58,7 @@ class DefaultMultiAccountStatusListProducerTest { val wallets = listOf(userWallet1, userWallet2) val walletsFlow = MutableStateFlow(wallets) - every { userWalletsListRepository.loadAndGet() } returns walletsFlow + every { userWalletsListRepository.userWallets } returns walletsFlow val accountStatusList1 = mockk() val accountStatusList2 = mockk() @@ -78,8 +81,9 @@ class DefaultMultiAccountStatusListProducerTest { val expected = listOf(accountStatusList1, accountStatusList2) Truth.assertThat(actual).containsExactly(expected) - coVerify(ordering = Ordering.SEQUENCE) { - userWalletsListRepository.loadAndGet() + coVerifySequence { + userWalletsListRepository.load() + userWalletsListRepository.userWallets singleAccountStatusListSupplier( params = SingleAccountStatusListProducer.Params(userWalletId1), ) @@ -93,7 +97,7 @@ class DefaultMultiAccountStatusListProducerTest { fun `produce returns empty flow if userWallets is empty list`() = runTest { // Arrange val walletsFlow = MutableStateFlow>(emptyList()) - every { userWalletsListRepository.loadAndGet() } returns walletsFlow + every { userWalletsListRepository.userWallets } returns walletsFlow // Act val actual = producer.produce().let(::getEmittedValues) @@ -101,16 +105,17 @@ class DefaultMultiAccountStatusListProducerTest { // Assert Truth.assertThat(actual).isEmpty() - coVerify(ordering = Ordering.SEQUENCE) { - userWalletsListRepository.loadAndGet() + coVerifySequence { + userWalletsListRepository.load() + userWalletsListRepository.userWallets } } @Test fun `produce returns empty flow if userWallets is null`() = runTest { // Arrange - val walletsFlow = flowOf>(emptyList()) - every { userWalletsListRepository.loadAndGet() } returns walletsFlow + val walletsFlow = MutableStateFlow>(emptyList()) + every { userWalletsListRepository.userWallets } returns walletsFlow // Act val actual = producer.produce().let(::getEmittedValues) @@ -118,8 +123,9 @@ class DefaultMultiAccountStatusListProducerTest { // Assert Truth.assertThat(actual).isEmpty() - coVerify(ordering = Ordering.SEQUENCE) { - userWalletsListRepository.loadAndGet() + coVerifySequence { + userWalletsListRepository.load() + userWalletsListRepository.userWallets } } @@ -130,7 +136,7 @@ class DefaultMultiAccountStatusListProducerTest { val userWallet3 = mockk { every { walletId } returns userWalletId3 } val walletsFlow = MutableStateFlow(listOf(userWallet1, userWallet2)) - every { userWalletsListRepository.loadAndGet() } returns walletsFlow + every { userWalletsListRepository.userWallets } returns walletsFlow val accountStatusList1 = mockk() val accountStatusList2 = mockk() @@ -169,8 +175,9 @@ class DefaultMultiAccountStatusListProducerTest { val expected2 = listOf(accountStatusList1, accountStatusList2, accountStatusList3) Truth.assertThat(actual2).containsExactly(expected2) - coVerify(ordering = Ordering.SEQUENCE) { - userWalletsListRepository.loadAndGet() + coVerifySequence { + userWalletsListRepository.load() + userWalletsListRepository.userWallets singleAccountStatusListSupplier( params = SingleAccountStatusListProducer.Params(userWalletId1), ) @@ -186,7 +193,8 @@ class DefaultMultiAccountStatusListProducerTest { singleAccountStatusListSupplier( params = SingleAccountStatusListProducer.Params(userWalletId3), ) - userWalletsListRepository.loadAndGet() + userWalletsListRepository.load() + userWalletsListRepository.userWallets singleAccountStatusListSupplier( params = SingleAccountStatusListProducer.Params(userWalletId1), ) diff --git a/domain/common/src/main/java/com/tangem/domain/common/wallets/UserWalletsListRepository.kt b/domain/common/src/main/java/com/tangem/domain/common/wallets/UserWalletsListRepository.kt index fa1a12c054..c9f9aecb00 100644 --- a/domain/common/src/main/java/com/tangem/domain/common/wallets/UserWalletsListRepository.kt +++ b/domain/common/src/main/java/com/tangem/domain/common/wallets/UserWalletsListRepository.kt @@ -5,7 +5,6 @@ import com.tangem.domain.common.wallets.error.* import com.tangem.domain.models.scan.ScanResponse import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.models.wallet.UserWalletId -import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.StateFlow /** @@ -31,21 +30,12 @@ interface UserWalletsListRepository { */ val selectedUserWallet: StateFlow - /** Get user wallet by [id] */ - fun getSyncOrNull(id: UserWalletId): UserWallet? - - /** Get user wallet by [id] */ - fun getSyncStrict(id: UserWalletId): UserWallet - /** * Loads user wallets list and selected wallet. * If the list is already loaded, it does nothing. */ suspend fun load() - /** Loads user wallets list and selected wallet and returns a flow of the list */ - fun loadAndGet(): Flow> - /** * Gets and if necessary loads user wallets list and selected wallet. */ diff --git a/domain/common/src/main/java/com/tangem/domain/common/wallets/UserWalletsListRepositoryExt.kt b/domain/common/src/main/java/com/tangem/domain/common/wallets/UserWalletsListRepositoryExt.kt index d1474f7fd8..c5ee21b86a 100644 --- a/domain/common/src/main/java/com/tangem/domain/common/wallets/UserWalletsListRepositoryExt.kt +++ b/domain/common/src/main/java/com/tangem/domain/common/wallets/UserWalletsListRepositoryExt.kt @@ -5,6 +5,8 @@ import arrow.core.raise.either import com.tangem.domain.common.wallets.error.SaveWalletError import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.models.wallet.UserWalletId +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flow /** * Update user wallet by [userWalletId] and return updated wallet. @@ -29,4 +31,22 @@ suspend fun UserWalletsListRepository.update( .bind() updatedUserWallet +} + +/** Get user wallet by [id] */ +fun UserWalletsListRepository.getSyncOrNull(id: UserWalletId): UserWallet? { + return userWallets.value?.find { it.walletId == id } +} + +/** Get user wallet by [id] or throw an exception if it is not found */ +fun UserWalletsListRepository.getSyncStrict(id: UserWalletId): UserWallet { + return requireNotNull(getSyncOrNull(id)) { "Unable to find user wallet with provided ID: $id" } +} + +/** Loads user wallets list and selected wallet and returns a flow of the list */ +fun UserWalletsListRepository.loadAndGet(): Flow> = flow { + load() + userWallets.collect { + emit(requireNotNull(it)) + } } \ No newline at end of file diff --git a/features/referral/data/src/main/java/com/tangem/feature/referral/data/ReferralRepositoryImpl.kt b/features/referral/data/src/main/java/com/tangem/feature/referral/data/ReferralRepositoryImpl.kt index 125322a147..5e766048e2 100644 --- a/features/referral/data/src/main/java/com/tangem/feature/referral/data/ReferralRepositoryImpl.kt +++ b/features/referral/data/src/main/java/com/tangem/feature/referral/data/ReferralRepositoryImpl.kt @@ -9,6 +9,7 @@ import com.tangem.datasource.api.common.response.getOrThrow import com.tangem.datasource.api.tangemTech.TangemTechApi import com.tangem.datasource.api.tangemTech.models.StartReferralBody import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.getSyncStrict import com.tangem.domain.models.account.DerivationIndex import com.tangem.domain.models.currency.CryptoCurrency import com.tangem.domain.models.wallet.UserWalletId