Expose replacement implementations of `QueryClient` APIs in UI

未關閉
#8,531 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
5/5
預估耗時
一週以上
新手友好度
25/100
Issue 類型
功能
描述清晰度
需要釐清
活躍度
冷清
技術堆疊
typescript
領域
frontend

研究方向

先閱讀遭阻塞的 issue #8530 和 ADR 0020 PR #131,以了解 guard 設計和待完成的對齊工作。檢視 createUIQueryClient API,以及此處所述的 react-router v6 createHashRouter/RouterProvider 遷移。完成的標準是為樂觀更新、路由載入器和 getQueryCache 變更選擇並交付獲批准的替代方案。

由索引模型根據 Issue 內容生成。

描述

Tracks follow-up work after the initial guard implementation (#8530) and ADR-level alignment on PR #131.


Subissues

Replacement: optimistic-update alternative for data-service-backed state (setQueryData / setQueriesData)

#8530 throws on these for data-service keys. This ticket designs and ships a sanctioned alternative so feature teams can still do optimistic UI updates. Options (pending ADR 0020 PR #131 resolution):

  • Messenger-dispatched primitive: dataService.setOptimisticCacheData(queryKey, updater) that writes to the background cache and propagates via cacheUpdated → hydrate(). Loses synchronous-write semantics; cold-path MV3 SW wake-up (100–300ms) makes worst case materially slower than the canonical pattern.
  • Sanctioned UI facade with explicit rollback on mutation failure. Preserves synchronous-write semantics.
  • Explicit ADR statement that optimistic updates for data-service keys are out of scope under Option A.

File after PR #131 alignment on which option to pursue.


Replacement: route-loader integration for data-service keys (ensureQueryData / ensureInfiniteQueryData)

#8530 throws on these for data-service keys. This ticket designs and ships a sanctioned loader-compatible alternative. Extension is mid-transition to react-router v6 data-router (createHashRouter + RouterProvider), where loader: () => queryClient.ensureQueryData(...) is the natural pattern. Options (pending PR #131 resolution):

  • ensureDataServiceQueryData(routeMessenger, queryKey) — dispatches to the service via the route messenger, awaits cache population. Composes with the UI messengers ADR RouteMessenger authorization boundary. Requires route-messenger-manager or closure-injected handle (UI messengers ADR Option 1B).
  • Block loaders from consuming data-service keys; treat route data loading as React-side only (useSuspenseQuery in route component).

File after PR #131 alignment on which option to pursue.


getQueryCache() facade**

client.getQueryCache().build/.add/.remove bypasses all instance-shadowing from #8530. Two design options:

  • Shadow getQueryCache to return a facade that gates mutating methods by key prefix
  • Stop returning a raw QueryClient from createUIQueryClient — return a narrower facade (breaking API change)

File after Layer 1 (#8530) is validated and a design option is chosen.


Dependencies

Blocked on: #8530 (Layer 1 guards)
Blocked on (replacements): ADR 0020 PR #131 resolution

主要語言
TypeScript
星號
424
分支
311
平均合併
1 天 8 小時
30 天內合併 PR
446

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 有 Pull Request 範本
  • 沒有貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

MetaMask/core 的其他 Issue

查看 MetaMask/core 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。