const MaxTitleLen, MaxDescriptionLen, MaxLinkLen, MaxNoteLen, MaxMilestones, MaxReviewers, MaxApplicants, MaxTags, MaxTagLen, MaxBps, DefaultWorkWindow
Limits keep bounties renderable and every transition bounded in gas.
Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.
Package bounty is the state machine behind Guildhall bounties.
Package bounty is the state machine behind Guildhall bounties.
It holds no funds and moves no coins. Every transition validates who is acting and what state the bounty is in, mutates the bounty, and returns the transfers the escrow realm must execute as a list of Payouts. Keeping the rules here, free of chain effects, lets them be tested exhaustively and reused by any realm that wants to escrow work.
Lifecycle:
1Open ──Assign──▶ Active ──(every milestone settled)──▶ Completed
2 ▲ │
3 └──Unassign/Resign┘
4Open ──Cancel──▶ Cancelled (unpaid milestones refunded)
Milestones move independently once a bounty is Active:
1Pending ──Submit──▶ Submitted ──Approve×quorum──▶ Paid
2 ▲ │ │
3 └──RequestChanges──┘ └──OpenDispute──▶ Disputed ──Resolve──▶ Paid | Split | Refunded
A milestone with requested changes can be resubmitted or disputed.
Limits keep bounties renderable and every transition bounded in gas.
New validates p and returns a funded, open bounty.
When no reviewers are given, the poster reviews alone. When no arbiter is given, the caller is expected to fill in a default (the escrow realm's council) before calling New.
ParseMilestones parses "Title=amount;Title=amount". An empty string yields a single "Complete the bounty" milestone worth total (which must be positive).
ParseStatus is the inverse of Status.String.
Application is a contributor's request to be assigned.
1type Bounty struct {
2 ID uint64
3 Poster address
4 Title string
5 Description string
6 Link string
7 Tags []string
8 // Denom identifies what the escrow holds: a native coin denom, or a
9 // grc20reg key when IsGRC20 is set.
10 Denom string
11 IsGRC20 bool
12
13 Reviewers []address
14 Quorum int
15 Arbiter address
16
17 Assignee address
18 Applications []Application
19 Milestones []*Milestone
20 Status Status
21 WorkWindow time.Duration
22
23 CreatedAt time.Time
24 AssignedAt time.Time
25 ClosedAt time.Time
26}Bounty is a funded task split into milestones.
Apply files an application from a prospective contributor.
Approve records a reviewer's approval. When the quorum is reached the milestone is paid and the returned payout sends its full amount to the worker.
Assign hands the bounty to a contributor. Only the poster may assign, and the assignee cannot be the poster or a reviewer.
Cancel withdraws an open bounty and refunds every unsettled milestone. An active bounty must be unassigned first, so a poster cannot pull funds from under someone who is working.
Escrowed is the amount still held for this bounty.
HasApplied reports whether addr has an application on file.
Involves reports whether addr plays any role in the bounty.
IsReviewer reports whether addr is one of the bounty's reviewers.
Milestone returns the milestone at idx.
OpenDispute escalates a submitted or rejected milestone to the arbiter. Either the poster or the worker who submitted it may open a dispute.
PaidOut is the amount released to workers.
RequestChanges sends a submitted milestone back to the worker, discarding approvals collected so far.
1func (b *Bounty) Resolve(caller address, idx int, workerBps int64, ruling string, now time.Time) ([]Payout, error)Resolve settles a disputed milestone. The arbiter awards workerBps of the milestone to the worker and refunds the rest to the poster.
Submit hands a milestone in for review.
Total is the sum of all milestone amounts.
Unassign returns an active bounty to the open pool.
The assignee may step back at any time. The poster may reclaim the bounty once the work window has elapsed since assignment. Either way, no milestone may be awaiting review or arbitration: those are settled first.
Dispute records a contested milestone and how it was settled.
1type Milestone struct {
2 Title string
3 Amount int64
4 Status MilestoneStatus
5 Submission string
6 SubmittedAt time.Time
7 Approvals []address
8 Feedback string
9 Dispute *Dispute
10 // Worker is the assignee at the time the milestone was submitted. It
11 // stays fixed through review and dispute so a later reassignment cannot
12 // redirect payment for work someone else delivered.
13 Worker address
14 PaidOut int64
15 Refunded int64
16 SettleAt time.Time
17}Milestone is one independently payable slice of a bounty.
MilestoneSpec describes a milestone when posting a bounty.
MilestoneStatus is the state of a single milestone.
Params are the inputs to New.
Payout is a transfer the escrow realm must execute.
PayoutKind says why escrowed funds move.
Status is the lifecycle state of a bounty.