Skip to content

Initial Multichain API docs #1621

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open

Initial Multichain API docs #1621

wants to merge 37 commits into from

Conversation

alexandratran
Copy link
Contributor

@alexandratran alexandratran commented Oct 9, 2024

Description

Initial Multichain API docs.

Issue(s) fixed

Fixes #1566

Preview

(Links updated Mar 5)

Checklist

Complete this checklist before merging your PR:

  • If this PR contains a major change to the documentation content, I have added an entry to the top of the "What's new?" page.
  • The proposed changes have been reviewed and approved by a member of the documentation team.

Copy link

vercel bot commented Oct 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
metamask-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 22, 2025 4:06am

@vandan
Copy link
Contributor

vandan commented Oct 18, 2024

For MetaMask, I do not believe we need to document the scenario where wallet_createSession is used with sessionIds.

# Conflicts:
#	docusaurus.config.js
#	wallet-sidebar.js
…nto 1566-multichain

# Conflicts:
#	docusaurus.config.js
#	wallet-sidebar.js
@vandan
Copy link
Contributor

vandan commented Apr 15, 2025

Sorry to change this, but the multichain API will essentially be rolling directly to production (vs Flask). We will still need to describe it as "experimental" in the API reference though.
We could also reference the following MIPs, which will include a little more detail:
https://github.com/MetaMask/metamask-improvement-proposals/blob/main/MIPs/mip-5.md (Multichain API)
https://github.com/MetaMask/metamask-improvement-proposals/blob/main/MIPs/mip-6.md (Ethereum-specific use of the Multichain API)

# Conflicts:
#	docs/whats-new.md
---
description: Learn about the Multichain API.
sidebar_custom_props:
flask_only: true
Copy link
Contributor

Choose a reason for hiding this comment

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

it's flask and beta soon i believe. @vandan

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To clarify, should we remove the flask label and replace it with a note that the feature is experimental / a beta release?

}
}%%

sequenceDiagram
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to show the case where sessionChange is successful?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This diagram was taken from CAIP 316. Would a successful sessionChange case look the same as the failed case, minus the "connection interrupted" / "connection re-established" arrows?

Comment on lines +43 to +46
scope: msg.data.params.scope,
method: msg.data.params.notification.method,
subscription: msg.data.params.notification.params.subscription,
number: msg.data.params.notification.params.result.number
Copy link
Contributor

Choose a reason for hiding this comment

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

this is specifically for making eth_subscription events over wallet_notify easier to read. It will break if there are other wallet_notify events that are not eth_subscription. Perhaps we remove this block entirely, or make the guards more precise?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we remove, would we be removing the entire message handling block?

// Set up message listener for events.
extensionPort.onMessage.addListener((msg) => {
  // Format wallet_notify events to be able to read them later.
  if (msg.data.method === "wallet_notify") {
    console.log("wallet_notify:", {
      scope: msg.data.params.scope,
      method: msg.data.params.notification.method,
      subscription: msg.data.params.notification.params.subscription,
      number: msg.data.params.notification.params.result.number
    })
    return;
  }
  console.log(msg.data)
})

Alternatively, we can specify that this example specifically makes eth_subscription events easier to read.

- For each network, request access to [Wallet API methods](../../reference/json-rpc-methods/index.md)
that your dapp expects to call at any time.
The methods listed in the `sessionScope` of each Multichain API response indicate which wallet
capabilities your dapp can use during the connection.
Copy link
Contributor

Choose a reason for hiding this comment

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

session vs connection, what is the better term? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was raised by @vandan in a previous comment, so we switched to "connection" to see how it flows. I'm OK with either term.

The CAIP standards extensively use the term "session", which insinuates a transient connection. MetaMask predominantly establishes persistent connections so we could consider using alternative terminology such as "connection". But I'm not sure if it's more confusing to diverge from the names used in the Multichain API methods.

},
"sessionProperties": {
"expiry": "2022-12-24T17:07:31+00:00",
"caip154-mandatory": "true"
Copy link
Contributor

Choose a reason for hiding this comment

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

@adonesky1 we technically don't enforce these yet

Choose a reason for hiding this comment

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

Yeah let's remove this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I remove the whole sessionProperties or just "caip154-mandatory": "true"?

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.

Initial Multichain API docs
5 participants