Skip to content

Commit df9adf9

Browse files
shoom3301elena-zhkernelwhisperer
authored
fix: check balance sufficiency it case of wrap/unwrap (#6835)
* fix: check balance sufficiency it case of wrap/unwrap * fix typo in hooks banner * fix: move balances check outside isWrapUnwrap --------- Co-authored-by: Elena <[email protected]> Co-authored-by: Daniel Constantin <[email protected]>
1 parent d2ed41e commit df9adf9

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

apps/cowswap-frontend/src/locales/en-US.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3598,7 +3598,7 @@ msgstr "CoW Protocol covers the fees and costs by executing your order at a slig
35983598

35993599
#: apps/cowswap-frontend/src/modules/hooksStore/containers/HooksStoreWidget/index.tsx
36003600
msgid "With hooks you can add specific actions <0>before</0> and <1>after</1> your swap."
3601-
msgstr "With hooks you can add specific actions <0>before</0> and <1>after</1> your swap.<<<<<<< Updated upstream"
3601+
msgstr "With hooks you can add specific actions <0>before</0> and <1>after</1> your swap."
36023602

36033603
#: apps/cowswap-frontend/src/modules/tokensList/hooks/useRestrictedTokenImportStatus.ts
36043604
#: apps/cowswap-frontend/src/modules/tokensList/hooks/useRestrictedTokensImportStatus.ts

apps/cowswap-frontend/src/modules/tradeFormValidation/services/validateTradeForm.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,20 @@ export function validateTradeForm(context: TradeFormValidationContext): TradeFor
103103
validations.push(TradeFormValidation.InputAmountNotSet)
104104
}
105105

106+
if (!canPlaceOrderWithoutBalance && !!account) {
107+
if (!inputCurrencyBalance && isBalancesLoading) {
108+
validations.push(TradeFormValidation.BalancesLoading)
109+
}
110+
111+
if (!inputCurrencyBalance && !isBalancesLoading) {
112+
validations.push(TradeFormValidation.BalancesNotLoaded)
113+
}
114+
115+
if (inputCurrencyBalance && inputCurrencyAmount && inputCurrencyBalance.lessThan(inputCurrencyAmount)) {
116+
validations.push(TradeFormValidation.BalanceInsufficient)
117+
}
118+
}
119+
106120
if (!isWrapUnwrap) {
107121
const isRecipientAddress = Boolean(recipient && isAddress(recipient))
108122

@@ -119,20 +133,6 @@ export function validateTradeForm(context: TradeFormValidationContext): TradeFor
119133
validations.push(TradeFormValidation.CurrencyNotSupported)
120134
}
121135

122-
if (!canPlaceOrderWithoutBalance && !!account) {
123-
if (!inputCurrencyBalance && isBalancesLoading) {
124-
validations.push(TradeFormValidation.BalancesLoading)
125-
}
126-
127-
if (!inputCurrencyBalance && !isBalancesLoading) {
128-
validations.push(TradeFormValidation.BalancesNotLoaded)
129-
}
130-
131-
if (inputCurrencyBalance && inputCurrencyAmount && inputCurrencyBalance.lessThan(inputCurrencyAmount)) {
132-
validations.push(TradeFormValidation.BalanceInsufficient)
133-
}
134-
}
135-
136136
if (isFastQuote || !tradeQuote.quote || (isBridging && tradeQuote.isLoading)) {
137137
validations.push(TradeFormValidation.QuoteLoading)
138138
}

0 commit comments

Comments
 (0)