Updated on 2026-08-14
This commit is contained in:
parent
25f7ea1644
commit
6b01eacf9d
4 changed files with 27 additions and 11 deletions
|
|
@ -61,6 +61,18 @@ internal class DefaultCurrenciesRepository(
|
|||
private val isMultiCurrencyWalletCurrenciesFetching = MutableStateFlow(
|
||||
value = emptyMap<UserWalletId, Boolean>(),
|
||||
)
|
||||
private val parallelTransactionsEnabledBlockchains = setOf(
|
||||
Blockchain.Ethereum,
|
||||
Blockchain.EthereumTestnet,
|
||||
Blockchain.Polygon,
|
||||
Blockchain.PolygonTestnet,
|
||||
Blockchain.Arbitrum,
|
||||
Blockchain.ArbitrumTestnet,
|
||||
Blockchain.Binance,
|
||||
Blockchain.BinanceTestnet,
|
||||
Blockchain.Tron,
|
||||
Blockchain.TronTestnet,
|
||||
)
|
||||
|
||||
override suspend fun saveTokens(
|
||||
userWalletId: UserWalletId,
|
||||
|
|
@ -366,18 +378,19 @@ internal class DefaultCurrenciesRepository(
|
|||
}
|
||||
}
|
||||
|
||||
override fun hasPendingTransactions(
|
||||
override fun isSendBlockedByPendingTransactions(
|
||||
cryptoCurrencyStatus: CryptoCurrencyStatus,
|
||||
coinStatus: CryptoCurrencyStatus?,
|
||||
): Boolean {
|
||||
val blockchain = Blockchain.fromId(cryptoCurrencyStatus.currency.network.id.value)
|
||||
val isBitcoinBlockchain = blockchain == Blockchain.Bitcoin || blockchain == Blockchain.BitcoinTestnet
|
||||
|
||||
return if (cryptoCurrencyStatus.currency is CryptoCurrency.Coin && isBitcoinBlockchain) {
|
||||
val outgoingTransactions = cryptoCurrencyStatus.value.pendingTransactions.filter { it.isOutgoing }
|
||||
outgoingTransactions.isNotEmpty()
|
||||
} else {
|
||||
coinStatus?.value?.hasCurrentNetworkTransactions == true
|
||||
return when {
|
||||
cryptoCurrencyStatus.currency is CryptoCurrency.Coin && isBitcoinBlockchain -> {
|
||||
val outgoingTransactions = cryptoCurrencyStatus.value.pendingTransactions.filter { it.isOutgoing }
|
||||
outgoingTransactions.isNotEmpty()
|
||||
}
|
||||
parallelTransactionsEnabledBlockchains.contains(blockchain) -> false
|
||||
else -> coinStatus?.value?.hasCurrentNetworkTransactions == true
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ class GetCryptoCurrencyActionsUseCase(
|
|||
cryptoCurrencyStatus.value.amount.isNullOrZero() -> {
|
||||
ScenarioUnavailabilityReason.EmptyBalance(ScenarioUnavailabilityReason.WithdrawalScenario.SEND)
|
||||
}
|
||||
currenciesRepository.hasPendingTransactions(
|
||||
currenciesRepository.isSendBlockedByPendingTransactions(
|
||||
cryptoCurrencyStatus = cryptoCurrencyStatus,
|
||||
coinStatus = coinStatus,
|
||||
) -> {
|
||||
|
|
|
|||
|
|
@ -194,12 +194,15 @@ interface CurrenciesRepository {
|
|||
fun getMissedAddressesCryptoCurrencies(userWalletId: UserWalletId): Flow<List<CryptoCurrency>>
|
||||
|
||||
/**
|
||||
* Determines whether the currency has pending transaction or currency network has pending transaction
|
||||
* Determines whether the currency sending is blocked by network pending transaction
|
||||
*
|
||||
* @param cryptoCurrencyStatus currency status
|
||||
* @param coinStatus main currency status in [cryptoCurrencyStatus] network
|
||||
*/
|
||||
fun hasPendingTransactions(cryptoCurrencyStatus: CryptoCurrencyStatus, coinStatus: CryptoCurrencyStatus?): Boolean
|
||||
fun isSendBlockedByPendingTransactions(
|
||||
cryptoCurrencyStatus: CryptoCurrencyStatus,
|
||||
coinStatus: CryptoCurrencyStatus?,
|
||||
): Boolean
|
||||
|
||||
/**
|
||||
* Retrieves fee paid currency for specific [currency].
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ internal class MockCurrenciesRepository(
|
|||
return isSortedByBalance.map { it.getOrElse { e -> throw e } }
|
||||
}
|
||||
|
||||
override fun hasPendingTransactions(
|
||||
override fun isSendBlockedByPendingTransactions(
|
||||
cryptoCurrencyStatus: CryptoCurrencyStatus,
|
||||
coinStatus: CryptoCurrencyStatus?,
|
||||
): Boolean {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue