Skip to content

Comments

feat: ConnectMultichain Singleton#157

Merged
jiexi merged 110 commits intomainfrom
jl/singleton
Feb 20, 2026
Merged

feat: ConnectMultichain Singleton#157
jiexi merged 110 commits intomainfrom
jl/singleton

Conversation

@jiexi
Copy link
Contributor

@jiexi jiexi commented Feb 3, 2026

Explanation

This PR introduces a singleton pattern for the Multichain SDK that shifts the source of truth for connection status for downstream ecosystem clients (ConnectEVM, ConnectSolana) to the wallet_sessionChanged event.

  1. Adds a singleton for the actual MetaMaskConnectMultichain instance itself with logic to merge incoming constructor options with the existing constructor options of the singleton

  2. Removes the disconnect() on connect() pattern

  3. Calling connect() while there is an inflight MWP connection results in a 'Existing connection is pending. Please check your MetaMask Mobile app to continue.' error being thrown

    • This mirrors the existing Default transport behavior in which multiple permission requests cannot be inflight at once (request of type wallet_requestPermissions already pending for origin...)
  4. connect() is now additive and will combine the requested scopes and accounts with the existing (if any)

    • Also had to remove wallet_revokeSession call in DefaultTransport.connect()
  5. disconnect() now supports partial revokes. If some scopes still remain after a partial revoke, the underlying connection remains intact and can be reused.

  6. Fix/Adjust Browser Playground

    • Adds disconnect buttons to Browser playground cards
    • Fixes EVM Provider setChainId and setAccounts to also use the connect event
    • Removes the explicit ActiveProviderStorage pattern. Now all providers (cards) are "Active" even without user input to connect to a specific ecosystem
    • Multichain Card and button properly reflect initial instantiation connecting status
  7. Makes wallet_sessionChanged the source of truth for ConnectEvm and future ecosystem clients

Addresses: https://consensyssoftware.atlassian.net/browse/WAPI-1066

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 communicated my changes to consumers by updating changelogs for packages I've changed, highlighting breaking changes as necessary
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

@jiexi jiexi requested a review from a team as a code owner February 3, 2026 19:16
@adonesky1
Copy link
Contributor

adonesky1 commented Feb 5, 2026

Screen.Recording.2026-02-05.at.2.20.51.PM.mov

EDIT

After testing further I see that even if my initial connection is with the legacy connector I see that same error 🤔

I'm starting to wonder whether we should even have this error "Requests cannot be made to chains not explicitly configured in supportedNetworks."

@jiexi
Copy link
Contributor Author

jiexi commented Feb 19, 2026

PR desc updated

wenfix
wenfix previously approved these changes Feb 20, 2026
…inApiClientWrapper/index.ts

Co-authored-by: Tamas <tamas.soos94@gmail.com>
Copy link
Contributor

@adonesky1 adonesky1 left a comment

Choose a reason for hiding this comment

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

LGTM! Let's go!!! Amazing work Jiexi 🚀 🚀 🚀

@jiexi jiexi merged commit 7df7d10 into main Feb 20, 2026
52 checks passed
@jiexi jiexi deleted the jl/singleton branch February 20, 2026 23:19
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.

5 participants