Skip to content

Fix/reclaim vote cost#274

Merged
Mosas2000 merged 30 commits into
mainfrom
fix/reclaim-vote-cost
Apr 24, 2026
Merged

Fix/reclaim vote cost#274
Mosas2000 merged 30 commits into
mainfrom
fix/reclaim-vote-cost

Conversation

@Mosas2000

Copy link
Copy Markdown
Owner

Key Changes

  1. Contract & Type System Updates
    Extended RawStake and RawVote interfaces in frontend/src/types/contract.ts to include V2-specific fields: locked-until and cost-paid.
    Updated VoteRecord domain model in frontend/src/types/voting.ts to support reclaim tracking.
    Mapped cost-paid from Clarity deserialization to the domain model in type-converters.ts.
    Expanded CONTRACT_ERROR_CODES with relevant V2 error states (e.g., ERR-STAKE-LOCKED).
  2. Infrastructure & Caching
    BlockchainDataCache: Extended the caching layer to store user-specific voting records using a composite proposalId-voter key strategy.
    Stacks API Helpers:
    Added getVote read-only helper for fetching individual on-chain voting records.
    Implemented callReclaimVoteCost transaction helper with built-in cache invalidation logic for both votes and stakes.
  3. New Hooks & Components
    useVote Hook: A robust custom hook for fetching and refreshing voting records, essential for tracking reclaim eligibility.
    ReclaimVoteAction Component: A premium UI component integrated into the Proposal Detail page that:
    Automatically detects eligibility based on block height and user vote data.
    Provides guided visual feedback for Locked, Available, Executing, and Success states.
    Includes Stacks Explorer links and educational tooltips about quadratic voting cost recovery.
  4. Quality Assurance
    Unit Testing:
    Comprehensive test suite for useVote hook (fetching, manual refresh, error handling).
    Robust component tests for ReclaimVoteAction (UI transitions, prop validation, and event handling).
    Vitest Configuration: Updated frontend/vitest.config.ts to include test coverage for components and utilities outside the src/ directory.
    Implementation Details
    Branch: fix/reclaim-vote-cost
    Commits: 30 granular, imperative commits following professional development standards.
    Visuals: The reclaim component uses existing glassmorphism design tokens to maintain a premium and consistent aesthetic.
    Verification
    All 10 new unit tests pass (npm run test:frontend).
    Reclaim button correctly enables only after votingEndsAt block height is reached.
    Successful transactions trigger an available stake cache invalidation to update the user's dashboard balance immediately.
    Explorer links correctly point to Mainnet/Testnet based on network configuration.
    Closes Bug: Vote-cost reclaim flow is not exposed in the app #251

@Mosas2000 Mosas2000 merged commit dbb14ed into main Apr 24, 2026
9 of 29 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.

Bug: Vote-cost reclaim flow is not exposed in the app

1 participant