refactor(snaps-rpc-methods)!: Use messenger for permitted methods#3987
refactor(snaps-rpc-methods)!: Use messenger for permitted methods#3987FrederikBolding wants to merge 19 commits into
Conversation
| /** | ||
| * @returns All installed Snaps. | ||
| */ | ||
| getAllSnaps: () => Promise<GetSnapsResult>; |
There was a problem hiding this comment.
Turns out the types here have always been wrong
| * file does not exist. | ||
| */ | ||
| export type GetFileResult = string; | ||
| export type GetFileResult = string | null; |
There was a problem hiding this comment.
This has always been possible, but the type was wrong.
41732f0 to
84d1229
Compare
| import { updateInterfaceHandler } from './updateInterface'; | ||
|
|
||
| /* eslint-disable @typescript-eslint/naming-convention */ | ||
| const methodHandlers = { |
There was a problem hiding this comment.
TypeScript failed to generate declarations for this, but we don't actually need to export it, so I moved it here and stopped exporting.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3987 +/- ##
=======================================
Coverage 98.58% 98.58%
=======================================
Files 427 425 -2
Lines 12408 12368 -40
Branches 1949 1949
=======================================
- Hits 12232 12193 -39
+ Misses 176 175 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 644d708. Configure here.
8d8aceb to
0e1747b
Compare
| const response = await engine.handle({ | ||
| jsonrpc: '2.0', | ||
| id: 1, | ||
| method: 'snap_updateInterface', |
There was a problem hiding this comment.
Some of the tests were not correctly nested under the describe() which results in some whitespace changes. Likely easier to review with whitespace off.
7bdac91 to
3d46203
Compare
7bb3579 to
7ac6086
Compare

Migrate the permitted method handlers to use the
messengerwhere applicable.https://consensyssoftware.atlassian.net/browse/WPC-995
Note
Medium Risk
Refactors many permitted RPC handlers to route through controller
messenger.callactions instead of direct hook functions, which can subtly change permission checks, origin handling, and side effects across core Snap RPC methods.Overview
Permitted Snap RPC methods are migrated from hook-based implementations to
messenger-driven controller actions. Handlers now declareactionNames, acceptJsonRpcRequestWithOrigin, and call into actions likePermissionController:hasPermission,SnapController:*,CronjobController:*,WebSocketService:*,KeyringController:getState, andSnapInterfaceController:*.This removes the exported permitted
handlerslist and updates schema generation to read permitted methods fromsrc/permitted/middleware.tsinstead of the deletedhandlers.ts, with associated test updates to useMockControllerMessengerand origin middleware.Also tightens the
get-fileexample by assertingsnap_getFilereturns content beforeJSON.parse, updates its manifest shasum, and adjusts Jest coverage thresholds slightly.Reviewed by Cursor Bugbot for commit 399e36b. Bugbot is set up for automated code reviews on this repo. Configure here.