Skip to content

fix: Stop relying on account metadata for MultichainRoutingService#3974

Merged
FrederikBolding merged 3 commits intomainfrom
fb/accounts-controller-breaking-changes
Apr 29, 2026
Merged

fix: Stop relying on account metadata for MultichainRoutingService#3974
FrederikBolding merged 3 commits intomainfrom
fb/accounts-controller-breaking-changes

Conversation

@FrederikBolding
Copy link
Copy Markdown
Member

@FrederikBolding FrederikBolding commented Apr 29, 2026

Stop relying on account.metadata.snap.enabled for MultichainRoutingService as it is going away. Instead we can cross-check getRunnableSnaps.

While doing this fix I also managed to re-use getSupportedAccountsMetadata in more cases.

https://consensyssoftware.atlassian.net/browse/WPC-988


Note

Medium Risk
Changes routing eligibility checks for account Snaps by cross-referencing SnapController:getRunnableSnaps, which could impact which accounts/methods are considered routable if Snap/account metadata is inconsistent. Touches request routing and scope support detection, so regressions would affect multichain RPC handling.

Overview
Stops relying on account.metadata.snap.enabled (and other snap metadata fields) to decide whether an account Snap can service a request, and instead gates supported accounts by whether their metadata.snap.id appears in SnapController:getRunnableSnaps.

Refactors MultichainRoutingService to reuse #getSupportedAccountsMetadata for both request routing (#getSnapAccountId) and isSupportedScope, and extends it with an optional method filter.

Updates multichain test fixtures and InternalAccount typing to remove the deprecated metadata.snap.enabled/name fields, and adjusts tests to mock SnapController:getRunnableSnaps (including updated call ordering expectations).

Reviewed by Cursor Bugbot for commit a5425d0. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment on lines +362 to +365
account.metadata.snap?.id !== undefined &&
runnableSnaps.includes(account.metadata.snap?.id) &&
((method !== undefined && account.methods.includes(method)) ||
method === undefined),
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is quite a bit more complicated to read now, but potentially worth it for the re-use?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I wonder if flipping the expression would make it slightly more readable? 🤔 like:

          account.metadata.snap?.id !== undefined &&
          runnableSnaps.includes(account.metadata.snap?.id) &&
          (method === undefined || account.methods.includes(method))

I assume the compiler will "infer" that method cannot be undefined after the ||?

Copy link
Copy Markdown

@ccharly ccharly Apr 29, 2026

Choose a reason for hiding this comment

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

(but IMO that's worth for the re-use yep)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good point!

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.56%. Comparing base (581474c) to head (a5425d0).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3974   +/-   ##
=======================================
  Coverage   98.56%   98.56%           
=======================================
  Files         429      429           
  Lines       12363    12365    +2     
  Branches     1942     1944    +2     
=======================================
+ Hits        12185    12187    +2     
  Misses        178      178           

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

// We currently assume here that if one Snap exists that service the scope, we can service the scope generally.
return hasAccountSnap || this.#getProtocolSnaps(scope).length > 0;
return (
this.#getSupportedAccountsMetadata(scope).length > 0 ||
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is slightly slower now since we do not use .some. We could duplicate the code to make it faster

@FrederikBolding FrederikBolding marked this pull request as ready for review April 29, 2026 12:19
@FrederikBolding FrederikBolding requested a review from a team as a code owner April 29, 2026 12:19
@FrederikBolding FrederikBolding added this pull request to the merge queue Apr 29, 2026
Merged via the queue into main with commit 4fc63db Apr 29, 2026
130 checks passed
@FrederikBolding FrederikBolding deleted the fb/accounts-controller-breaking-changes branch April 29, 2026 12:44
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.

3 participants