Repository navigation
Conversation
53683f1 to
366f0e5
Compare
de1cebf to
b34a7ac
Compare
57aca30 to
1dc195a
Compare
🛑 Files requiring codeowner reviewTo merge this PR, you'll need to get approvals from the following owners. @MetaMask/core-platform (8 files)
@MetaMask/metamask-assets (55 files)
@MetaMask/social-ai (1 file)
@MetaMask/core-platform (expand for more) |
7fcd76f to
e80304d
Compare
|
@metamaskbot publish-previews |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
1bf8168 to
70269bb
Compare
|
@metamaskbot publish-previews |
|
The "Publish preview" workflow has been updated to a new version that uses OIDC for authentication. Please use the new workflow instead of this one. To trigger the new workflow, go to the Publish a preview build workflow, click "Run workflow", and enter |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
70269bb to
cf24e3c
Compare
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
c552582 to
3927e09
Compare
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
f6d6c8b to
826c10a
Compare
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
826c10a to
afc94f7
Compare
afc94f7 to
ef8fdc8
Compare
| error, | ||
| }, | ||
| ); | ||
| return; |
There was a problem hiding this comment.
Failed subscribe never retries while connected
Medium Severity
#subscribeOnSocket keeps a channel in #channels but never sends it when channelHasSubscription throws, or when subscribe fails with any error that does not contain Request failed. Those channels wait for the next CONNECTED event, so a failure while already connected is not retried and live quotes never start.
Reviewed by Cursor Bugbot for commit ef8fdc8. Configure here.
There was a problem hiding this comment.
Not applicable on the current code. A request timeout closes the socket, and the CONNECTED handler sends the tracked channels again in one frame. A gateway refusal goes through #forget and is left closed so a session-cap rejection is not retried. A failure that leaves the channel tracked is sent again on the next connect.
e5e37c5 to
a81375a
Compare
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
d96e511 to
cabf5ed
Compare
cabf5ed to
e122a49
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort 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 e122a49. Configure here.
| this.#getAssetIdsFromBalanceState(subscription.request), | ||
| ); | ||
| await this.#marketStats.reconcile(this.#candidatesFor(assetIds)); | ||
| } |
There was a problem hiding this comment.
Teardown loses in-flight stream reconcile
Medium Severity
#reconcileMarketStats only checks #subscription before an await on #filterToSupportedPriceableAssets. If unsubscribe or destroy runs during that fetch, MarketStatsPriceStream still subscribes afterward. MarketStatsService serializes those calls, so a teardown subscribe([]) can be followed by the in-flight list and reopen assets-controller channels after lock, UI close, or controller destroy.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit e122a49. Configure here.
Co-authored-by: Cursor <cursoragent@cursor.com>
e122a49 to
98d550d
Compare
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |


Explanation
https://www.loom.com/share/a7c45936a44344be86349497c916ad0c
Spot prices today come from a poll of
GET /v3/spot-pricesand are stored onAssetsControllerasassetsPrice. A screen can only show that polled price, and it does not update until the next poll.This adds a live quote next to that poll. The gateway already publishes price changes on
market-stats.v1. The wallet opens one channel per asset and currency (market-stats.v1.<caip-19>.<currency>), and the gateway sends every change as one batch onmarket-stats.v1, about every 30 seconds. Chain health arrives onsystem-notifications.v1.market-stats.v1.A screen reads two prices:
assetsPriceis still the polled price.PriceDataSourcewrites it, and it is what gets persisted.MarketStatsStoreis an in-memory cache of the latest socket quote. A tick updates that store and does not write Redux, so it does not persist and does not notifyAssetsController.The screen shows the live quote when the store has one for that asset. Otherwise it shows the polled price.
PriceDataSourceasks forincludeWssSupportField=true. After each poll it opens channels, in onesubscribecall, for tracked assets whose stored price haswssSupport: true. Hidden assets stay out. Assets withoutwssSupport, assets the gateway rejects, and assets on a chain reported down stay on the poll. A rejected channel is retried on the next poll. A down chain waits a short delay, then polls again. IfMarketStatsServiceis not registered, every asset stays on the poll.Screens for an asset the account does not hold (explore, search, an asset page with no balance row) call
MarketStatsService:subscribethemselves. That quote lands in the same store. Nothing is written toassetsPrice.Design notes that are easy to miss:
market-stats.v1.subscribedoes not add another hold, so the caller'sunsubscribecloses it. If the asset is also in the tracked set, the next price-poll reconcile opens it again.errorevent with no request id fails only the in-flight market-stats subscribe it names.subscriberegisters the chain-status callback and the batch callback. There is noinit().@metamask/assets-controllerneeded two other packages:@metamask/core-backendowns the shared socket, soMarketStatsServicelives there.ChannelSubscriptionManagernow subscribes and unsubscribes many channels in one frame, which market stats uses and OHLCV keeps using.BackendWebSocketService.subscribeskips channels the socket already has, and a partial subscribe keeps the channels the gateway accepted.@metamask/walletconstructsMarketStatsServiceand delegates theBackendWebSocketServiceactions it needs.Walletdoes not constructBackendWebSocketService. The host still registers that service. The firstsubscribeis what starts listening.Breaking changes
AssetsController:priceChangedis removed. Socket ticks areMarketStatsService:pricesUpdated. Polled prices stay inassetsPrice.AssetsControllerMessengernow includesMarketStatsService:subscribe,unsubscribe,getSubscriptions,getChainStatuses, andchainStatusChanged. Delegate them from the root messenger.PriceDataSourcerequiresmessenger. The stream is always constructed. With no registeredMarketStatsService, every asset stays on the poll.Walletnow registersMarketStatsService. A host that already registers that service on the wallet messenger must remove that registration before upgrading.References
Checklist
Note
High Risk
Breaking controller/messenger and price event contracts, plus new WebSocket subscription behavior on the shared backend socket that affects how prices are sourced and displayed.
Overview
Adds live spot prices alongside the existing
/v3/spot-pricespoll: tracked assets withwssSupportopenmarket-stats.v1channels through newMarketStatsPriceStreamwired intoPriceDataSource(now requires a messenger withMarketStatsServiceactions). Polling still covers every tracked asset and requestsincludeWssSupportField=true; socket ticks are not merged intoassetsPrice.Breaking: removes
AssetsController:priceChanged; consumers subscribe toMarketStatsService:pricesUpdatedand use the re-exported quote helpers from@metamask/core-backend, which addsMarketStatsServiceand related WS plumbing.AssetsControllerreconciles streams after balance writes and reopens channels after currency refresh;BackendWebSocketServicenow surfaces partial subscribe failures andunsubscribeChannels.Includes architecture docs, changelogs, and broad test/fixture updates (fungible price shape, Stellar account types, lint suppressions).
Reviewed by Cursor Bugbot for commit 98d550d. Bugbot is set up for automated code reviews on this repo. Configure here.