From 14d1adb29e767f0b8ca7064c116536cf87e3dbaf Mon Sep 17 00:00:00 2001 From: Tangem Date: Mon, 1 Jun 2026 18:45:47 +0300 Subject: [PATCH] Updated on 2026-08-14 --- .../deeplink/DefaultPromoDeeplinkHandler.kt | 7 ++- .../DefaultPromoDeeplinkHandlerTest.kt | 53 ++++++++++--------- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/deeplink/DefaultPromoDeeplinkHandler.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/deeplink/DefaultPromoDeeplinkHandler.kt index 0321bc421a..89fe896c13 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/deeplink/DefaultPromoDeeplinkHandler.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/deeplink/DefaultPromoDeeplinkHandler.kt @@ -1,6 +1,7 @@ package com.tangem.feature.wallet.deeplink import com.tangem.blockchain.common.Blockchain +import com.tangem.blockchainsdk.utils.toNetworkId import com.tangem.common.routing.deeplink.DeeplinkConst import com.tangem.common.routing.deeplink.DeeplinkConst.PROMO_CODE_KEY import com.tangem.core.analytics.api.AnalyticsEventHandler @@ -91,7 +92,7 @@ internal class DefaultPromoDeeplinkHandler @AssistedInject constructor( multiNetworkStatusSupplier .invoke(MultiNetworkStatusProducer.Params(userWallet.walletId)) .first { statuses -> - statuses.any { status -> status.network.rawId == Blockchain.Bitcoin.id } + statuses.any { status -> status.network.rawId == Blockchain.Bitcoin.toNetworkId() } } }, ) @@ -104,7 +105,9 @@ internal class DefaultPromoDeeplinkHandler @AssistedInject constructor( TangemLogger.withTag(LOG_TAG).d("All user cryptoCurrencies on main ${cryptoCurrencies?.size}") - val bitcoinCurrency = cryptoCurrencies?.firstOrNull { it.id.rawNetworkId == Blockchain.Bitcoin.id } + val bitcoinCurrency = cryptoCurrencies?.firstOrNull { + it.id.rawNetworkId == Blockchain.Bitcoin.toNetworkId() + } TangemLogger.withTag(LOG_TAG).d("BitcoinCurrency $bitcoinCurrency") val bitcoinStatus = networkStatuses?.firstOrNull { status -> diff --git a/features/wallet/impl/src/test/kotlin/com/tangem/feature/wallet/presentation/wallet/deeplink/DefaultPromoDeeplinkHandlerTest.kt b/features/wallet/impl/src/test/kotlin/com/tangem/feature/wallet/presentation/wallet/deeplink/DefaultPromoDeeplinkHandlerTest.kt index a2e0fbda2f..16a9f088b1 100644 --- a/features/wallet/impl/src/test/kotlin/com/tangem/feature/wallet/presentation/wallet/deeplink/DefaultPromoDeeplinkHandlerTest.kt +++ b/features/wallet/impl/src/test/kotlin/com/tangem/feature/wallet/presentation/wallet/deeplink/DefaultPromoDeeplinkHandlerTest.kt @@ -5,6 +5,7 @@ package com.tangem.feature.wallet.presentation.wallet.deeplink import arrow.core.Either import com.google.common.truth.Truth import com.tangem.blockchain.common.Blockchain +import com.tangem.blockchainsdk.utils.toNetworkId import com.tangem.common.routing.deeplink.DeeplinkConst import com.tangem.core.analytics.api.AnalyticsEventHandler import com.tangem.core.decompose.ui.UiMessage @@ -92,13 +93,13 @@ class DefaultPromoDeeplinkHandlerTest { every { getSelectedWalletSyncUseCase.invoke() } returns Either.Right(userWallet) val ethStatus = buildNetworkStatus(rawNetworkId = "ethereum", address = "0x123") - val btcStatus = buildNetworkStatus(rawNetworkId = Blockchain.Bitcoin.id, address = "bc1qxyz") + val btcStatus = buildNetworkStatus(rawNetworkId = Blockchain.Bitcoin.toNetworkId(), address = "bc1qxyz") coEvery { multiNetworkStatusSupplier.invoke(any()) } returns flow { emit(emptySet()) emit(setOf(ethStatus)) emit(setOf(btcStatus)) } - val btcCoin = buildCryptoCurrency(rawNetworkId = Blockchain.Bitcoin.id) + val btcCoin = buildCryptoCurrency(rawNetworkId = Blockchain.Bitcoin.toNetworkId()) coEvery { multiWalletCryptoCurrenciesSupplier.getSyncOrNull(any()) } returns setOf(btcCoin) coEvery { activateBitcoinPromocodeUseCase.invoke(any(), "bc1qxyz", promoCode) } returns Either.Right("ok") val dispatcherProvider = testDispatcherProvider(testScheduler) @@ -203,9 +204,9 @@ class DefaultPromoDeeplinkHandlerTest { val queryParams = mapOf(DeeplinkConst.PROMO_CODE_KEY to "PROMO123") val userWallet = mockUserWallet("ABCDEF") every { getSelectedWalletSyncUseCase.invoke() } returns Either.Right(userWallet) - val btcUnreachable = buildUnreachableNetworkStatus(rawNetworkId = Blockchain.Bitcoin.id) + val btcUnreachable = buildUnreachableNetworkStatus(rawNetworkId = Blockchain.Bitcoin.toNetworkId()) coEvery { multiNetworkStatusSupplier.invoke(any()) } returns flowOf(setOf(btcUnreachable)) - val btcCoin = buildCryptoCurrency(rawNetworkId = Blockchain.Bitcoin.id) + val btcCoin = buildCryptoCurrency(rawNetworkId = Blockchain.Bitcoin.toNetworkId()) coEvery { multiWalletCryptoCurrenciesSupplier.getSyncOrNull(any()) } returns setOf(btcCoin) val dispatcherProvider = testDispatcherProvider(testScheduler) @@ -245,9 +246,9 @@ class DefaultPromoDeeplinkHandlerTest { val queryParams = mapOf(DeeplinkConst.PROMO_CODE_KEY to promoCode) val userWallet = mockUserWallet("ABCDEF") every { getSelectedWalletSyncUseCase.invoke() } returns Either.Right(userWallet) - val btcStatus = buildNetworkStatus(rawNetworkId = Blockchain.Bitcoin.id, address = "bc1qxyz") + val btcStatus = buildNetworkStatus(rawNetworkId = Blockchain.Bitcoin.toNetworkId(), address = "bc1qxyz") coEvery { multiNetworkStatusSupplier.invoke(any()) } returns flowOf(setOf(btcStatus)) - val btcCoin = buildCryptoCurrency(rawNetworkId = Blockchain.Bitcoin.id) + val btcCoin = buildCryptoCurrency(rawNetworkId = Blockchain.Bitcoin.toNetworkId()) coEvery { multiWalletCryptoCurrenciesSupplier.getSyncOrNull(any()) } returns setOf(btcCoin) coEvery { activateBitcoinPromocodeUseCase.invoke(any(), "bc1qxyz", promoCode) } returns Either.Right("ok") val dispatcherProvider = testDispatcherProvider(testScheduler) @@ -363,9 +364,9 @@ class DefaultPromoDeeplinkHandlerTest { val queryParams = mapOf(DeeplinkConst.PROMO_CODE_KEY to promoCode) val userWallet = mockUserWallet("ABCDEF") every { getSelectedWalletSyncUseCase.invoke() } returns Either.Right(userWallet) - val btcStatus = buildNetworkStatus(rawNetworkId = Blockchain.Bitcoin.id, address = "bc1qxyz") + val btcStatus = buildNetworkStatus(rawNetworkId = Blockchain.Bitcoin.toNetworkId(), address = "bc1qxyz") coEvery { multiNetworkStatusSupplier.invoke(any()) } returns flowOf(setOf(btcStatus)) - val btcCurrency = buildCryptoCurrency(rawNetworkId = Blockchain.Bitcoin.id) + val btcCurrency = buildCryptoCurrency(rawNetworkId = Blockchain.Bitcoin.toNetworkId()) coEvery { multiWalletCryptoCurrenciesSupplier.getSyncOrNull(any()) } returns setOf(btcCurrency) coEvery { activateBitcoinPromocodeUseCase.invoke(any(), "bc1qxyz", promoCode) } returns Either.Left(error) val dispatcherProvider = testDispatcherProvider(testScheduler) @@ -397,7 +398,7 @@ class DefaultPromoDeeplinkHandlerTest { val queryParams = mapOf(DeeplinkConst.PROMO_CODE_KEY to "PROMO123") val userWallet = mockUserWallet("ABCDEF") every { getSelectedWalletSyncUseCase.invoke() } returns Either.Right(userWallet) - val btcStatus = buildNetworkStatus(rawNetworkId = Blockchain.Bitcoin.id, address = "bc1qxyz") + val btcStatus = buildNetworkStatus(rawNetworkId = Blockchain.Bitcoin.toNetworkId(), address = "bc1qxyz") coEvery { multiNetworkStatusSupplier.invoke(any()) } returns flowOf(setOf(btcStatus)) val ethOnly = buildCryptoCurrency(rawNetworkId = "ethereum") coEvery { multiWalletCryptoCurrenciesSupplier.getSyncOrNull(any()) } returns setOf(ethOnly) @@ -433,7 +434,7 @@ class DefaultPromoDeeplinkHandlerTest { every { getSelectedWalletSyncUseCase.invoke() } returns Either.Right(userWallet) val ethStatus = buildNetworkStatus(rawNetworkId = "ethereum", address = "0x123") - val btcStatus = buildNetworkStatus(rawNetworkId = Blockchain.Bitcoin.id, address = "bc1qxyz") + val btcStatus = buildNetworkStatus(rawNetworkId = Blockchain.Bitcoin.toNetworkId(), address = "bc1qxyz") coEvery { multiNetworkStatusSupplier.invoke(any()) } returns flow { emit(emptySet()) emit(setOf(ethStatus)) @@ -487,19 +488,19 @@ class DefaultPromoDeeplinkHandlerTest { val dpCustom = Network.DerivationPath.Custom("m/84'/0'/0'") val btcStatusCard = buildNetworkStatus( - rawNetworkId = Blockchain.Bitcoin.id, + rawNetworkId = Blockchain.Bitcoin.toNetworkId(), address = "bc1qcard", derivationPath = dpCard, ) val btcStatusCustom = buildNetworkStatus( - rawNetworkId = Blockchain.Bitcoin.id, + rawNetworkId = Blockchain.Bitcoin.toNetworkId(), address = "bc1qcustom", derivationPath = dpCustom, ) coEvery { multiNetworkStatusSupplier.invoke(any()) } returns flowOf(setOf(btcStatusCard, btcStatusCustom)) - val btcCoinCustom = buildCryptoCurrency(rawNetworkId = Blockchain.Bitcoin.id, derivationPath = dpCustom) - val btcCoinCard = buildCryptoCurrency(rawNetworkId = Blockchain.Bitcoin.id, derivationPath = dpCard) + val btcCoinCustom = buildCryptoCurrency(rawNetworkId = Blockchain.Bitcoin.toNetworkId(), derivationPath = dpCustom) + val btcCoinCard = buildCryptoCurrency(rawNetworkId = Blockchain.Bitcoin.toNetworkId(), derivationPath = dpCard) coEvery { multiWalletCryptoCurrenciesSupplier.getSyncOrNull(any()) } returns setOf( btcCoinCustom, btcCoinCard, @@ -544,18 +545,18 @@ class DefaultPromoDeeplinkHandlerTest { val dpCustom = Network.DerivationPath.Custom("m/84'/0'/0'") val btcStatusCard = buildNetworkStatus( - rawNetworkId = Blockchain.Bitcoin.id, + rawNetworkId = Blockchain.Bitcoin.toNetworkId(), address = "bc1qcard", derivationPath = dpCard, ) val btcStatusCustom = buildNetworkStatus( - rawNetworkId = Blockchain.Bitcoin.id, + rawNetworkId = Blockchain.Bitcoin.toNetworkId(), address = "bc1qcustom", derivationPath = dpCustom, ) coEvery { multiNetworkStatusSupplier.invoke(any()) } returns flowOf(setOf(btcStatusCard, btcStatusCustom)) - val btcCoinCard = buildCryptoCurrency(rawNetworkId = Blockchain.Bitcoin.id, derivationPath = dpCard) + val btcCoinCard = buildCryptoCurrency(rawNetworkId = Blockchain.Bitcoin.toNetworkId(), derivationPath = dpCard) coEvery { multiWalletCryptoCurrenciesSupplier.getSyncOrNull(any()) } returns setOf(btcCoinCard) coEvery { activateBitcoinPromocodeUseCase.invoke(any(), "bc1qcard", promoCode) } returns Either.Right("ok") @@ -607,12 +608,12 @@ class DefaultPromoDeeplinkHandlerTest { val dpCustom = Network.DerivationPath.Custom("m/84'/0'/0'") val btcStatusCard = buildNetworkStatus( - rawNetworkId = Blockchain.Bitcoin.id, + rawNetworkId = Blockchain.Bitcoin.toNetworkId(), address = "bc1qcard", derivationPath = dpCard, ) val btcStatusCustom = buildNetworkStatus( - rawNetworkId = Blockchain.Bitcoin.id, + rawNetworkId = Blockchain.Bitcoin.toNetworkId(), address = "bc1qcustom", derivationPath = dpCustom, ) @@ -666,14 +667,14 @@ class DefaultPromoDeeplinkHandlerTest { val dpCustom = Network.DerivationPath.Custom("m/84'/0'/0'") val btcStatusCard = buildNetworkStatus( - rawNetworkId = Blockchain.Bitcoin.id, + rawNetworkId = Blockchain.Bitcoin.toNetworkId(), address = "bc1qcard", derivationPath = dpCard, ) coEvery { multiNetworkStatusSupplier.invoke(any()) } returns flowOf(setOf(btcStatusCard)) - val btcCoinCustom = buildCryptoCurrency(rawNetworkId = Blockchain.Bitcoin.id, derivationPath = dpCustom) - val btcCoinCard = buildCryptoCurrency(rawNetworkId = Blockchain.Bitcoin.id, derivationPath = dpCard) + val btcCoinCustom = buildCryptoCurrency(rawNetworkId = Blockchain.Bitcoin.toNetworkId(), derivationPath = dpCustom) + val btcCoinCard = buildCryptoCurrency(rawNetworkId = Blockchain.Bitcoin.toNetworkId(), derivationPath = dpCard) coEvery { multiWalletCryptoCurrenciesSupplier.getSyncOrNull(any()) } returns setOf( btcCoinCustom, btcCoinCard, @@ -725,13 +726,13 @@ class DefaultPromoDeeplinkHandlerTest { val dpCustom = Network.DerivationPath.Custom("m/84'/0'/0'") val btcStatusCustom = buildNetworkStatus( - rawNetworkId = Blockchain.Bitcoin.id, + rawNetworkId = Blockchain.Bitcoin.toNetworkId(), address = "bc1qcustom", derivationPath = dpCustom, ) coEvery { multiNetworkStatusSupplier.invoke(any()) } returns flowOf(setOf(btcStatusCustom)) - val btcCoinCard = buildCryptoCurrency(rawNetworkId = Blockchain.Bitcoin.id, derivationPath = dpCard) + val btcCoinCard = buildCryptoCurrency(rawNetworkId = Blockchain.Bitcoin.toNetworkId(), derivationPath = dpCard) coEvery { multiWalletCryptoCurrenciesSupplier.getSyncOrNull(any()) } returns setOf(btcCoinCard) val dispatcherProvider = testDispatcherProvider(testScheduler) @@ -780,13 +781,13 @@ class DefaultPromoDeeplinkHandlerTest { val dpCustom = Network.DerivationPath.Custom("m/84'/0'/0'") val btcStatusCard = buildNetworkStatus( - rawNetworkId = Blockchain.Bitcoin.id, + rawNetworkId = Blockchain.Bitcoin.toNetworkId(), address = "bc1qcard", derivationPath = dpCard, ) coEvery { multiNetworkStatusSupplier.invoke(any()) } returns flowOf(setOf(btcStatusCard)) - val btcCoinCustom = buildCryptoCurrency(rawNetworkId = Blockchain.Bitcoin.id, derivationPath = dpCustom) + val btcCoinCustom = buildCryptoCurrency(rawNetworkId = Blockchain.Bitcoin.toNetworkId(), derivationPath = dpCustom) coEvery { multiWalletCryptoCurrenciesSupplier.getSyncOrNull(any()) } returns setOf(btcCoinCustom) val dispatcherProvider = testDispatcherProvider(testScheduler)