Playground
gnomod.toml
module = "gno.land/r/moul/gnopm/registry/v0" gno = "0.9" private = true [addpkg] creator = "g1manfred47kzduec920z88wfr64ylksmdcedlf5" height = 410018 max_deposit = "14000000ugnot"
helpers_test.gno
package registry
import (
pm "gno.land/p/moul/gnopm/v0"
"gno.land/p/nt/testutils/v0"
)
// Deterministic, checksum-valid test addresses. Made rather than typed: the
// address-namespace rule turns on the bech32 alphabet, which drops 1, b, i and
// o, so a plausible-looking hand-written "g1..." fails the check for a reason
// that has nothing to do with what is under test.
var (
alice = testutils.TestAddress("alice")
bob = testutils.TestAddress("bob")
// alicePkg sits in alice's OWN address namespace, which is the only
// ownership a test can create: r/sys/users is not writable from a unit
// test, so a name namespace can never resolve to a test account.
alicePkg = "gno.land/r/" + alice.String() + "/scratch/v0"
)
const (
repoURL = "https://github.com/moul/gno-contracts"
sha1Zero = "0000000000000000000000000000000000000000"
sha1One = "1111111111111111111111111111111111111111"
otherPkg = "gno.land/p/moul/md/v1"
)
// reset puts the realm back to its initial state. Realm globals persist for the
// whole test binary and examples run after every Test, so anything that renders
// starts from a known tree or its pinned output silently depends on test order.
func reset() { reg = pm.New() }
// seedFixture builds a deterministic registry straight through the library: no
// chain context needed, which is what lets an Example use it. Going through the
// library rather than through Register also skips the crossing call, which an
// example cannot make.
func seedFixture() {
reset()
reg.Register(alice, 100, alicePkg, repoURL, sha1Zero, "scratch", "refs/tags/v0.1.0")
reg.Register(bob, 110, alicePkg, "https://github.com/bob/impostor", sha1One, "", "")
reg.Register(alice, 120, otherPkg, repoURL, sha1One, "p/moul/md", "")
}
registry.gno
// Package registry is an open, on-chain map from a deployed gno package path
// back to the source that produced it: repository, commit, directory.
//
// It is the realm half of gno.land/p/moul/gnopm/v0, which holds the domain
// model and the whole of the reasoning; this file is wiring. Every exported
// mutation is a crossing function that resolves the caller, forwards to the
// library, aborts on error (the only way to revert state in gno) and emits an
// event for indexers.
//
// # It cannot promise, and does not pretend to
//
// Nothing here is verified and nothing here can be. A realm cannot clone a
// repository, so it cannot check that the bytes at the claimed commit are the
// bytes deployed at the claimed path. What it stores is testimony under a
// signature: this address says this package came from that source.
//
// That is still worth storing, for two reasons.
//
// First, it is testimony in the exact shape a verifier needs. Path, repository,
// commit and directory are precisely the four inputs to "hash the addpkg
// payload of that directory and compare it with what the chain hands back",
// which gnopm already does against a local tree (`gnopm verify -deployed`). The
// registry does not answer the question; it makes the question answerable by
// anything that can clone.
//
// Second, the chain knows who signed. A claim from the address that owns the
// package path's namespace comes from the party that controls the path, and
// OwnedBy reports that. It is computed on every read, never stored, because a
// name can be transferred and a stored answer would rot into exactly the kind
// of stale claim this realm exists to distinguish from a live one.
//
// # Open, and tagged
//
// Anyone may claim any path, including one they had nothing to do with. That is
// deliberate: gating registration on namespace ownership would leave the map
// empty on day one, when almost nothing has been registered by its own
// deployer, and an empty registry teaches nobody anything. A stranger's claim
// is not suppressed, it is labelled and ranked below the owner's, and Render
// never presents an unverified claim as a fact.
//
// A claimant may always withdraw their own claim, and may never touch anyone
// else's.
package registry
import (
"chain"
"chain/runtime"
pm "gno.land/p/moul/gnopm/v0"
"gno.land/r/sys/users"
)
var reg = pm.New()
// caller is the address that crossed into this realm. Deliberately not
// restricted to end users: a realm may hold a namespace, and a DAO registering
// the source of the packages it governs is the same operation.
func caller(cur realm) address {
if !cur.IsCurrent() {
panic("gnopm/registry: spoofed realm")
}
return cur.Previous().Address()
}
func must(err error) {
if err != nil {
panic(err)
}
}
// resolveName is the r/sys/users half of the ownership rule, passed to the
// library so the library stays pure.
//
// isCurrent is deliberately ignored, matching r/moul/forge: a name that
// resolves through an alias still resolves to the same holder, so a namespace
// survives its owner renaming. IsDeleted folds the nil check in, which is what
// its own doc comment asks call sites to rely on.
func resolveName(name string) (address, bool) {
data, _ := users.ResolveName(name)
if data.IsDeleted() {
return "", false
}
return data.Addr(), true
}
// Register records that pkgPath was built from dir of repo at commit.
//
// Calling it again for the same path replaces the caller's own claim and
// nobody else's, so moving a claim to a new commit after a redeploy is one
// call with no read first.
//
// ref is optional and is never the thing verified: a ref moves, a commit does
// not. It is recorded so a reader can tell a claim pinned to a released tag
// from one pinned to a commit on nobody's branch, and so a verifier can report
// a commit that has since been orphaned by a force-push.
//
// dir is empty when the package sits at the repository root.
func Register(cur realm, pkgPath, repo, commit, dir, ref string) {
a := caller(cur)
_, err := reg.Register(a, runtime.ChainHeight(), pkgPath, repo, commit, dir, ref)
must(err)
chain.Emit("SourceClaimed",
"pkgpath", pkgPath,
"claimant", a.String(),
"repo", repo,
"commit", commit,
)
}
// Withdraw removes the caller's own claim about pkgPath.
func Withdraw(cur realm, pkgPath string) {
a := caller(cur)
must(reg.Withdraw(a, pkgPath))
chain.Emit("SourceWithdrawn", "pkgpath", pkgPath, "claimant", a.String())
}
// PackageCount is how many package paths carry at least one claim.
func PackageCount() int { return reg.Size() }
// ClaimCount is the total number of claims across every path.
func ClaimCount() int { return reg.Claims() }
// HasClaims reports whether anything has been said about pkgPath. Cheap enough
// for another realm or an indexer to ask per package.
func HasClaims(pkgPath string) bool { return reg.Package(pkgPath) != nil }
// OwnerClaim returns the repository, commit and directory claimed by the party
// that owns pkgPath's namespace, and whether such a claim exists.
//
// This is the only read that filters, and it filters on the one signal the
// chain can actually prove. Everything else a caller wants is in Render or in
// the events.
func OwnerClaim(pkgPath string) (repo, commit, dir string, ok bool) {
p := reg.Package(pkgPath)
if p == nil {
return "", "", "", false
}
p.IterateClaims(func(c *pm.Claim) bool {
if c.OwnedBy(resolveName) {
repo, commit, dir, ok = c.Repo, c.Commit, c.Dir, true
return true // stop
}
return false
})
return repo, commit, dir, ok
}
registry_test.gno
package registry
import (
"strings"
"testing"
"gno.land/p/nt/uassert/v0"
)
func TestRegisterAndWithdraw(cur realm, t *testing.T) {
reset()
testing.SetRealm(testing.NewUserRealm(alice))
Register(cross(cur), otherPkg, repoURL, sha1Zero, "p/moul/md", "refs/heads/main")
uassert.Equal(t, 1, PackageCount())
uassert.Equal(t, 1, ClaimCount())
uassert.True(t, HasClaims(otherPkg))
uassert.False(t, HasClaims("gno.land/p/moul/nope/v0"))
testing.SetRealm(testing.NewUserRealm(alice))
Withdraw(cross(cur), otherPkg)
uassert.Equal(t, 0, PackageCount())
uassert.False(t, HasClaims(otherPkg))
}
// A claim is the claimant's own. Nobody else may take it back, and the refusal
// has to abort rather than silently do nothing: a Withdraw that quietly did
// nothing reads to the caller exactly like one that worked.
func TestWithdrawIsNotTransferable(cur realm, t *testing.T) {
reset()
testing.SetRealm(testing.NewUserRealm(alice))
Register(cross(cur), otherPkg, repoURL, sha1Zero, "", "")
testing.SetRealm(testing.NewUserRealm(bob))
uassert.AbortsContains(t, cur, "no such claim", func() {
Withdraw(cross(cur), otherPkg)
})
uassert.True(t, HasClaims(otherPkg), "alice's claim survived bob")
}
func TestRegisterAborts(cur realm, t *testing.T) {
reset()
cases := []struct {
name string
pkgPath, repo, commit, dir, ref string
contains string
}{
{"bad path", "nonsense", repoURL, sha1Zero, "", "", "invalid package path"},
{"non-https repo", otherPkg, "javascript:alert(1)", sha1Zero, "", "", "invalid repository URL"},
{"abbreviated commit", otherPkg, repoURL, "0123456", "", "", "invalid commit id"},
{"absolute dir", otherPkg, repoURL, sha1Zero, "/etc", "", "invalid directory"},
{"unqualified ref", otherPkg, repoURL, sha1Zero, "", "main", "invalid ref name"},
}
for _, tc := range cases {
testing.SetRealm(testing.NewUserRealm(alice))
uassert.AbortsContains(t, cur, tc.contains, func() {
Register(cross(cur), tc.pkgPath, tc.repo, tc.commit, tc.dir, tc.ref)
}, tc.name)
}
uassert.Equal(t, 0, ClaimCount(), "nothing was stored")
}
// OwnerClaim is the only read that filters, and it filters on the one thing
// about a claim the chain can prove. An address namespace belongs to that
// account with nothing registered anywhere, so it is testable without
// r/sys/users, which a test cannot write to.
func TestOwnerClaim(cur realm, t *testing.T) {
reset()
testing.SetRealm(testing.NewUserRealm(bob))
Register(cross(cur), alicePkg, "https://github.com/bob/impostor", sha1One, "", "")
_, _, _, ok := OwnerClaim(alicePkg)
uassert.False(t, ok, "a stranger's claim is not the owner's")
testing.SetRealm(testing.NewUserRealm(alice))
Register(cross(cur), alicePkg, repoURL, sha1Zero, "scratch", "")
repo, commit, dir, ok := OwnerClaim(alicePkg)
uassert.True(t, ok, "the namespace holder's claim is found")
uassert.Equal(t, repoURL, repo)
uassert.Equal(t, sha1Zero, commit)
uassert.Equal(t, "scratch", dir)
_, _, _, ok = OwnerClaim("gno.land/p/moul/nothing/v0")
uassert.False(t, ok, "an unclaimed path has no owner claim")
}
// Re-registering moves the caller's own claim and creates no second one.
func TestReregister(cur realm, t *testing.T) {
reset()
testing.SetRealm(testing.NewUserRealm(alice))
Register(cross(cur), otherPkg, repoURL, sha1Zero, "p/moul/md", "")
testing.SkipHeights(10)
testing.SetRealm(testing.NewUserRealm(alice))
Register(cross(cur), otherPkg, repoURL, sha1One, "p/moul/md", "refs/tags/v1")
uassert.Equal(t, 1, ClaimCount())
got := Render(otherPkg)
uassert.True(t, strings.Contains(got, sha1One[:12]), "the new commit renders")
uassert.False(t, strings.Contains(got, sha1Zero[:12]), "the old one is gone")
uassert.True(t, strings.Contains(got, "| last updated | block"), "an updated claim says when")
}
// A package path arrives at Render already split on "/", so the routing is the
// rejoin. Anything that does not reassemble into a path is a miss, and a miss
// must not render as an empty package page.
func TestRenderRouting(t *testing.T) {
reset()
uassert.True(t, strings.Contains(Render("nonsense"), "Not found"), "one bad element")
uassert.True(t, strings.Contains(Render("a/b/c"), "Not found"), "too few elements")
uassert.True(t, strings.Contains(Render("help"), "How this registry works"), "help page")
uassert.True(t, strings.Contains(Render(""), "gnopm source registry"), "home")
uassert.True(t, strings.Contains(Render(otherPkg), "Nobody has claimed"), "valid but unclaimed")
}
// The page ranks the owner's claim above a stranger's and says which is which.
// Rendering them identically is the whole mistake this realm exists to avoid,
// so the separation is pinned rather than left to review.
func TestRenderSeparatesOwnerFromStranger(t *testing.T) {
seedFixture()
got := Render(alicePkg)
iOwner := strings.Index(got, "Claimed by the namespace owner")
iOthers := strings.Index(got, "Claimed by others")
uassert.True(t, iOwner >= 0, "the owner section exists")
uassert.True(t, iOthers >= 0, "the others section exists")
uassert.True(t, iOwner < iOthers, "the owner is ranked first")
uassert.True(t, strings.Contains(got, "impostor"), "a stranger's claim is shown, not hidden")
uassert.True(t, strings.Contains(got, "do not own"), "and is labelled as not the owner's")
}
render.gno
package registry
import (
"chain/runtime"
"chain/runtime/unsafe"
"strconv"
"strings"
pm "gno.land/p/moul/gnopm/v0"
"gno.land/p/moul/md/v0"
"gno.land/p/moul/realmpath/v0"
"gno.land/p/moul/txlink/v0"
)
// untrusted-render: every STORED field is charset-validated at write time by
// gno.land/p/moul/gnopm/v0 (ValidPkgPath, ValidRepo, ValidCommit, ValidDir,
// ValidRef). Each is an allowlist, so a stored field cannot hold a backtick, a
// pipe, a bracket, a control character or a bidi override, and therefore needs
// no escaping at any of the several places one claim is shown. Validating once
// at the write beats escaping at every read, and it is why ValidRef is narrower
// than git's own rule: one denylist field would have undone it for all of them.
//
// The one string here that is NOT validated is the render path itself, which
// arrives from the URL and is echoed back by notFound. That one is escaped.
// pageSize bounds every listing: a Render that walks unbounded state is a
// Render that eventually stops rendering.
const pageSize = 20
// Render routes gnoweb paths:
//
// / every claimed package path
// /<package path> the claims about one package
// /help what this realm is, and how to write to it
func Render(path string) string {
req := realmpath.Parse(path)
parts := req.PathParts()
if len(parts) == 0 || parts[0] == "" {
return renderHome(pageOf(req))
}
if len(parts) == 1 && parts[0] == "help" {
return renderHelp()
}
// A package path contains slashes, so it arrives split. Rejoining is the
// whole of the routing: anything that reassembles into a valid path is a
// package page, anything else is a miss.
pkgPath := strings.Join(parts, "/")
if !pm.ValidPkgPath(pkgPath) {
return notFound(pkgPath + " is not a package path")
}
return renderPackage(pkgPath)
}
func base() string {
return strings.TrimPrefix(unsafe.CurrentRealm().PkgPath(), runtime.ChainDomain())
}
func pkgURL(pkgPath string) string { return base() + ":" + pkgPath }
// link does not escape its text, because every call site passes a field that is
// charset-validated at write time (see the note above). Escaping here would
// turn "gno.land/p/moul/md/v1" into "gno\.land/p/moul/md/v1" on every row of
// every listing, for no safety anyone gains.
func link(text, url string) string { return "[" + text + "](" + url + ")" }
// join glues blocks with exactly one blank line between them.
//
// gno collapses two consecutive blank lines inside an example's // Output:
// block, exactly as Go does, so a Render that ever emits them cannot be pinned
// by an example at all. Appending "\n" by hand as sections are built is how a
// Render acquires them; assembling a list of blocks and joining once is how it
// stops. Every block arrives without its own leading or trailing blank.
func join(blocks []string) string {
for i, b := range blocks {
blocks[i] = strings.Trim(b, "\n")
}
return strings.Join(blocks, "\n\n") + "\n"
}
func pageOf(req *realmpath.Request) int {
n, err := strconv.Atoi(req.Query.Get("page"))
if err != nil || n < 1 {
return 1
}
return n
}
// notFound echoes the requested path, which is the only untrusted string this
// file handles: it comes from the URL and has already failed validation by the
// time we are here. It is escaped rather than dropped, because "that is not a
// package path" without saying which one is an unhelpful error.
func notFound(why string) string {
return md.H1("Not found") + "\n" + md.EscapeText(why) + ".\n\n" + link("Back to the registry", base()) + "\n"
}
func renderHome(page int) string {
var b strings.Builder
b.WriteString(md.H1("gnopm source registry"))
b.WriteString("\nWhere a deployed package says it came from. Every entry is a claim made by whoever signed it, never a verified fact: this realm cannot clone a repository, so it records testimony in the shape a verifier needs and labels who said it.\n")
b.WriteString("\n**Packages:** " + strconv.Itoa(reg.Size()) + " · **Claims:** " + strconv.Itoa(reg.Claims()) + "\n")
if reg.Size() == 0 {
b.WriteString("\nNothing claimed yet. " + link("Register the first package", txlink.Call("Register")) + "\n")
b.WriteString("\n" + link("How this works", base()+":help") + "\n")
return b.String()
}
b.WriteString("\n| package | claims | owner has claimed |\n")
b.WriteString("| --- | ---: | --- |\n")
rows := 0
reg.IteratePackages((page-1)*pageSize, pageSize, func(p *pm.Package) bool {
rows++
owner := "no"
if _, _, _, ok := OwnerClaim(p.PkgPath); ok {
owner = "yes"
}
b.WriteString("| " + link(p.PkgPath, pkgURL(p.PkgPath)) +
" | " + strconv.Itoa(p.Count()) +
" | " + owner + " |\n")
return false
})
if p := pager(page, rows); p != "" {
b.WriteString("\n" + p + "\n")
}
b.WriteString("\n" + link("How this works", base()+":help") + "\n")
return b.String()
}
func pager(page, rows int) string {
var parts []string
if page > 1 {
parts = append(parts, link("previous", base()+"?page="+strconv.Itoa(page-1)))
}
if rows == pageSize {
parts = append(parts, link("next", base()+"?page="+strconv.Itoa(page+1)))
}
return strings.Join(parts, " · ")
}
func renderPackage(pkgPath string) string {
p := reg.Package(pkgPath)
if p == nil {
return join([]string{
md.H1(pkgPath),
"Nobody has claimed a source for this package.",
link("Claim it", txlink.Call("Register", "pkgPath", pkgPath)),
link("Back to the registry", base()),
})
}
// The namespace owner first, then everyone else. The ordering IS the
// tagging: no ranking is stored, it is recomputed here from the one thing
// about a claim that the chain can actually prove.
var owner, others []*pm.Claim
p.IterateClaims(func(c *pm.Claim) bool {
if c.OwnedBy(resolveName) {
owner = append(owner, c)
} else {
others = append(others, c)
}
return false
})
ns := md.InlineCode(pm.Namespace(pkgPath))
blocks := []string{
md.H1(pkgPath),
strconv.Itoa(p.Count()) + " claim(s). A claim is what an address said, not what anyone checked.",
}
if len(owner) > 0 {
blocks = append(blocks,
md.H2("Claimed by the namespace owner"),
"The signer owns "+ns+", so this claim comes from the party that controls the path. That is not a proof the source matches. It is a proof of who is speaking.")
for _, c := range owner {
blocks = append(blocks, claimBlock(c))
}
}
if len(others) > 0 {
blocks = append(blocks,
md.H2("Claimed by others"),
"These addresses do not own "+ns+". A third party may be filling in the map honestly, or pointing at a repository that has nothing to do with this package. Read the source before trusting either.")
for _, c := range others {
blocks = append(blocks, claimBlock(c))
}
}
return join(append(blocks, link("Back to the registry", base())))
}
func claimBlock(c *pm.Claim) string {
var b strings.Builder
b.WriteString("| field | value |\n| --- | --- |\n")
b.WriteString("| claimant | " + md.InlineCode(c.Claimant.String()) + " |\n")
b.WriteString("| commit | " + link(c.Commit[:12], c.SourceURL()) + " |\n")
b.WriteString("| repository | " + link(c.Repo, c.Repo) + " |\n")
dir := c.Dir
if dir == "" {
dir = "(repository root)"
}
b.WriteString("| directory | " + md.InlineCode(dir) + " |\n")
if c.Ref != "" {
b.WriteString("| ref | " + md.InlineCode(c.Ref) + " |\n")
}
b.WriteString("| claimed at | block " + strconv.FormatInt(c.Height, 10) + " |\n")
updated := "never"
if c.UpdatedAt != c.Height {
updated = "block " + strconv.FormatInt(c.UpdatedAt, 10)
}
b.WriteString("| last updated | " + updated + " |")
return b.String()
}
func renderHelp() string {
var b strings.Builder
b.WriteString(md.H1("How this registry works"))
b.WriteString("\nA gno import path is a chain address, not a repository URL, so nothing on chain says where a deployed package came from. This realm is where an address can say so.\n")
b.WriteString("\n" + md.H2("What it proves"))
b.WriteString("\nNothing on its own, and that is the honest answer. A realm cannot clone a repository, so it cannot check that the code at a commit is the code at a path. Three claims get confused with each other and only two of them can ever be settled:\n\n")
b.WriteString("| claim | provable |\n| --- | --- |\n")
b.WriteString("| this package came from that repository | no. Not here and not anywhere: anyone may deploy any bytes and claim any repository |\n")
b.WriteString("| the deployed bytes equal the addpkg payload of that directory at that commit | yes, by hashing both sides. Off chain, by anything that can clone |\n")
b.WriteString("| the claimant owns this path's namespace | yes, from chain data, and it is recomputed on every read |\n")
b.WriteString("\n" + md.H2("Writing to it"))
b.WriteString("\nRegister the source of a package you deployed. Calling it again replaces your own claim and nobody else's, which is how you move a claim to a new commit after a redeploy.\n\n")
b.WriteString(link("Register", txlink.Call("Register")) + " · " + link("Withdraw", txlink.Call("Withdraw")) + "\n")
b.WriteString("\nFields: the full package path, an https repository URL, a 40 or 64 character lowercase hex commit, the subdirectory holding the package (empty for the repository root), and optionally a fully-qualified ref such as " + md.InlineCode("refs/tags/v1.2.0") + ".\n")
b.WriteString("\nAnyone may claim any path. A claim from an address that does not own the namespace is not hidden: it is shown under its own heading and ranked below the owner's.\n")
b.WriteString("\n" + link("Back to the registry", base()) + "\n")
return b.String()
}
render_test.gno
package registry
// ExampleRender pins the realm's Render output, which is its whole public
// surface. Each example calls seedFixture first: realm globals persist for the
// whole test binary and examples run after every Test, so without the reset the
// pinned output would silently depend on test order.
func ExampleRender() {
seedFixture()
print(Render(""))
// Output:
// # gnopm source registry
//
// Where a deployed package says it came from. Every entry is a claim made by whoever signed it, never a verified fact: this realm cannot clone a repository, so it records testimony in the shape a verifier needs and labels who said it.
//
// **Packages:** 2 · **Claims:** 3
//
// | package | claims | owner has claimed |
// | --- | ---: | --- |
// | [gno.land/p/moul/md/v1](/r/moul/gnopm/registry/v0:gno.land/p/moul/md/v1) | 1 | no |
// | [gno.land/r/g1v9kxjcm9ta047h6lta047h6lta047h6lzd40gh/scratch/v0](/r/moul/gnopm/registry/v0:gno.land/r/g1v9kxjcm9ta047h6lta047h6lta047h6lzd40gh/scratch/v0) | 2 | yes |
//
// [How this works](/r/moul/gnopm/registry/v0:help)
}
// The package page is the one that matters: an owner's claim and a stranger's
// claim about the same path, under separate headings, owner first. The pinned
// output is what stops that distinction being quietly refactored away.
func ExampleRender_package() {
seedFixture()
print(Render(alicePkg))
// Output:
// # gno.land/r/g1v9kxjcm9ta047h6lta047h6lta047h6lzd40gh/scratch/v0
//
// 2 claim(s). A claim is what an address said, not what anyone checked.
//
// ## Claimed by the namespace owner
//
// The signer owns `g1v9kxjcm9ta047h6lta047h6lta047h6lzd40gh`, so this claim comes from the party that controls the path. That is not a proof the source matches. It is a proof of who is speaking.
//
// | field | value |
// | --- | --- |
// | claimant | `g1v9kxjcm9ta047h6lta047h6lta047h6lzd40gh` |
// | commit | [000000000000](https://github.com/moul/gno-contracts/tree/0000000000000000000000000000000000000000/scratch) |
// | repository | [https://github.com/moul/gno-contracts](https://github.com/moul/gno-contracts) |
// | directory | `scratch` |
// | ref | `refs/tags/v0.1.0` |
// | claimed at | block 100 |
// | last updated | never |
//
// ## Claimed by others
//
// These addresses do not own `g1v9kxjcm9ta047h6lta047h6lta047h6lzd40gh`. A third party may be filling in the map honestly, or pointing at a repository that has nothing to do with this package. Read the source before trusting either.
//
// | field | value |
// | --- | --- |
// | claimant | `g1vfhkyh6lta047h6lta047h6lta047h6l03vdhu` |
// | commit | [111111111111](https://github.com/bob/impostor/tree/1111111111111111111111111111111111111111) |
// | repository | [https://github.com/bob/impostor](https://github.com/bob/impostor) |
// | directory | `(repository root)` |
// | claimed at | block 110 |
// | last updated | never |
//
// [Back to the registry](/r/moul/gnopm/registry/v0)
}
func ExampleRender_unclaimed() {
seedFixture()
print(Render("gno.land/p/moul/nothing/v0"))
// Output:
// # gno.land/p/moul/nothing/v0
//
// Nobody has claimed a source for this package.
//
// [Claim it](/r/moul/gnopm/registry/v0$help&func=Register&pkgPath=gno.land%2Fp%2Fmoul%2Fnothing%2Fv0)
//
// [Back to the registry](/r/moul/gnopm/registry/v0)
}
func ExampleRender_help() {
seedFixture()
print(Render("help"))
// Output:
// # How this registry works
//
// A gno import path is a chain address, not a repository URL, so nothing on chain says where a deployed package came from. This realm is where an address can say so.
//
// ## What it proves
//
// Nothing on its own, and that is the honest answer. A realm cannot clone a repository, so it cannot check that the code at a commit is the code at a path. Three claims get confused with each other and only two of them can ever be settled:
//
// | claim | provable |
// | --- | --- |
// | this package came from that repository | no. Not here and not anywhere: anyone may deploy any bytes and claim any repository |
// | the deployed bytes equal the addpkg payload of that directory at that commit | yes, by hashing both sides. Off chain, by anything that can clone |
// | the claimant owns this path's namespace | yes, from chain data, and it is recomputed on every read |
//
// ## Writing to it
//
// Register the source of a package you deployed. Calling it again replaces your own claim and nobody else's, which is how you move a claim to a new commit after a redeploy.
//
// [Register](/r/moul/gnopm/registry/v0$help&func=Register) · [Withdraw](/r/moul/gnopm/registry/v0$help&func=Withdraw)
//
// Fields: the full package path, an https repository URL, a 40 or 64 character lowercase hex commit, the subdirectory holding the package (empty for the repository root), and optionally a fully-qualified ref such as `refs/tags/v1.2.0`.
//
// Anyone may claim any path. A claim from an address that does not own the namespace is not hidden: it is shown under its own heading and ranked below the owner's.
//
// [Back to the registry](/r/moul/gnopm/registry/v0)
}