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

governance package

Overview

Package governance implements proposal lifecycle management and voting. It supports text proposals, parameter changes, and community-pool spending. Voting uses timestamped delegation history and quorum from total xGNS supply (including launchpad-held xGNS); proposal timing and thresholds are configurable.

Functions

Cancel

func Cancel( cur realm, proposalId int64, ) int64

Cancel cancels the proposal with the given ID.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • proposalId: The ID of the proposal to cancel.

Returns:

  • proposalId: The ID of the proposal.

Halt check: reverts while the Governance halt scope is active.

Param

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/gov/governance" -func "Cancel" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/gov/governance" -func "Cancel" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

Execute

func Execute( cur realm, proposalId int64, ) int64

Execute executes the given proposal.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • proposalId: The ID of the proposal to execute.

Returns:

  • proposalId: The ID of the proposal.

Halt check: reverts while the Governance halt scope is active, except for halt-recovery proposals that only target the halt realm.

Param

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/gov/governance" -func "Execute" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/gov/governance" -func "Execute" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

ExistsProposal

func ExistsProposal(proposalID int64) bool

ExistsProposal checks whether a proposal is stored.

Parameters:

  • proposalID: proposal identifier to look up

Returns:

  • bool: true when proposalID is stored, otherwise false

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.ExistsProposal()"

Result

ExistsVotingInfo

func ExistsVotingInfo(proposalID int64, addr address) bool

ExistsVotingInfo checks whether voting information exists for a user on a proposal.

Parameters:

  • proposalID: proposal identifier to inspect
  • addr: voter address to look up within proposalID

Returns:

  • bool: true when voting information exists for the proposal and address

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.ExistsVotingInfo(,)"

Result

GetConfigVersionByProposalId

func GetConfigVersionByProposalId(proposalId int64) (int64, error)

GetConfigVersionByProposalId returns the config version used by a proposal.

Parameters:

  • proposalId: proposal identifier to inspect

Returns:

  • int64: governance configuration version captured by the proposal
  • error: nil on success, or an error when the proposal does not exist

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.GetConfigVersionByProposalId()"

Result

GetCurrentProposalID

func GetCurrentProposalID() int64

GetCurrentProposalID returns the current proposal ID counter.

Returns:

  • int64: current proposal ID counter used for newly created proposals

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.GetCurrentProposalID()"

Result

GetCurrentVotingWeightSnapshot

func GetCurrentVotingWeightSnapshot() (int64, int64, error)

GetCurrentVotingWeightSnapshot returns the current total voting weight and its timestamp anchor computed with the configured smoothing duration.

Returns:

  • int64: total voting weight averaged over the configured smoothing window
  • int64: Unix timestamp used as the snapshot history anchor
  • error: nil on success, or an error when the current configuration or snapshot data cannot be retrieved

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.GetCurrentVotingWeightSnapshot()"

Result

GetDescriptionByProposalId

func GetDescriptionByProposalId(proposalId int64) (string, error)

GetDescriptionByProposalId returns the description of a proposal.

Parameters:

  • proposalId: proposal identifier to inspect

Returns:

  • string: proposal description
  • error: nil on success, or an error when the proposal does not exist

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.GetDescriptionByProposalId()"

Result

GetImplementationPackagePath

func GetImplementationPackagePath() string

GetImplementationPackagePath returns the package path of the currently active implementation.

Returns:

  • packagePath: package path of the active implementation

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.GetImplementationPackagePath()"

Result

GetLatestConfigVersion

func GetLatestConfigVersion() int64

GetLatestConfigVersion returns the current governance configuration version.

Returns:

  • int64: latest configuration version stored by governance

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.GetLatestConfigVersion()"

Result

GetMaxSmoothingPeriod

func GetMaxSmoothingPeriod() int64

GetMaxSmoothingPeriod returns the maximum smoothing period for delegation history cleanup.

Returns:

  • int64: maximum permitted smoothing period in seconds

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.GetMaxSmoothingPeriod()"

Result

GetNayByProposalId

func GetNayByProposalId(proposalId int64) (int64, error)

GetNayByProposalId returns the no vote weight of a proposal.

Parameters:

  • proposalId: proposal identifier to inspect

Returns:

  • int64: total voting weight recorded for no votes
  • error: nil on success, or an error when the proposal does not exist

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.GetNayByProposalId()"

Result

GetOldestActiveProposalSnapshotTime

func GetOldestActiveProposalSnapshotTime() (int64, bool, error)

GetOldestActiveProposalSnapshotTime returns the oldest active proposal's timestamp anchor. An empty index returns no active proposal; a stale or missing first entry returns an error so cleanup cannot silently skip it.

Returns:

  • int64: snapshot timestamp of the oldest active proposal, or zero when the index is empty or an error occurs
  • bool: true when an active proposal was found at the oldest index entry, otherwise false
  • error: nil for an empty index or active entry, or an error when the entry is missing or inactive

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.GetOldestActiveProposalSnapshotTime()"

Result

GetProposalCreatedAt

func GetProposalCreatedAt(proposalId int64) (int64, error)

GetProposalCreatedAt returns the creation timestamp of a proposal.

Parameters:

  • proposalId: proposal identifier to look up

Returns:

  • int64: Unix timestamp at which the proposal was created
  • error: nil on success, or an error when the proposal does not exist

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.GetProposalCreatedAt()"

Result

GetProposalCreatedHeight

func GetProposalCreatedHeight(proposalId int64) (int64, error)

GetProposalCreatedHeight returns the creation block height of a proposal.

Parameters:

  • proposalId: proposal identifier to look up

Returns:

  • int64: block height at which the proposal was created
  • error: nil on success, or an error when the proposal does not exist

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.GetProposalCreatedHeight()"

Result

GetProposalStatusByProposalId

func GetProposalStatusByProposalId(proposalId int64) (string, error)

GetProposalStatusByProposalId returns the current status of a proposal.

Parameters:

  • proposalId: proposal identifier to inspect

Returns:

  • string: status computed from the proposal and the current Unix time
  • error: nil on success, or an error when the proposal does not exist

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.GetProposalStatusByProposalId()"

Result

GetProposals

func GetProposals() *rotree.ReadOnlyTree

GetProposals returns a read-only view of every proposal, keyed by the decimal string form of the proposal ID. Callers paginate it themselves through IterateByOffset. Reading an entry yields a clone, so the view cannot mutate realm state.

Returns:

  • *rotree.ReadOnlyTree: read-only proposal tree keyed by decimal proposal ID

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.GetProposals()"

Result

GetQuorumAmountByProposalId

func GetQuorumAmountByProposalId(proposalId int64) (int64, error)

GetQuorumAmountByProposalId returns the quorum requirement for a proposal.

Parameters:

  • proposalId: proposal identifier to inspect

Returns:

  • int64: minimum voting weight required for the proposal's quorum
  • error: nil on success, or an error when the proposal does not exist

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.GetQuorumAmountByProposalId()"

Result

GetTitleByProposalId

func GetTitleByProposalId(proposalId int64) (string, error)

GetTitleByProposalId returns the title of a proposal.

Parameters:

  • proposalId: proposal identifier to inspect

Returns:

  • string: proposal title
  • error: nil on success, or an error when the proposal does not exist

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.GetTitleByProposalId()"

Result

GetUserProposals

func GetUserProposals() *rotree.ReadOnlyTree

GetUserProposals returns a read-only view of the proposals created per user, keyed by creator address with the creator's proposal IDs as the value. Reading an entry yields a copy of the ID slice, so the view cannot mutate realm state.

Returns:

  • *rotree.ReadOnlyTree: read-only user-proposal tree keyed by creator address

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.GetUserProposals()"

Result

GetVoteStatus

func GetVoteStatus(proposalId int64) (quorum, maxVotingWeight, yesWeight, noWeight int64, err error)

GetVoteStatus returns the vote status of a proposal.

Parameters:

  • proposalId: proposal identifier to inspect

Returns:

  • quorum: minimum vote weight required for the proposal to pass
  • maxVotingWeight: maximum possible voting weight recorded for the proposal
  • yesWeight: total weight of yes votes
  • noWeight: total weight of no votes
  • err: nil on success, or an error when the proposal does not exist

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.GetVoteStatus()"

Result

GetVoteWeight

func GetVoteWeight(proposalID int64, addr address) (int64, error)

GetVoteWeight returns the voting weight of an address for a proposal.

Parameters:

  • proposalID: proposal identifier to inspect
  • addr: voter address whose recorded vote weight is requested

Returns:

  • int64: weight recorded for addr's vote
  • error: nil on success, or an error when no voting information exists for the proposal and address

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.GetVoteWeight(,)"

Result

GetVotedAt

func GetVotedAt(proposalID int64, addr address) (int64, error)

GetVotedAt returns the timestamp when an address voted on a proposal.

Parameters:

  • proposalID: proposal identifier to inspect
  • addr: voter address whose vote timestamp is requested

Returns:

  • int64: Unix timestamp recorded for addr's vote
  • error: nil on success, or an error when no voting information exists for the proposal and address

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.GetVotedAt(,)"

Result

GetVotedHeight

func GetVotedHeight(proposalID int64, addr address) (int64, error)

GetVotedHeight returns the block height when an address voted on a proposal.

Parameters:

  • proposalID: proposal identifier to inspect
  • addr: voter address whose vote height is requested

Returns:

  • int64: block height recorded for addr's vote
  • error: nil on success, or an error when no voting information exists for the proposal and address

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.GetVotedHeight(,)"

Result

GetVotingInfos

func GetVotingInfos(proposalID int64) *rotree.ReadOnlyTree

GetVotingInfos returns a read-only view of a proposal's value-backed voting infos, keyed by voter address. Existing proposals have an empty view before the first vote; nil is returned only when the stored voting-info tree is absent.

Parameters:

  • proposalID: proposal identifier whose voting information is requested

Returns:

  • *rotree.ReadOnlyTree: read-only voting-info tree keyed by voter address, or nil when no tree is stored

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.GetVotingInfos()"

Result

GetYeaByProposalId

func GetYeaByProposalId(proposalId int64) (int64, error)

GetYeaByProposalId returns the yes vote weight of a proposal.

Parameters:

  • proposalId: proposal identifier to inspect

Returns:

  • int64: total voting weight recorded for yes votes
  • error: nil on success, or an error when the proposal does not exist

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.GetYeaByProposalId()"

Result

NewConfigTree

func NewConfigTree() *bptree.BPTree

NewConfigTree creates an empty BPTree used to index configuration values by their encoded int64 version.

Returns:

  • *bptree.BPTree: empty configuration index tree

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.NewConfigTree()"

Result

NewProposalTree

func NewProposalTree() *bptree.BPTree

NewProposalTree creates an empty B+ tree for proposals keyed by proposal ID.

Returns:

  • *bptree.BPTree: empty 16-way proposal tree

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.NewProposalTree()"

Result

NewProposalUserVotingInfoTree

func NewProposalUserVotingInfoTree() *bptree.BPTree

NewProposalUserVotingInfoTree creates an empty B+ tree mapping proposal IDs to their per-user voting-information trees.

Returns:

  • *bptree.BPTree: empty 16-way proposal voting-information index tree

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.NewProposalUserVotingInfoTree()"

Result

NewUserProposalTree

func NewUserProposalTree() *bptree.BPTree

NewUserProposalTree creates an empty B+ tree mapping users to proposal IDs.

Returns:

  • *bptree.BPTree: empty 16-way user-proposal index tree

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.NewUserProposalTree()"

Result

NewVotingInfoTree

func NewVotingInfoTree() *bptree.BPTree

NewVotingInfoTree creates an empty B+ tree for per-user voting information.

Returns:

  • *bptree.BPTree: empty 16-way voting-information tree

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.NewVotingInfoTree()"

Result

ProposeCommunityPoolSpend

func ProposeCommunityPoolSpend( cur realm, title string, description string, to address, tokenPath string, amount int64, ) int64

ProposeCommunityPoolSpend creates a CommunityPoolSpend proposal with the provided data. The transfer is attempted when an approved proposal executes.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • title: The title of the proposal.
  • description: The description of the proposal.
  • to: A valid address to receive the spent token.
  • tokenPath: A registered token path.
  • amount: A strictly positive amount in the token's smallest unit.

The community-pool balance is checked at execution, not proposal creation.

Returns:

  • proposalId: The ID of the proposal.

Halt check: reverts while the Governance halt scope is active.

Params

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/gov/governance" -func "ProposeCommunityPoolSpend" -args $'' -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/gov/governance" -func "ProposeCommunityPoolSpend" -args $'' -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

ProposeParameterChange

func ProposeParameterChange( cur realm, title string, description string, numToExecute int64, executions string, ) int64

ProposeParameterChange creates a ParameterChange proposal with the provided data.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • title: The title of the proposal.
  • description: The description of the proposal.
  • numToExecute: The number of changes to execute.
  • executions: The list of changes to execute.

Returns:

  • proposalId: The ID of the proposal.

Halt check: reverts while the Governance halt scope is active, except for halt-recovery proposals that only target the halt realm.

Params

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/gov/governance" -func "ProposeParameterChange" -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/gov/governance" -func "ProposeParameterChange" -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

ProposeText

func ProposeText( cur realm, title string, description string, ) int64

ProposeText creates a new text proposal with the provided data.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • title: The title of the proposal.
  • description: The description of the proposal.

Returns:

  • proposalId: The ID of the proposal.

Halt check: reverts while the Governance halt scope is active.

Params

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/gov/governance" -func "ProposeText" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/gov/governance" -func "ProposeText" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

Reconfigure

func Reconfigure( cur realm, votingStartDelay int64, votingPeriod int64, votingWeightSmoothingDuration int64, quorum int64, proposalCreationThreshold int64, executionDelay int64, executionWindow int64, ) int64

Reconfigure updates the governance configuration parameters. Only callable by admin or governance.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • 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

Halt check: reverts while the Governance halt scope is active.

Params

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/gov/governance" -func "Reconfigure" -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/gov/governance" -func "Reconfigure" -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

RegisterInitializer

func 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. Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • initializer: Callback that receives the proxy-authorized realm context, governance store, and staker accessor and returns the versioned implementation.

Param

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/gov/governance" -func "RegisterInitializer" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/gov/governance" -func "RegisterInitializer" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

RemoveInactiveProposalFromIndex

func RemoveInactiveProposalFromIndex(cur realm, proposalID int64)

RemoveInactiveProposalFromIndex removes an inactive proposal from the timestamp-ordered index without deleting its proposal or voting history. Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • proposalID: Identifier of the inactive proposal to remove from the active index.

Halt check: reverts while the Governance halt scope is active.

Param

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/gov/governance" -func "RemoveInactiveProposalFromIndex" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/gov/governance" -func "RemoveInactiveProposalFromIndex" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

Render

func Render(path string) string

Render delegates web rendering to the active implementation.

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.Render()"

Result

UpgradeImpl

func UpgradeImpl(cur realm, targetPackagePath string)

UpgradeImpl 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. Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • targetPackagePath: Registered implementation package path to activate.

Param

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/gov/governance" -func "UpgradeImpl" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/gov/governance" -func "UpgradeImpl" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

Vote

func Vote( cur realm, proposalId int64, yes bool, ) string

Vote allows a user to vote on a given proposal.

The proposal's timestamp-based smoothing calculation determines the applied weight. A vote cannot be changed after it is recorded.

Parameters:

  • cur: Current realm context; callers use cross(cur) when crossing into this realm.
  • proposalId: The ID of the proposal to vote.
  • yes: The flag to vote as yes or not.

Returns:

  • voteWeight: The caller's calculated vote weight, formatted as a decimal string.

Halt check: reverts while the Governance halt scope is active, except for halt-recovery proposals that only target the halt realm.

Params

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/gnoswap/gov/governance" -func "Vote" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/gov/governance" -func "Vote" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

GetProposalCommunityPoolSpendInfo

func GetProposalCommunityPoolSpendInfo(proposalID int64) (*CommunityPoolSpendInfo, error)

GetProposalCommunityPoolSpendInfo returns a cloned copy of the community pool spend info for a proposal.

Parameters:

  • proposalID: proposal identifier to inspect

Returns:

  • *CommunityPoolSpendInfo: cloned community-pool spend details, or nil when an error occurs
  • error: nil on success, or an error when the proposal is missing or has no spend data

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.GetProposalCommunityPoolSpendInfo()"

Result

NewCommunityPoolSpendInfo

func NewCommunityPoolSpendInfo(to address, tokenPath string, amount int64) *CommunityPoolSpendInfo

NewCommunityPoolSpendInfo creates community-pool spend data.

Parameters:

  • to: Recipient address that receives the community-pool transfer.
  • tokenPath: Registered token path of the asset to transfer.
  • amount: Transfer amount in the token's smallest unit.

Returns:

  • *CommunityPoolSpendInfo: spend data containing the recipient, token path, and amount.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.NewCommunityPoolSpendInfo(,,)"

Result

GetConfig

func GetConfig(configVersion int64) (Config, error)

GetConfig returns a specific governance configuration by version.

Parameters:

  • configVersion: configuration version to retrieve

Returns:

  • Config: configuration stored under configVersion
  • error: nil on success, or an error when configVersion is not found

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.GetConfig()"

Result

GetLatestConfig

func GetLatestConfig() (Config, error)

GetLatestConfig returns the latest governance configuration.

Returns:

  • Config: latest stored configuration for the current version
  • error: nil on success, or an error when the current configuration is missing

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.GetLatestConfig()"

Result

NewConfig

func NewConfig( votingStartDelay, votingPeriod, votingWeightSmoothingDuration, quorum, proposalCreationThreshold, executionDelay, executionWindow int64, ) Config

NewConfig constructs a governance configuration from the supplied delays, thresholds, quorum percentage, and execution window.

Parameters:

  • votingStartDelay: delay from proposal creation until voting opens, in seconds
  • votingPeriod: duration for which voting remains open, in seconds
  • votingWeightSmoothingDuration: interval used to smooth delegation weight, in seconds
  • quorum: required approval percentage of total xGNS supply, from 0 through 100
  • proposalCreationThreshold: minimum xGNS amount required to create a proposal
  • executionDelay: delay after voting ends before execution, in seconds
  • executionWindow: duration after the execution delay during which execution is allowed, in seconds

Returns:

  • Config: configuration value populated with the supplied governance parameters

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.NewConfig(,,,,,,)"

Result

NewConfigPtr

func NewConfigPtr( votingStartDelay, votingPeriod, votingWeightSmoothingDuration, quorum, proposalCreationThreshold, executionDelay, executionWindow int64, ) *Config

NewConfigPtr 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.

Parameters:

  • votingStartDelay: delay from proposal creation until voting opens, in seconds
  • votingPeriod: duration for which voting remains open, in seconds
  • votingWeightSmoothingDuration: interval used to smooth delegation weight, in seconds
  • quorum: required approval percentage of total xGNS supply, from 0 through 100
  • proposalCreationThreshold: minimum xGNS amount required to create a proposal
  • executionDelay: delay after voting ends before execution, in seconds
  • executionWindow: duration after the execution delay during which execution is allowed, in seconds

Returns:

  • *Config: pointer to a configuration value populated with the supplied governance parameters

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.NewConfigPtr(,,,,,,)"

Result

NewDefaultConfig

func NewDefaultConfig() Config

NewDefaultConfig returns the governance configuration's built-in defaults: one day before voting, seven days of voting, one day of weight smoothing, 50% quorum, a 1-billion-xGNS creation threshold, one day execution delay, and a 30-day execution window.

Returns:

  • Config: default governance configuration value

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.NewDefaultConfig()"

Result

NewCounter

func NewCounter() *Counter

NewCounter creates a new Counter whose current ID is initialized to zero.

Returns:

  • *Counter: counter initialized with current ID 0

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.NewCounter()"

Result

GetProposalExecutionInfo

func GetProposalExecutionInfo(proposalID int64) (*ExecutionInfo, error)

GetProposalExecutionInfo returns a cloned copy of the execution info for a proposal.

Parameters:

  • proposalID: proposal identifier to inspect

Returns:

  • *ExecutionInfo: cloned parameter-change execution messages and count, or nil when an error occurs
  • error: nil on success, or an error when the proposal is missing or has no execution data

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.GetProposalExecutionInfo()"

Result

NewExecutionInfo

func NewExecutionInfo(num int64, msgs []string) *ExecutionInfo

NewExecutionInfo creates execution data for a parameter-change proposal.

Parameters:

  • num: Number of encoded parameter-change messages to execute.
  • msgs: Encoded parameter-change messages, one message per execution.

Returns:

  • *ExecutionInfo: execution data containing the declared count and messages.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.NewExecutionInfo(,)"

Result

NewGovernanceStore

func NewGovernanceStore(kvStore store.KVStore) IGovernanceStore

NewGovernanceStore creates a governance store backed by the provided KV store. The returned interface is used by governance implementations and upgrades.

Parameters:

  • kvStore: KV store used for governance counters, trees, and records

Returns:

  • IGovernanceStore: governance store implementation backed by kvStore

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.NewGovernanceStore()"

Result

NewParameterChangeInfo

func NewParameterChangeInfo(pkgPath string, function string, params []string) ParameterChangeInfo

NewParameterChangeInfo creates one encoded parameter-change target description.

Parameters:

  • pkgPath: Package path containing the parameter-change handler.
  • function: Handler function name to invoke.
  • params: String arguments passed to the handler in order.

Returns:

  • ParameterChangeInfo: parameter-change target and its encoded arguments.

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.NewParameterChangeInfo(,,)"

Result

NewProposal

func NewProposal( proposalID int64, status *ProposalStatus, metadata *ProposalMetadata, data *ProposalData, proposerAddress address, configVersion int64, snapshotTime int64, createdHeight int64, ) *Proposal

NewProposal creates a new proposal instance with the supplied identity, lifecycle, metadata, and type-specific data.

