Skip to content
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

feat: Implement MultichainRouter and onProtocolRequest (SIP-26) #2875

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

Conversation

FrederikBolding
Copy link
Member

@FrederikBolding FrederikBolding commented Nov 5, 2024

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:

"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

@FrederikBolding FrederikBolding changed the title wip: Add MultichainRoutingController feat: Implement MultichainRoutingController (SIP-26) Nov 20, 2024
@FrederikBolding FrederikBolding changed the title feat: Implement MultichainRoutingController (SIP-26) feat: Implement MultichainRoutingController and onProtocolRequest (SIP-26) Nov 20, 2024
Copy link

codecov bot commented Nov 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.87%. Comparing base (c909011) to head (ef7e20c).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2875      +/-   ##
==========================================
+ Coverage   94.80%   94.87%   +0.06%     
==========================================
  Files         503      506       +3     
  Lines       10996    11116     +120     
  Branches     1685     1702      +17     
==========================================
+ Hits        10425    10546     +121     
+ Misses        571      570       -1     

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

@FrederikBolding FrederikBolding changed the title feat: Implement MultichainRoutingController and onProtocolRequest (SIP-26) feat: Implement MultichainRouter and onProtocolRequest (SIP-26) Nov 21, 2024
@FrederikBolding FrederikBolding force-pushed the fb/sip26 branch 2 times, most recently from 047e488 to ba2412d Compare December 5, 2024 09:48
@FrederikBolding FrederikBolding force-pushed the fb/sip26 branch 2 times, most recently from 0c62acf to 5e42ee7 Compare December 16, 2024 12:30
@FrederikBolding FrederikBolding marked this pull request as ready for review January 29, 2025 09:37
@FrederikBolding FrederikBolding requested a review from a team as a code owner January 29, 2025 09:37
);

if (!selectedAccount) {
throw rpcErrors.invalidParams();
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a more descriptive error message?

Copy link
Member Author

Choose a reason for hiding this comment

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

Any proposals? 😄

Copy link
Member

Choose a reason for hiding this comment

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

"Unable to get selected account" or something?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

Mrtenz
Mrtenz previously approved these changes Jan 29, 2025
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.

Implement routing logic and endowment for SIP-26
2 participants