Updated on 2026-08-14
This commit is contained in:
parent
c96248514b
commit
be704a7f0b
1 changed files with 10 additions and 4 deletions
|
|
@ -353,12 +353,18 @@ internal class SwapInteractorImpl @Inject constructor(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun manageWarnings(fromToken: CryptoCurrency): List<Warning> {
|
private suspend fun manageWarnings(fromToken: CryptoCurrency, amount: SwapAmount): List<Warning> {
|
||||||
val userWalletId = getSelectedWallet()?.walletId ?: return emptyList()
|
val userWalletId = getSelectedWallet()?.walletId ?: return emptyList()
|
||||||
val existentialDeposit = repository.getExistentialDeposit(userWalletId, fromToken.network)
|
val existentialDeposit = repository.getExistentialDeposit(userWalletId, fromToken.network)
|
||||||
val warnings = mutableListOf<Warning>()
|
val warnings = mutableListOf<Warning>()
|
||||||
if (existentialDeposit != null) {
|
if (existentialDeposit != null) {
|
||||||
warnings.add(Warning.ExistentialDepositWarning(existentialDeposit))
|
val nativeBalance = userWalletManager.getNativeTokenBalance(
|
||||||
|
fromToken.network.backendId,
|
||||||
|
fromToken.network.derivationPath.value,
|
||||||
|
) ?: ProxyAmount.empty()
|
||||||
|
if (nativeBalance.value.minus(amount.value) < existentialDeposit) {
|
||||||
|
warnings.add(Warning.ExistentialDepositWarning(existentialDeposit))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return warnings
|
return warnings
|
||||||
}
|
}
|
||||||
|
|
@ -793,7 +799,7 @@ internal class SwapInteractorImpl @Inject constructor(
|
||||||
txFeeState = txFee,
|
txFeeState = txFee,
|
||||||
exchangeProviderType = exchangeProviderType,
|
exchangeProviderType = exchangeProviderType,
|
||||||
).copy(
|
).copy(
|
||||||
warnings = manageWarnings(fromToken.currency),
|
warnings = manageWarnings(fromToken.currency, amount),
|
||||||
)
|
)
|
||||||
|
|
||||||
when (exchangeProviderType) {
|
when (exchangeProviderType) {
|
||||||
|
|
@ -951,7 +957,7 @@ internal class SwapInteractorImpl @Inject constructor(
|
||||||
)
|
)
|
||||||
swapState.copy(
|
swapState.copy(
|
||||||
permissionState = PermissionDataState.Empty,
|
permissionState = PermissionDataState.Empty,
|
||||||
warnings = manageWarnings(fromToken.currency),
|
warnings = manageWarnings(fromToken.currency, amount),
|
||||||
preparedSwapConfigState = PreparedSwapConfigState(
|
preparedSwapConfigState = PreparedSwapConfigState(
|
||||||
isAllowedToSpend = true,
|
isAllowedToSpend = true,
|
||||||
isBalanceEnough = isBalanceIncludeFeeEnough,
|
isBalanceEnough = isBalanceIncludeFeeEnough,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue