fix: reject malformed CAIP-10 addresses in setCaipAddress - #5634
Merged
Conversation
When a wallet emits an empty string as the account address, AppKit would store a malformed CAIP-10 address like "eip155:42161:" in state. This propagated through balance fetching, identity sync, and SIWE, all operating on an empty address. Added a validation guard in setCaipAddress that rejects any CAIP-10 string that doesn't have exactly 3 non-empty colon-separated parts. Closes REOWN-4448 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
9 Skipped Deployments
|
Contributor
|
All contributors have signed the CTA ✍️ ✅ |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
svenvoskamp
approved these changes
Apr 13, 2026
Contributor
Author
|
I have read the CTA Document and I hereby sign the CTA |
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
Prevents malformed CAIP-10 addresses from entering AppKit state when a wallet emits an empty address string (REOWN-4448).
Technical Report
Problem
When a wallet connector emits an empty string "" as the account address (observed sporadically with injected wallets and WalletConnect during reconnection/network switching), AppKit stores a malformed CAIP-10 address like "eip155:42161:" in state. This propagates through balance fetching, identity sync, and SIWE — all operating on an empty address.
Root Cause Analysis
syncAccountInfo in appkit-base-client.ts constructs the CAIP-10 address via string interpolation: `${chainNamespace}:${newChainId}:${address}`. With an empty address, this produces "eip155:42161:" — technically a string but invalid CAIP-10. setCaipAddress stored this directly without validation. Downstream, getPlainAddress() returns "", and consumers operate on a garbage address.
ParseUtil.parseCaipAddress already validates CAIP-10 format, but setCaipAddress bypassed it entirely — doing raw interpolation and direct state assignment.
Approach & Reasoning
Added validation guard in setCaipAddress — the single convergence point before any CAIP-10 value enters state. The guard splits on ":" and checks for exactly 3 non-empty parts (namespace:chainId:address). Malformed values are rejected with a console.warn for debuggability.
Why setCaipAddress and not the callers: There are multiple code paths that call setCaipAddress (syncAccountInfo, onAuthProviderConnected, adapter callbacks). Guarding at the convergence point covers all of them with one check.
Why silent reject with warning (not throw): The wallet is the source of the bad data, not the app. Throwing would crash the connection flow. Silently rejecting keeps the app functional with whatever address was previously in state. The console.warn ensures the issue is visible for debugging.
Format validation: Splits on ":" and checks parts.length === 3 && !parts.some(p => !p). This correctly handles:
Works with REOWN-4447 fix: Even if toChecksummedAddress returns an empty/undefined address, this guard catches it before it enters state.
Verification
Test plan
🤖 Generated with Claude Code