Commit a3c1ac2
authored
fix: Prevent crash in modal version handling cp-13.11.1 (#38382)
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->
## **Description**
Fixes a crash caused by `useMultichainAccountsIntroModal` that entirely
bricks Flask. The crash occurs because the version handling doesn't
handle our versioning scheme well. This PR changes the logic to use
`previousAppVersion` and strips the `prerelease` part of the version
(which indicates the build type) for a proper comparison.
Also updates the tests for this hook which were flawed as they didn't
use the hook in question at all.
[](https://codespaces.new/MetaMask/metamask-extension/pull/38382?quickstart=1)
## **Changelog**
<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`
If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`
(This helps the Release Engineer do their job more quickly and
accurately)
-->
CHANGELOG entry: Fixes a crash when updating Flask
## **Manual testing steps**
1. Force `lastUpdatedFromVersion` to `13.9.0.150` and
`previousAppVersion` to `13.9.0-flask.0`
2. See that it crashes without this PR
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<img width="454" height="634" alt="image"
src="https://github.com/user-attachments/assets/ea140cfa-66ef-402e-a6cd-3ca3a2bc6402"
/>
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Use `previousAppVersion` and strip prerelease parts for version
comparison in `useMultichainAccountsIntroModal`; update tests to
exercise the hook with provider-backed state.
>
> - **Hooks** (`ui/hooks/useMultichainAccountsIntroModal.ts`):
> - Use `previousAppVersion` instead of `lastUpdatedFromVersion` for
upgrade checks.
> - Parse and strip prerelease identifiers via `semver.parse` before
comparing with `BIP44_ACCOUNTS_INTRODUCTION_VERSION` using `semver.lt`.
> - Export `BIP44_ACCOUNTS_INTRODUCTION_VERSION` for external use.
> - Maintain display gating by `DEFAULT_ROUTE` and existing state flags;
compute and set `showMultichainIntroModal` accordingly.
> - **Tests** (`ui/hooks/useMultichainAccountsIntroModal.test.ts`):
> - Replace ad-hoc logic with `renderHookWithProvider` to test the
actual hook.
> - Cover upgrades across thresholds including prerelease versions
(e.g., `*-flask.0`) and ensure correct show/hide behavior across routes
and states.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
9d7267f. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent c87f69b commit a3c1ac2
File tree
2 files changed
+92
-73
lines changed- ui/hooks
2 files changed
+92
-73
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
2 | 6 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
| 7 | + | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | | - | |
14 | | - | |
| 13 | + | |
| 14 | + | |
15 | 15 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
29 | 32 | | |
30 | 33 | | |
31 | 34 | | |
| |||
39 | 42 | | |
40 | 43 | | |
41 | 44 | | |
42 | | - | |
| 45 | + | |
43 | 46 | | |
44 | 47 | | |
45 | 48 | | |
46 | 49 | | |
47 | 50 | | |
48 | | - | |
| 51 | + | |
49 | 52 | | |
50 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
51 | 66 | | |
52 | 67 | | |
53 | 68 | | |
54 | | - | |
| 69 | + | |
55 | 70 | | |
56 | 71 | | |
57 | 72 | | |
58 | 73 | | |
59 | 74 | | |
60 | | - | |
| 75 | + | |
61 | 76 | | |
62 | | - | |
| 77 | + | |
63 | 78 | | |
64 | 79 | | |
65 | 80 | | |
66 | | - | |
| 81 | + | |
67 | 82 | | |
68 | 83 | | |
69 | 84 | | |
70 | 85 | | |
71 | 86 | | |
72 | | - | |
| 87 | + | |
73 | 88 | | |
74 | | - | |
| 89 | + | |
75 | 90 | | |
76 | 91 | | |
77 | 92 | | |
78 | 93 | | |
79 | 94 | | |
80 | | - | |
| 95 | + | |
81 | 96 | | |
82 | 97 | | |
83 | 98 | | |
84 | 99 | | |
85 | 100 | | |
86 | | - | |
| 101 | + | |
87 | 102 | | |
88 | | - | |
| 103 | + | |
89 | 104 | | |
90 | 105 | | |
91 | | - | |
92 | | - | |
| 106 | + | |
| 107 | + | |
93 | 108 | | |
94 | 109 | | |
95 | 110 | | |
96 | 111 | | |
97 | | - | |
98 | | - | |
| 112 | + | |
| 113 | + | |
99 | 114 | | |
100 | | - | |
| 115 | + | |
101 | 116 | | |
102 | 117 | | |
103 | | - | |
104 | | - | |
| 118 | + | |
| 119 | + | |
105 | 120 | | |
106 | 121 | | |
107 | 122 | | |
108 | 123 | | |
109 | | - | |
110 | | - | |
| 124 | + | |
| 125 | + | |
111 | 126 | | |
112 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
113 | 133 | | |
114 | 134 | | |
115 | 135 | | |
116 | | - | |
| 136 | + | |
117 | 137 | | |
118 | 138 | | |
119 | 139 | | |
120 | 140 | | |
121 | 141 | | |
122 | | - | |
| 142 | + | |
123 | 143 | | |
124 | | - | |
| 144 | + | |
125 | 145 | | |
126 | 146 | | |
127 | 147 | | |
128 | | - | |
| 148 | + | |
129 | 149 | | |
130 | 150 | | |
131 | 151 | | |
132 | 152 | | |
133 | 153 | | |
134 | | - | |
| 154 | + | |
135 | 155 | | |
136 | | - | |
| 156 | + | |
137 | 157 | | |
138 | 158 | | |
139 | 159 | | |
140 | | - | |
| 160 | + | |
141 | 161 | | |
142 | 162 | | |
143 | 163 | | |
144 | 164 | | |
145 | 165 | | |
146 | | - | |
| 166 | + | |
147 | 167 | | |
148 | | - | |
| 168 | + | |
149 | 169 | | |
150 | 170 | | |
151 | 171 | | |
152 | | - | |
| 172 | + | |
153 | 173 | | |
154 | 174 | | |
155 | 175 | | |
156 | 176 | | |
157 | 177 | | |
158 | | - | |
| 178 | + | |
159 | 179 | | |
160 | | - | |
| 180 | + | |
161 | 181 | | |
162 | 182 | | |
163 | 183 | | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
| 184 | + | |
| 185 | + | |
173 | 186 | | |
174 | 187 | | |
175 | 188 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
9 | | - | |
| 8 | + | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
| |||
33 | 32 | | |
34 | 33 | | |
35 | 34 | | |
36 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
42 | 49 | | |
43 | 50 | | |
44 | | - | |
45 | | - | |
46 | | - | |
| 51 | + | |
| 52 | + | |
47 | 53 | | |
48 | 54 | | |
49 | 55 | | |
| |||
0 commit comments