1// Package udao defines minimal interfaces for Decentralized Autonomous Organizations (DAOs).2// It intentionally does not expose members and votes, as these details are implementation-specific.3// Instead, it focuses on providing an external view of proposals and their statuses,4// which is what non-members and non-voters typically care about.5//6// The package is designed to allow for composable DAO patterns, enabling flexible7// and modular implementations of various DAO structures and behaviors.8package udao910// DAO defines a minimal interface for a Decentralized Autonomous Organization11// from an external point of view, hiding the internal details of members and voting.12type DAO interface {13 // Propose submits a new proposal to the DAO14 Propose(prop Proposal) (id uint64, err error)1516 // GetProposalStatus retrieves the current status and metrics of a specific proposal17 GetProposalStatus(id uint64) (ProposalStatus, error)1819 // Execute attempts to execute a proposal if it has passed20 Execute(id uint64) error2122 // GetProposal retrieves the details of a specific proposal23 GetProposal(id uint64) (Proposal, error)2425 // XXX: find a smart way to list proposals26 // // ListProposalss retrieves a list of Proposals with pagination and optional filters27 // ListDAOs(offset, limit int, filters ...ProposalFilter) ([]DAO, error)28}2930// Proposal defines the interface for a DAO proposal31type Proposal interface {32 Title() string33 Body() string34 Constraints() []Constraint35}3637// ProposalStatus represents the current status and metrics of a proposal38type ProposalStatus struct {39 // status40 State ProposalState4142 // metrics43 YeaPercentage float6444 NayPercentage float6445 NonVoterPercentage float6446 // XXX: other metrics?47}4849// ProposalState represents the current state of a proposal50type ProposalState int5152const (53 Pending ProposalState = iota54 Active55 Passed56 Rejected57 Executed58 Expired // XXX: better name for when it's expired but not because of time?59)6061// Constraint defines an interface for proposal constraints62type Constraint interface {63 Validate() (bool, string)64 Description() string65}6667// ValidateConstraints checks if all constraints of a proposal are met68func ValidateConstraints(p Proposal) (bool, []string) {69 var unmetReasons []string70 for _, constraint := range p.Constraints() {71 valid, reason := constraint.Validate()72 if !valid {73 unmetReasons = append(unmetReasons, reason)74 }75 }76 return len(unmetReasons) == 0, unmetReasons77}78Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.