Skip to content

fix(scan): honour ?network= on home + list + leaderboard pages#57

Merged
github-actions[bot] merged 1 commit into
mainfrom
fix/scan-network-deeplink-on-list-pages
May 11, 2026
Merged

fix(scan): honour ?network= on home + list + leaderboard pages#57
github-actions[bot] merged 1 commit into
mainfrom
fix/scan-network-deeplink-on-list-pages

Conversation

@satyakwok
Copy link
Copy Markdown
Member

@satyakwok satyakwok commented May 11, 2026

Summary

Deep audit found 22 client-side pages calling useNetwork() without the matching useNetworkFromQuery() hook. Result: deeplinks like https://scan.sentrixchain.com/blocks?network=testnet (the V1 mainnet host with a network query override) rendered mainnet data because the network cookie never flipped on first load.

Detail pages (blocks/[height], tx/[hash], address/[addr], tokens/[addr]) were correct. Everything else — home, blocks list, validators, tokens list, leaderboard subpages, search, sentinel, accounts, gas, supply, epochs, contracts, mempool, analytics, api-docs, forks — missed the hook.

Why this matters when each network has its own subdomain

Canonical access is via dedicated subdomain, not the query string:

Network V1 (Next.js scan, this PR) V2 (Leptos / Obsidian)
Mainnet scan.sentrixchain.com scan.sentriscloud.com
Testnet scan-testnet.sentrixchain.com scan-testnet.sentriscloud.com

The ?network= query exists as a cross-domain fallback for inbound deeplinks from other apps that aren't network-aware (faucet success page, wallet notifications, partner emails — all places where a single template URL gets reused with a network suffix). Without this fix, those links land on the right domain but the wrong cookie, so the user sees a network mismatch on first paint.

Reproduction (pre-fix, verified live)

GET https://scan.sentrixchain.com/blocks?network=testnet
→ page renders block heights around 1,681,800  (V1 mainnet's actual chain tip)
   instead of around 3,172,785                 (V1 testnet's actual chain tip)

The cookie carried mainnet, the URL hinted testnet, the page rendered with the cookie's network and ignored the URL hint.

Fix

One-line call to useNetworkFromQuery() after each useNetwork() call site, with a consistent comment so future pages follow the pattern:

const { network } = useNetwork();
// Deeplink network switch.
useNetworkFromQuery();

22 files modified, all in apps/scan/app/[locale]/.

Verification

  • pnpm --filter @sentriscloud/scan typecheck clean
  • After deploy: https://scan.sentrixchain.com/blocks?network=testnet shows testnet block heights (~3.17M), not mainnet.
  • The dedicated https://scan-testnet.sentrixchain.com/... flow is unchanged — that path was never broken.

Related work today

Test plan

  • CI green
  • https://scan.sentrixchain.com/blocks?network=testnet lists testnet blocks (~3.17M heights), not mainnet
  • Cookie state persists after one cross-network deeplink visit
  • Dedicated-subdomain flow (scan-testnet.sentrixchain.com) still works as before

Audit on 2026-05-11 caught 22 client-side pages calling useNetwork()
without the matching useNetworkFromQuery() — meaning a deeplink like
https://scan.sentrixchain.com/?network=testnet rendered MAINNET data
because the cookie never flipped.

Detail pages already had the call (blocks/[height], tx/[hash],
address/[addr], tokens/[addr]). Home + every list page + every
leaderboard subpage was missing it. This PR adds the one-line call
across all 22 sites with a consistent comment so future pages
follow the pattern.

Verified live before fix:
  GET /?network=testnet → page rendered height ~1,681,800 (mainnet)
                          instead of ~3,172,785 (testnet)

After fix the cookie flips on first render and the page swaps to
the correct network's data.

Typecheck clean.
@github-actions github-actions Bot enabled auto-merge (squash) May 11, 2026 01:08
@github-actions github-actions Bot merged commit c4e24b1 into main May 11, 2026
5 checks passed
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