You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## **Description**
Improve readability and performance
Spreading the accumulator can generally be
[slower](https://www.richsnapp.com/article/2019/06-09-reduce-spread-anti-pattern)
than a simple for loop, not to mention less readable
[](https://codespaces.new/MetaMask/metamask-extension/pull/37435?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: null
## **Related issues**
Fixes:
## **Manual testing steps**
1. Go to this page...
2.
3.
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<!-- [screenshots/recordings] -->
### **After**
<!-- [screenshots/recordings] -->
## **Pre-merge author checklist**
- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [ ] 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]
> Refactors multiple reducers using spread into explicit
loops/Object.assign for building maps, arrays, and initial state across
controllers, selectors, UI, tests, and constants.
>
> - **Core/Controllers**
> - `app/scripts/constants/sentry-state.ts`: Replace `reduce` + spread
with loop and `Object.assign` to build `flattenedBackgroundStateMask`.
> -
`app/scripts/controller-init/assets/network-enablement-controller-init.ts`:
Build `allEnabledNetworks` via loop and `Object.assign`.
> - `app/scripts/controllers/metametrics-controller.ts`: Rework
`#buildValidTraits` to use `for...of` accumulation; preserve validation
and return shape.
> - `app/scripts/lib/ComposableObservableStore.js`: Use `Object.assign`
when merging child states in `getFlatState`.
> - **Shared/Constants**
> - `shared/constants/tokens.js`: Build `STATIC_MAINNET_TOKEN_LIST` via
loop; switch to named export after declaration.
> - **Selectors**
> - `shared/modules/selectors/networks.ts`: Build `clientIdsByChain` via
loop; in `getNetworksByScopes`, use `concat` instead of array spread.
> - `ui/selectors/multichain/networks.ts`: Construct EVM multichain
config map via loop.
> - `ui/selectors/selectors.js`: Mutate accumulator object in accounts
reduce instead of returning new object each iteration.
> - **UI Components**
> - `ui/components/app/contact-list/contact-list.component.js`: Group
contacts by letter using explicit loops and pre-allocated buckets.
> - `ui/components/multichain/.../asset-picker-modal-network.tsx`:
Initialize and update `checkedChainIds` via loops; rework "select all"
toggle to build a new map.
> - **Tests**
> - `test/e2e/fixture-builder.js`: Build `optionalScopes` for multichain
test dapp using a loop.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
41a2b7f. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
0 commit comments