Skip to content

Feat/use wallet hook#2488

Merged
chaitanyapotti merged 7 commits into
masterfrom
feat/useWallet-hook
May 19, 2026
Merged

Feat/use wallet hook#2488
chaitanyapotti merged 7 commits into
masterfrom
feat/useWallet-hook

Conversation

@lwin-kyaw
Copy link
Copy Markdown
Contributor

@lwin-kyaw lwin-kyaw commented May 18, 2026

Jira Link

N/A

Description

This PR adds a new useWallets hook for both React and Vue, backed by getConnectedAccountsWithProviders(), and re-exports it from the modal packages for easier app integration.

It also enriches connected wallet state with linked-account metadata so consumers can distinguish between linked wallets and currently connected wallets. Using that data, the demo account-linking screen now shows Switch to this wallet only for already connected linked wallets and falls back to Connect this wallet otherwise.

In addition, this PR fixes reconnect behavior in the Wagmi and Solana providers so reconnect logic only runs for the primary connector during account switching, and replaces hardcoded account-linking status copy in the modal UI with translation keys.

How has this been tested?

  • Ran npm run test
  • Verified:
    • @web3auth/modal:test
    • @web3auth/no-modal:test

Screenshots (if appropriate)

N/A

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • My code follows the code style of this project. (run lint)
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Note

Medium Risk
Medium risk because it changes how Web3AuthNoModal tracks connected wallet state during account switching and alters reconnect gating for Wagmi/Solana providers, which could affect session/connection synchronization across connectors.

Overview
Adds a new useWallets hook (React/Vue) that syncs currently connected accounts (including connector + provider details) via getConnectedAccountsWithProviders(), and re-exports it from @web3auth/modal for easier consumption.

Refactors connected-wallet state in Web3AuthNoModal to store linked-account metadata alongside providers/connectors, keep that metadata in sync when fetching user/linked accounts, and expose getConnectedAccountsWithProviders() (with new tests).

Behavior tweaks: Wagmi and Solana providers now only resync/reconnect when the active connection matches the primary connector during account switching, the demo account-linking view distinguishes connected vs merely linked wallets (button text + refresh), and account-linking status copy in the modal UI is moved to i18n keys (EN/FR).

Reviewed by Cursor Bugbot for commit 2d275b6. Bugbot is set up for automated code reviews on this repo. Configure here.

@lwin-kyaw lwin-kyaw requested review from a team as code owners May 18, 2026 17:58
@vercel
Copy link
Copy Markdown

vercel Bot commented May 18, 2026

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

Project Deployment Actions Updated (UTC)
web3auth-web Ready Ready Preview, Comment May 19, 2026 5:14am

Request Review

Comment thread packages/no-modal/src/noModal.ts

const syncAccountState = async (): Promise<void> => {
await Promise.all([getUserInfo(), syncWallets()]);
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Race condition in parallel syncAccountState calls

Low Severity

syncAccountState calls getUserInfo() and syncWallets() in parallel via Promise.all. Since syncWallets() internally calls the synchronous getConnectedAccountsWithProviders(), it reads the connector map state before getUserInfo() has a chance to call syncConnectedWalletLinkedAccounts. This means connectedWalletIds may contain stale IDs (e.g., "__primary__") that won't match real linked account IDs, causing getSwitchButtonText to show incorrect button text until a subsequent sync.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit df609f4. Configure here.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 3 total unresolved issues (including 2 from previous reviews).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b1423d0. Configure here.

Comment thread packages/modal/src/react/wagmi/provider.ts Outdated
@chaitanyapotti chaitanyapotti merged commit 61cd80e into master May 19, 2026
7 checks passed
@chaitanyapotti chaitanyapotti deleted the feat/useWallet-hook branch May 19, 2026 08:09
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