Repository navigation
feat(social-controllers): route trader reads to the signed-in user's own route - #11325
Draft
xavier-brochard wants to merge 4 commits into
Draft
xavier-brochard wants to merge 4 commits into
xavier-brochard wants to merge 4 commits into
Conversation
…own route fetchTraderProfile, fetchOpenPositions, fetchClosedPositions, fetchTraderFeed, and fetchPositionById are viewer-aware. When the trader is the signed-in user they call GET /v1/traders/me/... (which includes private trading); otherwise they call the public route. The choice stays inside SocialService so callers cannot pick the wrong one. The viewer is read from the bearer token's sub. fetchPositionById accepts an optional profileId to route directly. Add TradingPrivacy and an optional tradingPrivacy on TraderProfileResponse, validated by TraderProfileResponseStruct. Regenerate the messenger action types. Co-authored-by: Cursor <cursoragent@cursor.com>
xavier-brochard
temporarily deployed
to
default-branch
November 5, 2026 14:10 — with
GitHub Actions
Inactive
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ 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 8e099f3. Configure here.
Co-authored-by: Cursor <cursoragent@cursor.com>
xavier-brochard
marked this pull request as draft
November 5, 2026 20:04
… position Without a profileId, fetchPositionById probed the signed-in user's own route first. A 404 there was thrown as an error, so the default service policy retried it before the public fallback ran. The probe now resolves a 404 as null, so the miss is not retried. Owner 200s, owner 500s, and the public fallback on 404 are unchanged. Co-authored-by: Cursor <cursoragent@cursor.com>
The changelog check in CI requires an Unreleased entry that links to the current PR. Link the three new entries to #11325 and note that the owner-route 404 is not retried. Co-authored-by: Cursor <cursoragent@cursor.com>
This branch was previously deployed
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.

Explanation
Five existing
SocialServicemethods are now viewer-aware:fetchTraderProfile,fetchOpenPositions,fetchClosedPositions,fetchTraderFeed, andfetchPositionById. When the trader is the signed-in user, they call the backend'sGET /v1/traders/me/...routes, which include private trading. Otherwise they call the public routes.Mobile callers should not have to choose between the owner and public routes themselves, because picking the wrong one is easy to do. The choice now lives inside
SocialService, so callers cannot pick the wrong route.What changed:
subis read from the bearer token, for routing only. The server still verifies the token.fetchPositionByIdaccepts an optionalprofileId. When it is set, the route is chosen from it directly. Without it, the owner route is tried first, and the public route is used on a 404.fetchTraderProfilematches by profile ID. A wallet address never matches the signed-in user, so pass the profile ID to get your own profile. If the owner route returns a profile other than the one requested, it throws.TradingPrivacytype ('public' | 'private') and an optionaltradingPrivacyfield onTraderProfileResponse.TraderProfileResponseStructvalidates the field, and responses from backends that omit it still parse.Behaviour change: owners of private trading now get their own positions and feed from the existing method names. This is documented under Changed in the CHANGELOG. No public method was removed or renamed.
Backend dependency: the
/v1/traders/me/*routes are implemented inva-mmcx-social-api(TSA-1333, TSA-1334). The backend PRs are being opened separately. The backend/v1/traders/me/*routes must be deployed before this Core release is published.Testing:
yarn workspace @metamask/social-controllers run test:coverage: 301 tests passing, 100% coverage.yarn lint: passed.yarn changelog:validate: passed.SocialService-method-action-types.ts).References
/v1/traders/me/*routes inva-mmcx-social-api, which must be deployed before this Core release is published.Checklist
Note
Medium Risk
Changes how authenticated reads resolve routes and cache keys for trading privacy; wrong routing could hide or expose data until the server enforces authorization on
/traders/me/*.Overview
SocialService now picks owner vs public social-api routes for five trader read methods, so clients keep the same APIs while signed-in users can see private trading on their own data.
When the requested trader matches the bearer token’s
sub(profile ID only—wallet addresses never count as “self”), calls go toGET …/traders/me/…for profile, open/closed positions, trader feed, and position-by-id. Other traders still use the public paths.fetchPositionByIdgains optionalprofileIdfor direct routing; without it, the service tries/traders/me/position/…first and falls back to the public route on 404.fetchTraderProfilethrows if the owner route returns a different profile than requested. Per-user/meresponses usestaleTime: 0so cached data is not shared across viewers.Also adds exported
TradingPrivacyand optionaltradingPrivacyonTraderProfileResponse, plusFETCH_TRADER_PROFILE_MISMATCH, with broad unit tests for JWT parsing edge cases and routing.Reviewed by Cursor Bugbot for commit 4e03580. Bugbot is set up for automated code reviews on this repo. Configure here.