Commit 680b813
authored
fix: update start index for proposed account name for pk/hardware imports (#6677)
## Explanation
Currently, PK/Hardware imports were being started at `Account 2` as
opposed to `Account 1`. When we apply group metadata we already have
that group in state, the logic in `#applyGroupMetadata` doesn't account
for the fact that the group we're applying metadata shouldn't be counted
for in the following line:
https://github.com/MetaMask/core/blob/main/packages/account-tree-controller/src/AccountTreeController.ts#L461.
Due to the way we apply group metadata (after we've added the groups
into state), we need to take the min between `proposedNameIndex` and
`highestAccountNameIndex` NOT the max. This change in logic accounts for
group metadata being applied in the scenario when the controller is
being rehydrated through `init` and when a new pk/hardware account is
added in an active session (and handled through `accountAdded`).
## Before
https://github.com/user-attachments/assets/8ab1b3c6-574f-45bc-bf3a-3a3de7b45836
## After
https://github.com/user-attachments/assets/66e53362-e587-45d3-b7ae-43e09da17a09
## 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 changes1 parent b1a43cf commit 680b813
File tree
3 files changed
+16
-11
lines changed- packages/account-tree-controller
- src
3 files changed
+16
-11
lines changed| 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 | | |
| |||
Lines changed: 9 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
587 | 587 | | |
588 | 588 | | |
589 | 589 | | |
590 | | - | |
| 590 | + | |
591 | 591 | | |
592 | 592 | | |
593 | 593 | | |
| |||
610 | 610 | | |
611 | 611 | | |
612 | 612 | | |
613 | | - | |
| 613 | + | |
614 | 614 | | |
615 | 615 | | |
616 | 616 | | |
| |||
652 | 652 | | |
653 | 653 | | |
654 | 654 | | |
655 | | - | |
| 655 | + | |
656 | 656 | | |
657 | 657 | | |
658 | 658 | | |
659 | 659 | | |
660 | 660 | | |
661 | | - | |
| 661 | + | |
662 | 662 | | |
663 | 663 | | |
664 | 664 | | |
| |||
2430 | 2430 | | |
2431 | 2431 | | |
2432 | 2432 | | |
2433 | | - | |
2434 | | - | |
| 2433 | + | |
| 2434 | + | |
2435 | 2435 | | |
2436 | 2436 | | |
2437 | 2437 | | |
| |||
2902 | 2902 | | |
2903 | 2903 | | |
2904 | 2904 | | |
2905 | | - | |
2906 | | - | |
2907 | | - | |
| 2905 | + | |
| 2906 | + | |
| 2907 | + | |
2908 | 2908 | | |
2909 | 2909 | | |
2910 | 2910 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
458 | 458 | | |
459 | 459 | | |
460 | 460 | | |
461 | | - | |
| 461 | + | |
462 | 462 | | |
463 | 463 | | |
464 | 464 | | |
465 | | - | |
| 465 | + | |
466 | 466 | | |
467 | 467 | | |
468 | 468 | | |
| |||
0 commit comments