From d2d15bdbb961e4eeb5ccbd55b03ca0aaab775ede Mon Sep 17 00:00:00 2001 From: Tangem Date: Wed, 8 Jul 2026 14:24:46 +0100 Subject: [PATCH] Updated on 2026-08-14 --- .../addressbook/usecase/GetContactsUseCase.kt | 2 +- .../usecase/GetContactsUseCaseTest.kt | 35 +++++++++++++++++++ features/wallet/impl/build.gradle.kts | 1 + .../wallet/child/wallet/model/WalletModel.kt | 14 +++++--- 4 files changed, 46 insertions(+), 6 deletions(-) diff --git a/domain/address-book/src/main/kotlin/com/tangem/domain/addressbook/usecase/GetContactsUseCase.kt b/domain/address-book/src/main/kotlin/com/tangem/domain/addressbook/usecase/GetContactsUseCase.kt index 417a18b3d6..d7cd9b2bb3 100644 --- a/domain/address-book/src/main/kotlin/com/tangem/domain/addressbook/usecase/GetContactsUseCase.kt +++ b/domain/address-book/src/main/kotlin/com/tangem/domain/addressbook/usecase/GetContactsUseCase.kt @@ -30,7 +30,7 @@ class GetContactsUseCase( private fun Contact.matches(query: String): Boolean { val isNameContaining = name.value.contains(other = query, ignoreCase = true) val isAddressContaining = addresses.any { addressEntry -> - addressEntry.address.contains(other = query, ignoreCase = true) + addressEntry.address.contains(other = query, ignoreCase = false) } return isNameContaining || isAddressContaining } diff --git a/domain/address-book/src/test/kotlin/com/tangem/domain/addressbook/usecase/GetContactsUseCaseTest.kt b/domain/address-book/src/test/kotlin/com/tangem/domain/addressbook/usecase/GetContactsUseCaseTest.kt index 35ab2b38ab..fbe1f2d4a2 100644 --- a/domain/address-book/src/test/kotlin/com/tangem/domain/addressbook/usecase/GetContactsUseCaseTest.kt +++ b/domain/address-book/src/test/kotlin/com/tangem/domain/addressbook/usecase/GetContactsUseCaseTest.kt @@ -53,6 +53,41 @@ class GetContactsUseCaseTest { assertThat(result).containsExactly(bob) } + @Test + fun `GIVEN address query matching case WHEN invoke THEN returns matching contact`() = runTest { + // Arrange + val carol = contact(name = "Carol", address = "0xAbCdEf") + every { repository.getAllContacts() } returns flowOf(listOf(alice, carol)) + + // Act + val result = useCase(query = "0xAbCdEf").first() + + // Assert + assertThat(result).containsExactly(carol) + } + + @Test + fun `GIVEN address query with different case WHEN invoke THEN returns empty`() = runTest { + // Arrange + val carol = contact(name = "Carol", address = "0xAbCdEf") + every { repository.getAllContacts() } returns flowOf(listOf(alice, carol)) + + // Act + val result = useCase(query = "0xabcdef").first() + + // Assert + assertThat(result).isEmpty() + } + + @Test + fun `GIVEN name query with different case WHEN invoke THEN returns matching contact`() = runTest { + // Act + val result = useCase(query = "ALICE").first() + + // Assert + assertThat(result).containsExactly(alice) + } + @Test fun `GIVEN blank query WHEN invoke THEN returns all contacts unfiltered`() = runTest { // Act diff --git a/features/wallet/impl/build.gradle.kts b/features/wallet/impl/build.gradle.kts index fc9e638958..63e99aec25 100644 --- a/features/wallet/impl/build.gradle.kts +++ b/features/wallet/impl/build.gradle.kts @@ -128,6 +128,7 @@ dependencies { implementation(projects.domain.yieldSupply.models) /** Feature Apis */ + api(projects.features.addressBook.api) api(projects.features.biometry.api) api(projects.features.commonFeatures.api) api(projects.features.feed.api) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt index 4255fec73e..5d62057745 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt @@ -61,6 +61,7 @@ import com.tangem.feature.wallet.presentation.wallet.state.transformers.* import com.tangem.feature.wallet.presentation.wallet.state.utils.WalletEventSender import com.tangem.feature.wallet.presentation.wallet.ui.components.visa.KycRejectedCallbacks import com.tangem.feature.wallet.presentation.wallet.utils.ScreenLifecycleProvider +import com.tangem.features.addressbook.AddressBookFeatureToggles import com.tangem.features.biometry.AskBiometryComponent import com.tangem.features.hotwallet.HotWalletFeatureToggles import com.tangem.features.pushnotifications.api.PushNotificationsModelCallbacks @@ -127,6 +128,7 @@ internal class WalletModel @Inject constructor( private val hotWalletFeatureToggles: HotWalletFeatureToggles, private val walletFeatureToggles: WalletFeatureToggles, private val pushNotificationSettingsFeatureToggles: PushNotificationSettingsFeatureToggles, + private val addressBookFeatureToggles: AddressBookFeatureToggles, private val startAssetsDiscoveryUseCase: StartAssetsDiscoveryUseCase, private val syncAddressBooksUseCase: SyncAddressBooksUseCase, val screenLifecycleProvider: ScreenLifecycleProvider, @@ -164,7 +166,7 @@ internal class WalletModel @Inject constructor( subscribeToMainScreenQrScanning() enableNotificationsIfNeeded() applyPendingAssetsDiscovery() - syncAddressBooks() + syncAddressBooksIfNeeded() clickIntents.initialize(innerWalletRouter, modelScope) @@ -882,10 +884,12 @@ internal class WalletModel @Inject constructor( } } - private fun syncAddressBooks() { - modelScope.launch { - syncAddressBooksUseCase() - .onLeft { TangemLogger.e("Failed to sync address books: $it") } + private fun syncAddressBooksIfNeeded() { + if (addressBookFeatureToggles.isAddressBookEnabled) { + modelScope.launch { + syncAddressBooksUseCase() + .onLeft { TangemLogger.e("Failed to sync address books: $it") } + } } }