memba_dao.gno
4.13 Kb · 100 lines
1package memba_dao
2
3// MembaDAO — Community governance realm for the Memba ecosystem.
4//
5// Uses gnodaokit basedao for full DAO lifecycle:
6// - Role-based membership (admin, dev, ops, member)
7// - Proposal/Vote/Execute governance (66% threshold)
8// - Self-upgradable via ChangeDAOImplementation proposals
9// - Profile integration via r/samcrew/_deps/demo/profile
10//
11// Security:
12// - NO open AddMember — membership only via DAO proposals (66% vote)
13// - Caller identity via realmid.Previous (default in basedao)
14//
15// Founding member: samcrew-core-test1 multisig (testnet)
16//
17// interrealm v2: init takes a realm; basedao.New / localDAO.Execute thread it;
18// the v1 crossing wrapper (daokit.NewCrossing / CrossFn / the public DAO var)
19// is removed.
20
21import (
22 "gno.land/p/samcrew/basedao"
23 "gno.land/p/samcrew/daocond"
24 "gno.land/p/samcrew/daokit"
25 "gno.land/r/demo/profile" // genesis profile (v2); REQUIRED — basedao.New() panics without GetProfileString
26)
27
28var (
29 localDAO daokit.DAO // Local interface for maketx call
30 daoPrivate *basedao.DAOPrivate // Full access to internal DAO state
31)
32
33// Initializes MembaDAO with roles, founding member, and governance rules.
34func init(cur realm) {
35 // ── Roles ────────────────────────────────────────────────
36 roles := []basedao.RoleInfo{
37 {Name: "admin", Description: "DAO administrators with full governance power", Color: "#329175"},
38 {Name: "dev", Description: "Core developers building the Memba ecosystem", Color: "#4ecdc4"},
39 {Name: "ops", Description: "Operations team managing infrastructure", Color: "#fdcb6e"},
40 {Name: "member", Description: "Community members contributing to governance", Color: "#21577A"},
41 }
42
43 // ── Founding Member ─────────────────────────────────────
44 // samcrew-core-test1 multisig — testnet equivalent of production multisig
45 members := []basedao.Member{
46 {
47 Address: "g1x7k4628w93a7wzdhqc06atzx0v50rnshweuxu0",
48 Roles: []string{"admin", "dev"},
49 },
50 }
51
52 // ── Governance ───────────────────────────────────────────
53 store := basedao.NewMembersStore(roles, members)
54
55 // 66% threshold — strong consensus required for all actions.
56 // With 1 member (bootstrap), this effectively means 100% (1/1).
57 condition := daocond.MembersThreshold(0.66, store.IsMember, store.MembersCount)
58
59 // ── Initialize DAO ──────────────────────────────────────
60 localDAO, daoPrivate = basedao.New(&basedao.Config{
61 Name: "MembaDAO",
62 Description: "Community governance for the Memba ecosystem — multisig wallet & DAO platform on Gno",
63 Members: store,
64 InitialCondition: condition,
65 GetProfileString: profile.GetStringField,
66 SetProfileString: profile.SetStringField,
67 PrivateVarName: "daoPrivate",
68 SetImplemFn: setImplem,
69 }, cur)
70}
71
72// ── Public API ───────────────────────────────────────────────
73
74// Propose creates a new governance proposal.
75// Must be called via MsgRun (gnokey maketx run) for cross-realm support.
76func Propose(cur realm, req daokit.ProposalRequest) {
77 localDAO.Propose(req)
78}
79
80// Vote allows DAO members to cast their vote on a proposal.
81func Vote(cur realm, proposalID uint64, vote daocond.Vote) {
82 localDAO.Vote(proposalID, vote)
83}
84
85// Execute triggers execution of an approved proposal's actions.
86func Execute(cur realm, proposalID uint64) {
87 localDAO.Execute(proposalID, cur)
88}
89
90// Render generates the web UI for gnoweb.
91func Render(path string) string {
92 return localDAO.Render(path)
93}
94
95// ── Internal ─────────────────────────────────────────────────
96
97// setImplem updates the DAO implementation when governance proposals change it.
98func setImplem(newLocalDAO daokit.DAO) {
99 localDAO = newLocalDAO
100}