[READY] Improve Error Messages#1171
Open
Sharqiewicz wants to merge 1 commit into
Open
Conversation
✅ Deploy Preview for vortex-sandbox ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for vortexfi ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
There was a problem hiding this comment.
Pull request overview
Improves order-limit error UX by switching to friendlier, locale-aware "Minimum/Maximum {buy|sell} amount is X SYM." messages on the frontend, and adds backend support for Alfredpay above-maximum (upper-bound) limit errors that previously went unhandled.
Changes:
- Refactors
AlfredpayTradeLimitErrorinto a discriminated union (kind: "above" | "below") withstatic below()/above()factories, and detectsmaxQuantityin Alfredpay 409/errorCode 111426responses. - Adds new
QuoteError.AboveUpperLimit{Sell,Buy}constants and a backend mapper fromAlfredpayTradeLimitError→APIErrorcovering both above/below × buy/sell. - Rewrites the frontend limit-message rendering in
useRampValidationwith abuildLimitMessagehelper,Intl-based locale-aware formatting (i18n.language), a regex-based parser of backend-supplied amount/symbol, and switches translation keys to the friendlierlessThanMinimumWithdrawal/moreThanMaximumWithdrawal.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/shared/src/services/alfredpay/types.ts | Refactor AlfredpayTradeLimitError to discriminated union with static factories. |
| packages/shared/src/services/alfredpay/alfredpayApiService.ts | Extract maxQuantity, log diagnostic, dispatch to above()/below() factory. |
| packages/shared/src/endpoints/quote.endpoints.ts | Add AboveUpperLimitSell/AboveUpperLimitBuy quote-error constants. |
| apps/api/src/api/services/quote/index.ts | Extract mapAlfredpayLimitErrorToApiError covering both kinds × directions. |
| apps/frontend/src/stores/quote/useQuoteStore.ts | Pass-through entries for the new upper-limit QuoteError variants. |
| apps/frontend/src/hooks/ramp/useRampValidation.ts | Locale-aware formatting, regex parser for backend limits, buildLimitMessage helper, switch to friendlier translation keys, handle above-max cases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes: #1069
Improves the wording, locale-awareness, and coverage of order-limit error messages, and
adds backend support for above-maximum (upper-bound) limit errors from Alfredpay.
Minimum/Maximum {buy|sell} amount is X SYM.strings instead of theolder
{SYM} orders must be more/less than ...wording, with locale-aware number formatting(
Intl.NumberFormat).errorCode 111426withmaxQuantityinerrorMetadata) and surfaces them as user-facing limit errors. Previously only below-min errors werehandled.
AlfredpayTradeLimitErroris now a discriminated union (kind: "above" | "below"); consumed viastatic factories
AlfredpayTradeLimitError.above()/.below().Changes
Backend
apps/api/src/api/services/quote/index.tsAlfredpayTradeLimitErrorand maps them toAPIErrorvia anew
mapAlfredpayLimitErrorToApiErrorhelper.packages/shared/src/services/alfredpay/alfredpayApiService.tsmaxQuantityalongsideminQuantityfromerrorMetadataand picks the appropriatefactory.
logger.warnwhen a trade-limit error is thrown.packages/shared/src/services/alfredpay/types.tsAlfredpayTradeLimitErrorrefactored to discriminated union:kind,quantity,fromCurrency;private constructor +
static below()/static above()factories.packages/shared/src/endpoints/quote.endpoints.tsQuoteError.AboveUpperLimitSellandQuoteError.AboveUpperLimitBuy.Frontend
apps/frontend/src/hooks/ramp/useRampValidation.tsIntl.toLocaleStringusingi18n.language.buildLimitMessagehelper.(
/of\s+(\d+(?:\.\d+)?)\s+([A-Z]{3})/) and falls back to static config if not present.pages.swap.error.amountOutOfRange.*to the friendlierpages.swap.error.{lessThanMinimumWithdrawal,moreThanMaximumWithdrawal}.{buy,sell}(keys alreadyexisted in
en.json/pt.json).apps/frontend/src/stores/quote/useQuoteStore.tsAboveUpper*QuoteErrorvariants.User-facing (frontend translations)
{SYM} orders must be more than {min} {SYM}Minimum buy amount is {min} {SYM}.{SYM} orders must be less than {max} {SYM}Maximum buy amount is {max} {SYM}.{SYM} orders must be more than {min} {SYM}Minimum sell amount is {min} {SYM}.{SYM} orders must be less than {max} {SYM}Maximum sell amount is {max} {SYM}.Amounts are now locale-formatted (e.g.
10,000.50vs10.000,50) instead of rawBig.toString().Backend
QuoteErrorconstantsBelowLowerLimitSellOutput amount below minimum SELL limit ofBelowLowerLimitBuyInput amount below minimum BUY limit ofAboveUpperLimitSellOutput amount exceeds maximum SELL limit ofAboveUpperLimitBuyInput amount exceeds maximum BUY limit ofInternal (not user-facing)
AlfredpayTradeLimitErrorTrade below minimum: {qty} {ccy}/Trade above maximum: {qty} {ccy}