Skip to content

Conversation

@jiexi
Copy link
Contributor

@jiexi jiexi commented Dec 4, 2025

Description

When deeplinking the user into the wallet for non-initial connection cases, the wallet has no idea which connection/session the user is opening the wallet from. In the case that the connection the dapp is using no longer exists on the wallet side, the user will sit in the wallet indefinitely waiting for a request that will never arrive.

This PR fixes that by checking the connection id from the new simple deeplink of format `metamask://connect/mwp?id=CONN_ID_HERE. This will allow the wallet to prompt the user with an error toast if that connection no longer exists on the wallet side.

Changelog

CHANGELOG entry: null

MetaMask Connect has not been released yet

Related issues

See: MetaMask/connect-monorepo#63

Manual testing steps

Writing these testing steps as if you have context already. If not, please reach out to the Wallet Integrations team.

  1. Build the connect-monorepo packages in the branch linked above
  2. Delete all node_modules from wagmi and reinstall them
  3. Rebuild wagmi packages
  4. Start the wagmi react playground
  5. Visit the wagmi dapp from the native mobile browser
  6. Create a new connection
  7. In the wallet, clear all MMC connections by going to settings -> privacy -> connections
  8. From the dapp in the native mobile browser, make a sign request
  9. Open the deeplink
  10. the wallet should show you a not found error toast like the one in the recording

NOTE: if you are using expo, I highly recommend swiping away the metamask app between each deeplink

Screenshots/Recordings

Before

After

Screen.Recording.2025-12-04.at.3.00.22.PM.mov

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Implements simple MWP deeplink handling that shows a "connection not found" toast when a session is missing, renames SDKConnectV2 deeplink APIs, and updates QR scanner, adapter, i18n, and tests accordingly.

  • SDKConnect V2 / Deeplinks:
    • Introduces isMwpDeeplink, handleMwpDeeplink, and handleSimpleDeeplink in core/SDKConnectV2/services/connection-registry.ts to support MWP deeplinks and a simple id flow.
    • Shows a not-found toast when a simple deeplink references a missing connection, waiting for unlock and store readiness.
    • Updates deeplink entrypoint (core/DeeplinkManager/handleDeeplink.ts) to use new MWP handlers.
  • UI & i18n:
    • Adds HostApplicationAdapter.showNotFoundError() and wires notification display.
    • Adds sdk_connect_v2.show_not_found strings in locales/languages/en.json.
  • QR Scanner:
    • Switches to SDKConnectV2.isMwpDeeplink / handleMwpDeeplink in Views/QRScanner logic and utils.
  • Types:
    • Extends IHostApplicationAdapter with showNotFoundError.
  • Tests:
    • Adds/updates tests for MWP deeplink detection and handling, simple deeplink behavior, and QR scanner/util flows.
    • Adjusts test setup mocks to new API names.

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

@jiexi jiexi requested review from a team as code owners December 4, 2025 23:18
@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2025

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot metamaskbot added the team-wallet-integrations Wallet Integrations team label Dec 4, 2025
@jiexi jiexi changed the title jl/parse deeplink with sessionId feat: add connection not found error toast Dec 4, 2025
@jiexi jiexi changed the title feat: add connection not found error toast feat: add connection not found error toast for MetaMask Connect Dec 4, 2025
@github-actions github-actions bot added the size-S label Dec 4, 2025
@jiexi jiexi added the no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed label Dec 4, 2025
@github-actions github-actions bot added size-M and removed size-S labels Dec 5, 2025
handler,
);
});
}
Copy link

Choose a reason for hiding this comment

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

Bug: Event subscription leaks when wallet stays locked

The handleSimpleDeeplink method subscribes to 'KeyringController:unlock' when the wallet is locked, but if the wallet is never unlocked (user kills app, navigates away, etc.), the subscription and associated Promise callback remain in memory indefinitely. Each call to this method while the wallet is locked creates a new subscription that may never be cleaned up, causing accumulated memory retention over time.

Fix in Cursor Fix in Web

});

describe('isConnectDeeplink', () => {
describe('isMwpDeeplink', () => {
Copy link

Choose a reason for hiding this comment

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

Bug: Test names use prohibited "should" prefix (Bugbot Rules)

All new test cases in this file use "should" in their names (e.g., 'should return true for valid MWP connect deeplinks', 'should handle a valid simple deeplink', 'should not show error if connection is found in the store'). Per unit testing guidelines, test names must never use "should" - this is a hard rule with zero exceptions. Test names need to be action-oriented and describe what the code does directly.

Additional Locations (2)

Fix in Cursor Fix in Web

@jiexi jiexi requested a review from a team as a code owner December 5, 2025 18:39
});

describe('when the connection is not found in the store', () => {
it('should show error if connection when the keyring is unlocked', async () => {
Copy link

Choose a reason for hiding this comment

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

Bug: Test names use "should" violating naming rules (Bugbot Rules)

The new test names at lines 292 and 307 use "should" which violates the unit testing guidelines that state "NEVER use 'should' in test names - this is a hard rule with zero exceptions." Additionally, both test names have grammatical issues making them confusing: line 292 says "if connection when" (missing "not found") and line 307 says "connection is keyring is" (extra "is").

Additional Locations (1)

Fix in Cursor Fix in Web

@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2025

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeCore, SmokeWalletPlatform
  • Risk Level: medium
  • AI Confidence: 72%
click to see 🤖 AI reasoning details

This PR modifies critical core functionality in the SDKConnectV2 and DeeplinkManager modules:

  1. API Renaming: isConnectDeeplinkisMwpDeeplink and handleConnectDeeplinkhandleMwpDeeplink - this is a breaking API change within the codebase, though all usages have been properly updated.

  2. New Deeplink Routing Logic: The new handleMwpDeeplink acts as a router that distinguishes between "simple" deeplinks (with just an id param) and "connect" deeplinks (with p param). Simple deeplinks look up existing connections rather than creating new ones.

  3. Engine/KeyringController Integration: The handleSimpleDeeplink method interacts with Engine.context.KeyringController.isUnlocked() and subscribes to KeyringController:unlock events, which is critical wallet state.

  4. New Error UI: Added "Connection Not Found" error notification through showNotFoundError().

Since no E2E tests directly cover SDKConnectV2 deeplinks (confirmed by grep), I'm selecting:

  • SmokeCore: Because this modifies core deeplink handling infrastructure, Engine interactions, and QR Scanner functionality
  • SmokeWalletPlatform: Because this affects wallet connection flows and core platform behavior

The changes are well-covered by unit tests (connection-registry.test.ts, QRScanner tests updated), but the E2E risk is around potential regressions in deeplink handling and QR scanning flows that could affect user connectivity with dapps.

View GitHub Actions results

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 5, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed size-M team-wallet-integrations Wallet Integrations team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants