Skip to content

feat(testapp): add COOP simulation toggle#290

Merged
fan-zhang-sv merged 1 commit intomasterfrom
feat/testapp-coop-simulation
Apr 30, 2026
Merged

feat(testapp): add COOP simulation toggle#290
fan-zhang-sv merged 1 commit intomasterfrom
feat/testapp-coop-simulation

Conversation

@fan-zhang-sv
Copy link
Copy Markdown
Collaborator

Summary

  • 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.

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.js
  • yarn workspace sdk-playground typecheck
  • yarn workspace sdk-playground build (passes with existing unrelated export warnings for prolink/spend-permission imports)

Made with Cursor

@cb-heimdall
Copy link
Copy Markdown
Collaborator

cb-heimdall commented Apr 30, 2026

✅ Heimdall Review Status

Requirement Status More Info
Reviews 2/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

@github-actions
Copy link
Copy Markdown
Contributor

Review Summary

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.

@fan-zhang-sv fan-zhang-sv merged commit 0971520 into master Apr 30, 2026
12 checks passed
@fan-zhang-sv fan-zhang-sv deleted the feat/testapp-coop-simulation branch April 30, 2026 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants