Updated on 2026-08-14

This commit is contained in:
Tangem 2025-04-02 17:54:38 +05:00
parent 28d15c9043
commit a4eb7fce06
6 changed files with 41 additions and 38 deletions

View file

@ -108,25 +108,19 @@ internal class DefaultStakingRepository(
return integrationIdMap.getOrDefault(getIntegrationKey(cryptoCurrencyId), null)
}
override suspend fun fetchEnabledYields(refresh: Boolean) {
override suspend fun fetchEnabledYields() {
withContext(dispatchers.io) {
cacheRegistry.invokeOnExpire(
key = YIELDS_STORE_KEY,
skipCache = refresh,
block = {
when (val stakingTokensWithYields = stakeKitApi.getEnabledYields(preferredValidatorsOnly = false)) {
is ApiResponse.Success -> stakingYieldsStore.store(
stakingTokensWithYields.data.data.filter {
it.isAvailable ?: false
},
)
else -> {
stakingYieldsStore.store(emptyList())
throw (stakingTokensWithYields as ApiResponse.Error).cause
}
}
},
)
when (val stakingTokensWithYields = stakeKitApi.getEnabledYields(preferredValidatorsOnly = false)) {
is ApiResponse.Success -> stakingYieldsStore.store(
stakingTokensWithYields.data.data.filter {
it.isAvailable ?: false
},
)
else -> {
stakingYieldsStore.store(emptyList())
throw (stakingTokensWithYields as ApiResponse.Error).cause
}
}
}
}