Updated on 2026-08-14
This commit is contained in:
parent
67be280129
commit
deb6d570b0
20 changed files with 111 additions and 105 deletions
|
|
@ -111,7 +111,7 @@ internal class DefaultStakingRepository(
|
|||
rawNetworkId.plus(rawCurrencyId)
|
||||
}
|
||||
|
||||
override fun isStakingSupported(integrationKey: String): Boolean {
|
||||
override fun isStakingSupportedInMobileApp(integrationKey: String): Boolean {
|
||||
return integrationIdMap.containsKey(integrationKey)
|
||||
}
|
||||
|
||||
|
|
@ -121,7 +121,7 @@ internal class DefaultStakingRepository(
|
|||
key = YIELDS_STORE_KEY,
|
||||
skipCache = refresh,
|
||||
block = {
|
||||
val stakingTokensWithYields = stakeKitApi.getMultipleYields(preferredValidatorsOnly = true)
|
||||
val stakingTokensWithYields = stakeKitApi.getEnabledYields(preferredValidatorsOnly = true)
|
||||
.getOrThrow()
|
||||
|
||||
stakingYieldsStore.store(stakingTokensWithYields.data)
|
||||
|
|
@ -166,17 +166,22 @@ internal class DefaultStakingRepository(
|
|||
val rawCurrencyId = cryptoCurrency.id.rawCurrencyId ?: return StakingAvailability.Unavailable
|
||||
|
||||
return withContext(dispatchers.io) {
|
||||
val yields = getEnabledYields() ?: return@withContext StakingAvailability.Unavailable
|
||||
val isSupportedInMobileApp = isStakingSupportedInMobileApp(getIntegrationKey(cryptoCurrency.id))
|
||||
|
||||
val yields = getEnabledYields() ?: return@withContext if (isSupportedInMobileApp) {
|
||||
StakingAvailability.TemporaryUnavailable
|
||||
} else {
|
||||
StakingAvailability.Unavailable
|
||||
}
|
||||
|
||||
val prefetchedYield = findPrefetchedYield(yields, rawCurrencyId, cryptoCurrency.symbol)
|
||||
val isSupported = isStakingSupported(getIntegrationKey(cryptoCurrency.id))
|
||||
|
||||
when {
|
||||
prefetchedYield != null && isSupported -> {
|
||||
prefetchedYield != null && isSupportedInMobileApp -> {
|
||||
StakingAvailability.Available(prefetchedYield.id)
|
||||
}
|
||||
prefetchedYield == null && isSupported -> {
|
||||
StakingAvailability.TemporaryDisabled
|
||||
prefetchedYield == null && isSupportedInMobileApp -> {
|
||||
StakingAvailability.TemporaryUnavailable
|
||||
}
|
||||
else -> StakingAvailability.Unavailable
|
||||
}
|
||||
|
|
@ -336,8 +341,13 @@ internal class DefaultStakingRepository(
|
|||
val integrationId = integrationIdMap[getIntegrationKey(cryptoCurrency.id)]
|
||||
?: error("Could not get integrationId")
|
||||
stakingBalanceStore.get(userWalletId, address, integrationId)
|
||||
.distinctUntilChanged()
|
||||
.collectLatest {
|
||||
send(yieldBalanceConverter.convert(it))
|
||||
if (it != null) {
|
||||
send(yieldBalanceConverter.convert(it))
|
||||
} else {
|
||||
error("No yield balance available for currency ${cryptoCurrency.id.value}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -385,12 +395,13 @@ internal class DefaultStakingRepository(
|
|||
key = getYieldBalancesKey(userWalletId),
|
||||
skipCache = refresh,
|
||||
block = {
|
||||
val yields = getEnabledYields() ?: error("No yields found")
|
||||
val availableCurrencies = cryptoCurrencies
|
||||
.mapNotNull { currency ->
|
||||
val addresses = walletManagersFacade.getAddresses(userWalletId, currency.network)
|
||||
val integrationId = integrationIdMap[getIntegrationKey(currency.id)]
|
||||
|
||||
if (integrationId != null) {
|
||||
if (integrationId != null && yields.any { it.id == integrationId }) {
|
||||
addresses to integrationId
|
||||
} else {
|
||||
null
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue