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

governor source realm

Package governor is a simplified on-chain governance realm inspired by OpenZeppelin's Governor. Anyone may open a pro...

Overview

Package governor is a simplified on-chain governance realm inspired by OpenZeppelin's Governor. Anyone may open a proposal; every address gets a single equally-weighted vote (1 address = 1 vote); a proposal succeeds when its voting deadline has passed and the "for" tally strictly beats "against".

Constants 2

Functions 5

func CastVote

crossing Action
1func CastVote(cur realm, id int64, support int)
source

CastVote records one vote for the caller on proposal id. support is 0=against, 1=for, 2=abstain. One address may vote at most once per proposal, and voting is only allowed while the proposal is Active.

func Execute

crossing Action
1func Execute(cur realm, id int64)
source

Execute marks a Succeeded proposal as executed. It panics unless the proposal has reached the Succeeded state.

func Propose

crossing Action
1func Propose(cur realm, description string) int64
source

Propose opens a new proposal and returns its id. The snapshot height and deadline are recorded from the current chain height.

func Render

1func Render(path string) string
source

Render lists all proposals with their tallies and states as Markdown.

func State

Action
1func State(id int64) string
source

State returns the current lifecycle state of proposal id.

Types 1

type Proposal

struct
 1type Proposal struct {
 2	ID             int64
 3	Proposer       address
 4	Description    string
 5	SnapshotHeight int64
 6	Deadline       int64
 7	For            int64
 8	Against        int64
 9	Abstain        int64
10	Executed       bool
11	votes          *avl.Tree // voter address (string) -> support (int)
12}
source

Proposal is a single governance proposal.

Imports 6

Source Files 2