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.

Playground

gnomod.toml

module = "gno.land/r/g1magld5ptgzaktqcexxq0pgq5lmdf0kz6re8hlv/grant/v0"
gno = "0.9"
private = true

[addpkg]
  creator = "g1magld5ptgzaktqcexxq0pgq5lmdf0kz6re8hlv"
  height = 914308
  max_deposit = "16000000ugnot"

grant.gno

// Package grant is moul's personal grant board.
//
// It is small on purpose. moul funds it out of his own pocket, moul is the
// only member, and it exists mainly so the coding agents working on his repos
// and the people he already works with have a way to ask for money against
// work they can prove they did: a request, a milestone, a link to the merged
// PR, a tranche. It is open to anyone, not only to agents, and nothing here is
// privileged to a bot.
//
// # What this is NOT
//
// It is not a faucet, and it is not an official gno.land grant program. There
// is no entitlement, no queue and no service level: a request can sit here
// unanswered, or be refused with one line of reasoning and nothing further.
// The official thing, where anyone asks for tokens and a DAO decides, is a
// separate program that does not exist yet, at a path this realm deliberately
// does not name: naming one would read as a commitment nobody has made. This
// realm is moul's own money and a proof of concept for the library under it.
//
// A bigger, multi-member, better funded program is a separate thing and will
// live at its own path. This one stays personal, and its limits are on the
// page rather than in a comment: one member means "a majority of the board" is
// one signature, and the board page says so.
//
// # What is here versus in the library
//
// Almost nothing. Every rule, every tally, every markdown page comes from
// gno.land/p/moul/grants/v0, which is pure and has no idea coins exist. This
// file is the chain-facing half: it turns the caller into an address and the
// block into a height, holds the one Program, moves ugnot through the banker,
// and emits events. That is deliberate, so the next board (multi-member,
// differently funded, maybe a different denom) is another file this short and
// not a fork of this one.
//
// # Who the caller is
//
// Every actor is PreviousRealm().Address(), the immediate caller. Called
// through another realm that is the calling REALM, not the user behind it.
// An agent holding a gno.land account session scoped to this path applies and
// submits proofs as its own address, which is exactly what makes an agent's
// track record on this board its own and not moul's.
package grant

import (
	"strconv"

	"chain"
	"chain/banker"
	"chain/runtime"
	"chain/runtime/unsafe"

	"gno.land/p/g1magld5ptgzaktqcexxq0pgq5lmdf0kz6re8hlv/grants/v0"
)

const (
	// Denom is the only coin this board holds or pays.
	Denom = "ugnot"
	// Path is this realm's package path; its treasury is derived from it.
	Path = "gno.land/r/moul/grant/v0"
	// Link is Path as a gnoweb route.
	Link = "/r/moul/grant/v0"
)

// Owner is the founding and, for now, only member.
//
// Hardcoded rather than taken from the deployer: inside a plain
// `func Test(t *testing.T)` the gno test runner reports OriginCaller() as the
// EMPTY address, so a board seeded from it is empty in every test and
// something else on chain. That divergence is exactly where an authorization
// bug hides, so the address is written down.
const Owner = address("g1manfred47kzduec920z88wfr64ylksmdcedlf5")

var program *grants.Program

func init() { reset() }

// reset installs a fresh, empty board. Also called by the tests: realm globals
// persist for a whole test binary and examples run after every Test, so a
// pinned Render has to start from a known state.
func reset() { program = grants.NewProgram(Denom, Owner) }

// Address is the treasury: this realm's own package address. Fund it by
// sending ugnot to it, or by calling Fund with `-send`.
func Address() address { return chain.PackageAddress(Path) }

// Balance is what the treasury actually holds.
func Balance() int64 {
	return banker.NewReadonlyBanker().GetCoins(Address()).AmountOf(Denom)
}

// Committed is what approved grants can still claim, Available is the balance
// minus that, and it can go negative. See the library for why.
func Committed() int64 { return program.Committed() }
func Available() int64 { return program.Available(Balance()) }

// Raised is everything donated through Fund, Disbursed everything paid out.
func Raised() int64    { return program.Raised() }
func Disbursed() int64 { return program.Disbursed() }

// Members lists the board.
func Members() []address { return program.Board.Members() }

// Requests is how many requests have ever been filed.
func Requests() int { return program.Board.Size() }

// Fund credits the ugnot sent with the call to the treasury and puts the donor
// on the record. Coins sent to the realm address directly still land in the
// treasury; they just do not get a name next to them.
func Fund(cur realm) {
	if !cur.IsCurrent() {
		panic("grant: spoofed realm")
	}
	// OriginSend is what the SIGNER attached, not what reached this realm. A
	// realm the user called keeps those coins and could call Fund any number of
	// times, booking each as a donation, so only a user call may read it.
	prev := cur.Previous()
	if !prev.IsUserCall() {
		panic("grant: Fund must be called directly by an account, with -send")
	}
	from := prev.Address()
	amount := unsafe.OriginSend().AmountOf(Denom)
	if err := program.Fund(from, amount, runtime.ChainHeight()); err != nil {
		panic(err)
	}
	chain.Emit("Fund", "from", from.String(), "amount", strconv.FormatInt(amount, 10))
}

// Apply files a grant request for the caller. milestones reads
// "title:amount,title:amount", amounts in ugnot, paid in the order given.
// Returns the request id.
func Apply(cur realm, title, body, milestones string) int {
	if !cur.IsCurrent() {
		panic("grant: spoofed realm")
	}
	applicant := cur.Previous().Address()
	return file(applicant, applicant, "", title, body, milestones)
}

// ApplyFor files a grant request whose tranches pay beneficiary rather than
// the caller, with a reason for the detour that goes on the request page.
//
// This is the call that makes the board usable at all for the case it exists
// to serve. An account with nothing in it cannot pay the gas to ask for its
// first coins, so without someone else filing on its behalf the people who
// most need a small grant are exactly the people who cannot ask for one.
// Either address may then submit the proofs, and neither may vote.
func ApplyFor(cur realm, beneficiary, reason, title, body, milestones string) int {
	if !cur.IsCurrent() {
		panic("grant: spoofed realm")
	}
	applicant := cur.Previous().Address()
	return file(applicant, address(beneficiary), reason, title, body, milestones)
}

func file(applicant, beneficiary address, reason, title, body, milestones string) int {
	r, err := program.ApplyFor(applicant, beneficiary, reason, title, body, milestones,
		runtime.ChainHeight())
	if err != nil {
		panic(err)
	}
	chain.Emit("Apply", "id", strconv.Itoa(r.ID), "applicant", applicant.String(),
		"beneficiary", r.Payee().String(), "total", strconv.FormatInt(r.Total(), 10))
	return r.ID
}

// ProposeMember asks the board to add or remove a member. Members only.
func ProposeMember(cur realm, addr string, add bool, body string) int {
	if !cur.IsCurrent() {
		panic("grant: spoofed realm")
	}
	proposer := cur.Previous().Address()
	r, err := program.Board.SubmitMemberChange(proposer, address(addr), add, body, runtime.ChainHeight())
	if err != nil {
		panic(err)
	}
	chain.Emit("ProposeMember", "id", strconv.Itoa(r.ID), "subject", addr,
		"add", strconv.FormatBool(add))
	return r.ID
}

// Retract pulls the caller's own request before it is decided.
func Retract(cur realm, id int) {
	if !cur.IsCurrent() {
		panic("grant: spoofed realm")
	}
	caller := cur.Previous().Address()
	if err := program.Board.Withdraw(caller, id, runtime.ChainHeight()); err != nil {
		panic(err)
	}
	chain.Emit("Retract", "id", strconv.Itoa(id))
}

