Skip to content

feat: multichain initial request+deeplinks#1351

Merged
elribonazo merged 17 commits into
mainfrom
features/initial-request+deeplinks
Oct 2, 2025
Merged

feat: multichain initial request+deeplinks#1351
elribonazo merged 17 commits into
mainfrom
features/initial-request+deeplinks

Conversation

@elribonazo

@elribonazo elribonazo commented Sep 30, 2025

Copy link
Copy Markdown
Contributor

Explanation

This PR is adding support for mobile wallet protocol latest features (initial RPC Request) and deeplink management.

In Depth

  1. DeepLinks are triggered using the old logic we had in the old SDK.
  2. We integrated the initialPayload request for Mobile Wallet Protocol which speeds up connection and first request by allowing us to set an initialRPC request, which will be wallet_createSession.
  3. Added better fixtures in tests that now let us test specific Web Mobile flows (deeplinks)

Right now the unitary tests are able to reproduce the following environments:

  1. Desktop Browser with Extension installed
  2. NodeJS platforms
  3. ReactNative platforms
  4. Mobile Web

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate

Note

Adds deeplink/universal-link connection with MWP initial payload, introduces explicit Default/MWP transports, updates state/notifications and UI, and overhauls tests and playground.

  • SDK Core/Transports:
    • Introduce MWPTransport (initial payload, reconnect on focus, request timeouts) and new DefaultTransport (browser extension) with session create/upgrade logic.
    • Emit stateChanged via onNotification; refactor state flow; remove getCurrentSession from MultichainCore.
    • Add deeplink connect path for secure mobile web; persist/reconnect transport; improve disconnect handling.
  • UI:
    • Generate deeplink/universal link (metamask://, https://metamask.app.link); make unload/onClose async and adjust OTP modal callbacks.
  • Platform/Config:
    • Add isSecure, hasExtension; new METAMASK_CONNECT_BASE_URL and METAMASK_DEEPLINK_BASE.
  • Types/API:
    • Extend options (mobile.preferredOpenLink, mobile.useDeeplink, transport.onNotification); add ExtendedTransport; tweak RPC error message wording.
  • Tests:
    • Replace fixtures with new tests/* harness, mocks, and envs; add web-mobile coverage; expand connect/invoke/session error scenarios.
  • Playground:
    • Update React app to handle notifications/state/errors; CRACO config tweaks (conditions, polyfills).
  • Dependencies:
    • Bump @metamask/mobile-wallet-protocol-* to ^0.2.x; add @types/jsdom; adjust @metamask/utils in playground.

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

@elribonazo elribonazo marked this pull request as ready for review September 30, 2025 11:52
@elribonazo elribonazo requested a review from a team as a code owner September 30, 2025 11:52
cursor[bot]

This comment was marked as outdated.

@socket-security

socket-security Bot commented Sep 30, 2025

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatednpm/​@​metamask/​mobile-wallet-protocol-dapp-client@​0.1.1 ⏵ 0.2.177 +21006893 +1100
Addednpm/​@​types/​jsdom@​21.1.71001007485100
Updatednpm/​@​metamask/​mobile-wallet-protocol-core@​0.1.1 ⏵ 0.2.0100 +2100100 +33100 +8100

View full report

@codecov

codecov Bot commented Sep 30, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.99%. Comparing base (13cd092) to head (a3fed68).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1351      +/-   ##
==========================================
+ Coverage   74.93%   74.99%   +0.05%     
==========================================
  Files         184      184              
  Lines        4513     4519       +6     
  Branches     1105     1108       +3     
==========================================
+ Hits         3382     3389       +7     
+ Misses       1131     1130       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@elribonazo elribonazo force-pushed the features/initial-request+deeplinks branch from 04c3b12 to 65e816c Compare October 2, 2025 10:17
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Comment thread packages/sdk-multichain/src/domain/multichain/types.ts
import { addValidAccounts, getOptionalScopes, getValidAccounts } from '../../utils';

const DEFAULT_REQUEST_TIMEOUT = 60 * 1000;
const DEFAULT_CONNECTION_TIMEOUT = DEFAULT_REQUEST_TIMEOUT;

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.

We should use these two combined

https://github.com/MetaMask/mobile-wallet-protocol/pull/50/files#diff-6ad55774fe6aa232e30c073b528b62d2636a2ff63689571e9841d33bb87362caR23-R24

This will will request timeout + some grace period for the user to go back to the wallet. But the QR code will still have the same request timeout only

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.

So DEFAULT_REQUEST_TIMEOUT = 60s, DEFAULT_CONNECTION_TIMEOUT = 120s (DEFAULT_REQUEST_TIMEOUT + grace period for user to come back to the dapp)

chakra-guy
chakra-guy previously approved these changes Oct 2, 2025

@chakra-guy chakra-guy left a comment

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.

LGTM! Great tests!

@elribonazo elribonazo requested a review from chakra-guy October 2, 2025 12:43
@sonarqubecloud

sonarqubecloud Bot commented Oct 2, 2025

Copy link
Copy Markdown

@elribonazo elribonazo merged commit ac8f8c3 into main Oct 2, 2025
44 checks passed
@elribonazo elribonazo deleted the features/initial-request+deeplinks branch October 2, 2025 13:13
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