-
Notifications
You must be signed in to change notification settings - Fork 7
Feat gnobounty #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Feat gnobounty #22
Conversation
- Convert Register, Upvote, Downvote, and AddComment URLs to txlink.Call() - Use builder pattern for AddComment to allow user-editable text field - Cache match count to reduce redundant len() calls
| - `send`: The bounty amount in ugnot (1 GNOT = 1,000,000 ugnot) | ||
|
|
||
| **Minimum bounty**: 1 GNOT (1,000,000 ugnot) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gnot will be non-transferrable upon launch so you will not be able to use it to pay for things (usable only for gas)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on staging we can transfer gnot
| // Create the application | ||
| application := &Application{ | ||
| ID: applicationCount, | ||
| BountyID: bountyID, | ||
| Applicant: caller, | ||
| PRLink: prLink, | ||
| AppliedAt: time.Now(), | ||
| Status: StatusPending, | ||
| DAO: dao, | ||
| ProposalID: 0, // Will be set when proposal is created | ||
| } | ||
|
|
||
| // Create a proposal in the DAO to approve this application | ||
| proposalDef := NewClaimBountyProposal(bountyID, applicationCount, caller, prLink) | ||
|
|
||
| proposal := dao.MustPropose(caller, proposalDef) | ||
| application.ProposalID = proposal.ID() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do the DAO.MustPropose before creating the application structure so you can directly set the proposalId instead of setting it to 0 by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if app.DAO != nil && app.Status == StatusPending { | ||
| if app.DAO.Members().Has(validatorAddr) { | ||
| apps = append(apps, app) | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can do this in only one if
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| for i := 0; i < len(result)-1; i++ { | ||
| for j := 0; j < len(result)-i-1; j++ { | ||
| if result[j].Score < result[j+1].Score { | ||
| // Swap | ||
| result[j], result[j+1] = result[j+1], result[j] | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe ask @leohhhn if a bubble sort is already implemented
| output += "| Rank | User | Score | 💰 Bounties | 📝 Applications | ⚖️ Validations |\n" | ||
| output += "|---|---|---|---|---|---|\n" | ||
|
|
||
| for i, entry := range entries { | ||
| rank := "" | ||
| switch i { | ||
| case 0: | ||
| rank = "🥇" | ||
| case 1: | ||
| rank = "🥈" | ||
| case 2: | ||
| rank = "🥉" | ||
| default: | ||
| rank = ufmt.Sprintf("%d", i+1) | ||
| } | ||
|
|
||
| output += ufmt.Sprintf("| %s | %s | **%d** | %d | %d | %d |\n", | ||
| rank, | ||
| entry.Address, | ||
| entry.Score, | ||
| entry.BountiesCreated, | ||
| entry.BountiesApplied, | ||
| entry.ValidationsPerformed, | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use gno.land/p/moul/md to create the table
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Refund the creator | ||
| bnk := banker.NewBanker(banker.BankerTypeRealmSend) | ||
| send := chain.Coins{chain.Coin{Denom: "ugnot", Amount: bounty.Amount}} | ||
| pkgAddr := chain.PackageAddress("gno.land/r/greg007/gnobounty") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Save the package address into a variable so you can change it easily if it's redeployed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| // Transfer rewards | ||
| bnk := banker.NewBanker(banker.BankerTypeRealmSend) | ||
| pkgAddr := chain.PackageAddress("gno.land/r/greg007/gnobounty") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| output += "## 🎯 Quick Actions\n\n" | ||
| output += md.Link("👨⚖️ Register as Validator", registerValidatorLink) | ||
| output += " | " | ||
| output += md.Link("💰 Create a new bounty", createBountyLink) | ||
| output += ufmt.Sprintf(" _(minimum reward: %s)_", minSend) | ||
| output += " | " | ||
| output += md.Link("📋 View All Validators", "/r/greg007/gnobounty:validators") | ||
| output += " | " | ||
| output += md.Link("🏆 Leaderboard", "/r/greg007/gnobounty:leaderboard") | ||
| output += "\n\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same use gno.land/p/moul/md package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| output += " | " | ||
|
|
||
| // Add view details link | ||
| detailsPath := ufmt.Sprintf("/r/greg007/gnobounty:%d", bounty.ID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same, package address into a variable with a setter function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR introduces gnobounty, a decentralized bounty system built on Gno that allows users to place bounties on GitHub issues using cryptocurrency.