Commit 9aa68cd
authored
fix: Throw if Snap not installed (#3666)
When invoking Snaps directly, e.g. from within MetaMask, we were
currently not validating that Snaps were installed. This means that
misleading errors would be thrown about permissions when the Snap was
not installed in the first place.
Also removes this check from one RPC method, since it is now
unnecessary. We leave the RPC method around in `invokeKeyring` to not
change the error handling behavior.
Closes #3658
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Adds an installation check to SnapController.handleRequest, removes
redundant snap-installed checks from invokeSnap, aligns error messages,
and updates tests and coverage thresholds.
>
> - **SnapController**:
> - Validate Snap exists in `handleRequest` and throw a clear error if
not installed.
> - Refactor subsequent checks to use local `snap` (enabled/status).
> - **RPC Methods**:
> - `invokeSnap`: Remove `getSnap` hook and installed check; rely on
controller for validation.
> - `invokeKeyring`: Align "not installed" error message with
controller.
> - **Tests**:
> - Add test for non-installed Snap in `SnapController.handleRequest`.
> - Update `invokeSnap` tests to drop `getSnap` usage and non-installed
error case.
> - Update `invokeKeyring` tests to match new error message.
> - **Config**:
> - Slightly adjust Jest coverage thresholds in `snaps-rpc-methods`.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
303b2b9. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 5d19c66 commit 9aa68cd
File tree
7 files changed
+36
-44
lines changed- packages
- snaps-controllers/src/snaps
- snaps-rpc-methods
- src
- permitted
- restricted
7 files changed
+36
-44
lines changedLines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2192 | 2192 | | |
2193 | 2193 | | |
2194 | 2194 | | |
| 2195 | + | |
| 2196 | + | |
| 2197 | + | |
| 2198 | + | |
| 2199 | + | |
| 2200 | + | |
| 2201 | + | |
| 2202 | + | |
| 2203 | + | |
| 2204 | + | |
| 2205 | + | |
| 2206 | + | |
| 2207 | + | |
| 2208 | + | |
| 2209 | + | |
| 2210 | + | |
| 2211 | + | |
| 2212 | + | |
| 2213 | + | |
| 2214 | + | |
| 2215 | + | |
2195 | 2216 | | |
2196 | 2217 | | |
2197 | 2218 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3588 | 3588 | | |
3589 | 3589 | | |
3590 | 3590 | | |
| 3591 | + | |
| 3592 | + | |
| 3593 | + | |
| 3594 | + | |
| 3595 | + | |
| 3596 | + | |
| 3597 | + | |
3591 | 3598 | | |
3592 | 3599 | | |
3593 | 3600 | | |
| |||
3666 | 3673 | | |
3667 | 3674 | | |
3668 | 3675 | | |
3669 | | - | |
| 3676 | + | |
3670 | 3677 | | |
3671 | 3678 | | |
3672 | 3679 | | |
3673 | | - | |
| 3680 | + | |
3674 | 3681 | | |
3675 | 3682 | | |
3676 | 3683 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
306 | | - | |
| 306 | + | |
307 | 307 | | |
308 | 308 | | |
309 | 309 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| 110 | + | |
110 | 111 | | |
111 | | - | |
| 112 | + | |
112 | 113 | | |
113 | 114 | | |
114 | 115 | | |
| |||
Lines changed: 0 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | 26 | | |
28 | 27 | | |
29 | 28 | | |
| |||
33 | 32 | | |
34 | 33 | | |
35 | 34 | | |
36 | | - | |
37 | 35 | | |
38 | 36 | | |
39 | 37 | | |
| |||
53 | 51 | | |
54 | 52 | | |
55 | 53 | | |
56 | | - | |
57 | 54 | | |
58 | 55 | | |
59 | 56 | | |
| |||
90 | 87 | | |
91 | 88 | | |
92 | 89 | | |
93 | | - | |
94 | 90 | | |
95 | 91 | | |
96 | 92 | | |
| |||
101 | 97 | | |
102 | 98 | | |
103 | 99 | | |
104 | | - | |
105 | | - | |
106 | 100 | | |
107 | 101 | | |
108 | 102 | | |
| |||
113 | 107 | | |
114 | 108 | | |
115 | 109 | | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | 110 | | |
138 | 111 | | |
139 | 112 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
41 | 40 | | |
42 | 41 | | |
43 | 42 | | |
| |||
139 | 138 | | |
140 | 139 | | |
141 | 140 | | |
142 | | - | |
143 | 141 | | |
144 | 142 | | |
145 | 143 | | |
| |||
153 | 151 | | |
154 | 152 | | |
155 | 153 | | |
156 | | - | |
157 | 154 | | |
158 | 155 | | |
159 | 156 | | |
160 | 157 | | |
161 | 158 | | |
162 | | - | |
163 | 159 | | |
164 | 160 | | |
165 | 161 | | |
| |||
169 | 165 | | |
170 | 166 | | |
171 | 167 | | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | 168 | | |
179 | 169 | | |
180 | 170 | | |
| |||
0 commit comments