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 source realm

Readme View source

Governance

Decentralized protocol governance via GNS staking and voting.

Overview

Governance enables GNS holders to stake through gov/staker, receive xGNS, delegate voting power, create proposals, and vote on protocol changes. For more details, check out docs.

Configuration

The governance.Config type defines the governance parameters. The values used by a proposal are stored with that proposal; later reconfiguration does not rewrite an existing proposal. The current configuration can be changed through the governance Reconfigure handler. This type can be found in ../config.gno.

Field Description Default
VotingStartDelay Delay before voting starts after proposal creation 1 day
VotingPeriod Duration for collecting votes 7 days
VotingWeightSmoothingDuration Duration used for timestamp-based voting-weight averaging 1 day
Quorum Percentage of total xGNS supply required for proposal passage; total supply includes launchpad-held issuance 50%
ProposalCreationThreshold Minimum xGNS balance required to create a proposal 1,000,000,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

All values are configurable; the values above are the defaults in NewDefaultConfig.

Core Mechanics

Staking Flow

1GNS → Delegate → xGNS + delegated voting history → Vote
  1. Delegate GNS through gov/staker to receive an equal amount of xGNS.
  2. Assign voting power to a delegatee (which may be the delegator itself).
  3. Vote on proposals with the delegatee's timestamped delegation weight.
  4. Undelegation removes voting power immediately; the default lockup before collecting GNS is 7 days and is configurable.

Launchpad-backed xGNS is included in total xGNS supply for quorum, but is not an ordinary user delegation record.

Proposal Types

  • Text: Signal proposals without execution.
  • CommunityPoolSpend: Treasury disbursements encoded as a community-pool transfer on execution.
  • ParameterChange: Protocol parameter updates dispatched to registered handlers.

Proposal Lifecycle

Creation

  • Requires the configured ProposalCreationThreshold xGNS balance (1,000,000,000 xGNS by default).
  • One active proposal per address.
  • Valid type and parameters are required. Community-pool spend amounts must be strictly positive, recipients must be valid, and token paths must be registered.
  • A proposal stores its configuration version, creation timestamp, creation block height, quorum amount, and timestamp used for historical delegation lookup. The block height is metadata; voting-weight lookup is timestamp-based.

Voting

  • Voting starts after the configured start delay (1 day by default) and runs for the configured voting period (7 days by default).
  • Weight is the average of the caller's delegation at the proposal's stored snapshot timestamp and at proposal creation time. The snapshot timestamp is createdAt - VotingWeightSmoothingDuration (clamped at zero), and the smoothing duration defaults to 24 hours.
  • Each address can vote only once on a proposal. Vote returns the applied vote weight as a decimal string.

Execution

A proposal is considered valid and executable when:

  • The voting period has ended.
  • Total votes meet the quorum amount computed at creation from the total xGNS supply (including launchpad-held issuance) and the proposal's configured quorum percentage.
  • YES votes strictly exceed NO votes (ties do not pass).
  • The configured execution delay (1 day by default) has passed after voting ends.
  • Execution occurs within the configured execution window (30 days by default).
  • Text proposals are informational and cannot be executed; anyone can trigger execution of an approved executable proposal.

An approved community-pool spend can still fail at execution if the pool no longer has enough of the registered token.

Technical Details

Vote Weight Calculation

1// `smoothing` is the proposal's configured VotingWeightSmoothingDuration.
2snapshotTime = max(createdAt - smoothing, 0)
3weightAtSnapshot = getDelegationAt(voter, snapshotTime)
4weightAtCreation = getDelegationAt(voter, createdAt)
5voteWeight = (weightAtSnapshot + weightAtCreation) / 2

The lookups read delegation history by Unix timestamp. This is not a block-height snapshot.

Quorum Calculation

1quorumWeight = totalXGnsSupplyAtProposalCreation // includes launchpad-held xGNS
2quorumAmount = quorumWeight * quorumPercent / 100  // quorumPercent defaults to 50

The quorum amount is stored on the proposal and is not recomputed from the proposer's or voters' smoothed voting weight. A proposal passes only when total votes reach quorum and accumulated YES votes strictly exceed accumulated NO votes.

Rewards Distribution

Gov/staker exposes two reward streams:

  1. GNS emission rewards use the emission accumulator and each staker's own stake history.
  2. Protocol-fee rewards are tracked per token and accrual epoch. Each consumed bucket is divided by the total stake in force during that epoch, added to that token's Q128 accumulator, and settled over the staker's stake-event segments. Sub-unit Q128 remainders are retained for later collection.

CollectReward settles the emission stream and every known protocol-fee token. CollectEmissionReward and CollectProtocolFeeReward(tokenPath) are narrower paths; the token-specific protocol-fee path bounds both pending accrual buckets and stake events per call, so remaining work is collected later. Launchpad project wallets use the corresponding launchpad-only entry points.

Usage

These snippets call the public domain proxies from a realm function with a current cur token. Import the corresponding proxy packages and qualify their function names in integrating code.

 1// Through gov/staker: delegate GNS for xGNS voting power.
 2Delegate(cross(cur), delegatee, 1_000_000_000, "g1referrer...")
 3
 4// Create a text or community-pool proposal.
 5ProposeText(cross(cur), "Title", "Description")
 6ProposeCommunityPoolSpend(cross(cur), "Title", "Description", recipient, tokenPath, amount)
 7
 8// A parameter-change execution uses a registered handler. This is one valid
 9// Reconfigure message (all seven parameters are required).
10execution := "gno.land/r/gnoswap/gov/governance*EXE*Reconfigure*EXE*86400,604800,86400,50,1000000000,86400,2592000"
11ProposeParameterChange(cross(cur), "Update config", "Rationale", 1, execution)
12
13// Vote; the return value is the applied weight formatted as a decimal string.
14voteWeight := Vote(cross(cur), proposalId, true) // YES
15
16// Execute after the configured timelock and then, if needed, start undelegation.
17Execute(cross(cur), proposalId)
18Undelegate(cross(cur), delegatee, 250_000_000)
19
20// Collect only after the configured undelegation lockup has expired.
21CollectUndelegatedGns(cross(cur))

Security

  • Timestamp-based smoothing reduces flash-loan-style voting manipulation; it is not a block snapshot.
  • Sybil resistance comes from stake-weighted delegation.
  • The execution delay and window constrain when approved executable proposals can run.
  • A single active proposal is allowed per proposer address.
  • Quorum is fixed from the creation-time total xGNS supply, including launchpad-held issuance.
  • Community-pool balance is checked when the approved transfer executes, not when the proposal is created.

Constants 1

const GNS_TOKEN_KEY, HALT_PATH, RBAC_PATH, ACCESS_PATH, EMISSION_PATH, COMMON_PATH, POOL_PATH, POSITION_PATH, ROUTER_PATH, STAKER_PATH, LAUNCHPAD_PATH, PROTOCOL_FEE_PATH, COMMUNITY_POOL_PATH, GOV_GOVERNANCE_PATH, GOV_STAKER_PATH

 1const (
 2	GNS_TOKEN_KEY       = "gno.land/r/gnoswap/gns.GNS"
 3	HALT_PATH           = "gno.land/r/gnoswap/halt/v1"
 4	RBAC_PATH           = "gno.land/r/gnoswap/rbac/v1"
 5	ACCESS_PATH         = "gno.land/r/gnoswap/access/v1"
 6	EMISSION_PATH       = "gno.land/r/gnoswap/emission"
 7	COMMON_PATH         = "gno.land/r/gnoswap/common"
 8	POOL_PATH           = "gno.land/r/gnoswap/pool"
 9	POSITION_PATH       = "gno.land/r/gnoswap/position"
10	ROUTER_PATH         = "gno.land/r/gnoswap/router"
11	STAKER_PATH         = "gno.land/r/gnoswap/staker"
12	LAUNCHPAD_PATH      = "gno.land/r/gnoswap/launchpad"
13	PROTOCOL_FEE_PATH   = "gno.land/r/gnoswap/protocol_fee"
14	COMMUNITY_POOL_PATH = "gno.land/r/gnoswap/community_pool/v1"
15	GOV_GOVERNANCE_PATH = "gno.land/r/gnoswap/gov/governance"
16	GOV_STAKER_PATH     = "gno.land/r/gnoswap/gov/staker"
17)
source

