governance source realm
Package governance implements proposal lifecycle management and voting. It supports text proposals, parameter changes...
View source
Governance
Decentralized protocol governance via GNS staking and voting.
Overview
Governance system enables GNS holders to stake for xGNS voting power, create proposals, and vote on protocol changes. For more details, check out docs.
Configuration
The governance.Config type defines the core governance parameters. All values can be modified through governance proposals. This type can be found in the config.gno file.
| Field | Description | Default |
|---|---|---|
VotingStartDelay |
Delay before voting starts after proposal creation | 1 day |
VotingPeriod |
Duration for collecting votes | 7 days |
VotingWeightSmoothingDuration |
Period for averaging voting weight (prevents flash loans) | 1 day |
Quorum |
Percentage of active xGNS required for proposal passage | 50% |
ProposalCreationThreshold |
Minimum xGNS amount required to create a proposal | 1,000 xGNS |
ExecutionDelay |
Waiting period after voting ends before execution | 1 day |
ExecutionWindow |
Time window during which an approved proposal can be executed | 30 days |
Core Mechanics
Staking Flow
1GNS → Stake → xGNS (voting power) → Delegate → Vote
- Stake GNS to receive equal xGNS
- Delegate voting power (can be self)
- Vote on proposals with delegated power
- 7-day lockup for undelegation
Proposal Types
- Text: Signal proposals without execution
- CommunityPoolSpend: Treasury disbursements
- ParameterChange: Protocol parameter updates
Proposal Lifecycle
Creation
- Requires 1,000 xGNS balance
- One active proposal per address
- Valid type and parameters required
Voting
- 1 day delay before voting starts
- 7 days voting period
- Weight = 24hr average delegation (prevents flash loans)
Execution
A proposal is considered valid and executable when:
- The voting period has ended
- Total votes meet the quorum threshold (50% of xGNS total supply)
YESvotes strictly exceedNOvotes (ties do not pass)- The execution delay period (configured via
ExecutionDelaydefault: 24 hours) has passed after voting ends - Within the execution window period (configured via
ExecutionWindowdefault: 30 days)ExecutionDelayandExecutionWindoware configured through thegovernance.Configtype.
- Anyone can trigger execution once conditions are met
Technical Details
Vote Weight Calculation
1// 24-hour average prevents manipulation
2snapshot1 = getDelegationAt(proposalTime - 24hr)
3snapshot2 = getDelegationAt(proposalTime)
4voteWeight = (snapshot1 + snapshot2) / 2
Quorum Calculation
1activeXGNS = totalXGNS - launchpadXGNS
2quorumAmount = activeXGNS * quorumPercent / 100 // quorumPercent defaults to 50
The quorum threshold is calculated based on the Quorum percentage (default: 50%) of the active xGNS supply at the time of proposal creation. A proposal passes only when total votes reach quorum and the accumulated YES votes strictly exceed the accumulated NO votes.
Rewards Distribution
xGNS holders earn protocol fees:
1userShare = (userXGNS / totalXGNS) * protocolFees
Usage
1// Stake GNS for xGNS
2Delegate(amount, delegateTo)
3
4// Create proposal
5ProposeText(title, description, body)
6ProposeCommunityPoolSpend(recipient, amount)
7ProposeParameterChange(title, description, numToExecute, executions)
8
9// Vote on proposal
10Vote(proposalId, true) // YES
11Vote(proposalId, false) // NO
12
13// Execute after timelock
14Execute(proposalId)
15
16// Undelegate (7-day lockup)
17Undelegate()
Security
- Flash loan protection via vote smoothing
- Sybil resistance through stake weighting
- Timelock prevents rushed execution
- Single proposal limit per address
- Dynamic quorum excludes inactive xGNS
Package governance implements proposal lifecycle management and voting. It supports text proposals, parameter changes, and community pool spending. Proposals go through creation, voting, and execution phases with configurable parameters for voting delays, periods, and thresholds.
4
const _, StatusUpcoming, StatusActive, StatusPassed, StatusRejected, StatusExecutable, StatusExecuted, StatusExpired, StatusCanceled
1const (
2 _ ProposalStatusType = iota
3 StatusUpcoming // Proposal created but voting hasn't started yet
4 StatusActive // Proposal is in voting period
5 StatusPassed // Proposal has passed but hasn't been executed (or is text proposal)
6 StatusRejected // Proposal failed to meet voting requirements
7 StatusExecutable // Proposal can be executed (passed and in execution window)
8 StatusExecuted // Proposal has been successfully executed
9 StatusExpired // Proposal execution window has passed
10 StatusCanceled // Proposal has been canceled
11)const Text, CommunityPoolSpend, ParameterChange
const StoreKeyConfigCounter, StoreKeyProposalCounter, StoreKeyConfigs, StoreKeyProposals, StoreKeyProposalUserVotingInfos, StoreKeyUserProposals
1const (
2 StoreKeyConfigCounter StoreKey = "configCounter" // Config version counter
3 StoreKeyProposalCounter StoreKey = "proposalCounter" // Proposal ID counter
4
5 StoreKeyConfigs StoreKey = "configs" // Configurations BPTree
6
7 StoreKeyProposals StoreKey = "proposals" // Proposals BPTree
8
9 StoreKeyProposalUserVotingInfos StoreKey = "proposalUserVotingInfos" // Proposal voting infos BPTree
10
11 StoreKeyUserProposals StoreKey = "userProposals" // User proposals mapping BPTree
12)63
func Cancel
crossing ActionCancel cancels a proposal before voting begins. Only callable by the proposer.
Parameters:
- proposalId: ID of the proposal to cancel
Returns:
- int64: cancellation result code
func Execute
crossing ActionExecute executes a passed proposal that is in the execution window.
Parameters:
- proposalId: ID of the proposal to execute
Returns:
- int64: execution result code
func ExistsProposal
ActionExistsProposal checks if a proposal exists.
func ExistsVotingInfo
ActionExistsVotingInfo checks if a voting info exists for a user on a proposal.
func GetConfigVersionByProposalId
ActionGetConfigVersionByProposalId returns the config version used by a proposal.
func GetCurrentProposalID
ActionGetCurrentProposalID returns the current proposal ID counter.
func GetCurrentVotingWeightSnapshot
ActionGetCurrentVotingWeightSnapshot returns the current voting weight snapshot.
func GetDescriptionByProposalId
ActionGetDescriptionByProposalId returns the description of a proposal.
func GetImplementationPackagePath
ActionGetImplementationPackagePath returns the package path of the currently active implementation.
func GetLatestConfigVersion
ActionGetLatestConfigVersion returns the current config version.
func GetMaxSmoothingPeriod
ActionGetMaxSmoothingPeriod returns the maximum smoothing period for delegation history cleanup.
func GetNayByProposalId
ActionGetNayByProposalId returns the no vote weight of a proposal.
func GetOldestActiveProposalSnapshotTime
ActionGetOldestActiveProposalSnapshotTime returns the oldest snapshot time among active proposals.
func GetProposalCount
ActionGetProposalCount returns the total number of proposals.
func GetProposalCreatedAt
ActionGetProposalCreatedAt returns the creation timestamp of a proposal.
func GetProposalCreatedHeight
ActionGetProposalCreatedHeight returns the creation block height of a proposal.
func GetProposalIDs
ActionGetProposalIDs returns a paginated list of proposal IDs.
func GetProposalStatusByProposalId
ActionGetProposalStatusByProposalId returns the current status of a proposal.
func GetQuorumAmountByProposalId
ActionGetQuorumAmountByProposalId returns the quorum requirement for a proposal.
func GetTitleByProposalId
ActionGetTitleByProposalId returns the title of a proposal.
func GetUserProposalCount
ActionGetUserProposalCount returns the number of proposals created by a user.
func GetUserProposalIDs
ActionGetUserProposalIDs returns a paginated list of proposal IDs created by a user.
func GetVoteStatus
Action1func GetVoteStatus(proposalId int64) (quorum, maxVotingWeight, yesWeight, noWeight int64, err error)GetVoteStatus returns the vote status of a proposal.
Returns:
- quorum: minimum vote weight required for proposal to pass
- maxVotingWeight: maximum possible voting weight
- yesWeight: total weight of "yes" votes
- noWeight: total weight of "no" votes
func GetVoteWeight
ActionGetVoteWeight returns the voting weight of an address for a proposal.
func GetVotedAt
ActionGetVotedAt returns the timestamp when an address voted on a proposal.
func GetVotedHeight
ActionGetVotedHeight returns the block height when an address voted on a proposal.
func GetVotingInfoCount
ActionGetVotingInfoCount returns the number of voters for a proposal.
func GetYeaByProposalId
ActionGetYeaByProposalId returns the yes vote weight of a proposal.
func NewConfigTree
Actionfunc NewProposalTree
Actionfunc NewProposalUserVotingInfoTree
Actionfunc NewUserProposalTree
Actionfunc NewVotingInfoTree
Actionfunc ProposeCommunityPoolSpend
crossing ActionProposeCommunityPoolSpend creates a new community pool spending proposal.
Parameters:
- title: proposal title
- description: detailed proposal description
- to: recipient address
- tokenPath: token path to transfer
- amount: amount to transfer
Returns:
- int64: ID of the created proposal
func ProposeParameterChange
crossing ActionProposeParameterChange creates a new parameter change proposal.
Parameters:
- title: proposal title
- description: detailed proposal description
- numToExecute: number of executions to perform
- executions: encoded execution messages
Returns:
- int64: ID of the created proposal
func ProposeText
crossing ActionProposeText creates a new text proposal for general governance decisions.
Parameters:
- title: proposal title
- description: detailed proposal description
Returns:
- int64: ID of the created proposal
func Reconfigure
crossing ActionReconfigure updates the governance configuration parameters. Only callable by admin or governance.
Parameters:
- votingStartDelay: delay before voting starts (seconds)
- votingPeriod: voting duration (seconds)
- votingWeightSmoothingDuration: weight smoothing duration (seconds)
- quorum: minimum voting weight required (percentage)
- proposalCreationThreshold: minimum weight to create proposal
- executionDelay: delay before execution (seconds)
- executionWindow: execution time window (seconds)
Returns:
- int64: new configuration version
func RegisterInitializer
crossing Action1func RegisterInitializer(cur realm, initializer func(_ int, rlm realm, governanceStore IGovernanceStore, stakerAccessor GovStakerAccessor) IGovernance)RegisterInitializer registers a version-specific initializer. Each version (e.g. v1, v2) calls this function from its init body to plug itself into the proxy.
The initializer constructs the version's IGovernance from the supplied IGovernanceStore and GovStakerAccessor. It receives a realm value that resolves to the governance proxy realm — the only address with write permission on the shared KV store — so any per-version store bootstrap performed inside the initializer passes the proxy's authorization check.
Security: Only contracts within the domain path can register initializers. Each package path can only register once to prevent duplicate registrations.
func UpgradeImpl
crossing ActionUpgradeImpl switches the active governance implementation to a different version. This function allows seamless upgrades from one version to another without data migration or downtime.
Security: Only admin or governance can perform upgrades. The new implementation must have been previously registered via RegisterInitializer.
func Vote
crossing ActionVote casts a vote on a proposal.
Parameters:
- proposalId: ID of the proposal to vote on
- yes: true for yes vote, false for no vote
Returns:
- string: voting result information
func GetProposalCommunityPoolSpendInfo
ActionGetProposalCommunityPoolSpendInfo returns the community pool spend info for a proposal.
func NewCommunityPoolSpendInfo
Actionfunc GetConfig
ActionGetConfig returns a specific governance configuration by version.
func GetLatestConfig
ActionGetLatestConfig returns the latest governance configuration.
func NewConfig
Actionfunc NewConfigPtr
ActionNewConfigPtr constructs a Config and returns a pointer to it. The Config is allocated within the governance domain realm, satisfying realm allocation checks for callers (such as tests) that require a *Config value.
func NewDefaultConfig
Actionfunc NewCounter
ActionNewCounter creates a new Counter starting at 0.
func GetProposalExecutionInfo
ActionGetProposalExecutionInfo returns the execution info for a proposal.
func NewExecutionInfo
Actionfunc NewGovernanceStore
ActionNewGovernanceStore creates a new governance store instance with the provided KV store. This function is used by the upgrade system to create storage instances for each implementation.
func NewParameterChangeInfo
Actionfunc GetProposal
ActionGetProposal returns a proposal by ID. Returns a clone to prevent external modification.
func NewProposal
ActionNewProposal creates a new proposal instance with the provided parameters. NewProposal is the main constructor for creating governance proposals.
- metadata: proposal title and description
- data: type-specific proposal data
- proposerAddress: address of the proposal creator
- configVersion: governance configuration version
- snapshotTime: timestamp for voting weight snapshot lookup
- createdHeight: creation block height
Returns:
- *Proposal: newly created proposal instance
func NewProposalActionStatus
ActionNewProposalActionStatus creates a new action status for a proposal. Initializes the status with default values and the executable flag.
Parameters:
- executable: whether this proposal type can be executed
Returns:
- *ProposalActionStatus: new action status instance
func NewProposalData
Action1func NewProposalData(proposalType ProposalType, communityPoolSpend *CommunityPoolSpendInfo, execution *ExecutionInfo) *ProposalDataNewProposalData creates a new proposal data instance with the specified components.
Parameters:
- proposalType: type of the proposal
- communityPoolSpend: community pool spending information
- execution: parameter change execution information
Returns:
- *ProposalData: new proposal data instance
func NewProposalMetadata
ActionNewProposalMetadata creates a new proposal metadata instance with trimmed input.
Parameters:
- title: proposal title
- description: proposal description
Returns:
- *ProposalMetadata: new metadata instance with trimmed whitespace
func NewProposalScheduleStatus
Actionfunc NewProposalStatusBy
Actionfunc GetProposalTypeByProposalId
ActionGetProposalTypeByProposalId returns the type of a proposal.
func NewProposalVoteStatus
ActionNewProposalVoteStatus creates a new vote status for a proposal. Initializes vote tallies to zero and calculates the quorum requirement.
Parameters:
- maxVotingWeight: maximum possible voting weight for this proposal
- quorumAmount: quorum amount required for passage
Returns:
- *ProposalVoteStatus: new vote status instance
func GetVotingInfo
ActionGetVotingInfo returns the voting info for a user on a proposal. Returns a clone to prevent external modification.
func NewVotingInfo
ActionNewVotingInfo creates a new voting information structure for a user. This constructor initializes the voting eligibility based on delegation snapshots.
Parameters:
- availableVoteWeight: total voting weight available to this user
Returns:
- *VotingInfo: newly created voting information structure
21
type CommunityPoolSpendInfo
structCommunityPoolSpendInfo contains information for community pool spending proposals.
type Config
struct 1type Config struct {
2 // VotingStartDelay is the delay before voting starts after proposal creation (in seconds)
3 VotingStartDelay int64
4 // VotingPeriod is the duration during which votes are collected (in seconds)
5 VotingPeriod int64
6 // VotingWeightSmoothingDuration is the period over which voting weight is averaged
7 // for proposal creation and cancellation threshold calculations (in seconds)
8 VotingWeightSmoothingDuration int64
9 // Quorum is the percentage of active xGNS supply required for proposal approval
10 Quorum int64
11 // ProposalCreationThreshold is the minimum xGNS amount required to create a proposal
12 ProposalCreationThreshold int64
13 // ExecutionDelay is the waiting period after voting ends before a proposal can be executed (in seconds)
14 ExecutionDelay int64
15 // ExecutionWindow is the time window during which an approved proposal can be executed (in seconds)
16 ExecutionWindow int64
17}Config represents the configuration of the governor contract All parameters in this struct can be modified through governance.
type Counter
structCounter manages unique incrementing IDs.
type ExecutionInfo
structExecutionInfo contains information for parameter change execution. Messages are encoded strings that specify function calls and parameters.
type GovStakerAccessor
interface 1type GovStakerAccessor interface {
2 // GetTotalDelegationAmountAtSnapshot returns the total delegation amount at a specific snapshot time.
3 GetTotalDelegationAmountAtSnapshot(snapshotTime int64) (int64, bool)
4
5 // GetUserDelegationAmountAtSnapshot returns the user delegation amount at a specific snapshot time.
6 GetUserDelegationAmountAtSnapshot(userAddr address, snapshotTime int64) (int64, bool)
7
8 // GetTotalxGnsSupply returns the total xGNS supply used as the quorum base.
9 GetTotalxGnsSupply() int64
10}GovStakerAccessor provides an interface for accessing gov staker functionality. This abstraction allows for easier testing by enabling mock implementations.
type IGovernance
interfacetype IGovernanceGetter
interface 1type IGovernanceGetter interface {
2 // Store data getters
3 GetLatestConfigVersion() int64
4 GetCurrentProposalID() int64
5 GetMaxSmoothingPeriod() int64
6
7 // Config getters
8 GetLatestConfig() Config
9 GetConfig(configVersion int64) (Config, error)
10
11 // Proposal getters
12 GetProposalCount() int
13 GetProposalIDs(offset, count int) []int64
14 ExistsProposal(proposalID int64) bool
15 GetProposal(proposalID int64) (*Proposal, error)
16 GetProposerByProposalId(proposalId int64) (address, error)
17 GetProposalTypeByProposalId(proposalId int64) (ProposalType, error)
18 GetYeaByProposalId(proposalId int64) (int64, error)
19 GetNayByProposalId(proposalId int64) (int64, error)
20 GetConfigVersionByProposalId(proposalId int64) (int64, error)
21 GetQuorumAmountByProposalId(proposalId int64) (int64, error)
22 GetTitleByProposalId(proposalId int64) (string, error)
23 GetDescriptionByProposalId(proposalId int64) (string, error)
24 GetProposalStatusByProposalId(proposalId int64) (string, error)
25
26 // Vote getters
27 GetVoteStatus(proposalId int64) (quorum, maxVotingWeight, yesWeight, noWeight int64, err error)
28 GetVotingInfoCount(proposalID int64) int
29 GetVotingInfoAddresses(proposalID int64, offset, count int) []address
30 ExistsVotingInfo(proposalID int64, addr address) bool
31 GetVotingInfo(proposalID int64, addr address) (*VotingInfo, error)
32 GetVoteWeight(proposalID int64, addr address) (int64, error)
33 GetVotedHeight(proposalID int64, addr address) (int64, error)
34 GetVotedAt(proposalID int64, addr address) (int64, error)
35
36 // User proposal getters
37 GetUserProposalCount(user address) int
38 GetUserProposalIDs(user address, offset, count int) []int64
39
40 // Active proposal query
41 GetOldestActiveProposalSnapshotTime() (int64, bool)
42
43 // Voting weight snapshot getters
44 GetCurrentVotingWeightSnapshot() (int64, int64, error)
45}IGovernanceGetter provides read-only access to governance data.
type IGovernanceManager
interface 1type IGovernanceManager interface {
2 // Proposal management
3 ProposeText(
4 _ int, rlm realm,
5 title string,
6 description string,
7 ) int64
8
9 ProposeCommunityPoolSpend(
10 _ int, rlm realm,
11 title string,
12 description string,
13 to address,
14 tokenPath string,
15 amount int64,
16 ) int64
17
18 ProposeParameterChange(
19 _ int, rlm realm,
20 title string,
21 description string,
22 numToExecute int64,
23 executions string,
24 ) int64
25
26 // Voting
27 Vote(
28 _ int, rlm realm,
29 proposalId int64,
30 yes bool,
31 ) string
32
33 // Execution
34 Execute(
35 _ int, rlm realm,
36 proposalId int64,
37 ) int64
38
39 Cancel(
40 _ int, rlm realm,
41 proposalId int64,
42 ) int64
43
44 // Configuration
45 Reconfigure(
46 _ int, rlm realm,
47 votingStartDelay int64,
48 votingPeriod int64,
49 votingWeightSmoothingDuration int64,
50 quorum int64,
51 proposalCreationThreshold int64,
52 executionDelay int64,
53 executionWindow int64,
54 ) int64
55}type IGovernanceStore
interface 1type IGovernanceStore interface {
2 // Counter methods
3 HasConfigCounterStoreKey() bool
4 GetConfigCounter() *Counter
5 SetConfigCounter(_ int, rlm realm, counter *Counter) error
6
7 HasProposalCounterStoreKey() bool
8 GetProposalCounter() *Counter
9 SetProposalCounter(_ int, rlm realm, counter *Counter) error
10
11 // Config methods
12 HasConfigsStoreKey() bool
13 SetConfigs(_ int, rlm realm, configs *bptree.BPTree) error
14 SetConfig(_ int, rlm realm, version int64, config Config) error
15 GetConfig(version int64) (Config, bool)
16
17 // Proposal methods
18 HasProposalsStoreKey() bool
19 GetProposals() *bptree.BPTree
20 GetProposal(proposalID int64) (*Proposal, bool)
21 SetProposal(_ int, rlm realm, proposalID int64, proposal *Proposal) error
22 SetProposals(_ int, rlm realm, proposals *bptree.BPTree) error
23
24 // Proposal voting info methods
25 HasProposalUserVotingInfosStoreKey() bool
26 GetProposalUserVotingInfos() *bptree.BPTree
27 SetProposalUserVotingInfos(_ int, rlm realm, votingInfos *bptree.BPTree) error
28 GetProposalVotingInfos(proposalID int64) (*bptree.BPTree, bool)
29 SetProposalVotingInfos(_ int, rlm realm, proposalID int64, votingInfos *bptree.BPTree) error
30
31 // User proposals methods
32 HasUserProposalsStoreKey() bool
33 GetUserProposalIDs(user string) ([]int64, bool)
34 SetUserProposals(_ int, rlm realm, userProposals *bptree.BPTree) error
35 AddUserProposal(_ int, rlm realm, user string, proposalID int64) error
36 RemoveUserProposal(_ int, rlm realm, user string, proposalID int64) error
37}type ParameterChangeInfo
structParameterChangeInfo represents a single parameter change to be executed.
type Proposal
struct 1type Proposal struct {
2 id int64 // Unique identifier for the proposal
3 proposer address // The address of the proposer
4 configVersion int64 // The version of the governance config used
5 status *ProposalStatus // Current status and voting information
6 metadata *ProposalMetadata // Title and description
7 data *ProposalData // Type-specific proposal data
8 snapshotTime int64 // Timestamp for voting weight snapshot lookup
9 createdHeight int64 // Block height at creation
10}Proposal represents a governance proposal with all its associated data and state. This is the core structure that tracks proposal lifecycle from creation to execution.
Methods on Proposal
func Clone
method on ProposalClone creates a deep copy of the Proposal.
func ConfigVersion
method on ProposalConfigVersion returns the governance configuration version used for this proposal.
func CreatedAt
method on ProposalCreatedAt returns the creation timestamp of the proposal.
func Data
method on ProposalData returns the proposal data.
func Description
method on ProposalDescription returns the proposal description.
func ID
method on ProposalID returns the unique identifier of the proposal.
func IsCommunityPoolSpendType
method on ProposalIsCommunityPoolSpendType checks if this is a community pool spend proposal.
func IsParameterChangeType
method on ProposalIsParameterChangeType checks if this is a parameter change proposal.
func IsProposer
method on ProposalIsProposer checks if the given address is the proposer of this proposal.
func IsTextType
method on ProposalIsTextType checks if this is a text proposal.
func Metadata
method on ProposalMetadata returns the proposal metadata.
func Proposer
method on ProposalProposer returns the address of the proposal creator.
func SnapshotTime
method on ProposalSnapshotTime returns the snapshot time for voting weight lookup.
func Status
method on ProposalStatus returns the proposal status.
func Title
method on ProposalTitle returns the proposal title.
func Type
method on ProposalType returns the type of this proposal.
func VotingMaxWeight
method on ProposalVotingMaxWeight returns maximum possible voting weight for this proposal.
func VotingNoWeight
method on ProposalVotingNoWeight returns the total weight of "no" votes.
func VotingQuorumAmount
method on ProposalVotingQuorumAmount returns minimum vote weight required for proposal to pass.
func VotingYesWeight
method on ProposalVotingYesWeight returns the total weight of "yes" votes.
type ProposalActionStatus
struct 1type ProposalActionStatus struct {
2 canceled bool // Whether the proposal has been canceled
3 canceledAt int64 // Timestamp when proposal was canceled
4 canceledHeight int64 // Block height when proposal was canceled
5 canceledBy address // Who canceled the proposal
6
7 executed bool // Whether the proposal has been executed
8 executedAt int64 // Timestamp when proposal was executed
9 executedHeight int64 // Block height when proposal was executed
10 executedBy address // Who executed the proposal
11
12 executable bool // Whether this proposal type supports execution
13}ProposalActionStatus tracks the execution and cancellation status of a proposal. This structure manages the action-related state including who performed actions and when.
Methods on ProposalActionStatus
func Canceled
method on ProposalActionStatusGetter methods
func CanceledAt
method on ProposalActionStatusfunc CanceledBy
method on ProposalActionStatusCanceledBy returns the address that canceled the proposal. Only meaningful if IsCanceled() returns true.
Returns:
- std.Address: address of the canceller
func CanceledHeight
method on ProposalActionStatusfunc Clone
method on ProposalActionStatusClone creates a deep copy of the ProposalActionStatus.
func Executable
method on ProposalActionStatusfunc Executed
method on ProposalActionStatusfunc ExecutedAt
method on ProposalActionStatusfunc ExecutedBy
method on ProposalActionStatusExecutedBy returns the address that executed the proposal. Only meaningful if IsExecuted() returns true.
Returns:
- std.Address: address of the executor
func ExecutedHeight
method on ProposalActionStatusfunc IsExecutable
method on ProposalActionStatusIsExecutable returns whether this proposal type can be executed. Text proposals return false, while other types return true.
Returns:
- bool: true if proposal type supports execution
func IsExecuted
method on ProposalActionStatusIsExecuted returns whether the proposal has been executed.
Returns:
- bool: true if proposal has been executed
func SetCanceled
method on ProposalActionStatusSetter methods
func SetCanceledAt
method on ProposalActionStatusfunc SetCanceledBy
method on ProposalActionStatusfunc SetCanceledHeight
method on ProposalActionStatusfunc SetExecutable
method on ProposalActionStatusfunc SetExecuted
method on ProposalActionStatusfunc SetExecutedAt
method on ProposalActionStatusfunc SetExecutedBy
method on ProposalActionStatusfunc SetExecutedHeight
method on ProposalActionStatustype ProposalData
structProposalData contains the type-specific data for a proposal. This structure holds different data depending on the proposal type.
Methods on ProposalData
func Clone
method on ProposalDataClone creates a deep copy of the ProposalData.
func CommunityPoolSpend
method on ProposalDataCommunityPoolSpend returns the community pool spending information.
Returns:
- *CommunityPoolSpendInfo: community pool spending details
func Execution
method on ProposalDataExecution returns the execution information for parameter changes.
Returns:
- *ExecutionInfo: parameter change execution details
func ProposalType
method on ProposalDataProposalType returns the type of this proposal.
Returns:
- ProposalType: the proposal type
type ProposalMetadata
structProposalMetadata contains descriptive information about a proposal. This includes the title and description that are displayed to voters.
Methods on ProposalMetadata
func Clone
method on ProposalMetadataClone creates a deep copy of the ProposalMetadata.
func Description
method on ProposalMetadataDescription returns the proposal description.
Returns:
- string: proposal description
func Title
method on ProposalMetadataTitle returns the proposal title.
Returns:
- string: proposal title
type ProposalScheduleStatus
struct1type ProposalScheduleStatus struct {
2 createTime int64 // When the proposal was created
3 activeTime int64 // When voting starts (CreateTime + VotingStartDelay)
4 votingEndTime int64 // When voting ends (ActiveTime + VotingPeriod)
5 executableTime int64 // When execution window starts (VotingEndTime + ExecutionDelay)
6 expiredTime int64 // When execution window ends (ExecutableTime + ExecutionWindow)
7}ProposalScheduleStatus represents the pre-calculated time schedule for a proposal. This structure defines all the important timestamps in a proposal's lifecycle, from creation through voting to execution and expiration.
Methods on ProposalScheduleStatus
func ActiveTime
method on ProposalScheduleStatusfunc Clone
method on ProposalScheduleStatusClone creates a deep copy of the ProposalScheduleStatus.
func CreateTime
method on ProposalScheduleStatusGetter methods
func ExecutableTime
method on ProposalScheduleStatusfunc ExpiredTime
method on ProposalScheduleStatusfunc SetActiveTime
method on ProposalScheduleStatusfunc SetCreateTime
method on ProposalScheduleStatusSetter methods
func SetExecutableTime
method on ProposalScheduleStatusfunc SetExpiredTime
method on ProposalScheduleStatusfunc SetVotingEndTime
method on ProposalScheduleStatusfunc VotingEndTime
method on ProposalScheduleStatustype ProposalStatus
structProposalStatus manages the complete status of a proposal including scheduling, voting, and actions. This is the central status tracking structure that coordinates different aspects of proposal state.
Methods on ProposalStatus
func ActionStatus
method on ProposalStatusfunc Clone
method on ProposalStatusClone creates a deep copy of the ProposalStatus.
func NoWeight
method on ProposalStatusNoWeight returns the total weight of "no" votes.
Returns:
- int64: total "no" vote weight
func Schedule
method on ProposalStatusGetter methods
func VoteStatus
method on ProposalStatusfunc YesWeight
method on ProposalStatusYesWeight returns the total weight of "yes" votes.
Returns:
- int64: total "yes" vote weight
type ProposalStatusType
identProposalStatusType represents the current status of a proposal in its lifecycle. These statuses determine what actions are available for a proposal.
type ProposalType
identProposalType defines the different types of proposals supported by the governance system. Each type has different execution behavior and validation requirements.
Methods on ProposalType
func IsExecutable
method on ProposalTypeIsExecutable determines whether this proposal type can be executed. Text proposals are informational only and cannot be executed.
func String
method on ProposalTypeString returns the human-readable string representation of the proposal type.
type ProposalVoteStatus
struct1type ProposalVoteStatus struct {
2 yea int64 // Total weight of "yes" votes collected
3 nay int64 // Total weight of "no" votes collected
4 maxVotingWeight int64 // The max voting weight at the time of proposal creation
5 quorumAmount int64 // How many total votes must be collected for the proposal to be valid
6}ProposalVoteStatus tracks the voting tallies and requirements for a proposal. This structure manages vote counting, quorum calculation, and voting outcome determination.
Methods on ProposalVoteStatus
func Clone
method on ProposalVoteStatusClone creates a deep copy of the ProposalVoteStatus.
func MaxVotingWeight
method on ProposalVoteStatusGetter methods
func NoWeight
method on ProposalVoteStatusNoWeight returns the total weight of "no" votes.
Returns:
- int64: total "no" vote weight
func QuorumAmount
method on ProposalVoteStatusfunc SetMaxVotingWeight
method on ProposalVoteStatusfunc SetNoWeight
method on ProposalVoteStatusfunc SetQuorumAmount
method on ProposalVoteStatusfunc SetYesWeight
method on ProposalVoteStatusSetter methods
func YesWeight
method on ProposalVoteStatusYesWeight returns the total weight of "yes" votes.
Returns:
- int64: total "yes" vote weight
type StoreKey
identtype VotingInfo
struct1type VotingInfo struct {
2 availableVoteWeight int64 // Total voting weight available to this user for this proposal
3 votedWeight int64 // Actual weight used when voting (0 if not voted)
4 votedHeight int64 // Block height when vote was cast
5 votedAt int64 // Timestamp when vote was cast
6 votedYes bool // True if voted "yes", false if voted "no"
7 voted bool // True if user has already voted
8}VotingInfo tracks voting-related information for a specific user on a specific proposal. This structure maintains the user's voting eligibility, voting history, and voting power.
Methods on VotingInfo
func AvailableVoteWeight
method on VotingInfoAvailableVoteWeight returns the total voting weight available to this user. This weight is determined at proposal creation time based on delegation snapshots.
Returns:
- int64: available voting weight
func Clone
method on VotingInfoClone creates a deep copy of the VotingInfo.
func IsVoted
method on VotingInfoIsVoted checks if the user has already cast their vote.
Returns:
- bool: true if user has voted on this proposal
func SetAvailableVoteWeight
method on VotingInfoSetter methods
func SetVoted
method on VotingInfofunc SetVotedAt
method on VotingInfofunc SetVotedHeight
method on VotingInfofunc SetVotedWeight
method on VotingInfofunc SetVotedYes
method on VotingInfofunc VotedAt
method on VotingInfoVotedAt returns the timestamp when the vote was cast. Returns 0 if the user hasn't voted yet.
Returns:
- int64: timestamp when vote was cast
func VotedHeight
method on VotingInfoVotedHeight returns the block height when the vote was cast. Returns 0 if the user hasn't voted yet.
Returns:
- int64: block height when vote was cast
func VotedNo
method on VotingInfoVotedNo checks if the user voted "no" on the proposal. Only meaningful if IsVoted() returns true.
Returns:
- bool: true if user voted "no"
func VotedWeight
method on VotingInfoVotedWeight returns the weight actually used when voting. Returns 0 if the user hasn't voted yet.
Returns:
- int64: weight used for voting, or 0 if not voted
func VotedYes
method on VotingInfoVotedYes checks if the user voted "yes" on the proposal. Only meaningful if IsVoted() returns true.
Returns:
- bool: true if user voted "yes"
func VotingType
method on VotingInfoVotingType returns a human-readable string representation of the vote choice.
Returns:
- string: "yes" or "no" based on voting choice