Skip to content

fix(sdk): show unsupported chain error when wallet rejects wallet_addEthereumChain - #1147

Merged
ted-palmer merged 1 commit into
mainfrom
ted/int2-1475-show-correct-error-when-wallet-rejects-chain-addition
Oct 6, 2026
Merged

ted-palmer merged 1 commit into
mainfrom
ted/int2-1475-show-correct-error-when-wallet-rejects-chain-addition

Conversation

@ted-palmer

Copy link
Copy Markdown
Collaborator

No description provided.

@vercel

vercel Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated
relay-sdk-demo Ready Ready Preview Oct 2, 2026 8:07pm UTC

Request Review

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @ted-palmer's task in 1m 2s —— View job


📝 Docs Drift Check — No docs impact

This PR does not touch surfaces that require a relayprotocol/relay-docs update.

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @ted-palmer's task in 1m 23s —— View job


Code Review

  • Gather context (diff, commits, changed files)
  • Review viemWallet.ts switchChain/addChain error handling
  • Review ErrorWell.tsx message logic
  • Review tests and changeset

Code Review — No blocking issues found.

Reviewed 4 files (+94/-4). The change is small, scoped, and well-tested. Specific observations:

Correctness — Mapping wallet.addChain failures with e?.code === MethodNotSupportedRpcError.code (-32004) to a 'Wallet does not support chain' error is correct, and the three added tests cover the three real paths (unsupported → mapped, other error → rethrown, success → resolves).

Nice catch — ErrorWell.tsx:45 now includes fromChain?.displayName in the useMemo dependency array. It was previously read inside the memo (${fromChain?.displayName ?? 'this chain'}) but missing from deps, so this fixes a latent stale-value bug in addition to the new message.

Minor observations (non-blocking):

  • NOTE — The SDK already normalizes the -32004 case to 'Wallet does not support chain', which ErrorWell matches via includes('does not support chain'). The newly added /wallet_addEthereumChain.*not supported/ regex therefore only fires for raw errors that bypass the SDK transformation. That's fine as a defensive fallback, just worth noting it's not the path the SDK change produces.
  • NOTE — Some wallets reject an unsupported wallet_addEthereumChain with EIP-1193 code 4200 ("Unsupported Method") rather than EIP-1474 -32004. Those won't hit the new MethodNotSupportedRpcError.code branch and will fall through to throw e. The ErrorWell regex may still catch them by message, but if you want parity in the SDK you could also check 4200. Scoped out is reasonable given this PR targets the observed Coinbase Wallet (-32004) case.

Guidelines — Changeset follows the reader-focused format; conventional-commit PR title is correct; no relay:-prefix or import-extension concerns in the diff.

@greptile-apps

greptile-apps Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Improves wallet chain-rejection error handling and messaging.

The PR appears safe to merge; no actionable issues were found.

What we checked:

  • Chain advice comes first: ErrorWell returns the chain advice before reaching the generic locked-wallet message.
Summary

The SDK maps an unsupported wallet_addEthereumChain response to a chain-support error. The UI tells users to add the chain manually or connect another wallet.

  • Adds tests for the Coinbase/Ink error, a locked wallet, and successful chain addition.
  • Updates the displayed advice when the chain name changes.
  • Adds patch releases for both packages.

Greptile automatically discovered a related ticket that helped explain the purpose of this PR: replace misleading locked-wallet advice for Coinbase Wallet swaps originating on Ink.

Tests and visual checks were not run; dependencies are not installed.

Reviews (1) · Last reviewed commit: "fix(sdk): show unsupported chain error w..."

@ted-palmer
ted-palmer requested a review from pedromcunha October 2, 2026 20:14
@ted-palmer
ted-palmer merged commit aa83dcf into main Oct 6, 2026
9 checks passed
@ted-palmer
ted-palmer deleted the ted/int2-1475-show-correct-error-when-wallet-rejects-chain-addition branch October 6, 2026 18:41

This branch was successfully deployed

1 active deployment
Preview — 81688a46 Deployed Oct 2, 2026 by vercel[bot]
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.

2 participants