Updated on 2026-08-14

This commit is contained in:
Tangem 2025-03-03 16:45:50 +04:00
parent ca286232ba
commit a10b94fa45
6 changed files with 75 additions and 16 deletions

View file

@ -403,13 +403,31 @@ internal class DefaultStakingRepository(
?: YieldBalance.Error(integrationId, address)
}
@Suppress("LongMethod")
override suspend fun fetchMultiYieldBalance(
userWalletId: UserWalletId,
cryptoCurrencies: List<CryptoCurrency>,
refresh: Boolean,
) = withContext(dispatchers.io) {
if (refresh) {
stakingBalanceStore.refresh(userWalletId = userWalletId)
stakingBalanceStore.refresh(
userWalletId = userWalletId,
addressWithIntegrationIdMap = cryptoCurrencies
.mapNotNull { currency ->
val addresses = walletManagersFacade.getAddresses(userWalletId, currency.network)
val integrationId = integrationIdMap[getIntegrationKey(currency.id)]
if (integrationId != null) {
addresses to integrationId
} else {
null
}
}
.flatMap { (addresses, integrationId) ->
addresses.map { address -> integrationId to address.value }
}
.toMap(),
)
}
cacheRegistry.invokeOnExpire(