feat(treasury): approval/rejection voting UI for multisig proposals (#132)#255
Open
Jaydams wants to merge 1 commit into
Open
feat(treasury): approval/rejection voting UI for multisig proposals (#132)#255Jaydams wants to merge 1 commit into
Jaydams wants to merge 1 commit into
Conversation
…odebestia#132) Add ProposalCard component, vote-recording API endpoints, per-user vote tracking table, and real-time Socket.IO updates on the treasury page.
|
@Jaydams Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Closes #132 — builds the full approval/rejection voting flow for multisig
treasury proposals, from the database layer through the API to the UI.
Backend
Schema (
apps/backend/src/db/schema.ts): extendedtreasury_proposalswith
recipient,amount,token, andthresholdcolumns so proposalcards can render useful detail; added
proposal_vote_typeenum and a newproposal_votestable (unique on(treasury_proposal_id, user_id)) thatrecords each signer's vote and optional Freighter signature; added Drizzle
relations for both tables.
Migration (
drizzle/0008_treasury_multisig_voting.sql): creates thetreasury_proposalstable (first migration for it), adds the four newcolumns, and creates
proposal_voteswith FK constraints and a uniquepartial index to prevent double-voting at the DB level.
Treasury router (
src/routes/treasury.ts):POST /treasury/propose— now persists proposals to the DB (was a stubreturning TTL only); accepts optional
conversationIdandthreshold.GET /treasury/proposals?conversationId=— returns all proposals,optionally filtered by conversation; annotates each row with
hasVotedand
myVotefor the authenticated user via a single IN-query onproposal_votes.POST /treasury/proposals/:id/approveand.../reject— validates theproposal is still
active, inserts aproposal_votesrow, and returns409 on a unique-constraint violation (duplicate vote) or on an inactive
proposal.
Frontend
ProposalCardcomponent (src/components/treasury/ProposalCard.tsx):shows proposal ID, truncated recipient address, amount + token, a colour-coded
status badge (Pending / Approved / Rejected / Executed / Expired), an
approval progress bar (
approvalsCount / threshold), and Approve/Rejectbuttons. Buttons are disabled when
hasVotedis true orstatus !== "active".On click, Freighter signs
"approve:<proposalId>"/"reject:<proposalId>"before submitting to the API; a toast is shown if signing is cancelled or the
request fails.
Treasury page (
src/app/app/treasury/page.tsx):GET /treasury/proposalson mount (and after a new proposal iscreated via the modal).
treasury_proposal_updatedevents, patching
status,approvalsCount, andrejectionsCountin localstate without a full re-fetch.
ProposalCardgrid with skeleton loadingand an empty state.
proposals.
Test plan
POST /treasury/proposewith a valid body → 201, proposal appears inGET /treasury/proposalsGET /treasury/proposalsreturnshasVoted: false/myVote: nullbefore voting
button shows "Approved ✓", both buttons disable
activeproposal → 409 with descriptive errorfailed", no API call made
treasury_proposal_updated→ treasury page updates countsin real time without manual refresh