Skip to content

fix(ethers,ethers5): resolve walletProvider after account switch in modal#5663

Merged
0xmkh merged 7 commits into
mainfrom
chore/khizr-fixes-2-REOWN-4657
Jul 15, 2026
Merged

fix(ethers,ethers5): resolve walletProvider after account switch in modal#5663
0xmkh merged 7 commits into
mainfrom
chore/khizr-fixes-2-REOWN-4657

Conversation

@Khizr97

@Khizr97 Khizr97 commented May 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • In connect()'s early-return path (used when switching accounts in the modal), connector.provider was never initialised for connectors backed by ethersProviders (injected, coinbaseWallet, baseAccount, safe)
  • This caused the base-client's accountChanged handler to skip syncProvider() — leaving useAppKitProvider returning a stale provider
  • Fix resolves connector.provider from ethersProviders before emitting accountChanged, when it is not already set
  • Applies to both @reown/appkit-adapter-ethers and @reown/appkit-adapter-ethers5

Root Cause

appkit-base-client.ts only calls syncProvider() in the accountChanged handler when connector?.provider is truthy. The early-return path in connect() emits the event before initialising the provider, so the guard is never satisfied.

Test plan

  • New unit test: provider resolved from ethersProviders when connector.provider is undefined in early-return path
  • New unit test: existing connector.provider is preserved (no re-initialisation) when already set
  • All 72 Ethers adapter tests pass
  • All 46 Ethers5 adapter tests pass

Fixes: REOWN-4657

🤖 Generated with Claude Code

Khizr97 and others added 3 commits May 11, 2026 21:38
…in connect early-return path

When switching accounts in the modal, connect() takes an early-return path for
existing connections but never initialised connector.provider. This caused the
base-client's accountChanged handler to skip syncProvider() (which guards on
connector?.provider), leaving useAppKitProvider stale.

Fix: resolve connector.provider from ethersProviders before emitting the event
when it is not yet set. Applies to both ethers and ethers5 adapters.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tch fix

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@linear

linear Bot commented May 11, 2026

Copy link
Copy Markdown

REOWN-4657

@vercel

vercel Bot commented May 11, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
appkit-demo Ready Ready Preview, Comment Jul 15, 2026 2:36pm
appkit-gallery Ready Ready Preview, Comment Jul 15, 2026 2:36pm
appkit-headless-sample-app Ready Ready Preview, Comment Jul 15, 2026 2:36pm
appkit-laboratory Ready Ready Preview, Comment Jul 15, 2026 2:36pm
9 Skipped Deployments
Project Deployment Actions Updated (UTC)
appkit-basic-example Ignored Ignored Jul 15, 2026 2:36pm
appkit-basic-sign-client-example Ignored Ignored Jul 15, 2026 2:36pm
appkit-basic-up-example Ignored Ignored Jul 15, 2026 2:36pm
appkit-ethers5-bera Ignored Ignored Jul 15, 2026 2:36pm
appkit-nansen-demo Ignored Ignored Jul 15, 2026 2:36pm
appkit-wagmi-cdn-example Ignored Ignored Jul 15, 2026 2:36pm
ethereum-provider-wagmi-example Ignored Ignored Jul 15, 2026 2:36pm
next-wagmi-solana-bitcoin-example Ignored Ignored Jul 15, 2026 2:36pm
vue-wagmi-example Ignored Ignored Jul 15, 2026 2:36pm

Request Review

@changeset-bot

changeset-bot Bot commented May 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 71c64d1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 27 packages
Name Type
@reown/appkit-adapter-ethers5 Patch
@reown/appkit-adapter-ethers Patch
pay-test-exchange Patch
@reown/appkit-adapter-bitcoin Patch
@reown/appkit-adapter-solana Patch
@reown/appkit-adapter-ton Patch
@reown/appkit-adapter-tron Patch
@reown/appkit-adapter-wagmi Patch
@reown/appkit Patch
@reown/appkit-utils Patch
@reown/appkit-cdn Patch
@reown/appkit-cli Patch
@reown/appkit-codemod Patch
@reown/appkit-common Patch
@reown/appkit-controllers Patch
@reown/appkit-core Patch
@reown/appkit-experimental Patch
@reown/appkit-pay Patch
@reown/appkit-polyfills Patch
@reown/appkit-scaffold-ui Patch
@reown/appkit-siwe Patch
@reown/appkit-siwx Patch
@reown/appkit-testing Patch
@reown/appkit-ui Patch
@reown/appkit-universal-connector Patch
@reown/appkit-wallet Patch
@reown/appkit-wallet-button Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment thread packages/adapters/ethers5/src/client.ts Outdated
@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Visual Regression Test Results ✅ Passed

⚠️ 20 visual change(s) detected

Chromatic Build: https://www.chromatic.com/build?appId=6493191bf4b10fed8ca7353f&number=967
Storybook Preview: https://6493191bf4b10fed8ca7353f-grunepadlx.chromatic.com/

👉 Please review the visual changes in Chromatic and accept or reject them.

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor
Warnings
⚠️

🔑 Potential UUID detected in packages/adapters/ethers/src/tests/client.test.ts (line 1095): ba0ba0cd-17c6-4806-a...

Generated by 🚫 dangerJS against 71c64d1

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

📦 Bundle Size Check

All bundles are within size limits

📊 View detailed bundle sizes

> @reown/appkit-monorepo@1.7.1 size /home/runner/work/appkit/appkit


> size-limit

@reown/appkit - Main Entry
Size limit:   80 kB
Size:         75.87 kB with all dependencies, minified and gzipped
Loading time: 1.5 s    on slow 3G
Running time: 403 ms   on Snapdragon 410
Total time:   1.9 s
@reown/appkit/react
Size limit:   236 kB
Size:         235.11 kB with all dependencies, minified and gzipped
Loading time: 4.6 s     on slow 3G
Running time: 946 ms    on Snapdragon 410
Total time:   5.6 s
@reown/appkit/vue
Size limit:   80 kB
Size:         75.87 kB with all dependencies, minified and gzipped
Loading time: 1.5 s    on slow 3G
Running time: 478 ms   on Snapdragon 410
Total time:   2 s
@reown/appkit-scaffold-ui
Size limit:   220 kB
Size:         214.41 kB with all dependencies, minified and gzipped
Loading time: 4.2 s     on slow 3G
Running time: 704 ms    on Snapdragon 410
Total time:   4.9 s
@reown/appkit-ui
Size limit:   500 kB
Size:         13.16 kB with all dependencies, minified and gzipped
Loading time: 258 ms   on slow 3G
Running time: 95 ms    on Snapdragon 410
Total time:   352 ms

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 78.58% 40125 / 51057
🔵 Statements 78.58% 40125 / 51057
🔵 Functions 76.06% 4283 / 5631
🔵 Branches 86.68% 9798 / 11303
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/adapters/ethers/src/client.ts 67.28% 77.53% 63.63% 67.28% 117-118, 131-132, 155-156, 170-193, 206-242, 248-249, 256-273, 302-303, 398-423, 426-431, 444-445, 458-459, 494-496, 499-500, 527, 556-557, 565-566, 594-599, 618-677, 684-685, 707, 736-737, 748-749, 783-784, 788, 803-804, 821-826, 835-853, 859-860, 869-870, 881-882, 888-900
packages/adapters/ethers5/src/client.ts 61.86% 76.03% 63.63% 61.86% 114-115, 128-129, 152-153, 167-190, 203-239, 242-243, 249-250, 257-274, 393-418, 421-426, 439-440, 450-483, 489-491, 494-495, 522, 551-552, 560-561, 589-594, 598-657, 679-680, 702, 731-732, 744-745, 782-783, 787, 801-826, 834-852, 858-859, 868-869, 880-881, 887-899
Generated in workflow #17185 for commit 71c64d1 by the Vitest Coverage Report Action

@0xmkh 0xmkh merged commit da65c78 into main Jul 15, 2026
36 of 41 checks passed
@0xmkh 0xmkh deleted the chore/khizr-fixes-2-REOWN-4657 branch July 15, 2026 14:43
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants