Commit 6b67d84
authored
feat(snap-account-service): track account management Snaps + add
## Explanation
Tracking account management Snaps so we can "restrict" the use of this
service only for those Snaps.
This will also be used later on to initialize their associated
`SnapKeyring` v2.
## References
N/A
## Checklist
- [ ] I've updated the test suite for new or updated code as appropriate
- [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [ ] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md)
- [ ] I've introduced [breaking
changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md)
in this PR and have prepared draft pull requests for clients and
consumer packages to resolve them
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Changes `SnapAccountService.ensureReady` semantics to reject
unknown/uninitialized Snap IDs and adds new messenger dependencies on
`SnapController` lifecycle events, which could break existing consumers
or event wiring if not updated.
>
> **Overview**
> Adds `SnapTracker`, which seeds and maintains an in-memory set of
*account-management Snaps* (installed/enabled, not blocked, and
declaring `endowment:keyring`) based on
`SnapController:getRunnableSnaps` plus `SnapController` lifecycle
events.
>
> `SnapAccountService` now initializes this tracker in `init()`, exposes
a new `getSnaps()` messenger method, and updates `ensureReady(snapId)`
to **throw `Unknown snap: "<id>"`** unless the snap is currently tracked
(effectively requiring callers to run `init()` and only use eligible
Snaps). Tests and exports/changelog are updated accordingly, and the
service messenger contract expands to include the new `SnapController`
actions/events.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
48b03c9. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->:getSnaps (#8725)1 parent c351602 commit 6b67d84
7 files changed
Lines changed: 784 additions & 32 deletions
File tree
- packages/snap-account-service
- src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
14 | 16 | | |
| 17 | + | |
15 | 18 | | |
16 | 19 | | |
17 | 20 | | |
18 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
19 | 26 | | |
20 | 27 | | |
21 | 28 | | |
22 | 29 | | |
23 | | - | |
24 | | - | |
25 | 30 | | |
26 | 31 | | |
Lines changed: 18 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
8 | 20 | | |
9 | 21 | | |
10 | | - | |
| 22 | + | |
| 23 | + | |
11 | 24 | | |
12 | 25 | | |
13 | 26 | | |
14 | | - | |
| 27 | + | |
| 28 | + | |
15 | 29 | | |
16 | 30 | | |
17 | 31 | | |
| |||
22 | 36 | | |
23 | 37 | | |
24 | 38 | | |
25 | | - | |
| 39 | + | |
| 40 | + | |
Lines changed: 113 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
2 | 5 | | |
3 | 6 | | |
4 | 7 | | |
5 | 8 | | |
6 | 9 | | |
7 | 10 | | |
8 | 11 | | |
| 12 | + | |
| 13 | + | |
9 | 14 | | |
10 | 15 | | |
11 | 16 | | |
12 | 17 | | |
13 | 18 | | |
14 | 19 | | |
15 | 20 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | | - | |
27 | | - | |
28 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
29 | 36 | | |
30 | 37 | | |
31 | 38 | | |
32 | 39 | | |
| 40 | + | |
33 | 41 | | |
34 | 42 | | |
35 | 43 | | |
| |||
62 | 70 | | |
63 | 71 | | |
64 | 72 | | |
65 | | - | |
66 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
67 | 89 | | |
68 | 90 | | |
69 | 91 | | |
| |||
97 | 119 | | |
98 | 120 | | |
99 | 121 | | |
100 | | - | |
101 | | - | |
| 122 | + | |
102 | 123 | | |
103 | 124 | | |
104 | 125 | | |
105 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
106 | 143 | | |
107 | 144 | | |
108 | 145 | | |
109 | 146 | | |
110 | 147 | | |
111 | 148 | | |
| 149 | + | |
112 | 150 | | |
113 | 151 | | |
114 | 152 | | |
115 | 153 | | |
116 | 154 | | |
117 | 155 | | |
| 156 | + | |
118 | 157 | | |
119 | 158 | | |
120 | 159 | | |
121 | 160 | | |
| 161 | + | |
122 | 162 | | |
123 | 163 | | |
124 | 164 | | |
| |||
134 | 174 | | |
135 | 175 | | |
136 | 176 | | |
| 177 | + | |
137 | 178 | | |
138 | 179 | | |
139 | 180 | | |
| |||
144 | 185 | | |
145 | 186 | | |
146 | 187 | | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
147 | 192 | | |
148 | 193 | | |
149 | 194 | | |
| |||
154 | 199 | | |
155 | 200 | | |
156 | 201 | | |
157 | | - | |
| 202 | + | |
158 | 203 | | |
159 | 204 | | |
160 | 205 | | |
| |||
165 | 210 | | |
166 | 211 | | |
167 | 212 | | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
168 | 225 | | |
169 | | - | |
| 226 | + | |
170 | 227 | | |
171 | 228 | | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
172 | 253 | | |
173 | 254 | | |
174 | 255 | | |
175 | 256 | | |
176 | | - | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
177 | 263 | | |
178 | 264 | | |
179 | 265 | | |
| |||
190 | 276 | | |
191 | 277 | | |
192 | 278 | | |
193 | | - | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
194 | 285 | | |
195 | 286 | | |
196 | 287 | | |
| |||
213 | 304 | | |
214 | 305 | | |
215 | 306 | | |
| 307 | + | |
216 | 308 | | |
217 | 309 | | |
218 | 310 | | |
219 | 311 | | |
220 | 312 | | |
| 313 | + | |
| 314 | + | |
221 | 315 | | |
222 | 316 | | |
223 | 317 | | |
| |||
242 | 336 | | |
243 | 337 | | |
244 | 338 | | |
| 339 | + | |
245 | 340 | | |
246 | 341 | | |
247 | 342 | | |
| 343 | + | |
| 344 | + | |
248 | 345 | | |
249 | 346 | | |
250 | 347 | | |
| |||
0 commit comments