MetaMask / MetaMask/metamask-extension

[P1] util.js: relocate address-display helpers to a new address module

Open
#44,564 1 comment 0 reactions 0 assignees View on GitHub
exalate-duplicate INVALID-ISSUE-TEMPLATE mig-epic-70-child team-extension-platform
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.