Skip to content

Replace mock leaderboard with live Soroban RPC / indexer query (Closes #20)#62

Open
storm-beyndtech wants to merge 1 commit into
SmartDropLabs:mainfrom
storm-beyndtech:feat/live-leaderboard
Open

Replace mock leaderboard with live Soroban RPC / indexer query (Closes #20)#62
storm-beyndtech wants to merge 1 commit into
SmartDropLabs:mainfrom
storm-beyndtech:feat/live-leaderboard

Conversation

@storm-beyndtech

@storm-beyndtech storm-beyndtech commented Jun 28, 2026

Copy link
Copy Markdown

What

Replaces the 100 synthetic leaderboard rows with a live data source.

SorobanService.getLeaderboard(offset, limit, sortKey) returns one
{ entries, total } page from either:

  1. Backend indexerNEXT_PUBLIC_LEADERBOARD_API_URL (?offset&limit&sort),
    the intended source once smartdrop-backend /api/v1/leaderboard ships.
  2. On-chain event scan (fallback) — aggregates lock_assets /
    unlock_assets / update_credits across the factory pools and
    NEXT_PUBLIC_POOL_CONTRACT_ID, mirroring the existing getPoolDepositors
    pattern. Best-effort over a ~7‑day lookback until the backend exists.

useLeaderboard now fetches only the current page (server-side sort), keeps the
30s refresh scoped to that page, and debounces the address filter at 300ms.

Acceptance criteria

  • Removes synthetic data; fetches real addresses/credits/stake
  • Server-side pagination (PAGE_SIZE = 10, offset/limit)
  • Sort key passed to the query, not done in memory over a full set
  • 300ms-debounced partial-address search on the current page
  • 30s refresh re-fetches the current page only
  • Existing Chakra Spinner / no-data states reused (page unchanged)

Files

  • src/lib/soroban.ts
  • src/hooks/useLeaderboard.ts

Notes for reviewers

  • Type-checks clean (tsc) for both changed files.
  • ⚠️ main currently has pre-existing build-breaking corruption unrelated to
    this PR — next.config.ts:4, src/app/farm/page.tsx:3, and
    ConnectWalletButton.tsx contain injected/garbled lines (see separate report).
    A red next build in CI stems from that, not from this change.

…pLabs#20)

- soroban.ts: add SorobanService.getLeaderboard(offset, limit, sortKey)
  returning { entries, total } from either the backend indexer
  (NEXT_PUBLIC_LEADERBOARD_API_URL) or an on-chain event scan over
  lock_assets / unlock_assets / update_credits across the factory pools
  and NEXT_PUBLIC_POOL_CONTRACT_ID, mirroring getPoolDepositors.
- useLeaderboard.ts: drop the synthetic rows; fetch only the current page,
  server-side sort, 30s current-page refresh, 300ms debounced address filter.
- Leaderboard page unchanged (same hook interface).
@storm-beyndtech storm-beyndtech force-pushed the feat/live-leaderboard branch from f0f6b12 to 0828c1c Compare June 28, 2026 16:11
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