-
Notifications
You must be signed in to change notification settings - Fork 122
fix: bump InputAmountNotSet validation priority < 8000 span class="f1-light color-fg-muted">#5851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe validation logic in the trade form service was updated to introduce a new check for missing input amounts when handling quote errors. Now, if the input amount is not set and a quote error occurs, a more specific validation result is returned instead of a generic error. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant TradeFormValidator
User->>TradeFormValidator: Submit trade form
TradeFormValidator->>TradeFormValidator: Check for quote errors
alt Not wrap/unwrap operation
alt Input amount is not set
TradeFormValidator-->>User: Return InputAmountNotSet error
else Input amount is set
TradeFormValidator-->>User: Return QuoteErrors error
end
else Wrap/unwrap operation
TradeFormValidator-->>User: Continue with existing logic
end
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
yarn install v1.22.22 ✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
apps/cowswap-frontend/src/modules/tradeFormValidation/services/validateTradeForm.ts (2)
51-54
: Consider removing the later duplicateInputAmountNotSet
check to cut cyclomatic complexityThe same condition is evaluated again at lines 78-80.
With the new early-return in place, the second check is now unreachable whenevertradeQuote.error
is truthy, but we still evaluate it for the other branch. You can:- if (inputAmountIsNotSet) { - return TradeFormValidation.InputAmountNotSet - }Move this block to the very top of the function (just after the online check) and delete both current occurrences.
This trims one nested branch, reduces duplication, and simplifies mental tracing.
119-132
: DuplicateSellNativeToken
validation blocks – can be collapsed into one
isNativeIn
is checked twice (lines 119-122 and again 130-132) with identical return values. Consolidating them avoids dead code paths and shaves two comparisons per call.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/cowswap-frontend/src/modules/tradeFormValidation/services/validateTradeForm.ts
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Setup
- GitHub Check: Cypress
🔇 Additional comments (1)
apps/cowswap-frontend/src/modules/tradeFormValidation/services/validateTradeForm.ts (1)
50-56
: Early-return forInputAmountNotSet
is a welcome improvement, but please add a regression testThe new guard gives the “amount not set” validation higher priority over a generic quote error, which is exactly what the bug report asked for.
Please add/extend unit tests that drivetradeQuote.error = true
whileinputAmountIsNotSet = true
to assert that the function now returnsTradeFormValidation.InputAmountNotSet
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Summary
Fixes https://www.notion.so/cownation/Bridge-quote-error-when-no-amounts-2108da5f04ca80cab170d7801a29c694?source=copy_link
To Test
See https://www.notion.so/cownation/Bridge-quote-error-when-no-amounts-2108da5f04ca80cab170d7801a29c694?source=copy_link
Summary by CodeRabbit