Documentation ¶
Index ¶
- Constants
- Variables
- func ActiveProposalByTimeKey(endTime time.Time) []byte
- func ActiveProposalQueueKey(proposalID uint64, endTime time.Time) []byte
- func ContentFromProposalType(title, desc, ty string) gov.Content
- func DefaultGovernors() []sdk.AccAddress
- func ExpeditedProposalQueueKey(proposalID uint64) []byte
- func GetGovernorCountBytes(count uint64) (countBz []byte)
- func GetGovernorCountFromBytes(bz []byte) (count uint64)
- func GetGovernorIteratorKey() []byte
- func GetGovernorKey(address sdk.AccAddress) []byte
- func GetProposalIDBytes(proposalID uint64) (proposalIDBz []byte)
- func GetProposalIDFromBytes(bz []byte) (proposalID uint64)
- func IsValidProposalType(ty string) bool
- func NewAddGovernorProposal(title string, description string, governor sdk.AccAddress) gov.Content
- func NewRemoveGovernorProposal(title string, description string, governor sdk.AccAddress) gov.Content
- func NewTextProposal(title, description string) gov.Content
- func ParamKeyTable() params.KeyTable
- func ProposalKey(proposalID uint64) []byte
- func RegisterCodec(cdc *codec.Codec)
- func RegisterProposalType(ty string)
- func RegisterProposalTypeCodec(o interface{}, name string)
- func SplitActiveProposalQueueKey(key []byte) (proposalID uint64, endTime time.Time)
- func SplitExpeditedProposalQueueKey(key []byte) (proposalID uint64)
- func SplitGovernorKey(key []byte) sdk.AccAddress
- func SplitKeyVote(key []byte) (proposalID uint64, voterAddr sdk.AccAddress)
- func SplitProposalKey(key []byte) (proposalID uint64)
- func ValidProposalStatus(status ProposalStatus) bool
- func ValidVoteOption(option VoteOption) bool
- func ValidateAbstract(c gov.Content) error
- func ValidateGenesis(data GenesisState) error
- func VoteKey(proposalID uint64, voterAddr sdk.AccAddress) []byte
- func VotesKey(proposalID uint64) []byte
- type AddGovernorProposal
- type GenesisState
- type MsgExpedite
- type MsgSubmitProposal
- type MsgVote
- type Params
- type Proposal
- type ProposalStatus
- func (status ProposalStatus) Format(s fmt.State, verb rune)
- func (status ProposalStatus) Marshal() ([]byte, error)
- func (status ProposalStatus) MarshalJSON() ([]byte, error)
- func (status ProposalStatus) String() string
- func (status *ProposalStatus) Unmarshal(data []byte) error
- func (status *ProposalStatus) UnmarshalJSON(data []byte) error
- type Proposals
- type RemoveGovernorProposal
- func (p RemoveGovernorProposal) GetDescription() string
- func (p RemoveGovernorProposal) GetTitle() string
- func (p RemoveGovernorProposal) ProposalRoute() string
- func (p RemoveGovernorProposal) ProposalType() string
- func (p RemoveGovernorProposal) String() string
- func (p RemoveGovernorProposal) ValidateBasic() error
- type TallyParams
- type TallyResult
- type TextProposal
- type Vote
- type VoteOption
- type Votes
- type VotingParams
Constants ¶
View Source
const ( MaxDescriptionLength int = 5000 MaxTitleLength int = 140 )
View Source
const ( EventTypeSubmitProposal = "submit_proposal" EventTypeVote = "vote" EventTypeExpedite = "expedite" EventTypeAddGovernor = "add_governor" EventTypeRemoveGovernor = "remove_governor" AttributeKeySender = "sender" AttributeKeyProposalId = "proposal_id" AttributeKeyStatus = "status" AttributeKeyOption = "option" AttributeKeyVotingStartTime = "voting_start_time" AttributeKeyVotingEndTime = "voting_end_time" AttributeKeyContent = "content" AttributeKeyGovernor = "governor" AttributeKeyTitle = "title" AttributeKeyDescription = "description" AttributeValueModule = ModuleName )
View Source
const ( ModuleName = "governance" StoreKey = ModuleName RouterKey = ModuleName QuerierRoute = ModuleName DefaultParamspace = ModuleName )
View Source
const ( TypeMsgVote = "vote" TypeMsgSubmitProposal = "submit_proposal" )
View Source
const ( ProposalTypeText string = "Text" ProposalTypeAddGovernor = "AddGovernor" ProposalTypeRemoveGovernor = "RemoveGovernor" )
View Source
const (
DefaultPeriod time.Duration = time.Hour * 24 * 3 // devnet: time.Second * 120
)
View Source
const DefaultStartingProposalID uint64 = 1
Variables ¶
View Source
var ( ErrUnknownProposal = sdkerrors.Register(ModuleName, 1, "unknown proposal") ErrUnknownVote = sdkerrors.Register(ModuleName, 9, "unknown vote") ErrInactiveProposal = sdkerrors.Register(ModuleName, 2, "inactive proposal") //ErrAlreadyActiveProposal = sdkerrors.Register(ModuleName, 3, "proposal already active") ErrInvalidProposalContent = sdkerrors.Register(ModuleName, 4, "invalid proposal content") ErrInvalidProposalType = sdkerrors.Register(ModuleName, 5, "invalid proposal type") ErrInvalidVote = sdkerrors.Register(ModuleName, 6, "invalid vote option") ErrInvalidGenesis = sdkerrors.Register(ModuleName, 7, "invalid genesis state") ErrNoProposalHandlerExists = sdkerrors.Register(ModuleName, 8, "no handler exists for proposal type") ErrNotGovernor = sdkerrors.Register(ModuleName, 10, "proposer/voter is not a governor") ErrAlreadyVoted = sdkerrors.Register(ModuleName, 11, "already voted") )
View Source
var ( ProposalsKeyPrefix = []byte{0x00} ActiveProposalQueuePrefix = []byte{0x01} ExpeditedProposalQueuePrefix = []byte{0x04} ProposalIDKey = []byte{0x02} GovernorCountKey = []byte{0x03} VotesKeyPrefix = []byte{0x10} GovernorKeyPrefix = []byte{0x21} StatusPresent = []byte{0x01} )
- 0x00<proposalID_Bytes>: Proposal - 0x01<endTime_Bytes><proposalID_Bytes>: activeProposalID - 0x02<endTime_Bytes><proposalID_Bytes>: inactiveProposalID - 0x03: nextProposalID - 0x10<proposalID_Bytes><depositorAddr_Bytes>: Deposit - 0x20<proposalID_Bytes><voterAddr_Bytes>: Voter
View Source
var ( DefaultQuorum = sdk.NewDecWithPrec(334, 3) DefaultThreshold = sdk.NewDecWithPrec(5, 1) )
View Source
var ( ParamStoreKeyVotingParams = []byte("votingparams") ParamStoreKeyTallyParams = []byte("tallyparams") )
View Source
var (
DefaultGovernorList = []string{
"anatha170mj6j6veall698u5xwkdhpf2nlza9j6n366v2",
"anatha1e4ay99w2v3qqnl8wrmv3s85mexm6eum2vhucmf",
"anatha1p470fhtytsym8fpp5j6rak2ec2qrvmwdvpg3ve",
}
)
View Source
var ModuleCdc = codec.New()
Functions ¶
func ActiveProposalByTimeKey ¶
func ActiveProposalQueueKey ¶
func ContentFromProposalType ¶
func DefaultGovernors ¶
func DefaultGovernors() []sdk.AccAddress
func GetGovernorCountBytes ¶
func GetGovernorIteratorKey ¶
func GetGovernorIteratorKey() []byte
func GetGovernorKey ¶
func GetGovernorKey(address sdk.AccAddress) []byte
func GetProposalIDBytes ¶
func GetProposalIDFromBytes ¶
func IsValidProposalType ¶
func NewAddGovernorProposal ¶
func NewTextProposal ¶
func ParamKeyTable ¶
func ProposalKey ¶
func RegisterCodec ¶
func RegisterProposalType ¶
func RegisterProposalType(ty string)
func RegisterProposalTypeCodec ¶
func RegisterProposalTypeCodec(o interface{}, name string)
func SplitGovernorKey ¶
func SplitGovernorKey(key []byte) sdk.AccAddress
func SplitKeyVote ¶
func SplitKeyVote(key []byte) (proposalID uint64, voterAddr sdk.AccAddress)
func SplitProposalKey ¶
func ValidProposalStatus ¶
func ValidProposalStatus(status ProposalStatus) bool
func ValidVoteOption ¶
func ValidVoteOption(option VoteOption) bool
func ValidateAbstract ¶
func ValidateGenesis ¶
func ValidateGenesis(data GenesisState) error
Types ¶
type AddGovernorProposal ¶
type AddGovernorProposal struct { Title string `json:"title" yaml:"title"` Description string `json:"description" yaml:"description"` Governor sdk.AccAddress `json:"governor" yaml:"governor"` }
func (AddGovernorProposal) GetDescription ¶
func (p AddGovernorProposal) GetDescription() string
func (AddGovernorProposal) GetTitle ¶
func (p AddGovernorProposal) GetTitle() string
func (AddGovernorProposal) ProposalRoute ¶
func (p AddGovernorProposal) ProposalRoute() string
func (AddGovernorProposal) ProposalType ¶
func (p AddGovernorProposal) ProposalType() string
func (AddGovernorProposal) String ¶
func (p AddGovernorProposal) String() string
func (AddGovernorProposal) ValidateBasic ¶
func (p AddGovernorProposal) ValidateBasic() error
type GenesisState ¶
type GenesisState struct { StartingProposalID uint64 `json:"starting_proposal_id" yaml:"starting_proposal_id"` Votes Votes `json:"votes" yaml:"votes"` Proposals Proposals `json:"proposals" yaml:"proposals"` VotingParams VotingParams `json:"voting_params" yaml:"voting_params"` TallyParams TallyParams `json:"tally_params" yaml:"tally_params"` Governors []sdk.AccAddress `json:"governors" yaml:"governors"` }
func DefaultGenesisState ¶
func DefaultGenesisState() GenesisState
func NewGenesisState ¶
func NewGenesisState(startingProposalID uint64, vp VotingParams, tp TallyParams, governors []sdk.AccAddress) GenesisState
func (GenesisState) Equal ¶
func (data GenesisState) Equal(data2 GenesisState) bool
func (GenesisState) IsEmpty ¶
func (data GenesisState) IsEmpty() bool
type MsgExpedite ¶
type MsgExpedite struct { ProposalID uint64 `json:"proposal_id" yaml:"proposal_id"` Sender sdk.AccAddress `json:"sender" yaml:"sender"` }
MsgExpedite
func NewMsgExpedite ¶
func NewMsgExpedite(sender sdk.AccAddress, proposalID uint64) MsgExpedite
func (MsgExpedite) GetSignBytes ¶
func (msg MsgExpedite) GetSignBytes() []byte
func (MsgExpedite) GetSigners ¶
func (msg MsgExpedite) GetSigners() []sdk.AccAddress
func (MsgExpedite) Route ¶
func (msg MsgExpedite) Route() string
func (MsgExpedite) String ¶
func (msg MsgExpedite) String() string
func (MsgExpedite) Type ¶
func (msg MsgExpedite) Type() string
func (MsgExpedite) ValidateBasic ¶
func (msg MsgExpedite) ValidateBasic() error
type MsgSubmitProposal ¶
type MsgSubmitProposal struct { Content gov.Content `json:"content" yaml:"content"` Proposer sdk.AccAddress `json:"proposer" yaml:"proposer"` }
func NewMsgSubmitProposal ¶
func NewMsgSubmitProposal(content gov.Content, proposer sdk.AccAddress) MsgSubmitProposal
func (MsgSubmitProposal) GetSignBytes ¶
func (msg MsgSubmitProposal) GetSignBytes() []byte
func (MsgSubmitProposal) GetSigners ¶
func (msg MsgSubmitProposal) GetSigners() []sdk.AccAddress
func (MsgSubmitProposal) Route ¶
func (msg MsgSubmitProposal) Route() string
func (MsgSubmitProposal) String ¶
func (msg MsgSubmitProposal) String() string
func (MsgSubmitProposal) Type ¶
func (msg MsgSubmitProposal) Type() string
func (MsgSubmitProposal) ValidateBasic ¶
func (msg MsgSubmitProposal) ValidateBasic() error
type MsgVote ¶
type MsgVote struct { ProposalID uint64 `json:"proposal_id" yaml:"proposal_id"` Voter sdk.AccAddress `json:"voter" yaml:"voter"` Option VoteOption `json:"option" yaml:"option"` }
MsgVote
func NewMsgVote ¶
func NewMsgVote(voter sdk.AccAddress, proposalID uint64, option VoteOption) MsgVote
func (MsgVote) GetSignBytes ¶
func (MsgVote) GetSigners ¶
func (msg MsgVote) GetSigners() []sdk.AccAddress
func (MsgVote) ValidateBasic ¶
ValidateBasic implements Msg
type Params ¶
type Params struct { VotingParams VotingParams `json:"voting_params" yaml:"voting_params"` TallyParams TallyParams `json:"tally_params" yaml:"tally_params"` }
func DefaultParams ¶
func DefaultParams() Params
func NewParams ¶
func NewParams(vp VotingParams, tp TallyParams) Params
type Proposal ¶
type Proposal struct { gov.Content `json:"content" yaml:"content"` // Proposal content interface ProposalID uint64 `json:"id" yaml:"id"` Status ProposalStatus `json:"proposal_status" yaml:"proposal_status"` TallyResult TallyResult `json:"tally_result" yaml:"tally_result"` VotingStartTime time.Time `json:"voting_start_time" yaml:"voting_start_time"` VotingEndTime time.Time `json:"voting_end_time" yaml:"voting_end_time"` ExecutionTime time.Time `json:"proposal_execution_time" yaml:"proposal_execution_time"` Expedited bool `json:"expedited" yaml:"expedited"` }
type ProposalStatus ¶
type ProposalStatus byte
const ( StatusNil ProposalStatus = 0x00 StatusVotingPeriod ProposalStatus = 0x01 StatusExpediting ProposalStatus = 0x05 StatusPassed ProposalStatus = 0x02 StatusRejected ProposalStatus = 0x03 StatusFailed ProposalStatus = 0x04 )
func ProposalStatusFromString ¶
func ProposalStatusFromString(str string) (ProposalStatus, error)
func (ProposalStatus) Marshal ¶
func (status ProposalStatus) Marshal() ([]byte, error)
func (ProposalStatus) MarshalJSON ¶
func (status ProposalStatus) MarshalJSON() ([]byte, error)
func (ProposalStatus) String ¶
func (status ProposalStatus) String() string
func (*ProposalStatus) Unmarshal ¶
func (status *ProposalStatus) Unmarshal(data []byte) error
func (*ProposalStatus) UnmarshalJSON ¶
func (status *ProposalStatus) UnmarshalJSON(data []byte) error
type RemoveGovernorProposal ¶
type RemoveGovernorProposal struct { Title string `json:"title" yaml:"title"` Description string `json:"description" yaml:"description"` Governor sdk.AccAddress `json:"governor" yaml:"governor"` }
func (RemoveGovernorProposal) GetDescription ¶
func (p RemoveGovernorProposal) GetDescription() string
func (RemoveGovernorProposal) GetTitle ¶
func (p RemoveGovernorProposal) GetTitle() string
func (RemoveGovernorProposal) ProposalRoute ¶
func (p RemoveGovernorProposal) ProposalRoute() string
func (RemoveGovernorProposal) ProposalType ¶
func (p RemoveGovernorProposal) ProposalType() string
func (RemoveGovernorProposal) String ¶
func (p RemoveGovernorProposal) String() string
func (RemoveGovernorProposal) ValidateBasic ¶
func (p RemoveGovernorProposal) ValidateBasic() error
type TallyParams ¶
type TallyParams struct { Quorum sdk.Dec `json:"quorum" yaml:"quorum"` Threshold sdk.Dec `json:"threshold" yaml:"threshold"` }
func DefaultTallyParams ¶
func DefaultTallyParams() TallyParams
func NewTallyParams ¶
func NewTallyParams(quorum sdk.Dec, threshold sdk.Dec) TallyParams
func (TallyParams) String ¶
func (tp TallyParams) String() string
type TallyResult ¶
func EmptyTallyResult ¶
func EmptyTallyResult() TallyResult
func NewTallyResult ¶
func NewTallyResult(yes, no sdk.Int) TallyResult
func NewTallyResultFromMap ¶
func NewTallyResultFromMap(results map[VoteOption]sdk.Dec) TallyResult
func (TallyResult) Equals ¶
func (tr TallyResult) Equals(comp TallyResult) bool
func (TallyResult) String ¶
func (tr TallyResult) String() string
type TextProposal ¶
type TextProposal struct { Title string `json:"title" yaml:"title"` Description string `json:"description" yaml:"description"` }
func (TextProposal) GetDescription ¶
func (tp TextProposal) GetDescription() string
func (TextProposal) GetTitle ¶
func (tp TextProposal) GetTitle() string
func (TextProposal) ProposalRoute ¶
func (tp TextProposal) ProposalRoute() string
func (TextProposal) ProposalType ¶
func (tp TextProposal) ProposalType() string
func (TextProposal) String ¶
func (tp TextProposal) String() string
func (TextProposal) ValidateBasic ¶
func (tp TextProposal) ValidateBasic() error
type Vote ¶
type Vote struct { ProposalID uint64 `json:"proposal_id" yaml:"proposal_id"` Voter sdk.AccAddress `json:"voter" yaml:"voter"` Option VoteOption `json:"option" yaml:"option"` }
func NewVote ¶
func NewVote(proposalID uint64, voter sdk.AccAddress, option VoteOption) Vote
type VoteOption ¶
type VoteOption byte
const ( OptionEmpty VoteOption = 0x00 OptionYes VoteOption = 0x01 OptionNo VoteOption = 0x02 )
func VoteOptionFromString ¶
func VoteOptionFromString(str string) (VoteOption, error)
func (VoteOption) Marshal ¶
func (vo VoteOption) Marshal() ([]byte, error)
func (VoteOption) MarshalJSON ¶
func (vo VoteOption) MarshalJSON() ([]byte, error)
func (VoteOption) String ¶
func (vo VoteOption) String() string
func (*VoteOption) Unmarshal ¶
func (vo *VoteOption) Unmarshal(data []byte) error
func (*VoteOption) UnmarshalJSON ¶
func (vo *VoteOption) UnmarshalJSON(data []byte) error
type VotingParams ¶
func DefaultVotingParams ¶
func DefaultVotingParams() VotingParams
func NewVotingParams ¶
func NewVotingParams(votingPeriod time.Duration) VotingParams
func (VotingParams) String ¶
func (vp VotingParams) String() string
Click to show internal directories.
Click to hide internal directories.