Updated on 2026-08-14

This commit is contained in:
Tangem 2025-07-24 17:48:38 +03:00
parent 85803abc7f
commit 095c755362
194 changed files with 830 additions and 473 deletions

View file

@ -84,6 +84,7 @@ dependencies {
implementation(projects.domain.core)
implementation(projects.domain.card)
implementation(projects.domain.demo)
implementation(projects.domain.demo.models)
implementation(projects.domain.wallets)
implementation(projects.domain.wallets.models)
implementation(projects.domain.settings)
@ -121,6 +122,8 @@ dependencies {
implementation(projects.domain.notifications.toggles)
implementation(projects.domain.swap.models)
implementation(projects.domain.swap)
implementation(projects.domain.walletManager)
implementation(projects.domain.walletManager.models)
implementation(projects.common)
implementation(projects.common.routing)
@ -167,6 +170,7 @@ dependencies {
implementation(projects.data.blockaid)
implementation(projects.data.notifications)
implementation(projects.data.swap)
implementation(projects.data.walletManager)
/** Features */
implementation(projects.features.referral.impl)

@ -1 +1 @@
Subproject commit 02dca1e527f2695b69a9a1d01fc88880a0661486
Subproject commit 91f870957a6c36c5bf6dcd6e769648f6c7b7abd7

View file

@ -1,7 +1,7 @@
package com.tangem.tap.common.analytics.converters
import com.tangem.blockchain.common.Blockchain
import com.tangem.domain.common.CardTypesResolver
import com.tangem.domain.card.CardTypesResolver
import com.tangem.tap.common.analytics.events.AnalyticsParam
import com.tangem.utils.converter.Converter
import com.tangem.core.analytics.models.AnalyticsParam as CoreAnalyticsParam

View file

@ -2,7 +2,7 @@ package com.tangem.tap.common.analytics.paramsInterceptor
import com.tangem.core.analytics.api.ParamsInterceptor
import com.tangem.core.analytics.models.AnalyticsEvent
import com.tangem.domain.common.util.cardTypesResolver
import com.tangem.domain.card.common.util.cardTypesResolver
import com.tangem.domain.models.scan.ProductType
import com.tangem.domain.models.scan.ScanResponse
import com.tangem.domain.wallets.builder.UserWalletIdBuilder

View file

@ -3,11 +3,12 @@ package com.tangem.tap.di.domain
import com.tangem.domain.card.*
import com.tangem.domain.card.repository.CardRepository
import com.tangem.domain.card.repository.DerivationsRepository
import com.tangem.domain.demo.DemoConfig
import com.tangem.domain.demo.models.DemoConfig
import com.tangem.domain.demo.IsDemoCardUseCase
import com.tangem.domain.walletmanager.WalletManagersFacade
import com.tangem.domain.wallets.legacy.UserWalletsListManager
import com.tangem.domain.wallets.usecase.IsNeedToBackupUseCase
import com.tangem.domain.wallets.usecase.NetworkHasDerivationUseCase
import com.tangem.sdk.api.TangemSdkManager
import com.tangem.tap.domain.card.DefaultDeleteSavedAccessCodesUseCase
import com.tangem.tap.domain.card.DefaultResetCardUseCase

View file

@ -1,7 +1,7 @@
package com.tangem.tap.di.domain
import com.tangem.domain.card.repository.CardSdkConfigRepository
import com.tangem.domain.demo.DemoConfig
import com.tangem.domain.demo.models.DemoConfig
import com.tangem.domain.networks.single.SingleNetworkStatusFetcher
import com.tangem.domain.networks.single.SingleNetworkStatusSupplier
import com.tangem.domain.tokens.MultiWalletCryptoCurrenciesSupplier

View file

@ -1,37 +0,0 @@
package com.tangem.tap.di.domain
import com.tangem.blockchainsdk.BlockchainSDKFactory
import com.tangem.datasource.asset.loader.AssetLoader
import com.tangem.datasource.local.userwallet.UserWalletsStore
import com.tangem.datasource.local.walletmanager.WalletManagersStore
import com.tangem.domain.walletmanager.DefaultWalletManagersFacade
import com.tangem.domain.walletmanager.WalletManagersFacade
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
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 WalletManagersFacadeModule {
@Provides
@Singleton
fun provideWalletManagersFacade(
walletManagersStore: WalletManagersStore,
userWalletsStore: UserWalletsStore,
assetLoader: AssetLoader,
blockchainSDKFactory: BlockchainSDKFactory,
dispatchers: CoroutineDispatcherProvider,
): WalletManagersFacade {
return DefaultWalletManagersFacade(
walletManagersStore = walletManagersStore,
userWalletsStore = userWalletsStore,
assetLoader = assetLoader,
dispatchers = dispatchers,
blockchainSDKFactory = blockchainSDKFactory,
)
}
}

View file

@ -7,8 +7,8 @@ import com.tangem.common.card.EllipticCurve
import com.tangem.common.extensions.ByteArrayKey
import com.tangem.common.extensions.toMapKey
import com.tangem.crypto.hdWallet.DerivationPath
import com.tangem.domain.common.configs.CardConfig
import com.tangem.domain.common.util.derivationStyleProvider
import com.tangem.domain.card.configs.CardConfig
import com.tangem.domain.card.common.util.derivationStyleProvider
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.network.Network
import com.tangem.domain.models.scan.KeyWalletPublicKey

View file

@ -1,6 +1,5 @@
package com.tangem.tap.domain.model
import com.tangem.domain.common.BlockchainNetwork
import com.tangem.domain.features.addCustomToken.CustomCurrency
import com.tangem.tap.common.redux.global.CryptoCurrencyName
import com.tangem.blockchain.common.Blockchain as SdkBlockchain
@ -32,21 +31,6 @@ sealed interface Currency {
}
companion object {
fun fromBlockchainNetwork(blockchainNetwork: BlockchainNetwork, token: SdkToken? = null): Currency {
return if (token != null) {
Token(
token = token,
blockchain = blockchainNetwork.blockchain,
derivationPath = blockchainNetwork.derivationPath,
)
} else {
Blockchain(
blockchain = blockchainNetwork.blockchain,
derivationPath = blockchainNetwork.derivationPath,
)
}
}
fun fromCustomCurrency(customCurrency: CustomCurrency): Currency {
return when (customCurrency) {
is CustomCurrency.CustomBlockchain -> Blockchain(

View file

@ -19,7 +19,7 @@ import com.tangem.core.ui.extensions.resourceReference
import com.tangem.core.ui.extensions.toWrappedList
import com.tangem.core.ui.message.dialog.Dialogs
import com.tangem.domain.common.extensions.withMainContext
import com.tangem.domain.common.util.twinsIsTwinned
import com.tangem.domain.card.common.util.twinsIsTwinned
import com.tangem.domain.feedback.models.FeedbackEmailType
import com.tangem.domain.models.scan.ScanResponse
import com.tangem.domain.wallets.builder.UserWalletIdBuilder

View file

@ -5,7 +5,7 @@ import arrow.core.right
import com.tangem.common.routing.AppRoute
import com.tangem.core.analytics.Analytics
import com.tangem.domain.card.ScanCardException
import com.tangem.domain.common.util.twinsIsTwinned
import com.tangem.domain.card.common.util.twinsIsTwinned
import com.tangem.domain.core.chain.Chain
import com.tangem.domain.core.chain.ResultChain
import com.tangem.domain.models.scan.ScanResponse

View file

@ -19,8 +19,8 @@ import com.tangem.crypto.bip39.DefaultMnemonic
import com.tangem.crypto.hdWallet.DerivationPath
import com.tangem.crypto.hdWallet.bip32.ExtendedPublicKey
import com.tangem.domain.card.repository.CardSdkConfigRepository
import com.tangem.domain.common.util.cardTypesResolver
import com.tangem.domain.common.util.derivationStyleProvider
import com.tangem.domain.card.common.util.cardTypesResolver
import com.tangem.domain.card.common.util.derivationStyleProvider
import com.tangem.domain.models.scan.CardDTO
import com.tangem.domain.models.scan.ScanResponse
import com.tangem.domain.models.wallet.UserWalletId

View file

@ -13,10 +13,10 @@ import com.tangem.common.extensions.toMapKey
import com.tangem.common.map
import com.tangem.crypto.bip39.Mnemonic
import com.tangem.crypto.hdWallet.DerivationPath
import com.tangem.domain.common.CardTypesResolver
import com.tangem.domain.common.DerivationStyleProvider
import com.tangem.domain.common.TapWorkarounds.isTestCard
import com.tangem.domain.common.configs.CardConfig
import com.tangem.domain.card.CardTypesResolver
import com.tangem.domain.card.DerivationStyleProvider
import com.tangem.domain.card.common.TapWorkarounds.isTestCard
import com.tangem.domain.card.configs.CardConfig
import com.tangem.domain.models.scan.CardDTO
import com.tangem.operations.backup.PrimaryCard
import com.tangem.operations.backup.StartPrimaryCardLinkingCommand

View file

@ -6,8 +6,8 @@ import com.tangem.blockchain.common.derivation.DerivationStyle
import com.tangem.blockchainsdk.utils.fromNetworkId
import com.tangem.crypto.hdWallet.DerivationPath
import com.tangem.datasource.local.token.UserTokensResponseStore
import com.tangem.domain.common.DerivationStyleProvider
import com.tangem.domain.common.TapWorkarounds.useOldStyleDerivation
import com.tangem.domain.card.DerivationStyleProvider
import com.tangem.domain.card.common.TapWorkarounds.useOldStyleDerivation
import com.tangem.domain.models.scan.CardDTO
import com.tangem.domain.models.wallet.UserWalletId
import com.tangem.domain.wallets.builder.UserWalletIdBuilder

View file

@ -14,16 +14,16 @@ import com.tangem.common.tlv.Tlv
import com.tangem.common.tlv.TlvDecoder
import com.tangem.crypto.CryptoUtils
import com.tangem.crypto.hdWallet.DerivationPath
import com.tangem.domain.common.DerivationStyleProvider
import com.tangem.domain.common.TapWorkarounds.isExcluded
import com.tangem.domain.common.TapWorkarounds.isNotSupportedInThatRelease
import com.tangem.domain.common.TapWorkarounds.isStart2Coin
import com.tangem.domain.common.TapWorkarounds.isTangemTwins
import com.tangem.domain.common.TapWorkarounds.isVisa
import com.tangem.domain.card.DerivationStyleProvider
import com.tangem.domain.card.common.TapWorkarounds.isExcluded
import com.tangem.domain.card.common.TapWorkarounds.isNotSupportedInThatRelease
import com.tangem.domain.card.common.TapWorkarounds.isStart2Coin
import com.tangem.domain.card.common.TapWorkarounds.isTangemTwins
import com.tangem.domain.card.common.TapWorkarounds.isVisa
import com.tangem.domain.common.TwinsHelper
import com.tangem.domain.common.configs.CardConfig
import com.tangem.domain.common.util.derivationStyleProvider
import com.tangem.domain.common.visa.VisaUtilities
import com.tangem.domain.card.common.util.derivationStyleProvider
import com.tangem.domain.card.common.visa.VisaUtilities
import com.tangem.domain.card.configs.CardConfig
import com.tangem.domain.models.scan.CardDTO
import com.tangem.domain.models.scan.CardDTO.Companion.RING_BATCH_IDS
import com.tangem.domain.models.scan.CardDTO.Companion.RING_BATCH_PREFIX

View file

@ -17,7 +17,7 @@ import com.tangem.datasource.local.visa.VisaAuthTokenStorage
import com.tangem.datasource.local.visa.VisaOTPStorage
import com.tangem.datasource.local.visa.VisaOtpData
import com.tangem.datasource.local.visa.hasSavedOTP
import com.tangem.domain.common.visa.VisaWalletPublicKeyUtility
import com.tangem.domain.card.common.visa.VisaWalletPublicKeyUtility
import com.tangem.domain.models.scan.CardDTO
import com.tangem.domain.visa.error.VisaActivationError
import com.tangem.domain.visa.model.*

View file

@ -16,10 +16,10 @@ import com.tangem.common.extensions.toHexString
import com.tangem.core.error.ext.tangemError
import com.tangem.crypto.hdWallet.DerivationPath
import com.tangem.crypto.hdWallet.bip32.ExtendedPublicKey
import com.tangem.domain.common.util.derivationStyleProvider
import com.tangem.domain.common.visa.VisaUtilities
import com.tangem.domain.common.visa.VisaWalletPublicKeyUtility
import com.tangem.domain.common.visa.VisaWalletPublicKeyUtility.findKeyWithoutDerivation
import com.tangem.domain.card.common.util.derivationStyleProvider
import com.tangem.domain.card.common.visa.VisaUtilities
import com.tangem.domain.card.common.visa.VisaWalletPublicKeyUtility
import com.tangem.domain.card.common.visa.VisaWalletPublicKeyUtility.findKeyWithoutDerivation
import com.tangem.domain.models.scan.CardDTO
import com.tangem.domain.visa.error.VisaActivationError
import com.tangem.domain.visa.model.VisaDataForApprove

View file

@ -9,7 +9,7 @@ import com.tangem.common.extensions.hexToBytes
import com.tangem.common.extensions.toHexString
import com.tangem.core.error.ext.tangemError
import com.tangem.datasource.local.visa.VisaAuthTokenStorage
import com.tangem.domain.common.visa.VisaWalletPublicKeyUtility
import com.tangem.domain.card.common.visa.VisaWalletPublicKeyUtility
import com.tangem.domain.visa.error.VisaActivationError
import com.tangem.domain.visa.error.VisaApiError
import com.tangem.domain.visa.error.VisaCardScanError

View file

@ -2,7 +2,7 @@ package com.tangem.tap.features.demo
import com.tangem.core.ui.extensions.resourceReference
import com.tangem.core.ui.message.DialogMessage
import com.tangem.domain.demo.DemoConfig
import com.tangem.domain.demo.models.DemoConfig
import com.tangem.domain.models.scan.ScanResponse
import com.tangem.tap.common.extensions.inject
import com.tangem.tap.common.redux.AppState

View file

@ -1,6 +1,6 @@
package com.tangem.tap.features.demo
import com.tangem.domain.demo.DemoConfig
import com.tangem.domain.demo.models.DemoConfig
import com.tangem.domain.models.scan.ScanResponse
import org.rekotlin.Action

View file

@ -6,7 +6,7 @@ import com.tangem.common.routing.AppRouter
import com.tangem.core.analytics.Analytics
import com.tangem.core.decompose.di.ModelScoped
import com.tangem.core.decompose.model.Model
import com.tangem.domain.common.util.cardTypesResolver
import com.tangem.domain.card.common.util.cardTypesResolver
import com.tangem.sdk.api.TangemSdkManager
import com.tangem.tap.common.analytics.events.AnalyticsParam
import com.tangem.tap.common.analytics.events.Settings

View file

@ -10,11 +10,11 @@ import com.tangem.core.analytics.Analytics
import com.tangem.core.decompose.di.ModelScoped
import com.tangem.core.decompose.model.Model
import com.tangem.core.decompose.model.ParamsContainer
import com.tangem.domain.card.CardTypesResolver
import com.tangem.domain.card.ScanCardProcessor
import com.tangem.domain.card.repository.CardSdkConfigRepository
import com.tangem.domain.common.CardTypesResolver
import com.tangem.domain.common.util.cardTypesResolver
import com.tangem.domain.common.util.getBackupCardsCount
import com.tangem.domain.card.common.util.cardTypesResolver
import com.tangem.domain.card.common.util.getBackupCardsCount
import com.tangem.domain.models.scan.CardDTO
import com.tangem.domain.models.scan.ScanResponse
import com.tangem.domain.models.wallet.requireColdWallet

View file

@ -1,6 +1,6 @@
package com.tangem.tap.features.details.ui.common.utils
import com.tangem.domain.common.CardTypesResolver
import com.tangem.domain.card.CardTypesResolver
import com.tangem.domain.models.scan.CardDTO
internal fun isAccessCodeRecoveryAllowed(typeResolver: CardTypesResolver): Boolean = typeResolver.isWallet2()

View file

@ -1,6 +1,6 @@
package com.tangem.tap.features.details.ui.common.utils
import com.tangem.domain.common.CardTypesResolver
import com.tangem.domain.card.CardTypesResolver
import com.tangem.tap.features.details.ui.cardsettings.TextReference
import com.tangem.wallet.R

View file

@ -1,6 +1,6 @@
package com.tangem.tap.features.details.ui.common.utils
import com.tangem.domain.common.CardTypesResolver
import com.tangem.domain.card.CardTypesResolver
import com.tangem.domain.models.scan.CardDTO
import com.tangem.tap.features.details.redux.SecurityOption
import java.util.EnumSet

View file

@ -11,7 +11,7 @@ import com.tangem.core.decompose.model.ParamsContainer
import com.tangem.domain.card.DeleteSavedAccessCodesUseCase
import com.tangem.domain.card.ResetCardUseCase
import com.tangem.domain.card.ResetCardUserCodeParams
import com.tangem.domain.common.util.cardTypesResolver
import com.tangem.domain.card.common.util.cardTypesResolver
import com.tangem.domain.models.wallet.requireColdWallet
import com.tangem.domain.wallets.legacy.UserWalletsListManager
import com.tangem.domain.wallets.legacy.asLockable

View file

@ -8,7 +8,7 @@ import com.tangem.core.analytics.api.AnalyticsErrorHandler
import com.tangem.core.analytics.api.AnalyticsEventHandler
import com.tangem.core.decompose.di.ModelScoped
import com.tangem.core.decompose.model.Model
import com.tangem.domain.common.util.cardTypesResolver
import com.tangem.domain.card.common.util.cardTypesResolver
import com.tangem.sdk.api.TangemSdkManager
import com.tangem.tap.common.analytics.events.AnalyticsParam
import com.tangem.tap.common.analytics.events.Settings

View file

@ -15,7 +15,7 @@ import com.tangem.core.decompose.navigation.Router
import com.tangem.core.navigation.url.UrlOpener
import com.tangem.domain.card.ScanCardProcessor
import com.tangem.domain.card.repository.CardSdkConfigRepository
import com.tangem.domain.common.util.cardTypesResolver
import com.tangem.domain.card.common.util.cardTypesResolver
import com.tangem.domain.models.scan.ScanResponse
import com.tangem.domain.settings.repositories.SettingsRepository
import com.tangem.domain.settings.usercountry.GetUserCountryUseCase

View file

@ -9,7 +9,7 @@ import com.tangem.common.routing.AppRoute
import com.tangem.core.analytics.Analytics
import com.tangem.core.analytics.models.AnalyticsParam
import com.tangem.core.analytics.models.Basic
import com.tangem.domain.common.util.cardTypesResolver
import com.tangem.domain.card.common.util.cardTypesResolver
import com.tangem.domain.models.scan.ScanResponse
import com.tangem.tap.common.analytics.converters.ParamCardCurrencyConverter
import com.tangem.tap.common.analytics.events.IntroductionProcess

View file

@ -1,7 +1,7 @@
package com.tangem.tap.features.onboarding
import com.tangem.domain.common.util.cardTypesResolver
import com.tangem.domain.common.util.twinsIsTwinned
import com.tangem.domain.card.common.util.cardTypesResolver
import com.tangem.domain.card.common.util.twinsIsTwinned
import com.tangem.domain.models.scan.CardDTO
import com.tangem.domain.models.scan.ScanResponse
import com.tangem.domain.visa.model.VisaCardActivationStatus

View file

@ -11,7 +11,7 @@ import com.tangem.common.routing.utils.popTo
import com.tangem.core.analytics.Analytics
import com.tangem.core.analytics.models.AnalyticsParam
import com.tangem.core.analytics.models.Basic
import com.tangem.domain.common.util.cardTypesResolver
import com.tangem.domain.card.common.util.cardTypesResolver
import com.tangem.domain.models.scan.ScanResponse
import com.tangem.domain.models.wallet.UserWallet
import com.tangem.domain.wallets.legacy.UserWalletsListManager.Lockable.UnlockType

View file

@ -6,7 +6,7 @@ import com.tangem.blockchainsdk.utils.toBlockchain
import com.tangem.common.services.Result
import com.tangem.common.services.performRequest
import com.tangem.datasource.api.common.createRetrofitInstance
import com.tangem.domain.common.TapWorkarounds.isStart2Coin
import com.tangem.domain.card.common.TapWorkarounds.isStart2Coin
import com.tangem.domain.common.extensions.withIOContext
import com.tangem.domain.core.utils.lceContent
import com.tangem.domain.core.utils.lceError

View file

@ -9,8 +9,8 @@ import com.tangem.common.test.domain.token.MockCryptoCurrencyFactory
import com.tangem.data.common.network.NetworkFactory
import com.tangem.datasource.local.userwallet.UserWalletsStore
import com.tangem.domain.card.ScanCardException
import com.tangem.domain.common.configs.GenericCardConfig
import com.tangem.domain.common.configs.MultiWalletCardConfig
import com.tangem.domain.card.configs.GenericCardConfig
import com.tangem.domain.card.configs.MultiWalletCardConfig
import com.tangem.domain.models.wallet.UserWallet
import com.tangem.domain.models.wallet.UserWalletId
import com.tangem.operations.derivation.DerivationTaskResponse

View file

@ -10,10 +10,10 @@ import com.tangem.common.test.domain.card.MockScanResponseFactory
import com.tangem.common.test.domain.token.MockCryptoCurrencyFactory
import com.tangem.common.test.domain.wallet.MockUserWalletFactory
import com.tangem.crypto.hdWallet.DerivationPath
import com.tangem.domain.common.configs.GenericCardConfig
import com.tangem.domain.common.configs.MultiWalletCardConfig
import com.tangem.domain.common.configs.Wallet2CardConfig
import com.tangem.domain.common.util.derivationStyleProvider
import com.tangem.domain.card.configs.GenericCardConfig
import com.tangem.domain.card.configs.MultiWalletCardConfig
import com.tangem.domain.card.configs.Wallet2CardConfig
import com.tangem.domain.card.common.util.derivationStyleProvider
import org.junit.Test
/**

View file

@ -2,7 +2,7 @@ package com.tangem.tap.domain.userWalletList.implementation
import com.google.common.truth.Truth
import com.tangem.common.test.domain.card.MockScanResponseFactory
import com.tangem.domain.common.configs.GenericCardConfig
import com.tangem.domain.card.configs.GenericCardConfig
import com.tangem.domain.models.wallet.UserWallet
import com.tangem.domain.models.wallet.UserWalletId
import io.mockk.mockk

View file

@ -17,6 +17,7 @@ dependencies {
implementation(projects.domain.legacy)
implementation(projects.domain.models)
implementation(projects.domain.card)
implementation(projects.domain.staking.models)
implementation(projects.domain.tokens.models)
implementation(projects.domain.txhistory.models)

View file

@ -2,7 +2,11 @@ package com.tangem.common.test.domain.card
import com.tangem.common.card.CardWallet
import com.tangem.common.card.FirmwareVersion
import com.tangem.domain.common.configs.*
import com.tangem.domain.card.configs.CardConfig
import com.tangem.domain.card.configs.EdSingleCurrencyCardConfig
import com.tangem.domain.card.configs.GenericCardConfig
import com.tangem.domain.card.configs.MultiWalletCardConfig
import com.tangem.domain.card.configs.Wallet2CardConfig
import com.tangem.domain.models.scan.CardDTO
import com.tangem.domain.models.scan.KeyWalletPublicKey
import com.tangem.domain.models.scan.ProductType

View file

@ -8,9 +8,9 @@ import com.tangem.blockchainsdk.utils.toNetworkId
import com.tangem.common.test.domain.card.MockScanResponseFactory
import com.tangem.common.test.domain.wallet.MockUserWalletFactory
import com.tangem.data.common.currency.CryptoCurrencyFactory
import com.tangem.domain.common.DerivationStyleProvider
import com.tangem.domain.common.configs.GenericCardConfig
import com.tangem.domain.common.util.derivationStyleProvider
import com.tangem.domain.card.DerivationStyleProvider
import com.tangem.domain.card.common.util.derivationStyleProvider
import com.tangem.domain.card.configs.GenericCardConfig
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.network.Network
import com.tangem.domain.models.wallet.UserWallet

View file

@ -1,8 +1,8 @@
package com.tangem.common.test.domain.wallet
import com.tangem.common.test.domain.card.MockScanResponseFactory
import com.tangem.domain.common.configs.GenericCardConfig
import com.tangem.domain.common.util.cardTypesResolver
import com.tangem.domain.card.common.util.cardTypesResolver
import com.tangem.domain.card.configs.GenericCardConfig
import com.tangem.domain.models.scan.ScanResponse
import com.tangem.domain.models.wallet.UserWallet
import com.tangem.domain.wallets.builder.UserWalletIdBuilder

View file

@ -34,6 +34,7 @@ dependencies {
implementation(projects.domain.appCurrency.models)
implementation(projects.domain.models)
implementation(projects.domain.legacy)
implementation(projects.domain.card)
implementation(projects.domain.staking.models)
implementation(projects.domain.staking)
implementation(projects.domain.tokens.models)

View file

@ -8,7 +8,7 @@ import com.tangem.core.ui.extensions.wrappedList
import com.tangem.core.ui.format.bigdecimal.fiat
import com.tangem.core.ui.format.bigdecimal.format
import com.tangem.domain.appcurrency.model.AppCurrency
import com.tangem.domain.common.util.getCardsCount
import com.tangem.domain.card.common.util.getCardsCount
import com.tangem.domain.models.ArtworkModel
import com.tangem.domain.models.StatusSource
import com.tangem.domain.models.TotalFiatBalance

View file

@ -21,6 +21,7 @@ dependencies {
/* Domain */
implementation(projects.domain.demo)
implementation(projects.domain.legacy)
implementation(projects.domain.card)
implementation(projects.domain.models)
implementation(projects.domain.tokens.models)
implementation(projects.domain.wallets.models)

View file

@ -6,9 +6,9 @@ import com.tangem.blockchainsdk.utils.toBlockchain
import com.tangem.blockchainsdk.utils.toNetworkId
import com.tangem.datasource.local.token.UserTokensResponseStore
import com.tangem.datasource.local.userwallet.UserWalletsStore
import com.tangem.domain.common.TapWorkarounds.isTestCard
import com.tangem.domain.common.util.cardTypesResolver
import com.tangem.domain.demo.DemoConfig
import com.tangem.domain.card.common.TapWorkarounds.isTestCard
import com.tangem.domain.card.common.util.cardTypesResolver
import com.tangem.domain.demo.models.DemoConfig
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.network.Network
import com.tangem.domain.models.wallet.UserWallet

View file

@ -6,7 +6,7 @@ import com.tangem.blockchainsdk.utils.fromNetworkId
import com.tangem.blockchainsdk.utils.toCoinId
import com.tangem.data.common.network.NetworkFactory
import com.tangem.datasource.api.tangemTech.models.UserTokensResponse
import com.tangem.domain.common.util.cardTypesResolver
import com.tangem.domain.card.common.util.cardTypesResolver
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.wallet.UserWallet
import timber.log.Timber

View file

@ -7,7 +7,7 @@ import com.tangem.data.common.quote.QuotesFetcher
import com.tangem.datasource.api.tangemTech.TangemTechApi
import com.tangem.datasource.local.token.UserTokensResponseStore
import com.tangem.datasource.local.userwallet.UserWalletsStore
import com.tangem.domain.demo.DemoConfig
import com.tangem.domain.demo.models.DemoConfig
import com.tangem.domain.networks.multi.MultiNetworkStatusSupplier
import com.tangem.domain.notifications.toggles.NotificationsFeatureToggles
import com.tangem.domain.wallets.repository.WalletsRepository

View file

@ -6,9 +6,9 @@ import com.tangem.blockchain.common.FeePaidCurrency
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
import com.tangem.blockchainsdk.utils.toBlockchain
import com.tangem.blockchainsdk.utils.toNetworkId
import com.tangem.domain.common.DerivationStyleProvider
import com.tangem.domain.common.extensions.canHandleToken
import com.tangem.domain.common.util.derivationStyleProvider
import com.tangem.domain.card.DerivationStyleProvider
import com.tangem.domain.card.common.extensions.canHandleToken
import com.tangem.domain.card.common.util.derivationStyleProvider
import com.tangem.domain.models.network.Network
import com.tangem.domain.models.wallet.UserWallet
import timber.log.Timber

View file

@ -12,9 +12,9 @@ import com.tangem.data.common.network.NetworkFactory
import com.tangem.datasource.api.tangemTech.models.UserTokensResponse
import com.tangem.datasource.local.token.UserTokensResponseStore
import com.tangem.datasource.local.userwallet.UserWalletsStore
import com.tangem.domain.common.configs.GenericCardConfig
import com.tangem.domain.common.util.cardTypesResolver
import com.tangem.domain.demo.DemoConfig
import com.tangem.domain.card.configs.GenericCardConfig
import com.tangem.domain.card.common.util.cardTypesResolver
import com.tangem.domain.demo.models.DemoConfig
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.network.Network
import com.tangem.domain.models.scan.ProductType

View file

@ -7,10 +7,10 @@ import com.tangem.common.test.domain.card.MockScanResponseFactory
import com.tangem.common.test.domain.token.MockCryptoCurrencyFactory
import com.tangem.common.test.domain.wallet.MockUserWalletFactory
import com.tangem.common.test.utils.ProvideTestModels
import com.tangem.domain.common.DerivationStyleProvider
import com.tangem.domain.common.configs.GenericCardConfig
import com.tangem.domain.common.configs.MultiWalletCardConfig
import com.tangem.domain.common.util.derivationStyleProvider
import com.tangem.domain.card.DerivationStyleProvider
import com.tangem.domain.card.configs.GenericCardConfig
import com.tangem.domain.card.configs.MultiWalletCardConfig
import com.tangem.domain.card.common.util.derivationStyleProvider
import com.tangem.domain.models.network.Network
import com.tangem.domain.models.scan.ScanResponse
import com.tangem.domain.models.wallet.UserWallet

View file

@ -41,6 +41,7 @@ dependencies {
implementation(projects.domain.feedback)
implementation(projects.domain.feedback.models)
implementation(projects.domain.legacy)
implementation(projects.domain.card)
implementation(projects.domain.models)
implementation(projects.domain.wallets)
implementation(projects.domain.wallets.models)

View file

@ -1,8 +1,8 @@
package com.tangem.data.feedback.converters
import com.tangem.domain.common.TapWorkarounds.isStart2Coin
import com.tangem.domain.common.TapWorkarounds.isVisa
import com.tangem.domain.common.util.getBackupCardsCount
import com.tangem.domain.card.common.TapWorkarounds.isStart2Coin
import com.tangem.domain.card.common.TapWorkarounds.isVisa
import com.tangem.domain.card.common.util.getBackupCardsCount
import com.tangem.domain.feedback.models.CardInfo
import com.tangem.domain.models.scan.CardDTO
import com.tangem.domain.models.scan.ScanResponse

View file

@ -18,6 +18,7 @@ dependencies {
implementation(projects.domain.demo)
implementation(projects.domain.models)
implementation(projects.domain.manageTokens)
implementation(projects.domain.card)
implementation(projects.domain.tokens.models)
implementation(projects.domain.wallets.models)
implementation(projects.domain.legacy)

View file

@ -14,9 +14,9 @@ import com.tangem.datasource.api.common.response.getOrThrow
import com.tangem.datasource.api.tangemTech.TangemTechApi
import com.tangem.datasource.local.token.UserTokensResponseStore
import com.tangem.datasource.local.userwallet.UserWalletsStore
import com.tangem.domain.common.extensions.canHandleBlockchain
import com.tangem.domain.common.extensions.supportedBlockchains
import com.tangem.domain.common.util.cardTypesResolver
import com.tangem.domain.card.common.extensions.canHandleBlockchain
import com.tangem.domain.card.common.extensions.supportedBlockchains
import com.tangem.domain.card.common.util.cardTypesResolver
import com.tangem.domain.managetokens.model.AddCustomTokenForm
import com.tangem.domain.managetokens.model.ManagedCryptoCurrency
import com.tangem.domain.managetokens.repository.CustomTokensRepository

View file

@ -19,12 +19,12 @@ import com.tangem.datasource.api.tangemTech.models.UserTokensResponse
import com.tangem.datasource.local.config.testnet.TestnetTokensStorage
import com.tangem.datasource.local.token.UserTokensResponseStore
import com.tangem.datasource.local.userwallet.UserWalletsStore
import com.tangem.domain.common.TapWorkarounds.isTestCard
import com.tangem.domain.common.extensions.canHandleBlockchain
import com.tangem.domain.common.extensions.canHandleToken
import com.tangem.domain.common.extensions.supportedBlockchains
import com.tangem.domain.common.extensions.supportedTokens
import com.tangem.domain.common.util.cardTypesResolver
import com.tangem.domain.card.common.TapWorkarounds.isTestCard
import com.tangem.domain.card.common.extensions.canHandleBlockchain
import com.tangem.domain.card.common.extensions.canHandleToken
import com.tangem.domain.card.common.extensions.supportedBlockchains
import com.tangem.domain.card.common.extensions.supportedTokens
import com.tangem.domain.card.common.util.cardTypesResolver
import com.tangem.domain.managetokens.model.*
import com.tangem.domain.managetokens.model.ManagedCryptoCurrency.SourceNetwork
import com.tangem.domain.managetokens.repository.ManageTokensRepository

View file

@ -13,9 +13,9 @@ import com.tangem.data.common.network.NetworkFactory
import com.tangem.datasource.api.tangemTech.models.CoinsResponse
import com.tangem.datasource.api.tangemTech.models.UserTokensResponse
import com.tangem.datasource.local.config.testnet.models.TestnetTokensConfig
import com.tangem.domain.common.DerivationStyleProvider
import com.tangem.domain.common.extensions.canHandleToken
import com.tangem.domain.common.util.derivationStyleProvider
import com.tangem.domain.card.DerivationStyleProvider
import com.tangem.domain.card.common.extensions.canHandleToken
import com.tangem.domain.card.common.util.derivationStyleProvider
import com.tangem.domain.managetokens.model.ManagedCryptoCurrency
import com.tangem.domain.managetokens.model.ManagedCryptoCurrency.SourceNetwork
import com.tangem.domain.models.currency.CryptoCurrency

View file

@ -25,6 +25,8 @@ dependencies {
// region Project - Domain
implementation(projects.domain.legacy)
implementation(projects.domain.walletManager)
implementation(projects.domain.card)
api(projects.domain.models)
implementation(projects.domain.networks)
// endregion

View file

@ -11,7 +11,7 @@ import com.tangem.data.networks.models.SimpleNetworkStatus
import com.tangem.data.networks.store.NetworksStatusesStore
import com.tangem.data.networks.toSimple
import com.tangem.datasource.local.userwallet.UserWalletsStore
import com.tangem.domain.common.configs.GenericCardConfig
import com.tangem.domain.card.configs.GenericCardConfig
import com.tangem.domain.models.network.NetworkStatus
import com.tangem.domain.networks.multi.MultiNetworkStatusProducer
import com.tangem.utils.coroutines.TestingCoroutineDispatcherProvider

View file

@ -23,6 +23,8 @@ dependencies {
implementation(projects.domain.wallets.models)
implementation(projects.domain.tokens.models)
implementation(projects.domain.nft)
implementation(projects.domain.walletManager)
implementation(projects.domain.card)
implementation(projects.domain.nft.models)
/** Project - Utils */

View file

@ -16,8 +16,8 @@ import com.tangem.datasource.local.nft.converter.NFTSdkAssetSalePriceConverter
import com.tangem.datasource.local.nft.converter.NFTSdkCollectionConverter
import com.tangem.datasource.local.nft.converter.NFTSdkCollectionIdentifierConverter
import com.tangem.datasource.local.userwallet.UserWalletsStore
import com.tangem.domain.common.extensions.canHandleToken
import com.tangem.domain.common.util.cardTypesResolver
import com.tangem.domain.card.common.extensions.canHandleToken
import com.tangem.domain.card.common.util.cardTypesResolver
import com.tangem.domain.models.StatusSource
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.network.Network
@ -542,6 +542,7 @@ internal class DefaultNFTRepository @Inject constructor(
}
private fun Network.canHandleNFTs(userWalletId: UserWalletId): Boolean {
// TODO [REDACTED_TASK_KEY]
val scanResponse = userWalletsStore.getSyncStrict(userWalletId).requireColdWallet().scanResponse
val blockchain = Blockchain.fromNetworkId(backendId) ?: return false

View file

@ -25,6 +25,8 @@ dependencies {
/** Domain modules */
implementation(projects.domain.onramp)
implementation(projects.domain.legacy)
implementation(projects.domain.card)
implementation(projects.domain.walletManager)
implementation(projects.domain.appTheme.models)
implementation(projects.domain.models)

View file

@ -20,9 +20,9 @@ import com.tangem.datasource.local.preferences.PreferencesKeys
import com.tangem.datasource.local.preferences.utils.getObject
import com.tangem.datasource.local.token.UserTokensResponseStore
import com.tangem.datasource.local.userwallet.UserWalletsStore
import com.tangem.domain.common.extensions.canHandleBlockchain
import com.tangem.domain.common.extensions.canHandleToken
import com.tangem.domain.common.util.cardTypesResolver
import com.tangem.domain.card.common.extensions.canHandleBlockchain
import com.tangem.domain.card.common.extensions.canHandleToken
import com.tangem.domain.card.common.util.cardTypesResolver
import com.tangem.domain.models.wallet.UserWallet
import com.tangem.domain.models.wallet.UserWalletId
import com.tangem.domain.onramp.model.HotCryptoCurrency

View file

@ -32,6 +32,8 @@ dependencies {
implementation(projects.domain.wallets)
implementation(projects.domain.wallets.models)
implementation(projects.domain.legacy)
implementation(projects.domain.walletManager)
implementation(projects.domain.card)
implementation(projects.domain.models)
/** Feature Api modules */

View file

@ -34,7 +34,7 @@ import com.tangem.datasource.api.stakekit.models.response.model.transaction.tron
import com.tangem.datasource.local.token.StakingYieldsStore
import com.tangem.datasource.local.token.converter.StakingNetworkTypeConverter
import com.tangem.datasource.local.token.converter.TokenConverter
import com.tangem.domain.common.TapWorkarounds.isWallet2
import com.tangem.domain.card.common.TapWorkarounds.isWallet2
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.network.Network
import com.tangem.domain.models.wallet.UserWallet

View file

@ -27,6 +27,8 @@ dependencies {
implementation(projects.domain.core)
implementation(projects.domain.demo)
implementation(projects.domain.legacy)
implementation(projects.domain.walletManager)
implementation(projects.domain.card)
implementation(projects.domain.models)
implementation(projects.domain.staking)
implementation(projects.domain.staking.models)

View file

@ -15,7 +15,7 @@ import com.tangem.datasource.exchangeservice.swap.ExpressServiceLoader
import com.tangem.datasource.local.token.UserTokensResponseStore
import com.tangem.datasource.local.userwallet.UserWalletsStore
import com.tangem.domain.core.utils.catchOn
import com.tangem.domain.demo.DemoConfig
import com.tangem.domain.demo.models.DemoConfig
import com.tangem.domain.models.wallet.UserWallet
import com.tangem.domain.models.wallet.isMultiCurrency
import com.tangem.domain.models.wallet.requireColdWallet

View file

@ -8,7 +8,7 @@ import com.tangem.datasource.api.tangemTech.TangemTechApi
import com.tangem.datasource.exchangeservice.swap.ExpressServiceLoader
import com.tangem.datasource.local.token.UserTokensResponseStore
import com.tangem.datasource.local.userwallet.UserWalletsStore
import com.tangem.domain.demo.DemoConfig
import com.tangem.domain.demo.models.DemoConfig
import com.tangem.domain.tokens.MultiWalletCryptoCurrenciesFetcher
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
import dagger.Module

View file

@ -17,10 +17,10 @@ import com.tangem.datasource.api.tangemTech.models.UserTokensResponse
import com.tangem.datasource.exchangeservice.swap.ExpressServiceLoader
import com.tangem.datasource.local.token.UserTokensResponseStore
import com.tangem.datasource.local.userwallet.UserWalletsStore
import com.tangem.domain.common.CardTypesResolver
import com.tangem.domain.common.util.cardTypesResolver
import com.tangem.domain.card.CardTypesResolver
import com.tangem.domain.card.common.util.cardTypesResolver
import com.tangem.domain.core.error.DataError
import com.tangem.domain.demo.DemoConfig
import com.tangem.domain.demo.models.DemoConfig
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.network.Network
import com.tangem.domain.models.wallet.*

View file

@ -18,7 +18,7 @@ import com.tangem.datasource.api.tangemTech.models.UserTokensResponse
import com.tangem.datasource.exchangeservice.swap.ExpressServiceLoader
import com.tangem.datasource.local.token.UserTokensResponseStore
import com.tangem.datasource.local.userwallet.UserWalletsStore
import com.tangem.domain.demo.DemoConfig
import com.tangem.domain.demo.models.DemoConfig
import com.tangem.domain.models.wallet.UserWallet
import com.tangem.domain.models.wallet.UserWalletId
import com.tangem.domain.models.wallet.isMultiCurrency

View file

@ -10,7 +10,7 @@ import com.tangem.data.common.currency.ResponseCryptoCurrenciesFactory
import com.tangem.datasource.api.tangemTech.models.UserTokensResponse
import com.tangem.datasource.local.token.UserTokensResponseStore
import com.tangem.datasource.local.userwallet.UserWalletsStore
import com.tangem.domain.common.configs.GenericCardConfig
import com.tangem.domain.card.configs.GenericCardConfig
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.wallet.UserWallet
import com.tangem.domain.models.wallet.isMultiCurrency

View file

@ -23,6 +23,7 @@ dependencies {
/** Domain */
implementation(projects.domain.transaction)
implementation(projects.domain.legacy)
implementation(projects.domain.walletManager)
implementation(projects.libs.blockchainSdk)
implementation(projects.domain.wallets.models)
implementation(projects.domain.tokens.models)

View file

@ -16,6 +16,7 @@ dependencies {
implementation(projects.core.datasource)
implementation(projects.core.pagination)
implementation(projects.domain.legacy)
implementation(projects.domain.walletManager)
implementation(projects.libs.blockchainSdk)
implementation(projects.domain.models)
implementation(projects.domain.tokens.models)

View file

@ -21,6 +21,7 @@ dependencies {
/** Project - Domain */
implementation(projects.domain.visa)
implementation(projects.domain.card)
implementation(projects.domain.models)
implementation(projects.domain.wallets.models)
implementation(projects.domain.appCurrency.models)

View file

@ -17,7 +17,7 @@ import com.tangem.data.visa.utils.*
import com.tangem.datasource.api.pay.TangemPayApi
import com.tangem.datasource.api.pay.models.response.VisaTxHistoryResponse
import com.tangem.datasource.local.userwallet.UserWalletsStore
import com.tangem.domain.common.util.cardTypesResolver
import com.tangem.domain.card.common.util.cardTypesResolver
import com.tangem.domain.models.wallet.UserWallet
import com.tangem.domain.models.wallet.UserWalletId
import com.tangem.domain.models.wallet.requireColdWallet

View file

@ -8,7 +8,7 @@ import com.tangem.datasource.api.common.response.getOrThrow
import com.tangem.datasource.api.pay.TangemPayApi
import com.tangem.datasource.api.pay.models.request.RefreshTokenByCardWalletRequest
import com.tangem.datasource.local.userwallet.UserWalletsStore
import com.tangem.domain.common.util.cardTypesResolver
import com.tangem.domain.card.common.util.cardTypesResolver
import com.tangem.domain.models.wallet.UserWallet
import com.tangem.domain.models.wallet.UserWalletId
import com.tangem.domain.models.wallet.requireColdWallet

View file

@ -3,7 +3,7 @@ package com.tangem.data.visa.utils
import com.tangem.blockchain.common.Blockchain
import com.tangem.data.common.currency.CryptoCurrencyFactory
import com.tangem.data.common.network.NetworkFactory
import com.tangem.domain.common.util.derivationStyleProvider
import com.tangem.domain.card.common.util.derivationStyleProvider
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.network.NetworkAddress
import com.tangem.domain.models.wallet.UserWallet

View file

@ -22,6 +22,7 @@ dependencies {
implementation(projects.domain.tokens.models)
implementation(projects.domain.models)
implementation(projects.domain.legacy)
implementation(projects.domain.walletManager)
implementation(projects.libs.blockchainSdk)
implementation(projects.data.common)

1
data/wallet-manager/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/build

View file

@ -0,0 +1,53 @@
plugins {
alias(deps.plugins.android.library)
alias(deps.plugins.kotlin.android)
alias(deps.plugins.kotlin.kapt)
alias(deps.plugins.hilt.android)
id("configuration")
}
android {
namespace = "com.tangem.data.walletmanager"
}
dependencies {
/** Tangem libraries */
implementation(tangemDeps.blockchain)
implementation(tangemDeps.card.core)
/** Core */
implementation(projects.core.datasource)
implementation(projects.core.utils)
implementation(projects.core.error)
implementation(projects.core.error.ext)
/** Domain */
implementation(projects.domain.wallets)
implementation(projects.domain.walletManager)
implementation(projects.domain.demo)
implementation(projects.domain.card)
api(projects.domain.models)
/** Domain models */
implementation(projects.domain.wallets.models)
implementation(projects.domain.tokens.models)
implementation(projects.domain.txhistory.models)
implementation(projects.domain.transaction.models)
/** DI */
implementation(deps.hilt.android)
kapt(deps.hilt.kapt)
/** Other deps */
implementation(projects.libs.blockchainSdk)
implementation(deps.androidx.datastore)
implementation(deps.arrow.core)
implementation(deps.timber)
/** Testing libraries */
testImplementation(deps.test.junit5)
testRuntimeOnly(deps.test.junit5.engine)
testImplementation(deps.test.mockk)
testImplementation(deps.test.truth)
testImplementation(projects.common.test)
}

View file

@ -1,4 +1,4 @@
package com.tangem.domain.walletmanager
package com.tangem.data.walletmanager
import arrow.core.Either
import arrow.core.raise.either
@ -23,11 +23,11 @@ import com.tangem.blockchainsdk.BlockchainSDKFactory
import com.tangem.blockchainsdk.models.UpdateWalletManagerResult
import com.tangem.blockchainsdk.utils.toBlockchain
import com.tangem.crypto.hdWallet.DerivationPath
import com.tangem.data.walletmanager.utils.*
import com.tangem.datasource.asset.loader.AssetLoader
import com.tangem.datasource.local.userwallet.UserWalletsStore
import com.tangem.datasource.local.walletmanager.WalletManagersStore
import com.tangem.domain.common.util.hasDerivation
import com.tangem.domain.demo.DemoConfig
import com.tangem.domain.demo.models.DemoConfig
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.network.Network
import com.tangem.domain.models.network.TxInfo
@ -36,11 +36,12 @@ import com.tangem.domain.models.wallet.UserWalletId
import com.tangem.domain.transaction.models.AssetRequirementsCondition
import com.tangem.domain.txhistory.models.PaginationWrapper
import com.tangem.domain.txhistory.models.TxHistoryState
import com.tangem.domain.walletmanager.WalletManagersFacade
import com.tangem.domain.walletmanager.model.RentData
import com.tangem.domain.walletmanager.model.SmartContractMethod
import com.tangem.domain.walletmanager.model.TokenInfo
import com.tangem.domain.walletmanager.utils.*
import com.tangem.domain.walletmanager.utils.WalletManagerFactory
import com.tangem.domain.walletmanager.utils.SdkPageConverter
import com.tangem.domain.wallets.extension.hasDerivation
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.sync.Mutex
@ -49,11 +50,10 @@ import kotlinx.coroutines.withContext
import timber.log.Timber
import java.math.BigDecimal
import java.util.EnumSet
import javax.inject.Inject
@Suppress("LargeClass", "TooManyFunctions")
// FIXME: Move to its own module and make internal
@Deprecated("Inject the WalletManagerFacade interface using DI instead")
class DefaultWalletManagersFacade(
internal class DefaultWalletManagersFacade @Inject constructor(
private val walletManagersStore: WalletManagersStore,
private val userWalletsStore: UserWalletsStore,
private val assetLoader: AssetLoader,
@ -163,8 +163,7 @@ class DefaultWalletManagersFacade(
val derivationPath = network.derivationPath.value
if (derivationPath != null &&
userWallet is UserWallet.Cold &&
!userWallet.scanResponse.hasDerivation(blockchain, derivationPath)
!userWallet.hasDerivation(blockchain, derivationPath)
) {
Timber.w("Derivation missed for: $blockchain")
return UpdateWalletManagerResult.MissedDerivation
@ -289,10 +288,7 @@ class DefaultWalletManagersFacade(
derivationPath: String?,
extraTokens: Set<CryptoCurrency.Token>,
): UpdateWalletManagerResult {
if (derivationPath != null &&
userWallet is UserWallet.Cold &&
!userWallet.scanResponse.hasDerivation(blockchain, derivationPath)
) {
if (derivationPath != null && !userWallet.hasDerivation(blockchain, derivationPath)) {
Timber.w("Derivation missed for: $blockchain")
return UpdateWalletManagerResult.MissedDerivation
}

View file

@ -1,25 +1,31 @@
package com.tangem.domain.walletmanager.utils
package com.tangem.data.walletmanager
import com.tangem.blockchain.common.*
import com.tangem.blockchain.common.Amount
import com.tangem.blockchain.common.AmountType
import com.tangem.blockchain.common.Token
import com.tangem.blockchain.common.TransactionData
import com.tangem.blockchain.common.TransactionStatus
import com.tangem.blockchain.common.WalletManager
import com.tangem.blockchain.common.address.Address
import com.tangem.blockchainsdk.models.UpdateWalletManagerResult
import com.tangem.blockchainsdk.models.UpdateWalletManagerResult.*
import com.tangem.blockchainsdk.utils.amountToCreateAccount
import com.tangem.data.walletmanager.utils.SdkAddressToAddressConverter
import com.tangem.data.walletmanager.utils.TransactionDataToTxHistoryItemConverter
import com.tangem.domain.models.currency.CryptoCurrency
import timber.log.Timber
import java.math.BigDecimal
import com.tangem.blockchain.common.address.Address as SdkAddress
/** Factory for creating [UpdateWalletManagerResult] */
/** Factory for creating [com.tangem.blockchainsdk.models.UpdateWalletManagerResult] */
internal class UpdateWalletManagerResultFactory {
/** Get [Verified] result for [walletManager] */
fun getResult(walletManager: WalletManager): Verified {
/** Get [com.tangem.blockchainsdk.models.UpdateWalletManagerResult.Verified] result for [walletManager] */
fun getResult(walletManager: WalletManager): UpdateWalletManagerResult.Verified {
val wallet = walletManager.wallet
val addresses = getAvailableAddresses(wallet.addresses)
val feePaidCurrency = wallet.blockchain.feePaidCurrency()
val txHistoryItemConverter = TransactionDataToTxHistoryItemConverter(addresses, feePaidCurrency)
return Verified(
return UpdateWalletManagerResult.Verified(
selectedAddress = wallet.address,
addresses = addresses,
currenciesAmounts = getTokensAmounts(wallet.amounts.values.toSet()),
@ -28,18 +34,18 @@ internal class UpdateWalletManagerResultFactory {
}
/**
* Get demo [Verified] result
* Get demo [UpdateWalletManagerResult.Verified] result
*
* @param walletManager wallet manager
* @param demoAmount amount that will be used for demo result
*/
fun getDemoResult(walletManager: WalletManager, demoAmount: Amount): Verified {
fun getDemoResult(walletManager: WalletManager, demoAmount: Amount): UpdateWalletManagerResult.Verified {
val wallet = walletManager.wallet
val addresses = getAvailableAddresses(wallet.addresses)
val feePaidCurrency = wallet.blockchain.feePaidCurrency()
val txHistoryItemConverter = TransactionDataToTxHistoryItemConverter(addresses, feePaidCurrency)
return Verified(
return UpdateWalletManagerResult.Verified(
selectedAddress = wallet.address,
addresses = addresses,
currenciesAmounts = getDemoTokensAmounts(demoAmount, walletManager.cardTokens),
@ -48,8 +54,8 @@ internal class UpdateWalletManagerResultFactory {
}
/**
* Get [NoAccount] result.
* If unable to get required amount for creating account, [Unreachable] result will be returned.
* Get [UpdateWalletManagerResult.NoAccount] result.
* If unable to get required amount for creating account, [UpdateWalletManagerResult.Unreachable] result will be returned.
*
* @param walletManager wallet manager
* @param customMessage custom error message
@ -67,12 +73,12 @@ internal class UpdateWalletManagerResultFactory {
return if (amount == null) {
Timber.w("Unable to get required amount to create account for: $blockchain")
Unreachable(
UpdateWalletManagerResult.Unreachable(
selectedAddress = wallet.address,
addresses = getAvailableAddresses(wallet.addresses),
)
} else {
NoAccount(
UpdateWalletManagerResult.NoAccount(
selectedAddress = wallet.address,
addresses = getAvailableAddresses(wallet.addresses),
amountToCreateAccount = amount,
@ -81,30 +87,30 @@ internal class UpdateWalletManagerResultFactory {
}
}
/** Get [Unreachable] result for [walletManager] */
fun getUnreachableResult(walletManager: WalletManager): Unreachable {
/** Get [UpdateWalletManagerResult.Unreachable] result for [walletManager] */
fun getUnreachableResult(walletManager: WalletManager): UpdateWalletManagerResult.Unreachable {
val wallet = walletManager.wallet
return Unreachable(
return UpdateWalletManagerResult.Unreachable(
selectedAddress = wallet.address,
addresses = getAvailableAddresses(wallet.addresses),
)
}
private fun getAvailableAddresses(addresses: Set<SdkAddress>): Set<Address> {
private fun getAvailableAddresses(addresses: Set<Address>): Set<UpdateWalletManagerResult.Address> {
return SdkAddressToAddressConverter.convertList(addresses).toSet()
}
private fun getTokensAmounts(amounts: Set<Amount>): Set<CryptoCurrencyAmount> {
private fun getTokensAmounts(amounts: Set<Amount>): Set<UpdateWalletManagerResult.CryptoCurrencyAmount> {
return amounts.mapNotNullTo(hashSetOf(), ::createCurrencyAmount)
}
private fun createCurrencyAmount(amount: Amount): CryptoCurrencyAmount? {
private fun createCurrencyAmount(amount: Amount): UpdateWalletManagerResult.CryptoCurrencyAmount? {
return when (val type = amount.type) {
is AmountType.Token -> {
val value = getCurrencyAmountValue(amount) ?: return null
CryptoCurrencyAmount.Token(
UpdateWalletManagerResult.CryptoCurrencyAmount.Token(
currencyRawId = type.token.id?.let(CryptoCurrency::RawID),
contractAddress = type.token.contractAddress,
value = value,
@ -113,7 +119,7 @@ internal class UpdateWalletManagerResultFactory {
is AmountType.Coin -> {
val value = getCurrencyAmountValue(amount) ?: return null
CryptoCurrencyAmount.Coin(value = value)
UpdateWalletManagerResult.CryptoCurrencyAmount.Coin(value = value)
}
is AmountType.FeeResource,
is AmountType.Reserve,
@ -131,12 +137,17 @@ internal class UpdateWalletManagerResultFactory {
return value
}
private fun getDemoTokensAmounts(demoAmount: Amount, tokens: Set<Token>): Set<CryptoCurrencyAmount> {
private fun getDemoTokensAmounts(
demoAmount: Amount,
tokens: Set<Token>,
): Set<UpdateWalletManagerResult.CryptoCurrencyAmount> {
val amountValue = demoAmount.value ?: BigDecimal.ZERO
val demoAmounts = hashSetOf<CryptoCurrencyAmount>(CryptoCurrencyAmount.Coin(amountValue))
val demoAmounts = hashSetOf<UpdateWalletManagerResult.CryptoCurrencyAmount>(
UpdateWalletManagerResult.CryptoCurrencyAmount.Coin(amountValue),
)
return tokens.mapTo(demoAmounts) { token ->
CryptoCurrencyAmount.Token(
UpdateWalletManagerResult.CryptoCurrencyAmount.Token(
currencyRawId = token.id?.let(CryptoCurrency::RawID),
contractAddress = token.contractAddress,
value = amountValue,
@ -147,7 +158,7 @@ internal class UpdateWalletManagerResultFactory {
private fun getCurrentTransactions(
txHistoryItemConverter: TransactionDataToTxHistoryItemConverter,
recentTransactions: Set<TransactionData.Uncompiled>,
): Set<CryptoCurrencyTransaction> {
): Set<UpdateWalletManagerResult.CryptoCurrencyTransaction> {
val unconfirmedTransactions = recentTransactions.filter { it.status == TransactionStatus.Unconfirmed }
return unconfirmedTransactions.mapNotNullTo(hashSetOf()) {
@ -161,17 +172,17 @@ internal class UpdateWalletManagerResultFactory {
private fun createCurrencyTransaction(
txHistoryItemConverter: TransactionDataToTxHistoryItemConverter,
data: TransactionData.Uncompiled,
): CryptoCurrencyTransaction? {
): UpdateWalletManagerResult.CryptoCurrencyTransaction? {
return when (val type = data.amount.type) {
is AmountType.Coin -> {
val txHistoryItem = txHistoryItemConverter.convert(data) ?: return null
CryptoCurrencyTransaction.Coin(txInfo = txHistoryItem)
UpdateWalletManagerResult.CryptoCurrencyTransaction.Coin(txInfo = txHistoryItem)
}
is AmountType.Token -> {
val txHistoryItem = txHistoryItemConverter.convert(data) ?: return null
CryptoCurrencyTransaction.Token(
UpdateWalletManagerResult.CryptoCurrencyTransaction.Token(
tokenId = type.token.id,
contractAddress = type.token.contractAddress,
txInfo = txHistoryItem,

View file

@ -1,14 +1,14 @@
package com.tangem.domain.walletmanager.utils
package com.tangem.data.walletmanager
import com.tangem.blockchain.common.Blockchain
import com.tangem.blockchain.common.DerivationParams
import com.tangem.blockchain.common.WalletManager
import com.tangem.blockchainsdk.BlockchainSDKFactory
import com.tangem.crypto.hdWallet.DerivationPath
import com.tangem.domain.common.DerivationStyleProvider
import com.tangem.domain.common.extensions.makePublicKey
import com.tangem.domain.common.extensions.makeWalletManagerForApp
import com.tangem.domain.common.util.derivationStyleProvider
import com.tangem.data.walletmanager.extensions.makePublicKey
import com.tangem.data.walletmanager.extensions.makeWalletManagerForApp
import com.tangem.domain.card.DerivationStyleProvider
import com.tangem.domain.card.common.util.derivationStyleProvider
import com.tangem.domain.models.scan.ScanResponse
import com.tangem.domain.models.wallet.UserWallet
import timber.log.Timber

View file

@ -0,0 +1,18 @@
package com.tangem.data.walletmanager.di
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
import com.tangem.data.walletmanager.DefaultWalletManagersFacade
import com.tangem.domain.walletmanager.WalletManagersFacade
@Module
@InstallIn(SingletonComponent::class)
internal interface WalletManagerModule {
@Binds
@Singleton
fun bindWalletManagerFacade(impl: DefaultWalletManagersFacade): WalletManagersFacade
}

View file

@ -1,4 +1,4 @@
package com.tangem.domain.common.extensions
package com.tangem.data.walletmanager.extensions
import com.tangem.blockchain.blockchains.cardano.CardanoUtils
import com.tangem.blockchain.common.*
@ -8,11 +8,11 @@ import com.tangem.common.extensions.hexToBytes
import com.tangem.common.extensions.toMapKey
import com.tangem.crypto.hdWallet.DerivationPath
import com.tangem.crypto.hdWallet.bip32.ExtendedPublicKey
import com.tangem.domain.common.TapWorkarounds.isTestCard
import com.tangem.domain.common.TapWorkarounds.useOldStyleDerivation
import com.tangem.domain.common.configs.CardConfig
import com.tangem.domain.common.configs.Wallet2CardConfig
import com.tangem.domain.common.util.cardTypesResolver
import com.tangem.domain.card.common.TapWorkarounds.isTestCard
import com.tangem.domain.card.common.TapWorkarounds.useOldStyleDerivation
import com.tangem.domain.card.common.util.cardTypesResolver
import com.tangem.domain.card.configs.CardConfig
import com.tangem.domain.card.configs.Wallet2CardConfig
import com.tangem.domain.models.scan.CardDTO
import com.tangem.domain.models.scan.ScanResponse

View file

@ -1,4 +1,4 @@
package com.tangem.domain.walletmanager.utils
package com.tangem.data.walletmanager.utils
import com.tangem.blockchain.common.CryptoCurrencyType
import com.tangem.blockchain.common.Token

View file

@ -1,4 +1,4 @@
package com.tangem.domain.walletmanager.utils
package com.tangem.data.walletmanager.utils
import com.tangem.blockchain.common.address.AddressType
import com.tangem.blockchainsdk.models.UpdateWalletManagerResult.Address

View file

@ -1,4 +1,4 @@
package com.tangem.domain.walletmanager.utils
package com.tangem.data.walletmanager.utils
import com.tangem.domain.transaction.models.AssetRequirementsCondition
import com.tangem.utils.converter.Converter

View file

@ -1,4 +1,4 @@
package com.tangem.domain.walletmanager.utils
package com.tangem.data.walletmanager.utils
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.utils.converter.Converter

View file

@ -1,4 +1,4 @@
package com.tangem.domain.walletmanager.utils
package com.tangem.data.walletmanager.utils
import com.tangem.blockchain.transactionhistory.models.TransactionHistoryItem
import com.tangem.domain.models.network.TxInfo

View file

@ -1,4 +1,4 @@
package com.tangem.domain.walletmanager.utils
package com.tangem.data.walletmanager.utils
import com.tangem.blockchain.transactionhistory.TransactionHistoryState
import com.tangem.domain.txhistory.models.TxHistoryState

View file

@ -1,4 +1,4 @@
package com.tangem.domain.walletmanager.utils
package com.tangem.data.walletmanager.utils
import com.tangem.blockchain.transactionhistory.models.TransactionHistoryItem.TransactionType
import com.tangem.domain.models.network.TxInfo

View file

@ -1,4 +1,4 @@
package com.tangem.domain.walletmanager.utils
package com.tangem.data.walletmanager.utils
import com.tangem.blockchain.common.*
import com.tangem.blockchainsdk.models.UpdateWalletManagerResult.Address

View file

@ -1,12 +1,17 @@
package com.tangem.domain.walletmanager.utils
package com.tangem.data.walletmanager
import com.google.common.truth.Truth
import com.tangem.blockchain.common.*
import com.tangem.blockchain.common.Amount
import com.tangem.blockchain.common.AmountType
import com.tangem.blockchain.common.Blockchain
import com.tangem.blockchain.common.Token
import com.tangem.blockchain.common.TransactionData
import com.tangem.blockchain.common.TransactionStatus
import com.tangem.blockchain.common.Wallet
import com.tangem.blockchain.common.WalletManager
import com.tangem.blockchain.common.address.Address
import com.tangem.blockchain.common.address.AddressType
import com.tangem.blockchainsdk.models.UpdateWalletManagerResult
import com.tangem.blockchainsdk.models.UpdateWalletManagerResult.*
import com.tangem.blockchainsdk.models.UpdateWalletManagerResult.Address.Type
import com.tangem.common.test.domain.walletmanager.MockUpdateWalletManagerResultFactory
import com.tangem.common.test.utils.ProvideTestModels
import com.tangem.domain.models.currency.CryptoCurrency
@ -62,9 +67,14 @@ internal class UpdateWalletManagerResultFactoryTest {
addresses = setOf(Address(value = "0x1", type = AddressType.Default)),
transactions = emptyList(),
),
expected = Verified(
expected = UpdateWalletManagerResult.Verified(
selectedAddress = "0x1",
addresses = setOf(Address(value = "0x1", type = Type.Primary)),
addresses = setOf(
UpdateWalletManagerResult.Address(
value = "0x1",
type = UpdateWalletManagerResult.Address.Type.Primary,
),
),
currenciesAmounts = emptySet(),
currentTransactions = emptySet(),
),
@ -80,10 +90,17 @@ internal class UpdateWalletManagerResultFactoryTest {
),
transactions = emptyList(),
),
expected = Verified(
expected = UpdateWalletManagerResult.Verified(
selectedAddress = "0x1",
addresses = setOf(Address(value = "0x1", type = Type.Primary)),
currenciesAmounts = setOf(CryptoCurrencyAmount.Coin(value = BigDecimal.ONE)),
addresses = setOf(
UpdateWalletManagerResult.Address(
value = "0x1",
type = UpdateWalletManagerResult.Address.Type.Primary,
),
),
currenciesAmounts = setOf(
UpdateWalletManagerResult.CryptoCurrencyAmount.Coin(value = BigDecimal.ONE),
),
currentTransactions = emptySet(),
),
),
@ -106,12 +123,19 @@ internal class UpdateWalletManagerResultFactoryTest {
),
),
),
expected = Verified(
expected = UpdateWalletManagerResult.Verified(
selectedAddress = "0x1",
addresses = setOf(Address(value = "0x1", type = Type.Primary)),
currenciesAmounts = setOf(CryptoCurrencyAmount.Coin(value = BigDecimal.ONE)),
addresses = setOf(
UpdateWalletManagerResult.Address(
value = "0x1",
type = UpdateWalletManagerResult.Address.Type.Primary,
),
),
currenciesAmounts = setOf(
UpdateWalletManagerResult.CryptoCurrencyAmount.Coin(value = BigDecimal.ONE),
),
currentTransactions = setOf(
CryptoCurrencyTransaction.Coin(
UpdateWalletManagerResult.CryptoCurrencyTransaction.Coin(
txInfo = createTxInfo(
status = TxInfo.TransactionStatus.Unconfirmed,
amount = BigDecimal.ONE,
@ -150,22 +174,28 @@ internal class UpdateWalletManagerResultFactoryTest {
),
),
),
expected = Verified(
expected = UpdateWalletManagerResult.Verified(
selectedAddress = "0x1",
addresses = setOf(
Address(value = "0x1", type = Type.Primary),
Address(value = "0x11", type = Type.Secondary),
UpdateWalletManagerResult.Address(
value = "0x1",
type = UpdateWalletManagerResult.Address.Type.Primary,
),
UpdateWalletManagerResult.Address(
value = "0x11",
type = UpdateWalletManagerResult.Address.Type.Secondary,
),
),
currenciesAmounts = setOf(
CryptoCurrencyAmount.Coin(value = BigDecimal.ONE),
CryptoCurrencyAmount.Token(
UpdateWalletManagerResult.CryptoCurrencyAmount.Coin(value = BigDecimal.ONE),
UpdateWalletManagerResult.CryptoCurrencyAmount.Token(
value = BigDecimal.ZERO,
currencyRawId = usdtToken.id?.let(CryptoCurrency::RawID),
contractAddress = usdtToken.contractAddress,
),
),
currentTransactions = setOf(
CryptoCurrencyTransaction.Token(
UpdateWalletManagerResult.CryptoCurrencyTransaction.Token(
txInfo = createTxInfo(
status = TxInfo.TransactionStatus.Unconfirmed,
amount = BigDecimal.TEN,
@ -180,7 +210,7 @@ internal class UpdateWalletManagerResultFactoryTest {
)
}
data class GetResultTestModel(val wallet: Wallet, val expected: Verified)
data class GetResultTestModel(val wallet: Wallet, val expected: UpdateWalletManagerResult.Verified)
@Nested
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@ -211,13 +241,16 @@ internal class UpdateWalletManagerResultFactoryTest {
),
demoAmount = Amount(value = null, blockchain = Blockchain.Ethereum),
cardTokens = emptySet(),
expected = Verified(
expected = UpdateWalletManagerResult.Verified(
selectedAddress = "0x1",
addresses = setOf(
Address(value = "0x1", type = Type.Primary),
UpdateWalletManagerResult.Address(
value = "0x1",
type = UpdateWalletManagerResult.Address.Type.Primary,
),
),
currenciesAmounts = setOf(
CryptoCurrencyAmount.Coin(value = BigDecimal.ZERO), // default for demo
UpdateWalletManagerResult.CryptoCurrencyAmount.Coin(value = BigDecimal.ZERO), // default for demo
),
currentTransactions = emptySet(),
),
@ -230,13 +263,16 @@ internal class UpdateWalletManagerResultFactoryTest {
),
demoAmount = Amount(value = BigDecimal.ONE, blockchain = Blockchain.Ethereum),
cardTokens = emptySet(),
expected = Verified(
expected = UpdateWalletManagerResult.Verified(
selectedAddress = "0x1",
addresses = setOf(
Address(value = "0x1", type = Type.Primary),
UpdateWalletManagerResult.Address(
value = "0x1",
type = UpdateWalletManagerResult.Address.Type.Primary,
),
),
currenciesAmounts = setOf(
CryptoCurrencyAmount.Coin(value = BigDecimal.ONE), // used demo amount
UpdateWalletManagerResult.CryptoCurrencyAmount.Coin(value = BigDecimal.ONE), // used demo amount
),
currentTransactions = emptySet(),
),
@ -254,15 +290,17 @@ internal class UpdateWalletManagerResultFactoryTest {
),
demoAmount = Amount(value = null, blockchain = Blockchain.Ethereum),
cardTokens = emptySet(),
expected = Verified(
expected = UpdateWalletManagerResult.Verified(
selectedAddress = "0x1",
addresses = setOf(
Address(
UpdateWalletManagerResult.Address(
value = "0x1",
type = Type.Primary,
type = UpdateWalletManagerResult.Address.Type.Primary,
),
),
currenciesAmounts = setOf(CryptoCurrencyAmount.Coin(value = BigDecimal.ZERO)),
currenciesAmounts = setOf(
UpdateWalletManagerResult.CryptoCurrencyAmount.Coin(value = BigDecimal.ZERO),
),
currentTransactions = emptySet(),
),
),
@ -276,15 +314,17 @@ internal class UpdateWalletManagerResultFactoryTest {
),
demoAmount = Amount(value = BigDecimal.TEN, blockchain = Blockchain.Ethereum),
cardTokens = emptySet(),
expected = Verified(
expected = UpdateWalletManagerResult.Verified(
selectedAddress = "0x1",
addresses = setOf(
Address(
UpdateWalletManagerResult.Address(
value = "0x1",
type = Type.Primary,
type = UpdateWalletManagerResult.Address.Type.Primary,
),
),
currenciesAmounts = setOf(CryptoCurrencyAmount.Coin(value = BigDecimal.TEN)),
currenciesAmounts = setOf(
UpdateWalletManagerResult.CryptoCurrencyAmount.Coin(value = BigDecimal.TEN),
),
currentTransactions = emptySet(),
),
),
@ -309,14 +349,19 @@ internal class UpdateWalletManagerResultFactoryTest {
),
demoAmount = Amount(value = BigDecimal.TEN, blockchain = Blockchain.Ethereum),
cardTokens = emptySet(),
expected = Verified(
expected = UpdateWalletManagerResult.Verified(
selectedAddress = "0x1",
addresses = setOf(
Address(value = "0x1", type = Type.Primary),
UpdateWalletManagerResult.Address(
value = "0x1",
type = UpdateWalletManagerResult.Address.Type.Primary,
),
),
currenciesAmounts = setOf(
UpdateWalletManagerResult.CryptoCurrencyAmount.Coin(value = BigDecimal.TEN),
),
currenciesAmounts = setOf(CryptoCurrencyAmount.Coin(value = BigDecimal.TEN)),
currentTransactions = setOf(
CryptoCurrencyTransaction.Coin(
UpdateWalletManagerResult.CryptoCurrencyTransaction.Coin(
txInfo = createTxInfo(
status = TxInfo.TransactionStatus.Unconfirmed,
amount = BigDecimal.ONE,
@ -357,22 +402,28 @@ internal class UpdateWalletManagerResultFactoryTest {
),
demoAmount = Amount(value = null, blockchain = Blockchain.Ethereum),
cardTokens = setOf(usdtToken),
expected = Verified(
expected = UpdateWalletManagerResult.Verified(
selectedAddress = "0x1",
addresses = setOf(
Address(value = "0x1", type = Type.Primary),
Address(value = "0x11", type = Type.Secondary),
UpdateWalletManagerResult.Address(
value = "0x1",
type = UpdateWalletManagerResult.Address.Type.Primary,
),
UpdateWalletManagerResult.Address(
value = "0x11",
type = UpdateWalletManagerResult.Address.Type.Secondary,
),
),
currenciesAmounts = setOf(
CryptoCurrencyAmount.Coin(value = BigDecimal.ZERO),
CryptoCurrencyAmount.Token(
UpdateWalletManagerResult.CryptoCurrencyAmount.Coin(value = BigDecimal.ZERO),
UpdateWalletManagerResult.CryptoCurrencyAmount.Token(
value = BigDecimal.ZERO,
currencyRawId = usdtToken.id?.let(CryptoCurrency::RawID),
contractAddress = usdtToken.contractAddress,
),
),
currentTransactions = setOf(
CryptoCurrencyTransaction.Token(
UpdateWalletManagerResult.CryptoCurrencyTransaction.Token(
txInfo = createTxInfo(
status = TxInfo.TransactionStatus.Unconfirmed,
amount = BigDecimal.TEN,
@ -412,22 +463,28 @@ internal class UpdateWalletManagerResultFactoryTest {
),
demoAmount = Amount(value = BigDecimal.TEN, blockchain = Blockchain.Ethereum),
cardTokens = setOf(usdtToken),
expected = Verified(
expected = UpdateWalletManagerResult.Verified(
selectedAddress = "0x1",
addresses = setOf(
Address(value = "0x1", type = Type.Primary),
Address(value = "0x11", type = Type.Secondary),
UpdateWalletManagerResult.Address(
value = "0x1",
type = UpdateWalletManagerResult.Address.Type.Primary,
),
UpdateWalletManagerResult.Address(
value = "0x11",
type = UpdateWalletManagerResult.Address.Type.Secondary,
),
),
currenciesAmounts = setOf(
CryptoCurrencyAmount.Coin(value = BigDecimal.TEN),
CryptoCurrencyAmount.Token(
UpdateWalletManagerResult.CryptoCurrencyAmount.Coin(value = BigDecimal.TEN),
UpdateWalletManagerResult.CryptoCurrencyAmount.Token(
value = BigDecimal.TEN,
currencyRawId = usdtToken.id?.let(CryptoCurrency::RawID),
contractAddress = usdtToken.contractAddress,
),
),
currentTransactions = setOf(
CryptoCurrencyTransaction.Token(
UpdateWalletManagerResult.CryptoCurrencyTransaction.Token(
txInfo = createTxInfo(
status = TxInfo.TransactionStatus.Unconfirmed,
amount = BigDecimal.TEN,
@ -435,7 +492,7 @@ internal class UpdateWalletManagerResultFactoryTest {
tokenId = "0x3",
contractAddress = "0x4",
),
CryptoCurrencyTransaction.Coin(
UpdateWalletManagerResult.CryptoCurrencyTransaction.Coin(
txInfo = createTxInfo(
status = TxInfo.TransactionStatus.Unconfirmed,
amount = BigDecimal.ONE,
@ -453,7 +510,7 @@ internal class UpdateWalletManagerResultFactoryTest {
val wallet: Wallet,
val demoAmount: Amount,
val cardTokens: Set<Token>,
val expected: Verified,
val expected: UpdateWalletManagerResult.Verified,
)
@Nested
@ -487,9 +544,14 @@ internal class UpdateWalletManagerResultFactoryTest {
),
customMessage = "",
amountToCreateAccount = null,
expected = Unreachable(
expected = UpdateWalletManagerResult.Unreachable(
selectedAddress = "0x1",
addresses = setOf(Address(value = "0x1", type = Type.Primary)),
addresses = setOf(
UpdateWalletManagerResult.Address(
value = "0x1",
type = UpdateWalletManagerResult.Address.Type.Primary,
),
),
),
),
// endregion
@ -518,9 +580,14 @@ internal class UpdateWalletManagerResultFactoryTest {
),
customMessage = "custom message",
amountToCreateAccount = BigDecimal.ONE,
expected = NoAccount(
expected = UpdateWalletManagerResult.NoAccount(
selectedAddress = "0x1",
addresses = setOf(Address(value = "0x1", type = Type.Primary)),
addresses = setOf(
UpdateWalletManagerResult.Address(
value = "0x1",
type = UpdateWalletManagerResult.Address.Type.Primary,
),
),
amountToCreateAccount = BigDecimal.ONE,
errorMessage = "custom message",
),
@ -546,9 +613,14 @@ internal class UpdateWalletManagerResultFactoryTest {
),
customMessage = "",
amountToCreateAccount = BigDecimal.ZERO,
expected = NoAccount(
expected = UpdateWalletManagerResult.NoAccount(
selectedAddress = "0x1",
addresses = setOf(Address(value = "0x1", type = Type.Primary)),
addresses = setOf(
UpdateWalletManagerResult.Address(
value = "0x1",
type = UpdateWalletManagerResult.Address.Type.Primary,
),
),
amountToCreateAccount = BigDecimal.ZERO,
errorMessage = "",
),
@ -585,11 +657,17 @@ internal class UpdateWalletManagerResultFactoryTest {
),
customMessage = "",
amountToCreateAccount = BigDecimal.ZERO,
expected = NoAccount(
expected = UpdateWalletManagerResult.NoAccount(
selectedAddress = "0x1",
addresses = setOf(
Address(value = "0x1", type = Type.Primary),
Address(value = "0x11", type = Type.Secondary),
UpdateWalletManagerResult.Address(
value = "0x1",
type = UpdateWalletManagerResult.Address.Type.Primary,
),
UpdateWalletManagerResult.Address(
value = "0x11",
type = UpdateWalletManagerResult.Address.Type.Secondary,
),
),
amountToCreateAccount = BigDecimal.ZERO,
errorMessage = "",
@ -631,9 +709,14 @@ internal class UpdateWalletManagerResultFactoryTest {
addresses = setOf(Address(value = "0x1", type = AddressType.Default)),
transactions = emptyList(),
),
expected = Unreachable(
expected = UpdateWalletManagerResult.Unreachable(
selectedAddress = "0x1",
addresses = setOf(Address(value = "0x1", type = Type.Primary)),
addresses = setOf(
UpdateWalletManagerResult.Address(
value = "0x1",
type = UpdateWalletManagerResult.Address.Type.Primary,
),
),
),
),
// endregion
@ -647,9 +730,14 @@ internal class UpdateWalletManagerResultFactoryTest {
),
transactions = emptyList(),
),
expected = Unreachable(
expected = UpdateWalletManagerResult.Unreachable(
selectedAddress = "0x1",
addresses = setOf(Address(value = "0x1", type = Type.Primary)),
addresses = setOf(
UpdateWalletManagerResult.Address(
value = "0x1",
type = UpdateWalletManagerResult.Address.Type.Primary,
),
),
),
),
// endregion
@ -671,9 +759,14 @@ internal class UpdateWalletManagerResultFactoryTest {
),
),
),
expected = Unreachable(
expected = UpdateWalletManagerResult.Unreachable(
selectedAddress = "0x1",
addresses = setOf(Address(value = "0x1", type = Type.Primary)),
addresses = setOf(
UpdateWalletManagerResult.Address(
value = "0x1",
type = UpdateWalletManagerResult.Address.Type.Primary,
),
),
),
),
// endregion
@ -706,11 +799,17 @@ internal class UpdateWalletManagerResultFactoryTest {
),
),
),
expected = Unreachable(
expected = UpdateWalletManagerResult.Unreachable(
selectedAddress = "0x1",
addresses = setOf(
Address(value = "0x1", type = Type.Primary),
Address(value = "0x11", type = Type.Secondary),
UpdateWalletManagerResult.Address(
value = "0x1",
type = UpdateWalletManagerResult.Address.Type.Primary,
),
UpdateWalletManagerResult.Address(
value = "0x11",
type = UpdateWalletManagerResult.Address.Type.Secondary,
),
),
),
),

View file

@ -10,19 +10,30 @@ android {
dependencies {
implementation(projects.core.analytics.models)
implementation(projects.core.error)
implementation(projects.core.error.ext)
implementation(projects.domain.demo)
implementation(projects.domain.core)
implementation(projects.domain.legacy)
implementation(projects.domain.walletManager) // TODO refactor to use from data module
implementation(projects.libs.blockchainSdk)
// TODO: Remove after new card scan result was implemented
implementation(projects.domain.models)
implementation(projects.domain.tokens.models)
implementation(projects.domain.wallets.models)
implementation(deps.timber)
implementation(tangemDeps.card.core)
implementation(tangemDeps.blockchain) {
exclude(module = "joda-time")
}
/** Testing libraries */
testImplementation(deps.test.junit5)
testRuntimeOnly(deps.test.junit5.engine)
testImplementation(deps.test.mockk)
testImplementation(deps.test.truth)
testImplementation(projects.common.test)
}

View file

@ -1,4 +1,4 @@
package com.tangem.domain.common
package com.tangem.domain.card
import com.tangem.blockchain.common.Blockchain
import com.tangem.blockchain.common.Token

View file

@ -1,7 +1,7 @@
package com.tangem.domain.common
package com.tangem.domain.card
import com.tangem.blockchain.common.derivation.DerivationStyle
import com.tangem.domain.common.TapWorkarounds.isWallet2
import com.tangem.domain.card.common.TapWorkarounds.isWallet2
import com.tangem.domain.models.scan.CardDTO
interface DerivationStyleProvider {
@ -25,6 +25,7 @@ internal class TangemDerivationStyleProvider(
}
}
// TODO remove this class [REDACTED_TASK_KEY]
internal class TangemHotDerivationStyleProvider : DerivationStyleProvider {
override fun getDerivationStyle(): DerivationStyle? = DerivationStyle.V3
}

View file

@ -1,21 +0,0 @@
package com.tangem.domain.card
import arrow.core.Either
import com.tangem.blockchainsdk.utils.toBlockchain
import com.tangem.domain.common.util.hasDerivation
import com.tangem.domain.models.network.Network
import com.tangem.domain.models.wallet.UserWallet
class NetworkHasDerivationUseCase {
operator fun invoke(userWallet: UserWallet, network: Network): Either<Throwable, Boolean> = Either.catch {
when (userWallet) {
is UserWallet.Cold -> {
val blockchain = network.toBlockchain()
val derivationPath = network.derivationPath.value
derivationPath != null && userWallet.scanResponse.hasDerivation(blockchain, derivationPath)
}
is UserWallet.Hot -> true
}
}
}

View file

@ -1,15 +1,16 @@
package com.tangem.domain.common
package com.tangem.domain.card
import com.tangem.blockchain.common.Blockchain
import com.tangem.blockchain.common.Token
import com.tangem.common.card.EllipticCurve
import com.tangem.common.card.FirmwareVersion
import com.tangem.common.card.WalletData
import com.tangem.domain.common.TapWorkarounds.getTangemNoteBlockchain
import com.tangem.domain.common.TapWorkarounds.isStart2Coin
import com.tangem.domain.common.TapWorkarounds.isTestCard
import com.tangem.domain.common.TapWorkarounds.isWallet2
import com.tangem.domain.common.visa.VisaUtilities
import com.tangem.domain.card.common.TapWorkarounds.getTangemNoteBlockchain
import com.tangem.domain.card.common.TapWorkarounds.isStart2Coin
import com.tangem.domain.card.common.TapWorkarounds.isTestCard
import com.tangem.domain.card.common.TapWorkarounds.isWallet2
import com.tangem.domain.card.common.getTwinCardIdForUser
import com.tangem.domain.card.common.visa.VisaUtilities
import com.tangem.domain.models.scan.CardDTO
import com.tangem.domain.models.scan.ProductType
import com.tangem.operations.attestation.Attestation
@ -25,15 +26,15 @@ internal class TangemCardTypesResolver(
override fun isTangemWallet(): Boolean {
return card.settings.isBackupAllowed && card.settings.isHDWalletAllowed &&
card.firmwareVersion >= FirmwareVersion.MultiWalletAvailable
card.firmwareVersion >= FirmwareVersion.Companion.MultiWalletAvailable
}
override fun isShibaWallet(): Boolean {
return card.firmwareVersion.compareTo(FirmwareVersion.KeysImportAvailable) == 0
return card.firmwareVersion.compareTo(FirmwareVersion.Companion.KeysImportAvailable) == 0
}
override fun isWhiteWallet(): Boolean {
return walletData == null && card.firmwareVersion <= FirmwareVersion.HDWalletAvailable
return walletData == null && card.firmwareVersion <= FirmwareVersion.Companion.HDWalletAvailable
}
override fun isWallet2(): Boolean = card.isWallet2
@ -62,7 +63,7 @@ internal class TangemCardTypesResolver(
(multiWalletAvailable() || card.wallets.firstOrNull()?.curve == EllipticCurve.Secp256k1)
}
private fun multiWalletAvailable() = card.firmwareVersion >= FirmwareVersion.MultiWalletAvailable
private fun multiWalletAvailable() = card.firmwareVersion >= FirmwareVersion.Companion.MultiWalletAvailable
override fun getBlockchain(): Blockchain {
return when (productType) {
@ -75,7 +76,7 @@ internal class TangemCardTypesResolver(
} else {
return Blockchain.Unknown
}
Blockchain.fromBlockchainName(blockchainName)
Blockchain.Companion.fromBlockchainName(blockchainName)
}
}
}
@ -126,7 +127,7 @@ internal class TangemCardTypesResolver(
Blockchain.Cardano
}
else -> {
Blockchain.fromId(blockchainName)
fromId(blockchainName)
}
}
}

View file

@ -1,9 +1,9 @@
package com.tangem.domain.common
package com.tangem.domain.card.common
import com.tangem.blockchain.common.Blockchain
import com.tangem.common.card.FirmwareVersion
import com.tangem.domain.common.visa.VisaUtilities
import com.tangem.domain.demo.DemoConfig
import com.tangem.domain.card.common.visa.VisaUtilities
import com.tangem.domain.demo.models.DemoConfig
import com.tangem.domain.models.scan.CardDTO
import java.util.Locale

View file

@ -0,0 +1,90 @@
package com.tangem.domain.card.common
import com.tangem.crypto.CryptoUtils
import com.tangem.domain.models.scan.CardDTO
object TwinsHelper {
/**
* Card compatibility
* cb61 <-> cb62
* cb64 <-> cb65
*
*/
private const val FIRST_CARD_FIRST_SERIES = "CB61"
private const val SECOND_CARD_FIRST_SERIES = "CB62"
private const val FIRST_CARD_SECOND_SERIES = "CB64"
private const val SECOND_CARD_SECOND_SERIES = "CB65"
@Suppress("MagicNumber")
fun verifyTwinPublicKey(issuerData: ByteArray, cardWalletPublicKey: ByteArray?): Boolean {
if (issuerData.size < 65 || cardWalletPublicKey == null) return false
val publicKey = issuerData.sliceArray(0 until 65)
val signedKey = issuerData.sliceArray(65 until issuerData.size)
return CryptoUtils.verify(cardWalletPublicKey, publicKey, signedKey)
}
fun getTwinCardNumber(cardId: String): TwinCardNumber? {
val isFirstCard = cardId.startsWith(FIRST_CARD_FIRST_SERIES) ||
cardId.startsWith(FIRST_CARD_SECOND_SERIES)
if (isFirstCard) return TwinCardNumber.First
val isSecondCard = cardId.startsWith(SECOND_CARD_FIRST_SERIES) ||
cardId.startsWith(SECOND_CARD_SECOND_SERIES)
if (isSecondCard) return TwinCardNumber.Second
return null
}
@Suppress("MagicNumber")
fun getTwinCardIdForUser(cardId: String): String {
if (cardId.length < 16) return cardId
val twinCardId = cardId.substring(11..14)
val twinCardNumber = getTwinCardNumber(cardId)?.number ?: 1
return "$twinCardId #$twinCardNumber"
}
/**
* Twins compatibility
* cb61 <-> cb62
* cb64 <-> cb65
*/
fun isTwinsCompatible(firstCardId: String, secondCardId: String): Boolean {
return secondCardId.startsWith(getCompatibleTwinCardId(firstCardId))
}
private fun getCompatibleTwinCardId(cardId: String): String {
return when {
cardId.startsWith(FIRST_CARD_FIRST_SERIES) -> SECOND_CARD_FIRST_SERIES
cardId.startsWith(FIRST_CARD_SECOND_SERIES) -> SECOND_CARD_SECOND_SERIES
cardId.startsWith(SECOND_CARD_FIRST_SERIES) -> FIRST_CARD_FIRST_SERIES
cardId.startsWith(SECOND_CARD_SECOND_SERIES) -> FIRST_CARD_SECOND_SERIES
else -> {
"unknown"
}
}
}
}
enum class TwinCardNumber(val number: Int) {
First(1), Second(2);
fun pairNumber(): TwinCardNumber = when (this) {
First -> Second
Second -> First
}
}
@Deprecated("Use ScanResponse.isTangemTwin")
fun CardDTO.isTangemTwin(): Boolean {
return TwinsHelper.getTwinCardNumber(cardId) != null
}
fun CardDTO.getTwinCardNumber(): TwinCardNumber? {
return TwinsHelper.getTwinCardNumber(this.cardId)
}
fun CardDTO.getTwinCardIdForUser(): String {
return TwinsHelper.getTwinCardIdForUser(this.cardId)
}

View file

@ -1,17 +1,17 @@
package com.tangem.domain.common.extensions
package com.tangem.domain.card.common.extensions
import com.tangem.blockchain.common.Blockchain
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
import com.tangem.common.card.EllipticCurve
import com.tangem.common.card.FirmwareVersion
import com.tangem.domain.common.CardTypesResolver
import com.tangem.domain.common.TapWorkarounds.isTestCard
import com.tangem.domain.common.configs.CardConfig
import com.tangem.domain.common.util.cardTypesResolver
import com.tangem.domain.card.common.util.cardTypesResolver
import com.tangem.domain.card.CardTypesResolver
import com.tangem.domain.card.common.TapWorkarounds.isTestCard
import com.tangem.domain.card.configs.CardConfig
import com.tangem.domain.models.scan.CardDTO
import com.tangem.domain.models.wallet.UserWallet
// TODO: refactor [REDACTED_JIRA]
// TODO: refactor [REDACTED_JIRA]\
/**
[REDACTED_AUTHOR]
@ -28,7 +28,7 @@ fun UserWallet.supportedBlockchains(excludedBlockchains: ExcludedBlockchains): L
)
}
is UserWallet.Hot -> {
Blockchain.entries.filter { it !in excludedBlockchains }
Blockchain.entries.filter { it.isTestnet().not() && it !in excludedBlockchains }
}
}
}
@ -94,7 +94,9 @@ fun UserWallet.canHandleToken(blockchain: Blockchain, excludedBlockchains: Exclu
)
}
is UserWallet.Hot -> blockchain !in excludedBlockchains
is UserWallet.Hot -> blockchain.isTestnet().not() &&
blockchain !in excludedBlockchains &&
blockchain.canHandleTokens()
}
}

View file

@ -1,14 +1,19 @@
package com.tangem.domain.common.util
package com.tangem.domain.card.common.util
import com.tangem.blockchain.blockchains.cardano.CardanoUtils
import com.tangem.blockchain.common.Blockchain
import com.tangem.common.card.EllipticCurve
import com.tangem.common.extensions.toMapKey
import com.tangem.crypto.hdWallet.DerivationPath
import com.tangem.domain.common.*
import com.tangem.domain.common.TapWorkarounds.isTangemTwins
import com.tangem.domain.common.TapWorkarounds.isTestCard
import com.tangem.domain.common.configs.CardConfig
import com.tangem.domain.common.configs.Wallet2CardConfig
import com.tangem.domain.card.CardTypesResolver
import com.tangem.domain.card.DerivationStyleProvider
import com.tangem.domain.card.TangemCardTypesResolver
import com.tangem.domain.card.TangemDerivationStyleProvider
import com.tangem.domain.card.TangemHotDerivationStyleProvider
import com.tangem.domain.card.common.TapWorkarounds.isTangemTwins
import com.tangem.domain.card.common.TapWorkarounds.isTestCard
import com.tangem.domain.card.configs.CardConfig
import com.tangem.domain.card.configs.Wallet2CardConfig
import com.tangem.domain.models.scan.CardDTO
import com.tangem.domain.models.scan.ScanResponse
import com.tangem.domain.models.wallet.UserWallet
@ -47,27 +52,36 @@ private fun ScanResponse.hasDerivation(blockchain: Blockchain, derivationPath: D
return if (config is Wallet2CardConfig) {
// new logic for wallet2
val primaryCurve = config.primaryCurve(blockchain)
primaryCurve?.let { hasDerivation(it, derivationPath) } == true
primaryCurve?.let { hasDerivation(blockchain, it, derivationPath) } == true
} else {
// leave logic for legacy wallets
when {
Blockchain.secp256k1Blockchains(isTestnet).contains(blockchain) -> {
hasDerivation(EllipticCurve.Secp256k1, derivationPath)
hasDerivation(blockchain, EllipticCurve.Secp256k1, derivationPath)
}
Blockchain.ed25519Blockchains(isTestnet).contains(blockchain) -> {
hasDerivation(EllipticCurve.Ed25519, derivationPath)
hasDerivation(blockchain, EllipticCurve.Ed25519, derivationPath)
}
else -> false
}
}
}
private fun ScanResponse.hasDerivation(curve: EllipticCurve, derivationPath: DerivationPath): Boolean {
private fun ScanResponse.hasDerivation(
blockchain: Blockchain,
curve: EllipticCurve,
derivationPath: DerivationPath,
): Boolean {
val foundWallet = card.wallets.firstOrNull { it.curve == curve }
?: return false
val extendedPublicKeysMap = derivedKeys[foundWallet.publicKey.toMapKey()] ?: return false
val extendedPublicKey = extendedPublicKeysMap[derivationPath]
return extendedPublicKey != null
return if (blockchain == Blockchain.Cardano) {
// Cardano uses extended derivation path
extendedPublicKey != null && extendedPublicKeysMap[CardanoUtils.extendedDerivationPath(derivationPath)] != null
} else {
extendedPublicKey != null
}
}
/**

Some files were not shown because too many files have changed in this diff Show more