diff --git a/examples/gno.land/p/moul/entity/entity.gno b/examples/gno.land/p/moul/entity/entity.gno new file mode 100644 index 00000000000..34846cc10b4 --- /dev/null +++ b/examples/gno.land/p/moul/entity/entity.gno @@ -0,0 +1,36 @@ +// Package entity provides an interface that abstracts a notion of entity which +// can under the hood be an EOA (std.Address), a package realm (PkgPath, +// std.Address). It also tries to give a notion of type where for instance, a +// user can be either a simple user or a team, and a contract can be either an +// arbitrary contract, or one that implements a famous pattern/interface, such +// as a DAO. It also provides some composition utilities so that an entity can +// be a flow that matches multiple other entities. +package entity + +import ( + "std" + + "gno.land/p/demo/users" +) + +type Entity interface { + Addr() std.Address + Path() string + Kind + isEntity() +} + +type UserEntity interface { + Entity + isUserEntity() +} + +type RealmEntity interface { + Entity + isRealmEntity() +} + +func NewUserByAddr(addr std.Address) UserEntity { panic("not implemented") } +func NewUserByAddrOrName(aon users.AddressOrName) UserEntity { panic("not implemented") } +func NewUserByName(name string) UserEntity { panic("not implemented") } +func NewRealm(rlm std.Realm) RealmEntity { panic("not implemented") } diff --git a/examples/gno.land/p/moul/ownable/ownable.gno b/examples/gno.land/p/moul/ownable/ownable.gno new file mode 100644 index 00000000000..b728e83a66a --- /dev/null +++ b/examples/gno.land/p/moul/ownable/ownable.gno @@ -0,0 +1,30 @@ +// Package ownable propose an abstraction around the ownership which provides +// various kind of owners and some composition options. +package ownable + +import "std" + +type Owner interface { + Addr() std.Address + Kind() Kind + owner() +} + +type UserOwner struct { + addr std.Address +} + +type RealmOwner struct { + realm std.Realm +} + +type MembstoreOwner struct { + // membstore.Membstore +} + +type DAOOwner struct { + // dao.DAO +} + +func And(a, b ...Owner) Owner { panic("not implemented") } +func Or(a, b ...Owner) Owner { panic("not implemented") } diff --git a/examples/gno.land/p/moul/safe/safe.gno b/examples/gno.land/p/moul/safe/safe.gno new file mode 100644 index 00000000000..1e19e77177c --- /dev/null +++ b/examples/gno.land/p/moul/safe/safe.gno @@ -0,0 +1,74 @@ +// Package safe is inspired by Gnosis Safe +package safe + +import ( + "std" + + "gno.land/p/demo/avl" +) + +// Gnosis safe style using this with threshold +// : affMember + update threshold at the same time + +type Safe interface { + Name() string + Members() []std.Address + Threshold() uint + Size() uint + NextProposal() Proposal + UpcomingProposals(page uint) (props []Proposal, total uint) + PreviousProposals(page uint) (props []Proposal, total uint) + // balances (native, grc20, grc721) + + ProposeAddingMember(addr std.Address, newThreshold uint) (prop Proposal, err error) + ProposeRemovingMember(addr std.Address, newThreshold uint) (prop Proposal, err error) + ProposeUpdatingThreshold(newThreshold uint) (prop Proposal, err error) + // ProposeClosure(cl func()) (prop Proposal, err error) + // ProposeBankXXX() + // ProposeGRC20XXX() + // ProposeGRC721XXX() + + GetProposal(id uint) Proposal + ApproveProposal(p Proposal) error + ExecuteProposal(p Proposal) error + CancelProposal(p Proposal) error // XXX: should be ProposeToCancel? + + Render(path string) string +} + +type Proposal interface { + ID() uint + Active() bool + Executed() bool + Voters() []std.Address +} + +func NewSafe() Safe { + caller := std.PrevRealm().Addr() + return safe{ + members: []std.Address{caller}, + threshold: 1, + prevProps: []Proposal{}, + nextProps: []Proposal{}, + } +} + +type safe struct { + name string + members avl.Tree // id -> std.Address + threshold uint + prevProps avl.tree // pid -> Proposal + nextProps avl.Tree // pid -> Proposal +} + +func (s safe) String() string { panic("not implemented") } + +func (s safe) Members() []std.Address { return s.members } +func (s safe) Threshold() uint { return s.threshold } +func (s safe) Size() uint { return len(s.members) } +func (s *safe) AddMember(addr std.Address, newThreshold uint) error { +} + +type proposal struct{} + +func (p proposal) String() string { panic("not implemented") }