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

daocond source pure

Constants 1

const VoteYes, VoteNo, VoteAbstain

1const (
2	VoteYes     Vote = "yes"
3	VoteNo      Vote = "no"
4	VoteAbstain Vote = "abstain"
5)
source

Available vote options.

Typed as Vote, not as untyped strings: an untyped constant assigns to a plain string without complaint, so a caller could hold one in a string variable and only discover the mismatch at a conversion. Typing them is a source-breaking change for any such caller, which is why it has to happen before publication rather than after.

Functions 7

func NewBallot

1func NewBallot() Ballot
source

Creates a new ballot implementation using AVL tree.

func And

1func And(conditions ...Condition) Condition
source

Creates a new condition from multiple conditions where all must be true to pass.

Example: And(MembersThreshold(0.6), RoleCount(2, "admin")) Requires both 60% member approval AND 2 admin votes.

func GnoloveDAOCondThreshold

1func GnoloveDAOCondThreshold(threshold float64, roles []string, hasRoleFn func(memberId string, role string) bool, usersWithRoleCountFn func(role string) uint32) Condition
source

Creates a weighted voting condition based on role tiers with dynamic power calculation. Example: GnoloveDAOCondThreshold(0.5, ["admin", "mod", "user"], hasRoleFn, countFn) This is our implementation of the govdao condition following Jae Kwon's specification: https://gist.github.com/jaekwon/918ad325c4c8f7fb5d6e022e33cb7eb3

func MembersThreshold

1func MembersThreshold(threshold float64, isMemberFn func(memberId string) bool, membersCountFn func() uint64) Condition
source

Creates a condition requiring a percentage of members to vote yes.

Example: MembersThreshold(0.6, isMemberFn, countFn) Requires 60% member approval.

func Or

1func Or(conditions ...Condition) Condition
source

Creates a new condition from multiple conditions where any one must be true.

Example: Or(MembersThreshold(0.6), RoleCount(2, "admin")) Requires either 60% member approval OR 2 admin votes.

func RoleCount

1func RoleCount(count uint64, role string, hasRoleFn func(memberId string, role string) bool) Condition
source

Creates a condition requiring a specific number of role holders to vote yes.

Example: RoleCount(2, "admin", hasRoleFn) Requires 2 admin votes.

func RoleThreshold

1func RoleThreshold(threshold float64, role string, hasRoleFn func(memberId string, role string) bool, usersRoleCountFn func(role string) uint32) Condition
source

Creates a condition requiring a percentage of role holders to vote yes.

Example: RoleThreshold(0.6, "admin", hasRoleFn, countFn) Requires 60% of admins.

Types 4

type Ballot

interface
 1type Ballot interface {
 2	// Records a vote from a specific voter.
 3	Vote(voter string, vote Vote)
 4
 5	// Retrieves the vote from a specific voter.
 6	Get(voter string) Vote
 7	// Returns the total number of votes cast.
 8	Total() int
 9
10	// Iterate over all votes, calling fn for each voter/vote pair.
11	// If fn returns false, iteration stops.
12	// Useful for counting specific vote types or finding particular voters.
13	Iterate(fn func(voter string, vote Vote) bool)
14}
source

Represents a collection of votes that can be evaluated against conditions.

type BallotAVL

struct
1type BallotAVL struct {
2	tree *avl.Tree
3}
source

Methods on BallotAVL

func Get

method on BallotAVL
1func (b *BallotAVL) Get(voter string) Vote
source

Gets the vote from a specific voter, returns VoteAbstain if no vote recorded.

func Iterate

method on BallotAVL
1func (b *BallotAVL) Iterate(fn func(voter string, vote Vote) bool)
source

Iterates over all votes, calling fn for each voter-vote pair.

func Total

method on BallotAVL
1func (b *BallotAVL) Total() int
source

Returns the total number of votes cast.

func Vote

method on BallotAVL
1func (b *BallotAVL) Vote(voter string, vote Vote)
source

Records a vote from a specific voter, overwriting any previous vote.

type Condition

interface
 1type Condition interface {
 2	// Checks if the condition is satisfied by the current votes.
 3	Eval(ballot Ballot) bool
 4	// Returns progress toward satisfying the condition (0.0 to 1.0).
 5	Signal(ballot Ballot) float64
 6
 7	// Displays the condition as human-readable text.
 8	// Example output: "[ 60% Members OR 2 admin ]"
 9	Render() string
10	// Displays the condition with current vote counts.
11	// Example output: "[ 3/5 Members OR 1/2 admin ]"
12	RenderWithVotes(ballot Ballot) string
13}
source

Represents a voting requirement.

type Vote

ident
1type Vote string
source

Represents a voting decision.

Imports 6

Source Files 9