Commit a607066
feat: Migrate controller guidelines and examples to new Messenger (#6335)
## Explanation
Migrate the controller guidelines and the `sample-controllers` package
to the `next` export of the `@metamask/base-controller` package and the
new `Messenger` class from `@metamask/messenger`.
## References
Relates to #5626
## Checklist
- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs),
highlighting breaking changes as necessary
- [x] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Migrate controller docs and sample-controllers to the new
@metamask/messenger Messenger and @metamask/base-controller/next,
updating APIs, metadata, tests, and dependencies.
>
> - **Docs**
> - Rewrite guidelines and data-services to use `@metamask/messenger`
`Messenger` instead of `RestrictedMessenger`; update examples for
actions/events typing, root/child messenger setup, delegation, and
selector utilities (`MessengerActions`/`MessengerEvents`).
> - Replace references to “messaging system” with “messenger”; update
code samples to
`messenger.call/subscribe/publish/registerMethodActionHandlers`.
> - **Sample Controllers** (`@metamask/sample-controllers`)
> - Migrate to `@metamask/base-controller/next` and
`@metamask/messenger`.
> - Replace `messagingSystem.*` with `messenger.*`; update
controller/service messenger types to `Messenger<...>` and constructor
usage.
> - Update state metadata (`anonymous` → `includeInDebugSnapshot`).
> - Revise tests to use new `Messenger`, mock namespace utilities, and
`MessengerActions/MessengerEvents`.
> - Add dependency on `@metamask/messenger`; update TS project
references.
> - Changelog: mark BREAKING changes for Messenger migration and
metadata rename.
> - **Repo/README**
> - Dependency graph: add `sample_controllers --> messenger`; add
middleware/controller edge; list `@metamask/messenger` package.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
c1ad7a4. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com>
Co-authored-by: Michele Esposito <michele@esposito.codes>1 parent 08302be commit a607066
File tree
14 files changed
+348
-309
lines changed- docs
- packages/sample-controllers
- src
- sample-gas-prices-service
14 files changed
+348
-309
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
333 | 333 | | |
334 | 334 | | |
335 | 335 | | |
| 336 | + | |
336 | 337 | | |
337 | 338 | | |
338 | 339 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
102 | | - | |
103 | | - | |
| 101 | + | |
104 | 102 | | |
105 | 103 | | |
106 | 104 | | |
107 | 105 | | |
108 | 106 | | |
109 | | - | |
| 107 | + | |
110 | 108 | | |
111 | 109 | | |
112 | | - | |
| 110 | + | |
113 | 111 | | |
114 | 112 | | |
115 | 113 | | |
| |||
145 | 143 | | |
146 | 144 | | |
147 | 145 | | |
148 | | - | |
| 146 | + | |
149 | 147 | | |
150 | 148 | | |
151 | 149 | | |
| |||
162 | 160 | | |
163 | 161 | | |
164 | 162 | | |
165 | | - | |
| 163 | + | |
166 | 164 | | |
167 | 165 | | |
168 | | - | |
169 | | - | |
170 | | - | |
| 166 | + | |
171 | 167 | | |
172 | 168 | | |
173 | 169 | | |
| |||
272 | 268 | | |
273 | 269 | | |
274 | 270 | | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
279 | 277 | | |
280 | 278 | | |
281 | 279 | | |
| |||
321 | 319 | | |
322 | 320 | | |
323 | 321 | | |
324 | | - | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
325 | 327 | | |
326 | 328 | | |
327 | 329 | | |
| |||
375 | 377 | | |
376 | 378 | | |
377 | 379 | | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
382 | 386 | | |
383 | 387 | | |
384 | 388 | | |
| |||
387 | 391 | | |
388 | 392 | | |
389 | 393 | | |
390 | | - | |
| 394 | + | |
391 | 395 | | |
392 | 396 | | |
393 | 397 | | |
394 | 398 | | |
395 | 399 | | |
396 | 400 | | |
397 | 401 | | |
398 | | - | |
| 402 | + | |
399 | 403 | | |
400 | 404 | | |
401 | | - | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
402 | 408 | | |
403 | 409 | | |
404 | 410 | | |
405 | 411 | | |
406 | 412 | | |
407 | | - | |
408 | | - | |
409 | | - | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
410 | 421 | | |
411 | 422 | | |
412 | 423 | | |
413 | | - | |
| 424 | + | |
414 | 425 | | |
415 | 426 | | |
416 | 427 | | |
| |||
421 | 432 | | |
422 | 433 | | |
423 | 434 | | |
424 | | - | |
| 435 | + | |
425 | 436 | | |
426 | 437 | | |
427 | 438 | | |
| |||
436 | 447 | | |
437 | 448 | | |
438 | 449 | | |
439 | | - | |
| 450 | + | |
440 | 451 | | |
441 | 452 | | |
442 | 453 | | |
443 | | - | |
444 | | - | |
445 | 454 | | |
446 | 455 | | |
447 | 456 | | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
448 | 466 | | |
449 | 467 | | |
450 | 468 | | |
451 | 469 | | |
452 | 470 | | |
453 | 471 | | |
454 | 472 | | |
455 | | - | |
| 473 | + | |
456 | 474 | | |
457 | 475 | | |
458 | 476 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
10 | 15 | | |
11 | 16 | | |
12 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
Lines changed: 23 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
2 | 9 | | |
3 | 10 | | |
4 | 11 | | |
5 | 12 | | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
| |||
301 | 304 | | |
302 | 305 | | |
303 | 306 | | |
304 | | - | |
| 307 | + | |
305 | 308 | | |
306 | 309 | | |
307 | 310 | | |
| |||
362 | 365 | | |
363 | 366 | | |
364 | 367 | | |
365 | | - | |
366 | | - | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
367 | 371 | | |
368 | 372 | | |
369 | 373 | | |
| |||
389 | 393 | | |
390 | 394 | | |
391 | 395 | | |
392 | | - | |
| 396 | + | |
393 | 397 | | |
394 | 398 | | |
395 | 399 | | |
| |||
402 | 406 | | |
403 | 407 | | |
404 | 408 | | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
409 | 415 | | |
| 416 | + | |
410 | 417 | | |
411 | | - | |
| 418 | + | |
| 419 | + | |
412 | 420 | | |
| 421 | + | |
413 | 422 | | |
414 | 423 | | |
415 | 424 | | |
| |||
0 commit comments