Package paths

Functions 16

func NewGovernanceV1

Action
1func NewGovernanceV1(
2	governanceStore governance.IGovernanceStore,
3	stakerAccessor governance.GovStakerAccessor,
4) governance.IGovernance
source

NewGovernanceV1 creates a governance v1 implementation backed by the supplied state store and staker voting-weight accessor.

Parameters:

  • governanceStore: persistence adapter for configuration, proposals, counters, and voting information
  • stakerAccessor: accessor that supplies delegation snapshots and total xGNS supply for governance decisions

Returns:

  • governance.IGovernance: governance manager and getter implementation using the supplied dependencies

func NewProposalCommunityPoolSpendData

Action
1func NewProposalCommunityPoolSpendData(
2	tokenPath string,
3	to address,
4	amount int64,
5	communityPoolPackagePath string,
6) *governance.ProposalData
source

NewProposalCommunityPoolSpendData creates proposal data for a community pool spend proposal. Automatically generates the execution message for the token transfer.

Parameters:

  • tokenPath: path of the token to transfer
  • to: recipient address for the transfer
  • amount: amount of tokens to transfer
  • communityPoolPackagePath: package path of the community pool contract

Returns:

  • *ProposalData: proposal data configured for community pool spending

func NewProposalExecutionData

Action
1func NewProposalExecutionData(numToExecute int64, executions string) *governance.ProposalData
source

NewProposalExecutionData creates proposal data for a parameter change proposal. Each message in executions should be formatted as <pkgPath>*EXE*<function>*EXE*<params>, separated by *GOV* when there are multiple messages.

Parameters:

  • numToExecute: number of parameter changes to execute
  • executions: raw encoded execution string with parameter changes

Returns:

  • *ProposalData: proposal data configured for parameter changes

func NewProposalScheduleStatus

Action
1func NewProposalScheduleStatus(
2	votingStartDelay,
3	votingPeriod,
4	executionDelay,
5	executionWindow,
6	createdAt int64,
7) *governance.ProposalScheduleStatus
source

NewProposalScheduleStatus creates a new schedule status with calculated timestamps. This constructor takes the governance timing parameters and calculates all important timestamps for the proposal's lifecycle.

Parameters:

  • votingStartDelay: delay before voting starts (seconds)
  • votingPeriod: duration of voting period (seconds)
  • executionDelay: delay before execution can start (seconds)
  • executionWindow: window during which execution is allowed (seconds)
  • createdAt: timestamp when proposal was created

Returns:

  • *ProposalScheduleStatus: new schedule status with calculated times

func NewProposalStatus

Action
1func NewProposalStatus(
2	config governance.Config,
3	maxVotingWeight int64,
4	executable bool,
5	createdAt int64,
6	quorumWeight int64,
7) *governance.ProposalStatus
source

NewProposalStatus creates a new proposal status with the specified configuration. This initializes all status components with the governance configuration and timing.

Parameters:

  • config: governance configuration to use
  • maxVotingWeight: maximum voting weight for this proposal
  • executable: whether this proposal type can be executed
  • createdAt: timestamp when proposal was created
  • quorumWeight: total xGNS supply at proposal creation, used as the quorum base

Returns:

  • *ProposalStatus: new proposal status instance

func NewProposalTextData

Action
1func NewProposalTextData() *governance.ProposalData
source

NewProposalTextData creates proposal data for a text proposal. Text proposals have no additional data requirements.

Returns:

  • *ProposalData: proposal data configured for text proposal

func NewParameterHandlerOptions

Action
1func NewParameterHandlerOptions(
2	pkgPath,
3	function string,
4	paramCount int,
5	handlerFunc func(_ int, rlm realm, _ []string) error,
6	paramValidators ...paramValidator,
7) ParameterHandler
source

NewParameterHandlerOptions creates a new parameter handler with the specified configuration.

Parameters:

  • pkgPath: package path of the target contract
  • function: function name to be called
  • paramCount: expected number of parameters
  • handlerFunc: callback receiving the discriminator, propagated realm, and serialized parameters to execute the change
  • paramValidators: optional validators for each parameter (must match paramCount if provided)

Returns:

  • ParameterHandler: configured parameter handler interface

func CreateParameterHandlers

Action
1func CreateParameterHandlers() *ParameterRegistry
source

CreateParameterHandlers initializes and configures all supported parameter handlers. This function defines all the parameter changes that can be executed through governance proposals. It covers configuration changes for various system components including pools, staking, fees, etc.

Returns:

  • *ParameterRegistry: fully configured registry with all supported handlers

func NewParameterRegistry

Action
1func NewParameterRegistry() *ParameterRegistry
source

NewParameterRegistry creates a new empty parameter registry.

Returns:

  • *ParameterRegistry: new registry instance

func NewProposalActionStatusResolver

Action
1func NewProposalActionStatusResolver(status *governance.ProposalActionStatus) *ProposalActionStatusResolver
source

NewProposalActionStatusResolver wraps a proposal action status for mutation and execution-state queries.

Parameters:

  • status: proposal action status to resolve and update.

Returns:

  • *ProposalActionStatusResolver: resolver backed by status.

func NewProposalDataResolver

Action
1func NewProposalDataResolver(proposalData *governance.ProposalData) *ProposalDataResolver
source

NewProposalDataResolver wraps proposal data for type-specific validation and execution-message parsing.

Parameters:

  • proposalData: proposal data to resolve and validate.

Returns:

  • *ProposalDataResolver: resolver backed by proposalData.

func NewProposalMetadataResolver

Action
1func NewProposalMetadataResolver(metadata *governance.ProposalMetadata) *ProposalMetadataResolver
source

NewProposalMetadataResolver wraps proposal metadata for validation.

Parameters:

  • metadata: proposal title and description to validate.

Returns:

  • *ProposalMetadataResolver: resolver backed by metadata.

func NewProposalResolver

Action
1func NewProposalResolver(proposal *governance.Proposal) *ProposalResolver
source

NewProposalResolver wraps a persisted governance proposal and initializes resolvers for its status, type-specific data, and metadata.

Parameters:

  • proposal: persisted proposal to resolve

Returns:

  • *ProposalResolver: resolver backed by proposal and its nested state

func NewProposalScheduleStatusResolver

Action
1func NewProposalScheduleStatusResolver(status *governance.ProposalScheduleStatus) *ProposalScheduleStatusResolver
source

NewProposalScheduleStatusResolver wraps a proposal schedule for phase-boundary queries.

Parameters:

  • status: proposal schedule containing creation, voting, and execution timestamps

Returns:

  • *ProposalScheduleStatusResolver: resolver backed by status

func NewProposalStatusResolver

Action
1func NewProposalStatusResolver(status *governance.ProposalStatus) *ProposalStatusResolver
source

NewProposalStatusResolver wraps proposal status components for lifecycle and vote queries.

Parameters:

  • status: proposal status containing schedule, action, and vote state

Returns:

  • *ProposalStatusResolver: resolver backed by status

func NewProposalVoteStatusResolver

Action
1func NewProposalVoteStatusResolver(voteStatus *governance.ProposalVoteStatus) *ProposalVoteStatusResolver
source

NewProposalVoteStatusResolver wraps persisted vote status for vote tally calculations and mutation.

Parameters:

  • voteStatus: persisted proposal vote status to resolve

Returns:

  • *ProposalVoteStatusResolver: resolver backed by voteStatus

Types 10

type ParameterHandler

interface
 1type ParameterHandler interface {
 2	// Execute processes the parameters and applies the changes to the system.
 3	// The `_ int, rlm realm` discriminator pair forwards the governance proxy's
 4	// realm value into the handler so any cross-realm calls inside the closure
 5	// run under the proxy's identity (the only address with caller-allowlist
 6	// permission against the targeted /r/ realms).
 7	//
 8	// Parameters:
 9	//   - _: integer discriminator required by the crossing entrypoint; callers use 0
10	//   - rlm: current governance proxy realm context forwarded to the handler
11	//   - params: serialized parameter values to validate and apply in handler order
12	//
13	// Returns:
14	//   - error: nil when the parameter change succeeds, or an execution/validation error
15	Execute(_ int, rlm realm, params []string) error
16}
source

ParameterHandler interface defines the contract for parameter execution handlers. Each handler is responsible for executing specific parameter changes in the system.

type ParameterHandlerOptions

struct
1type ParameterHandlerOptions struct {
2	pkgPath            string                                   // Package path of the target contract
3	function           string                                   // Function name to be called
4	paramCount         int                                      // Expected number of parameters
5	handlerFunc        func(_ int, rlm realm, _ []string) error // Function that executes the parameter change
6	paramValidators    []paramValidator                         // Optional per-parameter validators for proposal-time checks
7	compositeValidator compositeValidator                       // Optional cross-parameter validator for static business rules
8}
source

ParameterHandlerOptions contains the configuration and execution logic for a parameter handler. This struct encapsulates all information needed to identify and execute a parameter change.

NOTE: handlerFunc uses `rlm realm` (rather than `cur realm`) as the realm parameter name. The v2 preprocessor reserves the `cur` name for the first realm-type parameter of top-level crossing function declarations and `t.Run` closures only; using it as the realm-parameter name on a multi-parameter struct-field function value trips a parser check ("only the first realm type argument of a crossing function may have name `cur`"). Naming it `rlm` keeps the lowering identical without the syntax constraint.

Methods on ParameterHandlerOptions

func Execute

method on ParameterHandlerOptions
1func (h *ParameterHandlerOptions) Execute(_ int, rlm realm, params []string) error
source

Execute validates parameter count and executes the handler function. This method ensures the correct number of parameters are provided before execution.

Parameters:

  • _: integer discriminator required by the crossing entrypoint; callers use 0
  • rlm: governance proxy realm threaded into the wrapped handler
  • params: serialized parameter values to pass to the handler

Returns:

  • error: parameter-count error or the error returned by the wrapped handler

func HandlerKey

method on ParameterHandlerOptions
1func (h *ParameterHandlerOptions) HandlerKey() string
source

HandlerKey generates a unique key for this handler based on package path and function name.

Returns:

  • string: unique identifier for the handler

func ValidateParams

method on ParameterHandlerOptions
1func (h *ParameterHandlerOptions) ValidateParams(params []string) error
source

ValidateParams checks the parameter count and runs configured individual and composite validators without executing the handler.

Parameters:

  • params: serialized parameter values to validate in handler order

Returns:

  • error: nil when all configured checks pass, or the first count/type/business-rule validation error

type ParameterRegistry

struct
1type ParameterRegistry struct {
2	handlers map[string]ParameterHandlerOptions // Map storing handler configurations keyed by package:function
3}
source

ParameterRegistry manages the collection of parameter handlers for governance execution. This registry allows proposals to execute parameter changes across different system contracts.

Methods on ParameterRegistry

func Handler

method on ParameterRegistry
1func (r *ParameterRegistry) Handler(key string) (ParameterHandler, error)
source

Handler retrieves a parameter handler by its package:function key. This method is used during proposal execution to find the appropriate handler.

Parameters:

  • key: handler key returned by HandlerKey, in "pkgPath:function" format

Returns:

  • ParameterHandler: the matching parameter handler
  • error: error if the key has no registered handler

func Register

method on ParameterRegistry
1func (r *ParameterRegistry) Register(handler ParameterHandlerOptions)
source

Register adds a new parameter handler to the registry. Each handler is identified by a unique combination of package path and function name.

Parameters:

  • handler: parameter handler configuration to register

type ProposalActionStatusResolver

struct
1type ProposalActionStatusResolver struct {
2	*governance.ProposalActionStatus
3}
source

Methods on ProposalActionStatusResolver

func Execute

method on ProposalActionStatusResolver
1func (p *ProposalActionStatusResolver) Execute(
2	executedAt, executedHeight int64,
3	executedBy address,
4) error
source

Execute marks the proposal as executed and records execution details. This method validates that the proposal is eligible for execution.

Parameters:

  • executedAt: Unix timestamp when execution occurred.
  • executedHeight: block height when execution occurred.
  • executedBy: address performing the execution.

Returns:

  • error: nil on success; an error when the proposal is not executable or has already been canceled.

type ProposalDataResolver

struct
1type ProposalDataResolver struct {
2	*governance.ProposalData
3}
source

ProposalDataResolver handles business logic for proposal data.

Methods on ProposalDataResolver

func ParameterChangesInfos

method on ProposalDataResolver
1func (r *ProposalDataResolver) ParameterChangesInfos() ([]governance.ParameterChangeInfo, error)
source

ParameterChangesInfos parses the execution messages and returns structured parameter change information. Each message is expected to be in format: pkgPath*EXE*function*EXE*params

Returns:

  • []ParameterChangeInfo: slice of parsed parameter change information
  • error: validation error if any execution message is malformed

func Validate

method on ProposalDataResolver
1func (r *ProposalDataResolver) Validate() error
source

Validate performs type-specific validation of the proposal data. Different proposal types have different validation requirements.

Returns:

  • error: validation error if data is invalid

type ProposalMetadataResolver

struct
1type ProposalMetadataResolver struct {
2	*governance.ProposalMetadata
3}
source

Methods on ProposalMetadataResolver

func Validate

method on ProposalMetadataResolver
1func (r *ProposalMetadataResolver) Validate() error
source

Validate performs comprehensive validation of the proposal metadata. Checks title and description length and content requirements.

Returns:

  • error: validation error if metadata is invalid

type ProposalResolver

struct
1type ProposalResolver struct {
2	*governance.Proposal
3	statusResolver   *ProposalStatusResolver
4	dataResolver     *ProposalDataResolver
5	metadataResolver *ProposalMetadataResolver
6}
source

Methods on ProposalResolver

func CommunityPoolSpendTokenPath

method on ProposalResolver
1func (r *ProposalResolver) CommunityPoolSpendTokenPath() string
source

CommunityPoolSpendTokenPath returns the token path for a community pool spend proposal. It returns an empty string when the proposal has no community-pool spend data.

Returns:

  • string: token package path to spend, or empty string for other proposal types

func IsActive

method on ProposalResolver
1func (r *ProposalResolver) IsActive(current int64) bool
source

IsActive determines whether the proposal is active at current. Upcoming, voting, and passed executable proposals are active; rejected, expired, executed, canceled, and passed text proposals are inactive.

Parameters:

  • current: timestamp at which the proposal status is evaluated

Returns:

  • bool: true when the proposal can still be voted on or executed at current

func IsExecutable

method on ProposalResolver
1func (r *ProposalResolver) IsExecutable(current int64) bool
source

IsExecutable determines whether the proposal can be executed at current. The proposal type must support execution and its status must be executable.

Parameters:

  • current: timestamp at which execution eligibility is evaluated

Returns:

  • bool: true when this type and current lifecycle state permit execution

func IsVotingPeriod

method on ProposalResolver
1func (r *ProposalResolver) IsVotingPeriod(votedAt int64) bool
source

IsVotingPeriod reports whether votedAt falls within the proposal's active voting status.

Parameters:

  • votedAt: timestamp at which voting eligibility is checked

Returns:

  • bool: true when the proposal status at votedAt is StatusActive

func Status

method on ProposalResolver
1func (r *ProposalResolver) Status(current int64) string
source

Status returns the current status string of the proposal at current.

Parameters:

  • current: timestamp at which the proposal status is evaluated

Returns:

  • string: human-readable status name for the proposal at current

func StatusType

method on ProposalResolver
1func (r *ProposalResolver) StatusType(current int64) governance.ProposalStatusType
source

StatusType returns the current status type of the proposal at current.

Parameters:

  • current: timestamp at which the proposal status is evaluated

Returns:

  • governance.ProposalStatusType: lifecycle status at current

func Validate

method on ProposalResolver
1func (r *ProposalResolver) Validate() error
source

Validate performs comprehensive validation of the proposal's type-specific data and metadata before the proposal is stored.

Returns:

  • error: nil when both data and metadata validate; the first validation error otherwise

func Vote

method on ProposalResolver
1func (r *ProposalResolver) Vote(votedYes bool, weight int64) error
source

Vote records a vote for this proposal and updates its yes or no tally. This is an internal method called during the voting process.

Parameters:

  • votedYes: true to add weight to the yes tally; false to add it to no
  • weight: voting weight to add to the selected tally

Returns:

  • error: nil when the selected tally is updated; an error from vote-status validation otherwise

func VotingTotalWeight

method on ProposalResolver
1func (r *ProposalResolver) VotingTotalWeight() int64
source

VotingTotalWeight returns the total weight of all votes cast by combining the proposal's yes and no tallies.

Returns:

  • int64: combined weight of all recorded votes

type ProposalScheduleStatusResolver

struct
1type ProposalScheduleStatusResolver struct {
2	*governance.ProposalScheduleStatus
3}
source

Methods on ProposalScheduleStatusResolver

func IsPassedActiveAt

method on ProposalScheduleStatusResolver
1func (p *ProposalScheduleStatusResolver) IsPassedActiveAt(current int64) bool
source

IsPassedActiveAt checks if the current time has passed the voting start time. When true, the proposal enters its active voting period.

Parameters:

  • current: timestamp to check against

Returns:

  • bool: true if voting period has started

func IsPassedCreatedAt

method on ProposalScheduleStatusResolver
1func (p *ProposalScheduleStatusResolver) IsPassedCreatedAt(current int64) bool
source

IsPassedCreatedAt checks if the current time has passed the proposal creation time. This is always true once a proposal exists.

Parameters:

  • current: timestamp to check against

Returns:

  • bool: true if current time is at or after creation time

func IsPassedExecutableAt

method on ProposalScheduleStatusResolver
1func (p *ProposalScheduleStatusResolver) IsPassedExecutableAt(current int64) bool
source

IsPassedExecutableAt checks if the current time has passed the execution start time. When true, approved proposals can be executed (after execution delay).

Parameters:

  • current: timestamp to check against

Returns:

  • bool: true if execution window has started

func IsPassedExpiredAt

method on ProposalScheduleStatusResolver
1func (p *ProposalScheduleStatusResolver) IsPassedExpiredAt(current int64) bool
source

IsPassedExpiredAt checks if the current time has passed the execution expiration time. When true, the proposal can no longer be executed and has expired.

Parameters:

  • current: timestamp to check against

Returns:

  • bool: true if execution window has expired

func IsPassedVotingEndedAt

method on ProposalScheduleStatusResolver
1func (p *ProposalScheduleStatusResolver) IsPassedVotingEndedAt(current int64) bool
source

IsPassedVotingEndedAt checks if the current time has passed the voting end time. When true, no more votes can be cast on the proposal.

Parameters:

  • current: timestamp to check against

Returns:

  • bool: true if voting period has ended

type ProposalStatusResolver

struct
1type ProposalStatusResolver struct {
2	*governance.ProposalStatus
3	scheduleResolver     *ProposalScheduleStatusResolver
4	actionStatusResolver *ProposalActionStatusResolver
5	voteStatusResolver   *ProposalVoteStatusResolver
6}
source

Methods on ProposalStatusResolver

func IsActive

method on ProposalStatusResolver
1func (p *ProposalStatusResolver) IsActive(current int64) bool
source

IsActive checks if the proposal is in active voting status.

Parameters:

  • current: timestamp to check status at

Returns:

  • bool: true if proposal is active (voting period)

func IsCanceled

method on ProposalStatusResolver
1func (p *ProposalStatusResolver) IsCanceled(current int64) bool
source

IsCanceled checks if the proposal has been canceled.

