gov

package
v0.0.0-...-8790121 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2019 License: Apache-2.0 Imports: 22 Imported by: 0

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

View Source
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
)
View Source
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

View Source
const (
	// Default period for deposits & voting
	DefaultPeriod time.Duration = 86400 * 2 * time.Second // 2 days
)

Variables

View Source
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
)
View Source
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

func EndBlocker(ctx sdk.Context, keeper Keeper) sdk.Tags

Called every block, process inflation, update validator set

func InitGenesis

func InitGenesis(ctx sdk.Context, k Keeper, data GenesisState)

InitGenesis - store genesis parameters

func NewHandler

func NewHandler(keeper Keeper) sdk.Handler

Handle all "gov" type messages.

func NewQuerier

func NewQuerier(keeper Keeper) sdk.Querier

func ParamKeyTable

func ParamKeyTable() params.KeyTable

Key declaration for parameters

func ProposalEqual

func ProposalEqual(proposalA Proposal, proposalB Proposal) bool

checks if two proposals are equal (note: slow, for tests only)

func SortAddresses

func SortAddresses(addrs []sdk.AccAddress)

Sorts Addresses

func SortByteArrays

func SortByteArrays(src [][]byte) [][]byte

Public

func ValidateGenesis

func ValidateGenesis(data GenesisState) error

ValidateGenesis

Types

type AppModule

type AppModule struct {
	AppModuleBasic
	// contains filtered or unexported fields
}

___________________________ app module

func NewAppModule

func NewAppModule(keeper Keeper) AppModule

NewAppModule creates a new AppModule object

func (AppModule) BeginBlock

func (AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) sdk.Tags

module begin-block

func (AppModule) EndBlock

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) Name

func (AppModule) Name() string

module name

func (AppModule) NewHandler

func (am AppModule) NewHandler() sdk.Handler

module handler

func (AppModule) NewQuerierHandler

func (am AppModule) NewQuerierHandler() sdk.Querier

module querier

func (AppModule) QuerierRoute

func (AppModule) QuerierRoute() string

module querier route name

func (AppModule) RegisterInvariants

func (AppModule) RegisterInvariants(_ sdk.InvariantRouter)

register invariants

func (AppModule) Route

func (AppModule) Route() string

module message route name

type AppModuleBasic

type AppModuleBasic struct{}

app module basics object

func (AppModuleBasic) DefaultGenesis

func (AppModuleBasic) DefaultGenesis() json.RawMessage

default genesis state

func (AppModuleBasic) Name

func (AppModuleBasic) Name() string

module name

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 Content

type Content = types.Content

type Deposit

type Deposit = types.Deposit

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 Deposits

type Deposits = types.Deposits

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 Handler

type Handler = types.Handler

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

func (keeper Keeper) ActiveProposalQueueIterator(ctx sdk.Context, endTime time.Time) sdk.Iterator

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

func (keeper Keeper) DeleteDeposits(ctx sdk.Context, proposalID uint64)

Deletes all the deposits on a specific proposal without refunding them

func (Keeper) DeleteProposal

func (keeper Keeper) DeleteProposal(ctx sdk.Context, proposalID uint64)

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

func (keeper Keeper) GetDeposits(ctx sdk.Context, proposalID uint64) sdk.Iterator

Gets all the deposits on a specific proposal as an sdk.Iterator

func (Keeper) GetLastProposalID

func (keeper Keeper) GetLastProposalID(ctx sdk.Context) (proposalID uint64)

Get the last used proposal ID

func (Keeper) GetProposal

func (keeper Keeper) GetProposal(ctx sdk.Context, proposalID uint64) (proposal Proposal, ok bool)

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) GetVotes

func (keeper Keeper) GetVotes(ctx sdk.Context, proposalID uint64) sdk.Iterator

Gets all the votes 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

func (keeper Keeper) InactiveProposalQueueIterator(ctx sdk.Context, endTime time.Time) sdk.Iterator

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) Logger

func (keeper Keeper) Logger(ctx sdk.Context) log.Logger

Logger returns a module-specific logger.

func (Keeper) RefundDeposits

func (keeper Keeper) RefundDeposits(ctx sdk.Context, proposalID uint64)

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

func (keeper Keeper) SetProposal(ctx sdk.Context, proposal Proposal)

Implements sdk.AccountKeeper.

func (Keeper) SubmitProposal

func (keeper Keeper) SubmitProposal(ctx sdk.Context, content Content) (Proposal, sdk.Error)

Proposals

type MsgDeposit

type MsgDeposit = types.MsgDeposit

type MsgSubmitProposal

type MsgSubmitProposal = types.MsgSubmitProposal

type MsgVote

type MsgVote = types.MsgVote

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

func (Params) String

func (gp Params) String() string

type Proposal

type Proposal = types.Proposal

type ProposalQueue

type ProposalQueue = types.ProposalQueue

type ProposalStatus

type ProposalStatus = types.ProposalStatus

type Proposals

type Proposals = types.Proposals

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).

func NewRouter

func NewRouter() Router

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 Vote

type Vote = types.Vote

type VoteOption

type VoteOption = types.VoteOption

type VoteWithMetadata

type VoteWithMetadata struct {
	ProposalID uint64 `json:"proposal_id"`
	Vote       Vote   `json:"vote"`
}

VoteWithMetadata (just for genesis)

type Votes

type Votes = types.Votes

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

Directories

Path Synopsis
cli
nolint
nolint

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL