PathrockNetwork Gno Explorer
HomeBlocksTransactionsTokensRealmsPackagesValidatorsAnalytics

PathrockNetwork Gno Explorer — an independent explorer for Gno.land Mainnet (gnoland-1), operated by PathrockNetwork. Not an official Gno.land service.

gnowebarchive RPC

gno.land/r/gnoswap/gov/governance

Realm
Open in gnoweb ↗

Overview

Kind
Realm (renderable)
Name
governance
Namespace
gnoswap / gov
Files
21 (README)(gnomod.toml)
Exported functions
64
Module
gno.land/r/gnoswap/gov/governance
gno
0.9

Files (21)

  • README.mdmarkdown
  • gnomod.tomltoml
  • accessor.gnogno
  • config.gnogno
  • counter.gnogno
  • doc.gnogno
  • getters.gnogno
  • proposal_action_status.gnogno
  • proposal_data.gnogno
  • proposal_schedule_status.gnogno
  • proposal_status.gnogno
  • proposal_type.gnogno
  • proposal_vote_status.gnogno
  • proposal.gnogno
  • proxy.gnogno
  • render.gnogno
  • state.gnogno
  • store.gnogno
  • types.gnogno
  • upgrade.gnogno
  • voting_info.gnogno
  • config.gnogno
    1package governance23import (4	"errors"56	bptree "gno.land/p/nt/bptree/v0"7)8

    Functions

    • Cancel(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, proposalId int64) int64

    • DefaultVotingInfo() struct{availableVoteWeight int64; votedWeight int64; votedHeight int64; votedAt int64; votedYes bool; voted bool}

    • Execute(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, proposalId int64) int64

    • ExistsProposal(proposalID int64) bool

    • ExistsVotingInfo(proposalID int64, addr string) bool

    • GetConfig(configVersion int64) (struct{VotingStartDelay int64; VotingPeriod int64; VotingWeightSmoothingDuration int64; Quorum int64; ProposalCreationThreshold int64; ExecutionDelay int64; ExecutionWindow int64}, interface {Error func() string})

    • GetConfigVersionByProposalId(proposalId int64) (int64, interface {Error func() string})

    • GetCurrentProposalID() int64

    • GetCurrentVotingWeightSnapshot() (int64, int64, interface {Error func() string})

    • GetDescriptionByProposalId(proposalId int64) (string, interface {Error func() string})

    • GetImplementationPackagePath() string

    • GetLatestConfig() (struct{VotingStartDelay int64; VotingPeriod int64; VotingWeightSmoothingDuration int64; Quorum int64; ProposalCreationThreshold int64; ExecutionDelay int64; ExecutionWindow int64}, interface {Error func() string})

    • GetLatestConfigVersion() int64

    • GetMaxSmoothingPeriod() int64

    • GetNayByProposalId(proposalId int64) (int64, interface {Error func() string})

    • GetOldestActiveProposalSnapshotTime() (int64, bool, interface {Error func() string})

    • GetProposalCommunityPoolSpendInfo(proposalID int64) (*gno.land/r/gnoswap/gov/governance.CommunityPoolSpendInfo, interface {Error func() string})

    • GetProposalCreatedAt(proposalId int64) (int64, interface {Error func() string})

    • GetProposalCreatedHeight(proposalId int64) (int64, interface {Error func() string})

    • GetProposalExecutionInfo(proposalID int64) (*gno.land/r/gnoswap/gov/governance.ExecutionInfo, interface {Error func() string})

    • GetProposals() *gno.land/p/nt/bptree/rotree/v0.ReadOnlyTree

    • GetProposalStatusByProposalId(proposalId int64) (string, interface {Error func() string})

    • GetProposalTypeByProposalId(proposalId int64) (string, interface {Error func() string})

    • GetProposerByProposalId(proposalId int64) (string, interface {Error func() string})

    • GetQuorumAmountByProposalId(proposalId int64) (int64, interface {Error func() string})

    • GetTitleByProposalId(proposalId int64) (string, interface {Error func() string})

    • GetUserProposals() *gno.land/p/nt/bptree/rotree/v0.ReadOnlyTree

    • GetVotedAt(proposalID int64, addr string) (int64, interface {Error func() string})

    • GetVotedHeight(proposalID int64, addr string) (int64, interface {Error func() string})

    • GetVoteStatus(proposalId int64) (quorum int64, maxVotingWeight int64, yesWeight int64, noWeight int64, err interface {Error func() string})

    • GetVoteWeight(proposalID int64, addr string) (int64, interface {Error func() string})

    • GetVotingInfos(proposalID int64) *gno.land/p/nt/bptree/rotree/v0.ReadOnlyTree

    • GetYeaByProposalId(proposalId int64) (int64, interface {Error func() string})

    • NewCommunityPoolSpendInfo(to string, tokenPath string, amount int64) *gno.land/r/gnoswap/gov/governance.CommunityPoolSpendInfo

    • NewConfig(votingStartDelay int64, votingPeriod int64, votingWeightSmoothingDuration int64, quorum int64, proposalCreationThreshold int64, executionDelay int64, executionWindow int64) struct{VotingStartDelay int64; VotingPeriod int64; VotingWeightSmoothingDuration int64; Quorum int64; ProposalCreationThreshold int64; ExecutionDelay int64; ExecutionWindow int64}

    • NewConfigPtr(votingStartDelay int64, votingPeriod int64, votingWeightSmoothingDuration int64, quorum int64, proposalCreationThreshold int64, executionDelay int64, executionWindow int64) *gno.land/r/gnoswap/gov/governance.Config

    • NewConfigTree() *gno.land/p/nt/bptree/v0.BPTree

    • NewCounter() *gno.land/r/gnoswap/gov/governance.Counter

    • NewDefaultConfig() struct{VotingStartDelay int64; VotingPeriod int64; VotingWeightSmoothingDuration int64; Quorum int64; ProposalCreationThreshold int64; ExecutionDelay int64; ExecutionWindow int64}

    • NewExecutionInfo(num int64, msgs []string) *gno.land/r/gnoswap/gov/governance.ExecutionInfo

    • NewGovernanceStore(kvStore interface {AddAuthorizedCaller func(int, .uverse.realm, .uverse.address, gno.land/p/gnoswap/store/v1.Permission) .uverse.error; Delete func(int, .uverse.realm, string) .uverse.error; Get func(string) (interface {}, .uverse.error); GetAddress func(string) (.uverse.address, .uverse.error); GetAllKeys func() ([]string, .uverse.error); GetAuthorizedCallers func() (map[.uverse.address]gno.land/p/gnoswap/store/v1.Permission, .uverse.error); GetBPTree func(string) (*gno.land/p/nt/bptree/v0.BPTree, .uverse.error); GetBool func(string) (bool, .uverse.error); GetDomainAddress func() .uverse.address; GetInt64 func(string) (int64, .uverse.error); GetString func(string) (string, .uverse.error); GetUint64 func(string) (uint64, .uverse.error); Has func(string) bool; IsWriteAuthorized func(.uverse.address) bool; RemoveAuthorizedCaller func(int, .uverse.realm, .uverse.address) .uverse.error; Set func(int, .uverse.realm, string, interface {}) .uverse.error; UpdateAuthorizedCaller func(int, .uverse.realm, .uverse.address, gno.land/p/gnoswap/store/v1.Permission) .uverse.error}) interface {AddUserProposal func(int, .uverse.realm, string, int64) .uverse.error; GetActiveProposalsBySnapshot func() *gno.land/p/nt/bptree/v0.BPTree; GetConfig func(int64) (gno.land/r/gnoswap/gov/governance.Config, bool); GetConfigCounter func() *gno.land/r/gnoswap/gov/governance.Counter; GetProposal func(int64) (*gno.land/r/gnoswap/gov/governance.Proposal, bool); GetProposalCounter func() *gno.land/r/gnoswap/gov/governance.Counter; GetProposalUserVotingInfos func() *gno.land/p/nt/bptree/v0.BPTree; GetProposalVotingInfos func(int64) (*gno.land/p/nt/bptree/v0.BPTree, bool); GetProposals func() *gno.land/p/nt/bptree/v0.BPTree; GetUserProposalIDs func(string) ([]int64, bool); GetUserProposals func() *gno.land/p/nt/bptree/v0.BPTree; HasActiveProposalsBySnapshotStoreKey func() bool; HasConfigCounterStoreKey func() bool; HasConfigsStoreKey func() bool; HasProposalCounterStoreKey func() bool; HasProposalUserVotingInfosStoreKey func() bool; HasProposalsStoreKey func() bool; HasUserProposalsStoreKey func() bool; RemoveUserProposal func(int, .uverse.realm, string, int64) .uverse.error; SetActiveProposalsBySnapshot func(int, .uverse.realm, *gno.land/p/nt/bptree/v0.BPTree) .uverse.error; SetConfig func(int, .uverse.realm, int64, gno.land/r/gnoswap/gov/governance.Config) .uverse.error; SetConfigCounter func(int, .uverse.realm, *gno.land/r/gnoswap/gov/governance.Counter) .uverse.error; SetConfigs func(int, .uverse.realm, *gno.land/p/nt/bptree/v0.BPTree) .uverse.error; SetProposal func(int, .uverse.realm, int64, *gno.land/r/gnoswap/gov/governance.Proposal) .uverse.error; SetProposalCounter func(int, .uverse.realm, *gno.land/r/gnoswap/gov/governance.Counter) .uverse.error; SetProposalUserVotingInfos func(int, .uverse.realm, *gno.land/p/nt/bptree/v0.BPTree) .uverse.error; SetProposalVotingInfos func(int, .uverse.realm, int64, *gno.land/p/nt/bptree/v0.BPTree) .uverse.error; SetProposals func(int, .uverse.realm, *gno.land/p/nt/bptree/v0.BPTree) .uverse.error; SetUserProposals func(int, .uverse.realm, *gno.land/p/nt/bptree/v0.BPTree) .uverse.error}

    • NewParameterChangeInfo(pkgPath string, function string, params []string) struct{pkgPath string; function string; params []string}

    • NewProposal(proposalID int64, status *gno.land/r/gnoswap/gov/governance.ProposalStatus, metadata *gno.land/r/gnoswap/gov/governance.ProposalMetadata, data *gno.land/r/gnoswap/gov/governance.ProposalData, proposerAddress string, configVersion int64, snapshotTime int64, createdHeight int64) *gno.land/r/gnoswap/gov/governance.Proposal

    • NewProposalActionStatus(executable bool) *gno.land/r/gnoswap/gov/governance.ProposalActionStatus

    • NewProposalData(proposalType string, communityPoolSpend *gno.land/r/gnoswap/gov/governance.CommunityPoolSpendInfo, execution *gno.land/r/gnoswap/gov/governance.ExecutionInfo) *gno.land/r/gnoswap/gov/governance.ProposalData

    • NewProposalMetadata(title string, description string) *gno.land/r/gnoswap/gov/governance.ProposalMetadata

    • NewProposalScheduleStatus(createTime int64, activeTime int64, votingEndTime int64, executableTime int64, expiredTime int64) *gno.land/r/gnoswap/gov/governance.ProposalScheduleStatus

    • NewProposalStatusBy(schedule *gno.land/r/gnoswap/gov/governance.ProposalScheduleStatus, actionStatus *gno.land/r/gnoswap/gov/governance.ProposalActionStatus, voteStatus *gno.land/r/gnoswap/gov/governance.ProposalVoteStatus) *gno.land/r/gnoswap/gov/governance.ProposalStatus

    • NewProposalTree() *gno.land/p/nt/bptree/v0.BPTree

    • NewProposalUserVotingInfoTree() *gno.land/p/nt/bptree/v0.BPTree

    • NewProposalVoteStatus(maxVotingWeight int64, quorumAmount int64) *gno.land/r/gnoswap/gov/governance.ProposalVoteStatus

    • NewUserProposalTree() *gno.land/p/nt/bptree/v0.BPTree

    • NewVotedVotingInfo(availableVoteWeight int64, votedYes bool, votedWeight int64, votedHeight int64, votedAt int64) struct{availableVoteWeight int64; votedWeight int64; votedHeight int64; votedAt int64; votedYes bool; voted bool}

    • NewVotingInfo(availableVoteWeight int64) struct{availableVoteWeight int64; votedWeight int64; votedHeight int64; votedAt int64; votedYes bool; voted bool}

    • NewVotingInfoTree() *gno.land/p/nt/bptree/v0.BPTree

    • ProposeCommunityPoolSpend(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, title string, description string, to string, tokenPath string, amount int64) int64

    • ProposeParameterChange(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, title string, description string, numToExecute int64, executions string) int64

    • ProposeText(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, title string, description string) int64

    • Reconfigure(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, votingStartDelay int64, votingPeriod int64, votingWeightSmoothingDuration int64, quorum int64, proposalCreationThreshold int64, executionDelay int64, executionWindow int64) int64

    • RegisterInitializer(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, initializer func(int, .uverse.realm, gno.land/r/gnoswap/gov/governance.IGovernanceStore, gno.land/r/gnoswap/gov/governance.GovStakerAccessor) gno.land/r/gnoswap/gov/governance.IGovernance)

    • RemoveInactiveProposalFromIndex(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, proposalID int64)

    • Render(path string) string

    • UpgradeImpl(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, targetPackagePath string)

    • Vote(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, proposalId int64, yes bool) string

    Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.

    Rendered

    RenderedRawgnoweb ↗

    vm/qrender output, sanitized (docs/render-security.md) and displayed in an empty-sandbox iframe — scripts, forms and popups cannot run. Links stay inert in-preview; right-click to open.

    9// Config represents the configuration of the governor contract.
    10// All parameters can be modified through Reconfigure by admin or governance.
    11type Config struct {
    12 // VotingStartDelay is the delay before voting starts after proposal creation (in seconds)
    13 VotingStartDelay int64
    14 // VotingPeriod is the duration during which votes are collected (in seconds)
    15 VotingPeriod int64
    16 // VotingWeightSmoothingDuration is the period over which voting weight is averaged
    17 // for proposal creation and cancellation threshold calculations (in seconds).
    18 VotingWeightSmoothingDuration int64
    19 // Quorum is the percentage of total xGNS supply required for proposal approval.
    20 // Total supply includes xGNS held by the launchpad.
    21 Quorum int64
    22 // ProposalCreationThreshold is the minimum xGNS amount required to create a proposal
    23 ProposalCreationThreshold int64
    24 // ExecutionDelay is the waiting period after voting ends before a proposal can be executed (in seconds)
    25 ExecutionDelay int64
    26 // ExecutionWindow is the time window during which an approved proposal can be executed (in seconds)
    27 ExecutionWindow int64
    28}
    29
    30// IsValid reports whether the configuration's durations, threshold, quorum, and
    31// cumulative schedule values satisfy the governance validation constraints.
    32//
    33// Parameters:
    34// - currentTime: current time value included when checking that the cumulative schedule does not become negative
    35//
    36// Returns:
    37// - error: nil when all fields and cumulative values are valid; otherwise an error describing the first invalid value
    38func (c Config) IsValid(currentTime int64) error {
    39 if c.VotingStartDelay < 0 {
    40 return errors.New("votingStartDelay cannot be negative")
    41 }
    42
    43 if c.VotingPeriod < 0 {
    44 return errors.New("votingPeriod cannot be negative")
    45 }
    46
    47 if c.ExecutionDelay < 0 {
    48 return errors.New("executionDelay cannot be negative")
    49 }
    50
    51 if c.ExecutionWindow < 0 {
    52 return errors.New("executionWindow cannot be negative")
    53 }
    54
    55 if c.VotingWeightSmoothingDuration < 0 {
    56 return errors.New("votingWeightSmoothingDuration cannot be negative")
    57 }
    58
    59 if c.ProposalCreationThreshold < 0 {
    60 return errors.New("proposalCreationThreshold cannot be negative")
    61 }
    62
    63 if c.Quorum < 0 || c.Quorum > 100 {
    64 return errors.New("quorum must be between 0 and 100")
    65 }
    66
    67 sum := int64(0)
    68
    69 sum += c.VotingStartDelay
    70 if sum < 0 {
    71 return errors.New("votingStartDelay cannot be negative")
    72 }
    73
    74 sum += c.VotingPeriod
    75 if sum < 0 {
    76 return errors.New("votingPeriod cannot be negative")
    77 }
    78
    79 sum += c.ExecutionDelay
    80 if sum < 0 {
    81 return errors.New("executionDelay cannot be negative")
    82 }
    83
    84 sum += c.ExecutionWindow
    85 if sum < 0 {
    86 return errors.New("executionWindow cannot be negative")
    87 }
    88
    89 sum += currentTime
    90 if sum < 0 {
    91 return errors.New("total delay cannot be negative")
    92 }
    93
    94 return nil
    95}
    96
    97// NewConfig constructs a governance configuration from the supplied delays,
    98// thresholds, quorum percentage, and execution window.
    99//
    100// Parameters:
    101// - votingStartDelay: delay from proposal creation until voting opens, in seconds
    102// - votingPeriod: duration for which voting remains open, in seconds
    103// - votingWeightSmoothingDuration: interval used to smooth delegation weight, in seconds
    104// - quorum: required approval percentage of total xGNS supply, from 0 through 100
    105// - proposalCreationThreshold: minimum xGNS amount required to create a proposal
    106// - executionDelay: delay after voting ends before execution, in seconds
    107// - executionWindow: duration after the execution delay during which execution is allowed, in seconds
    108//
    109// Returns:
    110// - Config: configuration value populated with the supplied governance parameters
    111func NewConfig(
    112 votingStartDelay,
    113 votingPeriod,
    114 votingWeightSmoothingDuration,
    115 quorum,
    116 proposalCreationThreshold,
    117 executionDelay,
    118 executionWindow int64,
    119) Config {
    120 return Config{
    121 VotingStartDelay: votingStartDelay,
    122 VotingPeriod: votingPeriod,
    123 VotingWeightSmoothingDuration: votingWeightSmoothingDuration,
    124 Quorum: quorum,
    125 ProposalCreationThreshold: proposalCreationThreshold,
    126 ExecutionDelay: executionDelay,
    127 ExecutionWindow: executionWindow,
    128 }
    129}
    130
    131// NewConfigPtr constructs a Config and returns a pointer to it. The Config is
    132// allocated within the governance domain realm, satisfying realm allocation
    133// checks for callers (such as tests) that require a *Config value.
    134//
    135// Parameters:
    136// - votingStartDelay: delay from proposal creation until voting opens, in seconds
    137// - votingPeriod: duration for which voting remains open, in seconds
    138// - votingWeightSmoothingDuration: interval used to smooth delegation weight, in seconds
    139// - quorum: required approval percentage of total xGNS supply, from 0 through 100
    140// - proposalCreationThreshold: minimum xGNS amount required to create a proposal
    141// - executionDelay: delay after voting ends before execution, in seconds
    142// - executionWindow: duration after the execution delay during which execution is allowed, in seconds
    143//
    144// Returns:
    145// - *Config: pointer to a configuration value populated with the supplied governance parameters
    146func NewConfigPtr(
    147 votingStartDelay,
    148 votingPeriod,
    149 votingWeightSmoothingDuration,
    150 quorum,
    151 proposalCreationThreshold,
    152 executionDelay,
    153 executionWindow int64,
    154) *Config {
    155 c := NewConfig(
    156 votingStartDelay,
    157 votingPeriod,
    158 votingWeightSmoothingDuration,
    159 quorum,
    160 proposalCreationThreshold,
    161 executionDelay,
    162 executionWindow,
    163 )
    164 return &c
    165}
    166
    167// NewDefaultConfig returns the governance configuration's built-in defaults:
    168// one day before voting, seven days of voting, one day of weight smoothing,
    169// 50% quorum, a 1-billion-xGNS creation threshold, one day execution delay,
    170// and a 30-day execution window.
    171//
    172// Returns:
    173// - Config: default governance configuration value
    174func NewDefaultConfig() Config {
    175 return Config{
    176 VotingStartDelay: 86400, // 1 day - delay before voting starts
    177 VotingPeriod: 604800, // 7 days - duration for collecting votes
    178 VotingWeightSmoothingDuration: 86400, // 1 day - period for averaging voting weight
    179 Quorum: 50, // 50% of total xGNS supply required
    180 ProposalCreationThreshold: 1_000_000_000, // 1 billion xGNS - minimum amount to create proposals
    181 ExecutionDelay: 86400, // 1 day - waiting period before execution
    182 ExecutionWindow: 2592000, // 30 days - window for executing proposals
    183 }
    184}
    185
    186// NewConfigTree creates an empty BPTree used to index configuration values by
    187// their encoded int64 version.
    188//
    189// Returns:
    190// - *bptree.BPTree: empty configuration index tree
    191func NewConfigTree() *bptree.BPTree {
    192 return bptree.NewBPTreeN(16)
    193}
    194