Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

README.md

1.68 Kb · 45 lines

gno.land/p/moul/entity

🚧 API sketch, not an implementation. The interfaces below are declared; all three constructors panic("not implemented"). Nothing here works yet.

A proposal for one type that stands for "whoever is acting", whether that is an externally owned account or a realm.

1type Entity interface {
2	Addr() address
3	Path() string    // "" for an EOA, the pkgpath for a realm
4	Kind
5	isEntity()
6}

UserEntity and RealmEntity narrow it, and Kind is meant to carry the second axis: a user can be a person or a team, a realm can be an arbitrary contract or one that implements a known interface such as a DAO.

1func NewUserByAddr(addr address) UserEntity    // panics today
2func NewUserByName(name string) UserEntity     // panics today
3func NewRealm(rlm runtime.Realm) RealmEntity   // panics today

The motivation is that gno code constantly branches on "is this an address or a pkgpath", and that branch leaks into every API that wants to accept either. A single Entity would let a realm accept both and let composition (an entity that matches several others) be expressed once.

Closely related to p/moul/ownable, which is the same idea narrowed to ownership.


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.