Viem Migration - Upgrade wagmi and handling different tabs wallet connection#7467
Open
lgahdl wants to merge 53 commits intorelease/28-04-2026from
Open
Viem Migration - Upgrade wagmi and handling different tabs wallet connection#7467lgahdl wants to merge 53 commits intorelease/28-04-2026from
lgahdl wants to merge 53 commits intorelease/28-04-2026from
Conversation
* chore: update sdk and simplify deps * chore(i18n): extract i18n strings [automatic] --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Denis Makarov <limitofzero@gmail.com>
…et-viem # Conflicts: # pnpm-lock.yaml
…allet_revokePermissions When SafeConnectionHandler switched from the injected connector to the safe connector inside a Safe App iframe, it called wagmi's disconnect() which internally calls wallet_revokePermissions on MetaMask. Since MetaMask manages permissions per origin (not per tab), this revoked the eth_accounts permission for the entire localhost:3000 origin, causing any open browser tab at that URL to lose its wallet connection. Fix: write the shimDisconnect storage flag directly instead of calling disconnect(). This prevents the connector from being reconnected on next load without touching MetaMask's global permissions. The connectSafeInIframe effect still runs and makes the safe connector the active connection. Also introduce IS_CROSS_ORIGIN_IFRAME — a one-time check that distinguishes genuine cross-origin iframes (Safe App) from same-origin ones (browser extensions like Loom or 1Password that also run inside iframes). This ensures SafeConnectionHandler only activates in actual cross-origin contexts.
…s-when-the-app-is-opened-in-safe-and-in-a
* feat: add AffiliateFeedbackButton Co-authored-by: Copilot <copilot@github.com> * chore(i18n): extract i18n strings [automatic] * fix: adjust Wrapper styling for AffiliateFeedbackButton * feat: update affiliate feedback button text and add tests for account page * feat: enhance affiliate feedback button logic and integrate wallet status checks * feat: add font size to affiliate feedback button styles --------- Co-authored-by: Copilot <copilot@github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…ection-issues-when-the-app-is-opened-in-safe-and-in-a
…ow-925-connection-issues-when-the-app-is-opened-in-safe-and-in-a
…et-viem # Conflicts: # apps/cowswap-frontend/package.json # libs/wallet/package.json # pnpm-lock.yaml
…ow-925-connection-issues-when-the-app-is-opened-in-safe-and-in-a
…hen-the-app-is-opened-in-safe-and-in-a
alfetopito
reviewed
May 8, 2026
alfetopito
reviewed
May 8, 2026
alfetopito
reviewed
May 8, 2026
alfetopito
reviewed
May 8, 2026
alfetopito
reviewed
May 8, 2026
Collaborator
Author
|
@coderabbitai review |
Contributor
✅ Actions performedReview triggered.
|
limitofzero
approved these changes
May 8, 2026
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes connection issues when the app is opened in Safe and in a cross-origin iframe (widget standalone mode).
Three separate problems are fixed:
Safe App iframe blink / disconnect — When the user switches wallets or disconnects in a regular browser tab, the Safe App iframe would blink or lose its connection. AppKit is now skipped entirely in Safe App iframes (plain wagmi config with only the Safe connector), and
@appkit/*localStorage keys are redirected tosessionStoragefor all cross-origin iframes so storage events don't leak across contexts.Tab isolation — Connecting or disconnecting a wallet in Tab A was affecting Tab B. A new
providerIsolation.tsmodule wraps every EIP-1193 provider (both EIP-6963 and legacywindow.ethereum) to blockwallet_revokePermissions(which revokes permissions for the entire origin, not just the current tab) and filteraccountsChangedevents so they only fire in the tab where the wallet is active.Widget standalone "Connection declined" on first Rabby connect — When the widget reloads, wagmi restores a stale connector UID from localStorage. AppKit's reconnect falls back to
connect()withoutisReconnecting: true, firingeth_requestAccountsas a background call. A manual wallet connect click then triggers a second request, causing Rabby (and other strict wallets) to decline it. Fixed by disablingenableReconnectin the widget context.Also upgrades
wagmi,@wagmi/core, and@wagmi/connectorsto their latest versions.To Test
Open the app normally in two browser tabs with the same wallet (e.g. Rabby)
Open the app as a Safe App (inside app.safe.global)
Open the widget configurator in standalone mode (localhost:4200)
Background
The root cause of the Safe iframe blink was AppKit writing to
localStorageunder@appkit/*keys — those writes firestorageevents in all same-origin iframes, including the Safe App frame. Redirecting those writes tosessionStorageinside cross-origin iframes isolates the storage state per context.The
wallet_revokePermissionsissue is a wagmi behaviour: on disconnect, wagmi calls this method to clear wallet state, but the method revokes permissions for the entire origin (all tabs share the same permission grant). Blocking it at the provider level while keepingshimDisconnect: trueis sufficient — shimDisconnect prevents reconnect on next page load without touching origin-wide permissions.Summary by CodeRabbit
Bug Fixes
New Features
Tests
Chores