1package governance23import (4 gnsmath "gno.land/p/gnoswap/gnsmath/v1"56 "gno.land/r/gnoswap/gov/governance"7)89type ProposalVoteStatusResolver struct {10 *governance.ProposalVoteStatus11}1213// NewProposalVoteStatusResolver wraps persisted vote status for vote tally14// calculations and mutation.15//16// Parameters:17// - voteStatus: persisted proposal vote status to resolve18//19// Returns:20// - *ProposalVoteStatusResolver: resolver backed by voteStatus21func NewProposalVoteStatusResolver(voteStatus *governance.ProposalVoteStatus) *ProposalVoteStatusResolver {22 return &ProposalVoteStatusResolver{voteStatus}23}2425// TotalVoteWeight returns the total weight of all votes cast (yes + no).26//27// Returns:28// - int64: combined "yes" and "no" vote weight29func (p *ProposalVoteStatusResolver) TotalVoteWeight() int64 {30 return gnsmath.SafeAddInt64(p.YesWeight(), p.NoWeight())31}3233// IsPassed determines if the proposal has passed the voting requirements.34// A proposal passes when total vote weight reaches quorum and "yes" votes35// strictly exceed "no" votes.36//37// Returns:38// - bool: true when quorum is met and yes weight is greater than no weight39func (p *ProposalVoteStatusResolver) IsPassed() bool {40 if p.TotalVoteWeight() < p.QuorumAmount() {41 return false42 }4344 return p.YesWeight() > p.NoWeight()45}4647// addYesVoteWeight adds the specified weight to the "yes" vote tally.48// This is called when a user votes "yes" on the proposal.49//50// Parameters:51// - yea: vote weight to add to "yes" votes52//53// Returns:54// - error: always nil (reserved for future validation)55func (p *ProposalVoteStatusResolver) AddYesVoteWeight(yea int64) error {56 p.SetYesWeight(gnsmath.SafeAddInt64(p.YesWeight(), yea))57 return nil58}5960// addNoVoteWeight adds the specified weight to the "no" vote tally.61// This is called when a user votes "no" on the proposal.62//63// Parameters:64// - nay: vote weight to add to "no" votes65//66// Returns:67// - error: always nil (reserved for future validation)68func (p *ProposalVoteStatusResolver) AddNoVoteWeight(nay int64) error {69 p.SetNoWeight(gnsmath.SafeAddInt64(p.NoWeight(), nay))70 return nil71}72Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.
vm/qrender output, sanitized (docs/render-security.md) and displayed in an empty-sandbox iframe — scripts, forms and popups cannot run. Links stay inert in-preview; right-click to open.