Commit a6f4d69
authored
fix: remove whole redux state pass through for bridge selectors (#33529)
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until this PR meets the canonical
Definition of Ready For Review in `docs/readme/ready-for-review.md`.
In short: the template must be materially complete (not just section
titles
present), all status checks must be currently passing, and the only
expected
follow-up commits must be reviewer-driven.
-->
<!--
mms-check directive vocabulary — read by
.github/scripts/shared/pr-template-checks.ts
at module load to build the validation plan. Directives are invisible in
rendered
markdown and must NOT be removed or edited without updating the
validator registry.
type=text Section must contain non-placeholder prose.
type=changelog Section must have a valid CHANGELOG entry: line.
type=issue-link Section must have a Fixes:/Closes:/Refs: line with a
value.
type=manual-testing Section must have real testing steps or an explicit
N/A.
type=screenshot Section must have evidence (image/URL) or an explicit
N/A.
type=checklist Section must have all checkboxes consciously checked.
required=true|false Whether a missing/invalid section runs the validator
at all.
blocking=true|false Whether a failure of this check fails the CI
workflow.
Default: false — failures are shown as warnings in the sticky
comment but do not block the PR.
Sections without a directive are checked for structural presence only.
-->
## **Description**
<!-- mms-check: type=text required=true -->
<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->
This PR removes whole Redux-state passthrough inputs from three Bridge
account selectors. The selectors now compose granular token and account
inputs, preventing result recomputation on unrelated dispatches while
preserving selected account-group lookup, destination scope matching,
and the existing `Set<AccountId>` API.
It also adds EVM and non-EVM value coverage plus recomputation and
reference-stability tests.
## **Changelog**
<!-- mms-check: type=changelog required=true blocking=true -->
<!--
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: null
## **Related issues**
<!-- mms-check: type=issue-link required=true -->
Fixes: #31269
## **Manual testing steps**
<!-- mms-check: type=manual-testing required=true -->
N/A — this is an internal selector memoization change with no UI
behavior change.
Automated verification: run `yarn jest app/selectors/bridge.test.ts` and
confirm all 24 tests pass, including the unrelated-state recomputation
and stable Set-reference cases.
## **Screenshots/Recordings**
<!-- mms-check: type=screenshot required=true -->
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<!-- [screenshots/recordings] -->
N/A — no UI changes.
### **After**
<!-- [screenshots/recordings] -->
N/A — no UI changes.
## **Pre-merge author checklist**
<!-- mms-check: type=checklist required=true -->
<!--
Every checklist item must be consciously assessed before marking this PR
as
"Ready for review". A checked box means you deliberately considered that
responsibility, not that you literally performed every action listed.
Unchecked boxes are ambiguous: they are not an implicit "N/A" and they
are not
a silent "skip". See `docs/readme/ready-for-review.md` for the full
checklist
semantics.
-->
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
#### Performance checks (if applicable)
- [ ] I've tested on Android
- Ideally on a mid-range device; emulator is acceptable
- [ ] I've tested with a power user scenario
- Use these [power-user
SRPs](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/edit-v2/401401446401?draftShareId=9d77e1e1-4bdc-4be1-9ebb-ccd916988d93)
to import wallets with many accounts and tokens
- [ ] I've instrumented key operations with Sentry traces for production
performance metrics
- See [`trace()`](/app/util/trace.ts) for usage and
[`addToken`](/app/components/Views/AddAsset/components/AddCustomToken/AddCustomToken.tsx#L274)
for an example
For performance guidelines and tooling, see the [Performance
Guide](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/400085549067/Performance+Guide+for+Engineers).
## **Pre-merge reviewer checklist**
<!--
Reviewer checklist items follow the same semantics as the author
checklist: an
unchecked box is ambiguous, a checked box means the reviewer consciously
assessed that responsibility. See `docs/readme/ready-for-review.md`.
-->
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Destination account eligibility logic was rewritten (different data
source and `anyScopesMatch` vs per-scope queries); behavior should match
but account picking for bridge is user-facing if wrong.
>
> **Overview**
> **Refactors three Bridge account selectors** so they no longer depend
on the entire `RootState`, which was forcing recomputation on every
unrelated dispatch.
>
> `selectSourceWalletAddress` and `selectBatchSellSourceWalletAddress`
now compose `selectSourceToken` / `selectBatchSellSourceTokens` with
`selectSelectedInternalAccountByScope` instead of calling scope lookup
inside a `(state) => state` input.
**`selectValidDestInternalAccountIds`** drops `createDeepEqualSelector`
and `selectInternalAccountsByScope` in favor of
`selectInternalAccountsById` plus `anyScopesMatch` for destination scope
and EVM wildcard (`eip155:0`) filtering, while still returning a
`Set<AccountId>`.
>
> **Tests** add shared bridge selector mock state, EVM/Solana coverage,
and assertions that unrelated bridge fields (e.g. `sourceAmount`) do not
trigger recomputation or new `Set` references until the relevant token
changes.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
f604031. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent b0c757a commit a6f4d69
2 files changed
Lines changed: 255 additions & 37 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
| 12 | + | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
15 | 27 | | |
16 | 28 | | |
17 | 29 | | |
| |||
35 | 47 | | |
36 | 48 | | |
37 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
38 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 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 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
39 | 262 | | |
40 | 263 | | |
41 | 264 | | |
| |||
45 | 268 | | |
46 | 269 | | |
47 | 270 | | |
48 | | - | |
| 271 | + | |
49 | 272 | | |
50 | 273 | | |
51 | 274 | | |
| |||
54 | 277 | | |
55 | 278 | | |
56 | 279 | | |
57 | | - | |
| 280 | + | |
58 | 281 | | |
59 | 282 | | |
60 | 283 | | |
| |||
68 | 291 | | |
69 | 292 | | |
70 | 293 | | |
71 | | - | |
| 294 | + | |
72 | 295 | | |
73 | 296 | | |
74 | 297 | | |
| |||
90 | 313 | | |
91 | 314 | | |
92 | 315 | | |
93 | | - | |
| 316 | + | |
94 | 317 | | |
95 | 318 | | |
96 | 319 | | |
| |||
104 | 327 | | |
105 | 328 | | |
106 | 329 | | |
107 | | - | |
| 330 | + | |
108 | 331 | | |
109 | 332 | | |
110 | 333 | | |
| |||
120 | 343 | | |
121 | 344 | | |
122 | 345 | | |
123 | | - | |
| 346 | + | |
124 | 347 | | |
125 | 348 | | |
126 | 349 | | |
| |||
136 | 359 | | |
137 | 360 | | |
138 | 361 | | |
139 | | - | |
| 362 | + | |
140 | 363 | | |
141 | 364 | | |
142 | 365 | | |
| |||
156 | 379 | | |
157 | 380 | | |
158 | 381 | | |
159 | | - | |
| 382 | + | |
160 | 383 | | |
161 | 384 | | |
162 | 385 | | |
| |||
176 | 399 | | |
177 | 400 | | |
178 | 401 | | |
179 | | - | |
| 402 | + | |
180 | 403 | | |
181 | 404 | | |
182 | 405 | | |
| |||
196 | 419 | | |
197 | 420 | | |
198 | 421 | | |
199 | | - | |
| 422 | + | |
200 | 423 | | |
201 | 424 | | |
202 | 425 | | |
| |||
217 | 440 | | |
218 | 441 | | |
219 | 442 | | |
220 | | - | |
| 443 | + | |
221 | 444 | | |
222 | 445 | | |
223 | 446 | | |
| |||
237 | 460 | | |
238 | 461 | | |
239 | 462 | | |
240 | | - | |
| 463 | + | |
241 | 464 | | |
242 | 465 | | |
243 | 466 | | |
| |||
256 | 479 | | |
257 | 480 | | |
258 | 481 | | |
259 | | - | |
| 482 | + | |
260 | 483 | | |
261 | 484 | | |
262 | 485 | | |
| |||
0 commit comments