Skip to content

refactor: remove wallet capabilities fallback#7847

Open
kernelwhisperer wants to merge 1 commit into
feat/7702-batch-supportfrom
refactor/wallet-capabilities-3
Open

refactor: remove wallet capabilities fallback#7847
kernelwhisperer wants to merge 1 commit into
feat/7702-batch-supportfrom
refactor/wallet-capabilities-3

Conversation

@kernelwhisperer

Copy link
Copy Markdown
Contributor

Summary

  • Fix wallet capability checks by routing them through the connected wallet.
  • Remove the now-unnecessary direct RPC fallback.
  • Remove the unused provider and connection-restoring state from WalletInfo.

Background

Capability requests were incorrectly sent to the chain’s public RPC, which does not expose wallet capabilities. Using the connected wallet fixes detection and makes the fallback/provider plumbing unnecessary (seems to work in Safe via WC too).

image

@kernelwhisperer
kernelwhisperer requested a review from Danziger July 13, 2026 09:39
@kernelwhisperer kernelwhisperer self-assigned this Jul 13, 2026
@vercel

vercel Bot commented Jul 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cowfi Ready Ready Preview Jul 14, 2026 11:29am
explorer-dev Ready Ready Preview Jul 14, 2026 11:29am
storybook Ready Ready Preview Jul 14, 2026 11:29am
swap-dev Ready Ready Preview Jul 14, 2026 11:29am
widget-configurator Ready Ready Preview Jul 14, 2026 11:29am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
cosmos Ignored Ignored Jul 14, 2026 11:29am
sdk-tools Ignored Ignored Preview Jul 14, 2026 11:29am

Request Review

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f944d75f-1fdf-4a42-853a-3006e7ef5478

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/wallet-capabilities-3

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 13, 2026

Copy link
Copy Markdown

Deploying explorer-dev with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0b71643
Status: ✅  Deploy successful!
Preview URL: https://c74df0e4.explorer-dev-dxz.pages.dev
Branch Preview URL: https://refactor-wallet-capabilities-13y7.explorer-dev-dxz.pages.dev

View logs

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 13, 2026

Copy link
Copy Markdown

Deploying swap-dev with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0b71643
Status: ✅  Deploy successful!
Preview URL: https://8ec708ad.swap-dev-5u6.pages.dev
Branch Preview URL: https://refactor-wallet-capabilities-uosj.swap-dev-5u6.pages.dev

View logs

@kernelwhisperer kernelwhisperer changed the title refactor: wallet capabilities refactor: wallet capabilities fallback Jul 13, 2026
@kernelwhisperer
kernelwhisperer force-pushed the feat/7702-batch-support branch from 87dd4b6 to 25f5b15 Compare July 13, 2026 09:41
@kernelwhisperer
kernelwhisperer force-pushed the refactor/wallet-capabilities-3 branch from 31b2c35 to 9a60a15 Compare July 13, 2026 09:42

@fairlighteth fairlighteth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ AI Review (Codex GPT-5, worked 25m): normalize the mobile empty-capabilities result

Finding: [NON-BLOCKING] Keep walletCapabilitiesAtom on its declared object-or-null contract

  • Location: libs/wallet/src/api/state/walletCapabilitiesAtom.ts:30-43
  • The connector routing is correct, but the chain-specific viem call can resolve undefined. EIP-5792 permits an unsupported requested chain to be omitted, while mobileInjectedProviderGuard.ts:10-12 deliberately converts a hanging MetaMask iOS capability request into {}.
  • With pinned viem 2.48.8, that raw {} becomes capabilities[chainId]undefined. The atom then violates its Promise<WalletCapabilities | null> contract, and line 75 dereferences walletCapabilities.atomic.
  • The loadable wrapper fails closed to false, so current UI consumers recover, but the exported raw atom can return an undocumented value. The {} unit mock currently bypasses the wagmi/viem normalization that creates it.

Suggested fix

  • Return capabilities ?? null.
  • Add a regression test where the action resolves undefined—or a fake provider returns raw {}—and assert that the raw atom returns null and batch support resolves false without rejecting.