Parameters:

  • current: timestamp to check status at

Returns:

  • bool: true if proposal has been canceled

func IsExecutable

method on ProposalStatusResolver
1func (p *ProposalStatusResolver) IsExecutable(current int64) bool
source

IsExecutable checks if the proposal is in executable status.

Parameters:

  • current: timestamp to check status at

Returns:

  • bool: true if proposal can be executed

func IsExecuted

method on ProposalStatusResolver
1func (p *ProposalStatusResolver) IsExecuted(current int64) bool
source

IsExecuted checks if the proposal has been executed.

Parameters:

  • current: timestamp to check status at

Returns:

  • bool: true if proposal has been executed

func IsExpired

method on ProposalStatusResolver
1func (p *ProposalStatusResolver) IsExpired(current int64) bool
source

IsExpired checks if the proposal execution window has expired.

Parameters:

  • current: timestamp to check status at

Returns:

  • bool: true if proposal has expired

func IsPassed

method on ProposalStatusResolver
1func (p *ProposalStatusResolver) IsPassed(current int64) bool
source

IsPassed checks if the proposal has passed voting.

Parameters:

  • current: timestamp to check status at

Returns:

  • bool: true if proposal has passed

func IsRejected

method on ProposalStatusResolver
1func (p *ProposalStatusResolver) IsRejected(current int64) bool
source

IsRejected checks if the proposal has been rejected by voting.

Parameters:

  • current: timestamp to check status at

Returns:

  • bool: true if proposal was rejected

func IsUpcoming

method on ProposalStatusResolver
1func (p *ProposalStatusResolver) IsUpcoming(current int64) bool
source

IsUpcoming checks if the proposal is in upcoming status.

Parameters:

  • current: timestamp to check status at

Returns:

  • bool: true if proposal is upcoming

func StatusType

method on ProposalStatusResolver
1func (p *ProposalStatusResolver) StatusType(current int64) governance.ProposalStatusType
source

StatusType determines the current status of the proposal based on timing, voting, and actions. This is the main status calculation method that considers all factors.

Parameters:

  • current: current timestamp to evaluate status at

Returns:

  • ProposalStatusType: current status of the proposal

func TotalVoteWeight

method on ProposalStatusResolver
1func (p *ProposalStatusResolver) TotalVoteWeight() int64
source

TotalVoteWeight returns the total weight of all votes cast.

Returns:

  • int64: total vote weight

type ProposalVoteStatusResolver

struct
1type ProposalVoteStatusResolver struct {
2	*governance.ProposalVoteStatus
3}
source

Methods on ProposalVoteStatusResolver

func AddNoVoteWeight

method on ProposalVoteStatusResolver
1func (p *ProposalVoteStatusResolver) AddNoVoteWeight(nay int64) error
source

addNoVoteWeight adds the specified weight to the "no" vote tally. This is called when a user votes "no" on the proposal.

Parameters:

  • nay: vote weight to add to "no" votes

Returns:

  • error: always nil (reserved for future validation)

func AddYesVoteWeight

method on ProposalVoteStatusResolver
1func (p *ProposalVoteStatusResolver) AddYesVoteWeight(yea int64) error
source

addYesVoteWeight adds the specified weight to the "yes" vote tally. This is called when a user votes "yes" on the proposal.

Parameters:

  • yea: vote weight to add to "yes" votes

Returns:

  • error: always nil (reserved for future validation)

func IsPassed

method on ProposalVoteStatusResolver
1func (p *ProposalVoteStatusResolver) IsPassed() bool
source

IsPassed determines if the proposal has passed the voting requirements. A proposal passes when total vote weight reaches quorum and "yes" votes strictly exceed "no" votes.

Returns:

  • bool: true when quorum is met and yes weight is greater than no weight

func TotalVoteWeight

method on ProposalVoteStatusResolver
1func (p *ProposalVoteStatusResolver) TotalVoteWeight() int64
source

TotalVoteWeight returns the total weight of all votes cast (yes + no).

Returns:

  • int64: combined "yes" and "no" vote weight

Imports 29

Source Files 23