v0 source pure
Package ownable proposes an abstraction around the ownership which provides various kind of owners and some compositi...
View source
gno.land/p/nym-moultest123/ownable
🚧 API sketch, not an implementation. The types below are declared; the two composition helpers
panic("not implemented"). Nothing here works yet. Do not import it expecting behaviour.
A proposal for one Owner interface covering every kind of thing that can own
a realm, so that ownership checks stop being written four different ways.
1type Owner interface {
2 Addr() address
3 Kind() Kind
4 owner() // unexported: only this package may implement Owner
5}
Four owner kinds are declared: UserOwner (an address), RealmOwner (a
runtime.Realm), MembstoreOwner and DAOOwner (both still empty structs,
waiting on the membstore and dao interfaces).
The part worth keeping is the composition idea: ownership as an expression rather than a single address.
1func And(a Owner, b ...Owner) Owner // panics today
2func Or(a Owner, b ...Owner) Owner // panics today
Or(user, dao) is "the owner, or the DAO that can override them".
And(a, b) is a 2-of-2. Today every realm hardcodes one of these shapes.
The tests pin the surface on purpose: they assert that And and Or panic, so
implementing one is a visible change to this package rather than a silent shift
in behaviour for whoever imported it.
Recovered from an unmerged upstream proposal. For ownership that works today,
use p/nt/ownable
or p/moul/authz.
Part of moul/gno-contracts — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.
⚠️ Disclaimer: provided as-is, without warranty; not security-audited. Full disclaimer: DISCLAIMER.
Package ownable proposes an abstraction around the ownership which provides various kind of owners and some composition options.