Skip to content

feat: expose approved CAIP network IDs in useAppKitNetwork - #5570

Merged
0xmkh merged 7 commits into
mainfrom
tomiir/wallets-hook-networks
Mar 5, 2026
Merged

feat: expose approved CAIP network IDs in useAppKitNetwork#5570
0xmkh merged 7 commits into
mainfrom
tomiir/wallets-hook-networks

Conversation

@tomiir

@tomiir tomiir commented Mar 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Exposes WalletConnect session-approved CAIP network IDs through the useAppKitNetwork hook
  • Adds approvedCaipNetworkIds (CaipNetworkId[] | undefined) and supportsAllNetworks (boolean) to UseAppKitNetworkReturn
  • Updates React, Vue, and vanilla JS (subscribeNetwork) entry points

Behavior by connection type

Connection type approvedCaipNetworkIds supportsAllNetworks
Browser wallet (injected) undefined true
WalletConnect Session chains false
MetaMask Wallet via WC Session chains true (special case)
Coinbase SDK / Phantom injected undefined true

Usage

const { approvedCaipNetworkIds, supportsAllNetworks } = useAppKitNetwork()

if (!supportsAllNetworks && approvedCaipNetworkIds) {
  // Only these networks are supported by the WC session
  console.log(approvedCaipNetworkIds) // ["eip155:1", "eip155:137", ...]
}

Test plan

  • Build passes (pnpm build)
  • All 3173 unit tests pass (pnpm test)
  • New tests for useAppKitNetworkCore cover both active chain and no-chain scenarios
  • Manual test: connect via WalletConnect and verify approvedCaipNetworkIds populates
  • Manual test: connect via injected wallet and verify approvedCaipNetworkIds is undefined

🤖 Generated with Claude Code


Note

Low Risk
Additive API change that plumbs existing per-chain network metadata into hooks and subscriptions; risk is mainly around consumers relying on prior return shapes and correctness of derived defaults when no active chain is set.

Overview
useAppKitNetwork (React + Vue) and AppKitBaseClient.subscribeNetwork now surface WalletConnect session network constraints by adding approvedCaipNetworkIds and supportsAllNetworks to the returned network state.

This extends the shared UseAppKitNetworkReturn type, wires the values from each chain’s networkState, updates Vue reactivity/unsubscribe handling to track networkState changes, bumps @reown/appkit to 1.8.19, and adds/updates unit tests to cover defaults and subscription behavior.

Written by Cursor Bugbot for commit 751d591. This will update automatically on new commits. Configure here.

Surface WalletConnect session-approved networks through the useAppKitNetwork
hook across React, Vue, and vanilla JS. Adds approvedCaipNetworkIds and
supportsAllNetworks fields so developers can check which networks a connected
wallet supports without accessing internal controllers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 2, 2026 17:56
@changeset-bot

changeset-bot Bot commented Mar 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 751d591

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

This PR includes changesets to release 26 packages
Name Type
@reown/appkit Patch
@reown/appkit-controllers Patch
@reown/appkit-adapter-bitcoin Patch
@reown/appkit-adapter-ethers Patch
@reown/appkit-adapter-ethers5 Patch
@reown/appkit-adapter-solana Patch
@reown/appkit-adapter-ton Patch
@reown/appkit-adapter-tron Patch
@reown/appkit-adapter-wagmi Patch
@reown/appkit-universal-connector Patch
@reown/appkit-cdn Patch
@reown/appkit-experimental Patch
@reown/appkit-testing Patch
@reown/appkit-ui Patch
@reown/appkit-core Patch
@reown/appkit-utils Patch
@reown/appkit-scaffold-ui Patch
@reown/appkit-siwe Patch
@reown/appkit-siwx Patch
@reown/appkit-wallet-button Patch
@reown/appkit-pay Patch
@reown/appkit-common Patch
@reown/appkit-polyfills Patch
@reown/appkit-wallet Patch
@reown/appkit-cli Patch
@reown/appkit-codemod 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

@vercel

vercel Bot commented Mar 2, 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 Mar 5, 2026 1:15pm
appkit-gallery Ready Ready Preview, Comment Mar 5, 2026 1:15pm
appkit-headless-sample-app Ready Ready Preview, Comment Mar 5, 2026 1:15pm
appkit-laboratory Ready Ready Preview, Comment Mar 5, 2026 1:15pm
9 Skipped Deployments
Project Deployment Actions Updated (UTC)
appkit-basic-example Ignored Ignored Mar 5, 2026 1:15pm
appkit-basic-sign-client-example Ignored Ignored Mar 5, 2026 1:15pm
appkit-basic-up-example Ignored Ignored Mar 5, 2026 1:15pm
appkit-ethers5-bera Ignored Ignored Mar 5, 2026 1:15pm
appkit-nansen-demo Ignored Ignored Mar 5, 2026 1:15pm
appkit-wagmi-cdn-example Ignored Ignored Mar 5, 2026 1:15pm
ethereum-provider-wagmi-example Ignored Ignored Mar 5, 2026 1:15pm
next-wagmi-solana-bitcoin-example Ignored Ignored Mar 5, 2026 1:15pm
vue-wagmi-example Ignored Ignored Mar 5, 2026 1:15pm

Request Review

@github-actions

github-actions Bot commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

Visual Regression Test Results ✅ Passed

⚠️ 15 visual change(s) detected

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

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR exposes WalletConnect session-approved CAIP network IDs through the useAppKitNetwork hook by adding approvedCaipNetworkIds: CaipNetworkId[] | undefined and supportsAllNetworks: boolean to UseAppKitNetworkReturn. These fields reflect per-chain network state already tracked in ChainController, making it available through public-facing hooks and subscription APIs.

