Fix/reclaim vote cost#274
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Key Changes
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).
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.
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.
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