Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

v0 source pure

Package guild implements the quest state machine used by the Guildhall bounty board. It holds no coins and keeps no g...

Overview

Package guild implements the quest state machine used by the Guildhall bounty board. It holds no coins and keeps no globals: a realm posts a Quest, locks the reward itself, and drives the quest through these pure transition methods.

Constants 2

Variables 1

var ErrInvalidPoster, ErrEmptyTitle, ErrTitleTooLong, ErrSpecTooLong, ErrInvalidReward, ErrInvalidLease, ErrInvalidReview, ErrInvalidDeadline, ErrNotOpen, ErrNotClaimed, ErrNotSubmitted, ErrNotPoster, ErrNotWorker, ErrSelfClaim, ErrPastDeadline, ErrLeaseExpired, ErrReviewOpen, ErrReviewClosed, ErrBeforeDeadline, ErrSubmittedPending, ErrProofURLEmpty, ErrProofURLTooLong, ErrNoteTooLong, ErrReasonTooLong

 1var (
 2	ErrInvalidPoster    = errors.New("guild: invalid poster address")
 3	ErrEmptyTitle       = errors.New("guild: title is required")
 4	ErrTitleTooLong     = errors.New("guild: title exceeds 80 bytes")
 5	ErrSpecTooLong      = errors.New("guild: spec exceeds 2000 bytes")
 6	ErrInvalidReward    = errors.New("guild: reward must be positive")
 7	ErrInvalidLease     = errors.New("guild: lease blocks out of range [100, 500000]")
 8	ErrInvalidReview    = errors.New("guild: review blocks out of range [100, 500000]")
 9	ErrInvalidDeadline  = errors.New("guild: deadline must be later than height plus lease")
10	ErrNotOpen          = errors.New("guild: quest is not open")
11	ErrNotClaimed       = errors.New("guild: quest is not claimed")
12	ErrNotSubmitted     = errors.New("guild: quest is not submitted")
13	ErrNotPoster        = errors.New("guild: caller is not the poster")
14	ErrNotWorker        = errors.New("guild: caller is not the worker")
15	ErrSelfClaim        = errors.New("guild: poster cannot claim their own quest")
16	ErrPastDeadline     = errors.New("guild: deadline has passed")
17	ErrLeaseExpired     = errors.New("guild: lease has expired")
18	ErrReviewOpen       = errors.New("guild: review window is still open")
19	ErrReviewClosed     = errors.New("guild: review window has closed")
20	ErrBeforeDeadline   = errors.New("guild: deadline has not passed")
21	ErrSubmittedPending = errors.New("guild: quest has a pending submission")
22	ErrProofURLEmpty    = errors.New("guild: proof URL is required")
23	ErrProofURLTooLong  = errors.New("guild: proof URL exceeds 300 bytes")
24	ErrNoteTooLong      = errors.New("guild: note exceeds 500 bytes")
25	ErrReasonTooLong    = errors.New("guild: reason exceeds 500 bytes")
26)
source

Functions 1

func New

1func New(id uint64, poster address, title, spec string, reward, leaseBlocks, reviewBlocks, deadline, h int64) (*Quest, error)
source

New validates its inputs and returns an Open quest with a "posted" event recorded at height h.

Types 3

type Event

struct
1type Event struct {
2	Height int64
3	Actor  address
4	Action string
5	Detail string
6}
source

Event records one state change in a quest's history.

type Quest

struct
 1type Quest struct {
 2	ID           uint64
 3	Poster       address
 4	Title        string
 5	Spec         string
 6	Reward       int64
 7	LeaseBlocks  int64
 8	ReviewBlocks int64
 9	Deadline     int64
10	Status       Status
11	Worker       address
12	LeaseEnd     int64
13	ProofURL     string
14	Note         string
15	SubmittedAt  int64
16	AutoPaid     bool
17	History      []Event
18}
source

Quest is a single bounty: posted with an escrowed reward, claimed under a lease, submitted with proof, then paid, rejected back to open, refunded or cancelled.

Methods on Quest

func Accept

method on Quest
1func (q *Quest) Accept(p address, h int64) error
source

Accept pays the submission out: the poster approves inside or past the review window, there is no time limit on acceptance.

func AutoAccept

method on Quest
1func (q *Quest) AutoAccept(w address, h int64) error
source

AutoAccept pays the worker when the poster let the review window lapse: silence counts as acceptance.

func Cancel

method on Quest
1func (q *Quest) Cancel(p address, h int64) error
source

Cancel withdraws an Open quest — or one whose claim went stale — and frees the escrow back to the poster.

func Claim

method on Quest
1func (q *Quest) Claim(w address, h int64) error
source

Claim lets w take the quest while it is Open — including a stale claim whose lease expired. The poster can never claim their own quest.

func Refund

method on Quest
1func (q *Quest) Refund(p address, h int64) error
source

Refund returns the escrow to the poster once the deadline has passed, for an Open quest or a claim whose lease went stale. A pending submission can never be refunded.

func Reject

method on Quest
1func (q *Quest) Reject(p address, h int64, reason string) error
source

Reject sends the quest back to Open, inside the review window, and clears the worker. The cleared fields are preserved in the event detail.

func ReviewEnd

method on Quest
1func (q *Quest) ReviewEnd() int64
source

ReviewEnd is the last height at which the poster may reject a submission.

func StatusAt

method on Quest
1func (q *Quest) StatusAt(h int64) Status
source

StatusAt reports the effective status at height h: a Claimed quest whose lease has run out reads as Open again.

func Submit

method on Quest
1func (q *Quest) Submit(w address, h int64, proofURL, note string) error
source

Submit turns in the worker's proof while the lease is live.

type Status

ident
1type Status int
source

Status is the lifecycle state of a Quest.

Methods on Status

func String

method on Status
1func (s Status) String() string
source

Dependencies

Imports 2

/p/nym-ololade001/guild/v0

Imported by indexer

Source Files 3