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

dao source realm

Constants 1

const AbstainVote, YesVote, NoVote

1const (
2	AbstainVote VoteOption = "ABSTAIN" // Side is not chosen
3	YesVote     VoteOption = "YES"     // Proposal should be accepted
4	NoVote      VoteOption = "NO"      // Proposal should be rejected
5)
source

Functions 21

func ExecuteOrRejectProposal

crossing Action
1func ExecuteOrRejectProposal(cur realm, pid ProposalID) bool
source

ExecuteOrRejectProposal executes the proposal with the provided ProposalID or rejects it when there is an execution error. If the proposal was denied, it will return false. If the proposal is correctly executed, it will return true, unless execution fails with an error, in which case proposal is rejected with the error as the reason. This function allows to finish proposals by rejecting them when there is a state change or an error in the proposal parameters that makes execution fail, potentially leaving the proposal active forever because it can't be successfully executed.

func ExecuteProposal

crossing Action
1func ExecuteProposal(cur realm, pid ProposalID) bool
source

ExecuteProposal will try to execute the proposal with the provided ProposalID. If the proposal was denied, it will return false. If the proposal is correctly executed, it will return true. If something happens this function will panic.

func MustVoteOnProposalSimple

crossing Action
1func MustVoteOnProposalSimple(cur realm, pid int64, option string)
source

MustVoteOnProposalSimple is like MustVoteOnProposal but intended to be used through gnokey with basic types.

func Render

crossing
1func Render(cur realm, p string) string
source

Render calls directly to Render's DAO implementation. This allows to have this realm as the main entry point for everything.

func UpdateImpl

crossing Action
1func UpdateImpl(cur realm, r UpdateRequest)
source

UpdateImpl is a method intended to be used on a proposal. This method will update the current govDAO implementation to a new one. AllowedDAOs are a list of realms that can call this method, in case the new DAO implementation had a breaking bug. Any value set as nil will be ignored. If AllowedDAOs field is not set correctly, the actual DAO implementation wont be able to execute new Proposals!

func VoteOnProposal

crossing Action
1func VoteOnProposal(cur realm, r VoteRequest) error
source

VoteOnProposal sends a vote to the actual govDAO implementation. If the voter cannot vote the specified proposal, this method will return an error with the explanation of why.

func GetProposal

Action
1func GetProposal(pid ProposalID) (*Proposal, error)
source

GetProposal gets created proposal by its ID. Non-crossing pure read: looks up the proposal in this realm's package var. Callable directly from any realm without cross-call syntax.

func CreateProposal

crossing Action
1func CreateProposal(cur realm, r ProposalRequest) (ProposalID, error)
source

CreateProposal will try to create a new proposal, that will be validated by the actual govDAO implementation. If the proposal cannot be created, an error will be returned.

func MustCreateProposal

crossing Action
1func MustCreateProposal(cur realm, r ProposalRequest) ProposalID
source

MustCreateProposal is an utility method that does the same as CreateProposal, but instead of erroing if something happens, it panics.

func NewSimpleExecutor

Action
1func NewSimpleExecutor(_ int, rlm realm, callback func(realm) error, description string) *SimpleExecutor
source

NewSimpleExecutor constructs an Executor whose creationRealm is captured from rlm.PkgPath() at construction time. The IsCurrent() check rejects stale or stashed realm values so the captured value is the authentic caller realm. creationRealm is display-only (rendered as "Executor created in: ..." in proposal listings) — no auth gate downstream.

func NewUpdateRequest

Action
1func NewUpdateRequest(d DAO, allowedDAOs []string) UpdateRequest
source

NewUpdateRequest copies allowedDAOs into a fresh slice owned by /r/gov/dao. Under the storage=authority model, if we stored the caller-passed slice directly, the base ArrayValue would retain PkgID = caller_realm: storage rent would attribute to caller, and /r/gov/dao could not mutate (e.g. append to) its own copy without a DidUpdate panic. The internal copy ensures the UpdateRequest and its AllowedDAOs both live entirely in /r/gov/dao's authority.

Types 12

type DAO

interface
 1type DAO interface {
 2	// PreCreateProposal is called just before creating a new Proposal
 3	// It is intended to be used to get the address of the proposal, that
 4	// may vary depending on the DAO implementation, and to validate that
 5	// the requester is allowed to do a proposal
 6	PreCreateProposal(_ int, rlm realm, r ProposalRequest) (address, error)
 7
 8	// PostCreateProposal is called after creating the Proposal. It is
 9	// intended to be used as a way to store a new proposal status, that
10	// depends on the actuall govDAO implementation
11	PostCreateProposal(_ int, rlm realm, r ProposalRequest, pid ProposalID)
12
13	// VoteOnProposal will send a petition to vote for a specific proposal
14	// to the actual govDAO implementation
15	VoteOnProposal(_ int, rlm realm, r VoteRequest) error
16
17	// PreExecuteProposal is called when someone is trying to execute a proposal by ID.
18	// Is intended to be used to validate who can trigger the proposal execution.
19	PreExecuteProposal(_ int, rlm realm, pid ProposalID) (bool, error)
20
21	// ExecuteProposal executes the proposal executor and on error changes proposal
22	// status to denied with the error message being the denial reason.
23	// It returns the executor error when it fails.
24	ExecuteProposal(_ int, rlm realm, pid ProposalID, e Executor) error
25
26	// Render will return a human-readable string in markdown format that
27	// will be used to show new data through the dao proxy entrypoint.
28	// Crossing: the chain query layer auto-injects .cur, and
29	// implementations forward cur to internal rlm-aware helpers (mux
30	// RenderRlm + downstream cross(rlm) reads).
31	Render(cur realm, pkgpath string, path string) string
32}
source

DAO is the govDAO implementation interface. All mutating/auth-gated methods take rlm as their realm-typed parameter in the second position (the `_ int, rlm realm` non-crossing form): callers thread the proxy's cur as data without forcing a realm transition, so the impl's existing unsafe.CurrentRealm()-based auth gates (isValidCall, memberstore.Get) continue to see the proxy realm. Render stays unchanged.

type Executor

interface
1type Executor interface {
2	Execute(cur realm) error
3	String() string
4	CreationRealm() string
5}
source

type Proposal

struct
1type Proposal struct {
2	author address
3
4	title       string
5	description string
6
7	executor    Executor
8	allowedDAOs []string
9}
source

Methods on Proposal

func AllowedDAOs

method on Proposal
1func (p *Proposal) AllowedDAOs() []string
source

func Author

method on Proposal
1func (p *Proposal) Author() address
source

func Description

method on Proposal
1func (p *Proposal) Description() string
source

func Title

method on Proposal
1func (p *Proposal) Title() string
source

type ProposalID

ident
1type ProposalID int64
source

Methods on ProposalID

func String

method on ProposalID
1func (pid ProposalID) String() string
source

type ProposalRequest

struct
1type ProposalRequest struct {
2	title       string
3	description string
4	executor    Executor
5	filter      Filter
6}
source

Methods on ProposalRequest

func Description

method on ProposalRequest
1func (p *ProposalRequest) Description() string
source

func Filter

method on ProposalRequest
1func (p *ProposalRequest) Filter() Filter
source

func Title

method on ProposalRequest
1func (p *ProposalRequest) Title() string
source

type Proposals

struct
1type Proposals struct {
2	seq            seqid.ID
3	*bptree.BPTree // *bptree.BPTree[ProposalID]*Proposal
4}
source

Methods on Proposals

func GetProposal

method on Proposals
1func (ps *Proposals) GetProposal(pid ProposalID) *Proposal
source

func SetProposal

method on Proposals
1func (ps *Proposals) SetProposal(p *Proposal) ProposalID
source

type SafeExecutor

struct
1type SafeExecutor struct {
2	e Executor
3}
source

SafeExecutor wraps an Executor to only allow its execution by allowed govDAOs.

Methods on SafeExecutor

func CreationRealm

method on SafeExecutor
1func (e *SafeExecutor) CreationRealm() string
source

func Execute

crossing method on SafeExecutor
1func (e *SafeExecutor) Execute(cur realm) error
source

func String

method on SafeExecutor
1func (e *SafeExecutor) String() string
source

type SimpleExecutor

struct
1type SimpleExecutor struct {
2	callback      func(realm) error
3	desc          string
4	creationRealm string
5}
source

SimpleExecutor implements the Executor interface using a callback function and a description string.

Methods on SimpleExecutor

func CreationRealm

method on SimpleExecutor
1func (e *SimpleExecutor) CreationRealm() string
source

func Execute

crossing method on SimpleExecutor
1func (e *SimpleExecutor) Execute(cur realm) error
source

func String

method on SimpleExecutor
1func (e *SimpleExecutor) String() string
source

type VoteOption

ident
1type VoteOption string
source

VoteOption is the limited voting option for a DAO proposal New govDAOs can create their own VoteOptions if needed in the future.

type VoteRequest

struct
1type VoteRequest struct {
2	Option     VoteOption
3	ProposalID ProposalID
4	Metadata   interface{}
5}
source

Imports 6

Source Files 4