chore(perps): upgrade @metamask/perps-controller to v7.0.0#30861
Conversation
Adapt to breaking change: 'equity' MarketType replaced with granular values 'stock', 'pre-ipo', 'index', and 'etf'. Update all filters, counts, badge styles, category pills, locale strings, and tests.
|
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. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
| m.marketType === 'stock' || | ||
| m.marketType === 'pre-ipo' || | ||
| m.marketType === 'index' || | ||
| m.marketType === 'etf', |
| m.marketType === 'stock' || | ||
| m.marketType === 'pre-ipo' || | ||
| m.marketType === 'index' || | ||
| m.marketType === 'etf' || | ||
| m.marketType === 'commodity', |
| m.marketType === 'stock' || | ||
| m.marketType === 'pre-ipo' || | ||
| m.marketType === 'index' || | ||
| m.marketType === 'etf', |
| (m) => | ||
| m.marketType === 'stock' || | ||
| m.marketType === 'pre-ipo' || | ||
| m.marketType === 'index' || | ||
| m.marketType === 'etf' || | ||
| m.marketType === 'commodity', |
| } else if (market.marketType === 'stock') { | ||
| counts.stocks++; | ||
| } else if (market.marketType === 'pre-ipo') { | ||
| counts.preIpo++; | ||
| } else if (market.marketType === 'index') { | ||
| counts.indices++; | ||
| } else if (market.marketType === 'etf') { | ||
| counts.etfs++; |
| | 'crypto' | ||
| | 'stock' | ||
| | 'pre-ipo' | ||
| | 'index' | ||
| | 'etf' | ||
| | 'commodity' | ||
| | 'forex'; |
There was a problem hiding this comment.
type to be used from core
Address PR review feedback: - Add 'pre-ipo', 'indices', 'etfs' to categoryMap in handleCategorySelect so analytics events fire for the new category filters - Replace raw market type string literals with MarketCategory enum from @metamask/perps-controller across all source files
| type BadgeType = | ||
| | 'experimental' | ||
| | 'stock' | ||
| | 'pre-ipo' | ||
| | 'index' | ||
| | 'etf' | ||
| | 'commodity' | ||
| | 'crypto' | ||
| | 'forex'; |
There was a problem hiding this comment.
Is this a type that can also be extracted from core?
There was a problem hiding this comment.
Noticing that this is in a test file. Weird that we need to declare a type specifically for a test
Replace manually defined market type union with MarketType imported from @metamask/perps-controller, per reviewer feedback.
Replace ~8 inline four-way disjunctions (Stock || PreIpo || Index || Etf) with the existing isEquityAsset() helper from marketHours.ts. This ensures a single source of truth so future stock-like categories only need updating in STOCK_LIKE_MARKET_TYPES.
…om source - Replace raw string literals for pre-ipo/indices/etfs analytics values with named constants following the established snake_case convention. - Import BadgeType from PerpsBadge.types in view test instead of re-declaring it inline.
Group the temporary PRE_IPO, INDICES, ETFS analytics constants into a LOCAL_BUTTON_CLICKED object mirroring PERPS_EVENT_VALUE.BUTTON_CLICKED shape for consistency and easier future migration.
|
Do not merge, need to test |
| m.marketType === 'equity' || | ||
| m.marketType === 'commodity' || | ||
| m.marketType === 'forex', | ||
| isEquityAsset(m.marketType) || |
There was a problem hiding this comment.
We shouldn’t call this equity anymore right?
There was a problem hiding this comment.
Technically yeah, I wanted to make it a bit easier to review, hereby it's still called equity in this helper. Can change it in the next PR
Remove pre-ipo, indices, and etfs from default category badges since they share the stocks tab. Use isEquityAsset helper for the stocks filter to match all stock-like market types consistently.
|
Made some updates, as the intent of this PR is not to make any UI changes |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #30861 +/- ##
==========================================
- Coverage 82.72% 82.70% -0.02%
==========================================
Files 5566 5573 +7
Lines 143286 143466 +180
Branches 33099 33165 +66
==========================================
+ Hits 118529 118653 +124
- Misses 16870 16901 +31
- Partials 7887 7912 +25 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
geositta
left a comment
There was a problem hiding this comment.
One clarification for the v7 migration: since the dedicated UI treatment for pre-ipo, indices, and etfs is planned for a later PR, should this branch keep those categories hidden from availableCategories even when v7 data contains them? Right now the categories are only visible when counts are nonzero, so the current data still looks unchanged, but the code path would expose those pills as soon as those market types appear.
…cated UI These categories would be exposed as soon as v7 data includes markets of those types. Since the dedicated UI treatment is planned for a follow-up PR, keep them hidden from availableCategories for now.
…ilters These market types are folded into the existing "Stocks" category via isEquityAsset. Removes dedicated badge styles, filter branches, analytics mappings, and test coverage for pre-ipo/index/etf as standalone categories.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 538e96f. Configure here.
…est assertions The marketCounts object no longer includes these fields after the category cleanup, so the test expectations need to match.
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: Performance Test Selection: |

Description
Upgrades
@metamask/perps-controllerfrom v6.3.0 to v7.0.0 and adapts to the breaking change where the'equity'MarketType has been replaced with granular values:'stock','pre-ipo','index', and'etf'.Why: The upstream controller published a major version bump (#8892) that splits the former catch-all
'equity'type into specific sub-types for stocks, pre-IPO markets, indices, and ETFs. This gives more precise data-model categorization and enables dedicated UI category pills for each sub-type.What changed:
@metamask/perps-controllerto^7.0.0marketType === 'equity'checks to use the new granular typespre-ipo,indices,etfs) in market list and category badgesequitystyle)isEquityAsset()helper to check against all stock-like typesChangelog
CHANGELOG entry: null
Related issues
Fixes: N/A — upstream dependency upgrade
Manual testing steps
Screenshots/Recordings
N/A — no visual design changes; existing styles are mapped to new type keys.
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Note
Medium Risk
Touches market categorization across list, home, trending feeds, and badges; misclassification could hide or mislabel markets, but changes are mostly mechanical with broad test updates.
Overview
Upgrades
@metamask/perps-controllerto v7 and aligns the app with the breaking change that removes the singleequitymarket type in favor ofstock,pre-ipo,index, andetf.Stock-like assets are grouped via
isEquityAsset()(backed byMarketCategoryandSTOCK_LIKE_MARKET_TYPES), so market hours banners, home/list filtering, and Trending Stocks pills still treat all four types like the old equity bucket.marketCounts.equitybecomesstocks, commodity/forex checks useMarketCategory, andPerpsBadge/ i18n dropequityforstockplus new badge strings for pre-IPO, index, and ETF. Tests andUrlAutocompletetypes are updated accordingly; locale adds tab labels for Pre-IPO, Indices, and ETFs ahead of dedicated list filters.Reviewed by Cursor Bugbot for commit d9be4f9. Bugbot is set up for automated code reviews on this repo. Configure here.