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.

escrow source pure

Package escrow is the pure escrow state machine behind Tavern Quests.

Overview

Package escrow is the pure escrow state machine behind Tavern Quests.

It is a stateless library: it owns the quest record type and every rule for how a quest may move through its lifecycle, but it holds no chain state and moves no coins. The Tavern Quests realm (gno.land/r/nym-tavern777/quests) stores the records, verifies payments, and performs the actual coin transfers; every authorization and transition decision is delegated here so the rules can be unit-tested in isolation and reused by other realms.

Lifecycle:

Example
1Open --Claim(claimer != poster)--> Claimed
2Open --Cancel(poster)--> Cancelled            (escrow refunded by realm)
3Claimed --Submit(claimant)--> Submitted
4Submitted --Approve(poster)--> Completed      (escrow released by realm)
5Submitted --Reject(poster)--> Claimed         (submission cleared, retry)

Every transition validates first and mutates only on success, so a rejected transition never leaves partial state behind.

Constants 1

Functions 6

func Approve

1func Approve(q *Quest, actor address) error
source

Approve marks a Submitted quest Completed. The hosting realm releases the escrowed reward to the claimant when this succeeds.

func Cancel

1func Cancel(q *Quest, actor address) error
source

Cancel closes an Open quest. The hosting realm refunds the escrowed reward to the poster when this succeeds. A quest that has been claimed can no longer be cancelled.

func Claim

1func Claim(q *Quest, actor address) error
source

Claim moves an Open quest to Claimed for actor. The poster cannot claim their own quest, and a quest can have only one claimant.

func Reject

1func Reject(q *Quest, actor address) error
source

Reject sends a Submitted quest back to Claimed, clearing the delivery note so the claimant can fix and resubmit.

func Submit

1func Submit(q *Quest, actor address, note string) error
source

Submit records the claimant's delivery note and moves a Claimed quest to Submitted.

func ValidateNew

1func ValidateNew(title, description string, reward int64) error
source

ValidateNew checks the fields of a quest that is about to be posted. reward is the ugnot amount the poster actually sent, verified by the realm against the transaction before calling this.

Types 2

type Quest

struct
 1type Quest struct {
 2	ID          int64
 3	Poster      address
 4	Claimant    address
 5	Title       string
 6	Description string
 7	Reward      int64 // ugnot
 8	Status      Status
 9	Submission  string // claimant's delivery note / proof reference
10}
source

Quest is a single escrowed task on the board. Reward is denominated in ugnot and is held by the hosting realm between posting and payout/refund.

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

String returns the lowercase board label for the status.

Dependencies

Imports 2

/p/nym-tavern777/escrow

Imported by indexer

Source Files 3