Skip to content

Comments

feat(super-user): auto-activate via subdomain and add persistent cache#256

Open
AugustoL wants to merge 16 commits intoopenscan-explorer:mainfrom
AugustoL:feat/improve-super-user-mode
Open

feat(super-user): auto-activate via subdomain and add persistent cache#256
AugustoL wants to merge 16 commits intoopenscan-explorer:mainfrom
AugustoL:feat/improve-super-user-mode

Conversation

@AugustoL
Copy link
Collaborator

Description

Improves super user mode with two enhancements: auto-activation via the super subdomain and a persistent localStorage cache for blockchain data.

Related Issue

Closes #240, Closes #242

Type of Change

  • New feature
  • Bug fix
  • Documentation update
  • Refactoring
  • Performance improvement
  • Other (please describe):

Changes Made

Issue #240 — Subdomain-based super user activation

  • Added super subdomain entry to src/config/subdomains.ts so super.openscan.io is recognized
  • In SettingsContext.tsx, detect super subdomain on init and force isSuperUser: true

Issue #242 — Persistent storage in super user mode

  • Added persistentCacheSizeMB field to UserSettings type (default: 10 MB)
  • Created src/utils/persistentCache.ts — localStorage-based cache with LRU eviction, OPENSCAN_PCACHE_ prefix keys, and QuotaExceededError handling
  • Created src/hooks/usePersistentCache.ts — React hook providing getCached/setCached that are no-ops when super user mode is disabled
  • Added super user settings section to Settings page (cache size limit dropdown, usage display, clear button) — only visible when isSuperUser is true
  • Integrated clearPersistentCache() into the existing clearAllCaches() function
  • Added i18n translations for en and es

Screenshots (if applicable)

N/A — Settings section only visible when super user mode is active.

Checklist

  • I have run npm run format:fix and npm run lint:fix
  • I have run npm run typecheck with no errors (pre-existing errors only)
  • I have run tests with npm run test:run
  • I have tested my changes locally
  • I have updated documentation if needed
  • My code follows the project's architecture patterns

Additional Notes

The usePersistentCache hook is ready for page-level components (block, tx, address pages) to integrate — they can wrap their data fetches with getCached/setCached to persist blockchain data across sessions.

MatiasOS and others added 7 commits February 23, 2026 20:40
…text

- zh: use 发送方/接收方 (sender/receiver) instead of 发件人/收件人 (mail sender/recipient) for from/to fields
- zh: use 金额 (amount) instead of 价值 (abstract value) for ETH transaction amounts
- ja: use 金額 (amount) instead of 価値 (abstract value) for ETH transaction amounts
- ja: use 勝者 (winner) instead of 優勝者 (champion) for RPC race winner
Add super user mode auto-activation when accessing via the "super"
subdomain (e.g., super.openscan.io). Add a persistent localStorage
cache with LRU eviction for blockchain data when in super user mode,
with configurable size limit (5-100MB) and a dedicated Settings section.

Closes openscan-explorer#240, closes openscan-explorer#242
@github-actions
Copy link

github-actions bot commented Feb 24, 2026

🚀 Preview: https://pr-256--openscan.netlify.app
📝 Commit: 8a2cfefaf570d6880672c38cc4bdad92e50ebe75

Add violet accent glow on navbar and footer borders, a "Super User"
badge in the navbar, and violet styling on the active toggle button
to provide clear visual feedback when super user mode is enabled.
…languages

feat(i18n): add Chinese Simplified, Japanese, and Portuguese (BR) translations
…tribution-rule

chore(claude): add no AI attribution rule
- New /rpcs page with network dropdown (EVM + Bitcoin), sortable table
  (provider, latency, status, privacy), and one-click "Add" to config
- Latency test via eth_blockNumber (EVM) / getblockcount (Bitcoin)
  using JSON-RPC 2.0, batched in parallel groups of 6 with 10s timeout
- Status dots: green (online), red (offline), yellow (timeout), pulsing
  gray (pending); offline endpoints always sort last on latency column
- Active row highlight for endpoints already in user RPC config
- Full i18n support (en/es) with new rpcs namespace
- Add "Test RPCs" button in Settings → RPC Endpoints section linking to
  the new page
- Mobile responsive layout
…utton

Display the block number returned by each RPC endpoint so users can
easily identify which providers are up to date. Remove the redundant
"Active" badge and "Add" button since endpoints are managed in settings.
Center all non-provider columns for better readability.
… quality

Tests all configured RPCs in parallel and reorders them by privacy tier
(open source > closed source > tracking) then latency, pushing offline
endpoints to the end. Auto-saves the new order after sync completes.
feat(rpcs): add RPCs page for testing and comparing RPC endpoints
…o feat/improve-super-user-mode

# Conflicts:
#	src/components/pages/settings/index.tsx
@josealoha666
Copy link

🧪 Persistent Cache — Test Report

Preview: pr-256--openscan.netlify.app | Commit: 8a2cfef

✅ What works

Test Result
Super User Mode toggle ✅ Enables/disables correctly from navbar
Settings UI — Cache Size dropdown ✅ 5/10/25/50/100 MB options, persists on save
Settings UI — Usage display ✅ Real-time "Using X.XX MB of Y MB"
Settings UI — Clear Cache button ✅ Clears all OPENSCAN_PCACHE_ entries, UI updates to 0.00 MB
localStorage persistence ✅ Data survives page reload/navigation
Cache key format OPENSCAN_PCACHE_{networkId}:{type}:{identifier}
Cache entry structure data, storedAt, lastAccessedAt, version fields correct
Size calculation ✅ Matches actual localStorage bytes (UTF-16 × 2)
clearAllCaches() integration ✅ Persistent cache included in general "Clear Cache"
Cache size limit change ✅ Dropdown updates persistentCacheSizeMB in settings, reflected in UI

⚠️ Cache not wired to data fetching yet

The usePersistentCache hook exists and works correctly, but no component calls it. Browsing network pages, block detail, tx detail, and address pages produces zero OPENSCAN_PCACHE_ entries in localStorage.

This is acknowledged in the PR description ("ready for page-level components to integrate"), but it means the persistent cache feature is not functional end-to-end for users yet — Settings will always show "Using 0.00 MB".

🔧 Test methodology

  1. Opened PR preview, enabled Super User Mode
  2. Navigated to Settings → verified cache section visible with correct defaults
  3. Browsed Ethereum Mainnet, block pages, tx pages → checked localStorage for OPENSCAN_PCACHE_ keys (found 0)
  4. Manually wrote test entries to localStorage via console → verified Settings UI reflected correct size (1.91 MB)
  5. Tested Clear Cache button → entries cleared, UI updated to 0.00 MB
  6. Wrote 5 entries, reloaded page → data persisted correctly
  7. Changed cache size limit to 5 MB, saved → setting persisted

Verdict

Infrastructure: solid ✅ — The cache utilities, hook, settings UI, and LRU eviction logic are well-implemented.
Integration: missing — Hook needs to be wired into data-fetching components for the feature to be user-facing.

Recommendation: ship as infra-only and wire the hook in a follow-up PR, or add basic integration to at least one data path (e.g., block detail) before merge.

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.

feat: add persistent storage in super user mode feat: Use subdomain for superuser mode (super.openscan)

3 participants