Updated on 2026-08-14
This commit is contained in:
parent
d159d4e55b
commit
8dbcfaff99
23 changed files with 2335 additions and 2318 deletions
|
|
@ -498,8 +498,9 @@ internal class SwapInteractorImpl @Inject constructor(
|
|||
|
||||
private fun isBalanceEnough(fromToken: Currency, networkId: String, amount: SwapAmount, fee: BigDecimal?): Boolean {
|
||||
/** to compare [BigDecimal] use only comparator */
|
||||
return (userWalletManager.getCurrentWalletTokensBalance(networkId)[fromToken.symbol]?.value
|
||||
?: BigDecimal.ZERO) > amount.value.plus(fee ?: BigDecimal.ZERO)
|
||||
val balance = userWalletManager.getCurrentWalletTokensBalance(networkId)[fromToken.symbol]?.value
|
||||
?: BigDecimal.ZERO
|
||||
return balance > amount.value.plus(fee ?: BigDecimal.ZERO)
|
||||
}
|
||||
|
||||
private fun getWalletAddress(networkId: String): String {
|
||||
|
|
@ -522,11 +523,11 @@ internal class SwapInteractorImpl @Inject constructor(
|
|||
return false
|
||||
}
|
||||
userWalletManager.getNativeTokenBalance(networkId)?.let { balance ->
|
||||
return (balance.value.minus(spendAmount.value) > fee.multiply(
|
||||
return balance.value.minus(spendAmount.value) > fee.multiply(
|
||||
BigDecimal.valueOf(
|
||||
INCREASE_FEE_TO_CHECK_ENOUGH_PERCENT,
|
||||
),
|
||||
))
|
||||
)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,9 +134,9 @@ class StateBuilder(val actions: UiActions) {
|
|||
permissionState = convertPermissionState(quoteModel.permissionState, actions.onGivePermissionClick),
|
||||
fee = feeState,
|
||||
swapButton = SwapButton(
|
||||
enabled = quoteModel.preparedSwapConfigState.isAllowedToSpend
|
||||
&& quoteModel.preparedSwapConfigState.isBalanceEnough
|
||||
&& quoteModel.preparedSwapConfigState.isFeeEnough,
|
||||
enabled = quoteModel.preparedSwapConfigState.isAllowedToSpend &&
|
||||
quoteModel.preparedSwapConfigState.isBalanceEnough &&
|
||||
quoteModel.preparedSwapConfigState.isFeeEnough,
|
||||
loading = false,
|
||||
onClick = actions.onSwapClick,
|
||||
),
|
||||
|
|
@ -270,7 +270,7 @@ class StateBuilder(val actions: UiActions) {
|
|||
|
||||
fun mapError(uiState: SwapStateHolder, error: DataError): SwapStateHolder {
|
||||
return when (error) {
|
||||
//todo use if needed later
|
||||
// todo use if needed later
|
||||
// DataError.InsufficientLiquidity -> TODO()
|
||||
// DataError.NoError -> TODO()
|
||||
is DataError.UnknownError -> addWarning(uiState, error.message)
|
||||
|
|
|
|||
|
|
@ -231,7 +231,11 @@ private fun FeeItem(feeState: FeeState, currency: String) {
|
|||
SmallInfoCardWithWarning(
|
||||
startText = titleString,
|
||||
endText = feeState.fee,
|
||||
warningText = stringResource(id = R.string.token_details_send_blocked_fee_format, currency, currency),
|
||||
warningText = stringResource(
|
||||
id = R.string.swapping_not_enough_funds_for_fee,
|
||||
currency,
|
||||
currency,
|
||||
),
|
||||
)
|
||||
}
|
||||
is FeeState.Empty -> {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue