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

basedao source pure

Constants 11

const HOME_PATH, MEMBERS_PATH, PROPOSALS_PATH, HOME_NO_PROFILE_PATH, CONFIG_PATH, PROPOSAL_HISTORY_PATH, MEMBER_DETAIL_PATH, PROPOSAL_DETAIL_PATH, ROLE_DETAIL_PATH, FALLBACK_DISPLAY_NAME

 1const (
 2	HOME_PATH             = ""
 3	MEMBERS_PATH          = "members"
 4	PROPOSALS_PATH        = "proposals"
 5	HOME_NO_PROFILE_PATH  = "noprofile"
 6	CONFIG_PATH           = "config"
 7	PROPOSAL_HISTORY_PATH = "history"
 8	MEMBER_DETAIL_PATH    = "member/{address}"
 9	PROPOSAL_DETAIL_PATH  = "proposal/{id}"
10	ROLE_DETAIL_PATH      = "role/{name}"
11	FALLBACK_DISPLAY_NAME = "Anon"
12)
source

WELL KNOWN PATHS

const MembersViewExtensionPath

1const MembersViewExtensionPath = "gno.land/p/samcrew/basedao.MembersView"
source

The extension registry key. It names this package, so it has to match the path this package is published at — third-party lookups are pinned to this literal once published, and it named gno.land/p/demo/basedao, which does not exist.

Functions 18

func NewChangeDAOImplementationAction

1func NewChangeDAOImplementationAction(label string, migrate MigrateFn) daokit.Action
source

The label is required and appears in the proposal a member votes on.

Without it every migration renders as the same fixed sentence, so a voter sees nothing distinguishing a routine upgrade from a takeover. A function value cannot be rendered, so the caller has to say what it is — name the version, the commit, or the change.

It is NOT a safety control. Whoever writes the migration writes the label, so a takeover can ship as "routine security patch". It exists so an honest proposal can be told apart from another honest proposal, and so a voter has something to check the code against. Read the migration.

func NewEditProfileHandler

1func NewEditProfileHandler(setter ProfileStringSetter, allowedFields []string) daokit.ActionHandler
source

func TruncateMiddle

1func TruncateMiddle(s string, max ...int) string
source

Truncates a string to a maximum length, adding "..." in the middle if it exceeds the limit.

func New

1func New(conf *Config, rlm realm) (daokit.DAO, *DAOPrivate)
source

func NewMembersStore

1func NewMembersStore(initialRoles []RoleInfo, initialMembers []Member) *MembersStore
source

func MustGetMembersViewExtension

1func MustGetMembersViewExtension(dao daokit.DAO, rlm realm) MembersViewExtension
source

The realm is threaded because daokit.DAO.Extension takes one. This extension is public, so any realm may fetch it and the realm is not checked — pass your own cur.

Types 18

type ActionAddMember

struct
1type ActionAddMember struct {
2	Address address
3	Roles   []string
4}
source

Methods on ActionAddMember

func String

method on ActionAddMember
1func (a *ActionAddMember) String() string
source

type ActionAssignRole

struct
1type ActionAssignRole struct {
2	Address address
3	Role    string
4}
source

Methods on ActionAssignRole

func String

method on ActionAssignRole
1func (a *ActionAssignRole) String() string
source

type ActionEditProfile

struct
1type ActionEditProfile struct {
2	kv [][2]string
3}
source

Methods on ActionEditProfile

func String

method on ActionEditProfile
1func (a *ActionEditProfile) String() string
source

type ActionUnassignRole

struct
1type ActionUnassignRole struct {
2	Address address
3	Role    string
4}
source

Methods on ActionUnassignRole

func String

method on ActionUnassignRole
1func (a *ActionUnassignRole) String() string
source

type CallerIDFn

func
1type CallerIDFn func(dao *DAOPrivate, rlm realm) string
source

CallerIDFn resolves the identity of the DAO's immediate caller.

It receives the DAO realm's own threaded realm, so the implementation can use rlm.Previous(), which is statically scoped to that crossing function.

On every path the entry gate admits, a stack walk would name the same realm: the gate has already established that the DAO's own frame is the live one, so unsafe.PreviousRealm() and rlm.Previous() agree. The walk goes wrong only in the shape the gate now rejects — a caller invoking these methods through the DAO handle, with no DAO realm frame on the stack at all, where the walk names the signing account instead. Deriving from the threaded realm is preferred because it does not depend on the gate having run first.

The realm is deliberately the SECOND parameter: a function whose first parameter is a realm is read as crossing, and /p/ packages may not declare crossing functions.

type Config

struct
 1type Config struct {
 2	// Basic DAO information
 3	Name        string
 4	Description string
 5	ImageURI    string
 6
 7	// Storage handler
 8	Members *MembersStore
 9
10	// Feature toggles
11	NoDefaultHandlers  bool // Skips registration of default management actions (add/remove members, etc.)
12	NoDefaultRendering bool // Skips setup of default web UI rendering routes
13	NoCreationEvent    bool // Skips emitting the DAO creation event
14
15	// Governance configuration
16	InitialCondition daocond.Condition // Default condition for all built-in actions, defaults to 60% member majority
17
18	// Profile integration (optional)
19	SetProfileString ProfileStringSetter // Function to update profile fields (DisplayName, Bio, Avatar)
20	GetProfileString ProfileStringGetter // Function to retrieve profile fields for members
21
22	// Advanced customization hooks
23	SetImplemFn       SetImplemRaw      // Function called when DAO implementation changes via governance
24	MigrationParamsFn MigrationParamsFn // Function providing parameters for DAO upgrades
25	// Condition for replacing the DAO's implementation. A passing migration
26	// hands proposer-authored code the DAO's live realm and its full private
27	// state, so it is a takeover in the general case — it should not be as easy
28	// as adding a member.
29	//
30	// If you leave InitialCondition to its default, this defaults to an 80%
31	// member majority — the same dimension, raised.
32	//
33	// If you SET InitialCondition, this defaults to it unchanged, and you should
34	// set this too. A Condition is opaque, so nothing here can strengthen yours:
35	// conjoining a members threshold onto role-based governance can demand a
36	// majority such a DAO never assembles, and migration is the one rule that
37	// cannot be repaired afterwards — changing it requires a migration. Whatever
38	// you choose, make it at least as hard as InitialCondition along every
39	// dimension; a condition that merely replaces yours can be WEAKER where it
40	// matters.
41	MigrationCondition daocond.Condition
42	RenderFn           RenderFn   // Rendering function for Gnoweb
43	CallerID           CallerIDFn // Resolves the immediate caller from the DAO's threaded realm; defaults to defaultCallerID
44
45	// Internal configuration
46	PrivateVarName string // Name of the private DAO variable for member querying extensions
47}
source

type DAOPrivate

struct
 1type DAOPrivate struct {
 2	Core             *daokit.Core
 3	Members          *MembersStore
 4	RenderRouter     *mux.Router
 5	GetProfileString ProfileStringGetter
 6	Realm            runtime.Realm
 7	RenderFn         func(path string, dao *DAOPrivate) string
 8	CallerID         CallerIDFn
 9
10	InitialConfig *Config // mostly there in case we need this data during upgrade
11}
source

DAO is meant for internal realm usage and should not be exposed.

Methods on DAOPrivate

func Execute

method on DAOPrivate
1func (d *DAOPrivate) Execute(proposalID uint64, rlm realm)
source

func HomePageView

method on DAOPrivate
1func (d *DAOPrivate) HomePageView(path string) string
source

func MemberDetailView

method on DAOPrivate
1func (d *DAOPrivate) MemberDetailView(addr string) string
source

func MembersPageView

method on DAOPrivate
1func (d *DAOPrivate) MembersPageView(path string) string
source

func MuxConfigPage

method on DAOPrivate
1func (d *DAOPrivate) MuxConfigPage(res *mux.ResponseWriter, req *mux.Request)
source

func MuxHomePage

method on DAOPrivate
1func (d *DAOPrivate) MuxHomePage(res *mux.ResponseWriter, req *mux.Request)
source

func MuxMemberDetailPage

method on DAOPrivate
1func (d *DAOPrivate) MuxMemberDetailPage(res *mux.ResponseWriter, req *mux.Request)
source

func MuxMembersPage

method on DAOPrivate
1func (d *DAOPrivate) MuxMembersPage(res *mux.ResponseWriter, req *mux.Request)
source

func MuxProposalDetailPage

method on DAOPrivate
1func (d *DAOPrivate) MuxProposalDetailPage(res *mux.ResponseWriter, req *mux.Request)
source

func MuxProposalHistoryPage

method on DAOPrivate
1func (d *DAOPrivate) MuxProposalHistoryPage(res *mux.ResponseWriter, req *mux.Request)
source

func MuxProposalsPage

method on DAOPrivate
1func (d *DAOPrivate) MuxProposalsPage(res *mux.ResponseWriter, req *mux.Request)
source

func MuxRoleDetailPage

method on DAOPrivate
1func (d *DAOPrivate) MuxRoleDetailPage(res *mux.ResponseWriter, req *mux.Request)
source

func ProposalsView

method on DAOPrivate
1func (d *DAOPrivate) ProposalsView(path string) string
source

func Propose

method on DAOPrivate
1func (d *DAOPrivate) Propose(req daokit.ProposalRequest, rlm realm) uint64
source

func Render

method on DAOPrivate
1func (d *DAOPrivate) Render(path string) string
source

func RenderMembersTable

method on DAOPrivate
1func (d *DAOPrivate) RenderMembersTable(path string, members *avl.Tree) string
source

Renders a table of members with their display name, address, roles, and profile link. It supports pagination.

func RenderProposalsTable

method on DAOPrivate
1func (d *DAOPrivate) RenderProposalsTable(path string, proposals *daokit.ProposalsStore) string
source

func RenderRoleLinkWithChip

method on DAOPrivate
1func (d *DAOPrivate) RenderRoleLinkWithChip(role string) string
source

Formats a role as a clickable link in Markdown, with colored chip at left.

func RoleColoredChip

method on DAOPrivate
1func (d *DAOPrivate) RoleColoredChip(role string, canvas ...*svg.Canvas) string
source

Returns a colored chip svg for the given role. If no role is given, a gray chip is returned. It can optionally take a custom svg.Canvas to define the size and style of the chip.

func RoleDetailPageView

method on DAOPrivate
1func (d *DAOPrivate) RoleDetailPageView(path string, name string) string
source

func RoleDetailView

method on DAOPrivate
1func (d *DAOPrivate) RoleDetailView(path string, name string) string
source

func Vote

method on DAOPrivate
1func (d *DAOPrivate) Vote(proposalID uint64, vote daocond.Vote, rlm realm)
source

type Member

struct
1type Member struct {
2	Address string
3	Roles   []string
4}
source

type MembersStore

struct
1type MembersStore struct {
2	Roles   *avl.Tree // role name -> *Role
3	Members *avl.Tree // string -> *avl.Tree [roles -> struct{}]
4}
source

Methods on MembersStore

func AddMember

method on MembersStore
1func (m *MembersStore) AddMember(member string, roles []string)
source

func AddRole

method on MembersStore
1func (m *MembersStore) AddRole(role RoleInfo)
source

func AddRoleToMember

method on MembersStore
1func (m *MembersStore) AddRoleToMember(member string, role string)
source

func CountMemberRoles

method on MembersStore
1func (m *MembersStore) CountMemberRoles(member string) int
source

func GetMemberRoles

method on MembersStore
1func (m *MembersStore) GetMemberRoles(member string) []string
source

func GetMembers

method on MembersStore
1func (m *MembersStore) GetMembers() []string
source

func GetMembersWithRole

method on MembersStore
1func (m *MembersStore) GetMembersWithRole(role string) []string
source

func GetRoles

method on MembersStore
1func (m *MembersStore) GetRoles() []string
source

func HasRole

method on MembersStore
1func (m *MembersStore) HasRole(member string, role string) bool
source

func IsMember

method on MembersStore
1func (m *MembersStore) IsMember(member string) bool
source

func MembersCount

method on MembersStore
1func (m *MembersStore) MembersCount() uint64
source

func RemoveMember

method on MembersStore
1func (m *MembersStore) RemoveMember(member string)
source

func RemoveRole

method on MembersStore
1func (m *MembersStore) RemoveRole(role string)
source

func RemoveRoleFromMember

method on MembersStore
1func (m *MembersStore) RemoveRoleFromMember(member string, role string)
source

func RoleInfo

method on MembersStore
1func (m *MembersStore) RoleInfo(role string) RoleInfo
source

type MigrateFn

func
1type MigrateFn = func(prev *DAOPrivate, params []any, rlm realm) daokit.DAO
source

type RenderFn

func
1type RenderFn func(path string, dao *DAOPrivate) string
source

type Role

struct
1type Role struct {
2	Name        string
3	Description string
4	Color       string
5	Members     *avl.Tree // string -> struct{}
6}
source

type RoleInfo

struct
1type RoleInfo struct {
2	Name        string
3	Description string
4	Color       string
5}
source

Imports 20

Source Files 16