Skip to content

refactor: migrate validator endpoints from v1 to v2#600

Merged
daithihearn merged 1 commit into
mainfrom
refactor/v2-validator-endpoints
Jun 9, 2026
Merged

refactor: migrate validator endpoints from v1 to v2#600
daithihearn merged 1 commit into
mainfrom
refactor/v2-validator-endpoints

Conversation

@daithihearn

Copy link
Copy Markdown
Member

Summary

  • Migrates the three deprecated indexer endpoints used by the validators list and address page to their v2 replacements:
    • /api/v1/validators/api/v2/validators
    • /api/v1/validators/{id}/api/v2/validators/{id}
    • /api/v1/validators/blocks/missed?timeframe=WEEK/api/v2/validators/{id}/slots (now takes a 7-day Unix-seconds window; reliability derived from missedSlotRatio)
  • Fixes a long-standing display bug: the schema parsed a field literally named nftYieldsNextCycle, but that field has never existed in the API (v1 and v2 both expose nftYieldsIfDelegatedNextCycle). Every NFT tier therefore rendered as 0% in production. The summary now merges current nftYields with nftYieldsIfDelegatedNextCycle (next-cycle takes precedence) and the UI omits tiers absent from both, matching the Stargate display pattern.
  • Fixes NaN% reliability: guards against 0/0 slot windows (e.g. a queued validator with no scheduled slots over the last 7 days).
  • Drops dead exports (ValidatorSortBy, SortDirection, validatorId query param, ValidatorDetails.online) that v2 no longer supports and no caller used.
  • Drops export from six unused selector-decoder / sourcify-cache types that knip flagged (pre-existing failures on main, unblocking pre-commit).

Test plan

  • Homepage: validator count + total VET staked still render in HomeStatsGroup
  • Validator address page (e.g. /address/0xfe28fa171d78fb02bc3227bec8073b4d94ab6c4d): Stake breakdown, staking pie chart, Validator APY + next-cycle APY, cycle info populate
  • NFT Tier Next Cycle APYs: shows non-zero values for the tiers the validator has, omits tiers absent from both API objects (no more all-zero rows)
  • Reliability: renders a sensible percentage (no NaN%)
  • Endorser address page: EndorsedValidatorsSection lists endorsed validators with correct stake amounts

🤖 Generated with Claude Code

The indexer marked /api/v1/validators, /api/v1/validators/{id}, and
/api/v1/validators/blocks/missed as deprecated; switch all three to
their v2 replacements. The slots endpoint now takes a 7-day Unix-seconds
window instead of a timeframe enum, and reliability is derived from
missedSlotRatio (already 0..1) so 0/0 windows render as 0% rather
than NaN%.

Along the way, fixes a long-standing bug where the validator details
schema parsed a field literally named `nftYieldsNextCycle` — that field
has never existed in the API (both v1 and v2 expose
`nftYieldsIfDelegatedNextCycle`), so the value was always `{}` and
every NFT tier rendered as 0%. The summary now merges current
`nftYields` with `nftYieldsIfDelegatedNextCycle` (next-cycle takes
precedence) and the UI omits tiers absent from both, matching the
Stargate display pattern.

Drops dead exports (`ValidatorSortBy`, `SortDirection`, the
`validatorId` query param, `ValidatorDetails.online`) that the v2
contract no longer supports and that had no callers.

Also drops `export` from six selector-decoder / sourcify-cache types
that knip flagged as unused — none of them are imported anywhere,
they were only blocking the pre-commit hook.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

Block explorer – Preview

Name Status Preview Updated (UTC)
block-explorer-preview 🗑️ Destroyed (427c280) Preview deleted 2026-06-09 19:28:41

Preview environment destroyed after PR was closed

@daithihearn daithihearn added the increment:patch PR adds backwards compatible bug fixes / patches label Jun 9, 2026
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

PR Docker Image Published

docker pull ghcr.io/vechain/block-explorer:pr.600.427c280
Run locally
docker run --rm -p 3000:3000 ghcr.io/vechain/block-explorer:pr.600.427c280

@daithihearn daithihearn enabled auto-merge (squash) June 9, 2026 16:17
@daithihearn daithihearn disabled auto-merge June 9, 2026 19:27
@daithihearn daithihearn merged commit f91999c into main Jun 9, 2026
15 of 16 checks passed
@daithihearn daithihearn deleted the refactor/v2-validator-endpoints branch June 9, 2026 19:27
@daithihearn daithihearn deployed to preview-pr-600 June 9, 2026 19:27 — with GitHub Actions Active
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

increment:patch PR adds backwards compatible bug fixes / patches

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant