Skip to content

refactor: extract explorer helpers + layout into submodules#419

Merged
satyakwok merged 3 commits intomainfrom
refactor/explorer-extract-helpers-layout
Apr 29, 2026
Merged

refactor: extract explorer helpers + layout into submodules#419
satyakwok merged 3 commits intomainfrom
refactor/explorer-extract-helpers-layout

Conversation

@satyakwok
Copy link
Copy Markdown
Member

Summary

Phase 2 of the workspace audit. explorer.rs was a 1428-LOC monolith mixing pure formatters, chrome layout, and per-page handlers. Split:

  • explorer/helpers.rshtml_escape (still pub), truncate, srx, addr_with_label, fmt_ts, fmt_day
  • explorer/layout.rs — CSS, chart-section script, page() wrapper, nav_tabs()
  • explorer.rs — handlers only (home / blocks / transactions / detail pages / lists / mempool / daily stats)

After: explorer.rs 1197 LOC + helpers 77 + layout 176. Same total surface area but the read-from-top experience is way calmer.

No behaviour change — only mechanical extraction. Public re-export of html_escape preserved (shape used elsewhere in the crate).

Test plan

  • cargo check / clippy --workspace --tests -- -D warnings clean
  • cargo test --workspace passes (full suite)

Satya Kwok and others added 3 commits April 29, 2026 01:16
…chain.com

scan.sentrixchain.com remains the primary explorer with full
native-op coverage. Blockscout sidecar adds EVM-standard UX
(ERC-20 holders, source verification, EIP-3091 URLs) for listing
platforms + EVM tooling that expects that shape.
explorer.rs was 1428 LOC mixing:
- HTML-escape + truncate + srx + addr-with-label + fmt-ts + fmt-day
  (pure formatters with no shared state)
- CSS + chart-section script + page wrapper + nav-tabs (chrome layout)
- Per-page handlers (home / blocks / transactions / block / address /
  tx / validators / tokens / richlist / validator / token / mempool +
  stats_daily endpoint)

Move the formatters into explorer/helpers.rs and the chrome into
explorer/layout.rs. explorer.rs drops to 1197 LOC, focused on the
handlers themselves. No behaviour change; cargo clippy + cargo test
both clean.

Phase 2 of the workspace audit (see internal AUDIT_REPORT). Per-handler
splits stay deferred — they'd add new module surface for marginal
readability gain on this round.
@satyakwok satyakwok merged commit 3aa3899 into main Apr 29, 2026
5 checks passed
satyakwok added a commit that referenced this pull request Apr 29, 2026
* docs: dual-explorer note for Blockscout sidecar at blockscout.sentrixchain.com

scan.sentrixchain.com remains the primary explorer with full
native-op coverage. Blockscout sidecar adds EVM-standard UX
(ERC-20 holders, source verification, EIP-3091 URLs) for listing
platforms + EVM tooling that expects that shape.

* chore: humanize the just-extracted submodule headers

The recent batch of refactor PRs (#419 explorer, #420 bft engine, #421
slashing) shipped with header comments that read a bit like a release-
notes generator wrote them — "X.rs — short description. Pulled out
of Y for Z. No behaviour change." That's not the voice the rest of
this codebase carries. Comments here usually tell stories, reference
incidents, drop dates and PR numbers. This pass rewrites the seven
new file headers + the two re-export blocks so they sound like the
operator wrote them late at night, which is closer to the truth.

No code change.

---------

Co-authored-by: Satya Kwok <satyakwik@gmail.com>
Co-authored-by: satyakwok <satyakwok@users.noreply.github.com>
Co-authored-by: Satya Kwok <satyakwik@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant