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

v1 state

Back to all declarations

votingPeriod

int64

votingPeriod is the number of blocks a proposal stays open for voting.

Value

100

VoteAgainst

untyped bigint

Vote support values.

Value

(0 <untyped> bigint)

VoteFor

untyped bigint

Vote support values.

Value

(1 <untyped> bigint)

VoteAbstain

untyped bigint

Vote support values.

Value

(2 <untyped> bigint)

StateActive

untyped string

Proposal state values.

Value

"Active"

StateSucceeded

untyped string

Proposal state values.

Value

"Succeeded"

StateDefeated

untyped string

Proposal state values.

Value

"Defeated"

StateExecuted

untyped string

Proposal state values.

Value

"Executed"

Proposal

type

Proposal is a single governance proposal. It carries no ID field: the id belongs to the store, which hands it back on lookup and iteration.

Value

v1.Proposal

proposals

*v0.Store

proposals assigns the proposal ids. v0 kept its own nextID plus an idKey() that zero-padded to width 12, which stopped ordering Render past 10^12, and its own totalCount, which the store's LastID already answers.

Open
OID
0baf59…f4b0:4
proposals details

Inspect pointer

Propose

func(description string) int64

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

Open
OID
0baf59…f4b0:7
Propose details

Inspect func

CastVote

func(id int64, support int)

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.

Open
OID
0baf59…f4b0:9
CastVote details

Inspect func

Execute

func(id int64)

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

Open
OID
0baf59…f4b0:10
Execute details

Inspect func

State

func(id int64) string

State returns the current lifecycle state of proposal id.

Open
OID
0baf59…f4b0:11
State details

Inspect func

computeState

func(p *v1.Proposal, h int64) string

computeState is the pure state machine: it decides the state of p at chain height h. Kept free of globals so it is unit-testable.

Open
OID
0baf59…f4b0:12
computeState details

Inspect func

mustGet

func(id int64) *v1.Proposal
Open
OID
0baf59…f4b0:13
mustGet details

Inspect func

bar

func(value int64, total int64, width int) string

bar renders a proportional ▓░ progress bar of fixed width.

Open
OID
0baf59…f4b0:14
bar details

Inspect func

Render

func(path string) string

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

Open
OID
0baf59…f4b0:15
Render details

Inspect func
votingPeriod : int64 =100
VoteAgainst : untyped bigint =(0 <untyped> bigint)
VoteFor : untyped bigint =(1 <untyped> bigint)
VoteAbstain : untyped bigint =(2 <untyped> bigint)
StateActive : untyped string ="Active"
StateSucceeded : untyped string ="Succeeded"
StateDefeated : untyped string ="Defeated"
StateExecuted : untyped string ="Executed"
Proposal : type =v1.Proposal
proposals : *v0.Store Inspect
Propose : func(description string) int64 Inspect
CastVote : func(id int64, support int) Inspect
Execute : func(id int64) Inspect
State : func(id int64) string Inspect
computeState : func(p *v1.Proposal, h int64) string Inspect
mustGet : func(id int64) *v1.Proposal Inspect
bar : func(value int64, total int64, width int) string Inspect
Render : func(path string) string Inspect