Review scope and related context
  • No existing review thread covers this; CodeRabbit skipped the non-default base branch.
  • The PR screenshot confirms Safe via WalletConnect on Avalanche receives atomic.status: supported.
  • Base PR #7844 already contains the broader wallet QA matrix. Optionally note which EIP-7702 and unsupported-wallet cases were rerun after this routing change.
  • The four Cypress #do-trade-button failures are identical on the base PR, so they are not attributed to this change.
🤖 Prompt for AI agents
Verify this finding against PR head 4ec1bfbe.

In walletCapabilitiesAtom:
- Preserve connector-based wagmi routing and the existing timeout.
- Normalize an undefined getCapabilities result to null.
- Add coverage for the valid empty/missing-chain response path.
- Confirm walletCapabilitiesAtom never exposes undefined and isAtomicBatchSupportedAsyncAtom resolves false rather than rejecting.
- Do not reintroduce the public-RPC or legacy provider fallback.

Generated using the pr-review skill from the CoW Protocol skills repo.

@fairlighteth

fairlighteth commented Jul 13, 2026

Copy link
Copy Markdown
Contributor
🧪 Scoped browser QA passed: connected-wallet capability routing and mobile timeout fallback verified

Outcome

  • Supported capability routing: a fixture-backed connected provider returned atomic.status: supported. The provider received two wallet_getCapabilities calls, the app logged both successful fetches within 2–4 ms, no HTTP request carried that RPC method, and the Swap form settled without a loading or unsupported-wallet state.
  • Hanging mobile provider: two underlying capability calls remained pending; the guarded app calls settled after 1005 ms and 1003 ms. TWAP rendered Unsupported wallet, with no lingering loading state or page error.
  • Real-wallet smoke retained: MetaMask 13.35.1 previously reached visible wallet-connected-ui on this same head and remained connected after reload.
  • Non-blocking caveat: the hanging path still logs capabilities: undefined. Current UI consumers fail closed correctly, but this run does not invalidate the raw-atom contract review finding.
  • Not checked / follow-up: a real supported Safe via WalletConnect session, wallet_sendCalls, signing/submission, and a real MetaMask iOS reproduction.

Run details

  • Source: PR head 4ec1bfbe8535 via the public Vercel preview; browser console reported commit 4ec1bfb.
  • Environment: Linux; Chromium 140.0.7339.186; en-US.
  • Wallet: fixture-backed wallet-connected-ui for the capability matrix; real MetaMask wallet-connected-ui for the reload smoke; signing-capable behavior was not exercised.
  • AI assistance: Codex orchestrated Playwright execution, inspected the structured and visual artifacts, and drafted this summary.

Artifacts

Supported response routed through the connected provider; Swap settled normally:

Chromium fixture-backed connected provider with supported wallet capabilities and a settled Swap form

Hanging mobile capability request settled fail-closed:

Chromium mobile fixture showing the TWAP unsupported-wallet fallback after wallet_getCapabilities remains pending

How to retest

  • Connect an EIP-6963 provider through the injected-wallet UI on /#/1/swap and return { "0x1": { "atomic": { "status": "supported" } } } from wallet_getCapabilities. Expected: the connected provider receives the method, no public-RPC HTTP request carries it, and the form settles normally.
  • With a mobile user agent, leave the same provider method unresolved on /#/1/advanced/orders. Expected: handling settles after about 1 second, TWAP shows Unsupported wallet, and the UI does not remain loading.

Generated using the pr-qa skill from the CoW Protocol skills repo.

@Danziger Danziger left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UACK, nice find! 👌

@kernelwhisperer
kernelwhisperer force-pushed the feat/7702-batch-support branch from 4cba8dc to 0eb7628 Compare July 14, 2026 11:08
@kernelwhisperer kernelwhisperer changed the title refactor: wallet capabilities fallback refactor: remove wallet capabilities fallback Jul 14, 2026
@kernelwhisperer
kernelwhisperer force-pushed the refactor/wallet-capabilities-3 branch from 4ec1bfb to 0b71643 Compare July 14, 2026 11:24
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