Skip to content

Commit

Permalink
feat: Implement MultichainRouter and onProtocolRequest (SIP-26) (#…
Browse files Browse the repository at this point in the history
…2875)

This PR adds a `MultichainRouter` that can handle routing of non-EVM
requests received via the multichain API. The multichain API should
integrate this by calling `MultichainRouter.handleRequest` for any
requests that are not understood by our existing JSON-RPC stack.

Additionally this PR implements `onProtocolRequest`, a new handler that
Snaps can choose to register if they want to service protocol (non
signing) requests for a given set of methods for one or more chains. The
endowment is registered as follows:
```json5
"initialPermissions": {
  "endowment:protocol": {
    "scopes": {
      "<caip2_chainId>": {
        "methods": [
          // List of supported methods
        ],
        "notifications": [
          // List of supported notifications
        ]
      }
    }
  }
}
```

This implementation follows https://metamask.github.io/SIPs/SIPS/sip-26

Closes #2898

---------

Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com>
  • Loading branch information
FrederikBolding and Mrtenz authored Jan 31, 2025
1 parent ce86a74 commit 0c7eb2e
Show file tree
Hide file tree
Showing 31 changed files with 1,568 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "R4WjwqkDLNMUtU07n8AGq0WZKjsqjTjQXlASF++J4ws=",
"shasum": "Yzt/aRJTbRwAn3zbbK7W3MjgVVt2f6jLMGSc6pe2oyg=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/browserify/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "06xWu+ehUlNMpbJQxTZi2mlnAJId3cLHEK6fWD2Z9rc=",
"shasum": "J+fHvBGBrcoSZ5R1dEiIO3PegqNGFElb1i4h9Zw4zxg=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
8 changes: 4 additions & 4 deletions packages/snaps-controllers/coverage.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"branches": 93.06,
"functions": 96.61,
"lines": 98.08,
"statements": 97.8
"branches": 93.28,
"functions": 96.8,
"lines": 98.15,
"statements": 97.88
}
1 change: 1 addition & 0 deletions packages/snaps-controllers/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export * from './utils';
export * from './cronjob';
export * from './interface';
export * from './insights';
export * from './multichain';
Loading

0 comments on commit 0c7eb2e

Please sign in to comment.