escrow source pure
Package escrow is the pure escrow state machine behind Tavern Quests.
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.
1
6
func Approve
Approve marks a Submitted quest Completed. The hosting realm releases the escrowed reward to the claimant when this succeeds.
func Cancel
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
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
Reject sends a Submitted quest back to Claimed, clearing the delivery note so the claimant can fix and resubmit.
func Submit
Submit records the claimant's delivery note and moves a Claimed quest to Submitted.
func ValidateNew
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.
2
type Quest
structQuest 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
identStatus is the lifecycle state of a quest.