fix: Stop relying on account metadata for MultichainRoutingService#3974
fix: Stop relying on account metadata for MultichainRoutingService#3974FrederikBolding merged 3 commits intomainfrom
MultichainRoutingService#3974Conversation
| account.metadata.snap?.id !== undefined && | ||
| runnableSnaps.includes(account.metadata.snap?.id) && | ||
| ((method !== undefined && account.methods.includes(method)) || | ||
| method === undefined), |
There was a problem hiding this comment.
This is quite a bit more complicated to read now, but potentially worth it for the re-use?
There was a problem hiding this comment.
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 ||?
There was a problem hiding this comment.
(but IMO that's worth for the re-use yep)
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
| // 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 || |
There was a problem hiding this comment.
This is slightly slower now since we do not use .some. We could duplicate the code to make it faster
Stop relying on
account.metadata.snap.enabledforMultichainRoutingServiceas it is going away. Instead we can cross-checkgetRunnableSnaps.While doing this fix I also managed to re-use
getSupportedAccountsMetadatain 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 theirmetadata.snap.idappears inSnapController:getRunnableSnaps.Refactors
MultichainRoutingServiceto reuse#getSupportedAccountsMetadatafor both request routing (#getSnapAccountId) andisSupportedScope, and extends it with an optionalmethodfilter.Updates multichain test fixtures and
InternalAccounttyping to remove the deprecatedmetadata.snap.enabled/namefields, and adjusts tests to mockSnapController: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.