You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a Simulate COOP toggle to the eth_requestAccounts card in the testapp.
Register a static service worker that injects Cross-Origin-Opener-Policy: same-origin for ?coop=same-origin navigations, so the simulation works on GitHub Pages.
Keep the change scoped to the playground by adding a children slot to RpcMethodCard for the toggle UI.
PR title: feat(testapp): add COOP simulation toggle — valid Conventional Commits format, no changes needed.
Scope: All changes are confined to examples/testapp (playground app, not published). No SDK or library code is affected.
Assessment: Clean, well-scoped change. No issues found.
Details reviewed:
Service worker (coop-service-worker.js): Correctly intercepts only same-origin navigation requests with the ?coop=same-origin query param. Properly strips content-encoding and content-length headers to avoid body/header mismatches when injecting the COOP header. skipWaiting + clients.claim ensures immediate activation.
RpcMethodCard typing: Previously untyped props (implicit any) now have proper types derived from RpcRequestInput and ShortcutType. The children?: ReactNode slot is a clean extension. The values type narrowing from implicit any to object | readonly unknown[] is a correctness improvement.
connectionMethodShortcutsMap: Explicit Record<string, ShortcutType[]> annotation enables safe indexed access (returns ShortcutType[] | undefined) for the new connectionMethodShortcutsMap[rpc.method] usage pattern.
COOP toggle logic: ensureCoopServiceWorkerReady correctly handles edge cases (no SW support, already-controlled page, 1s timeout fallback). window.location.assign forces a full navigation, which is necessary for the service worker to intercept the request and inject the COOP header.
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
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.
Summary
eth_requestAccountscard in the testapp.Cross-Origin-Opener-Policy: same-originfor?coop=same-originnavigations, so the simulation works on GitHub Pages.childrenslot toRpcMethodCardfor the toggle UI.Test plan
yarn biome lint examples/testapp/src/pages/index.page.tsx examples/testapp/src/components/RpcMethods/RpcMethodCard.tsx examples/testapp/src/components/RpcMethods/shortcut/connectionMethodShortcuts.ts examples/testapp/public/coop-service-worker.jsyarn workspace sdk-playground typecheckyarn workspace sdk-playground build(passes with existing unrelated export warnings for prolink/spend-permission imports)Made with Cursor