// Vote records a member's ballot. The reason is stored and rendered next to
// the vote: it is the only part of a decision that tells an applicant what to
// do about it.
func Vote(cur realm, id int, approve bool, reason string) {
	if !cur.IsCurrent() {
		panic("grant: spoofed realm")
	}
	voter := cur.Previous().Address()
	st, err := program.Board.Vote(voter, id, approve, reason, runtime.ChainHeight())
	if err != nil {
		panic(err)
	}
	chain.Emit("Vote", "id", strconv.Itoa(id), "voter", voter.String(),
		"approve", strconv.FormatBool(approve), "status", st.String())
}

// SubmitProof offers evidence for the next milestone of an approved grant.
// kind is "url", "hash" or "text"; ref is the link, digest or statement.
func SubmitProof(cur realm, id, milestone int, kind, ref, note string) {
	if !cur.IsCurrent() {
		panic("grant: spoofed realm")
	}
	caller := cur.Previous().Address()
	p := grants.Proof{Kind: kind, Ref: ref, Note: note, Height: runtime.ChainHeight()}
	if err := program.Board.SubmitProof(caller, id, milestone, p); err != nil {
		panic(err)
	}
	chain.Emit("SubmitProof", "id", strconv.Itoa(id),
		"milestone", strconv.Itoa(milestone), "kind", kind)
}

// Review records a member's verdict on the proof under review. The verdict
// that carries also pays the tranche, in this same transaction. A verdict the
// treasury cannot cover is refused outright and changes nothing.
func Review(cur realm, id, milestone int, accept bool, reason string) {
	if !cur.IsCurrent() {
		panic("grant: spoofed realm")
	}
	voter := cur.Previous().Address()
	out, pay, err := program.Review(voter, id, milestone, accept, reason, runtime.ChainHeight(), Balance())
	if err != nil {
		panic(err)
	}
	chain.Emit("Review", "id", strconv.Itoa(id), "milestone", strconv.Itoa(milestone),
		"voter", voter.String(), "accept", strconv.FormatBool(accept), "outcome", out.String())
	if pay == nil {
		return
	}
	banker.NewBanker(banker.BankerTypeRealmSend, cur).
		SendCoins(Address(), pay.To, chain.NewCoins(chain.NewCoin(Denom, pay.Amount)))
	chain.Emit("Release", "id", strconv.Itoa(id), "milestone", strconv.Itoa(milestone),
		"to", pay.To.String(), "amount", strconv.FormatInt(pay.Amount, 10))
}

grant_test.gno

package grant

import (
	"chain"
	"chain/banker"
	"testing"

	"gno.land/p/g1magld5ptgzaktqcexxq0pgq5lmdf0kz6re8hlv/grants/v0"
	"gno.land/p/nt/uassert/v0"
	"gno.land/p/nt/urequire/v0"
)

const (
	zoe = address("g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz") // an applicant
	kim = address("g1jvh5ukk07dvd57fxefcp5aa29xaydxmxs7myyp") // a second one
)

func balanceOf(a address) int64 {
	return banker.NewReadonlyBanker().GetCoins(a).AmountOf(Denom)
}

func issue(n int64) { testing.IssueCoins(Address(), chain.NewCoins(chain.NewCoin(Denom, n))) }

func TestFreshBoardIsOwnedAndEmpty(t *testing.T) {
	reset()
	uassert.True(t, Owner.IsValid(), "the owner is a real address")
	uassert.True(t, zoe.IsValid())
	uassert.True(t, kim.IsValid())
	uassert.True(t, Address().IsValid(), "the treasury address")

	urequire.Equal(t, 1, len(Members()))
	uassert.Equal(t, Owner.String(), Members()[0].String())
	uassert.Equal(t, 0, Requests(), "nothing seeded, this board is real")
	uassert.Equal(t, int64(0), Committed())
	uassert.Equal(t, int64(0), Raised())
	uassert.Equal(t, int64(0), Disbursed())
}

// The whole path with real coins, on a one-member board: the owner is the
// majority, so one ballot carries and one review pays.
func TestApplyApproveProveGetPaid(cur realm, t *testing.T) {
	reset()
	urequire.Equal(t, int64(0), Balance(), "start from an empty treasury")

	// Someone funds the board, by name.
	issue(500)
	testing.SetOriginSend(chain.NewCoins(chain.NewCoin(Denom, 500)))
	testing.SetRealm(testing.NewUserRealm(kim))
	Fund(cross(cur))
	uassert.Equal(t, int64(500), Balance())
	uassert.Equal(t, int64(500), Raised())
	uassert.Equal(t, kim.String(), program.Donations[0].From.String())

	// An outsider applies. Anyone may.
	testing.SetRealm(testing.NewUserRealm(zoe))
	id := Apply(cross(cur), "Ship the indexer", "two tranches", "alpha:100,beta:400")
	uassert.Equal(t, 1, id)
	uassert.Equal(t, int64(0), Committed(), "a pending request promises nothing")

	// A non-member cannot vote, not even the applicant.
	testing.SetRealm(testing.NewUserRealm(zoe))
	uassert.AbortsContains(t, cur, grants.ErrNotMember.Error(), func() {
		Vote(cross(cur), id, true, "me again")
	})

	testing.SetRealm(testing.NewUserRealm(Owner))
	Vote(cross(cur), id, true, "worth it")
	uassert.Equal(t, int64(500), Committed(), "approval promises the full ask")
	uassert.Equal(t, int64(0), Available())

	// Milestone 1: proof, then the one review that carries also pays.
	testing.SetRealm(testing.NewUserRealm(kim))
	uassert.AbortsContains(t, cur, grants.ErrNotApplicant.Error(), func() {
		SubmitProof(cross(cur), id, 0, "url", "https://example.com/pr/1", "not mine to prove")
	})
	testing.SetRealm(testing.NewUserRealm(zoe))
	SubmitProof(cross(cur), id, 0, "url", "https://example.com/pr/1", "alpha is live")
	testing.SetRealm(testing.NewUserRealm(Owner))
	Review(cross(cur), id, 0, true, "confirmed")

	uassert.Equal(t, int64(100), balanceOf(zoe), "the tranche landed")
	uassert.Equal(t, int64(400), Balance())
	uassert.Equal(t, int64(100), Disbursed())
	urequire.Equal(t, 1, len(program.Payments))
	uassert.Equal(t, int64(100), program.Payments[0].Amount)

	// Out of order is refused.
	testing.SetRealm(testing.NewUserRealm(zoe))
	uassert.AbortsContains(t, cur, grants.ErrOutOfOrder.Error(), func() {
		SubmitProof(cross(cur), id, 0, "url", "https://example.com/pr/1", "again")
	})

	// Milestone 2: a proof the owner refuses, then one they accept.
	testing.SetRealm(testing.NewUserRealm(zoe))
	SubmitProof(cross(cur), id, 1, "text", "trust me", "")
	testing.SetRealm(testing.NewUserRealm(Owner))
	Review(cross(cur), id, 1, false, "no evidence")
	uassert.Equal(t, int64(100), balanceOf(zoe), "a refused proof pays nothing")

	testing.SetRealm(testing.NewUserRealm(zoe))
	SubmitProof(cross(cur), id, 1, "hash", "sha256:deadbeef", "beta, signed release")
	testing.SetRealm(testing.NewUserRealm(Owner))
	Review(cross(cur), id, 1, true, "verified")

	uassert.Equal(t, int64(500), balanceOf(zoe), "paid in full")
	uassert.Equal(t, int64(0), Balance(), "the treasury is back to empty")
	uassert.Equal(t, int64(0), Committed())
	uassert.Equal(t, int64(500), Disbursed())
	uassert.Equal(t, 2, len(program.Payments))

	// Both attempts on milestone 2 are on the record, refusal included.
	m2 := program.Board.Get(id).Milestones[1]
	urequire.Equal(t, 2, len(m2.Attempts))
	uassert.Equal(t, "refused", m2.Attempts[0].Outcome.String())
	uassert.Equal(t, "no evidence", m2.Attempts[0].Reviews[0].Reason)
	uassert.Equal(t, "accepted", m2.Attempts[1].Outcome.String())
}

// The verdict that would release a tranche the treasury cannot pay is refused
// outright and leaves no trace.
func TestReviewRefusesToReleaseWhatItCannotPay(cur realm, t *testing.T) {
	reset()
	urequire.Equal(t, int64(0), Balance(), "no coins anywhere")

	testing.SetRealm(testing.NewUserRealm(zoe))
	id := Apply(cross(cur), "Ship the indexer", "", "alpha:100")
	testing.SetRealm(testing.NewUserRealm(Owner))
	Vote(cross(cur), id, true, "worth it")
	testing.SetRealm(testing.NewUserRealm(zoe))
	SubmitProof(cross(cur), id, 0, "url", "https://example.com/pr/1", "")

	testing.SetRealm(testing.NewUserRealm(Owner))
	uassert.AbortsContains(t, cur, grants.ErrUnderfunded.Error(), func() {
		Review(cross(cur), id, 0, true, "confirmed")
	})
	m := program.Board.Get(id).Milestones[0]
	uassert.Equal(t, 0, len(m.Current().Reviews), "the ballot was not recorded")
	uassert.False(t, m.Released)
	uassert.Equal(t, 0, len(program.Payments))
	uassert.Equal(t, int64(-100), Available(), "and the shortfall is visible")
}

func TestRetractAndBadInput(cur realm, t *testing.T) {
	reset()
	testing.SetRealm(testing.NewUserRealm(zoe))
	uassert.AbortsContains(t, cur, grants.ErrBadSpec.Error(), func() {
		Apply(cross(cur), "Bad", "", "no amount here")
	})
	uassert.Equal(t, 0, Requests(), "nothing was filed")

	testing.SetRealm(testing.NewUserRealm(zoe))
	id := Apply(cross(cur), "Never mind", "", "thing:1")
	testing.SetRealm(testing.NewUserRealm(kim))
	uassert.AbortsContains(t, cur, grants.ErrNotApplicant.Error(), func() {
		Retract(cross(cur), id)
	})
	testing.SetRealm(testing.NewUserRealm(zoe))
	Retract(cross(cur), id)
	uassert.Equal(t, "withdrawn", program.Board.Get(id).Status.String())

	testing.SetOriginSend(chain.NewCoins())
	testing.SetRealm(testing.NewUserRealm(kim))
	uassert.AbortsContains(t, cur, grants.ErrNothingSent.Error(), func() { Fund(cross(cur)) })
	uassert.Equal(t, 0, len(program.Donations))
}

// The owner can hand out a seat, and once there are two members the bar moves
// to two. That is the path from this personal board to a real one.
func TestProposeMemberGrowsTheBoardAndRaisesTheBar(cur realm, t *testing.T) {
	reset()
	testing.SetRealm(testing.NewUserRealm(zoe))
	uassert.AbortsContains(t, cur, grants.ErrNotMember.Error(), func() {
		ProposeMember(cross(cur), zoe.String(), true, "let me in")
	})

	testing.SetRealm(testing.NewUserRealm(Owner))
	id := ProposeMember(cross(cur), kim.String(), true, "reviews everything anyway")
	testing.SetRealm(testing.NewUserRealm(Owner))
	Vote(cross(cur), id, true, "proposed it")
	uassert.Equal(t, "completed", program.Board.Get(id).Status.String())
	urequire.Equal(t, 2, len(Members()))

	testing.SetRealm(testing.NewUserRealm(zoe))
	next := Apply(cross(cur), "Ship the indexer", "", "alpha:100")
	r := program.Board.Get(next)
	uassert.Equal(t, 2, program.Board.Eligible(r))
	uassert.Equal(t, 2, program.Board.Majority(r), "two members, two signatures")

	testing.SetRealm(testing.NewUserRealm(Owner))
	Vote(cross(cur), next, true, "worth it")
	uassert.Equal(t, "pending", program.Board.Get(next).Status.String(), "the owner is no longer a majority")
	testing.SetRealm(testing.NewUserRealm(kim))
	Vote(cross(cur), next, true, "agreed")
	uassert.Equal(t, "approved", program.Board.Get(next).Status.String())
}

func TestRenderUnknownPaths(t *testing.T) {
	reset()
	uassert.True(t, len(Render("")) > 0)
	uassert.Equal(t, "# moul's grant board\n\nThere is no request 99.\n", Render("request/99"))
	uassert.True(t, len(Render("ledger")) > 0)
	uassert.True(t, len(Render("nope")) > 0)
}

// The case this board exists for: an account with nothing in it cannot pay the
// gas to ask for its first coins, so someone else asks for it. The treasury
// ends where it started, at zero, which is what the pinned pages render.
func TestApplyForPaysTheBeneficiaryNotTheFiler(cur realm, t *testing.T) {
	reset()
	urequire.Equal(t, int64(0), Balance())
	before := balanceOf(kim)

	issue(300)
	testing.SetOriginSend(chain.NewCoins(chain.NewCoin(Denom, 300)))
	testing.SetRealm(testing.NewUserRealm(address(Owner)))
	Fund(cross(cur))

	// zoe files for kim, whose account is empty.
	testing.SetRealm(testing.NewUserRealm(zoe))
	id := ApplyFor(cross(cur), kim.String(), "kim's account is empty, she cannot pay the gas",
		"Fund a first key", "so she can transact at all", "first transfer:300")
	r := program.Board.Get(id)
	urequire.True(t, r.OnBehalf())
	uassert.Equal(t, kim.String(), r.Payee().String())

	// The owner carries it alone, and either party may prove it. Here the
	// filer does, because the payee still cannot send a transaction.
	testing.SetRealm(testing.NewUserRealm(address(Owner)))
	Vote(cross(cur), id, true, "I know kim.")
	testing.SetRealm(testing.NewUserRealm(zoe))
	SubmitProof(cross(cur), id, 0, "text", "she has a key and no coins", "")
	testing.SetRealm(testing.NewUserRealm(address(Owner)))
	Review(cross(cur), id, 0, true, "Sent.")

	uassert.Equal(t, before+300, balanceOf(kim), "the payee got the coins")
	uassert.Equal(t, int64(0), Balance(), "and the treasury is back to empty")
	uassert.Equal(t, kim.String(), program.Payments[0].To.String())

	// A reason is not optional when the payee is someone else.
	testing.SetRealm(testing.NewUserRealm(zoe))
	uassert.AbortsContains(t, cur, "needs a reason", func() {
		ApplyFor(cross(cur), kim.String(), "", "no reason given", "", "x:1")
	})
}

// A realm cannot book a donation. It would receive the user's coins itself,
// then call Fund as many times as it liked, each one reading the same
// OriginSend and naming it a donation, with nothing reaching the treasury.
func TestFundRefusesARealmCaller(cur realm, t *testing.T) {
	reset()
	testing.SetOriginSend(chain.NewCoins(chain.NewCoin(Denom, 1_000_000)))
	testing.SetRealm(testing.NewCodeRealm("gno.land/r/someone/relay"))
	uassert.AbortsContains(t, cur, "called directly by an account", func() { Fund(cross(cur)) })
	uassert.Equal(t, int64(0), Raised(), "nothing booked")
}

render.gno

package grant

import "gno.land/p/g1magld5ptgzaktqcexxq0pgq5lmdf0kz6re8hlv/grants/v0"

// The board's whole front page is these three strings plus the library's
// Renderer. Nothing about the layout lives here, which is the test of whether
// the split worked: a second board is another file this size.
const (
	intro = "A small, personal grant board. moul funds it out of his own pocket, and it\n" +
		"exists mainly so the coding agents working on his repos, and the people he\n" +
		"already works with, can ask for money against work they can prove they did: a\n" +
		"request, a milestone, a link to the merged PR, a tranche. It is open to anyone.\n" +
		"Nothing here is privileged to a bot."

	notofficial = "**This is not a faucet and it is not an official grant program.** It is one\n" +
		"person's money, sent by hand, mostly to people he already knows, and it is also\n" +
		"a proof of concept for the library underneath. There is no entitlement, no queue\n" +
		"and no service level: a request can sit here unanswered, or be refused with one\n" +
		"line of reasoning and nothing further. An official programme, where anyone asks\n" +
		"for tokens and a DAO decides, is a separate thing that does not exist yet, and\n" +
		"this page deliberately does not name a path for it: naming one would read as a\n" +
		"commitment nobody has made."

	scope = "**One member, and the page says so.** A majority of a one-member board is one\n" +
		"signature, so today this is moul deciding in public rather than a DAO deciding.\n" +
		"What makes it worth reading is the record: every ballot carries its reason,\n" +
		"every proof stays up including the refused ones, and every coin out is on the\n" +
		"ledger. A bigger multi-member program is a separate thing and will live at its\n" +
		"own path."

	forothers = "**You can ask for someone else.** `ApplyFor` takes the address the money goes\n" +
		"to and a reason for the detour, and prints both on the request. That is not a\n" +
		"convenience: an account with nothing in it cannot pay the gas to ask for its\n" +
		"first coins, so on a board meant to fund empty accounts, someone else filing is\n" +
		"the only path that works. Either address may then submit the proofs, and neither\n" +
		"may vote on the request."

	agents = "**For agents.** A gno.land account session scoped to this path lets an agent\n" +
		"`Apply` and `SubmitProof` under its own address, so its track record here is\n" +
		"its own and not its operator's. A session cannot be given a board seat by\n" +
		"scoping alone: voting is membership, and membership is a request the board\n" +
		"decides."

	footer = "Built on [p/moul/grants/v0](/p/moul/grants/v0), which holds every rule, every\n" +
		"tally and this page's markdown, and has no idea coins exist."
)

// Render serves the board at "", one request at "request/<id>", and the money
// trail at "ledger".
func Render(path string) string {
	return grants.Renderer{
		Program:  program,
		Title:    "moul's grant board",
		Intro:    intro,
		Notes:    []string{notofficial, scope, forothers, agents},
		Path:     Path,
		Link:     Link,
		Treasury: Address(),
		Balance:  Balance(),
		Footer:   footer,
	}.Render(path)
}

render_example_test.gno

package grant

// ExampleRender pins the board as it is at deploy: one member, no requests,
// an empty treasury. That IS the shipped state, since nothing is seeded here.
// For a board mid-flight, with ballots, refused proofs and a paid tranche,
// see the pinned pages in p/moul/grants/v0's render_test.gno; the markdown is
// generated by the same Renderer.
//
// It calls reset() first: realm globals persist for the whole test binary and
// examples run after every Test. The treasury BALANCE is not a realm global
// and reset() cannot clear it, so the tests are written to be balance-neutral
// (TestApplyApproveProveGetPaid pays out exactly what it funds). A test that
// issues coins and does not spend them shows up as a diff here, which is the
// point.
func ExampleRender() {
	reset()
	print(Render(""))
	// Output:
	// # moul's grant board
	//
	// A small, personal grant board. moul funds it out of his own pocket, and it
	// exists mainly so the coding agents working on his repos, and the people he
	// already works with, can ask for money against work they can prove they did: a
	// request, a milestone, a link to the merged PR, a tranche. It is open to anyone.
	// Nothing here is privileged to a bot.
	//
	// **This is not a faucet and it is not an official grant program.** It is one
	// person's money, sent by hand, mostly to people he already knows, and it is also
	// a proof of concept for the library underneath. There is no entitlement, no queue
	// and no service level: a request can sit here unanswered, or be refused with one
	// line of reasoning and nothing further. An official programme, where anyone asks
	// for tokens and a DAO decides, is a separate thing that does not exist yet, and
	// this page deliberately does not name a path for it: naming one would read as a
	// commitment nobody has made.
	//
	// **One member, and the page says so.** A majority of a one-member board is one
	// signature, so today this is moul deciding in public rather than a DAO deciding.
	// What makes it worth reading is the record: every ballot carries its reason,
	// every proof stays up including the refused ones, and every coin out is on the
	// ledger. A bigger multi-member program is a separate thing and will live at its
	// own path.
	//
	// **You can ask for someone else.** `ApplyFor` takes the address the money goes
	// to and a reason for the detour, and prints both on the request. That is not a
	// convenience: an account with nothing in it cannot pay the gas to ask for its
	// first coins, so on a board meant to fund empty accounts, someone else filing is
	// the only path that works. Either address may then submit the proofs, and neither
	// may vote on the request.
	//
	// **For agents.** A gno.land account session scoped to this path lets an agent
	// `Apply` and `SubmitProof` under its own address, so its track record here is
	// its own and not its operator's. A session cannot be given a board seat by
	// scoping alone: voting is membership, and membership is a request the board
	// decides.
	//
	// ## Treasury
	//
	// | Field | Value |
	// |---|---|
	// | Address | `g1uah596w03ufkslrjfg8erxszvjq3zra6avs37n` |
	// | Balance | 0 ugnot |
	// | Promised | 0 ugnot |
	// | Unpromised | 0 ugnot |
	// | Donated | 0 ugnot |
	// | Paid out | 0 ugnot |
	//
	// ## Board
	//
	// A decision needs a majority of the members eligible to cast a ballot on it,
	// recomputed every time: the party a decision is about never votes on it, so an
	// applicant who sits on the board shrinks the room rather than packing it.
	//
	// | Member | Joined at height |
	// |---|---|
	// | `g1manfred47kzduec920z88wfr64ylksmdcedlf5` | 0 |
	//
	// ## Requests
	//
	// Nothing has been asked of this board yet. `Apply` is open to anyone.
	//
	// ## Where the money went
	//
	// [The ledger](/r/moul/grant/v0:ledger) lists every donation in and every tranche
	// out, with the height, the payee and the milestone it paid for.
	//
	// ## Calling it
	//
	// ```sh
	// # put money in
	// gnokey maketx call -pkgpath gno.land/r/moul/grant/v0 -func Fund -send 5000000ugnot ...
	// # ask for some
	// gnokey maketx call -pkgpath gno.land/r/moul/grant/v0 -func Apply \
	//   -args 'Port the thing' -args 'why it matters' -args 'design:100,ship:400' ...
	// # ask on behalf of someone who cannot pay the gas to ask
	// gnokey maketx call -pkgpath gno.land/r/moul/grant/v0 -func ApplyFor \
	//   -args g1... -args 'their account is empty' \
	//   -args 'Port the thing' -args 'why it matters' -args 'design:100,ship:400' ...
	// # decide (members only)
	// gnokey maketx call -pkgpath gno.land/r/moul/grant/v0 -func Vote -args 1 -args true -args 'reason' ...
	// # show your work, then get paid for it
	// gnokey maketx call -pkgpath gno.land/r/moul/grant/v0 -func SubmitProof \
	//   -args 1 -args 0 -args url -args 'https://...' -args 'what it is' ...
	// gnokey maketx call -pkgpath gno.land/r/moul/grant/v0 -func Review -args 1 -args 0 -args true -args 'looks done' ...
	// ```
	//
	// Built on [p/moul/grants/v0](/p/moul/grants/v0), which holds every rule, every
	// tally and this page's markdown, and has no idea coins exist.
}

// ExampleRenderLedger pins the money trail of a board nobody has funded yet.
func ExampleRenderLedger() {
	reset()
	print(Render("ledger"))
	// Output:
	// # moul's grant board: the ledger
	//
	// Every coin in and every coin out, in the order it happened. Coins sent
	// straight to `g1uah596w03ufkslrjfg8erxszvjq3zra6avs37n` land in the treasury
	// without appearing here, which is why `Fund` exists: it is the same transfer
	// with a name attached.
	//
	// ## In
	//
	// Nothing donated through `Fund` yet.
	//
	// ## Out
	//
	// No tranche has been released yet.
	//
	// Balance now: 0 ugnot. [Back to the board](/r/moul/grant/v0).
}