1// Package init provides basic user registration.2//3// SECURITY: every public function in this package is genesis-only. The4// realm exists to seed initial users into r/sys/users at chain genesis5// and to register itself as a controller. After genesis (block height6// > 0), no caller may use these functions.7//8// Without the genesis-only gate, the wide-open `RegisterUser` wrapper9// would let any EOA land-grab any name (including reserved-sounding10// names like "administrator" or "vitalik") to any address — for free,11// without the namereg/v0 payment, blacklist, or canonical-collision12// checks. The gate closes that bypass.13//14// Post-genesis user registration must go through a whitelisted15// controller that enforces its own policy (e.g. r/sys/namereg/v0).16package init1718import (19 "chain"20 "chain/runtime"2122 "gno.land/r/sys/users"23)2425// Bootstrap registers this package as a controller in r/sys/users.26// Genesis-only via AddControllerAtGenesis's own height==0 gate.27func Bootstrap(cur realm) {28 users.AddControllerAtGenesis(cross(cur), chain.PackageAddress("gno.land/r/sys/users/init"))29}3031// RegisterUser registers a new user in r/sys/users at chain genesis.32// PANICS if called after genesis (height > 0).33//34// Uses RegisterUserIgnoreCanonical: the genesis seed set is curated, and35// any deliberate confusable reservations (e.g. registering both `vitalik`36// and `vital1k` to two different addresses) must not abort chain bring-37// up. Decision #14 (later-wins) applies, so order in genesis_txs.jsonl38// determines which name owns the canonical pointer when stems collide.39func RegisterUser(cur realm, name string, addr address) {40 if runtime.ChainHeight() != 0 {41 panic("r/sys/users/init.RegisterUser: genesis-only; use a whitelisted controller post-genesis (e.g. r/sys/namereg/v0.Register)")42 }43 if err := users.RegisterUserIgnoreCanonical(cross(cur), name, addr); err != nil {44 panic(err)45 }46}47Bootstrap(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string})
RegisterUser(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, name string, addr string)
Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.
vm/qrender output, sanitized (docs/render-security.md) and displayed in an empty-sandbox iframe — scripts, forms and popups cannot run. Links stay inert in-preview; right-click to open.