Updated on 2026-08-14
This commit is contained in:
commit
24771f7f51
2 changed files with 24 additions and 3 deletions
|
|
@ -4,6 +4,7 @@ import arrow.core.NonEmptyList
|
|||
import com.tangem.domain.staking.model.stakekit.YieldBalance
|
||||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
import com.tangem.domain.tokens.model.TotalFiatBalance
|
||||
import com.tangem.lib.crypto.BlockchainUtils
|
||||
import com.tangem.utils.extensions.orZero
|
||||
import java.math.BigDecimal
|
||||
|
||||
|
|
@ -12,6 +13,7 @@ internal class TokenListFiatBalanceOperations(
|
|||
private val isAnyTokenLoading: Boolean,
|
||||
) {
|
||||
|
||||
@Suppress("LoopWithTooManyJumpStatements")
|
||||
fun calculateFiatBalance(): TotalFiatBalance {
|
||||
var fiatBalance: TotalFiatBalance = TotalFiatBalance.Loading
|
||||
if (isAnyTokenLoading) return fiatBalance
|
||||
|
|
@ -22,14 +24,22 @@ internal class TokenListFiatBalanceOperations(
|
|||
fiatBalance = TotalFiatBalance.Loading
|
||||
break
|
||||
}
|
||||
is CryptoCurrencyStatus.MissedDerivation,
|
||||
is CryptoCurrencyStatus.Unreachable,
|
||||
is CryptoCurrencyStatus.NoAmount,
|
||||
is CryptoCurrencyStatus.NoQuote,
|
||||
is CryptoCurrencyStatus.MissedDerivation,
|
||||
-> {
|
||||
fiatBalance = TotalFiatBalance.Failed
|
||||
break
|
||||
}
|
||||
is CryptoCurrencyStatus.Unreachable,
|
||||
is CryptoCurrencyStatus.NoAmount,
|
||||
-> {
|
||||
if (BlockchainUtils.isIncludeToBalanceOnError(token.currency.network.id.value)) {
|
||||
fiatBalance = recalculateNoAccountBalance(fiatBalance)
|
||||
} else {
|
||||
fiatBalance = TotalFiatBalance.Failed
|
||||
break
|
||||
}
|
||||
}
|
||||
is CryptoCurrencyStatus.NoAccount -> {
|
||||
fiatBalance = recalculateNoAccountBalance(fiatBalance)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,6 +116,17 @@ object BlockchainUtils {
|
|||
return l2BlockchainsList.contains(blockchain)
|
||||
}
|
||||
|
||||
/**
|
||||
* Blockchains not affecting total balance counting on errors
|
||||
*/
|
||||
fun isIncludeToBalanceOnError(blockchainId: String): Boolean {
|
||||
val blockchain = Blockchain.fromId(blockchainId)
|
||||
return when (blockchain) {
|
||||
Blockchain.Binance, Blockchain.BinanceTestnet -> true
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
private fun getNetworkStandardName(blockchain: Blockchain): String {
|
||||
return when (blockchain) {
|
||||
Blockchain.Ethereum, Blockchain.EthereumTestnet -> "ERC20"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue