Skip to content

fix: improve multichain SDK to use ConnectionRequests as QRCodes#1347

Merged
elribonazo merged 21 commits into
mainfrom
features/connection-requests
Sep 25, 2025
Merged

fix: improve multichain SDK to use ConnectionRequests as QRCodes#1347
elribonazo merged 21 commits into
mainfrom
features/connection-requests

Conversation

@elribonazo

@elribonazo elribonazo commented Sep 19, 2025

Copy link
Copy Markdown
Contributor

Explanation

Multichain SDK was previous using sessionRequests to generate QRCodes, during a while this was enough for us to start testing the Dapps (node, react).

Now the Mobile app can already establish connections with the Mobile wallet protocol relay server, and we need to integrate this ConnectionRequests into the multichain SDK so the QRCodes are created properly.

Difference is really not much (types extracted from MWP)

type ConnectionMode = "trusted" | "untrusted";
type SessionRequest = {
    id: string;
    mode: ConnectionMode;
    channel: string;
    publicKeyB64: string;
    expiresAt: number;
};
type DappSettings = { name?: string; url?: string } & ({ iconUrl?: string } | { base64Icon?: string });
type ConnectionRequest = {
	sessionRequest: SessionRequest;
	metadata: { dapp: DappSettings; sdk: { version: string; platform: string }};
};

This will make the QRCodes on install modal (all platforms) to use the right payload to generate QRCodes.

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

@elribonazo elribonazo changed the title fix: improve install modal to manage links directly not sessionRequests fix: improve multichain SDK to use ConnectionRequests as QRCodes Sep 19, 2025
@elribonazo elribonazo force-pushed the features/connection-requests branch from b1eef31 to ace6bcd Compare September 22, 2025 10:14
@elribonazo elribonazo marked this pull request as ready for review September 22, 2025 10:30
@elribonazo elribonazo requested a review from a team as a code owner September 22, 2025 10:30
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@codecov

codecov Bot commented Sep 22, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.93%. Comparing base (22b64c7) to head (c3b0f1e).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1347   +/-   ##
=======================================
  Coverage   74.93%   74.93%           
=======================================
  Files         184      184           
  Lines        4513     4513           
  Branches     1105     1105           
=======================================
  Hits         3382     3382           
  Misses       1131     1131           

☔ 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.

Comment on lines +36 to +37
"updateLink": any;
"updateExpiresIn": any;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

would typing these as string and number respectively cause us problems downstream, or would it be okay ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

* Abstract Modal class with shared functionality across all models
*/
export abstract class Modal<R = unknown, T = unknown> {
export abstract class Modal<R extends OTPCode | QRLink = OTPCode | QRLink, T extends ModalData = ModalData> {

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.

Does it make sense to use more descriptive names for the generic parameters here (R and T)? Something like SignInConfirmationMethod for the first one, don't have a great name for the second one. No is an okay answer.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I will add that

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Options + Data type though but improved them

() => {
return new Promise<SessionRequest>((resolveSession) => {
return new Promise<ConnectionRequest>((resolveConnectionRequest) => {
this.dappClient.on('session_request', (sessionRequest: SessionRequest) => {

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.

Could we use an enum for event names like session_request?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

on is currently not typed thats a good point, I think @chakra-guy is aware of this. It won't be with an enum though but it knows perfectly which events we have

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@socket-security

socket-security Bot commented Sep 24, 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/​multichain-api-client@​0.6.5 ⏵ 0.8.0100 +3100100 +1100 +5100

View full report

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.

chakra-guy
chakra-guy previously approved these changes Sep 25, 2025
Comment thread packages/sdk-multichain/src/multichain/index.ts
@sonarqubecloud

Copy link
Copy Markdown

@elribonazo elribonazo merged commit 13cd092 into main Sep 25, 2025
44 checks passed
@elribonazo elribonazo deleted the features/connection-requests branch September 25, 2025 14:17
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