Commit 096b7ee
authored
feat:add
Plus minor refactor to permission map generation.
## Explanation
We recently added `erc20-token-revocation` to the permission granting
flow. This change adds the type to the permission controller state, so
that these permissions become differentiated in the All Permission
section (rather than relegated to "other").
Also includes a minor refactor of parsing a list of stored permissions
into a multi-dimensional map keyed by `permissionType | chainId`, which
previously required changes to this function for every new type added.
Now simply adding the permission type to the
`createEmptyGatorPermissionsMap` function will be required for new
permissions.
## 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/contributing.md#updating-changelogs)
- [ ] I've introduced [breaking
changes](https://github.com/MetaMask/core/tree/main/docs/breaking-changes.md)
in this PR and have prepared draft pull requests for clients and
consumer packages to resolve them
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Adds a dedicated `erc20-token-revocation` bucket to controller state
and refactors permission categorization to be extensible via a
centralized empty-map factory.
>
> - **gator-permissions-controller**
> - **State/Defaults**: Introduce `createEmptyGatorPermissionsMap()` and
include `erc20-token-revocation` in default/cleared state; update
getters/disable flow to use new factory.
> - **Logic**: Rewrite `#categorizePermissionsDataByTypeAndChainId` to
dynamically bucket by known permission types (fallback to `other`)
instead of switch-case.
> - **Types**: Extend `GatorPermissionsMap` to include
`erc20-token-revocation` (imports `Erc20TokenRevocationPermission`).
> - **Tests**: Update expectations for default/empty maps; add test
ensuring `erc20-token-revocation` is categorized separately; preserve
sanitization checks; tweak utils serialization-failure test.
> - **Changelog**: Note differentiation of `erc20-token-revocation` from
`other`.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
e4e996d. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->erc20-token-revocation permission to controller state (#7318)1 parent 2b2cf96 commit 096b7ee
File tree
5 files changed
+107
-69
lines changed- packages/gator-permissions-controller
- src
5 files changed
+107
-69
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
Lines changed: 51 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
| |||
171 | 172 | | |
172 | 173 | | |
173 | 174 | | |
| 175 | + | |
174 | 176 | | |
175 | 177 | | |
176 | 178 | | |
| |||
222 | 224 | | |
223 | 225 | | |
224 | 226 | | |
| 227 | + | |
225 | 228 | | |
226 | 229 | | |
227 | 230 | | |
| |||
257 | 260 | | |
258 | 261 | | |
259 | 262 | | |
| 263 | + | |
260 | 264 | | |
261 | 265 | | |
262 | 266 | | |
| |||
278 | 282 | | |
279 | 283 | | |
280 | 284 | | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
281 | 326 | | |
282 | 327 | | |
283 | 328 | | |
| |||
304 | 349 | | |
305 | 350 | | |
306 | 351 | | |
| 352 | + | |
307 | 353 | | |
308 | 354 | | |
309 | 355 | | |
| |||
326 | 372 | | |
327 | 373 | | |
328 | 374 | | |
| 375 | + | |
329 | 376 | | |
330 | 377 | | |
331 | 378 | | |
| |||
390 | 437 | | |
391 | 438 | | |
392 | 439 | | |
| 440 | + | |
393 | 441 | | |
394 | 442 | | |
395 | 443 | | |
| |||
501 | 549 | | |
502 | 550 | | |
503 | 551 | | |
504 | | - | |
| 552 | + | |
505 | 553 | | |
506 | 554 | | |
507 | 555 | | |
| |||
523 | 571 | | |
524 | 572 | | |
525 | 573 | | |
526 | | - | |
| 574 | + | |
527 | 575 | | |
528 | 576 | | |
529 | 577 | | |
| |||
542 | 590 | | |
543 | 591 | | |
544 | 592 | | |
545 | | - | |
| 593 | + | |
546 | 594 | | |
547 | 595 | | |
548 | 596 | | |
| |||
Lines changed: 41 additions & 62 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
67 | 70 | | |
68 | 71 | | |
69 | 72 | | |
| |||
157 | 160 | | |
158 | 161 | | |
159 | 162 | | |
160 | | - | |
| 163 | + | |
161 | 164 | | |
162 | 165 | | |
163 | 166 | | |
| |||
509 | 512 | | |
510 | 513 | | |
511 | 514 | | |
| 515 | + | |
| 516 | + | |
512 | 517 | | |
513 | | - | |
| 518 | + | |
514 | 519 | | |
515 | 520 | | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | | - | |
520 | | - | |
521 | | - | |
522 | | - | |
523 | | - | |
524 | | - | |
525 | | - | |
526 | | - | |
527 | | - | |
528 | | - | |
529 | | - | |
530 | | - | |
531 | | - | |
532 | | - | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | | - | |
537 | | - | |
538 | | - | |
539 | | - | |
540 | | - | |
541 | | - | |
542 | | - | |
543 | | - | |
544 | | - | |
545 | | - | |
546 | | - | |
547 | | - | |
548 | | - | |
549 | | - | |
550 | | - | |
551 | | - | |
552 | | - | |
553 | | - | |
554 | | - | |
555 | | - | |
556 | | - | |
557 | | - | |
558 | | - | |
559 | | - | |
560 | | - | |
561 | | - | |
562 | | - | |
563 | | - | |
564 | | - | |
565 | | - | |
566 | | - | |
567 | | - | |
568 | | - | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
569 | 548 | | |
570 | 549 | | |
571 | 550 | | |
| |||
602 | 581 | | |
603 | 582 | | |
604 | 583 | | |
605 | | - | |
| 584 | + | |
606 | 585 | | |
607 | 586 | | |
608 | 587 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
174 | 175 | | |
175 | 176 | | |
176 | 177 | | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
177 | 184 | | |
178 | 185 | | |
179 | 186 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | | - | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
36 | | - | |
37 | | - | |
38 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
39 | 42 | | |
40 | 43 | | |
41 | 44 | | |
| |||
0 commit comments