Skip to content

Add governance signal hooks and priority-sort utilities - #30

Open
Stanys-dev wants to merge 2 commits into
lightchain-protocol:mainfrom
Stanys-dev:feat/governance-data-layer
Open

Stanys-dev wants to merge 2 commits into
lightchain-protocol:mainfrom
Stanys-dev:feat/governance-data-layer

Conversation

@Stanys-dev

Copy link
Copy Markdown

What this adds

Foundation layer for upcoming governance UX improvements: batch on-chain vote-status reads, active/pending proposal signals, client-side priority sorting, and GraphQL pre-sort for priority-desc. No visible UI change in this PR.

Why

Follow-up PRs will show vote badges, priority-sorted proposal lists, and sidebar urgency signals. Those features need shared hooks and pure sort/time helpers first, kept separate from UI so reviewers can validate data logic independently.

Changes

  • hooks/useGovernorHasVotedBatch.ts β€” batch hasVoted reads via wagmi useReadContracts
  • hooks/useActiveProposalNotVotedForWallet.ts β€” derives not-voted count from the batch map
  • hooks/useProposalGovernanceSignals.ts β€” TanStack Query hook for active/pending counts, next end time, and active proposal IDs
  • lib/sortProposalsByPriorityDesc.ts β€” client priority sort (active + not voted first, soonest end within tier 0)
  • lib/utils.ts β€” formatCompactTimeLeft() for compact urgency labels
  • types/index.ts β€” add priority-desc to ProposalSortOption
  • graphqlApi/index.ts β€” map priority-desc to server end_time asc pre-sort
  • vitest.config.ts + unit tests for sort and time helpers; npm test script

Scope

12 files. Hooks and lib only β€” no component or page changes. No contract changes.

Verification

  • Ran npm run test β€” 7 tests pass
  • Ran npm run build β€” compiles cleanly
  • npm run lint fails with a pre-existing ESLint config error on this repo (circular structure in flat config); not introduced by this PR

Test plan (for reviewer)

  • npm run test passes
  • npm run build / Vercel preview succeeds
  • No runtime/UI change expected β€” this is a data-layer-only PR

Made with Cursor

Introduce batch hasVoted reads, governance signal fetching, client-side priority sort, and GraphQL priority-desc pre-sort. Add Vitest with unit tests for sort and time-formatting helpers.

Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel

vercel Bot commented Jul 18, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the Lightchain AI Team on Vercel.

A member of the Team first needs to authorize it.

Map data/mock/proposals.json to API-shaped Proposal fixtures for deterministic priority-sort coverage.

Co-authored-by: Cursor <cursoragent@cursor.com>

This branch has not been deployed

No deployments
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