Updated on 2026-08-14
This commit is contained in:
parent
074b16c721
commit
d33f340540
6 changed files with 7 additions and 46 deletions
|
|
@ -7,14 +7,7 @@
|
||||||
"name": "VISA_ONBOARDING_ENABLED",
|
"name": "VISA_ONBOARDING_ENABLED",
|
||||||
"version": "undefined"
|
"version": "undefined"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "STAKING_TON_ENABLED",
|
|
||||||
"version": "5.28.0"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "STAKING_CARDANO_ENABLED",
|
|
||||||
"version": "5.31.1"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "STAKING_ETH_ENABLED",
|
"name": "STAKING_ETH_ENABLED",
|
||||||
"version": "undefined"
|
"version": "undefined"
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,9 @@ import com.tangem.domain.walletmanager.WalletManagersFacade
|
||||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||||
import kotlinx.coroutines.async
|
import kotlinx.coroutines.async
|
||||||
import kotlinx.coroutines.awaitAll
|
import kotlinx.coroutines.awaitAll
|
||||||
import kotlinx.coroutines.flow.*
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||||
|
import kotlinx.coroutines.flow.map
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
|
||||||
|
|
@ -161,10 +163,6 @@ internal class DefaultStakeKitRepository(
|
||||||
|
|
||||||
private fun getAvailableStakeKitIntegrationsIds(): List<StakingIntegrationID.StakeKit> {
|
private fun getAvailableStakeKitIntegrationsIds(): List<StakingIntegrationID.StakeKit> {
|
||||||
return StakingIntegrationID.StakeKit.entries
|
return StakingIntegrationID.StakeKit.entries
|
||||||
// load all integrations for now and filter in use cases if needed
|
|
||||||
// .filterNot {
|
|
||||||
// it.blockchain == Blockchain.Cardano && !stakingFeatureToggles.isCardanoStakingEnabled
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun NetworkTypeDTO.extractJsonName(): String {
|
private fun NetworkTypeDTO.extractJsonName(): String {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import com.tangem.data.staking.store.StakeKitBalancesStore
|
||||||
import com.tangem.domain.card.common.TapWorkarounds.isWallet2
|
import com.tangem.domain.card.common.TapWorkarounds.isWallet2
|
||||||
import com.tangem.domain.models.currency.CryptoCurrency
|
import com.tangem.domain.models.currency.CryptoCurrency
|
||||||
import com.tangem.domain.models.staking.StakingBalance
|
import com.tangem.domain.models.staking.StakingBalance
|
||||||
import com.tangem.domain.models.staking.StakingID
|
|
||||||
import com.tangem.domain.models.wallet.UserWallet
|
import com.tangem.domain.models.wallet.UserWallet
|
||||||
import com.tangem.domain.models.wallet.UserWalletId
|
import com.tangem.domain.models.wallet.UserWalletId
|
||||||
import com.tangem.domain.staking.model.StakingAvailability
|
import com.tangem.domain.staking.model.StakingAvailability
|
||||||
|
|
@ -16,7 +15,6 @@ import com.tangem.domain.staking.repositories.P2PEthPoolRepository
|
||||||
import com.tangem.domain.staking.repositories.StakeKitRepository
|
import com.tangem.domain.staking.repositories.StakeKitRepository
|
||||||
import com.tangem.domain.staking.repositories.StakingRepository
|
import com.tangem.domain.staking.repositories.StakingRepository
|
||||||
import com.tangem.domain.staking.toggles.StakingFeatureToggles
|
import com.tangem.domain.staking.toggles.StakingFeatureToggles
|
||||||
import com.tangem.domain.walletmanager.WalletManagersFacade
|
|
||||||
import com.tangem.domain.wallets.usecase.GetUserWalletUseCase
|
import com.tangem.domain.wallets.usecase.GetUserWalletUseCase
|
||||||
import com.tangem.lib.crypto.BlockchainUtils.isCardano
|
import com.tangem.lib.crypto.BlockchainUtils.isCardano
|
||||||
import com.tangem.lib.crypto.BlockchainUtils.isSolana
|
import com.tangem.lib.crypto.BlockchainUtils.isSolana
|
||||||
|
|
@ -34,7 +32,6 @@ internal class DefaultStakingRepository(
|
||||||
private val dispatchers: CoroutineDispatcherProvider,
|
private val dispatchers: CoroutineDispatcherProvider,
|
||||||
private val getUserWalletUseCase: GetUserWalletUseCase,
|
private val getUserWalletUseCase: GetUserWalletUseCase,
|
||||||
private val stakingFeatureToggles: StakingFeatureToggles,
|
private val stakingFeatureToggles: StakingFeatureToggles,
|
||||||
private val walletManagersFacade: WalletManagersFacade,
|
|
||||||
) : StakingRepository {
|
) : StakingRepository {
|
||||||
|
|
||||||
override fun getStakingAvailability(
|
override fun getStakingAvailability(
|
||||||
|
|
@ -42,7 +39,7 @@ internal class DefaultStakingRepository(
|
||||||
cryptoCurrency: CryptoCurrency,
|
cryptoCurrency: CryptoCurrency,
|
||||||
): Flow<StakingAvailability> {
|
): Flow<StakingAvailability> {
|
||||||
return channelFlow {
|
return channelFlow {
|
||||||
if (!checkFeatureToggleEnabled(userWalletId, cryptoCurrency)) {
|
if (!checkFeatureToggleEnabled(cryptoCurrency)) {
|
||||||
send(StakingAvailability.Unavailable)
|
send(StakingAvailability.Unavailable)
|
||||||
return@channelFlow
|
return@channelFlow
|
||||||
}
|
}
|
||||||
|
|
@ -78,7 +75,7 @@ internal class DefaultStakingRepository(
|
||||||
userWalletId: UserWalletId,
|
userWalletId: UserWalletId,
|
||||||
cryptoCurrency: CryptoCurrency,
|
cryptoCurrency: CryptoCurrency,
|
||||||
): StakingAvailability {
|
): StakingAvailability {
|
||||||
if (!checkFeatureToggleEnabled(userWalletId, cryptoCurrency)) {
|
if (!checkFeatureToggleEnabled(cryptoCurrency)) {
|
||||||
return StakingAvailability.Unavailable
|
return StakingAvailability.Unavailable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -118,31 +115,14 @@ internal class DefaultStakingRepository(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun checkFeatureToggleEnabled(userWalletId: UserWalletId, cryptoCurrency: CryptoCurrency): Boolean {
|
private fun checkFeatureToggleEnabled(cryptoCurrency: CryptoCurrency): Boolean {
|
||||||
return when (cryptoCurrency.network.id.toBlockchain()) {
|
return when (cryptoCurrency.network.id.toBlockchain()) {
|
||||||
Blockchain.TON -> stakingFeatureToggles.isTonStakingEnabled
|
|
||||||
Blockchain.Ethereum -> {
|
Blockchain.Ethereum -> {
|
||||||
when (cryptoCurrency) {
|
when (cryptoCurrency) {
|
||||||
is CryptoCurrency.Coin -> stakingFeatureToggles.isEthStakingEnabled
|
is CryptoCurrency.Coin -> stakingFeatureToggles.isEthStakingEnabled
|
||||||
is CryptoCurrency.Token -> true
|
is CryptoCurrency.Token -> true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Blockchain.Cardano -> {
|
|
||||||
val address = walletManagersFacade.getDefaultAddress(userWalletId, cryptoCurrency.network).orEmpty()
|
|
||||||
val balance = stakingBalanceStoreV2.getSyncOrNull(
|
|
||||||
userWalletId = userWalletId,
|
|
||||||
stakingId = StakingID(
|
|
||||||
integrationId = StakingIntegrationID.create(currencyId = cryptoCurrency.id)?.value
|
|
||||||
?: return false,
|
|
||||||
address = address,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
if ((balance as? StakingBalance.Data.StakeKit)?.balance?.items?.isNotEmpty() == true) {
|
|
||||||
return true
|
|
||||||
} else {
|
|
||||||
stakingFeatureToggles.isCardanoStakingEnabled
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else -> true
|
else -> true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,6 @@ internal object StakingDataModule {
|
||||||
dispatchers: CoroutineDispatcherProvider,
|
dispatchers: CoroutineDispatcherProvider,
|
||||||
getUserWalletUseCase: GetUserWalletUseCase,
|
getUserWalletUseCase: GetUserWalletUseCase,
|
||||||
stakingFeatureToggles: StakingFeatureToggles,
|
stakingFeatureToggles: StakingFeatureToggles,
|
||||||
walletManagersFacade: WalletManagersFacade,
|
|
||||||
): StakingRepository {
|
): StakingRepository {
|
||||||
return DefaultStakingRepository(
|
return DefaultStakingRepository(
|
||||||
stakeKitRepository = stakeKitRepository,
|
stakeKitRepository = stakeKitRepository,
|
||||||
|
|
@ -69,7 +68,6 @@ internal object StakingDataModule {
|
||||||
stakingBalanceStoreV2 = stakeKitBalancesStore,
|
stakingBalanceStoreV2 = stakeKitBalancesStore,
|
||||||
dispatchers = dispatchers,
|
dispatchers = dispatchers,
|
||||||
getUserWalletUseCase = getUserWalletUseCase,
|
getUserWalletUseCase = getUserWalletUseCase,
|
||||||
walletManagersFacade = walletManagersFacade,
|
|
||||||
stakingFeatureToggles = stakingFeatureToggles,
|
stakingFeatureToggles = stakingFeatureToggles,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,6 @@ internal class DefaultStakingFeatureToggles(
|
||||||
private val featureTogglesManager: FeatureTogglesManager,
|
private val featureTogglesManager: FeatureTogglesManager,
|
||||||
) : StakingFeatureToggles {
|
) : StakingFeatureToggles {
|
||||||
|
|
||||||
override val isTonStakingEnabled: Boolean
|
|
||||||
get() = featureTogglesManager.isFeatureEnabled(name = "STAKING_TON_ENABLED")
|
|
||||||
|
|
||||||
override val isCardanoStakingEnabled: Boolean
|
|
||||||
get() = featureTogglesManager.isFeatureEnabled("STAKING_CARDANO_ENABLED")
|
|
||||||
|
|
||||||
override val isEthStakingEnabled: Boolean
|
override val isEthStakingEnabled: Boolean
|
||||||
get() = featureTogglesManager.isFeatureEnabled("STAKING_ETH_ENABLED")
|
get() = featureTogglesManager.isFeatureEnabled("STAKING_ETH_ENABLED")
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
package com.tangem.domain.staking.toggles
|
package com.tangem.domain.staking.toggles
|
||||||
|
|
||||||
interface StakingFeatureToggles {
|
interface StakingFeatureToggles {
|
||||||
val isTonStakingEnabled: Boolean
|
|
||||||
val isCardanoStakingEnabled: Boolean
|
|
||||||
val isEthStakingEnabled: Boolean
|
val isEthStakingEnabled: Boolean
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue