MetaMask / MetaMask/metamask-extension
[P2] util.js: relocate numeric + typed-data helpers to existing homes
- 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:** S
---
## Problem
Low-fan-out helpers that already have subject-owning homes: `sanitizeMessage` (typed-data), `numericBalance`/`formatBalance`/`hexToText` (hex↔value), `bnGreaterThan`/`roundToDecimalPlacesRemovingExtraZeroes` (numeric).
## Solution
- `sanitizeMessage` → `shared/lib/typed-signature.ts` (evaluate collapsing into the newer `sanitizeMessageRecursively`).
- `numericBalance`/`formatBalance` → `shared/lib/conversion.utils.ts`; `hexToText` → `shared/lib/hexstring-utils.ts`.
- `bnGreaterThan`/`roundToDecimalPlacesRemovingExtraZeroes` → `ui/helpers/utils/number-utils.ts`.
Move tests with them; rewire the ≤1–3 import sites each.
## Acceptance Criteria
- [ ] Helpers relocated to the named modules; originals deleted; imports rewired.
- [ ] `sanitizeMessage`/`sanitizeMessageRecursively` reconciled or co-located. Tests green.
Contributor guide
Research direction
Start in ui/helpers/utils/util.js and inspect the named destination modules: shared/lib/typed-signature.ts, shared/lib/conversion.utils.ts, shared/lib/hexstring-utils.ts, and ui/helpers/utils/number-utils.ts. Move the helpers and their tests, rewire the limited import sites, and run the affected tests. Done means the originals are deleted, sanitizeMessage is reconciled or co-located, and tests are green.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100