MetaMask / MetaMask/metamask-extension
[P2] util.js: relocate token / contract / price helpers to token-util
- 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
`getContractAtAddress`, `checkTokenIdExists`, `getCalculatedTokenAmount1dAgo`, `fetchTokenExchangeRates` (fan-out ~8) are token-subject helpers.
## Solution
Move to `ui/helpers/utils/token-util.js` (the token subject module; the move also advances its own TS migration). `getContractAtAddress` may instead go to `shared/lib/contract-utils.ts` next to `readAddressAsContract` if a shared home is preferred. Codemod the ~8 `fetchTokenExchangeRates` import sites.
## Acceptance Criteria
- [ ] Helpers relocated; originals deleted; import sites rewired (codemod). Tests green.
Contributor guide
Research direction
Start in ui/helpers/utils/util.js and compare the token-related helpers with ui/helpers/utils/token-util.js. Trace the roughly eight fetchTokenExchangeRates import sites, and consider shared/lib/contract-utils.ts for getContractAtAddress alongside readAddressAsContract. Done means the helpers are relocated, originals deleted, imports rewired, and tests are green.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- blockchain
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100