feat(perps): prepare migration to perpscontroller to core#24549
feat(perps): prepare migration to perpscontroller to core#24549abretonc7s merged 6 commits intomainfrom
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsThis PR is a focused refactoring of the Perps (Perpetuals trading) feature with the following changes:
All changes are exclusively within the Perps feature ( The SmokePerps tag is the only relevant tag since:
Risk is medium because:
|
|


Description
This PR removes all i18n dependencies (
strings()calls) from core-bound Perps files to prepare for migration to@metamask/perps-controllerin the core monorepo.Why?
Core monorepo packages must be i18n-agnostic. Previously, several Perps files used
strings()for translated error messages and time formatting, which created a dependency on the mobile i18n system.What changed?
PERPS_ERROR_CODES.ORDER_SIZE_MIN) instead of translated stringsestimatedMinutes: numberinstead of formatted strings; UI hooks handle formattingtranslatePerpsError.tsandperpsErrorHandler.tsfiles handle translating error codes to user-facing messagesFiles modified:
perpsErrorCodes.ts- Added 6 new validation error codesHyperLiquidProvider.ts- Removed all 17strings()calls (15 error messages + 2 time formatting)translatePerpsError.ts- Added mappings for new error codesperpsErrorHandler.ts- Added mappings for new error codesHyperLiquidProvider.test.ts- Updated test expectations to use error codes and raw time valuesusePerpsWithdrawQuote.ts- Added time formatting logic (moved from provider)usePerpsOrderValidation.ts- AddedtranslatePerpsErrorfor protocol validation errorscontrollers/types/index.ts- AddedestimatedMinutes?: numbertoAssetRoute.constraintsNew error codes added:
ORDER_SIZE_POSITIVE- Order size must be positiveORDER_PRICE_REQUIRED- Price is required for validationORDER_SIZE_MIN- Order value below minimumORDER_LEVERAGE_INVALID- Leverage outside valid rangeORDER_LEVERAGE_BELOW_POSITION- Leverage below existing position requirementORDER_MAX_VALUE_EXCEEDED- Order value exceeds maximumChangelog
CHANGELOG entry: null
Related issues
Part of: PerpsController migration to core monorepo (Stages 1 & 2 complete)
Manual testing steps
Screenshots/Recordings
N/A - No visual changes. Error messages and time displays appear identically to before.
Before
strings()calls in HyperLiquidProviderstrings('time.minutes_format_plural', ...)After
estimatedMinutes: number, formatted inusePerpsWithdrawQuotehookPre-merge author checklist
Pre-merge reviewer checklist
Note
Decouples i18n from core-bound Perps logic and prepares for controller extraction.
PERPS_ERROR_CODES(adds many new codes) and replacesstrings()usage;translatePerpsErrorhandles UI translationutil/errorUtils.ensureErrorand updates imports across views/hooks/servicesestimatedMinutes(adds toAssetRoute.constraints); UI (usePerpsWithdrawQuote) formats timeHyperLiquidProvider, validation utils, and order calculations to emit error codes; adjusts tests to expect codes/minutesWritten by Cursor Bugbot for commit a711c1d. This will update automatically on new commits. Configure here.