Repository navigation
feat: send x-mm-service-profile on token search (assets-controllers ^113.2.0) - #47655
Conversation
…113.2.0) Bump @metamask/assets-controllers to ^113.2.0, whose searchTokens sends x-mm-service-profile (default assets--trending-search). Pass it explicitly from useDiscoverCryptoSearch and add the same header to the local /tokens/search helper used by useTokenSearch so every token search request is tagged. Refs: ASSETS-4243
|
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.
|
Builds ready [9d7e1ce]
⚡ Performance Benchmarks (Total: 🟢 5 pass · 🟡 5 warn · 🔴 3 fail)
Bundle Size Diffs
|
|
|
No release label on PR. Adding release label release-13.57.0 on PR, as PR was added to branch 13.57.0 when release was cut. |



Description
Token search requests now send the
x-mm-service-profile: assets--trending-searchheader, so backend services can identify this traffic (ASSETS-4243). This is the extension version of MetaMask/metamask-mobile#38852.The extension makes
/tokens/searchrequests from two places:ui/hooks/discover-search/useDiscoverCryptoSearch.ts) calls core'ssearchTokens. Since feat(assets-controllers): send x-mm-service-profile header in searchTokens core#11274 (released in@metamask/assets-controllers113.2.0), core sends this header withassets--trending-searchas the default. The hook now also passesserviceProfileexplicitly.ui/hooks/useTokenSearch.ts) uses a local helper,shared/lib/token-search/token-search-api.ts, that builds its own/tokens/searchURL. Bumping the package alone would not tag these requests. Core'ssearchTokenscan't replace this helper as-is: it has a different signature and response shape, and it takes noAbortSignal. So the helper's fetch now adds the header itself.Changes:
@metamask/assets-controllersfrom^113.1.1to^113.2.0. Peer dependencies are the same as 113.1.1. The only transitive change is theuuidrange (^14.0.1→^14.0.2), which still resolves to 14.0.3, so there are no LavaMoat policy changes. The lockfile is deduped.TOKEN_SEARCH_SERVICE_PROFILE = 'assets--trending-search', used by both paths.serviceProfileon both the first page and the next page of the Discover search.access-control-allow-headers: x-client-id,x-mm-service-profile).Note: the token-management search is tagged as
assets--trending-search, the same profile core now uses by default for everysearchTokenscaller. If backend wants a separate profile for it, that is a one-line change to the constant.Changelog
CHANGELOG entry: null
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/ASSETS-4243
Refs: MetaMask/core#11274, MetaMask/metamask-mobile#38852
Manual testing steps
GET /tokens/searchrequest includes the headerx-mm-service-profile: assets--trending-search. Scroll to load more results and check that the paginated request sends the same header./tokens/searchrequest includesx-mm-service-profile: assets--trending-searchand still includesX-Client-Id: extension.Pre-merge author checklist
Pre-merge reviewer checklist
Adversarial review (adverse)
Final verdict (round 2/3): SHIP (unanimous, 3/3)
Findings: 0 critical · 1 warning · 11 info (across both rounds). Fixed: the comment wrongly said the constant "matches the core default" (round 1 warning); it now says both paths pass the constant explicitly. Declined: none. Info items were not actioned (some are notes only, e.g. that the header is not a trust boundary and that the transitive
uuidrange changed).Reviewer: claude -p via adverse 0.2.1 (3 personas, 2 rounds).
Note
Low Risk
Adds a request header and bumps a dependency; no auth, signing, or response parsing changes beyond what tests cover.
Overview
Extension token search traffic is now tagged for backend analytics by sending
x-mm-service-profile: assets--trending-searchon every/tokens/searchcall, alongside the existingX-Client-Id: extension.A shared
TOKEN_SEARCH_SERVICE_PROFILEconstant keeps both call paths aligned: Discover crypto search passesserviceProfileinto@metamask/assets-controllerssearchTokens(including paginated loads), and the localshared/lib/token-search/token-search-apihelper (used for import/manage token search) sets the same header on its direct fetch.@metamask/assets-controllersis bumped to^113.2.0so core’s search client supports the option; tests assert the headers andserviceProfileon first and next pages.Reviewed by Cursor Bugbot for commit 9d7e1ce. Bugbot is set up for automated code reviews on this repo. Configure here.