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.

z_pages_filetest.gno

12.82 Kb · 239 lines
  1// PKGPATH: gno.land/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster/filetests/z_pages_filetest
  2
  3// Golden copy of the main pages on a small board with a quest in every
  4// state. Any change to what users see shows up as a diff here.
  5// Update with: gno test -update-golden-tests ./r/questmaster/
  6package z_pages_filetest
  7
  8import (
  9	"chain"
 10	"testing"
 11
 12	"gno.land/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster"
 13)
 14
 15const (
 16	poster  = address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // test1
 17	builder = address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") // test2
 18)
 19
 20func post(cur realm, reward int64, title, details string) uint64 {
 21	testing.SetRealm(testing.NewUserRealm(poster))
 22	testing.SetOriginSend(chain.Coins{{Denom: "ugnot", Amount: reward}})
 23	testing.IssueCoins(chain.PackageAddress("gno.land/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster"), chain.Coins{{Denom: "ugnot", Amount: reward}})
 24	id := questmaster.PostQuest(cross(cur), title, details, 20_000)
 25	testing.SetOriginSend(nil)
 26	return id
 27}
 28
 29func main(cur realm) {
 30	paid := post(cur, 2_500_000, "Translate the README to Indonesian", "Keep the headings.\nUse plain words.")
 31	testing.SetRealm(testing.NewUserRealm(builder))
 32	questmaster.ClaimQuest(cross(cur), paid)
 33	questmaster.SubmitWork(cross(cur), paid, "https://github.com/example/questmaster/pull/7")
 34	testing.SetRealm(testing.NewUserRealm(poster))
 35	questmaster.ApproveWork(cross(cur), paid)
 36
 37	cancelled := post(cur, 1_000_000, "Old idea", "")
 38	testing.SetRealm(testing.NewUserRealm(poster))
 39	questmaster.CancelQuest(cross(cur), cancelled)
 40
 41	working := post(cur, 3_000_000, "Write a gnokey cheat sheet", "One page, the ten most used commands.")
 42	testing.SetRealm(testing.NewUserRealm(builder))
 43	questmaster.ClaimQuest(cross(cur), working)
 44
 45	review := post(cur, 5_000_000, "Add a dark theme to the demo page", "")
 46	testing.SetRealm(testing.NewUserRealm(builder))
 47	questmaster.ClaimQuest(cross(cur), review)
 48	questmaster.SubmitWork(cross(cur), review, "https://github.com/example/questmaster/pull/9")
 49
 50	post(cur, 1_200_000, "Fix typos in docs/plan.md", "Any typo counts.")
 51
 52	closing := post(cur, 2_000_000, "Draw a logo", "")
 53	testing.SetRealm(testing.NewUserRealm(builder))
 54	questmaster.ClaimQuest(cross(cur), closing)
 55	testing.SetRealm(testing.NewUserRealm(poster))
 56	questmaster.CancelQuest(cross(cur), closing)
 57
 58	println(questmaster.Render(""))
 59	println("=====")
 60	println(questmaster.Render("quest/4"))
 61	println("=====")
 62	println(questmaster.Render("paid"))
 63	println("=====")
 64	println(questmaster.Render("builder/" + builder.String()))
 65	println("=====")
 66	println(questmaster.Render("quest/6"))
 67}
 68
 69// Output:
 70// # QuestMaster
 71//
 72// A bounty board for small tasks, paid in GNOT. A poster describes a task and locks the reward in this realm. A builder takes the task, does the work and sends a link to it. When the poster approves, the realm pays the builder. If the poster never answers, the builder can collect the reward after the review window. Nobody else, not even the authors, can move the locked GNOT.
 73//
 74// _Runs on the Onyx test network with test GNOT._
 75//
 76// **Post a quest:** [1 GNOT](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster$help&func=PostQuest&.send=1000000ugnot) · [5 GNOT](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster$help&func=PostQuest&.send=5000000ugnot) · [10 GNOT](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster$help&func=PostQuest&.send=10000000ugnot) · [How it works](#how-it-works) · [Help and commands](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster:help) · [Paid quests](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster:paid)
 77//
 78// ## Board
 79//
 80// | Open quests | GNOT locked | GNOT paid out | Quests paid |
 81// |---|---|---|---|
 82// | 1 | 11.2 | 2.5 | 1 |
 83//
 84// ## Open quests
 85//
 86// | # | Quest | Reward | Work window | Rejected |
 87// |---|---|---|---|---|
 88// | 5 | [Fix typos in docs/plan\.md](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster:quest/5) | 1.2 GNOT | 20,000 (about 19 hours) | 0 |
 89//
 90// ## How it works
 91//
 92// 1. **Post.** The poster writes a title, details and a work window, and sends the reward (at least 1 GNOT) with the call. The GNOT is locked here.
 93// 2. **Claim.** Anyone except the poster takes the quest. Only one builder works on a quest at a time.
 94// 3. **Submit.** The builder sends a link to the work (it must start with `https://`) before the work window ends.
 95// 4. **Review.** The poster approves (the builder is paid at once) or rejects with a reason (the quest opens again, and the reject count goes up for everyone to see).
 96// 5. **Paid.** The reward goes to the builder.
 97//
 98// A poster can cancel an open quest and get the reward back at once. Anyone can claim an open quest; once a builder has it, the poster can **close** the quest instead: the builder keeps their turn, and if it ends without approval the reward goes back to the poster.
 99//
100// > [!WARNING]
101// > **Posters: check your quest.** If you do not approve or reject a submission within the review window (about 7 days), the builder is paid automatically.
102//
103// Two deadlines keep things moving:
104//
105// - **Work window** (set by the poster, 1,000 to 2,200,000 blocks): if the builder has not submitted by then, anyone can release the quest so someone else can take it.
106// - **Review window** (172,800 blocks, about 7 days): if the poster has not approved or rejected by then, the builder can claim the reward.
107//
108// _Times are approximate, at about 3.5 seconds per block; deadlines are exact block heights._
109//
110// ---
111//
112// Built on [gno.land](https://gno.land) · [source](https://github.com/elangrr/questmaster)
113//
114// =====
115// # Quest 4: Add a dark theme to the demo page
116//
117// [Board](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster) · [Help](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster:help)
118//
119// | | |
120// |---|---|
121// | State | **Submitted (waiting for review)** |
122// | Reward | 5 GNOT |
123// | Poster | [g1jg8mtu…sqf5](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster:poster/g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5) |
124// | Builder | [g1us8428…njlj](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster:builder/g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj) |
125// | Work window | 20,000 blocks (about 19 hours) |
126// | Posted at block | 123 |
127// | Submitted at block | 123 |
128// | Review deadline | block 172,923 (about 7 days left) |
129// | Work | [https://github\.com/example/questmaster/pull/9](https://github.com/example/questmaster/pull/9) |
130// | Times rejected | 0 |
131// | Current block | 123 |
132//
133// ## Details
134//
135// _No details given._
136//
137// ## What can happen next
138//
139// If the poster does not answer by block 172,923, the builder can claim the reward from block 172,924.
140//
141// - **Approve**: the poster accepts the work and the builder is paid 5 GNOT. [Open in gnoweb](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster$help&func=ApproveWork&id=4)
142// - **Reject**: the poster refuses the work with a reason, until block 172,923. The quest opens again. [Open in gnoweb](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster$help&func=RejectWork&id=4)
143// - **Close quest**: the poster stops the quest. No coins move now; the builder keeps their turn, and if it ends without approval the reward goes back to the poster. It cannot be undone. [Open in gnoweb](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster$help&func=CancelQuest&id=4)
144//
145// With gnokey on Onyx (replace `KEY` with your key name):
146//
147// ```
148// gnokey maketx call -pkgpath "gno.land/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster" -func "ApproveWork" -args "4" -gas-fee 100000ugnot -gas-wanted 10000000 -broadcast -chainid onyx-1 -remote https://rpc.onyx.testnets.gno.land:443 KEY
149// gnokey maketx call -pkgpath "gno.land/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster" -func "RejectWork" -args "4" -args "What is missing" -gas-fee 100000ugnot -gas-wanted 10000000 -broadcast -chainid onyx-1 -remote https://rpc.onyx.testnets.gno.land:443 KEY
150// gnokey maketx call -pkgpath "gno.land/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster" -func "CancelQuest" -args "4" -gas-fee 100000ugnot -gas-wanted 10000000 -broadcast -chainid onyx-1 -remote https://rpc.onyx.testnets.gno.land:443 KEY
151// ```
152//
153// _Times are approximate, at about 3.5 seconds per block; deadlines are exact block heights._
154//
155// ---
156//
157// Built on [gno.land](https://gno.land) · [source](https://github.com/elangrr/questmaster)
158//
159// =====
160// # Paid quests
161//
162// [Board](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster)
163//
164// Every quest below was paid by this realm to its builder: 1 quest, 2.5 GNOT in total.
165//
166// | # | Quest | Reward | Builder | Times rejected |
167// |---|---|---|---|---|
168// | 1 | [Translate the README to Indonesian](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster:quest/1) | 2.5 GNOT | [g1us8428…njlj](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster:builder/g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj) | 0 |
169//
170//
171// ---
172//
173// Built on [gno.land](https://gno.land) · [source](https://github.com/elangrr/questmaster)
174//
175// =====
176// # Builder g1us8428…njlj
177//
178// [Board](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster) · [Same address as poster](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster:poster/g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj)
179//
180// Address: `g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj`
181//
182// Quests this address has claimed, with their current state. A quest stays here after the builder gives it up or is rejected.
183//
184// | # | Quest | Reward | State | Poster |
185// |---|---|---|---|---|
186// | 6 | [Draw a logo](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster:quest/6) | 2 GNOT | Claimed (work in progress), closing | [g1jg8mtu…sqf5](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster:poster/g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5) |
187// | 4 | [Add a dark theme to the demo page](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster:quest/4) | 5 GNOT | Submitted (waiting for review) | [g1jg8mtu…sqf5](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster:poster/g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5) |
188// | 3 | [Write a gnokey cheat sheet](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster:quest/3) | 3 GNOT | Claimed (work in progress) | [g1jg8mtu…sqf5](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster:poster/g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5) |
189// | 1 | [Translate the README to Indonesian](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster:quest/1) | 2.5 GNOT | Paid | [g1jg8mtu…sqf5](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster:poster/g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5) |
190//
191//
192// ---
193//
194// Built on [gno.land](https://gno.land) · [source](https://github.com/elangrr/questmaster)
195//
196// =====
197// # Quest 6: Draw a logo
198//
199// [Board](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster) · [Help](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster:help)
200//
201// | | |
202// |---|---|
203// | State | **Claimed (work in progress), closing** |
204// | Reward | 2 GNOT |
205// | Poster | [g1jg8mtu…sqf5](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster:poster/g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5) |
206// | Builder | [g1us8428…njlj](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster:builder/g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj) |
207// | Work window | 20,000 blocks (about 19 hours) |
208// | Posted at block | 123 |
209// | Claimed at block | 123 |
210// | Work deadline | block 20,123 (about 19 hours left) |
211// | Times rejected | 0 |
212// | Current block | 123 |
213//
214// > [!NOTE]
215// > **Closing**: the reward returns to the poster when the current builder's turn ends, unless the work is approved.
216//
217// ## Details
218//
219// _No details given._
220//
221// ## What can happen next
222//
223// If nothing is submitted by block 20,123, anyone can end the quest from block 20,124 and the reward goes back to the poster.
224//
225// - **Submit work**: the builder sends a link to the work (starting with `https://`), until block 20,123. [Open in gnoweb](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster$help&func=SubmitWork&id=6)
226// - **Unclaim**: the builder gives the quest back. It is closing, so it ends and the reward goes back to the poster. [Open in gnoweb](/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster$help&func=UnclaimQuest&id=6)
227//
228// With gnokey on Onyx (replace `KEY` with your key name):
229//
230// ```
231// gnokey maketx call -pkgpath "gno.land/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster" -func "SubmitWork" -args "6" -args "https://link-to-your-work" -gas-fee 100000ugnot -gas-wanted 10000000 -broadcast -chainid onyx-1 -remote https://rpc.onyx.testnets.gno.land:443 KEY
232// gnokey maketx call -pkgpath "gno.land/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/questmaster" -func "UnclaimQuest" -args "6" -gas-fee 100000ugnot -gas-wanted 10000000 -broadcast -chainid onyx-1 -remote https://rpc.onyx.testnets.gno.land:443 KEY
233// ```
234//
235// _Times are approximate, at about 3.5 seconds per block; deadlines are exact block heights._
236//
237// ---
238//
239// Built on [gno.land](https://gno.land) · [source](https://github.com/elangrr/questmaster)