Documentation ¶
Index ¶
- Constants
- Variables
- func ActiveProposalByTimeKey(endTime time.Time) []byte
- func ActiveProposalQueueKey(proposalID uint64, endTime time.Time) []byte
- func DepositKey(proposalID uint64, depositorAddr sdk.AccAddress) []byte
- func DepositsKey(proposalID uint64) []byte
- func GetProposalIDBytes(proposalID uint64) (proposalIDBz []byte)
- func GetProposalIDFromBytes(bz []byte) (proposalID uint64)
- func InactiveProposalByTimeKey(endTime time.Time) []byte
- func InactiveProposalQueueKey(proposalID uint64, endTime time.Time) []byte
- func JoinErrors(errs ...error) error
- func ProposalKey(proposalID uint64) []byte
- func SplitActiveProposalQueueKey(key []byte) (proposalID uint64, endTime time.Time)
- func SplitInactiveProposalQueueKey(key []byte) (proposalID uint64, endTime time.Time)
- func SplitKeyDeposit(key []byte) (proposalID uint64, depositorAddr sdk.AccAddress)
- func SplitKeyVote(key []byte) (proposalID uint64, voterAddr sdk.AccAddress)
- func SplitProposalKey(key []byte) (proposalID uint64)
- func VoteKey(proposalID uint64, voterAddr sdk.AccAddress) []byte
- func VotesKey(proposalID uint64) []byte
- func VotingPeriodProposalKey(proposalID uint64) []byte
- type AccountKeeper
- type BankKeeper
- type Config
- type GovHooks
- type GovHooksWrapper
- type MultiGovHooks
- func (h MultiGovHooks) AfterProposalDeposit(ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress) error
- func (h MultiGovHooks) AfterProposalFailedMinDeposit(ctx sdk.Context, proposalID uint64) error
- func (h MultiGovHooks) AfterProposalSubmission(ctx sdk.Context, proposalID uint64) error
- func (h MultiGovHooks) AfterProposalVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress) error
- func (h MultiGovHooks) AfterProposalVotingPeriodEnded(ctx sdk.Context, proposalID uint64) error
- type ParamSubspace
- type ProposalMetadata
- type StakingKeeper
Constants ¶
const ( EventTypeSubmitProposal = "submit_proposal" EventTypeProposalDeposit = "proposal_deposit" EventTypeProposalVote = "proposal_vote" EventTypeInactiveProposal = "inactive_proposal" EventTypeActiveProposal = "active_proposal" EventTypeSignalProposal = "signal_proposal" AttributeKeyVoter = "voter" 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
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 )
Variables ¶
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") // Error 23 is added through backport of #18189 PR ErrInvalidDepositDenom = sdkerrors.Register(ModuleName, 23, "invalid deposit denom") )
x/gov module sentinel errors
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
Functions ¶
func ActiveProposalByTimeKey ¶
ActiveProposalByTimeKey gets the active proposal queue key by endTime
func ActiveProposalQueueKey ¶
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 ¶
DepositsKey gets the first part of the deposits key based on the proposalID
func GetProposalIDBytes ¶
GetProposalIDBytes returns the byte representation of the proposalID
func GetProposalIDFromBytes ¶
GetProposalIDFromBytes returns proposalID in uint64 format from a byte array
func InactiveProposalByTimeKey ¶
InactiveProposalByTimeKey gets the inactive proposal queue key by endTime
func InactiveProposalQueueKey ¶
InactiveProposalQueueKey returns the key for a proposalID in the inactiveProposalQueue
func JoinErrors ¶
implementation of errors.Join() in Go 1.20, until we upgrade to that version
func ProposalKey ¶
ProposalKey gets a specific proposal from the store
func SplitActiveProposalQueueKey ¶
SplitActiveProposalQueueKey split the active proposal key and returns the proposal id and endTime
func SplitInactiveProposalQueueKey ¶
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 ¶
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 VotingPeriodProposalKey ¶ added in v0.47.0
VotingPeriodProposalKey gets if a proposal is in voting period.
Types ¶
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) error // Must be called after proposal is submitted AfterProposalDeposit(ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress) error // Must be called after a deposit is made AfterProposalVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress) error // Must be called after a vote on a proposal is cast AfterProposalFailedMinDeposit(ctx sdk.Context, proposalID uint64) error // Must be called when proposal fails to reach min deposit AfterProposalVotingPeriodEnded(ctx sdk.Context, proposalID uint64) error // 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) error
func (MultiGovHooks) AfterProposalFailedMinDeposit ¶ added in v0.43.0
func (h MultiGovHooks) AfterProposalFailedMinDeposit(ctx sdk.Context, proposalID uint64) error
func (MultiGovHooks) AfterProposalSubmission ¶ added in v0.43.0
func (h MultiGovHooks) AfterProposalSubmission(ctx sdk.Context, proposalID uint64) error
func (MultiGovHooks) AfterProposalVote ¶ added in v0.43.0
func (h MultiGovHooks) AfterProposalVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress) error
func (MultiGovHooks) AfterProposalVotingPeriodEnded ¶ added in v0.43.0
func (h MultiGovHooks) AfterProposalVotingPeriodEnded(ctx sdk.Context, proposalID uint64) error
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 IterateBondedValidatorsByPower( sdk.Context, func(index int64, validator stakingtypes.ValidatorI) (stop bool), ) TotalBondedTokens(sdk.Context) math.Int // total bonded tokens within the validator set IterateDelegations( ctx sdk.Context, delegator sdk.AccAddress, fn func(index int64, delegation stakingtypes.DelegationI) (stop bool), ) }
StakingKeeper expected staking keeper (Validator and Delegator sets) (noalias)