chore: remove dead exports and de-duplicate copy-pasted view helpers #168
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.