Updated on 2026-08-14
This commit is contained in:
parent
455455006d
commit
63910410c4
3 changed files with 43 additions and 19 deletions
|
|
@ -35,6 +35,7 @@ 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.staking.NetworkType
|
||||
import com.tangem.domain.models.staking.StakingID
|
||||
import com.tangem.domain.models.staking.YieldBalance
|
||||
import com.tangem.domain.models.staking.action.StakingActionType
|
||||
import com.tangem.domain.models.wallet.UserWallet
|
||||
|
|
@ -174,9 +175,11 @@ internal class DefaultStakingRepository(
|
|||
}
|
||||
|
||||
private fun getAvailableIntegrationsIds(): List<StakingIntegrationID> {
|
||||
return StakingIntegrationID.entries.filterNot {
|
||||
it.blockchain == Blockchain.Cardano && !stakingFeatureToggles.isCardanoStakingEnabled
|
||||
}
|
||||
return StakingIntegrationID.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 {
|
||||
|
|
@ -208,7 +211,7 @@ internal class DefaultStakingRepository(
|
|||
cryptoCurrency: CryptoCurrency,
|
||||
): Flow<StakingAvailability> {
|
||||
return channelFlow {
|
||||
if (!checkFeatureToggleEnabled(cryptoCurrency.network.id)) {
|
||||
if (!checkFeatureToggleEnabled(userWalletId, cryptoCurrency)) {
|
||||
send(StakingAvailability.Unavailable)
|
||||
return@channelFlow
|
||||
}
|
||||
|
|
@ -257,7 +260,7 @@ internal class DefaultStakingRepository(
|
|||
userWalletId: UserWalletId,
|
||||
cryptoCurrency: CryptoCurrency,
|
||||
): StakingAvailability {
|
||||
if (!checkFeatureToggleEnabled(cryptoCurrency.network.id)) {
|
||||
if (!checkFeatureToggleEnabled(userWalletId, cryptoCurrency)) {
|
||||
return StakingAvailability.Unavailable
|
||||
}
|
||||
|
||||
|
|
@ -294,10 +297,25 @@ internal class DefaultStakingRepository(
|
|||
}
|
||||
}
|
||||
|
||||
private fun checkFeatureToggleEnabled(networkId: Network.ID): Boolean {
|
||||
return when (networkId.toBlockchain()) {
|
||||
private suspend fun checkFeatureToggleEnabled(userWalletId: UserWalletId, cryptoCurrency: CryptoCurrency): Boolean {
|
||||
return when (cryptoCurrency.network.id.toBlockchain()) {
|
||||
Blockchain.TON -> stakingFeatureToggles.isTonStakingEnabled
|
||||
Blockchain.Cardano -> stakingFeatureToggles.isCardanoStakingEnabled
|
||||
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 != null && balance is YieldBalance.Data && balance.balance.items.isNotEmpty()) {
|
||||
return true
|
||||
} else {
|
||||
stakingFeatureToggles.isCardanoStakingEnabled
|
||||
}
|
||||
}
|
||||
else -> true
|
||||
}
|
||||
}
|
||||
|
|
@ -490,13 +508,6 @@ internal class DefaultStakingRepository(
|
|||
}
|
||||
|
||||
private fun findPrefetchedYield(yields: List<Yield>, currencyId: CryptoCurrency.RawID, symbol: String): Yield? {
|
||||
if (!stakingFeatureToggles.isCardanoStakingEnabled && symbol.equals(
|
||||
Blockchain.Cardano.currency,
|
||||
ignoreCase = true,
|
||||
)
|
||||
) {
|
||||
return null
|
||||
}
|
||||
return yields.find { yield ->
|
||||
yield.tokens.any { it.coinGeckoId == currencyId.value && it.symbol == symbol }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue