Closes #969 - #976
Merged
Merged
Closes #969#976
Conversation
|
Hey @actvabdulrahman! 👋 It looks like this PR isn't linked to any issue. If this PR is for one of the issues assigned to you as part of a Wave, please link it to ensure your contribution is tracked properly. You can do this by adding a keyword to the PR description (e.g.,
|
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.
Summary
src/modules/keys/keys.routes.tsandsrc/modules/creators/creators.routes.ts), including eligibility checks and DB-level double-vote prevention (@@unique([keyId, proposalId, voter])). No governance smart contract exists yet inaccesslayer-contracts, so real on-chain submission and event-driven state sync are genuinely blocked, not something this PR can complete — see "Scope descoped" below.castKeyProposalVoteinserted aGovernanceVoterow but never updatedGovernanceProposal.totalVotingWeightorresults, so list/detail tallies were immediately stale after every vote cast.$transaction, the proposal is re-read, itsactivestatus re-checked, and a new pure helperapplyVoteWeightincrementstotalVotingWeightandresults[optionIndex]alongside the vote insert and activity log — all in the same transaction, so a vote can never be recorded without its tally updating (or vice versa).src/modules/keys/key-proposal-votes.service.test.tswith mocked-Prisma unit tests coveringapplyVoteWeightdirectly (single vote, repeated same option, distinct options tracked independently, untouched result buckets preserved, large totals without floating-point drift viatoBigInt) and the fullcastKeyProposalVoteflow (tally accumulation across 3 distinct wallets/options, and every existing guard still enforced:DuplicateVoteError,HolderNotEligibleError,OptionIndexOutOfRangeError, closed-proposal rejection).Scope descoped (blocked, tracked for a follow-up issue): real on-chain contract submission (
create_proposal/cast_voteare currently TODO stubs;submitTransactionis a non-functional placeholder; no governance contract or Soroban client binding exists in this repo) and event-driven proposal-state sync (no Soroban event fetcher exists anywhere in the codebase; the existinggovernance-sync.job.tsonly does time-based expiry). Both require a governance contract to be defined inaccesslayer-contractsfirst — attempting them here would mean building against something that doesn't exist.Testing
pnpm lintpnpm buildpnpm exec prisma generatewhen schema or generated types changed(No Prisma schema changes were made — this fix only touches service logic and adds tests, so
prisma generateisn't applicable.pnpm test src/modules/keys/key-proposal-votes.service.test.tsalso run: 13/13 pass.)Checklist
(No docs updates needed — no setup or environment variables changed; this is a pure bugfix within existing service logic.)