@@ -47,28 +47,28 @@ func (p *ClaimBountyProposal) VotingPeriod() time.Duration {
4747 return 7 * 24 * time.Hour
4848}
4949
50- // Tally counts votes and determines if proposal passes
51- // Requires all 3 validators to vote YES for approval
50+ // Tally counts votes and determines if proposal is ready to execute
51+ // Returns true when all validators have voted (regardless of outcome)
5252func (p *ClaimBountyProposal) Tally(votes commondao.ReadonlyVotingRecord, members commondao.MemberSet) (bool, error) {
5353 totalMembers := members.Size()
5454 if totalMembers == 0 {
5555 return false, ufmt.Errorf("no members in DAO")
5656 }
5757
58- // Count votes using the VoteCount method
59- yesCount := votes.VoteCount(commondao.ChoiceYes)
60- noCount := votes.VoteCount(commondao.ChoiceNo)
58+ totalVotes := votes.Size()
6159
62- // Require 100% approval: all validators must vote YES
63- // For a 3-validator DAO, we need exactly 3 YES votes
64- if yesCount == totalMembers && noCount == 0 {
60+ // Return true when all validators have voted
61+ // This allows Execute to be called and handle approval/rejection
62+ if totalVotes == totalMembers {
6563 return true, nil
6664 }
6765
66+ // Not ready yet - waiting for more votes
6867 return false, nil
6968}
7069
71- // Execute executes the proposal after approval
70+ // Execute executes the proposal after all votes are in
71+ // Determines approval or rejection based on vote counts
7272func (p *ClaimBountyProposal) Execute(_ realm) error {
7373 app := GetApplication(p.ApplicationID)
7474 if app == nil {
@@ -84,19 +84,34 @@ func (p *ClaimBountyProposal) Execute(_ realm) error {
8484 return ufmt.Errorf("bounty already claimed")
8585 }
8686
87- // Mark application as approved
88- app.Status = StatusApproved
87+ // Get vote counts from the DAO proposal
88+ proposal := app.DAO.ActiveProposals().Get(app.ProposalID)
89+ if proposal == nil {
90+ return ufmt.Errorf("proposal not found")
91+ }
8992
90- // Mark bounty as claimed
91- bounty.IsClaimed = true
92- bounty.Claimer = p.Applicant
93- bounty.ClaimedAt = time.Now()
93+ yesCount := proposal.VotingRecord().VoteCount(commondao.ChoiceYes)
94+ noCount := proposal.VotingRecord().VoteCount(commondao.ChoiceNo)
95+ totalMembers := app.DAO.Members().Size()
9496
95- // Transfer bounty amount to applicant
96- bnk := banker.NewBanker(banker.BankerTypeRealmSend)
97- send := chain.Coins{chain.Coin{Denom: "ugnot", Amount: bounty.Amount}}
98- pkgAddr := chain.PackageAddress("gno.land/r/greg007/gnobounty")
99- bnk.SendCoins(pkgAddr, p.Applicant, send)
97+ // Check if unanimous approval (all YES, no NO)
98+ if yesCount == totalMembers && noCount == 0 {
99+ // Approve and transfer funds
100+ app.Status = StatusApproved
101+
102+ bounty.IsClaimed = true
103+ bounty.Claimer = p.Applicant
104+ bounty.ClaimedAt = time.Now()
105+
106+ // Transfer bounty amount to applicant
107+ bnk := banker.NewBanker(banker.BankerTypeRealmSend)
108+ send := chain.Coins{chain.Coin{Denom: "ugnot", Amount: bounty.Amount}}
109+ pkgAddr := chain.PackageAddress("gno.land/r/greg007/gnobounty")
110+ bnk.SendCoins(pkgAddr, p.Applicant, send)
111+ } else {
112+ // Reject - not unanimous
113+ app.Status = StatusRejected
114+ }
100115
101116 return nil
102117}
0 commit comments