Parameters:

  • proposalID: unique identifier assigned to the proposal
  • status: initial schedule, action, and voting status
  • metadata: proposal title and description metadata
  • data: type-specific proposal data
  • proposerAddress: address of the proposal creator
  • configVersion: governance configuration version captured for the proposal
  • snapshotTime: timestamp anchor for historical voting-weight lookup
  • createdHeight: block height at which the proposal was created

Returns:

  • *Proposal: newly initialized proposal containing the supplied fields

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.NewProposal(,,,,,,,)"

Result

NewProposalActionStatus

func NewProposalActionStatus(executable bool) *ProposalActionStatus

NewProposalActionStatus 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

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.NewProposalActionStatus()"

Result

NewProposalData

func NewProposalData(proposalType ProposalType, communityPoolSpend *CommunityPoolSpendInfo, execution *ExecutionInfo) *ProposalData

NewProposalData 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

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.NewProposalData(,,)"

Result

NewProposalMetadata

func NewProposalMetadata(title string, description string) *ProposalMetadata

NewProposalMetadata creates a new proposal metadata instance with trimmed input.

Parameters:

  • title: proposal title
  • description: proposal description

Returns:

  • *ProposalMetadata: new metadata instance with trimmed whitespace

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.NewProposalMetadata(,)"

Result

NewProposalScheduleStatus

func NewProposalScheduleStatus( createTime int64, activeTime int64, votingEndTime int64, executableTime int64, expiredTime int64, ) *ProposalScheduleStatus

NewProposalScheduleStatus creates a proposal schedule from its lifecycle timestamps.

Parameters:

  • createTime: Unix timestamp when the proposal was created
  • activeTime: Unix timestamp when voting starts
  • votingEndTime: Unix timestamp when voting ends
  • executableTime: Unix timestamp when the execution window starts
  • expiredTime: Unix timestamp when the execution window closes

Returns:

  • *ProposalScheduleStatus: schedule containing the supplied lifecycle timestamps

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.NewProposalScheduleStatus(,,,,)"

Result

NewProposalStatusBy

func NewProposalStatusBy( schedule *ProposalScheduleStatus, actionStatus *ProposalActionStatus, voteStatus *ProposalVoteStatus, ) *ProposalStatus

NewProposalStatusBy combines schedule, action, and vote state into a proposal status.

Parameters:

  • schedule: time-based lifecycle schedule for the proposal
  • actionStatus: execution and cancellation state for the proposal
  • voteStatus: vote tallies and voting requirements for the proposal

Returns:

  • *ProposalStatus: status object containing the supplied lifecycle components

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.NewProposalStatusBy(,,)"

Result

GetProposalTypeByProposalId

func GetProposalTypeByProposalId(proposalId int64) (ProposalType, error)

GetProposalTypeByProposalId returns the type of a proposal.

Parameters:

  • proposalId: proposal identifier to look up

Returns:

  • ProposalType: type recorded for the proposal
  • error: nil on success, or an error when the proposal does not exist

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.GetProposalTypeByProposalId()"

Result

NewProposalVoteStatus

func NewProposalVoteStatus( maxVotingWeight int64, quorumAmount int64, ) *ProposalVoteStatus

NewProposalVoteStatus 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

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.NewProposalVoteStatus(,)"

Result

DefaultVotingInfo

func DefaultVotingInfo() VotingInfo

DefaultVotingInfo creates an empty voting information value.

Returns:

  • VotingInfo: zero-valued voting record with no available weight and no vote recorded

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.DefaultVotingInfo()"

Result

NewVotedVotingInfo

func NewVotedVotingInfo(availableVoteWeight int64, votedYes bool, votedWeight, votedHeight, votedAt int64) VotingInfo

NewVotedVotingInfo creates a voting information value with a recorded vote.

Parameters:

  • availableVoteWeight: total voting weight available to the user for this proposal
  • votedYes: true when the recorded vote is yes, false when it is no
  • votedWeight: voting weight applied to the recorded vote
  • votedHeight: block height at which the vote was recorded
  • votedAt: Unix timestamp at which the vote was recorded

Returns:

  • VotingInfo: voting record populated with the supplied weight, choice, height, and timestamp and marked as voted

Params

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.NewVotedVotingInfo(,,,,)"

Result

NewVotingInfo

func NewVotingInfo(availableVoteWeight int64) VotingInfo

NewVotingInfo 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 value

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/gnoswap/gov/governance.NewVotingInfo()"

Result