Skip to content

fix(vibenet): make 'Add to wallet' idempotent and clear - #21

Merged
montycheese merged 1 commit into
mainfrom
fix-add-wallet-ux
Jul 24, 2026
Merged

fix(vibenet): make 'Add to wallet' idempotent and clear#21
montycheese merged 1 commit into
mainfrom
fix-add-wallet-ux

Conversation

@montycheese

@montycheese montycheese commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Problem

Hitting Add to wallet for a network the wallet already has showed:

Wallet did not add the network: User rejected the request.

wallet_addEthereumChain on an already-added chain doesn't re-add it — most wallets treat it as a switch request and prompt to switch. Dismissing that prompt returns EIP-1193 4001, which the handler reported as an add-failure. Misleading: the network was already there.

Fix (best-UX flow)

  1. Read eth_chainId first — if already on vibenet, show "Already connected to base vibenet." and don't prompt at all.
  2. Otherwise switch (wallet_switchEthereumChain, EIP-3326); only fall back to add (wallet_addEthereumChain) when the wallet reports the chain is unrecognized (4902).
  3. Treat a 4001 dismissal as a neutral "Request dismissed — no changes made." instead of a failure.

Adds getChainId, switchEthereumChain, isUserRejection, isUnrecognizedChain helpers to library/wallet.ts.

Verification

  • typecheck / build pass; lint clean (only pre-existing <img> warnings, untouched by this change).
  • Manual wallet check - verified on both CB wallet and Metamask

Hitting 'Add to wallet' for an already-added network fired
wallet_addEthereumChain, which most wallets treat as a switch prompt; a
dismissed prompt (EIP-1193 4001) was then surfaced as 'Wallet did not add
the network: User rejected the request' — misleading, since it's already added.

Now: read eth_chainId first and short-circuit with 'Already connected' when
on vibenet; otherwise switch (EIP-3326) and only add on 4902 (unrecognized
chain); treat 4001 as a neutral 'Request dismissed' rather than a failure.

Adds getChainId / switchEthereumChain / isUserRejection / isUnrecognizedChain
helpers to library/wallet.ts. typecheck/lint/build pass.
@cb-heimdall

Copy link
Copy Markdown
Collaborator

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/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

@vercel

vercel Bot commented Jul 24, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
omni-ui Ready Ready Preview, Comment Jul 24, 2026 2:09pm

Request Review

@montycheese
montycheese merged commit 4caf23b into main Jul 24, 2026
5 of 6 checks passed
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