Documentation ¶
Overview ¶
nolint autogenerated code using github.com/rigelrozanski/multitool aliases generated for the following subdirectories: ALIASGEN: github.com/cosmos/cosmos-sdk/x/gov/types
Index ¶
- Constants
- Variables
- func EndBlocker(ctx sdk.Context, keeper Keeper) sdk.Tags
- func InitGenesis(ctx sdk.Context, k Keeper, data GenesisState)
- func NewHandler(keeper Keeper) sdk.Handler
- func NewQuerier(keeper Keeper) sdk.Querier
- func ParamKeyTable() params.KeyTable
- func ProposalEqual(proposalA Proposal, proposalB Proposal) bool
- func SortAddresses(addrs []sdk.AccAddress)
- func SortByteArrays(src [][]byte) [][]byte
- func ValidateGenesis(data GenesisState) error
- type AppModule
- func (AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) sdk.Tags
- func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) ([]abci.ValidatorUpdate, sdk.Tags)
- func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage
- func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate
- func (AppModule) Name() string
- func (am AppModule) NewHandler() sdk.Handler
- func (am AppModule) NewQuerierHandler() sdk.Querier
- func (AppModule) QuerierRoute() string
- func (AppModule) RegisterInvariants(_ sdk.InvariantRouter)
- func (AppModule) Route() string
- type AppModuleBasic
- type BankKeeper
- type Content
- type Deposit
- type DepositParams
- type DepositWithMetadata
- type Deposits
- type GenesisState
- type Handler
- type Keeper
- func (keeper Keeper) ActiveProposalQueueIterator(ctx sdk.Context, endTime time.Time) sdk.Iterator
- func (keeper Keeper) AddDeposit(ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress, ...) (sdk.Error, bool)
- func (keeper Keeper) AddVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress, ...) sdk.Error
- func (keeper Keeper) DeleteDeposits(ctx sdk.Context, proposalID uint64)
- func (keeper Keeper) DeleteProposal(ctx sdk.Context, proposalID uint64)
- func (keeper Keeper) GetDeposit(ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress) (Deposit, bool)
- func (keeper Keeper) GetDepositParams(ctx sdk.Context) DepositParams
- func (keeper Keeper) GetDeposits(ctx sdk.Context, proposalID uint64) sdk.Iterator
- func (keeper Keeper) GetLastProposalID(ctx sdk.Context) (proposalID uint64)
- func (keeper Keeper) GetProposal(ctx sdk.Context, proposalID uint64) (proposal Proposal, ok bool)
- func (keeper Keeper) GetProposalsFiltered(ctx sdk.Context, voterAddr sdk.AccAddress, depositorAddr sdk.AccAddress, ...) []Proposal
- func (keeper Keeper) GetTallyParams(ctx sdk.Context) TallyParams
- func (keeper Keeper) GetVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress) (Vote, bool)
- func (keeper Keeper) GetVotes(ctx sdk.Context, proposalID uint64) sdk.Iterator
- func (keeper Keeper) GetVotingParams(ctx sdk.Context) VotingParams
- func (keeper Keeper) InactiveProposalQueueIterator(ctx sdk.Context, endTime time.Time) sdk.Iterator
- func (keeper Keeper) InsertActiveProposalQueue(ctx sdk.Context, endTime time.Time, proposalID uint64)
- func (keeper Keeper) InsertInactiveProposalQueue(ctx sdk.Context, endTime time.Time, proposalID uint64)
- func (keeper Keeper) Logger(ctx sdk.Context) log.Logger
- func (keeper Keeper) RefundDeposits(ctx sdk.Context, proposalID uint64)
- func (keeper Keeper) RemoveFromActiveProposalQueue(ctx sdk.Context, endTime time.Time, proposalID uint64)
- func (keeper Keeper) RemoveFromInactiveProposalQueue(ctx sdk.Context, endTime time.Time, proposalID uint64)
- func (keeper Keeper) SetProposal(ctx sdk.Context, proposal Proposal)
- func (keeper Keeper) SubmitProposal(ctx sdk.Context, content Content) (Proposal, sdk.Error)
- type MsgDeposit
- type MsgSubmitProposal
- type MsgVote
- type Params
- type Proposal
- type ProposalQueue
- type ProposalStatus
- type Proposals
- type QueryDepositParams
- type QueryProposalParams
- type QueryProposalsParams
- type QueryVoteParams
- type Router
- type SoftwareUpgradeProposal
- type TallyParams
- type TallyResult
- type TextProposal
- type Vote
- type VoteOption
- type VoteWithMetadata
- type Votes
- type VotingParams
Constants ¶
const ( MaxDescriptionLength = types.MaxDescriptionLength MaxTitleLength = types.MaxTitleLength DefaultCodespace = types.DefaultCodespace CodeUnknownProposal = types.CodeUnknownProposal CodeInactiveProposal = types.CodeInactiveProposal CodeAlreadyActiveProposal = types.CodeAlreadyActiveProposal CodeAlreadyFinishedProposal = types.CodeAlreadyFinishedProposal CodeAddressNotStaked = types.CodeAddressNotStaked CodeInvalidContent = types.CodeInvalidContent CodeInvalidProposalType = types.CodeInvalidProposalType CodeInvalidVote = types.CodeInvalidVote CodeInvalidGenesis = types.CodeInvalidGenesis CodeInvalidProposalStatus = types.CodeInvalidProposalStatus CodeProposalHandlerNotExists = types.CodeProposalHandlerNotExists ModuleName = types.ModuleName StoreKey = types.StoreKey RouterKey = types.RouterKey QuerierRoute = types.QuerierRoute DefaultParamspace = types.DefaultParamspace TypeMsgDeposit = types.TypeMsgDeposit TypeMsgVote = types.TypeMsgVote TypeMsgSubmitProposal = types.TypeMsgSubmitProposal StatusNil = types.StatusNil StatusDepositPeriod = types.StatusDepositPeriod StatusVotingPeriod = types.StatusVotingPeriod StatusPassed = types.StatusPassed StatusRejected = types.StatusRejected StatusFailed = types.StatusFailed ProposalTypeText = types.ProposalTypeText ProposalTypeSoftwareUpgrade = types.ProposalTypeSoftwareUpgrade OptionEmpty = types.OptionEmpty OptionYes = types.OptionYes OptionAbstain = types.OptionAbstain OptionNo = types.OptionNo OptionNoWithVeto = types.OptionNoWithVeto )
const ( QueryParams = "params" QueryProposals = "proposals" QueryProposal = "proposal" QueryDeposits = "deposits" QueryDeposit = "deposit" QueryVotes = "votes" QueryVote = "vote" QueryTally = "tally" ParamDeposit = "deposit" ParamVoting = "voting" ParamTallying = "tallying" )
query endpoints supported by the governance Querier
const ( // Default period for deposits & voting DefaultPeriod time.Duration = 86400 * 2 * time.Second // 2 days )
Variables ¶
var ( // functions aliases RegisterCodec = types.RegisterCodec RegisterProposalTypeCodec = types.RegisterProposalTypeCodec ValidateAbstract = types.ValidateAbstract ErrUnknownProposal = types.ErrUnknownProposal ErrInactiveProposal = types.ErrInactiveProposal ErrAlreadyActiveProposal = types.ErrAlreadyActiveProposal ErrAlreadyFinishedProposal = types.ErrAlreadyFinishedProposal ErrAddressNotStaked = types.ErrAddressNotStaked ErrInvalidProposalContent = types.ErrInvalidProposalContent ErrInvalidProposalType = types.ErrInvalidProposalType ErrInvalidVote = types.ErrInvalidVote ErrInvalidGenesis = types.ErrInvalidGenesis ErrNoProposalHandlerExists = types.ErrNoProposalHandlerExists KeyProposal = types.KeyProposal KeyDeposit = types.KeyDeposit KeyVote = types.KeyVote KeyDepositsSubspace = types.KeyDepositsSubspace KeyVotesSubspace = types.KeyVotesSubspace PrefixActiveProposalQueueTime = types.PrefixActiveProposalQueueTime KeyActiveProposalQueueProposal = types.KeyActiveProposalQueueProposal PrefixInactiveProposalQueueTime = types.PrefixInactiveProposalQueueTime KeyInactiveProposalQueueProposal = types.KeyInactiveProposalQueueProposal NewMsgSubmitProposal = types.NewMsgSubmitProposal NewMsgDeposit = types.NewMsgDeposit NewMsgVote = types.NewMsgVote NewProposal = types.NewProposal ProposalStatusFromString = types.ProposalStatusFromString ValidProposalStatus = types.ValidProposalStatus NewTallyResult = types.NewTallyResult NewTallyResultFromMap = types.NewTallyResultFromMap EmptyTallyResult = types.EmptyTallyResult NewTextProposal = types.NewTextProposal NewSoftwareUpgradeProposal = types.NewSoftwareUpgradeProposal RegisterProposalType = types.RegisterProposalType ContentFromProposalType = types.ContentFromProposalType IsValidProposalType = types.IsValidProposalType ProposalHandler = types.ProposalHandler VoteOptionFromString = types.VoteOptionFromString ValidVoteOption = types.ValidVoteOption // variable aliases ModuleCdc = types.ModuleCdc KeyDelimiter = types.KeyDelimiter KeyNextProposalID = types.KeyNextProposalID PrefixActiveProposalQueue = types.PrefixActiveProposalQueue PrefixInactiveProposalQueue = types.PrefixInactiveProposalQueue )
var ( ParamStoreKeyDepositParams = []byte("depositparams") ParamStoreKeyVotingParams = []byte("votingparams") ParamStoreKeyTallyParams = []byte("tallyparams") // TODO: Find another way to implement this without using accounts, or find a cleaner way to implement it using accounts. DepositedCoinsAccAddr = sdk.AccAddress(crypto.AddressHash([]byte("govDepositedCoins"))) BurnedDepositCoinsAccAddr = sdk.AccAddress(crypto.AddressHash([]byte("govBurnedDepositCoins"))) )
Parameter store key
Functions ¶
func EndBlocker ¶
Called every block, process inflation, update validator set
func InitGenesis ¶
func InitGenesis(ctx sdk.Context, k Keeper, data GenesisState)
InitGenesis - store genesis parameters
func NewQuerier ¶
func ProposalEqual ¶
checks if two proposals are equal (note: slow, for tests only)
Types ¶
type AppModule ¶
type AppModule struct { AppModuleBasic // contains filtered or unexported fields }
___________________________ app module
func NewAppModule ¶
NewAppModule creates a new AppModule object
func (AppModule) BeginBlock ¶
module begin-block
func (AppModule) EndBlock ¶
func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) ([]abci.ValidatorUpdate, sdk.Tags)
module end-block
func (AppModule) ExportGenesis ¶
func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage
module export genesis
func (AppModule) InitGenesis ¶
func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate
module init-genesis
func (AppModule) NewQuerierHandler ¶
module querier
func (AppModule) RegisterInvariants ¶
func (AppModule) RegisterInvariants(_ sdk.InvariantRouter)
register invariants
type AppModuleBasic ¶
type AppModuleBasic struct{}
app module basics object
func (AppModuleBasic) DefaultGenesis ¶
func (AppModuleBasic) DefaultGenesis() json.RawMessage
default genesis state
func (AppModuleBasic) RegisterCodec ¶
func (AppModuleBasic) RegisterCodec(cdc *codec.Codec)
register module codec
func (AppModuleBasic) ValidateGenesis ¶
func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error
module validate genesis
type BankKeeper ¶
type BankKeeper interface { GetCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins // TODO remove once governance doesn't require use of accounts SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) sdk.Error SetSendEnabled(ctx sdk.Context, enabled bool) }
expected bank keeper
type DepositParams ¶
type DepositParams struct { MinDeposit sdk.Coins `json:"min_deposit"` // Minimum deposit for a proposal to enter voting period. MaxDepositPeriod time.Duration `json:"max_deposit_period"` // Maximum period for Atom holders to deposit on a proposal. Initial value: 2 months }
Param around deposits for governance
func NewDepositParams ¶
func NewDepositParams(minDeposit sdk.Coins, maxDepositPeriod time.Duration) DepositParams
NewDepositParams creates a new DepositParams object
func (DepositParams) Equal ¶
func (dp DepositParams) Equal(dp2 DepositParams) bool
Checks equality of DepositParams
func (DepositParams) String ¶
func (dp DepositParams) String() string
type DepositWithMetadata ¶
type DepositWithMetadata struct { ProposalID uint64 `json:"proposal_id"` Deposit Deposit `json:"deposit"` }
DepositWithMetadata (just for genesis)
type GenesisState ¶
type GenesisState struct { StartingProposalID uint64 `json:"starting_proposal_id"` Deposits []DepositWithMetadata `json:"deposits"` Votes []VoteWithMetadata `json:"votes"` Proposals []Proposal `json:"proposals"` DepositParams DepositParams `json:"deposit_params"` VotingParams VotingParams `json:"voting_params"` TallyParams TallyParams `json:"tally_params"` }
GenesisState - all staking state that must be provided at genesis
func DefaultGenesisState ¶
func DefaultGenesisState() GenesisState
get raw genesis raw message for testing
func ExportGenesis ¶
func ExportGenesis(ctx sdk.Context, k Keeper) GenesisState
ExportGenesis - output genesis parameters
func NewGenesisState ¶
func NewGenesisState(startingProposalID uint64, dp DepositParams, vp VotingParams, tp TallyParams) GenesisState
func (GenesisState) Equal ¶
func (data GenesisState) Equal(data2 GenesisState) bool
Checks whether 2 GenesisState structs are equivalent.
func (GenesisState) IsEmpty ¶
func (data GenesisState) IsEmpty() bool
Returns if a GenesisState is empty or has data in it
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
Governance Keeper
func NewKeeper ¶
func NewKeeper( cdc *codec.Codec, key sdk.StoreKey, paramsKeeper params.Keeper, paramSpace params.Subspace, ck BankKeeper, ds sdk.DelegationSet, codespace sdk.CodespaceType, rtr Router, ) Keeper
NewKeeper returns a governance keeper. It handles: - submitting governance proposals - depositing funds into proposals, and activating upon sufficient funds being deposited - users voting on proposals, with weight proportional to stake in the system - and tallying the result of the vote.
func (Keeper) ActiveProposalQueueIterator ¶
Returns an iterator for all the proposals in the Active Queue that expire by endTime
func (Keeper) AddDeposit ¶
func (keeper Keeper) AddDeposit(ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress, depositAmount sdk.Coins) (sdk.Error, bool)
Adds or updates a deposit of a specific depositor on a specific proposal Activates voting period when appropriate
func (Keeper) AddVote ¶
func (keeper Keeper) AddVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress, option VoteOption) sdk.Error
Adds a vote on a specific proposal
func (Keeper) DeleteDeposits ¶
Deletes all the deposits on a specific proposal without refunding them
func (Keeper) DeleteProposal ¶
Implements sdk.AccountKeeper.
func (Keeper) GetDeposit ¶
func (keeper Keeper) GetDeposit(ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress) (Deposit, bool)
Gets the deposit of a specific depositor on a specific proposal
func (Keeper) GetDepositParams ¶
func (keeper Keeper) GetDepositParams(ctx sdk.Context) DepositParams
Returns the current DepositParams from the global param store
func (Keeper) GetDeposits ¶
Gets all the deposits on a specific proposal as an sdk.Iterator
func (Keeper) GetLastProposalID ¶
Get the last used proposal ID
func (Keeper) GetProposal ¶
Get Proposal from store by ProposalID
func (Keeper) GetProposalsFiltered ¶
func (keeper Keeper) GetProposalsFiltered(ctx sdk.Context, voterAddr sdk.AccAddress, depositorAddr sdk.AccAddress, status ProposalStatus, numLatest uint64) []Proposal
Get Proposal from store by ProposalID voterAddr will filter proposals by whether or not that address has voted on them depositorAddr will filter proposals by whether or not that address has deposited to them status will filter proposals by status numLatest will fetch a specified number of the most recent proposals, or 0 for all proposals
func (Keeper) GetTallyParams ¶
func (keeper Keeper) GetTallyParams(ctx sdk.Context) TallyParams
Returns the current TallyParam from the global param store
func (Keeper) GetVote ¶
func (keeper Keeper) GetVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress) (Vote, bool)
Gets the vote of a specific voter on a specific proposal
func (Keeper) GetVotingParams ¶
func (keeper Keeper) GetVotingParams(ctx sdk.Context) VotingParams
Returns the current VotingParams from the global param store
func (Keeper) InactiveProposalQueueIterator ¶
Returns an iterator for all the proposals in the Inactive Queue that expire by endTime
func (Keeper) InsertActiveProposalQueue ¶
func (keeper Keeper) InsertActiveProposalQueue(ctx sdk.Context, endTime time.Time, proposalID uint64)
Inserts a ProposalID into the active proposal queue at endTime
func (Keeper) InsertInactiveProposalQueue ¶
func (keeper Keeper) InsertInactiveProposalQueue(ctx sdk.Context, endTime time.Time, proposalID uint64)
Inserts a ProposalID into the inactive proposal queue at endTime
func (Keeper) RefundDeposits ¶
Refunds and deletes all the deposits on a specific proposal
func (Keeper) RemoveFromActiveProposalQueue ¶
func (keeper Keeper) RemoveFromActiveProposalQueue(ctx sdk.Context, endTime time.Time, proposalID uint64)
removes a proposalID from the Active Proposal Queue
func (Keeper) RemoveFromInactiveProposalQueue ¶
func (keeper Keeper) RemoveFromInactiveProposalQueue(ctx sdk.Context, endTime time.Time, proposalID uint64)
removes a proposalID from the Inactive Proposal Queue
func (Keeper) SetProposal ¶
Implements sdk.AccountKeeper.
type MsgDeposit ¶
type MsgDeposit = types.MsgDeposit
type MsgSubmitProposal ¶
type MsgSubmitProposal = types.MsgSubmitProposal
type Params ¶
type Params struct { VotingParams VotingParams `json:"voting_params"` TallyParams TallyParams `json:"tally_params"` DepositParams DepositParams `json:"deposit_params"` }
Params returns all of the governance params
func NewParams ¶
func NewParams(vp VotingParams, tp TallyParams, dp DepositParams) Params
type ProposalQueue ¶
type ProposalQueue = types.ProposalQueue
type ProposalStatus ¶
type ProposalStatus = types.ProposalStatus
type QueryDepositParams ¶
type QueryDepositParams struct { ProposalID uint64 Depositor sdk.AccAddress }
Params for query 'custom/gov/deposit'
func NewQueryDepositParams ¶
func NewQueryDepositParams(proposalID uint64, depositor sdk.AccAddress) QueryDepositParams
creates a new instance of QueryDepositParams
type QueryProposalParams ¶
type QueryProposalParams struct {
ProposalID uint64
}
Params for queries: - 'custom/gov/proposal' - 'custom/gov/deposits' - 'custom/gov/tally' - 'custom/gov/votes'
func NewQueryProposalParams ¶
func NewQueryProposalParams(proposalID uint64) QueryProposalParams
creates a new instance of QueryProposalParams
type QueryProposalsParams ¶
type QueryProposalsParams struct { Voter sdk.AccAddress Depositor sdk.AccAddress ProposalStatus ProposalStatus Limit uint64 }
Params for query 'custom/gov/proposals'
func NewQueryProposalsParams ¶
func NewQueryProposalsParams(status ProposalStatus, limit uint64, voter, depositor sdk.AccAddress) QueryProposalsParams
creates a new instance of QueryProposalsParams
type QueryVoteParams ¶
type QueryVoteParams struct { ProposalID uint64 Voter sdk.AccAddress }
Params for query 'custom/gov/vote'
func NewQueryVoteParams ¶
func NewQueryVoteParams(proposalID uint64, voter sdk.AccAddress) QueryVoteParams
creates a new instance of QueryVoteParams
type Router ¶
type Router interface { AddRoute(r string, h Handler) (rtr Router) HasRoute(r string) bool GetRoute(path string) (h Handler) Seal() }
Router implements a governance Handler router.
TODO: Use generic router (ref #3976).
type SoftwareUpgradeProposal ¶
type SoftwareUpgradeProposal = types.SoftwareUpgradeProposal
type TallyParams ¶
type TallyParams struct { Quorum sdk.Dec `json:"quorum"` // Minimum percentage of total stake needed to vote for a result to be considered valid Threshold sdk.Dec `json:"threshold"` // Minimum proportion of Yes votes for proposal to pass. Initial value: 0.5 Veto sdk.Dec `json:"veto"` // Minimum value of Veto votes to Total votes ratio for proposal to be vetoed. Initial value: 1/3 }
Param around Tallying votes in governance
func NewTallyParams ¶
func NewTallyParams(quorum, threshold, veto sdk.Dec) TallyParams
NewTallyParams creates a new TallyParams object
func (TallyParams) String ¶
func (tp TallyParams) String() string
type TallyResult ¶
type TallyResult = types.TallyResult
type TextProposal ¶
type TextProposal = types.TextProposal
type VoteOption ¶
type VoteOption = types.VoteOption
type VoteWithMetadata ¶
VoteWithMetadata (just for genesis)
type VotingParams ¶
type VotingParams struct {
VotingPeriod time.Duration `json:"voting_period"` // Length of the voting period.
}
Param around Voting in governance
func NewVotingParams ¶
func NewVotingParams(votingPeriod time.Duration) VotingParams
NewVotingParams creates a new VotingParams object
func (VotingParams) String ¶
func (vp VotingParams) String() string