Updated on 2026-08-14
This commit is contained in:
parent
7d870833db
commit
b8a3a6899f
9 changed files with 20 additions and 14 deletions
|
|
@ -34,7 +34,7 @@ class GetBalanceNotEnoughForFeeWarningUseCase(
|
|||
coinStatus: CryptoCurrencyStatus,
|
||||
): Either<Throwable, CryptoCurrencyWarning?> = Either.catch {
|
||||
withContext(dispatchers.io) {
|
||||
val feePaidCurrency = currenciesRepository.getFeePaidCurrency(userWalletId, tokenStatus.currency)
|
||||
val feePaidCurrency = currenciesRepository.getFeePaidCurrency(userWalletId, tokenStatus.currency.network)
|
||||
val coinBalance = coinStatus.value.amount ?: BigDecimal.ZERO
|
||||
|
||||
val isFeePaidByCoin = tokenStatus.currency is CryptoCurrency.Token
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ class GetCurrencyWarningsUseCase(
|
|||
coinStatus: CryptoCurrencyStatus,
|
||||
tokenStatus: CryptoCurrencyStatus,
|
||||
): CryptoCurrencyWarning? {
|
||||
val feePaidCurrency = currenciesRepository.getFeePaidCurrency(userWalletId, tokenStatus.currency)
|
||||
val feePaidCurrency = currenciesRepository.getFeePaidCurrency(userWalletId, tokenStatus.currency.network)
|
||||
val isNetworkFeeZero = currenciesRepository.isNetworkFeeZero(userWalletId, tokenStatus.currency.network)
|
||||
return when {
|
||||
feePaidCurrency is FeePaidCurrency.Coin &&
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ class GetFeePaidCryptoCurrencyStatusSyncUseCase(
|
|||
cryptoCurrencyStatus: CryptoCurrencyStatus,
|
||||
): Either<TokenListError, CryptoCurrencyStatus?> {
|
||||
val cryptoCurrency = cryptoCurrencyStatus.currency
|
||||
val feePaidCurrency = currenciesRepository.getFeePaidCurrency(userWalletId, cryptoCurrency)
|
||||
val network = cryptoCurrency.network
|
||||
val feePaidCurrency = currenciesRepository.getFeePaidCurrency(userWalletId, network)
|
||||
val operations = CurrenciesStatusesOperations(
|
||||
userWalletId = userWalletId,
|
||||
currenciesRepository = currenciesRepository,
|
||||
|
|
@ -39,7 +40,7 @@ class GetFeePaidCryptoCurrencyStatusSyncUseCase(
|
|||
when (feePaidCurrency) {
|
||||
FeePaidCurrency.Coin ->
|
||||
operations
|
||||
.getNetworkCoinSync(cryptoCurrency.network.id, cryptoCurrency.network.derivationPath)
|
||||
.getNetworkCoinSync(network.id, network.derivationPath)
|
||||
.getOrNull()
|
||||
FeePaidCurrency.SameCurrency,
|
||||
is FeePaidCurrency.FeeResource,
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class IsAmountSubtractAvailableUseCase(
|
|||
suspend operator fun invoke(userWalletId: UserWalletId, currency: CryptoCurrency): Either<Throwable, Boolean> =
|
||||
Either.catch {
|
||||
withContext(dispatchers.io) {
|
||||
when (val feeCurrency = currenciesRepository.getFeePaidCurrency(userWalletId, currency)) {
|
||||
when (val feeCurrency = currenciesRepository.getFeePaidCurrency(userWalletId, currency.network)) {
|
||||
is FeePaidCurrency.Coin -> currency is CryptoCurrency.Coin
|
||||
is FeePaidCurrency.SameCurrency -> true
|
||||
is FeePaidCurrency.Token -> currency.id == feeCurrency.tokenId
|
||||
|
|
|
|||
|
|
@ -231,9 +231,9 @@ interface CurrenciesRepository {
|
|||
): Boolean
|
||||
|
||||
/**
|
||||
* Retrieves fee paid currency for specific [currency].
|
||||
* Retrieves fee paid currency for specific [network].
|
||||
*/
|
||||
suspend fun getFeePaidCurrency(userWalletId: UserWalletId, currency: CryptoCurrency): FeePaidCurrency
|
||||
suspend fun getFeePaidCurrency(userWalletId: UserWalletId, network: Network): FeePaidCurrency
|
||||
|
||||
/**
|
||||
* Creates token [cryptoCurrency] based on current token and [network] it`s will be added
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ internal class MockCurrenciesRepository(
|
|||
return false
|
||||
}
|
||||
|
||||
override suspend fun getFeePaidCurrency(userWalletId: UserWalletId, currency: CryptoCurrency): FeePaidCurrency {
|
||||
override suspend fun getFeePaidCurrency(userWalletId: UserWalletId, network: Network): FeePaidCurrency {
|
||||
return FeePaidCurrency.Coin
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue