Updated on 2026-08-14
This commit is contained in:
parent
17d3649cb3
commit
53f4cb5dbf
5 changed files with 17 additions and 3 deletions
|
|
@ -3,6 +3,7 @@ package com.tangem.data.tokens.repository
|
|||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchainsdk.compatibility.getL2CompatibilityTokenComparison
|
||||
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||
import com.tangem.blockchainsdk.utils.fromNetworkId
|
||||
import com.tangem.blockchainsdk.utils.toCoinId
|
||||
import com.tangem.blockchainsdk.utils.toNetworkId
|
||||
import com.tangem.data.common.api.safeApiCall
|
||||
|
|
@ -506,6 +507,11 @@ internal class DefaultCurrenciesRepository(
|
|||
}
|
||||
}
|
||||
|
||||
override fun isNetworkFeeZero(userWalletId: UserWalletId, network: Network): Boolean {
|
||||
val blockchain = Blockchain.fromNetworkId(network.backendId)
|
||||
return blockchain?.isNetworkFeeZero() ?: false
|
||||
}
|
||||
|
||||
private fun getMultiCurrencyWalletCurrencies(userWallet: UserWallet): Flow<List<CryptoCurrency>> {
|
||||
return getSavedUserTokensResponse(userWallet.walletId).map { storedTokens ->
|
||||
responseCurrenciesFactory.createCurrencies(
|
||||
|
|
|
|||
|
|
@ -193,10 +193,12 @@ class GetCurrencyWarningsUseCase(
|
|||
tokenStatus: CryptoCurrencyStatus,
|
||||
): CryptoCurrencyWarning? {
|
||||
val feePaidCurrency = currenciesRepository.getFeePaidCurrency(userWalletId, tokenStatus.currency)
|
||||
val isNetworkFeeZero = currenciesRepository.isNetworkFeeZero(userWalletId, tokenStatus.currency.network)
|
||||
return when {
|
||||
feePaidCurrency is FeePaidCurrency.Coin &&
|
||||
!tokenStatus.value.amount.isZero() &&
|
||||
coinStatus.value.amount.isZero() -> {
|
||||
coinStatus.value.amount.isZero() &&
|
||||
!isNetworkFeeZero -> {
|
||||
CryptoCurrencyWarning.BalanceNotEnoughForFee(
|
||||
tokenCurrency = tokenStatus.currency,
|
||||
coinCurrency = coinStatus.currency,
|
||||
|
|
@ -205,7 +207,7 @@ class GetCurrencyWarningsUseCase(
|
|||
feePaidCurrency is FeePaidCurrency.Token -> {
|
||||
val feePaidTokenBalance = feePaidCurrency.balance
|
||||
val amount = tokenStatus.value.amount ?: return null
|
||||
if (!amount.isZero() && feePaidTokenBalance.isZero()) {
|
||||
if (!amount.isZero() && feePaidTokenBalance.isZero() && !isNetworkFeeZero) {
|
||||
constructTokenBalanceNotEnoughWarning(
|
||||
userWalletId = userWalletId,
|
||||
tokenStatus = tokenStatus,
|
||||
|
|
|
|||
|
|
@ -241,4 +241,6 @@ interface CurrenciesRepository {
|
|||
|
||||
/** Get crypto currencies by [currencyRawId] from all user wallets */
|
||||
fun getAllWalletsCryptoCurrencies(currencyRawId: String): Flow<Map<UserWallet, List<CryptoCurrency>>>
|
||||
|
||||
fun isNetworkFeeZero(userWalletId: UserWalletId, network: Network): Boolean
|
||||
}
|
||||
|
|
@ -150,4 +150,8 @@ internal class MockCurrenciesRepository(
|
|||
override fun getAllWalletsCryptoCurrencies(currencyRawId: String): Flow<Map<UserWallet, List<CryptoCurrency>>> {
|
||||
return emptyFlow()
|
||||
}
|
||||
|
||||
override fun isNetworkFeeZero(userWalletId: UserWalletId, network: Network): Boolean {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
|
@ -88,7 +88,7 @@ markdownComposeView = "0.5.4"
|
|||
# endregion Other libraries
|
||||
|
||||
# region Tangem
|
||||
tangemBlockchainSdk = "develop-875"
|
||||
tangemBlockchainSdk = "develop-876"
|
||||
#tangemBlockchainSdk = "0.0.1" # Keep it! - used for local builds
|
||||
tangemCardSdk = "develop-410"
|
||||
#tangemCardSdk = "0.0.1" # Keep it! - used for local builds ^
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue