Skip to content

fix(siwx): preserve multichain signing context - #5730

Open
svenvoskamp wants to merge 1 commit into
mainfrom
svenvoskamp/fix-siwx-signing-context
Open

fix(siwx): preserve multichain signing context#5730
svenvoskamp wants to merge 1 commit into
mainfrom
svenvoskamp/fix-siwx-signing-context

Conversation

@svenvoskamp

@svenvoskamp svenvoskamp commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Description

Part 1 of the native GitHub stack: #5730#5732#5733#5734.

Fix the core SIWX time-of-check/time-of-use race. Message creation captured an account and CAIP
chain, but the default signing path discarded that context and later re-read mutable AppKit state.
In a multichain session, the active namespace could change before the user pressed Sign.

This layer:

  • introduces an immutable SignMessageContext containing chain, account, and connector
  • forwards it through SIWX, the default signer, and the connection controller
  • selects the AppKit namespace, adapter, provider, network, and account from that context
  • rejects signing if the connector changed after message creation
  • tests an EVM SIWX message while the live AppKit namespace has moved to Solana

Signing sequence

sequenceDiagram
    autonumber
    actor User
    participant SIWX
    participant State as Mutable AppKit state
    participant AppKit
    participant Adapter

    SIWX->>State: Read chain, account, connector once
    State-->>SIWX: eip155:1, 0xAccount, walletConnect
    SIWX->>SIWX: Create message and retain context
    State-->>State: Active namespace may change to Solana
    User->>SIWX: Sign
    SIWX->>AppKit: signMessage(message, capturedContext)
    AppKit->>AppKit: Resolve EVM adapter and provider from eip155:1
    AppKit->>AppKit: Verify walletConnect is still active
    AppKit->>Adapter: Sign with captured network and account
Loading

Type of change

  • Chore
  • Bug fix
  • New feature
  • Breaking change

Associated Issues

N/A

Validation

  • AppKit, Controllers, and SIWX focused suites: 8 tests pass
  • Focused Prettier check passes

Checklist

  • Code is covered by automated tests
  • No unrelated behavior is changed
  • A changeset is included
  • I have reviewed my own code

@vercel

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

Request Review

@changeset-bot

changeset-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: bca1ba9

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-siwx 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-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

@github-actions

github-actions Bot commented Jul 30, 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=1000
Storybook Preview: https://6493191bf4b10fed8ca7353f-ofqllacxrm.chromatic.com/

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

@github-actions

github-actions Bot commented Jul 30, 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: 622 ms   on Snapdragon 410
Total time:   2.2 s
@reown/appkit/react
Size limit:   236 kB
Size:         235.13 kB with all dependencies, minified and gzipped
Loading time: 4.6 s     on slow 3G
Running time: 854 ms    on Snapdragon 410
Total time:   5.5 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: 436 ms   on Snapdragon 410
Total time:   2 s
@reown/appkit-scaffold-ui
Size limit:   220 kB
Size:         214.42 kB with all dependencies, minified and gzipped
Loading time: 4.2 s     on slow 3G
Running time: 946 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: 178 ms   on Snapdragon 410
Total time:   435 ms

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 78.65% 40266 / 51190
🔵 Statements 78.65% 40266 / 51190
🔵 Functions 76.14% 4296 / 5642
🔵 Branches 86.74% 9866 / 11373
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/appkit/src/client/appkit-base-client.ts 73.22% 85.98% 72.98% 73.22% 192-198, 218, 231-234, 237, 249-250, 256-257, 260, 269, 316-317, 363-364, 402-403, 405-406, 411-412, 494-495, 531-537, 608-609, 631-646, 649, 687, 728-732, 742-743, 746-747, 754-755, 760-761, 783-806, 815-816, 833-853, 857-878, 881-907, 910-916, 919-925, 928-934, 937-943, 946-956, 959-965, 968-975, 989-998, 1001-1007, 1010-1011, 1014-1015, 1034-1035, 1058-1098, 1105-1117, 1123-1150, 1153-1163, 1195-1196, 1221-1222, 1227, 1242-1258, 1272, 1276-1284, 1315-1316, 1335-1338, 1342-1343, 1345-1346, 1380-1382, 1386-1407, 1412-1413, 1421-1422, 1424-1425, 1519-1520, 1532-1533, 1538, 1561-1566, 1606, 1621, 1642-1643, 1652, 1654-1670, 1675, 1721-1722, 1734-1745, 1792-1809, 1854, 1860-1864, 1885-1900, 1903-1904, 1930-1933, 1969-1988, 2020, 2063-2064, 2070-2096, 2326-2327, 2370-2371, 2375-2376, 2380-2381, 2389-2390, 2398-2399, 2403-2404, 2412-2413, 2417-2418, 2425-2430, 2438-2439, 2442-2443, 2459-2462, 2465-2466, 2486-2487, 2490-2491, 2512, 2533-2534, 2542-2543, 2555-2556, 2570, 2597-2598, 2604-2605, 2639-2644, 2662-2663, 2666-2667, 2714-2715, 2786-2787, 2790-2791, 2794-2797, 2800-2801, 2804-2805, 2808-2809, 2812-2813, 2816-2820, 2829-2838, 2847-2858, 1405, 2428
packages/controllers/exports/index.ts 100% 100% 100% 100%
packages/controllers/src/controllers/ConnectionController.ts 84.9% 88.28% 53.76% 84.9% 183, 243-247, 250-254, 302-306, 314-315, 322-341, 356, 360, 364, 368, 372, 376, 380, 384, 388, 392, 475, 479, 501-505, 520-522, 533-534, 569-570, 580-581, 583-584, 592-593, 595-596, 615-616
packages/controllers/src/controllers/AdapterController/ChainAdapterBlueprint.ts 70.6% 85.29% 73.52% 70.6% 144-155, 237-238, 242-243, 266-270, 276-279, 309-310, 347-348, 361-362, 524-551, 564-592, 610-611, 624-653, 662-663, 778-779, 300-562
packages/controllers/src/utils/SIWXUtil.ts 74.04% 69.62% 56% 74.04% 40-41, 45-54, 56-57, 61-62, 67-80, 83-100, 108-109, 112-113, 116-117, 139-140, 178, 200-201, 203-204, 214-216, 219-234, 289, 312, 359-383, 477-488, 500-501, 50, 362-389
packages/siwx/src/core/SIWXConfig.ts 44.77% 66.66% 22.22% 44.77% 41-42, 52-58, 69-77, 88-102, 112-113, 124-130, 138-139
packages/siwx/src/signers/DefaultSigner.ts 18.18% 100% 0% 18.18% 14-38
Generated in workflow #17218 for commit bca1ba9 by the Vitest Coverage Report Action

@svenvoskamp

Copy link
Copy Markdown
Contributor Author

CI failure analysis for the first run:

  • 6 failures came from the new siwx-walletconnect.spec.ts: it used Playwright's
    test-scoped context fixture from beforeAll, which Playwright rejects during collection.
    The common EVM test list also scheduled this Wagmi-only scenario for Ethers and Ethers5.
  • Fixed in 5bf26893c: setup now happens inside the test, and the spec is routed only to the
    Chrome/Firefox Wagmi projects.
  • The remaining 11 failures were existing Laboratory E2E instability (email delivery /
    confirmation timeouts and missing SIWE prompt/network elements). As a control, the concurrent
    unrelated Checks run 30561030736
    reported 25 failures with the same classes of errors, including missing SIWE prompts across
    every multichain adapter.

A fresh CI run is in progress for the corrected test.

@svenvoskamp

Copy link
Copy Markdown
Contributor Author

Follow-up from the corrected CI attempt:

  • siwx-walletconnect.spec.ts passed on both Desktop Chrome/wagmi and
    Desktop Firefox/wagmi.
  • The 14 unexpected results are from existing smart-account, email, wallet,
    account-name, and multichain-email specs.
  • The six failed shards have been retriggered with GitHub's failed-job rerun.

})
} as const
const signature = caipNetworkId
? await (provider as unknown as UniversalProvider).request(request, caipNetworkId)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

hate this pattern 😪
not saying we do it here but if the internal provider is WC, why do we have it typed as a diferent one.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

yeah can we not use as unknown kind of scary xd

'@reown/appkit-adapter-wagmi': patch
'@reown/appkit-controllers': patch
'@reown/appkit-scaffold-ui': patch
'@reown/appkit-siwx': patch

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.

Maybe include all packages or changet auto handle rest?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

+1 we need to include all packages

Comment thread packages/adapters/wagmi/src/client.ts Outdated
Comment on lines +420 to +422
if (params.connectorId === CommonConstantsUtil.CONNECTOR_ID.WALLET_CONNECT) {
if (!params.provider) {
throw new Error('WalletConnect provider is undefined')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Instead of having these checks to see if it's walletconnect, can't we do a fix in walletconnect connector for every adapter? Wouldn't that be easier

Comment on lines +347 to 349
async signMessage(message: string, context?: SignMessageContext) {
return ConnectionController._getClient()?.signMessage(message, context)
},

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is it possible to get the context from contollers

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.

4 participants