From a905e1baf3066e073c86a9b6be9a538e6579feba Mon Sep 17 00:00:00 2001 From: Rui <102453770+ruixhuang@users.noreply.github.com> Date: Thu, 14 Mar 2024 18:50:34 -0400 Subject: [PATCH] MOB-333 Withdrawal error message "insufficient balance" but it seems like there is sufficient balance based on values displayed (#115) --- ...xTransferInputCtaButtonViewPresenter.swift | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/dydx/dydxPresenters/dydxPresenters/_v4/Transfer/Components/dydxTransferInputCtaButtonViewPresenter.swift b/dydx/dydxPresenters/dydxPresenters/_v4/Transfer/Components/dydxTransferInputCtaButtonViewPresenter.swift index 3e404e31d..7021e8508 100644 --- a/dydx/dydxPresenters/dydxPresenters/_v4/Transfer/Components/dydxTransferInputCtaButtonViewPresenter.swift +++ b/dydx/dydxPresenters/dydxPresenters/_v4/Transfer/Components/dydxTransferInputCtaButtonViewPresenter.swift @@ -230,30 +230,30 @@ class dydxTransferInputCtaButtonViewPresenter: HostedViewPresenter 0.0 else { return } - let gasFee = transferInput.summary?.gasFee?.doubleValue ?? 0 - let usdcBalanceInWallet = usdcBalanceInWallet ?? 0 - if usdcBalanceInWallet >= gasFee { - if transferInput.isCctp { - AbacusStateManager.shared.commitCCTPWithdraw { [weak self] success, error, result in - if success { - self?.postTransaction(result: result, transferInput: transferInput) - } else { - ErrorInfo.shared?.info(title: DataLocalizer.localize(path: "APP.GENERAL.ERROR"), - message: error?.localizedDescription, - type: .error, - error: nil, time: nil) - } - self?.viewModel?.ctaButtonState = .enabled(DataLocalizer.localize(path: "APP.GENERAL.CONFIRM_WITHDRAW")) + if transferInput.isCctp { + AbacusStateManager.shared.commitCCTPWithdraw { [weak self] success, error, result in + if success { + self?.postTransaction(result: result, transferInput: transferInput) + } else { + ErrorInfo.shared?.info(title: DataLocalizer.localize(path: "APP.GENERAL.ERROR"), + message: error?.localizedDescription, + type: .error, + error: nil, time: nil) } - } else { + self?.viewModel?.ctaButtonState = .enabled(DataLocalizer.localize(path: "APP.GENERAL.CONFIRM_WITHDRAW")) + } + } else { + let gasFee = transferInput.summary?.gasFee?.doubleValue ?? 0 + let usdcBalanceInWallet = usdcBalanceInWallet ?? 0 + if usdcBalanceInWallet >= gasFee { CosmoJavascript.shared.withdrawToIBC(subaccount: Int(selectedSubaccount.subaccountNumber), amount: amount, payload: data) { [weak self] result in self?.postTransaction(result: result, transferInput: transferInput) self?.viewModel?.ctaButtonState = .enabled(DataLocalizer.localize(path: "APP.GENERAL.CONFIRM_WITHDRAW")) } + } else { + self.showNoGas() + self.viewModel?.ctaButtonState = .enabled(DataLocalizer.localize(path: "APP.GENERAL.CONFIRM_WITHDRAW")) } - } else { - self.showNoGas() - self.viewModel?.ctaButtonState = .enabled(DataLocalizer.localize(path: "APP.GENERAL.CONFIRM_WITHDRAW")) } } }