MetaMask / MetaMask/metamask-extension

[P2] util.js: relocate string helpers to string-utils

Open
#44,559 0 comments 0 reactions 0 assignees View on GitHub
for-migration 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:** M

---

## Problem

`shortenString` (fan-out ~11), `sanitizeString` (bidi/invisible-char escaping — security-relevant), `getAvatarFallbackLetter`. `shortenString` is the base that `shortenAddress` builds on.

## Solution

Move all three to `shared/lib/string-utils.ts`. **Do this before the address-display ticket** so `shortenAddress` can re-import `shortenString` from its new home. Codemod the ~11 `shortenString` import sites.

## Acceptance Criteria

- [ ] Three helpers in `string-utils.ts`; originals deleted; imports rewired. Sequenced before the address ticket. Tests green.

Contributor guide

Open the contributing guide

Research direction

Start in ui/helpers/utils/util.js and inspect the three named helpers, then review shared/lib/string-utils.ts and the roughly 11 shortenString import sites. Rewire the imports and confirm the originals are removed; done means all three helpers are in the new file, address-display work can import shortenString there, and tests are green.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.