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 realm

Package gild is a paid task board.

Overview

Package gild is a paid task board.

A poster locks a reward in this realm when posting a task. One doer takes the task and sends a link to the work. The poster approves and the realm pays the doer. Two rules protect both sides:

  • If the poster stays silent for ReviewWindow after the work is sent, the doer can claim the reward.
  • If nobody takes the task, or the doer never sends work before the deadline, the poster gets the reward back.

Every payout is written to a public work record (see p/thesithunyein/rep), which other realms can read through Completed and Earned.

Constants 3

const ErrUserCallOnly, ErrReward, ErrRewardRange, ErrTitle, ErrDetails, ErrDone, ErrCategory, ErrDeadline, ErrNotFound, ErrNotOpen, ErrOwnTask, ErrPastDeadline, ErrNotDoer, ErrNotPoster, ErrNotTaken, ErrNotInReview, ErrURL, ErrChangesUsed, ErrNote, ErrTooEarly, ErrDoerHasTime, ErrCannotCancel

 1const (
 2	ErrUserCallOnly = "gild: post must be a direct user call"
 3	ErrReward       = "gild: send exactly one coin of " + Denom
 4	ErrRewardRange  = "gild: reward is outside the allowed range"
 5	ErrTitle        = "gild: title must be 3 to 120 characters"
 6	ErrDetails      = "gild: details are too long"
 7	ErrDone         = "gild: done text is too long"
 8	ErrCategory     = "gild: unknown category"
 9	ErrDeadline     = "gild: deadline must be 1 hour to 90 days from now"
10	ErrNotFound     = "gild: task not found"
11	ErrNotOpen      = "gild: task is not open"
12	ErrOwnTask      = "gild: you cannot take your own task"
13	ErrPastDeadline = "gild: deadline has passed"
14	ErrNotDoer      = "gild: only the doer can do this"
15	ErrNotPoster    = "gild: only the poster can do this"
16	ErrNotTaken     = "gild: task is not taken"
17	ErrNotInReview  = "gild: task is not in review"
18	ErrURL          = "gild: work link must start with https:// and have no spaces"
19	ErrChangesUsed  = "gild: changes were already asked once"
20	ErrNote         = "gild: note must be 1 to 1000 characters"
21	ErrTooEarly     = "gild: the review window has not ended"
22	ErrDoerHasTime  = "gild: the doer still has time before the deadline"
23	ErrCannotCancel = "gild: this task can no longer be cancelled"
24)
source

Error messages. Each failure has its own message so callers, tests and the web app can tell them apart.

const Denom, MinReward, MaxReward, ReviewWindow, ChangesExtension, MinDeadline, MaxDeadline, MinTitle, MaxTitle, MaxDetails, MaxDone, MaxURL, MaxNote, MaxPage

 1const (
 2	Denom                  = "ugnot"
 3	MinReward        int64 = 1_000_000             // 1 GNOT
 4	MaxReward        int64 = 1_000_000_000_000_000 // 1 billion GNOT, a sanity cap
 5	ReviewWindow           = 7 * 24 * time.Hour    // poster's time to answer sent work
 6	ChangesExtension       = 3 * 24 * time.Hour    // minimum time a doer gets after changes are asked
 7	MinDeadline            = time.Hour
 8	MaxDeadline            = 90 * 24 * time.Hour
 9
10	MinTitle   = 3
11	MaxTitle   = 120
12	MaxDetails = 4000
13	MaxDone    = 1000
14	MaxURL     = 300
15	MaxNote    = 1000
16	MaxPage    = 50
17)
source

Rules. They are constants so anyone can read them in the source.

Functions 18

func Approve

crossing Action
1func Approve(cur realm, id int64)
source

Approve pays the doer. Only the poster can call it, and only after work was sent.

func Cancel

crossing Action
1func Cancel(cur realm, id int64)
source

Cancel returns the reward to the poster. It works while the task is open, or when a doer took it but sent no work before the deadline. It never works once work has been sent, so a poster cannot cancel to avoid paying.

func ClaimAfterSilence

crossing Action
1func ClaimAfterSilence(cur realm, id int64)
source

ClaimAfterSilence pays the doer when the poster has not answered within ReviewWindow of the work being sent.

func Completed

Action
1func Completed(addr address) int
source

Completed returns how many tasks addr finished and was paid for on Gild. Other realms can call it to gate features by proven work.

func DoerTasksJSON

Action
1func DoerTasksJSON(addr address, offset, limit int) string
source

DoerTasksJSON lists tasks taken by addr, newest first.

func Earned

Action
1func Earned(addr address) int64
source

Earned returns the total paid to addr on Gild, in Denom.

func HasCompleted

Action
1func HasCompleted(addr address, n int) bool
source

HasCompleted reports whether addr finished at least n tasks on Gild.

func Post

crossing Action
1func Post(cur realm, title, details, done, category string, deadline int64) int64
source

Post creates a task and locks the coins sent with the call as its reward. It must be called directly by a user (maketx call) with exactly one coin of Denom attached. deadline is a Unix time in seconds.

func PosterTasksJSON

Action
1func PosterTasksJSON(addr address, offset, limit int) string
source

PosterTasksJSON lists tasks posted by addr, newest first.

func Release

crossing Action
1func Release(cur realm, id int64)
source

Release gives a taken task back so someone else can take it. Only the doer can call it, and only before work is sent. Any change request is cleared, so the next doer starts fresh.

func Render

1func Render(path string) string
source

Render serves "" (open tasks), "task/<id>" and "u/<address>".

func RequestChanges

crossing Action
1func RequestChanges(cur realm, id int64, note string)
source

RequestChanges sends the task back to the doer once. The doer gets at least ChangesExtension from now before the poster can take the reward back.

func Submit

crossing Action
1func Submit(cur realm, id int64, workURL string)
source

Submit sends a link to the finished work. Only the doer can call it, and only while the task is taken.

func Take

crossing Action
1func Take(cur realm, id int64)
source

Take assigns an open task to the caller. The poster cannot take their own task, and nobody can take a task after its deadline.

func TaskJSON

Action
1func TaskJSON(id int64) string
source

TaskJSON returns one task as JSON, or "null" if it does not exist.

func TasksJSON

Action
1func TasksJSON(filter string, offset, limit int) string
source

TasksJSON lists tasks newest first. filter is "open" or "all".

Types 2

type Status

ident
1type Status int
source

Status is where a task is in its life.

Methods on Status

func String

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

type Task

struct
 1type Task struct {
 2	ID       seqid.ID
 3	Title    string
 4	Details  string
 5	Done     string // what "done" looks like
 6	Category string
 7	Poster   address
 8	Doer     address
 9	Reward   int64 // in Denom
10	Status   Status
11
12	CreatedAt   time.Time
13	Deadline    time.Time // a doer must send work before this
14	TakenAt     time.Time
15	SubmittedAt time.Time
16	ClosedAt    time.Time
17
18	WorkURL      string
19	ChangesAsked bool
20	ChangesNote  string
21	PaidBy       string // "approval" or "silence" once paid
22}
source

Task is one posted piece of work.

Dependencies

Source Files 5