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

v0 source realm

Package releases is the registry every version of a project asks "am I the latest, and if not, what am I allowed to d...

Readme View source

gno.land/r/moul/releases/v0

The registry every version of a project asks "am I the latest?". One p/moul/releases project per name, owned by the address that opened it, each served as a stage homepage:

path page
"" every project, its latest version, its owner
"<project>" the stage: latest up front, every version with its status and whether it still takes writes, the changelog
"<project>/<version>" one release

The three-line integration

import (
	"chain/runtime/unsafe"
	reg "gno.land/r/moul/releases/v0"
)

var self = unsafe.CurrentRealm().PkgPath() // once, at init

func Render(path string) string { return reg.Banner("myproject", self) + body(path) }
func Post(cur realm, s string)  { reg.AssertWritable("myproject", self); ... }

The getters (Status, IsLatest, Latest, State, AssertWritable, Banner, Owner, StageURL) take no realm and are called without crossing. r/moul/demo/render is the first realm wired this way.

Every lookup is scoped by project name, which the version hard-codes. A path is only judged by the project that names it, so nobody can pause someone else's realm by listing its path as yanked in a project of their own. That is why it is Status(project, path) and not Status(path).

Writes

Crossing, owner only: NewProject (first come, first served, the caller owns it), AddRelease, SetStatus, Deprecate(version, reason, sunset), Yank, SetSuccessor, SetDescription, TransferProject. A status is a word: draft, prerelease, supported, deprecated, yanked, vulnerable; latest is computed and refused.

Seeded

init lists the r/moul realms that already ship two versions, owned by moul: config, faucet and render, each with v0 deprecated (no sunset) and v1 latest. The x/ experiments are left out on purpose.

Public, on purpose

Every guarded version imports this realm, and a private realm cannot be imported. So its code is frozen at the first deploy, and the API is kept to what a version needs. The state stays writable.

Known limit

A version already on chain is immutable and cannot gain the import. It is listed and labelled here, and only the stage page and the newer versions say it is old.


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

On mainnet: deployment status transactions unique callers deployed revision

Dependency graph:

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

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

Overview

Package releases is the registry every version of a project asks "am I the latest, and if not, what am I allowed to do?".

It stores one p/moul/releases Project per name, each owned by the address that opened it, and serves each one's stage homepage at its render path: /r/moul/releases/v0:<project>. The library is gno.land/p/moul/releases/v0; this realm is its state and its demo.

The integration, in a version

Example
1import (
2	"chain/runtime/unsafe"
3	reg "gno.land/r/moul/releases/v0"
4)
5
6var self = unsafe.CurrentRealm().PkgPath() // computed once, at init
7
8func Render(path string) string { return reg.Banner("myproject", self) + body(path) }
9func Post(cur realm, s string) { reg.AssertWritable("myproject", self); … }

The getters take no realm, so a version calls them without crossing. Every lookup is scoped by project name, which the version hard-codes: a path is only ever judged by the project that names it, so nobody can pause someone else's realm by listing its path as yanked in a project of their own.

Functions 16

func AddRelease

crossing Action
1func AddRelease(cur realm, project, version, pkgPath, url, notes, status string)
source

AddRelease lists a version. status is a word: draft, prerelease, supported, deprecated, yanked or vulnerable.

func AssertWritable

Action
1func AssertWritable(project, pkgPath string)
source

AssertWritable aborts unless the release at pkgPath still accepts writes: it is not yanked, not vulnerable, and not past a deprecation sunset.

func Banner

Action
1func Banner(project, pkgPath string) string
source

Banner is the markdown the release at pkgPath prepends to its Render: "" for the latest or an unlisted path, a one-paragraph notice otherwise.

func Deprecate

crossing Action
1func Deprecate(cur realm, project, version, reason string, sunset int64)
source

Deprecate marks a version deprecated: it keeps working, with a banner, until block height sunset, and is read-only from then on. 0 is never.

func IsLatest

Action
1func IsLatest(project, pkgPath string) bool
source

IsLatest reports whether pkgPath is project's latest supported release.

func Latest

Action
1func Latest(project string) (version, pkgPath string, ok bool)
source

Latest returns project's latest supported release.

func NewProject

crossing Action
1func NewProject(cur realm, name, description string)
source

NewProject opens a project owned by the caller. First come, first served: a name is taken for good, which is why a version names its project in code before it ships.

func Render

1func Render(path string) string
source

Render serves the index of projects at "", a project's stage homepage at "<project>", and one release at "<project>/<version>". Every owner string is escaped by the library, which is where the markdown is built.

func SetDescription

crossing Action
1func SetDescription(cur realm, project, description string)
source

SetDescription replaces a project's one-line description.

func SetStatus

crossing Action
1func SetStatus(cur realm, project, version, status, reason string)
source

SetStatus moves a version to a status word, with the reason readers see.

func SetSuccessor

crossing Action
1func SetSuccessor(cur realm, project, version, successor string)
source

SetSuccessor sends readers of version to successor instead of to Latest.

func StageURL

Action
1func StageURL(project string) string
source

StageURL is the link to a project's stage homepage.

func State

Action
1func State(project, pkgPath string) pausable.State
source

State is the pause state the release at pkgPath is in at the current block, the zero (running) State when it is not listed.

func Status

Action
1func Status(project, pkgPath string) (rel.Status, bool)
source

Status is what project says about the release at pkgPath, with Latest computed. ok is false when the project or the path is not listed.

func TransferProject

crossing Action
1func TransferProject(cur realm, project string, to address)
source

TransferProject hands a project to another address.

func Yank

crossing Action
1func Yank(cur realm, project, version, reason string)
source

Yank withdraws a version for good. It stays listed and accepts nothing.

Dependencies

Source Files 5