Accumulated dead code and copy-paste duplication. None of it is user-visible,
but the duplication is actively dangerous in one respect: three independent
copies of the timestamp formatters mean a fix to one does not reach the others,
and the README Display Consistency policy (README.md:186-195) requires the
same data to be formatted identically everywhere.
Never-called exports:
src/shared/networks.js:47-49 explorerLink() — exported at :56, zero call
sites. Every view hand-builds currentNetwork().explorerUrl + "/..." instead (txStatus.js:40, transactionDetail.js:60, helpers.js:344). Either adopt the helper
everywhere or delete it; do not leave both patterns.
src/shared/prices.js:85-96 getTotalValueUsd() — exported at :104, zero
call sites. getWalletValueUsd (prices.js:74) is used only by it, so it is
transitively dead. Check before deleting: its intended consumer was the
Home "Total USD value across all tokens" line at README.md:283, and home.js:68-72 currently shows only the active address total while
labelling it "Total:". That is arguably a bug — the README promises a
cross-wallet total. Decide whether to wire the function up (fixing the label
or the behaviour) or to delete it and correct the README. State which and
why; if it turns into a behaviour change, split it into its own issue rather
than smuggling it into a cleanup commit.
src/shared/constants.js:6 ETHEREUM_SEPOLIA_CHAIN_ID — exported at :41,
never used; the live value lives at networks.js:22. Duplicate source of
truth.
src/popup/views/helpers.js:447 addressColor and :455 etherscanAddressUrl
are exported but used only inside helpers.js. Unexport them.
Triplicated formatters:
isoDate() and timeAgo() exist three times with identical bodies: helpers.js:279-333 (the exported pair), addressDetail.js:84-138, and addressToken.js:41-98. Worse, addressDetail.js and addressToken.js shadow the imported helpers with their local copies — so the exported
versions are silently not what those two views use.
Duplicated small helpers:
formatTxValue — approval.js:28-33 and transactions.js:13-18
blockieHtml — confirmTx.js:48-51 and transactionDetail.js:46-49
tokenLabel — approval.js:35-38 and txStatus.js:108-111
Implementation requirements
Collapse each duplicated function to a single shared definition and import it
at every use site. For isoDate/timeAgo the canonical home is helpers.js; delete the shadowing local copies in addressDetail.js and addressToken.js.
Before deleting a shadowed copy, diff it against the canonical version.
The bodies are reported as identical, but confirm it — if they have drifted,
the behaviour change is the point and must be called out, especially for
anything touching the timezone/UTC display setting.
Do not use scripted search-and-replace. Edit the files directly.
Unused imports are handled by the ESLint issue (#152); this issue is about
unused definitions and exports. Coordinate so the two don't collide — if #152 has landed, the linter should already be green and stay green here.
Purely mechanical. No behaviour change except where explicitly decided for getTotalValueUsd, and that decision must be recorded.
Definition of done
Exactly one definition each of isoDate, timeAgo, formatTxValue, blockieHtml, and tokenLabel remains in the tree.
No view shadows an imported helper with a local copy.
explorerLink is either adopted at all three hand-built call sites or
removed.
ETHEREUM_SEPOLIA_CHAIN_ID duplication is resolved to a single source of
truth.
addressColor and etherscanAddressUrl are no longer exported.
The getTotalValueUsd decision is recorded, and if it is a behaviour
change it has been split into its own issue.
Timestamps still render identically to before on AddressDetail,
AddressToken, and TransactionDetail, including under the UTC setting.
Confirm by inspection and say so in the PR.
TODO.md updated in the same commit.
make check passes.
## Problem
Accumulated dead code and copy-paste duplication. None of it is user-visible,
but the duplication is actively dangerous in one respect: three independent
copies of the timestamp formatters mean a fix to one does not reach the others,
and the README Display Consistency policy (`README.md:186-195`) requires the
same data to be formatted identically everywhere.
**Never-called exports:**
- `src/shared/networks.js:47-49 explorerLink()` — exported at `:56`, zero call
sites. Every view hand-builds
`currentNetwork().explorerUrl + "/..."` instead (`txStatus.js:40`,
`transactionDetail.js:60`, `helpers.js:344`). Either adopt the helper
everywhere or delete it; do not leave both patterns.
- `src/shared/prices.js:85-96 getTotalValueUsd()` — exported at `:104`, zero
call sites. `getWalletValueUsd` (`prices.js:74`) is used only by it, so it is
transitively dead. **Check before deleting:** its intended consumer was the
Home "Total USD value across all tokens" line at `README.md:283`, and
`home.js:68-72` currently shows only the *active address* total while
labelling it "Total:". That is arguably a bug — the README promises a
cross-wallet total. Decide whether to wire the function up (fixing the label
or the behaviour) or to delete it and correct the README. State which and
why; if it turns into a behaviour change, split it into its own issue rather
than smuggling it into a cleanup commit.
- `src/shared/constants.js:6 ETHEREUM_SEPOLIA_CHAIN_ID` — exported at `:41`,
never used; the live value lives at `networks.js:22`. Duplicate source of
truth.
- `src/popup/views/helpers.js:447 addressColor` and `:455 etherscanAddressUrl`
are exported but used only inside `helpers.js`. Unexport them.
**Triplicated formatters:**
- `isoDate()` and `timeAgo()` exist three times with identical bodies:
`helpers.js:279-333` (the exported pair), `addressDetail.js:84-138`, and
`addressToken.js:41-98`. Worse, `addressDetail.js` and `addressToken.js`
**shadow the imported helpers with their local copies** — so the exported
versions are silently not what those two views use.
**Duplicated small helpers:**
- `formatTxValue` — `approval.js:28-33` and `transactions.js:13-18`
- `blockieHtml` — `confirmTx.js:48-51` and `transactionDetail.js:46-49`
- `tokenLabel` — `approval.js:35-38` and `txStatus.js:108-111`
## Implementation requirements
- Collapse each duplicated function to a single shared definition and import it
at every use site. For `isoDate`/`timeAgo` the canonical home is
`helpers.js`; delete the shadowing local copies in `addressDetail.js` and
`addressToken.js`.
- **Before deleting a shadowed copy, diff it against the canonical version.**
The bodies are reported as identical, but confirm it — if they have drifted,
the behaviour change is the point and must be called out, especially for
anything touching the timezone/UTC display setting.
- Do not use scripted search-and-replace. Edit the files directly.
- Unused *imports* are handled by the ESLint issue (#152); this issue is about
unused *definitions and exports*. Coordinate so the two don't collide — if
#152 has landed, the linter should already be green and stay green here.
- Purely mechanical. No behaviour change except where explicitly decided for
`getTotalValueUsd`, and that decision must be recorded.
## Definition of done
- [ ] Exactly one definition each of `isoDate`, `timeAgo`, `formatTxValue`,
`blockieHtml`, and `tokenLabel` remains in the tree.
- [ ] No view shadows an imported helper with a local copy.
- [ ] `explorerLink` is either adopted at all three hand-built call sites or
removed.
- [ ] `ETHEREUM_SEPOLIA_CHAIN_ID` duplication is resolved to a single source of
truth.
- [ ] `addressColor` and `etherscanAddressUrl` are no longer exported.
- [ ] The `getTotalValueUsd` decision is recorded, and if it is a behaviour
change it has been split into its own issue.
- [ ] Timestamps still render identically to before on AddressDetail,
AddressToken, and TransactionDetail, including under the UTC setting.
Confirm by inspection and say so in the PR.
- [ ] `TODO.md` updated in the same commit.
- [ ] `make check` passes.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Problem
Accumulated dead code and copy-paste duplication. None of it is user-visible,
but the duplication is actively dangerous in one respect: three independent
copies of the timestamp formatters mean a fix to one does not reach the others,
and the README Display Consistency policy (
README.md:186-195) requires thesame data to be formatted identically everywhere.
Never-called exports:
src/shared/networks.js:47-49 explorerLink()— exported at:56, zero callsites. Every view hand-builds
currentNetwork().explorerUrl + "/..."instead (txStatus.js:40,transactionDetail.js:60,helpers.js:344). Either adopt the helpereverywhere or delete it; do not leave both patterns.
src/shared/prices.js:85-96 getTotalValueUsd()— exported at:104, zerocall sites.
getWalletValueUsd(prices.js:74) is used only by it, so it istransitively dead. Check before deleting: its intended consumer was the
Home "Total USD value across all tokens" line at
README.md:283, andhome.js:68-72currently shows only the active address total whilelabelling it "Total:". That is arguably a bug — the README promises a
cross-wallet total. Decide whether to wire the function up (fixing the label
or the behaviour) or to delete it and correct the README. State which and
why; if it turns into a behaviour change, split it into its own issue rather
than smuggling it into a cleanup commit.
src/shared/constants.js:6 ETHEREUM_SEPOLIA_CHAIN_ID— exported at:41,never used; the live value lives at
networks.js:22. Duplicate source oftruth.
src/popup/views/helpers.js:447 addressColorand:455 etherscanAddressUrlare exported but used only inside
helpers.js. Unexport them.Triplicated formatters:
isoDate()andtimeAgo()exist three times with identical bodies:helpers.js:279-333(the exported pair),addressDetail.js:84-138, andaddressToken.js:41-98. Worse,addressDetail.jsandaddressToken.jsshadow the imported helpers with their local copies — so the exported
versions are silently not what those two views use.
Duplicated small helpers:
formatTxValue—approval.js:28-33andtransactions.js:13-18blockieHtml—confirmTx.js:48-51andtransactionDetail.js:46-49tokenLabel—approval.js:35-38andtxStatus.js:108-111Implementation requirements
at every use site. For
isoDate/timeAgothe canonical home ishelpers.js; delete the shadowing local copies inaddressDetail.jsandaddressToken.js.The bodies are reported as identical, but confirm it — if they have drifted,
the behaviour change is the point and must be called out, especially for
anything touching the timezone/UTC display setting.
unused definitions and exports. Coordinate so the two don't collide — if
#152 has landed, the linter should already be green and stay green here.
getTotalValueUsd, and that decision must be recorded.Definition of done
isoDate,timeAgo,formatTxValue,blockieHtml, andtokenLabelremains in the tree.explorerLinkis either adopted at all three hand-built call sites orremoved.
ETHEREUM_SEPOLIA_CHAIN_IDduplication is resolved to a single source oftruth.
addressColorandetherscanAddressUrlare no longer exported.getTotalValueUsddecision is recorded, and if it is a behaviourchange it has been split into its own issue.
AddressToken, and TransactionDetail, including under the UTC setting.
Confirm by inspection and say so in the PR.
TODO.mdupdated in the same commit.make checkpasses.