Package governance implements proposal lifecycle management and voting. It supports text proposals, parameter changes, and community pool spending. Proposals go through creation, voting, and execution phases with configurable parameters for voting delays, periods, and thresholds.
Functions
Cancel
func Cancel(
cur realm,
proposalId int64,
) int64
Cancel cancels a proposal before voting begins. Only callable by the proposer.
Parameters:
- proposalId: ID of the proposal to cancel
Returns:
- int64: cancellation result code
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 5000000 -send "" -broadcast -chainid "test11" -remote "https://rpc.test11.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test11.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/gov/governance" -func "Cancel" -args $'' -gas-fee 1000000ugnot -gas-wanted 5000000 -send "" ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "test11" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test11.testnets.gno.land" call.tx
Execute
func Execute(
cur realm,
proposalId int64,
) int64
Execute executes a passed proposal that is in the execution window.
Parameters:
- proposalId: ID of the proposal to execute
Returns:
- int64: execution result code
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 5000000 -send "" -broadcast -chainid "test11" -remote "https://rpc.test11.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test11.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/gov/governance" -func "Execute" -args $'' -gas-fee 1000000ugnot -gas-wanted 5000000 -send "" ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "test11" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test11.testnets.gno.land" call.tx
GetVoteStatus returns the vote status of a proposal.
Returns:
- quorum: minimum vote weight required for proposal to pass
- maxVotingWeight: maximum possible voting weight
- yesWeight: total weight of "yes" votes
- noWeight: total weight of "no" votes
func ProposeCommunityPoolSpend(
cur realm,
title string,
description string,
to address,
tokenPath string,
amount int64,
) int64
ProposeCommunityPoolSpend creates a new community pool spending proposal.
Parameters:
- title: proposal title
- description: detailed proposal description
- to: recipient address
- tokenPath: token path to transfer
- amount: amount to transfer
Returns:
- int64: ID of the created proposal
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 5000000 -send "" -broadcast -chainid "test11" -remote "https://rpc.test11.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test11.testnets.gno.land" 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 5000000 -send "" ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "test11" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test11.testnets.gno.land" call.tx
ProposeParameterChange
func ProposeParameterChange(
cur realm,
title string,
description string,
numToExecute int64,
executions string,
) int64
ProposeParameterChange creates a new parameter change proposal.
Parameters:
- title: proposal title
- description: detailed proposal description
- numToExecute: number of executions to perform
- executions: encoded execution messages
Returns:
- int64: ID of the created proposal
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 5000000 -send "" -broadcast -chainid "test11" -remote "https://rpc.test11.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test11.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/gov/governance" -func "ProposeParameterChange" -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 5000000 -send "" ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "test11" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test11.testnets.gno.land" call.tx
ProposeText
func ProposeText(
cur realm,
title string,
description string,
) int64
ProposeText creates a new text proposal for general governance decisions.
Parameters:
- title: proposal title
- description: detailed proposal description
Returns:
- int64: ID of the created proposal
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 5000000 -send "" -broadcast -chainid "test11" -remote "https://rpc.test11.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test11.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/gov/governance" -func "ProposeText" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 5000000 -send "" ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "test11" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test11.testnets.gno.land" 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:
- 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
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 5000000 -send "" -broadcast -chainid "test11" -remote "https://rpc.test11.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test11.testnets.gno.land" 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 5000000 -send "" ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "test11" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test11.testnets.gno.land" call.tx
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.
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 5000000 -send "" -broadcast -chainid "test11" -remote "https://rpc.test11.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test11.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/gov/governance" -func "UpgradeImpl" -args $'' -gas-fee 1000000ugnot -gas-wanted 5000000 -send "" ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "test11" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test11.testnets.gno.land" call.tx
Vote
func Vote(
cur realm,
proposalId int64,
yes bool,
) string
Vote casts a vote on a proposal.
Parameters:
- proposalId: ID of the proposal to vote on
- yes: true for yes vote, false for no vote
Returns:
- string: voting result information
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 5000000 -send "" -broadcast -chainid "test11" -remote "https://rpc.test11.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.test11.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/gnoswap/gov/governance" -func "Vote" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 5000000 -send "" ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "test11" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.test11.testnets.gno.land" call.tx
NewGovernanceStore creates a new governance store instance with the provided KV store. This function is used by the upgrade system to create storage instances for each implementation.
NewProposal creates a new proposal instance with the provided parameters. NewProposal is the main constructor for creating governance proposals.
- metadata: proposal title and description
- data: type-specific proposal data
- proposerAddress: address of the proposal creator
- configVersion: governance configuration version
- snapshotTime: timestamp for voting weight snapshot lookup
- createdAt: creation timestamp
- createdHeight: creation block height
Returns:
- \*Proposal: newly created proposal instance
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
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
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
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
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 structure