Changes:

  • Extended UseAppKitNetworkReturn type with two new fields and updated the React useAppKitNetworkCore to read them from ChainController state.
  • Updated the Vue (vue.ts and vue-core.ts) useAppKitNetwork hooks with a second subscribeChainProp subscription for reactive updates.
  • Extended subscribeNetwork in AppKitBaseClient to include the new fields in the callback payload.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/controllers/src/utils/TypeUtil.ts Adds approvedCaipNetworkIds and supportsAllNetworks to UseAppKitNetworkReturn
packages/controllers/exports/react.ts Updates useAppKitNetworkCore to read new fields from ChainController state snapshot
packages/appkit/exports/react.ts Passes new fields through useAppKitNetwork
packages/appkit/exports/react-core.ts Same as react.ts for the core variant
packages/appkit/exports/vue.ts Adds initial read and subscribeChainProp subscription for reactive updates
packages/appkit/exports/vue-core.ts Same as vue.ts for the core variant
packages/appkit/src/client/appkit-base-client.ts Includes new fields in the subscribeNetwork callback
packages/controllers/tests/hooks/react.test.ts Adds test cases for the two new fields in both active and no-chain scenarios

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

github-actions Bot commented Mar 2, 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.64 kB with all dependencies, minified and gzipped
Loading time: 1.5 s    on slow 3G
Running time: 698 ms   on Snapdragon 410
Total time:   2.2 s
@reown/appkit/react
Size limit:   235 kB
Size:         234.71 kB with all dependencies, minified and gzipped
Loading time: 4.6 s     on slow 3G
Running time: 1.6 s     on Snapdragon 410
Total time:   6.2 s
@reown/appkit/vue
Size limit:   80 kB
Size:         75.64 kB with all dependencies, minified and gzipped
Loading time: 1.5 s    on slow 3G
Running time: 669 ms   on Snapdragon 410
Total time:   2.2 s
@reown/appkit-scaffold-ui
Size limit:   220 kB
Size:         213.99 kB with all dependencies, minified and gzipped
Loading time: 4.2 s     on slow 3G
Running time: 945 ms    on Snapdragon 410
Total time:   5.2 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: 85 ms    on Snapdragon 410
Total time:   342 ms

@github-actions

github-actions Bot commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 78.57% 39652 / 50464
🔵 Statements 78.57% 39652 / 50464
🔵 Functions 76.31% 4252 / 5572
🔵 Branches 86.7% 9650 / 11130
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/appkit/exports/constants.ts 100% 100% 100% 100%
packages/appkit/exports/react.ts 46.15% 100% 33.33% 46.15% 50-65, 68-75
packages/appkit/exports/vue-core.ts 27.45% 100% 50% 27.45% 42-85
packages/appkit/exports/vue.ts 51.72% 100% 25% 51.72% 30-39, 57-58, 65-73, 79-80, 92-99
packages/appkit/src/client/appkit-base-client.ts 73.07% 85.29% 76.69% 73.07% 184-190, 210, 223-226, 229, 241-242, 248-249, 252, 261, 308-309, 355-356, 394-395, 397-398, 403-404, 485-486, 522-528, 599-600, 622-637, 640, 674-675, 678, 719-723, 730-731, 734-735, 740-741, 752-775, 784-785, 802-822, 826-847, 850-876, 879-885, 888-894, 897-903, 906-912, 915-925, 928-934, 937-944, 958-967, 970-976, 979-980, 983-984, 1003-1004, 1027-1067, 1074-1086, 1092-1119, 1122-1132, 1164-1165, 1190-1191, 1196, 1211-1227, 1241, 1245-1253, 1284-1285, 1304-1307, 1311-1312, 1314-1315, 1349-1351, 1355-1376, 1381-1382, 1390-1391, 1393-1394, 1488-1489, 1501-1502, 1507, 1530-1535, 1582, 1603-1604, 1613, 1615-1631, 1636, 1682-1683, 1695-1706, 1752-1765, 1810, 1816-1820, 1841-1856, 1859-1860, 1886-1889, 1925-1944, 1976, 2019-2020, 2026-2052, 2273-2274, 2311-2312, 2315-2316, 2332-2335, 2338-2339, 2359-2360, 2363-2364, 2385, 2406-2407, 2410-2420, 2424-2425, 2439, 2447, 2466-2467, 2473-2474, 2508-2513, 2531-2532, 2535-2536, 2583-2584, 2655-2656, 2659-2660, 2663-2666, 2669-2670, 2673-2674, 2677-2678, 2681-2682, 2685-2689, 2698-2707, 2716-2727, 1374, 2419
packages/controllers/exports/react.ts 88.6% 87.64% 46.15% 88.6% 70-79, 105-113, 130, 153, 548, 550-558, 575-576, 145-171, 446-578
Generated in workflow #16970 for commit 751d591 by the Vitest Coverage Report Action

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

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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.

Bugbot Free Tier Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

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

Comment thread packages/appkit/exports/vue-core.ts
When activeCaipNetwork changes (namespace switch), also read the new
active chain's networkState so approvedCaipNetworkIds and
supportsAllNetworks don't stay stale from the previous namespace.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@0xmkh
0xmkh merged commit 08f5c48 into main Mar 5, 2026
57 of 63 checks passed
@0xmkh
0xmkh deleted the tomiir/wallets-hook-networks branch March 5, 2026 14:00
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 5, 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