Updated on 2026-08-14
This commit is contained in:
parent
207da4af08
commit
7aef4046c3
31 changed files with 238 additions and 91 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
package com.tangem.tap.di
|
package com.tangem.tap.di
|
||||||
|
|
||||||
|
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||||
import com.tangem.datasource.exchangeservice.swap.SwapServiceLoader
|
import com.tangem.datasource.exchangeservice.swap.SwapServiceLoader
|
||||||
import com.tangem.domain.card.ScanCardUseCase
|
import com.tangem.domain.card.ScanCardUseCase
|
||||||
import com.tangem.domain.card.repository.CardSdkConfigRepository
|
import com.tangem.domain.card.repository.CardSdkConfigRepository
|
||||||
|
|
@ -49,6 +50,7 @@ internal object ActivityModule {
|
||||||
swapServiceLoader: SwapServiceLoader,
|
swapServiceLoader: SwapServiceLoader,
|
||||||
currenciesRepository: CurrenciesRepository,
|
currenciesRepository: CurrenciesRepository,
|
||||||
getNetworkCoinStatusUseCase: GetNetworkCoinStatusUseCase,
|
getNetworkCoinStatusUseCase: GetNetworkCoinStatusUseCase,
|
||||||
|
excludedBlockchains: ExcludedBlockchains,
|
||||||
dispatchers: CoroutineDispatcherProvider,
|
dispatchers: CoroutineDispatcherProvider,
|
||||||
): RampStateManager {
|
): RampStateManager {
|
||||||
return DefaultRampManager(
|
return DefaultRampManager(
|
||||||
|
|
@ -58,6 +60,7 @@ internal object ActivityModule {
|
||||||
swapServiceLoader = swapServiceLoader,
|
swapServiceLoader = swapServiceLoader,
|
||||||
currenciesRepository = currenciesRepository,
|
currenciesRepository = currenciesRepository,
|
||||||
getNetworkCoinStatusUseCase = getNetworkCoinStatusUseCase,
|
getNetworkCoinStatusUseCase = getNetworkCoinStatusUseCase,
|
||||||
|
excludedBlockchains = excludedBlockchains,
|
||||||
dispatchers = dispatchers,
|
dispatchers = dispatchers,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.tangem.tap.di.data
|
package com.tangem.tap.di.data
|
||||||
|
|
||||||
|
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||||
import com.tangem.datasource.local.userwallet.UserWalletsStore
|
import com.tangem.datasource.local.userwallet.UserWalletsStore
|
||||||
import com.tangem.domain.card.repository.DerivationsRepository
|
import com.tangem.domain.card.repository.DerivationsRepository
|
||||||
import com.tangem.sdk.api.TangemSdkManager
|
import com.tangem.sdk.api.TangemSdkManager
|
||||||
|
|
@ -20,8 +21,9 @@ internal object CardDataModule {
|
||||||
fun providesDerivationsRepository(
|
fun providesDerivationsRepository(
|
||||||
tangemSdkManager: TangemSdkManager,
|
tangemSdkManager: TangemSdkManager,
|
||||||
userWalletsStore: UserWalletsStore,
|
userWalletsStore: UserWalletsStore,
|
||||||
|
excludedBlockchains: ExcludedBlockchains,
|
||||||
dispatchers: CoroutineDispatcherProvider,
|
dispatchers: CoroutineDispatcherProvider,
|
||||||
): DerivationsRepository {
|
): DerivationsRepository {
|
||||||
return DefaultDerivationsRepository(tangemSdkManager, userWalletsStore, dispatchers)
|
return DefaultDerivationsRepository(tangemSdkManager, userWalletsStore, excludedBlockchains, dispatchers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.tangem.tap.domain.card
|
package com.tangem.tap.domain.card
|
||||||
|
|
||||||
import com.tangem.blockchain.common.Blockchain
|
import com.tangem.blockchain.common.Blockchain
|
||||||
|
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||||
import com.tangem.blockchainsdk.utils.fromNetworkId
|
import com.tangem.blockchainsdk.utils.fromNetworkId
|
||||||
import com.tangem.common.CompletionResult
|
import com.tangem.common.CompletionResult
|
||||||
import com.tangem.common.card.EllipticCurve
|
import com.tangem.common.card.EllipticCurve
|
||||||
|
|
@ -32,6 +33,7 @@ private typealias DerivedKeys = Map<ByteArrayKey, ExtendedPublicKeysMap>
|
||||||
internal class DefaultDerivationsRepository(
|
internal class DefaultDerivationsRepository(
|
||||||
private val tangemSdkManager: TangemSdkManager,
|
private val tangemSdkManager: TangemSdkManager,
|
||||||
private val userWalletsStore: UserWalletsStore,
|
private val userWalletsStore: UserWalletsStore,
|
||||||
|
private val excludedBlockchains: ExcludedBlockchains,
|
||||||
private val dispatchers: CoroutineDispatcherProvider,
|
private val dispatchers: CoroutineDispatcherProvider,
|
||||||
) : DerivationsRepository {
|
) : DerivationsRepository {
|
||||||
|
|
||||||
|
|
@ -49,6 +51,7 @@ internal class DefaultDerivationsRepository(
|
||||||
blockchain = Blockchain.fromNetworkId(it.value) ?: return@mapNotNull null,
|
blockchain = Blockchain.fromNetworkId(it.value) ?: return@mapNotNull null,
|
||||||
extraDerivationPath = null,
|
extraDerivationPath = null,
|
||||||
scanResponse = userWallet.scanResponse,
|
scanResponse = userWallet.scanResponse,
|
||||||
|
excludedBlockchains = excludedBlockchains,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
@ -85,6 +88,7 @@ internal class DefaultDerivationsRepository(
|
||||||
blockchain = Blockchain.fromNetworkId(backendId) ?: return@mapNotNull null,
|
blockchain = Blockchain.fromNetworkId(backendId) ?: return@mapNotNull null,
|
||||||
extraDerivationPath = extraDerivationPath,
|
extraDerivationPath = extraDerivationPath,
|
||||||
scanResponse = userWallet.scanResponse,
|
scanResponse = userWallet.scanResponse,
|
||||||
|
excludedBlockchains = excludedBlockchains,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,8 @@ import com.tangem.tap.common.extensions.*
|
||||||
import com.tangem.tap.common.redux.AppDialog
|
import com.tangem.tap.common.redux.AppDialog
|
||||||
import com.tangem.tap.common.redux.global.GlobalState
|
import com.tangem.tap.common.redux.global.GlobalState
|
||||||
import com.tangem.tap.features.demo.DemoHelper
|
import com.tangem.tap.features.demo.DemoHelper
|
||||||
import com.tangem.tap.features.onboarding.products.wallet.redux.OnboardingWalletAction
|
|
||||||
import com.tangem.tap.features.home.RUSSIA_COUNTRY_CODE
|
import com.tangem.tap.features.home.RUSSIA_COUNTRY_CODE
|
||||||
|
import com.tangem.tap.features.onboarding.products.wallet.redux.OnboardingWalletAction
|
||||||
import com.tangem.tap.features.saveWallet.redux.SaveWalletAction
|
import com.tangem.tap.features.saveWallet.redux.SaveWalletAction
|
||||||
import com.tangem.tap.mainScope
|
import com.tangem.tap.mainScope
|
||||||
import com.tangem.tap.proxy.redux.DaggerGraphState
|
import com.tangem.tap.proxy.redux.DaggerGraphState
|
||||||
|
|
@ -212,7 +212,9 @@ object OnboardingHelper {
|
||||||
|
|
||||||
fun handleTopUpAction(walletManager: WalletManager, scanResponse: ScanResponse, globalState: GlobalState) {
|
fun handleTopUpAction(walletManager: WalletManager, scanResponse: ScanResponse, globalState: GlobalState) {
|
||||||
val blockchain = walletManager.wallet.blockchain
|
val blockchain = walletManager.wallet.blockchain
|
||||||
val cryptoCurrency = CryptoCurrencyFactory().createCoin(
|
val excludedBlockchains = store.inject(DaggerGraphState::excludedBlockchains)
|
||||||
|
|
||||||
|
val cryptoCurrency = CryptoCurrencyFactory(excludedBlockchains).createCoin(
|
||||||
blockchain = blockchain,
|
blockchain = blockchain,
|
||||||
extraDerivationPath = null,
|
extraDerivationPath = null,
|
||||||
scanResponse = scanResponse,
|
scanResponse = scanResponse,
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.tangem.tap.network.exchangeServices
|
||||||
|
|
||||||
import com.tangem.blockchain.common.Blockchain
|
import com.tangem.blockchain.common.Blockchain
|
||||||
import com.tangem.blockchain.common.Token
|
import com.tangem.blockchain.common.Token
|
||||||
|
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||||
import com.tangem.data.common.currency.CryptoCurrencyFactory
|
import com.tangem.data.common.currency.CryptoCurrencyFactory
|
||||||
import com.tangem.domain.tokens.model.CryptoCurrency
|
import com.tangem.domain.tokens.model.CryptoCurrency
|
||||||
import com.tangem.tap.common.extensions.inject
|
import com.tangem.tap.common.extensions.inject
|
||||||
|
|
@ -10,9 +11,11 @@ import com.tangem.tap.proxy.redux.DaggerGraphState
|
||||||
import com.tangem.tap.store
|
import com.tangem.tap.store
|
||||||
import com.tangem.utils.converter.TwoWayConverter
|
import com.tangem.utils.converter.TwoWayConverter
|
||||||
|
|
||||||
internal class CryptoCurrencyConverter : TwoWayConverter<Currency, CryptoCurrency> {
|
internal class CryptoCurrencyConverter(
|
||||||
|
private val excludedBlockchains: ExcludedBlockchains,
|
||||||
|
) : TwoWayConverter<Currency, CryptoCurrency> {
|
||||||
|
|
||||||
private val cryptoCurrencyFactory by lazy { CryptoCurrencyFactory() }
|
private val cryptoCurrencyFactory by lazy { CryptoCurrencyFactory(excludedBlockchains) }
|
||||||
|
|
||||||
override fun convert(value: Currency): CryptoCurrency {
|
override fun convert(value: Currency): CryptoCurrency {
|
||||||
return when (value) {
|
return when (value) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.tangem.tap.network.exchangeServices
|
package com.tangem.tap.network.exchangeServices
|
||||||
|
|
||||||
|
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||||
import com.tangem.datasource.api.express.models.TangemExpressValues.EMPTY_CONTRACT_ADDRESS_VALUE
|
import com.tangem.datasource.api.express.models.TangemExpressValues.EMPTY_CONTRACT_ADDRESS_VALUE
|
||||||
import com.tangem.datasource.exchangeservice.swap.SwapServiceLoader
|
import com.tangem.datasource.exchangeservice.swap.SwapServiceLoader
|
||||||
import com.tangem.domain.exchange.RampStateManager
|
import com.tangem.domain.exchange.RampStateManager
|
||||||
|
|
@ -25,9 +26,10 @@ internal class DefaultRampManager(
|
||||||
private val currenciesRepository: CurrenciesRepository,
|
private val currenciesRepository: CurrenciesRepository,
|
||||||
private val getNetworkCoinStatusUseCase: GetNetworkCoinStatusUseCase,
|
private val getNetworkCoinStatusUseCase: GetNetworkCoinStatusUseCase,
|
||||||
private val dispatchers: CoroutineDispatcherProvider,
|
private val dispatchers: CoroutineDispatcherProvider,
|
||||||
|
excludedBlockchains: ExcludedBlockchains,
|
||||||
) : RampStateManager {
|
) : RampStateManager {
|
||||||
|
|
||||||
private val cryptoCurrencyConverter = CryptoCurrencyConverter()
|
private val cryptoCurrencyConverter = CryptoCurrencyConverter(excludedBlockchains)
|
||||||
|
|
||||||
override fun isSellSupportedByService(cryptoCurrency: CryptoCurrency): Boolean {
|
override fun isSellSupportedByService(cryptoCurrency: CryptoCurrency): Boolean {
|
||||||
return exchangeService?.availableForSell(
|
return exchangeService?.availableForSell(
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.tangem.data.common.currency
|
package com.tangem.data.common.currency
|
||||||
|
|
||||||
import com.tangem.blockchain.common.Blockchain
|
import com.tangem.blockchain.common.Blockchain
|
||||||
|
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||||
import com.tangem.blockchainsdk.utils.fromNetworkId
|
import com.tangem.blockchainsdk.utils.fromNetworkId
|
||||||
import com.tangem.blockchainsdk.utils.toCoinId
|
import com.tangem.blockchainsdk.utils.toCoinId
|
||||||
import com.tangem.domain.models.scan.ScanResponse
|
import com.tangem.domain.models.scan.ScanResponse
|
||||||
|
|
@ -10,7 +11,9 @@ import timber.log.Timber
|
||||||
import com.tangem.blockchain.common.Token as SdkToken
|
import com.tangem.blockchain.common.Token as SdkToken
|
||||||
|
|
||||||
// FIXME: Make internal
|
// FIXME: Make internal
|
||||||
class CryptoCurrencyFactory {
|
class CryptoCurrencyFactory(
|
||||||
|
private val excludedBlockchains: ExcludedBlockchains,
|
||||||
|
) {
|
||||||
|
|
||||||
@Suppress("LongParameterList") // Yep, it's long
|
@Suppress("LongParameterList") // Yep, it's long
|
||||||
fun createToken(
|
fun createToken(
|
||||||
|
|
@ -46,7 +49,7 @@ class CryptoCurrencyFactory {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
val network = getNetwork(blockchain, extraDerivationPath, scanResponse) ?: return null
|
val network = getNetwork(blockchain, extraDerivationPath, scanResponse, excludedBlockchains) ?: return null
|
||||||
val id = getTokenId(network, sdkToken)
|
val id = getTokenId(network, sdkToken)
|
||||||
|
|
||||||
return CryptoCurrency.Token(
|
return CryptoCurrency.Token(
|
||||||
|
|
@ -70,7 +73,7 @@ class CryptoCurrencyFactory {
|
||||||
Timber.e("Unable to map the SDK token to the domain token with Unknown blockchain")
|
Timber.e("Unable to map the SDK token to the domain token with Unknown blockchain")
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
val network = getNetwork(blockchain, extraDerivationPath, scanResponse) ?: return null
|
val network = getNetwork(blockchain, extraDerivationPath, scanResponse, excludedBlockchains) ?: return null
|
||||||
|
|
||||||
return createCoin(network)
|
return createCoin(network)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.tangem.data.common.currency
|
||||||
|
|
||||||
import com.tangem.blockchain.common.Blockchain
|
import com.tangem.blockchain.common.Blockchain
|
||||||
import com.tangem.blockchain.common.FeePaidCurrency
|
import com.tangem.blockchain.common.FeePaidCurrency
|
||||||
|
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||||
import com.tangem.blockchainsdk.utils.toNetworkId
|
import com.tangem.blockchainsdk.utils.toNetworkId
|
||||||
import com.tangem.domain.common.DerivationStyleProvider
|
import com.tangem.domain.common.DerivationStyleProvider
|
||||||
import com.tangem.domain.common.extensions.canHandleToken
|
import com.tangem.domain.common.extensions.canHandleToken
|
||||||
|
|
@ -19,10 +20,10 @@ fun getNetwork(
|
||||||
blockchain: Blockchain,
|
blockchain: Blockchain,
|
||||||
extraDerivationPath: String?,
|
extraDerivationPath: String?,
|
||||||
derivationStyleProvider: DerivationStyleProvider?,
|
derivationStyleProvider: DerivationStyleProvider?,
|
||||||
|
excludedBlockchains: ExcludedBlockchains,
|
||||||
canHandleTokens: Boolean,
|
canHandleTokens: Boolean,
|
||||||
): Network? {
|
): Network? {
|
||||||
if (blockchain == Blockchain.Unknown) {
|
if (!isBlockchainSupported(blockchain, excludedBlockchains)) {
|
||||||
Timber.e("Unable to convert Unknown blockchain to the domain network model")
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -43,10 +44,14 @@ fun getNetwork(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getNetwork(networkId: Network.ID, derivationPath: Network.DerivationPath, scanResponse: ScanResponse): Network? {
|
fun getNetwork(
|
||||||
|
networkId: Network.ID,
|
||||||
|
derivationPath: Network.DerivationPath,
|
||||||
|
scanResponse: ScanResponse,
|
||||||
|
excludedBlockchains: ExcludedBlockchains,
|
||||||
|
): Network? {
|
||||||
val blockchain = getBlockchain(networkId)
|
val blockchain = getBlockchain(networkId)
|
||||||
if (blockchain == Blockchain.Unknown) {
|
if (!isBlockchainSupported(blockchain, excludedBlockchains)) {
|
||||||
Timber.e("Unable to convert Unknown blockchain to the domain network model")
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -59,16 +64,43 @@ fun getNetwork(networkId: Network.ID, derivationPath: Network.DerivationPath, sc
|
||||||
currencySymbol = blockchain.currency,
|
currencySymbol = blockchain.currency,
|
||||||
standardType = getNetworkStandardType(blockchain),
|
standardType = getNetworkStandardType(blockchain),
|
||||||
hasFiatFeeRate = blockchain.feePaidCurrency() !is FeePaidCurrency.FeeResource,
|
hasFiatFeeRate = blockchain.feePaidCurrency() !is FeePaidCurrency.FeeResource,
|
||||||
canHandleTokens = scanResponse.card.canHandleToken(blockchain, scanResponse.cardTypesResolver),
|
canHandleTokens = scanResponse.card.canHandleToken(
|
||||||
|
blockchain,
|
||||||
|
scanResponse.cardTypesResolver,
|
||||||
|
excludedBlockchains,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getNetwork(blockchain: Blockchain, extraDerivationPath: String?, scanResponse: ScanResponse): Network? {
|
private fun isBlockchainSupported(blockchain: Blockchain, excludedBlockchains: ExcludedBlockchains): Boolean {
|
||||||
|
if (blockchain == Blockchain.Unknown) {
|
||||||
|
Timber.w("Unable to convert Unknown blockchain to the domain network model")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (blockchain in excludedBlockchains) {
|
||||||
|
Timber.w("Unable to convert excluded blockchain to the domain network model")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getNetwork(
|
||||||
|
blockchain: Blockchain,
|
||||||
|
extraDerivationPath: String?,
|
||||||
|
scanResponse: ScanResponse,
|
||||||
|
excludedBlockchains: ExcludedBlockchains,
|
||||||
|
): Network? {
|
||||||
return getNetwork(
|
return getNetwork(
|
||||||
blockchain = blockchain,
|
blockchain = blockchain,
|
||||||
extraDerivationPath = extraDerivationPath,
|
extraDerivationPath = extraDerivationPath,
|
||||||
derivationStyleProvider = scanResponse.derivationStyleProvider,
|
derivationStyleProvider = scanResponse.derivationStyleProvider,
|
||||||
canHandleTokens = scanResponse.card.canHandleToken(blockchain, scanResponse.cardTypesResolver),
|
excludedBlockchains = excludedBlockchains,
|
||||||
|
canHandleTokens = scanResponse.card.canHandleToken(
|
||||||
|
blockchain,
|
||||||
|
scanResponse.cardTypesResolver,
|
||||||
|
excludedBlockchains,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.tangem.data.common.currency
|
||||||
import com.tangem.blockchain.common.Blockchain
|
import com.tangem.blockchain.common.Blockchain
|
||||||
import com.tangem.blockchain.common.Token
|
import com.tangem.blockchain.common.Token
|
||||||
import com.tangem.blockchainsdk.compatibility.l2BlockchainsList
|
import com.tangem.blockchainsdk.compatibility.l2BlockchainsList
|
||||||
|
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||||
import com.tangem.blockchainsdk.utils.fromNetworkId
|
import com.tangem.blockchainsdk.utils.fromNetworkId
|
||||||
import com.tangem.blockchainsdk.utils.toCoinId
|
import com.tangem.blockchainsdk.utils.toCoinId
|
||||||
import com.tangem.datasource.api.tangemTech.models.UserTokensResponse
|
import com.tangem.datasource.api.tangemTech.models.UserTokensResponse
|
||||||
|
|
@ -12,7 +13,9 @@ import com.tangem.domain.tokens.model.CryptoCurrency
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import com.tangem.blockchain.common.Token as SdkToken
|
import com.tangem.blockchain.common.Token as SdkToken
|
||||||
|
|
||||||
class ResponseCryptoCurrenciesFactory {
|
class ResponseCryptoCurrenciesFactory(
|
||||||
|
private val excludedBlockchains: ExcludedBlockchains,
|
||||||
|
) {
|
||||||
|
|
||||||
fun createCurrency(currencyId: String, response: UserTokensResponse, scanResponse: ScanResponse): CryptoCurrency {
|
fun createCurrency(currencyId: String, response: UserTokensResponse, scanResponse: ScanResponse): CryptoCurrency {
|
||||||
return response.tokens
|
return response.tokens
|
||||||
|
|
@ -65,7 +68,12 @@ class ResponseCryptoCurrenciesFactory {
|
||||||
responseToken: UserTokensResponse.Token,
|
responseToken: UserTokensResponse.Token,
|
||||||
scanResponse: ScanResponse,
|
scanResponse: ScanResponse,
|
||||||
): CryptoCurrency.Coin? {
|
): CryptoCurrency.Coin? {
|
||||||
val network = getNetwork(blockchain, responseToken.derivationPath, scanResponse) ?: return null
|
val network = getNetwork(
|
||||||
|
blockchain,
|
||||||
|
responseToken.derivationPath,
|
||||||
|
scanResponse,
|
||||||
|
excludedBlockchains,
|
||||||
|
) ?: return null
|
||||||
|
|
||||||
return CryptoCurrency.Coin(
|
return CryptoCurrency.Coin(
|
||||||
id = getCoinId(network, blockchain.toCoinId()),
|
id = getCoinId(network, blockchain.toCoinId()),
|
||||||
|
|
@ -111,8 +119,13 @@ class ResponseCryptoCurrenciesFactory {
|
||||||
responseDerivationPath: String?,
|
responseDerivationPath: String?,
|
||||||
scanResponse: ScanResponse,
|
scanResponse: ScanResponse,
|
||||||
): CryptoCurrency.Token? {
|
): CryptoCurrency.Token? {
|
||||||
val network = getNetwork(blockchain, responseDerivationPath, scanResponse)
|
val network = getNetwork(
|
||||||
?: return null
|
blockchain,
|
||||||
|
responseDerivationPath,
|
||||||
|
scanResponse,
|
||||||
|
excludedBlockchains,
|
||||||
|
) ?: return null
|
||||||
|
|
||||||
val id = getTokenId(network, sdkToken)
|
val id = getTokenId(network, sdkToken)
|
||||||
|
|
||||||
return CryptoCurrency.Token(
|
return CryptoCurrency.Token(
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.tangem.data.managetokens
|
package com.tangem.data.managetokens
|
||||||
|
|
||||||
import com.tangem.blockchain.common.Blockchain
|
import com.tangem.blockchain.common.Blockchain
|
||||||
|
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||||
import com.tangem.blockchainsdk.utils.toNetworkId
|
import com.tangem.blockchainsdk.utils.toNetworkId
|
||||||
import com.tangem.crypto.hdWallet.DerivationPath
|
import com.tangem.crypto.hdWallet.DerivationPath
|
||||||
import com.tangem.data.common.api.safeApiCall
|
import com.tangem.data.common.api.safeApiCall
|
||||||
|
|
@ -36,10 +37,11 @@ internal class DefaultCustomTokensRepository(
|
||||||
private val userWalletsStore: UserWalletsStore,
|
private val userWalletsStore: UserWalletsStore,
|
||||||
private val appPreferencesStore: AppPreferencesStore,
|
private val appPreferencesStore: AppPreferencesStore,
|
||||||
private val walletManagersFacade: WalletManagersFacade,
|
private val walletManagersFacade: WalletManagersFacade,
|
||||||
|
private val excludedBlockchains: ExcludedBlockchains,
|
||||||
private val dispatchers: CoroutineDispatcherProvider,
|
private val dispatchers: CoroutineDispatcherProvider,
|
||||||
) : CustomTokensRepository {
|
) : CustomTokensRepository {
|
||||||
|
|
||||||
private val cryptoCurrencyFactory = CryptoCurrencyFactory()
|
private val cryptoCurrencyFactory = CryptoCurrencyFactory(excludedBlockchains)
|
||||||
private val userTokensResponseFactory = UserTokensResponseFactory()
|
private val userTokensResponseFactory = UserTokensResponseFactory()
|
||||||
private val tokenAddressConverter = TokenAddressesConverter()
|
private val tokenAddressConverter = TokenAddressesConverter()
|
||||||
private val userTokensBackwardCompatibility = UserTokensBackwardCompatibility()
|
private val userTokensBackwardCompatibility = UserTokensBackwardCompatibility()
|
||||||
|
|
@ -87,7 +89,9 @@ internal class DefaultCustomTokensRepository(
|
||||||
val userWallet = requireNotNull(userWalletsStore.getSyncOrNull(userWalletId)) {
|
val userWallet = requireNotNull(userWalletsStore.getSyncOrNull(userWalletId)) {
|
||||||
"User wallet [$userWalletId] not found while finding token"
|
"User wallet [$userWalletId] not found while finding token"
|
||||||
}
|
}
|
||||||
val network = requireNotNull(getNetwork(networkId, derivationPath, userWallet.scanResponse)) {
|
val network = requireNotNull(
|
||||||
|
getNetwork(networkId, derivationPath, userWallet.scanResponse, excludedBlockchains),
|
||||||
|
) {
|
||||||
"Network [$networkId] not found while finding token"
|
"Network [$networkId] not found while finding token"
|
||||||
}
|
}
|
||||||
val tokenAddress = tokenAddressConverter.convertTokenAddress(
|
val tokenAddress = tokenAddressConverter.convertTokenAddress(
|
||||||
|
|
@ -97,7 +101,7 @@ internal class DefaultCustomTokensRepository(
|
||||||
)
|
)
|
||||||
|
|
||||||
val supportedTokenNetworkIds = userWallet.scanResponse.card
|
val supportedTokenNetworkIds = userWallet.scanResponse.card
|
||||||
.supportedBlockchains(userWallet.scanResponse.cardTypesResolver)
|
.supportedBlockchains(userWallet.scanResponse.cardTypesResolver, excludedBlockchains)
|
||||||
.filter(Blockchain::canHandleTokens)
|
.filter(Blockchain::canHandleTokens)
|
||||||
.map(Blockchain::toNetworkId)
|
.map(Blockchain::toNetworkId)
|
||||||
|
|
||||||
|
|
@ -137,7 +141,9 @@ internal class DefaultCustomTokensRepository(
|
||||||
val userWallet = requireNotNull(userWalletsStore.getSyncOrNull(userWalletId)) {
|
val userWallet = requireNotNull(userWalletsStore.getSyncOrNull(userWalletId)) {
|
||||||
"User wallet [$userWalletId] not found while creating coin"
|
"User wallet [$userWalletId] not found while creating coin"
|
||||||
}
|
}
|
||||||
val network = requireNotNull(getNetwork(networkId, derivationPath, userWallet.scanResponse)) {
|
val network = requireNotNull(
|
||||||
|
getNetwork(networkId, derivationPath, userWallet.scanResponse, excludedBlockchains),
|
||||||
|
) {
|
||||||
"Network [$networkId] not found while creating coin"
|
"Network [$networkId] not found while creating coin"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -168,7 +174,9 @@ internal class DefaultCustomTokensRepository(
|
||||||
val userWallet = requireNotNull(userWalletsStore.getSyncOrNull(userWalletId)) {
|
val userWallet = requireNotNull(userWalletsStore.getSyncOrNull(userWalletId)) {
|
||||||
"User wallet [$userWalletId] not found while creating custom token"
|
"User wallet [$userWalletId] not found while creating custom token"
|
||||||
}
|
}
|
||||||
val network = requireNotNull(getNetwork(networkId, derivationPath, userWallet.scanResponse)) {
|
val network = requireNotNull(
|
||||||
|
getNetwork(networkId, derivationPath, userWallet.scanResponse, excludedBlockchains),
|
||||||
|
) {
|
||||||
"Network [$networkId] not found while creating custom token"
|
"Network [$networkId] not found while creating custom token"
|
||||||
}
|
}
|
||||||
val tokenAddress = tokenAddressConverter.convertTokenAddress(
|
val tokenAddress = tokenAddressConverter.convertTokenAddress(
|
||||||
|
|
@ -230,11 +238,18 @@ internal class DefaultCustomTokensRepository(
|
||||||
|
|
||||||
Blockchain.entries
|
Blockchain.entries
|
||||||
.mapNotNull { blockchain ->
|
.mapNotNull { blockchain ->
|
||||||
if (scanResponse.card.canHandleBlockchain(blockchain, scanResponse.cardTypesResolver)) {
|
val canHandleBlockchain = scanResponse.card.canHandleBlockchain(
|
||||||
|
blockchain,
|
||||||
|
scanResponse.cardTypesResolver,
|
||||||
|
excludedBlockchains,
|
||||||
|
)
|
||||||
|
|
||||||
|
if (canHandleBlockchain) {
|
||||||
getNetwork(
|
getNetwork(
|
||||||
blockchain = blockchain,
|
blockchain = blockchain,
|
||||||
extraDerivationPath = null,
|
extraDerivationPath = null,
|
||||||
scanResponse = scanResponse,
|
scanResponse = scanResponse,
|
||||||
|
excludedBlockchains = excludedBlockchains,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@ package com.tangem.data.managetokens
|
||||||
|
|
||||||
import com.tangem.blockchain.common.Blockchain
|
import com.tangem.blockchain.common.Blockchain
|
||||||
import com.tangem.blockchainsdk.compatibility.l2BlockchainsCoinIds
|
import com.tangem.blockchainsdk.compatibility.l2BlockchainsCoinIds
|
||||||
|
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||||
import com.tangem.blockchainsdk.utils.fromNetworkId
|
import com.tangem.blockchainsdk.utils.fromNetworkId
|
||||||
import com.tangem.blockchainsdk.utils.isSupportedInApp
|
|
||||||
import com.tangem.blockchainsdk.utils.toNetworkId
|
import com.tangem.blockchainsdk.utils.toNetworkId
|
||||||
import com.tangem.data.common.api.safeApiCall
|
import com.tangem.data.common.api.safeApiCall
|
||||||
import com.tangem.data.common.currency.UserTokensResponseFactory
|
import com.tangem.data.common.currency.UserTokensResponseFactory
|
||||||
|
|
@ -47,12 +47,13 @@ internal class DefaultManageTokensRepository(
|
||||||
private val manageTokensUpdateFetcher: ManageTokensUpdateFetcher,
|
private val manageTokensUpdateFetcher: ManageTokensUpdateFetcher,
|
||||||
private val appPreferencesStore: AppPreferencesStore,
|
private val appPreferencesStore: AppPreferencesStore,
|
||||||
private val testnetTokensStorage: TestnetTokensStorage,
|
private val testnetTokensStorage: TestnetTokensStorage,
|
||||||
|
private val excludedBlockchains: ExcludedBlockchains,
|
||||||
private val dispatchers: CoroutineDispatcherProvider,
|
private val dispatchers: CoroutineDispatcherProvider,
|
||||||
) : ManageTokensRepository {
|
) : ManageTokensRepository {
|
||||||
|
|
||||||
private val managedCryptoCurrencyFactory = ManagedCryptoCurrencyFactory()
|
private val managedCryptoCurrencyFactory = ManagedCryptoCurrencyFactory(excludedBlockchains)
|
||||||
private val userTokensResponseFactory = UserTokensResponseFactory()
|
private val userTokensResponseFactory = UserTokensResponseFactory()
|
||||||
private val cardCurrenciesFactory = CardCryptoCurrenciesFactory(DemoConfig())
|
private val cardCurrenciesFactory = CardCryptoCurrenciesFactory(DemoConfig(), excludedBlockchains)
|
||||||
|
|
||||||
// region getTokenListBatchFlow
|
// region getTokenListBatchFlow
|
||||||
override fun getTokenListBatchFlow(
|
override fun getTokenListBatchFlow(
|
||||||
|
|
@ -202,9 +203,9 @@ internal class DefaultManageTokensRepository(
|
||||||
|
|
||||||
private fun getSupportedBlockchains(userWallet: UserWallet?): List<Blockchain> {
|
private fun getSupportedBlockchains(userWallet: UserWallet?): List<Blockchain> {
|
||||||
return userWallet?.scanResponse?.let {
|
return userWallet?.scanResponse?.let {
|
||||||
it.card.supportedBlockchains(it.cardTypesResolver)
|
it.card.supportedBlockchains(it.cardTypesResolver, excludedBlockchains)
|
||||||
} ?: Blockchain.entries.filter {
|
} ?: Blockchain.entries.filter {
|
||||||
!it.isTestnet() && it.isSupportedInApp()
|
!it.isTestnet() && it !in excludedBlockchains
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// endregion
|
// endregion
|
||||||
|
|
@ -290,6 +291,7 @@ internal class DefaultManageTokensRepository(
|
||||||
val canHandleBlockchain = userWallet.scanResponse.card.canHandleBlockchain(
|
val canHandleBlockchain = userWallet.scanResponse.card.canHandleBlockchain(
|
||||||
blockchain = blockchain,
|
blockchain = blockchain,
|
||||||
cardTypesResolver = userWallet.cardTypesResolver,
|
cardTypesResolver = userWallet.cardTypesResolver,
|
||||||
|
excludedBlockchains = excludedBlockchains,
|
||||||
)
|
)
|
||||||
|
|
||||||
return if (!canHandleBlockchain) {
|
return if (!canHandleBlockchain) {
|
||||||
|
|
@ -304,7 +306,10 @@ internal class DefaultManageTokensRepository(
|
||||||
blockchain: Blockchain,
|
blockchain: Blockchain,
|
||||||
): CurrencyUnsupportedState.Token? {
|
): CurrencyUnsupportedState.Token? {
|
||||||
val cardTypesResolver = userWallet.scanResponse.cardTypesResolver
|
val cardTypesResolver = userWallet.scanResponse.cardTypesResolver
|
||||||
val supportedTokens = userWallet.scanResponse.card.supportedTokens(cardTypesResolver)
|
val supportedTokens = userWallet.scanResponse.card.supportedTokens(
|
||||||
|
cardTypesResolver,
|
||||||
|
excludedBlockchains,
|
||||||
|
)
|
||||||
|
|
||||||
return when {
|
return when {
|
||||||
// refactor this later by moving all this logic in card config
|
// refactor this later by moving all this logic in card config
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.tangem.data.managetokens.di
|
package com.tangem.data.managetokens.di
|
||||||
|
|
||||||
|
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||||
import com.tangem.data.managetokens.DefaultCustomTokensRepository
|
import com.tangem.data.managetokens.DefaultCustomTokensRepository
|
||||||
import com.tangem.data.managetokens.DefaultManageTokensRepository
|
import com.tangem.data.managetokens.DefaultManageTokensRepository
|
||||||
import com.tangem.data.managetokens.utils.ManageTokensUpdateFetcher
|
import com.tangem.data.managetokens.utils.ManageTokensUpdateFetcher
|
||||||
|
|
@ -30,6 +31,7 @@ internal object ManageTokensDataModule {
|
||||||
appPreferencesStore: AppPreferencesStore,
|
appPreferencesStore: AppPreferencesStore,
|
||||||
testnetTokensStorage: TestnetTokensStorage,
|
testnetTokensStorage: TestnetTokensStorage,
|
||||||
dispatchers: CoroutineDispatcherProvider,
|
dispatchers: CoroutineDispatcherProvider,
|
||||||
|
excludedBlockchains: ExcludedBlockchains,
|
||||||
): ManageTokensRepository {
|
): ManageTokensRepository {
|
||||||
return DefaultManageTokensRepository(
|
return DefaultManageTokensRepository(
|
||||||
tangemTechApi,
|
tangemTechApi,
|
||||||
|
|
@ -37,6 +39,7 @@ internal object ManageTokensDataModule {
|
||||||
manageTokensUpdateFetcher,
|
manageTokensUpdateFetcher,
|
||||||
appPreferencesStore,
|
appPreferencesStore,
|
||||||
testnetTokensStorage,
|
testnetTokensStorage,
|
||||||
|
excludedBlockchains,
|
||||||
dispatchers,
|
dispatchers,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -49,12 +52,14 @@ internal object ManageTokensDataModule {
|
||||||
appPreferencesStore: AppPreferencesStore,
|
appPreferencesStore: AppPreferencesStore,
|
||||||
walletManagersFacade: WalletManagersFacade,
|
walletManagersFacade: WalletManagersFacade,
|
||||||
dispatchers: CoroutineDispatcherProvider,
|
dispatchers: CoroutineDispatcherProvider,
|
||||||
|
excludedBlockchains: ExcludedBlockchains,
|
||||||
): CustomTokensRepository {
|
): CustomTokensRepository {
|
||||||
return DefaultCustomTokensRepository(
|
return DefaultCustomTokensRepository(
|
||||||
tangemTechApi,
|
tangemTechApi,
|
||||||
userWalletsStore,
|
userWalletsStore,
|
||||||
appPreferencesStore,
|
appPreferencesStore,
|
||||||
walletManagersFacade,
|
walletManagersFacade,
|
||||||
|
excludedBlockchains,
|
||||||
dispatchers,
|
dispatchers,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ import com.tangem.blockchain.common.Blockchain
|
||||||
import com.tangem.blockchainsdk.compatibility.applyL2Compatibility
|
import com.tangem.blockchainsdk.compatibility.applyL2Compatibility
|
||||||
import com.tangem.blockchainsdk.compatibility.getL2CompatibilityTokenComparison
|
import com.tangem.blockchainsdk.compatibility.getL2CompatibilityTokenComparison
|
||||||
import com.tangem.blockchainsdk.compatibility.l2BlockchainsList
|
import com.tangem.blockchainsdk.compatibility.l2BlockchainsList
|
||||||
|
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||||
import com.tangem.blockchainsdk.utils.fromNetworkId
|
import com.tangem.blockchainsdk.utils.fromNetworkId
|
||||||
import com.tangem.blockchainsdk.utils.isSupportedInApp
|
|
||||||
import com.tangem.blockchainsdk.utils.toCoinId
|
import com.tangem.blockchainsdk.utils.toCoinId
|
||||||
import com.tangem.data.common.currency.getCoinId
|
import com.tangem.data.common.currency.getCoinId
|
||||||
import com.tangem.data.common.currency.getNetwork
|
import com.tangem.data.common.currency.getNetwork
|
||||||
|
|
@ -22,7 +22,9 @@ import com.tangem.domain.managetokens.model.ManagedCryptoCurrency.SourceNetwork
|
||||||
import com.tangem.domain.models.scan.ScanResponse
|
import com.tangem.domain.models.scan.ScanResponse
|
||||||
import com.tangem.domain.tokens.model.Network
|
import com.tangem.domain.tokens.model.Network
|
||||||
|
|
||||||
internal class ManagedCryptoCurrencyFactory {
|
internal class ManagedCryptoCurrencyFactory(
|
||||||
|
private val excludedBlockchains: ExcludedBlockchains,
|
||||||
|
) {
|
||||||
|
|
||||||
fun create(
|
fun create(
|
||||||
coinsResponse: CoinsResponse,
|
coinsResponse: CoinsResponse,
|
||||||
|
|
@ -88,7 +90,7 @@ internal class ManagedCryptoCurrencyFactory {
|
||||||
scanResponse: ScanResponse,
|
scanResponse: ScanResponse,
|
||||||
): ManagedCryptoCurrency? {
|
): ManagedCryptoCurrency? {
|
||||||
val blockchain = Blockchain.fromNetworkId(token.networkId)
|
val blockchain = Blockchain.fromNetworkId(token.networkId)
|
||||||
?.takeIf { it.isSupportedInApp() }
|
?.takeUnless { it in excludedBlockchains }
|
||||||
?: return null
|
?: return null
|
||||||
|
|
||||||
if (!checkIsCustomToken(token, blockchain, scanResponse.derivationStyleProvider)) {
|
if (!checkIsCustomToken(token, blockchain, scanResponse.derivationStyleProvider)) {
|
||||||
|
|
@ -99,6 +101,7 @@ internal class ManagedCryptoCurrencyFactory {
|
||||||
blockchain = blockchain,
|
blockchain = blockchain,
|
||||||
extraDerivationPath = token.derivationPath,
|
extraDerivationPath = token.derivationPath,
|
||||||
scanResponse = scanResponse,
|
scanResponse = scanResponse,
|
||||||
|
excludedBlockchains = excludedBlockchains,
|
||||||
) ?: return null
|
) ?: return null
|
||||||
val contractAddress = token.contractAddress
|
val contractAddress = token.contractAddress
|
||||||
|
|
||||||
|
|
@ -161,15 +164,16 @@ internal class ManagedCryptoCurrencyFactory {
|
||||||
extraDerivationPath: String? = null,
|
extraDerivationPath: String? = null,
|
||||||
): SourceNetwork? {
|
): SourceNetwork? {
|
||||||
val blockchain = Blockchain.fromNetworkId(networkId)
|
val blockchain = Blockchain.fromNetworkId(networkId)
|
||||||
?.takeIf { it.isSupportedInApp() }
|
?.takeUnless { it in excludedBlockchains }
|
||||||
?: return null
|
?: return null
|
||||||
|
|
||||||
val network = getNetwork(
|
val network = getNetwork(
|
||||||
blockchain,
|
blockchain,
|
||||||
extraDerivationPath,
|
extraDerivationPath,
|
||||||
scanResponse?.derivationStyleProvider,
|
scanResponse?.derivationStyleProvider,
|
||||||
|
excludedBlockchains,
|
||||||
canHandleTokens = scanResponse?.let {
|
canHandleTokens = scanResponse?.let {
|
||||||
it.card.canHandleToken(blockchain, it.cardTypesResolver)
|
it.card.canHandleToken(blockchain, it.cardTypesResolver, excludedBlockchains)
|
||||||
} ?: true,
|
} ?: true,
|
||||||
) ?: return null
|
) ?: return null
|
||||||
|
|
||||||
|
|
@ -200,13 +204,14 @@ internal class ManagedCryptoCurrencyFactory {
|
||||||
.mapNotNullTo(mutableSetOf()) { token ->
|
.mapNotNullTo(mutableSetOf()) { token ->
|
||||||
val blockchain = Blockchain.fromNetworkId(token.networkId)
|
val blockchain = Blockchain.fromNetworkId(token.networkId)
|
||||||
|
|
||||||
if (blockchain != null && blockchain.isSupportedInApp()) {
|
if (blockchain != null && blockchain !in excludedBlockchains) {
|
||||||
getNetwork(
|
getNetwork(
|
||||||
blockchain,
|
blockchain,
|
||||||
token.derivationPath,
|
token.derivationPath,
|
||||||
scanResponse?.derivationStyleProvider,
|
scanResponse?.derivationStyleProvider,
|
||||||
|
excludedBlockchains,
|
||||||
canHandleTokens = scanResponse?.let {
|
canHandleTokens = scanResponse?.let {
|
||||||
it.card.canHandleToken(blockchain, it.cardTypesResolver)
|
it.card.canHandleToken(blockchain, it.cardTypesResolver, excludedBlockchains)
|
||||||
} ?: true,
|
} ?: true,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ dependencies {
|
||||||
implementation(projects.core.pagination)
|
implementation(projects.core.pagination)
|
||||||
implementation(projects.core.analytics)
|
implementation(projects.core.analytics)
|
||||||
implementation(projects.core.analytics.models)
|
implementation(projects.core.analytics.models)
|
||||||
|
implementation(projects.core.configToggles)
|
||||||
|
|
||||||
implementation(projects.domain.legacy)
|
implementation(projects.domain.legacy)
|
||||||
implementation(projects.domain.markets)
|
implementation(projects.domain.markets)
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.tangem.data.markets
|
||||||
import com.tangem.blockchain.common.Blockchain
|
import com.tangem.blockchain.common.Blockchain
|
||||||
import com.tangem.blockchainsdk.compatibility.applyL2Compatibility
|
import com.tangem.blockchainsdk.compatibility.applyL2Compatibility
|
||||||
import com.tangem.blockchainsdk.compatibility.getTokenIdIfL2Network
|
import com.tangem.blockchainsdk.compatibility.getTokenIdIfL2Network
|
||||||
|
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||||
import com.tangem.blockchainsdk.utils.fromNetworkId
|
import com.tangem.blockchainsdk.utils.fromNetworkId
|
||||||
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
||||||
import com.tangem.data.common.cache.CacheRegistry
|
import com.tangem.data.common.cache.CacheRegistry
|
||||||
|
|
@ -37,10 +38,14 @@ internal class DefaultMarketsTokenRepository(
|
||||||
private val userWalletsStore: UserWalletsStore,
|
private val userWalletsStore: UserWalletsStore,
|
||||||
private val dispatcherProvider: CoroutineDispatcherProvider,
|
private val dispatcherProvider: CoroutineDispatcherProvider,
|
||||||
private val analyticsEventHandler: AnalyticsEventHandler,
|
private val analyticsEventHandler: AnalyticsEventHandler,
|
||||||
|
private val excludedBlockchains: ExcludedBlockchains,
|
||||||
private val cacheRegistry: CacheRegistry,
|
private val cacheRegistry: CacheRegistry,
|
||||||
private val tokenExchangesStore: RuntimeStateStore<List<TokenMarketExchangesResponse.Exchange>>,
|
private val tokenExchangesStore: RuntimeStateStore<List<TokenMarketExchangesResponse.Exchange>>,
|
||||||
) : MarketsTokenRepository {
|
) : MarketsTokenRepository {
|
||||||
|
|
||||||
|
private val tokenMarketInfoConverter: TokenMarketInfoConverter = TokenMarketInfoConverter(excludedBlockchains)
|
||||||
|
private val cryptoCurrencyFactory = CryptoCurrencyFactory(excludedBlockchains)
|
||||||
|
|
||||||
private fun createTokenMarketsFetcher(firstBatchSize: Int, nextBatchSize: Int) = LimitOffsetBatchFetcher(
|
private fun createTokenMarketsFetcher(firstBatchSize: Int, nextBatchSize: Int) = LimitOffsetBatchFetcher(
|
||||||
prefetchDistance = firstBatchSize,
|
prefetchDistance = firstBatchSize,
|
||||||
batchSize = nextBatchSize,
|
batchSize = nextBatchSize,
|
||||||
|
|
@ -204,7 +209,7 @@ internal class DefaultMarketsTokenRepository(
|
||||||
}
|
}
|
||||||
|
|
||||||
val resultResponse = result.applyL2Compatibility(tokenId)
|
val resultResponse = result.applyL2Compatibility(tokenId)
|
||||||
return@withContext TokenMarketInfoConverter.convert(resultResponse)
|
return@withContext tokenMarketInfoConverter.convert(resultResponse)
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getTokenQuotes(fiatCurrencyCode: String, tokenId: String, tokenSymbol: String) =
|
override suspend fun getTokenQuotes(fiatCurrencyCode: String, tokenId: String, tokenSymbol: String) =
|
||||||
|
|
@ -234,7 +239,7 @@ internal class DefaultMarketsTokenRepository(
|
||||||
val blockchain = Blockchain.fromNetworkId(network.networkId) ?: error("Unknown network [${network.networkId}]")
|
val blockchain = Blockchain.fromNetworkId(network.networkId) ?: error("Unknown network [${network.networkId}]")
|
||||||
|
|
||||||
return if (network.contractAddress == null) {
|
return if (network.contractAddress == null) {
|
||||||
CryptoCurrencyFactory().createCoin(
|
cryptoCurrencyFactory.createCoin(
|
||||||
blockchain = blockchain,
|
blockchain = blockchain,
|
||||||
extraDerivationPath = null,
|
extraDerivationPath = null,
|
||||||
scanResponse = userWallet.scanResponse,
|
scanResponse = userWallet.scanResponse,
|
||||||
|
|
@ -244,9 +249,10 @@ internal class DefaultMarketsTokenRepository(
|
||||||
blockchain = blockchain,
|
blockchain = blockchain,
|
||||||
extraDerivationPath = null,
|
extraDerivationPath = null,
|
||||||
scanResponse = userWallet.scanResponse,
|
scanResponse = userWallet.scanResponse,
|
||||||
|
excludedBlockchains = excludedBlockchains,
|
||||||
) ?: return null
|
) ?: return null
|
||||||
|
|
||||||
CryptoCurrencyFactory().createToken(
|
cryptoCurrencyFactory.createToken(
|
||||||
network = currencyNetwork,
|
network = currencyNetwork,
|
||||||
rawId = token.id,
|
rawId = token.id,
|
||||||
name = token.name,
|
name = token.name,
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@ package com.tangem.data.markets.converters
|
||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import com.tangem.blockchain.common.Blockchain
|
import com.tangem.blockchain.common.Blockchain
|
||||||
|
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||||
import com.tangem.blockchainsdk.utils.fromNetworkId
|
import com.tangem.blockchainsdk.utils.fromNetworkId
|
||||||
import com.tangem.blockchainsdk.utils.isSupportedInApp
|
|
||||||
import com.tangem.datasource.api.markets.models.response.TokenMarketInfoResponse
|
import com.tangem.datasource.api.markets.models.response.TokenMarketInfoResponse
|
||||||
import com.tangem.domain.markets.BuildConfig
|
import com.tangem.domain.markets.BuildConfig
|
||||||
import com.tangem.domain.markets.TokenMarketInfo
|
import com.tangem.domain.markets.TokenMarketInfo
|
||||||
|
|
@ -11,10 +11,9 @@ import com.tangem.domain.markets.TokenQuotes
|
||||||
import com.tangem.utils.converter.Converter
|
import com.tangem.utils.converter.Converter
|
||||||
import java.math.BigDecimal
|
import java.math.BigDecimal
|
||||||
|
|
||||||
internal object TokenMarketInfoConverter : Converter<TokenMarketInfoResponse, TokenMarketInfo> {
|
internal class TokenMarketInfoConverter(
|
||||||
|
private val excludedBlockchains: ExcludedBlockchains,
|
||||||
private const val PROD_IMAGE_HOST = "https://s3.eu-central-1.amazonaws.com/tangem.api/security_provider/"
|
) : Converter<TokenMarketInfoResponse, TokenMarketInfo> {
|
||||||
private const val DEV_IMAGE_HOST = "https://s3.eu-central-1.amazonaws.com/tangem.api.dev/security_provider/"
|
|
||||||
|
|
||||||
override fun convert(value: TokenMarketInfoResponse): TokenMarketInfo {
|
override fun convert(value: TokenMarketInfoResponse): TokenMarketInfo {
|
||||||
return with(value) {
|
return with(value) {
|
||||||
|
|
@ -68,7 +67,8 @@ internal object TokenMarketInfoConverter : Converter<TokenMarketInfoResponse, To
|
||||||
decimalCount = network.decimalCount,
|
decimalCount = network.decimalCount,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
blockchain != null && blockchain.isSupportedInApp() && blockchain.canHandleTokens() -> {
|
blockchain != null && blockchain !in excludedBlockchains &&
|
||||||
|
blockchain.canHandleTokens() -> {
|
||||||
TokenMarketInfo.Network(
|
TokenMarketInfo.Network(
|
||||||
networkId = network.networkId,
|
networkId = network.networkId,
|
||||||
exchangeable = network.exchangeable,
|
exchangeable = network.exchangeable,
|
||||||
|
|
@ -193,4 +193,10 @@ internal object TokenMarketInfoConverter : Converter<TokenMarketInfoResponse, To
|
||||||
PROD_IMAGE_HOST
|
PROD_IMAGE_HOST
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private companion object {
|
||||||
|
|
||||||
|
const val PROD_IMAGE_HOST = "https://s3.eu-central-1.amazonaws.com/tangem.api/security_provider/"
|
||||||
|
const val DEV_IMAGE_HOST = "https://s3.eu-central-1.amazonaws.com/tangem.api.dev/security_provider/"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.tangem.data.markets.di
|
package com.tangem.data.markets.di
|
||||||
|
|
||||||
|
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||||
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
||||||
import com.tangem.data.common.cache.CacheRegistry
|
import com.tangem.data.common.cache.CacheRegistry
|
||||||
import com.tangem.data.markets.DefaultMarketsTokenRepository
|
import com.tangem.data.markets.DefaultMarketsTokenRepository
|
||||||
|
|
@ -28,6 +29,7 @@ internal object MarketsDataModule {
|
||||||
dispatchers: CoroutineDispatcherProvider,
|
dispatchers: CoroutineDispatcherProvider,
|
||||||
analyticsEventHandler: AnalyticsEventHandler,
|
analyticsEventHandler: AnalyticsEventHandler,
|
||||||
cacheRegistry: CacheRegistry,
|
cacheRegistry: CacheRegistry,
|
||||||
|
excludedBlockchains: ExcludedBlockchains,
|
||||||
): MarketsTokenRepository {
|
): MarketsTokenRepository {
|
||||||
return DefaultMarketsTokenRepository(
|
return DefaultMarketsTokenRepository(
|
||||||
marketsApi = marketsApi,
|
marketsApi = marketsApi,
|
||||||
|
|
@ -37,6 +39,7 @@ internal object MarketsDataModule {
|
||||||
analyticsEventHandler = analyticsEventHandler,
|
analyticsEventHandler = analyticsEventHandler,
|
||||||
cacheRegistry = cacheRegistry,
|
cacheRegistry = cacheRegistry,
|
||||||
tokenExchangesStore = RuntimeStateStore(defaultValue = emptyList()),
|
tokenExchangesStore = RuntimeStateStore(defaultValue = emptyList()),
|
||||||
|
excludedBlockchains = excludedBlockchains,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.tangem.data.tokens.di
|
package com.tangem.data.tokens.di
|
||||||
|
|
||||||
|
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||||
import com.tangem.data.common.cache.CacheRegistry
|
import com.tangem.data.common.cache.CacheRegistry
|
||||||
import com.tangem.data.tokens.repository.*
|
import com.tangem.data.tokens.repository.*
|
||||||
import com.tangem.datasource.api.tangemTech.TangemTechApi
|
import com.tangem.datasource.api.tangemTech.TangemTechApi
|
||||||
|
|
@ -31,6 +32,7 @@ internal object TokensDataModule {
|
||||||
cacheRegistry: CacheRegistry,
|
cacheRegistry: CacheRegistry,
|
||||||
dispatchers: CoroutineDispatcherProvider,
|
dispatchers: CoroutineDispatcherProvider,
|
||||||
swapServiceLoader: SwapServiceLoader,
|
swapServiceLoader: SwapServiceLoader,
|
||||||
|
excludedBlockchains: ExcludedBlockchains,
|
||||||
): CurrenciesRepository {
|
): CurrenciesRepository {
|
||||||
return DefaultCurrenciesRepository(
|
return DefaultCurrenciesRepository(
|
||||||
tangemTechApi = tangemTechApi,
|
tangemTechApi = tangemTechApi,
|
||||||
|
|
@ -40,6 +42,7 @@ internal object TokensDataModule {
|
||||||
appPreferencesStore = appPreferencesStore,
|
appPreferencesStore = appPreferencesStore,
|
||||||
dispatchers = dispatchers,
|
dispatchers = dispatchers,
|
||||||
swapServiceLoader = swapServiceLoader,
|
swapServiceLoader = swapServiceLoader,
|
||||||
|
excludedBlockchains = excludedBlockchains,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -70,6 +73,7 @@ internal object TokensDataModule {
|
||||||
appPreferencesStore: AppPreferencesStore,
|
appPreferencesStore: AppPreferencesStore,
|
||||||
cacheRegistry: CacheRegistry,
|
cacheRegistry: CacheRegistry,
|
||||||
dispatchers: CoroutineDispatcherProvider,
|
dispatchers: CoroutineDispatcherProvider,
|
||||||
|
excludedBlockchains: ExcludedBlockchains,
|
||||||
): NetworksRepository {
|
): NetworksRepository {
|
||||||
return DefaultNetworksRepository(
|
return DefaultNetworksRepository(
|
||||||
networksStatusesStore = networksStatusesStore,
|
networksStatusesStore = networksStatusesStore,
|
||||||
|
|
@ -78,6 +82,7 @@ internal object TokensDataModule {
|
||||||
appPreferencesStore = appPreferencesStore,
|
appPreferencesStore = appPreferencesStore,
|
||||||
cacheRegistry = cacheRegistry,
|
cacheRegistry = cacheRegistry,
|
||||||
dispatchers = dispatchers,
|
dispatchers = dispatchers,
|
||||||
|
excludedBlockchains = excludedBlockchains,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.tangem.data.tokens.repository
|
||||||
|
|
||||||
import com.tangem.blockchain.common.Blockchain
|
import com.tangem.blockchain.common.Blockchain
|
||||||
import com.tangem.blockchainsdk.compatibility.getL2CompatibilityTokenComparison
|
import com.tangem.blockchainsdk.compatibility.getL2CompatibilityTokenComparison
|
||||||
|
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||||
import com.tangem.blockchainsdk.utils.toCoinId
|
import com.tangem.blockchainsdk.utils.toCoinId
|
||||||
import com.tangem.blockchainsdk.utils.toNetworkId
|
import com.tangem.blockchainsdk.utils.toNetworkId
|
||||||
import com.tangem.data.common.api.safeApiCall
|
import com.tangem.data.common.api.safeApiCall
|
||||||
|
|
@ -48,12 +49,13 @@ internal class DefaultCurrenciesRepository(
|
||||||
private val appPreferencesStore: AppPreferencesStore,
|
private val appPreferencesStore: AppPreferencesStore,
|
||||||
private val swapServiceLoader: SwapServiceLoader,
|
private val swapServiceLoader: SwapServiceLoader,
|
||||||
private val dispatchers: CoroutineDispatcherProvider,
|
private val dispatchers: CoroutineDispatcherProvider,
|
||||||
|
excludedBlockchains: ExcludedBlockchains,
|
||||||
) : CurrenciesRepository {
|
) : CurrenciesRepository {
|
||||||
|
|
||||||
private val demoConfig = DemoConfig()
|
private val demoConfig = DemoConfig()
|
||||||
private val responseCurrenciesFactory = ResponseCryptoCurrenciesFactory()
|
private val responseCurrenciesFactory = ResponseCryptoCurrenciesFactory(excludedBlockchains)
|
||||||
private val cryptoCurrencyFactory = CryptoCurrencyFactory()
|
private val cryptoCurrencyFactory = CryptoCurrencyFactory(excludedBlockchains)
|
||||||
private val cardCurrenciesFactory = CardCryptoCurrenciesFactory(demoConfig)
|
private val cardCurrenciesFactory = CardCryptoCurrenciesFactory(demoConfig, excludedBlockchains)
|
||||||
private val userTokensResponseFactory = UserTokensResponseFactory()
|
private val userTokensResponseFactory = UserTokensResponseFactory()
|
||||||
private val userTokensBackwardCompatibility = UserTokensBackwardCompatibility()
|
private val userTokensBackwardCompatibility = UserTokensBackwardCompatibility()
|
||||||
private val customTokensMerger = CustomTokensMerger(tangemTechApi, dispatchers)
|
private val customTokensMerger = CustomTokensMerger(tangemTechApi, dispatchers)
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.tangem.data.tokens.repository
|
||||||
|
|
||||||
import com.tangem.blockchain.common.Blockchain
|
import com.tangem.blockchain.common.Blockchain
|
||||||
import com.tangem.blockchain.common.address.AddressType
|
import com.tangem.blockchain.common.address.AddressType
|
||||||
|
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||||
import com.tangem.blockchainsdk.utils.fromNetworkId
|
import com.tangem.blockchainsdk.utils.fromNetworkId
|
||||||
import com.tangem.data.common.cache.CacheRegistry
|
import com.tangem.data.common.cache.CacheRegistry
|
||||||
import com.tangem.data.common.currency.ResponseCryptoCurrenciesFactory
|
import com.tangem.data.common.currency.ResponseCryptoCurrenciesFactory
|
||||||
|
|
@ -39,12 +40,13 @@ internal class DefaultNetworksRepository(
|
||||||
private val appPreferencesStore: AppPreferencesStore,
|
private val appPreferencesStore: AppPreferencesStore,
|
||||||
private val cacheRegistry: CacheRegistry,
|
private val cacheRegistry: CacheRegistry,
|
||||||
private val dispatchers: CoroutineDispatcherProvider,
|
private val dispatchers: CoroutineDispatcherProvider,
|
||||||
|
excludedBlockchains: ExcludedBlockchains,
|
||||||
) : NetworksRepository {
|
) : NetworksRepository {
|
||||||
|
|
||||||
private val demoConfig by lazy { DemoConfig() }
|
private val demoConfig = DemoConfig()
|
||||||
private val cardCurrenciesFactory by lazy { CardCryptoCurrenciesFactory(demoConfig) }
|
private val cardCurrenciesFactory = CardCryptoCurrenciesFactory(demoConfig, excludedBlockchains)
|
||||||
private val responseCurrenciesFactory by lazy { ResponseCryptoCurrenciesFactory() }
|
private val responseCurrenciesFactory = ResponseCryptoCurrenciesFactory(excludedBlockchains)
|
||||||
private val networkStatusFactory by lazy { NetworkStatusFactory() }
|
private val networkStatusFactory = NetworkStatusFactory()
|
||||||
|
|
||||||
override fun getNetworkStatusesUpdates(
|
override fun getNetworkStatusesUpdates(
|
||||||
userWalletId: UserWalletId,
|
userWalletId: UserWalletId,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.tangem.data.tokens.utils
|
package com.tangem.data.tokens.utils
|
||||||
|
|
||||||
import com.tangem.blockchain.common.Blockchain
|
import com.tangem.blockchain.common.Blockchain
|
||||||
|
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||||
import com.tangem.data.common.currency.CryptoCurrencyFactory
|
import com.tangem.data.common.currency.CryptoCurrencyFactory
|
||||||
import com.tangem.domain.common.TapWorkarounds.isTestCard
|
import com.tangem.domain.common.TapWorkarounds.isTestCard
|
||||||
import com.tangem.domain.common.util.cardTypesResolver
|
import com.tangem.domain.common.util.cardTypesResolver
|
||||||
|
|
@ -8,9 +9,12 @@ import com.tangem.domain.demo.DemoConfig
|
||||||
import com.tangem.domain.models.scan.ScanResponse
|
import com.tangem.domain.models.scan.ScanResponse
|
||||||
import com.tangem.domain.tokens.model.CryptoCurrency
|
import com.tangem.domain.tokens.model.CryptoCurrency
|
||||||
|
|
||||||
class CardCryptoCurrenciesFactory(private val demoConfig: DemoConfig) {
|
class CardCryptoCurrenciesFactory(
|
||||||
|
private val demoConfig: DemoConfig,
|
||||||
|
excludedBlockchains: ExcludedBlockchains,
|
||||||
|
) {
|
||||||
|
|
||||||
private val cryptoCurrencyFactory = CryptoCurrencyFactory()
|
private val cryptoCurrencyFactory = CryptoCurrencyFactory(excludedBlockchains)
|
||||||
|
|
||||||
fun createDefaultCoinsForMultiCurrencyCard(scanResponse: ScanResponse): List<CryptoCurrency.Coin> {
|
fun createDefaultCoinsForMultiCurrencyCard(scanResponse: ScanResponse): List<CryptoCurrency.Coin> {
|
||||||
val card = scanResponse.card
|
val card = scanResponse.card
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package com.tangem.domain.common.extensions
|
package com.tangem.domain.common.extensions
|
||||||
|
|
||||||
import com.tangem.blockchain.common.Blockchain
|
import com.tangem.blockchain.common.Blockchain
|
||||||
import com.tangem.blockchainsdk.utils.isSupportedInApp
|
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||||
import com.tangem.common.card.EllipticCurve
|
import com.tangem.common.card.EllipticCurve
|
||||||
import com.tangem.common.card.FirmwareVersion
|
import com.tangem.common.card.FirmwareVersion
|
||||||
import com.tangem.domain.common.CardTypesResolver
|
import com.tangem.domain.common.CardTypesResolver
|
||||||
|
|
@ -15,7 +15,10 @@ import com.tangem.domain.models.scan.CardDTO
|
||||||
val FirmwareVersion.Companion.SolanaTokensAvailable
|
val FirmwareVersion.Companion.SolanaTokensAvailable
|
||||||
get() = FirmwareVersion(4, 52)
|
get() = FirmwareVersion(4, 52)
|
||||||
|
|
||||||
fun CardDTO.supportedBlockchains(cardTypesResolver: CardTypesResolver): List<Blockchain> {
|
fun CardDTO.supportedBlockchains(
|
||||||
|
cardTypesResolver: CardTypesResolver,
|
||||||
|
excludedBlockchains: ExcludedBlockchains,
|
||||||
|
): List<Blockchain> {
|
||||||
val supportedBlockchains = if (firmwareVersion < FirmwareVersion.MultiWalletAvailable) {
|
val supportedBlockchains = if (firmwareVersion < FirmwareVersion.MultiWalletAvailable) {
|
||||||
Blockchain.fromCurve(EllipticCurve.Secp256k1).toMutableList()
|
Blockchain.fromCurve(EllipticCurve.Secp256k1).toMutableList()
|
||||||
} else if (!cardTypesResolver.isWallet2() && !cardTypesResolver.isTangemWallet()) {
|
} else if (!cardTypesResolver.isWallet2() && !cardTypesResolver.isTangemWallet()) {
|
||||||
|
|
@ -27,11 +30,14 @@ fun CardDTO.supportedBlockchains(cardTypesResolver: CardTypesResolver): List<Blo
|
||||||
}
|
}
|
||||||
return supportedBlockchains
|
return supportedBlockchains
|
||||||
.filter { isTestCard == it.isTestnet() }
|
.filter { isTestCard == it.isTestnet() }
|
||||||
.filter { it.isSupportedInApp() }
|
.filter { it !in excludedBlockchains }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun CardDTO.supportedTokens(cardTypesResolver: CardTypesResolver): List<Blockchain> {
|
fun CardDTO.supportedTokens(
|
||||||
val tokensSupportedByBlockchain = supportedBlockchains(cardTypesResolver)
|
cardTypesResolver: CardTypesResolver,
|
||||||
|
excludedBlockchains: ExcludedBlockchains,
|
||||||
|
): List<Blockchain> {
|
||||||
|
val tokensSupportedByBlockchain = supportedBlockchains(cardTypesResolver, excludedBlockchains)
|
||||||
.filter { it.canHandleTokens() }
|
.filter { it.canHandleTokens() }
|
||||||
.toMutableList()
|
.toMutableList()
|
||||||
val tokensSupportedByCard = when {
|
val tokensSupportedByCard = when {
|
||||||
|
|
@ -68,10 +74,14 @@ fun CardDTO.canHandleToken(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun CardDTO.canHandleToken(blockchain: Blockchain, cardTypesResolver: CardTypesResolver): Boolean {
|
fun CardDTO.canHandleToken(
|
||||||
|
blockchain: Blockchain,
|
||||||
|
cardTypesResolver: CardTypesResolver,
|
||||||
|
excludedBlockchains: ExcludedBlockchains,
|
||||||
|
): Boolean {
|
||||||
val cardConfig = CardConfig.createConfig(this)
|
val cardConfig = CardConfig.createConfig(this)
|
||||||
val primaryCurveForBlockchain = cardConfig.primaryCurve(blockchain)
|
val primaryCurveForBlockchain = cardConfig.primaryCurve(blockchain)
|
||||||
val isContainsBlockchain = this.supportedTokens(cardTypesResolver).contains(blockchain)
|
val isContainsBlockchain = blockchain in supportedTokens(cardTypesResolver, excludedBlockchains)
|
||||||
val isWalletForCurveExists = wallets.any { it.curve == primaryCurveForBlockchain }
|
val isWalletForCurveExists = wallets.any { it.curve == primaryCurveForBlockchain }
|
||||||
// fixme: check for first wallets with 1 curve and remove condition
|
// fixme: check for first wallets with 1 curve and remove condition
|
||||||
return if (cardTypesResolver.isTangemWallet() || cardTypesResolver.isWallet2()) {
|
return if (cardTypesResolver.isTangemWallet() || cardTypesResolver.isWallet2()) {
|
||||||
|
|
@ -82,10 +92,14 @@ fun CardDTO.canHandleToken(blockchain: Blockchain, cardTypesResolver: CardTypesR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun CardDTO.canHandleBlockchain(blockchain: Blockchain, cardTypesResolver: CardTypesResolver): Boolean {
|
fun CardDTO.canHandleBlockchain(
|
||||||
|
blockchain: Blockchain,
|
||||||
|
cardTypesResolver: CardTypesResolver,
|
||||||
|
excludedBlockchains: ExcludedBlockchains,
|
||||||
|
): Boolean {
|
||||||
val cardConfig = CardConfig.createConfig(this)
|
val cardConfig = CardConfig.createConfig(this)
|
||||||
val primaryCurveForBlockchain = cardConfig.primaryCurve(blockchain)
|
val primaryCurveForBlockchain = cardConfig.primaryCurve(blockchain)
|
||||||
val isContainsBlockchain = this.supportedBlockchains(cardTypesResolver).contains(blockchain)
|
val isContainsBlockchain = blockchain in supportedBlockchains(cardTypesResolver, excludedBlockchains)
|
||||||
val isWalletForCurveExists = wallets.any { it.curve == primaryCurveForBlockchain }
|
val isWalletForCurveExists = wallets.any { it.curve == primaryCurveForBlockchain }
|
||||||
// fixme: check for first wallets with 1 curve and remove condition
|
// fixme: check for first wallets with 1 curve and remove condition
|
||||||
return if (cardTypesResolver.isTangemWallet() || cardTypesResolver.isWallet2()) {
|
return if (cardTypesResolver.isTangemWallet() || cardTypesResolver.isWallet2()) {
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.tangem.features.markets.details.impl.model
|
||||||
import androidx.compose.runtime.Stable
|
import androidx.compose.runtime.Stable
|
||||||
import arrow.core.Either
|
import arrow.core.Either
|
||||||
import arrow.core.getOrElse
|
import arrow.core.getOrElse
|
||||||
|
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||||
import com.tangem.common.ui.charts.state.MarketChartData
|
import com.tangem.common.ui.charts.state.MarketChartData
|
||||||
import com.tangem.common.ui.charts.state.MarketChartDataProducer
|
import com.tangem.common.ui.charts.state.MarketChartDataProducer
|
||||||
import com.tangem.common.ui.charts.state.sorted
|
import com.tangem.common.ui.charts.state.sorted
|
||||||
|
|
@ -64,6 +65,7 @@ internal class MarketsTokenDetailsModel @Inject constructor(
|
||||||
private val sendFeedbackEmailUseCase: SendFeedbackEmailUseCase,
|
private val sendFeedbackEmailUseCase: SendFeedbackEmailUseCase,
|
||||||
private val urlOpener: UrlOpener,
|
private val urlOpener: UrlOpener,
|
||||||
private val analyticsEventHandler: AnalyticsEventHandler,
|
private val analyticsEventHandler: AnalyticsEventHandler,
|
||||||
|
private val excludedBlockchains: ExcludedBlockchains,
|
||||||
) : Model() {
|
) : Model() {
|
||||||
|
|
||||||
private var quotesJob = JobHolder()
|
private var quotesJob = JobHolder()
|
||||||
|
|
@ -400,7 +402,7 @@ internal class MarketsTokenDetailsModel @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
val networks = newInfo.networks?.filter {
|
val networks = newInfo.networks?.filter {
|
||||||
BlockchainUtils.isSupportedNetworkId(it.networkId)
|
BlockchainUtils.isSupportedNetworkId(it.networkId, excludedBlockchains)
|
||||||
}
|
}
|
||||||
|
|
||||||
networksState.value = if (networks.isNullOrEmpty()) {
|
networksState.value = if (networks.isNullOrEmpty()) {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.tangem.feature.referral.data
|
||||||
|
|
||||||
import com.tangem.blockchain.common.Blockchain
|
import com.tangem.blockchain.common.Blockchain
|
||||||
import com.tangem.blockchain.common.Token
|
import com.tangem.blockchain.common.Token
|
||||||
|
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||||
import com.tangem.blockchainsdk.utils.fromNetworkId
|
import com.tangem.blockchainsdk.utils.fromNetworkId
|
||||||
import com.tangem.data.common.currency.CryptoCurrencyFactory
|
import com.tangem.data.common.currency.CryptoCurrencyFactory
|
||||||
import com.tangem.datasource.api.tangemTech.TangemTechApi
|
import com.tangem.datasource.api.tangemTech.TangemTechApi
|
||||||
|
|
@ -18,14 +19,18 @@ import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@Suppress("LongParameterList")
|
||||||
internal class ReferralRepositoryImpl @Inject constructor(
|
internal class ReferralRepositoryImpl @Inject constructor(
|
||||||
private val referralApi: TangemTechApi,
|
private val referralApi: TangemTechApi,
|
||||||
private val referralConverter: ReferralConverter,
|
private val referralConverter: ReferralConverter,
|
||||||
private val coroutineDispatcher: CoroutineDispatcherProvider,
|
private val coroutineDispatcher: CoroutineDispatcherProvider,
|
||||||
private val demoModeDatasource: DemoModeDatasource,
|
private val demoModeDatasource: DemoModeDatasource,
|
||||||
private val userWalletsStore: UserWalletsStore,
|
private val userWalletsStore: UserWalletsStore,
|
||||||
|
excludedBlockchains: ExcludedBlockchains,
|
||||||
) : ReferralRepository {
|
) : ReferralRepository {
|
||||||
|
|
||||||
|
private val cryptoCurrencyFactory = CryptoCurrencyFactory(excludedBlockchains)
|
||||||
|
|
||||||
override val isDemoMode: Boolean
|
override val isDemoMode: Boolean
|
||||||
get() = demoModeDatasource.isDemoModeActive
|
get() = demoModeDatasource.isDemoModeActive
|
||||||
|
|
||||||
|
|
@ -65,8 +70,6 @@ internal class ReferralRepositoryImpl @Inject constructor(
|
||||||
val blockchain = Blockchain.fromNetworkId(tokenData.networkId)
|
val blockchain = Blockchain.fromNetworkId(tokenData.networkId)
|
||||||
?: error("Blockchain ${tokenData.networkId} not found")
|
?: error("Blockchain ${tokenData.networkId} not found")
|
||||||
|
|
||||||
val cryptoCurrencyFactory = CryptoCurrencyFactory()
|
|
||||||
|
|
||||||
val contractAddress = tokenData.contractAddress
|
val contractAddress = tokenData.contractAddress
|
||||||
val decimalCount = tokenData.decimalCount
|
val decimalCount = tokenData.decimalCount
|
||||||
return if (contractAddress != null && decimalCount != null) {
|
return if (contractAddress != null && decimalCount != null) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.tangem.feature.referral.di
|
package com.tangem.feature.referral.di
|
||||||
|
|
||||||
|
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||||
import com.tangem.datasource.api.tangemTech.TangemTechApi
|
import com.tangem.datasource.api.tangemTech.TangemTechApi
|
||||||
import com.tangem.datasource.demo.DemoModeDatasource
|
import com.tangem.datasource.demo.DemoModeDatasource
|
||||||
import com.tangem.datasource.local.userwallet.UserWalletsStore
|
import com.tangem.datasource.local.userwallet.UserWalletsStore
|
||||||
|
|
@ -25,6 +26,7 @@ class ReferralRepositoryModule {
|
||||||
coroutineDispatcherProvider: CoroutineDispatcherProvider,
|
coroutineDispatcherProvider: CoroutineDispatcherProvider,
|
||||||
demoModeDatasource: DemoModeDatasource,
|
demoModeDatasource: DemoModeDatasource,
|
||||||
userWalletsStore: UserWalletsStore,
|
userWalletsStore: UserWalletsStore,
|
||||||
|
excludedBlockchains: ExcludedBlockchains,
|
||||||
): ReferralRepository {
|
): ReferralRepository {
|
||||||
return ReferralRepositoryImpl(
|
return ReferralRepositoryImpl(
|
||||||
referralApi = tangemTechApi,
|
referralApi = tangemTechApi,
|
||||||
|
|
@ -32,6 +34,7 @@ class ReferralRepositoryModule {
|
||||||
coroutineDispatcher = coroutineDispatcherProvider,
|
coroutineDispatcher = coroutineDispatcherProvider,
|
||||||
demoModeDatasource = demoModeDatasource,
|
demoModeDatasource = demoModeDatasource,
|
||||||
userWalletsStore = userWalletsStore,
|
userWalletsStore = userWalletsStore,
|
||||||
|
excludedBlockchains = excludedBlockchains,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -7,6 +7,7 @@ import arrow.core.raise.either
|
||||||
import arrow.core.right
|
import arrow.core.right
|
||||||
import com.squareup.moshi.Moshi
|
import com.squareup.moshi.Moshi
|
||||||
import com.tangem.blockchain.common.*
|
import com.tangem.blockchain.common.*
|
||||||
|
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||||
import com.tangem.blockchainsdk.utils.fromNetworkId
|
import com.tangem.blockchainsdk.utils.fromNetworkId
|
||||||
import com.tangem.data.common.currency.CryptoCurrencyFactory
|
import com.tangem.data.common.currency.CryptoCurrencyFactory
|
||||||
import com.tangem.datasource.api.common.response.ApiResponse
|
import com.tangem.datasource.api.common.response.ApiResponse
|
||||||
|
|
@ -48,12 +49,13 @@ internal class DefaultSwapRepository(
|
||||||
private val errorsDataConverter: ErrorsDataConverter,
|
private val errorsDataConverter: ErrorsDataConverter,
|
||||||
private val dataSignatureVerifier: DataSignatureVerifier,
|
private val dataSignatureVerifier: DataSignatureVerifier,
|
||||||
moshi: Moshi,
|
moshi: Moshi,
|
||||||
|
excludedBlockchains: ExcludedBlockchains,
|
||||||
) : SwapRepository {
|
) : SwapRepository {
|
||||||
|
|
||||||
private val expressDataConverter = ExpressDataConverter()
|
private val expressDataConverter = ExpressDataConverter()
|
||||||
private val leastTokenInfoConverter = LeastTokenInfoConverter()
|
private val leastTokenInfoConverter = LeastTokenInfoConverter()
|
||||||
private val swapPairInfoConverter = SwapPairInfoConverter()
|
private val swapPairInfoConverter = SwapPairInfoConverter()
|
||||||
private val cryptoCurrencyFactory = CryptoCurrencyFactory()
|
private val cryptoCurrencyFactory = CryptoCurrencyFactory(excludedBlockchains)
|
||||||
private val exchangeStatusConverter = ExchangeStatusConverter()
|
private val exchangeStatusConverter = ExchangeStatusConverter()
|
||||||
private val txDetailsMoshiAdapter = moshi.adapter(TxDetails::class.java)
|
private val txDetailsMoshiAdapter = moshi.adapter(TxDetails::class.java)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.tangem.feature.swap
|
package com.tangem.feature.swap
|
||||||
|
|
||||||
|
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||||
import com.tangem.datasource.local.preferences.AppPreferencesStore
|
import com.tangem.datasource.local.preferences.AppPreferencesStore
|
||||||
import com.tangem.datasource.local.preferences.PreferencesKeys
|
import com.tangem.datasource.local.preferences.PreferencesKeys
|
||||||
import com.tangem.datasource.local.preferences.utils.getObjectList
|
import com.tangem.datasource.local.preferences.utils.getObjectList
|
||||||
|
|
@ -18,12 +19,13 @@ import kotlinx.coroutines.flow.flowOn
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
|
|
||||||
class DefaultSwapTransactionRepository(
|
internal class DefaultSwapTransactionRepository(
|
||||||
private val appPreferencesStore: AppPreferencesStore,
|
private val appPreferencesStore: AppPreferencesStore,
|
||||||
private val dispatchers: CoroutineDispatcherProvider,
|
private val dispatchers: CoroutineDispatcherProvider,
|
||||||
|
excludedBlockchains: ExcludedBlockchains,
|
||||||
) : SwapTransactionRepository {
|
) : SwapTransactionRepository {
|
||||||
|
|
||||||
private val converter = SavedSwapTransactionListConverter()
|
private val converter = SavedSwapTransactionListConverter(excludedBlockchains)
|
||||||
|
|
||||||
override suspend fun storeTransaction(
|
override suspend fun storeTransaction(
|
||||||
userWalletId: UserWalletId,
|
userWalletId: UserWalletId,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.tangem.feature.swap.converters
|
package com.tangem.feature.swap.converters
|
||||||
|
|
||||||
|
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||||
import com.tangem.data.common.currency.ResponseCryptoCurrenciesFactory
|
import com.tangem.data.common.currency.ResponseCryptoCurrenciesFactory
|
||||||
import com.tangem.data.common.currency.UserTokensResponseFactory
|
import com.tangem.data.common.currency.UserTokensResponseFactory
|
||||||
import com.tangem.domain.models.scan.ScanResponse
|
import com.tangem.domain.models.scan.ScanResponse
|
||||||
|
|
@ -11,10 +12,11 @@ import com.tangem.feature.swap.domain.models.domain.SavedSwapTransactionListMode
|
||||||
import com.tangem.feature.swap.domain.models.domain.SavedSwapTransactionModel
|
import com.tangem.feature.swap.domain.models.domain.SavedSwapTransactionModel
|
||||||
import com.tangem.utils.converter.Converter
|
import com.tangem.utils.converter.Converter
|
||||||
|
|
||||||
class SavedSwapTransactionListConverter :
|
internal class SavedSwapTransactionListConverter(
|
||||||
Converter<SavedSwapTransactionListModel, SavedSwapTransactionListModelInner> {
|
excludedBlockchains: ExcludedBlockchains,
|
||||||
|
) : Converter<SavedSwapTransactionListModel, SavedSwapTransactionListModelInner> {
|
||||||
|
|
||||||
private val responseCryptoCurrenciesFactory = ResponseCryptoCurrenciesFactory()
|
private val responseCryptoCurrenciesFactory = ResponseCryptoCurrenciesFactory(excludedBlockchains)
|
||||||
private val userTokensResponseFactory = UserTokensResponseFactory()
|
private val userTokensResponseFactory = UserTokensResponseFactory()
|
||||||
|
|
||||||
override fun convert(value: SavedSwapTransactionListModel) = SavedSwapTransactionListModelInner(
|
override fun convert(value: SavedSwapTransactionListModel) = SavedSwapTransactionListModelInner(
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.tangem.feature.swap.di
|
package com.tangem.feature.swap.di
|
||||||
|
|
||||||
import com.squareup.moshi.Moshi
|
import com.squareup.moshi.Moshi
|
||||||
|
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||||
import com.tangem.datasource.api.express.TangemExpressApi
|
import com.tangem.datasource.api.express.TangemExpressApi
|
||||||
import com.tangem.datasource.api.express.models.response.ExpressErrorResponse
|
import com.tangem.datasource.api.express.models.response.ExpressErrorResponse
|
||||||
import com.tangem.datasource.crypto.DataSignatureVerifier
|
import com.tangem.datasource.crypto.DataSignatureVerifier
|
||||||
|
|
@ -34,6 +35,7 @@ internal class SwapDataModule {
|
||||||
userWalletsListManager: UserWalletsListManager,
|
userWalletsListManager: UserWalletsListManager,
|
||||||
errorsDataConverter: ErrorsDataConverter,
|
errorsDataConverter: ErrorsDataConverter,
|
||||||
@NetworkMoshi moshi: Moshi,
|
@NetworkMoshi moshi: Moshi,
|
||||||
|
excludedBlockchains: ExcludedBlockchains,
|
||||||
): SwapRepository {
|
): SwapRepository {
|
||||||
return DefaultSwapRepository(
|
return DefaultSwapRepository(
|
||||||
tangemExpressApi = tangemExpressApi,
|
tangemExpressApi = tangemExpressApi,
|
||||||
|
|
@ -43,6 +45,7 @@ internal class SwapDataModule {
|
||||||
errorsDataConverter = errorsDataConverter,
|
errorsDataConverter = errorsDataConverter,
|
||||||
dataSignatureVerifier = dataSignature,
|
dataSignatureVerifier = dataSignature,
|
||||||
moshi = moshi,
|
moshi = moshi,
|
||||||
|
excludedBlockchains = excludedBlockchains,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -51,10 +54,12 @@ internal class SwapDataModule {
|
||||||
fun provideSwapTransactionRepository(
|
fun provideSwapTransactionRepository(
|
||||||
appPreferencesStore: AppPreferencesStore,
|
appPreferencesStore: AppPreferencesStore,
|
||||||
dispatcherProvider: CoroutineDispatcherProvider,
|
dispatcherProvider: CoroutineDispatcherProvider,
|
||||||
|
excludedBlockchains: ExcludedBlockchains,
|
||||||
): SwapTransactionRepository {
|
): SwapTransactionRepository {
|
||||||
return DefaultSwapTransactionRepository(
|
return DefaultSwapTransactionRepository(
|
||||||
appPreferencesStore = appPreferencesStore,
|
appPreferencesStore = appPreferencesStore,
|
||||||
dispatchers = dispatcherProvider,
|
dispatchers = dispatcherProvider,
|
||||||
|
excludedBlockchains = excludedBlockchains,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -387,10 +387,6 @@ fun Blockchain.toMigratedCointId(): String = when (this) {
|
||||||
else -> toCoinId()
|
else -> toCoinId()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Blockchain.isSupportedInApp(): Boolean {
|
|
||||||
return !excludedBlockchains.contains(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Blockchain.amountToCreateAccount(token: Token? = null): BigDecimal? {
|
fun Blockchain.amountToCreateAccount(token: Token? = null): BigDecimal? {
|
||||||
return when (this) {
|
return when (this) {
|
||||||
Blockchain.Stellar -> if (token?.symbol == NODL) BigDecimal(NODL_AMOUNT_TO_CREATE_ACCOUNT) else BigDecimal.ONE
|
Blockchain.Stellar -> if (token?.symbol == NODL) BigDecimal(NODL_AMOUNT_TO_CREATE_ACCOUNT) else BigDecimal.ONE
|
||||||
|
|
@ -409,11 +405,4 @@ fun Blockchain.minimalAmount(): BigDecimal {
|
||||||
}
|
}
|
||||||
|
|
||||||
private const val NODL = "NODL"
|
private const val NODL = "NODL"
|
||||||
private const val NODL_AMOUNT_TO_CREATE_ACCOUNT = 1.5
|
private const val NODL_AMOUNT_TO_CREATE_ACCOUNT = 1.5
|
||||||
|
|
||||||
// no need to add testnets
|
|
||||||
private val excludedBlockchains = listOf(
|
|
||||||
Blockchain.Unknown,
|
|
||||||
Blockchain.Nexa,
|
|
||||||
Blockchain.NexaTestnet,
|
|
||||||
)
|
|
||||||
|
|
@ -3,8 +3,8 @@ package com.tangem.lib.crypto
|
||||||
import com.tangem.blockchain.blockchains.xrp.XrpAddressService
|
import com.tangem.blockchain.blockchains.xrp.XrpAddressService
|
||||||
import com.tangem.blockchain.common.Blockchain
|
import com.tangem.blockchain.common.Blockchain
|
||||||
import com.tangem.blockchainsdk.compatibility.l2BlockchainsList
|
import com.tangem.blockchainsdk.compatibility.l2BlockchainsList
|
||||||
|
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||||
import com.tangem.blockchainsdk.utils.fromNetworkId
|
import com.tangem.blockchainsdk.utils.fromNetworkId
|
||||||
import com.tangem.blockchainsdk.utils.isSupportedInApp
|
|
||||||
import com.tangem.lib.crypto.converter.XrpTaggedAddressConverter
|
import com.tangem.lib.crypto.converter.XrpTaggedAddressConverter
|
||||||
import com.tangem.lib.crypto.models.XrpTaggedAddress
|
import com.tangem.lib.crypto.models.XrpTaggedAddress
|
||||||
|
|
||||||
|
|
@ -64,8 +64,10 @@ object BlockchainUtils {
|
||||||
return blockchain == Blockchain.Tron || blockchain == Blockchain.TronTestnet
|
return blockchain == Blockchain.Tron || blockchain == Blockchain.TronTestnet
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isSupportedNetworkId(blockchainId: String): Boolean {
|
fun isSupportedNetworkId(blockchainId: String, excludedBlockchains: ExcludedBlockchains): Boolean {
|
||||||
return Blockchain.fromNetworkId(blockchainId)?.isSupportedInApp() ?: false
|
val blockchain = Blockchain.fromNetworkId(blockchainId)
|
||||||
|
|
||||||
|
return blockchain != null && blockchain !in excludedBlockchains
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isArbitrum(blockchainId: String): Boolean {
|
fun isArbitrum(blockchainId: String): Boolean {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue