Documentation ¶
Index ¶
- Constants
- Variables
- func ActiveProposalByTimeKey(endTime time.Time) []byte
- func ActiveProposalQueueKey(proposalID uint64, endTime time.Time) []byte
- func ApplyUnifiedDiff(src, diffStr string) (string, error)
- 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 ProposalKey(proposalID uint64) []byte
- func QuorumCheckByTimeKey(endTime time.Time) []byte
- func QuorumCheckQueueKey(proposalID uint64, endTime time.Time) []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 SplitQuorumQueueKey(key []byte) (proposalID uint64, endTime time.Time)
- 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 Hunk
- type MultiGovHooks
- func (h MultiGovHooks) AfterProposalDeposit(ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress)
- func (h MultiGovHooks) AfterProposalFailedMinDeposit(ctx sdk.Context, proposalID uint64)
- func (h MultiGovHooks) AfterProposalSubmission(ctx sdk.Context, proposalID uint64)
- func (h MultiGovHooks) AfterProposalVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress)
- func (h MultiGovHooks) AfterProposalVotingPeriodEnded(ctx sdk.Context, proposalID uint64)
- 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" EventTypeQuorumCheck = "quorum_check" 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" AttributeValueProposalQuorumMet = "proposal_quorum_met" // met quorum AttributeValueProposalQuorumNotMet = "proposal_quorum_not_met" // didn't meet quorum AttributeValueProposalQuorumCheckSkipped = "proposal_quorum_check_skipped" // skipped quorum check )
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, 20, "unknown proposal") //nolint:staticcheck ErrInactiveProposal = sdkerrors.Register(ModuleName, 30, "inactive proposal") //nolint:staticcheck ErrAlreadyActiveProposal = sdkerrors.Register(ModuleName, 40, "proposal already active") //nolint:staticcheck // Errors 5 & 6 are legacy errors related to v1beta1.Proposal. ErrInvalidProposalContent = sdkerrors.Register(ModuleName, 50, "invalid proposal content") //nolint:staticcheck ErrInvalidProposalType = sdkerrors.Register(ModuleName, 60, "invalid proposal type") //nolint:staticcheck ErrInvalidVote = sdkerrors.Register(ModuleName, 70, "invalid vote option") //nolint:staticcheck ErrInvalidGenesis = sdkerrors.Register(ModuleName, 80, "invalid genesis state") //nolint:staticcheck ErrNoProposalHandlerExists = sdkerrors.Register(ModuleName, 90, "no handler exists for proposal type") //nolint:staticcheck ErrUnroutableProposalMsg = sdkerrors.Register(ModuleName, 100, "proposal message not recognized by router") //nolint:staticcheck ErrNoProposalMsgs = sdkerrors.Register(ModuleName, 110, "no messages proposed") //nolint:staticcheck ErrInvalidProposalMsg = sdkerrors.Register(ModuleName, 120, "invalid proposal message") //nolint:staticcheck ErrInvalidSigner = sdkerrors.Register(ModuleName, 130, "expected gov account as only signer for proposal message") //nolint:staticcheck ErrInvalidSignalMsg = sdkerrors.Register(ModuleName, 140, "signal message is invalid") //nolint:staticcheck ErrMetadataTooLong = sdkerrors.Register(ModuleName, 150, "metadata too long") //nolint:staticcheck ErrMinDepositTooSmall = sdkerrors.Register(ModuleName, 160, "minimum deposit is too small") //nolint:staticcheck ErrInvalidConstitutionAmendment = sdkerrors.Register(ModuleName, 170, "invalid constitution amendment") //nolint:staticcheck )
x/gov module sentinel errors
var ( ProposalsKeyPrefix = []byte{0x00} ActiveProposalQueuePrefix = []byte{0x01} InactiveProposalQueuePrefix = []byte{0x02} ProposalIDKey = []byte{0x03} VotingPeriodProposalKeyPrefix = []byte{0x04} QuorumCheckQueuePrefix = []byte{0x05} DepositsKeyPrefix = []byte{0x10} VotesKeyPrefix = []byte{0x20} // ParamsKey is the key to query all gov params ParamsKey = []byte{0x30} // KeyConstitution is the key string used to store the chain's constitution KeyConstitution = []byte{0x40} )
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 ApplyUnifiedDiff ¶
ApplyUnifiedDiff applies a unified diff patch to the src string and returns the result. Does not make use of any external libraries to ensure deterministic behavior.
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 ProposalKey ¶
ProposalKey gets a specific proposal from the store
func QuorumCheckByTimeKey ¶
QuorumCheckByTimeKey gets the quorum check queue key by endTime
func QuorumCheckQueueKey ¶
QuorumCheckQueueKey returns the key for a proposalID in the quorumCheckQueue
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 SplitQuorumQueueKey ¶
SplitQuorumQueueKey split the quorum queue key and returns the proposal id and endTime
func VoteKey ¶
func VoteKey(proposalID uint64, voterAddr sdk.AccAddress) []byte
VoteKey key of a specific vote from the store
func VotingPeriodProposalKey ¶
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 ¶
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.
type GovHooks ¶
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 ¶
type GovHooksWrapper struct{ GovHooks }
func (GovHooksWrapper) IsOnePerModuleType ¶
func (GovHooksWrapper) IsOnePerModuleType()
IsOnePerModuleType implements the depinject.OnePerModuleType interface.
type Hunk ¶
Hunk represents a single change hunk in a unified diff.
func ParseUnifiedDiff ¶
ParseUnifiedDiff parses the unified diff string into hunks with validation.
type MultiGovHooks ¶
type MultiGovHooks []GovHooks
combine multiple governance hooks, all hook functions are run in array sequence
func NewMultiGovHooks ¶
func NewMultiGovHooks(hooks ...GovHooks) MultiGovHooks
func (MultiGovHooks) AfterProposalDeposit ¶
func (h MultiGovHooks) AfterProposalDeposit(ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress)
func (MultiGovHooks) AfterProposalFailedMinDeposit ¶
func (h MultiGovHooks) AfterProposalFailedMinDeposit(ctx sdk.Context, proposalID uint64)
func (MultiGovHooks) AfterProposalSubmission ¶
func (h MultiGovHooks) AfterProposalSubmission(ctx sdk.Context, proposalID uint64)
func (MultiGovHooks) AfterProposalVote ¶
func (h MultiGovHooks) AfterProposalVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress)
func (MultiGovHooks) AfterProposalVotingPeriodEnded ¶
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 ¶
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)