Version: v0.47.2 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2023 License: Apache-2.0 Imports: 9 Imported by: 2,671




View Source
const (
	EventTypeSubmitProposal   = "submit_proposal"
	EventTypeProposalDeposit  = "proposal_deposit"
	EventTypeProposalVote     = "proposal_vote"
	EventTypeInactiveProposal = "inactive_proposal"
	EventTypeActiveProposal   = "active_proposal"
	EventTypeSignalProposal   = "signal_proposal"

	AttributeKeyProposalResult     = "proposal_result"
	AttributeKeyOption             = "option"
	AttributeKeyProposalID         = "proposal_id"
	AttributeKeyProposalMessages   = "proposal_messages" // Msg type_urls in the proposal
	AttributeKeyVotingPeriodStart  = "voting_period_start"
	AttributeValueProposalDropped  = "proposal_dropped"  // didn't meet min deposit
	AttributeValueProposalPassed   = "proposal_passed"   // met vote quorum
	AttributeValueProposalRejected = "proposal_rejected" // didn't meet vote quorum
	AttributeValueProposalFailed   = "proposal_failed"   // error on proposal handler
	AttributeKeyProposalType       = "proposal_type"
	AttributeSignalTitle           = "signal_title"
	AttributeSignalDescription     = "signal_description"

Governance module event types

View Source
const (
	// ModuleName is the name of the module
	ModuleName = "gov"

	// StoreKey is the store key string for gov
	StoreKey = ModuleName

	// RouterKey is the message route for gov
	RouterKey = ModuleName


View Source
var (
	ErrUnknownProposal       = sdkerrors.Register(ModuleName, 2, "unknown proposal")
	ErrInactiveProposal      = sdkerrors.Register(ModuleName, 3, "inactive proposal")
	ErrAlreadyActiveProposal = sdkerrors.Register(ModuleName, 4, "proposal already active")
	// Errors 5 & 6 are legacy errors related to v1beta1.Proposal.
	ErrInvalidProposalContent  = sdkerrors.Register(ModuleName, 5, "invalid proposal content")
	ErrInvalidProposalType     = sdkerrors.Register(ModuleName, 6, "invalid proposal type")
	ErrInvalidVote             = sdkerrors.Register(ModuleName, 7, "invalid vote option")
	ErrInvalidGenesis          = sdkerrors.Register(ModuleName, 8, "invalid genesis state")
	ErrNoProposalHandlerExists = sdkerrors.Register(ModuleName, 9, "no handler exists for proposal type")
	ErrUnroutableProposalMsg   = sdkerrors.Register(ModuleName, 10, "proposal message not recognized by router")
	ErrNoProposalMsgs          = sdkerrors.Register(ModuleName, 11, "no messages proposed")
	ErrInvalidProposalMsg      = sdkerrors.Register(ModuleName, 12, "invalid proposal message")
	ErrInvalidSigner           = sdkerrors.Register(ModuleName, 13, "expected gov account as only signer for proposal message")
	ErrInvalidSignalMsg        = sdkerrors.Register(ModuleName, 14, "signal message is invalid")
	ErrMetadataTooLong         = sdkerrors.Register(ModuleName, 15, "metadata too long")
	ErrMinDepositTooSmall      = sdkerrors.Register(ModuleName, 16, "minimum deposit is too small")

x/gov module sentinel errors

View Source
var (
	ProposalsKeyPrefix            = []byte{0x00}
	ActiveProposalQueuePrefix     = []byte{0x01}
	InactiveProposalQueuePrefix   = []byte{0x02}
	ProposalIDKey                 = []byte{0x03}
	VotingPeriodProposalKeyPrefix = []byte{0x04}

	DepositsKeyPrefix = []byte{0x10}

	VotesKeyPrefix = []byte{0x20}

	// ParamsKey is the key to query all gov params
	ParamsKey = []byte{0x30}

Keys for governance store Items are stored with the following key: values

- 0x00<proposalID_Bytes>: Proposal

- 0x01<endTime_Bytes><proposalID_Bytes>: activeProposalID

- 0x02<endTime_Bytes><proposalID_Bytes>: inactiveProposalID

- 0x03: nextProposalID

- 0x04<proposalID_Bytes>: []byte{0x01} if proposalID is in the voting period

- 0x10<proposalID_Bytes><depositorAddrLen (1 Byte)><depositorAddr_Bytes>: Deposit

- 0x20<proposalID_Bytes><voterAddrLen (1 Byte)><voterAddr_Bytes>: Voter

- 0x30: Params


func ActiveProposalByTimeKey

func ActiveProposalByTimeKey(endTime time.Time) []byte

ActiveProposalByTimeKey gets the active proposal queue key by endTime

func ActiveProposalQueueKey

func ActiveProposalQueueKey(proposalID uint64, endTime time.Time) []byte

ActiveProposalQueueKey returns the key for a proposalID in the activeProposalQueue

func DepositKey

func DepositKey(proposalID uint64, depositorAddr sdk.AccAddress) []byte

DepositKey key of a specific deposit from the store

func DepositsKey

func DepositsKey(proposalID uint64) []byte

DepositsKey gets the first part of the deposits key based on the proposalID

func GetProposalIDBytes

func GetProposalIDBytes(proposalID uint64) (proposalIDBz []byte)

GetProposalIDBytes returns the byte representation of the proposalID

func GetProposalIDFromBytes

func GetProposalIDFromBytes(bz []byte) (proposalID uint64)

GetProposalIDFromBytes returns proposalID in uint64 format from a byte array

func InactiveProposalByTimeKey

func InactiveProposalByTimeKey(endTime time.Time) []byte

InactiveProposalByTimeKey gets the inactive proposal queue key by endTime

func InactiveProposalQueueKey

func InactiveProposalQueueKey(proposalID uint64, endTime time.Time) []byte

InactiveProposalQueueKey returns the key for a proposalID in the inactiveProposalQueue

func ProposalKey

func ProposalKey(proposalID uint64) []byte

ProposalKey gets a specific proposal from the store

func SplitActiveProposalQueueKey

func SplitActiveProposalQueueKey(key []byte) (proposalID uint64, endTime time.Time)

SplitActiveProposalQueueKey split the active proposal key and returns the proposal id and endTime

func SplitInactiveProposalQueueKey

func SplitInactiveProposalQueueKey(key []byte) (proposalID uint64, endTime time.Time)

SplitInactiveProposalQueueKey split the inactive proposal key and returns the proposal id and endTime

func SplitKeyDeposit

func SplitKeyDeposit(key []byte) (proposalID uint64, depositorAddr sdk.AccAddress)

SplitKeyDeposit split the deposits key and returns the proposal id and depositor address

func SplitKeyVote

func SplitKeyVote(key []byte) (proposalID uint64, voterAddr sdk.AccAddress)

SplitKeyVote split the votes key and returns the proposal id and voter address

func SplitProposalKey

func SplitProposalKey(key []byte) (proposalID uint64)

SplitProposalKey split the proposal key and returns the proposal id

func VoteKey

func VoteKey(proposalID uint64, voterAddr sdk.AccAddress) []byte

VoteKey key of a specific vote from the store

func VotesKey

func VotesKey(proposalID uint64) []byte

VotesKey gets the first part of the votes key based on the proposalID

func VotingPeriodProposalKey added in v0.47.0

func VotingPeriodProposalKey(proposalID uint64) []byte

VotingPeriodProposalKey gets if a proposal is in voting period.


type AccountKeeper

type AccountKeeper interface {
	GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI

	GetModuleAddress(name string) sdk.AccAddress
	GetModuleAccount(ctx sdk.Context, name string) types.ModuleAccountI

	// TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862
	SetModuleAccount(sdk.Context, types.ModuleAccountI)

AccountKeeper defines the expected account keeper (noalias)

type BankKeeper

type BankKeeper interface {
	GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
	GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin
	LockedCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
	SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins

	SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
	SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
	BurnCoins(ctx sdk.Context, name string, amt sdk.Coins) error

BankKeeper defines the expected interface needed to retrieve account balances.

type Config added in v0.46.0

type Config struct {
	// MaxMetadataLen defines the maximum proposal metadata length.
	MaxMetadataLen uint64

Config is a config struct used for intialising the gov module to avoid using globals.

func DefaultConfig added in v0.46.0

func DefaultConfig() Config

DefaultConfig returns the default config for gov.

type GovHooks added in v0.43.0

type GovHooks interface {
	AfterProposalSubmission(ctx sdk.Context, proposalID uint64)                            // Must be called after proposal is submitted
	AfterProposalDeposit(ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress) // Must be called after a deposit is made
	AfterProposalVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress)        // Must be called after a vote on a proposal is cast
	AfterProposalFailedMinDeposit(ctx sdk.Context, proposalID uint64)                      // Must be called when proposal fails to reach min deposit
	AfterProposalVotingPeriodEnded(ctx sdk.Context, proposalID uint64)                     // Must be called when proposal's finishes it's voting period

GovHooks event hooks for governance proposal object (noalias)

type GovHooksWrapper added in v0.47.0

type GovHooksWrapper struct{ GovHooks }

func (GovHooksWrapper) IsOnePerModuleType added in v0.47.0

func (GovHooksWrapper) IsOnePerModuleType()

IsOnePerModuleType implements the depinject.OnePerModuleType interface.

type MultiGovHooks added in v0.43.0

type MultiGovHooks []GovHooks

combine multiple governance hooks, all hook functions are run in array sequence

func NewMultiGovHooks added in v0.43.0

func NewMultiGovHooks(hooks ...GovHooks) MultiGovHooks

func (MultiGovHooks) AfterProposalDeposit added in v0.43.0

func (h MultiGovHooks) AfterProposalDeposit(ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress)

func (MultiGovHooks) AfterProposalFailedMinDeposit added in v0.43.0

func (h MultiGovHooks) AfterProposalFailedMinDeposit(ctx sdk.Context, proposalID uint64)

func (MultiGovHooks) AfterProposalSubmission added in v0.43.0

func (h MultiGovHooks) AfterProposalSubmission(ctx sdk.Context, proposalID uint64)

func (MultiGovHooks) AfterProposalVote added in v0.43.0

func (h MultiGovHooks) AfterProposalVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress)

func (MultiGovHooks) AfterProposalVotingPeriodEnded added in v0.43.0

func (h MultiGovHooks) AfterProposalVotingPeriodEnded(ctx sdk.Context, proposalID uint64)

type ParamSubspace

type ParamSubspace interface {
	Get(ctx sdk.Context, key []byte, ptr interface{})
	Set(ctx sdk.Context, key []byte, param interface{})

ParamSubspace defines the expected Subspace interface for parameters (noalias)

type ProposalMetadata added in v0.46.2

type ProposalMetadata struct {
	Title             string   `json:"title"`
	Authors           []string `json:"authors"`
	Summary           string   `json:"summary"`
	Details           string   `json:"details"`
	ProposalForumUrl  string   `json:"proposal_forum_url"` //nolint:revive // named 'Url' instead of 'URL' for avoiding the camel case split
	VoteOptionContext string   `json:"vote_option_context"`

ProposalMetadata is the metadata of a proposal This metadata is supposed to live off-chain when submitted in a proposal

type StakingKeeper

type StakingKeeper interface {
	// iterate through bonded validators by operator address, execute func for each validator
		sdk.Context, func(index int64, validator stakingtypes.ValidatorI) (stop bool),

	TotalBondedTokens(sdk.Context) math.Int // total bonded tokens within the validator set
		ctx sdk.Context, delegator sdk.AccAddress,
		fn func(index int64, delegation stakingtypes.DelegationI) (stop bool),

StakingKeeper expected staking keeper (Validator and Delegator sets) (noalias)


Path Synopsis
Package v1 is a reverse proxy.
Package v1 is a reverse proxy.
Package v1beta1 is a reverse proxy.
Package v1beta1 is a reverse proxy.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL