Updated on 2026-08-14
This commit is contained in:
parent
0e1e5e3a67
commit
135a8a22f0
5 changed files with 69 additions and 6 deletions
|
|
@ -52,6 +52,8 @@ internal class DefaultMultiYieldBalanceFetcher @Inject constructor(
|
|||
) : MultiYieldBalanceFetcher {
|
||||
|
||||
override suspend fun invoke(params: MultiYieldBalanceFetcher.Params): Either<Throwable, Unit> {
|
||||
Timber.i("Start fetching yield balances for params:\n$params")
|
||||
|
||||
checkIsSupportedByWalletOrElse(userWalletId = params.userWalletId) {
|
||||
return it.left()
|
||||
}
|
||||
|
|
@ -60,6 +62,8 @@ internal class DefaultMultiYieldBalanceFetcher @Inject constructor(
|
|||
return it.left()
|
||||
}
|
||||
|
||||
Timber.i("Staking IDs to fetch:\n${stakingIds.joinToString("\n")}")
|
||||
|
||||
return Either.catchOn(dispatchers.default) {
|
||||
yieldsBalancesStore.refresh(userWalletId = params.userWalletId, stakingIds = stakingIds)
|
||||
|
||||
|
|
@ -126,6 +130,13 @@ internal class DefaultMultiYieldBalanceFetcher @Inject constructor(
|
|||
val availableStakingIds = groupedStakingIds[true].orEmpty()
|
||||
val unavailableStakingIds = groupedStakingIds[false].orEmpty()
|
||||
|
||||
Timber.i(
|
||||
"""
|
||||
Available staking IDs: ${availableStakingIds.joinToString()}
|
||||
Unavailable staking IDs: ${unavailableStakingIds.joinToString()}
|
||||
""".trimIndent(),
|
||||
)
|
||||
|
||||
if (unavailableStakingIds.isNotEmpty()) {
|
||||
yieldsBalancesStore.storeError(userWalletId = userWalletId, stakingIds = unavailableStakingIds.toSet())
|
||||
}
|
||||
|
|
@ -138,7 +149,7 @@ internal class DefaultMultiYieldBalanceFetcher @Inject constructor(
|
|||
– stakingIds: ${stakingIds.joinToString()}
|
||||
""".trimIndent(),
|
||||
)
|
||||
Timber.d(exception)
|
||||
Timber.i(exception)
|
||||
throw exception
|
||||
}
|
||||
}
|
||||
|
|
@ -174,6 +185,7 @@ internal class DefaultMultiYieldBalanceFetcher @Inject constructor(
|
|||
.toSet()
|
||||
}
|
||||
|
||||
Timber.i("Successfully fetched yield balances for $userWalletId:\n${yieldBalances.joinToString("\n")}")
|
||||
yieldsBalancesStore.storeActual(userWalletId = userWalletId, values = yieldBalances)
|
||||
|
||||
if (!allResponsesReceived(requests, yieldBalances)) {
|
||||
|
|
|
|||
|
|
@ -47,11 +47,18 @@ internal class DefaultSingleYieldBalanceProducer @AssistedInject constructor(
|
|||
private var stakingId: StakingID? = null
|
||||
|
||||
override fun produce(): Flow<YieldBalance> {
|
||||
Timber.i("Producing yield balance for params:\n$params")
|
||||
|
||||
return multiYieldBalanceSupplier(
|
||||
params = MultiYieldBalanceProducer.Params(userWalletId = params.userWalletId),
|
||||
)
|
||||
.mapNotNull { balances ->
|
||||
val currentStakingId = getStakingId() ?: return@mapNotNull YieldBalance.Unsupported
|
||||
val currentStakingId = getStakingId()
|
||||
|
||||
if (currentStakingId == null) {
|
||||
Timber.i("Staking ID is null for params: $params")
|
||||
return@mapNotNull YieldBalance.Unsupported
|
||||
}
|
||||
|
||||
val currentBalances = balances.filter { it.getStakingId() == currentStakingId }
|
||||
|
||||
|
|
@ -66,7 +73,7 @@ internal class DefaultSingleYieldBalanceProducer @AssistedInject constructor(
|
|||
),
|
||||
)
|
||||
|
||||
Timber.w(
|
||||
Timber.e(
|
||||
"Multiple balances found for staking ID $currentStakingId:\n%s",
|
||||
currentBalances.joinToString("\n"),
|
||||
)
|
||||
|
|
@ -79,7 +86,15 @@ internal class DefaultSingleYieldBalanceProducer @AssistedInject constructor(
|
|||
currentBalances.first()
|
||||
}
|
||||
} else {
|
||||
currentBalances.firstOrNull() ?: YieldBalance.Unsupported
|
||||
val balance = currentBalances.firstOrNull()
|
||||
|
||||
if (balance != null) {
|
||||
Timber.i("Yield balance found for $currentStakingId:\n$balance")
|
||||
balance
|
||||
} else {
|
||||
Timber.i("No yield balance found for $currentStakingId:\n${YieldBalance.Unsupported}")
|
||||
YieldBalance.Unsupported
|
||||
}
|
||||
}
|
||||
}
|
||||
.distinctUntilChanged()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue