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

README.md

3.71 Kb · 82 lines

gno.land/p/moul/releases/v0

A project's changelog, and the answer every version of it needs: am I the latest, and if not, what am I still allowed to do? A revival of the quarantined p/demo/releases from gnolang/gno, extended with a status per version, a pause policy, and the banner an old version prepends to its page.

The state lives in r/moul/releases, which is also the live demo: one Project per name, each served as a stage homepage.

Status

status stored writes banner
📝 draft yes allowed "a draft"
🧪 prerelease yes allowed "a prerelease"
✅ supported yes allowed "still supported, the latest is ..."
🌟 latest computed allowed none
⚠️ deprecated yes allowed until its sunset height, read-only from it "deprecated, read-only from block N"
🚫 yanked yes, final paused "yanked, it accepts nothing"
🔴 vulnerable yes, can only be yanked paused "vulnerable, it accepts nothing"

Latest is the most recently added Supported release, computed on read, so shipping v2 never means rewriting v1. Severity() orders statuses by how much a reader should worry, Latest 0 to Vulnerable 5.

Policy: status and height in, pause state out

Policy(release, height) returns a p/moul/pausable State. It is a pure function of the stored status and the block height, so a deprecated version goes read-only at its sunset block with no transaction from anyone. An unknown status fails closed (paused); an unlisted path is running, because a registry that paused what it had not heard of would let a typo take a realm down.

API

p, _ := releases.NewProject("config", "moul's shared settings")
p.Add("v0", "gno.land/r/moul/config/v0", "", "first cut", releases.Supported, height)
p.Add("v1", "gno.land/r/moul/config/v1", "", "- pause levels", releases.Supported, height)
p.Deprecate("v0", "use v1", height+100000) // read-only from that block
p.Yank("v0", "leaks keys")                  // final

p.Latest()                    // Release{Version: "v1", ...}, true
p.ByVersion("v0"), p.ByPath("gno.land/r/moul/config/v0")
p.State(path, height)         // pausable.State
p.AssertWritable(path, height)
p.Banner(path, height, stageURL)  // "" for the latest
p.RenderStage(height, linkFn), p.RenderRelease("v0", height)

Lookups return a Release by value. The original ByVersion returned a pointer to a range-loop copy, which looked like a handle on the stored release and was not; there is no pointer here to get wrong. Storage is two p/nt/bptree indexes (version, package path) plus the insertion order.

Every owner-typed string (description, notes, reason, URL) is escaped where the markdown is built, because the registry is public and anyone can open a project in it.

Known limit

A version already on chain is immutable: it cannot gain the import. It can only be listed and labelled here, and its stage page and the newer versions say it is old. Only versions written after this package can show the banner and pause themselves.


Part of moul/gno-contracts — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.

Dependency graph:

gno.land/p/moul/releases/v0 dependency graph

⚠️ Disclaimer: provided as-is, without warranty; not security-audited. Full disclaimer: DISCLAIMER.