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 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
- type AccountKeeper
- type BankKeeper
- type GovHooks
- 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 StakingKeeper
Constants ¶
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" AttributeValueCategory = "governance" 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 // QuerierRoute is the querier route for gov QuerierRoute = 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") )
x/gov module sentinel errors
var ( ProposalsKeyPrefix = []byte{0x00} ActiveProposalQueuePrefix = []byte{0x01} InactiveProposalQueuePrefix = []byte{0x02} ProposalIDKey = []byte{0x03} DepositsKeyPrefix = []byte{0x10} VotesKeyPrefix = []byte{0x20} )
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
- 0x10<proposalID_Bytes><depositorAddrLen (1 Byte)><depositorAddr_Bytes>: Deposit
- 0x20<proposalID_Bytes><voterAddrLen (1 Byte)><voterAddr_Bytes>: Voter
var ( // ModuleCdc references the global x/gov module codec. Note, the codec should // ONLY be used in certain instances of tests and for JSON encoding as Amino is // still used for that purpose. // // The actual codec used for serialization should be provided to x/gov and // defined at the application level. ModuleCdc = codec.NewAminoCodec(amino) )
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 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
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 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 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 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) sdk.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)