Documentation ¶
Index ¶
- Constants
- Variables
- type AccountKeeper
- type BankKeeper
- type GovHooks
- type GovHooksWrapper
- type MultiGovHooks
- func (h MultiGovHooks) AfterProposalDeposit(ctx context.Context, proposalID uint64, depositorAddr sdk.AccAddress) error
- func (h MultiGovHooks) AfterProposalFailedMinDeposit(ctx context.Context, proposalID uint64) error
- func (h MultiGovHooks) AfterProposalSubmission(ctx context.Context, proposalID uint64) error
- func (h MultiGovHooks) AfterProposalVote(ctx context.Context, proposalID uint64, voterAddr sdk.AccAddress) error
- func (h MultiGovHooks) AfterProposalVotingPeriodEnded(ctx context.Context, proposalID uint64) error
- type PoolKeeper
- type ProposalMetadata
- type StakingKeeper
Constants ¶
const ( EventTypeSubmitProposal = "submit_proposal" EventTypeProposalDeposit = "proposal_deposit" EventTypeProposalVote = "proposal_vote" EventTypeInactiveProposal = "inactive_proposal" EventTypeActiveProposal = "active_proposal" EventTypeCancelProposal = "cancel_proposal" AttributeKeyProposalResult = "proposal_result" AttributeKeyVoter = "voter" AttributeKeyOption = "option" AttributeKeyProposalID = "proposal_id" AttributeKeyDepositor = "depositor" AttributeKeyProposalMessages = "proposal_messages" // Msg type_urls in the proposal AttributeKeyVotingPeriodStart = "voting_period_start" AttributeKeyProposalLog = "proposal_log" // log of proposal execution AttributeKeyProposalDepositError = "proposal_deposit_error" // error on proposal deposit refund/burn AttributeKeyProposalProposer = "proposal_proposer" // account address of the proposer AttributeValueProposalDropped = "proposal_dropped" // didn't meet min deposit AttributeValueProposalPassed = "proposal_passed" // met vote quorum AttributeValueProposalRejected = "proposal_rejected" // didn't meet vote quorum AttributeValueExpeditedProposalRejected = "expedited_proposal_rejected" // didn't meet expedited vote quorum AttributeValueOptimisticProposalRejected = "optimistic_proposal_rejected" // didn't meet optimistic vote quorum AttributeValueProposalFailed = "proposal_failed" // error on proposal handler AttributeValueProposalCanceled = "proposal_canceled" // 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 ( ErrInactiveProposal = errors.Register(ModuleName, 3, "inactive proposal") ErrAlreadyActiveProposal = errors.Register(ModuleName, 4, "proposal already active") // Errors 5 & 6 are legacy errors related to v1beta1.Proposal. ErrInvalidProposalContent = errors.Register(ModuleName, 5, "invalid proposal content") ErrInvalidProposalType = errors.Register(ModuleName, 6, "invalid proposal type") ErrInvalidVote = errors.Register(ModuleName, 7, "invalid vote option") ErrInvalidGenesis = errors.Register(ModuleName, 8, "invalid genesis state") ErrNoProposalHandlerExists = errors.Register(ModuleName, 9, "no handler exists for proposal type") ErrUnroutableProposalMsg = errors.Register(ModuleName, 10, "proposal message not recognized by router") ErrNoProposalMsgs = errors.Register(ModuleName, 11, "no messages proposed") ErrInvalidProposalMsg = errors.Register(ModuleName, 12, "invalid proposal message") ErrInvalidSigner = errors.Register(ModuleName, 13, "expected authority account as only signer for proposal message") ErrMetadataTooLong = errors.Register(ModuleName, 15, "metadata too long") ErrMinDepositTooSmall = errors.Register(ModuleName, 16, "minimum deposit is too small") ErrInvalidProposer = errors.Register(ModuleName, 18, "invalid proposer") ErrVotingPeriodEnded = errors.Register(ModuleName, 20, "voting period already ended") ErrInvalidProposal = errors.Register(ModuleName, 21, "invalid proposal") ErrSummaryTooLong = errors.Register(ModuleName, 22, "summary too long") ErrInvalidDepositDenom = errors.Register(ModuleName, 23, "invalid deposit denom") ErrTitleTooLong = errors.Register(ModuleName, 24, "title too long") ErrTooLateToCancel = errors.Register(ModuleName, 25, "too late to cancel proposal") ErrTooManyVoteOptions = errors.Register(ModuleName, 26, "too many weighted vote options") )
x/gov module sentinel errors
var ( ProposalsKeyPrefix = collections.NewPrefix(0) // ProposalsKeyPrefix stores the proposals raw bytes. ActiveProposalQueuePrefix = collections.NewPrefix(1) // ActiveProposalQueuePrefix stores the active proposals. InactiveProposalQueuePrefix = collections.NewPrefix(2) // InactiveProposalQueuePrefix stores the inactive proposals. ProposalIDKey = collections.NewPrefix(3) // ProposalIDKey stores the sequence representing the next proposal ID. DepositsKeyPrefix = collections.NewPrefix(16) // DepositsKeyPrefix stores deposits. VotesKeyPrefix = collections.NewPrefix(32) // VotesKeyPrefix stores the votes of proposals. ParamsKey = collections.NewPrefix(48) // ParamsKey stores the module's params. ConstitutionKey = collections.NewPrefix(49) // ConstitutionKey stores a chain's constitution. ProposalVoteOptionsKeyPrefix = collections.NewPrefix(50) // ProposalVoteOptionsKeyPrefix stores the vote options of proposals. MessageBasedParamsKey = collections.NewPrefix(51) // MessageBasedParamsKey stores the message based gov params. )
Functions ¶
This section is empty.
Types ¶
type AccountKeeper ¶
type AccountKeeper interface { AddressCodec() addresscodec.Codec GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI GetModuleAddress(name string) sdk.AccAddress GetModuleAccount(ctx context.Context, name string) sdk.ModuleAccountI // TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862 SetModuleAccount(context.Context, sdk.ModuleAccountI) }
AccountKeeper defines the expected account keeper (noalias)
type BankKeeper ¶
type BankKeeper interface { GetAllBalances(ctx context.Context, addr sdk.AccAddress) sdk.Coins GetBalance(ctx context.Context, addr sdk.AccAddress, denom string) sdk.Coin LockedCoins(ctx context.Context, addr sdk.AccAddress) sdk.Coins SpendableCoins(ctx context.Context, addr sdk.AccAddress) sdk.Coins SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error SendCoinsFromAccountToModule(ctx context.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error BurnCoins(context.Context, []byte, sdk.Coins) error }
BankKeeper defines the expected interface needed to retrieve account balances.
type GovHooks ¶
type GovHooks interface { AfterProposalSubmission(ctx context.Context, proposalID uint64) error // Must be called after proposal is submitted AfterProposalDeposit(ctx context.Context, proposalID uint64, depositorAddr sdk.AccAddress) error // Must be called after a deposit is made AfterProposalVote(ctx context.Context, proposalID uint64, voterAddr sdk.AccAddress) error // Must be called after a vote on a proposal is cast AfterProposalFailedMinDeposit(ctx context.Context, proposalID uint64) error // Must be called when proposal fails to reach min deposit AfterProposalVotingPeriodEnded(ctx context.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 ¶
type GovHooksWrapper struct{ GovHooks }
func (GovHooksWrapper) IsOnePerModuleType ¶
func (GovHooksWrapper) IsOnePerModuleType()
IsOnePerModuleType implements the depinject.OnePerModuleType interface.
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 context.Context, proposalID uint64, depositorAddr sdk.AccAddress) error
func (MultiGovHooks) AfterProposalFailedMinDeposit ¶
func (h MultiGovHooks) AfterProposalFailedMinDeposit(ctx context.Context, proposalID uint64) error
func (MultiGovHooks) AfterProposalSubmission ¶
func (h MultiGovHooks) AfterProposalSubmission(ctx context.Context, proposalID uint64) error
func (MultiGovHooks) AfterProposalVote ¶
func (h MultiGovHooks) AfterProposalVote(ctx context.Context, proposalID uint64, voterAddr sdk.AccAddress) error
func (MultiGovHooks) AfterProposalVotingPeriodEnded ¶
func (h MultiGovHooks) AfterProposalVotingPeriodEnded(ctx context.Context, proposalID uint64) error
type PoolKeeper ¶
type PoolKeeper interface {
FundCommunityPool(ctx context.Context, amount sdk.Coins, sender []byte) error
}
PoolKeeper defines the expected interface needed to fund & distribute pool balances.
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"` 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 { ValidatorAddressCodec() addresscodec.Codec // iterate through bonded validators by operator address, execute func for each validator IterateBondedValidatorsByPower( context.Context, func(index int64, validator sdk.ValidatorI) (stop bool), ) error TotalBondedTokens(context.Context) (math.Int, error) // total bonded tokens within the validator set IterateDelegations( ctx context.Context, delegator sdk.AccAddress, fn func(index int64, delegation sdk.DelegationI) (stop bool), ) error }
StakingKeeper expected staking keeper (Validator and Delegator sets) (noalias)