MetaMask / MetaMask/metamask-extension
[P1] util.js: relocate address-display helpers to a new address module
- Dominant language
- TypeScript
- Stars
- 13.2k
- Forks
- 5.6k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 451
Description
**Parent Epic:** [#44552 — `util.js` decomposition](https://github.com/MetaMask/metamask-extension/issues/44552)
**Source:** `ui/helpers/utils/util.js`
**Size:** XL
---
## Problem
`shortenAddress` (fan-out ~50 — the single largest relocation in the epic) and `checkExistingAddresses`. `shortenAddress` is a thin wrapper over `shortenString`.
## Solution
Create `ui/helpers/utils/address.ts` and move both there (or fold `shortenAddress` into `shared/lib/string-utils.ts` next to `shortenString`). Depends on the string-helpers ticket landing first. Rewrite the ~50 import sites with a `jscodeshift`/`ts-morph` codemod that also handles the 3 namespace-import test files (`import * as util`).
## Acceptance Criteria
- [ ] `shortenAddress`/`checkExistingAddresses` relocated; originals deleted; ~50 sites codemod-rewired incl. the 3 namespace-import tests; no behavior change. Tests green.
Contributor guide
Research direction
Start with ui/helpers/utils/util.js and the dependent string-helpers ticket, then inventory the roughly 50 import sites and the three namespace-import test files. Use the issue's codemod approach to relocate shortenAddress and checkExistingAddresses into ui/helpers/utils/address.ts or the specified shared string utility. Done means the originals are removed, imports are rewired without behavior changes, and all tests are green.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend, tooling
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100