Repository navigation
feat: add Launchpad TDP WS service and extract shared Channel Sub manager - #10884
Conversation
…ubscriptionManager
|
@metamaskbot publish-preview |
1 similar comment
|
@metamaskbot publish-preview |
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
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 0f1d8ee. Configure here.
| * @param raw - The raw abbreviated-key event. | ||
| * @returns The normalized event. | ||
| */ | ||
| export function normalizeEvent( |
There was a problem hiding this comment.
Why not keeping the raw data structure from the backend?
There was a problem hiding this comment.
Mainly readability + isolating backend changes. The wire keys are intentionally "unfriendly" (gp, mc, snhp, t10hp, gs…) to keep payloads small, so normalizing to graduationPercent / marketCap / etc. keeps consumers from hard-coding abbreviations. And it means if the backend renames a key or changes shape, only normalize.ts changes instead of every call site.
| export const LAUNCHPAD_TDP_SERVICE_ALLOWED_ACTIONS = [ | ||
| 'BackendWebSocketService:connect', | ||
| 'BackendWebSocketService:forceReconnection', | ||
| 'BackendWebSocketService:subscribe', | ||
| 'BackendWebSocketService:getConnectionInfo', | ||
| 'BackendWebSocketService:channelHasSubscription', | ||
| 'BackendWebSocketService:getSubscriptionsByChannel', | ||
| 'BackendWebSocketService:findSubscriptionsByChannelPrefix', | ||
| 'BackendWebSocketService:addChannelCallback', | ||
| 'BackendWebSocketService:removeChannelCallback', | ||
| ] as const; |
There was a problem hiding this comment.
This list is the same as OHLCV_SERVICE_ALLOWED_ACTIONS, and after the extraction neither service calls BackendWebSocketService itself. Every call is inside ChannelSubscriptionManager.
Define the list once in the manager and spread it from each service constant. Keep OHLCV_SERVICE_ALLOWED_ACTIONS and LAUNCHPAD_TDP_SERVICE_ALLOWED_ACTIONS as the public exports: getRestricted grants these actions to the messenger named OHLCVService / LaunchpadTokenDetailsService, and the manager only borrows that messenger.
export const CHANNEL_SUBSCRIPTION_MANAGER_ALLOWED_ACTIONS = [
'BackendWebSocketService:connect',
'BackendWebSocketService:forceReconnection',
'BackendWebSocketService:subscribe',
'BackendWebSocketService:channelHasSubscription',
'BackendWebSocketService:getSubscriptionsByChannel',
'BackendWebSocketService:addChannelCallback',
'BackendWebSocketService:removeChannelCallback',
] as const;export const LAUNCHPAD_TDP_SERVICE_ALLOWED_ACTIONS = [
...CHANNEL_SUBSCRIPTION_MANAGER_ALLOWED_ACTIONS,
] as const;
Those are the actions the manager actually calls. getConnectionInfo and findSubscriptionsByChannelPrefix are on both lists and are never called (same on main for OHLCV), so leave them off the shared list.
Do the same for the allowed-events arrays (connectionStateChanged is the only one). A service that later calls something else adds that action to its own constant.
|
Nice refactor ;) |
…onManager constant
## Explanation
Release 1377.0.0. This PR only bumps versions, finalizes changelogs,
updates dependency ranges, and refreshes `yarn.lock`. The behavior
shipped here is already on `main`.
Three packages are major releases because their unreleased changelogs
include breaking changes:
- `@metamask/transaction-controller` `72.3.0` → `73.0.0`. Simulation now
goes through `SentinelApiService:simulateTransactions`. Consumers must
construct a `SentinelApiService` and delegate that action.
`getSimulationConfig` now returns `{ newUrl?: string }` only
([MetaMask#9476](MetaMask#9476)).
- `@metamask/core-backend` `12.3.0` → `13.0.0`.
`OHLCV_SERVICE_ALLOWED_ACTIONS` no longer includes
`BackendWebSocketService:getConnectionInfo` or
`BackendWebSocketService:findSubscriptionsByChannelPrefix`
([MetaMask#10884](MetaMask#10884)). This release
also adds `fetchV5MultiAccountTransactions`
([MetaMask#11194](MetaMask#11194)),
`LaunchpadTokenDetailsService`, and `ChannelSubscriptionManager`
([MetaMask#10884](MetaMask#10884)).
- `@metamask/wallet` `20.0.0` → `21.0.0`. Default initialization now
includes `NetworkEnablementController`, and the wallet messenger
delegates `SentinelApiService:simulateTransactions`. Clients must
register `MultichainNetworkController:getState` and
`SentinelApiService:simulateTransactions` on the wallet messenger
([MetaMask#10997](MetaMask#10997),
[MetaMask#9476](MetaMask#9476)).
These packages are included so they can depend on
`transaction-controller` `^73.0.0` and, where they use it,
`core-backend` `^13.0.0`:
| Package | Version |
| --- | --- |
| `@metamask/assets-controller` | `20.1.0` |
| `@metamask/assets-controllers` | `113.0.1` |
| `@metamask/bridge-controller` | `83.1.3` |
| `@metamask/bridge-status-controller` | `78.0.1` |
| `@metamask/client-utils` | `3.1.0` |
| `@metamask/eip-5792-middleware` | `4.1.0` |
| `@metamask/gator-permissions-controller` | `6.1.0` |
| `@metamask/money-account-utils` | `2.2.0` |
| `@metamask/network-enablement-controller` | `7.1.0` |
| `@metamask/phishing-controller` | `18.3.0` |
| `@metamask/profile-metrics-controller` | `5.2.1` |
| `@metamask/shield-controller` | `7.1.1` |
| `@metamask/smart-transactions-controller` | `27.2.1` |
| `@metamask/social-controllers` | `3.14.1` |
| `@metamask/subscription-controller` | `15.1.2` |
| `@metamask/transaction-pay-controller` | `30.3.2` |
| `@metamask/transaction-pay-middleware` | `2.0.1` |
| `@metamask/user-operation-controller` | `42.1.0` |
Notable changes besides the dependency bumps:
- `@metamask/assets-controller`: optional `pricePercentChange5m` and
`pricePercentChange4h` on `FungibleAssetPrice`
([MetaMask#11201](MetaMask#11201)).
- `@metamask/client-utils`: `predictionSettled` on `ActivityKind`
([MetaMask#11169](MetaMask#11169)), plus fee fixes
for contract-interaction fallback and OP Stack L1/operator fees
([MetaMask#11013](MetaMask#11013),
[MetaMask#9630](MetaMask#9630)).
- `@metamask/network-enablement-controller`: preserve enablement when a
config-registry network is auto-enabled
([MetaMask#10763](MetaMask#10763)).
- `@metamask/phishing-controller`: Arc (`0x13b2`) token scanning
([MetaMask#11144](MetaMask#11144)).
- `@metamask/transaction-pay-controller`: shared recipient resolution
and Hyperliquid perps deposit detection
([MetaMask#10887](MetaMask#10887),
[MetaMask#11026](MetaMask#11026)).
`@metamask/earn-controller`, `@metamask/money-account-mfa-whitelist`,
`@metamask/money-account-upgrade-controller`,
`@metamask/network-connection-banner-controller`,
`@metamask/perps-controller`, and `@metamask/signature-controller` only
have dependency ranges updated. They are not version-bumped and are not
published in this release.
## References
* [MetaMask#9476](MetaMask#9476)
* [MetaMask#9630](MetaMask#9630)
* [MetaMask#10763](MetaMask#10763)
* [MetaMask#10884](MetaMask#10884)
* [MetaMask#10887](MetaMask#10887)
* [MetaMask#10997](MetaMask#10997)
* [MetaMask#11013](MetaMask#11013)
* [MetaMask#11026](MetaMask#11026)
* [MetaMask#11144](MetaMask#11144)
* [MetaMask#11169](MetaMask#11169)
* [MetaMask#11194](MetaMask#11194)
* [MetaMask#11201](MetaMask#11201)
## Checklist
<!--
- [ ] I've updated the test suite for new or updated code as appropriate
- [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
-->
- [x] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md)
- [ ] I've introduced [breaking
changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md)
in this PR and have prepared draft pull requests for clients and
consumer packages to resolve them
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> The diff is low-risk mechanically, but the published majors force
client upgrades around transaction simulation, backend WebSocket
actions, and wallet messenger registration—areas that affect core wallet
behavior.
>
> **Overview**
> This PR cuts **release 1377.0.0** by bumping the root monorepo
version, publishing new semver tags for many `@metamask/*` packages,
moving unreleased changelog entries into versioned sections, updating
inter-package dependency ranges, and refreshing **`yarn.lock`**. There
is **no new application logic** in the diff—only release bookkeeping for
work already on `main`.
>
> The release centers on three **major** packages whose changelogs
document breaking changes: **`@metamask/transaction-controller`
`73.0.0`** (simulation via `SentinelApiService:simulateTransactions`;
`getSimulationConfig` shape change), **`@metamask/core-backend`
`13.0.0`** (WebSocket allowed-actions cleanup plus new backend
APIs/services), and **`@metamask/wallet` `21.0.0`** (default
`NetworkEnablementController` wiring and Sentinel simulation delegation
on the wallet messenger). Dozens of other packages are **minor/patch
bumped** mainly to depend on **`transaction-controller` `^73.0.0`** and,
where applicable, **`core-backend` `^13.0.0`**.
>
> Several workspaces only have **`package.json` dependency range
updates** (e.g. `earn-controller`, `money-account-upgrade-controller`,
`signature-controller`) without a version bump in this PR. A few
packages also document **feature fixes** in their new changelog sections
(e.g. `assets-controller` price change fields, `client-utils` activity
kinds/fees, `phishing-controller` Arc scanning) as part of the versions
being published here.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
5a253e4. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com>

Explanation
This PR lands Phase 1 of the Launchpad (memecoin) WebSocket work in
@metamask/core-backend, scoped to Token Detail Pages (TDP), and refactors the existing OHLCV lifecycle into a shared, reusable helper first (extract-first).Per the
launchpad-tokens.v1gateway docs, Token Details are delivered per-asset on the asset's own channel (launchpad-tokens.v1.<assetId>) with the fullcreated | stats | migratedlifecycle — i.e. the same "subscribe-channel == delivery-channel" shape as OHLCV, and distinct from Discovery/Explore's top-level fan-in. Because TDP is OHLCV-shaped, the per-channel subscription machinery is identical, so it is extracted once and shared rather than cloned.What changed
ChannelSubscriptionManager(src/ws/ChannelSubscriptionManager.ts) — the channel-agnostic subscription lifecycle extracted out ofOHLCVService: reference counting, grace-period unsubscribe, grace-period flush, unsubscribe retry with backoff +forceReconnection, idempotency, resubscribe-on-reconnect, and optional system-notifications registration. Consumed by composition (not inheritance) via options (messenger,channelType,onMessage,onSubscriptionError, system-notifications channel/handler,onConnectionStateChange); grace/retry are overridable for tests.OHLCVServicerefactor (behavior-preserving) — reduced to its domain concerns (channel building, bar forwarding,#chainsUpchain status) and now delegates its lifecycle to aChannelSubscriptionManager. No change to its public API, messenger, exposed actions, or published events — its existing test suite passes unchanged, which is the proof the extraction preserves behavior.LaunchpadTokenDetailsService(src/ws/launchpad/) — a stateless service (mirroring the OHLCV pattern) that owns aChannelSubscriptionManager, subscribes/unsubscribes per-asset byassetId, parses each delivered batch, and publishes a singletokenUpdatedper batch. It keeps system-notifications handling, forwarding upstream status asstatusChanged, and publishessubscriptionError.src/ws/launchpad/types.ts,normalize.ts) — dependency-free event types (raw abbreviated-key shapes + a normalizedcreated | stats | migrateddiscriminated union), plusnormalizeEvent,parseBatch(array-tolerant, skips partial/invalid entries), andbuildChannel(assetId). Kept pure so a later Explore phase can import it directly.src/ws/launchpad/index.ts, packagesrc/index.tsexports for the service, the manager, and launchpad types, and the auto-generatedLaunchpadTokenDetailsService-method-action-types.ts.Out of scope (tracked for later phases): Explore / the stateful
BaseController(ring buffer, eviction, cross-source merge/reconcile) and allmetamask-mobilewiring (Engine init, hooks, StatBar).One open implementation detail (non-blocking)
Per-asset TDP routing is implemented via Rail A (the
subscribe()callback, keyed bysubscriptionId), matching OHLCV verbatim. If a real TDP frame turns out to be channel-name-only (nosubscriptionId), the swap toaddChannelCallbackis isolated to the manager's subscribe path and does not change the public design. This only needs a quick confirmation against a live frame.References
packages/core-backend/src/ws/launchpad/LAUNCHPAD_WS_ARCHITECTURE.mdChecklist
Note
Medium Risk
Shared WebSocket subscription lifecycle moves behind a new abstraction used by OHLCV and launchpad; behavior should be preserved for OHLCV but reconnect/unsubscribe edge cases affect both services. Breaking messenger allowlists require consumers that relied on the removed OHLCV actions to grant them explicitly.
Overview
Introduces
LaunchpadTokenDetailsServicefor per-asset launchpad token detail streaming over the backend WebSocket (subscribe/unsubscribebyassetId), withtokenUpdated,statusChanged, andsubscriptionErrorevents plus purenormalize/parseBatch/buildChannelhelpers forcreated | stats | migratedbatches.Extracts
ChannelSubscriptionManagerfrom OHLCV (ref counting, grace-period unsubscribe/flush, unsubscribe retry +forceReconnection, resubscribe on reconnect, optional system notifications) and refactorsOHLCVServiceto use it via composition while keeping the same public API and events.Breaking:
OHLCV_SERVICE_ALLOWED_ACTIONSno longer includes unusedgetConnectionInfoandfindSubscriptionsByChannelPrefix; OHLCV and launchpad allowed actions/events now share the minimalCHANNEL_SUBSCRIPTION_MANAGER_*set. Package exports and changelog are updated; new unit tests cover the manager, launchpad service, and normalizers.Reviewed by Cursor Bugbot for commit b388afd. Bugbot is set up for automated code reviews on this repo. Configure here.