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 IsValidProposalType(ty string) bool
- func ParamKeyTable() params.KeyTable
- func ProposalHandler(_ sdk.Context, c Content) error
- 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 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 ValidProposalStatus(status ProposalStatus) bool
- func ValidVoteOption(option VoteOption) bool
- func ValidateAbstract(c Content) error
- func ValidateGenesis(data GenesisState) error
- func VoteKey(proposalID uint64, voterAddr sdk.AccAddress) []byte
- func VotesKey(proposalID uint64) []byte
- type AccountKeeper
- type Content
- type Deposit
- type DepositParams
- type Deposits
- type GenesisState
- type Handler
- type MsgDeposit
- type MsgSubmitProposal
- type MsgVote
- type ParamSubspace
- type Params
- type Proposal
- type ProposalQueue
- 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 QueryDepositParams
- type QueryProposalParams
- type QueryProposalVotesParams
- type QueryProposalsParams
- type QueryVoteParams
- type Router
- type StakingKeeper
- type SupplyKeeper
- type TallyParams
- type TallyResult
- type TextProposal
- type ValidatorGovInfo
- type Vote
- type VoteOption
- type Votes
- type VotingParams
Constants ¶
const ( MaxDescriptionLength int = 5000 MaxTitleLength int = 140 )
Constants pertaining to a Content object
const ( EventTypeSubmitProposal = "submit_proposal" EventTypeProposalDeposit = "proposal_deposit" EventTypeProposalVote = "proposal_vote" EventTypeInactiveProposal = "inactive_proposal" EventTypeActiveProposal = "active_proposal" AttributeKeyProposalResult = "proposal_result" AttributeKeyOption = "option" AttributeKeyProposalID = "proposal_id" 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" )
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 // DefaultParamspace default name for parameter store DefaultParamspace = ModuleName )
const ( TypeMsgDeposit = "deposit" TypeMsgVote = "vote" TypeMsgSubmitProposal = "submit_proposal" )
Governance message types and routes
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 (
DefaultPeriod time.Duration = time.Hour * 24 * 2 // 2 days
)
Default period for deposits & voting
const DefaultStartingProposalID uint64 = 1
DefaultStartingProposalID is 1
const (
ProposalTypeText string = "Text"
)
Proposal types
Variables ¶
var ( ErrUnknownProposal = sdkerrors.Register(ModuleName, 1, "unknown proposal") 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") )
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><depositorAddr_Bytes>: Deposit
- 0x20<proposalID_Bytes><voterAddr_Bytes>: Voter
var ( DefaultMinDepositTokens = sdk.TokensFromConsensusPower(10) DefaultQuorum = sdk.NewDecWithPrec(334, 3) DefaultThreshold = sdk.NewDecWithPrec(5, 1) DefaultVeto = sdk.NewDecWithPrec(334, 3) )
Default governance params
var ( ParamStoreKeyDepositParams = []byte("depositparams") ParamStoreKeyVotingParams = []byte("votingparams") ParamStoreKeyTallyParams = []byte("tallyparams") )
Parameter store key
var ModuleCdc = codec.New()
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 IsValidProposalType ¶
IsValidProposalType returns a boolean determining if the proposal type is valid.
NOTE: Modules with their own proposal types must register them.
func ParamKeyTable ¶
ParamKeyTable - Key declaration for parameters
func ProposalHandler ¶
ProposalHandler implements the Handler interface for governance module-based proposals (ie. TextProposal ). Since these are merely signaling mechanisms at the moment and do not affect state, it performs a no-op.
func ProposalKey ¶
ProposalKey gets a specific proposal from the store
func RegisterCodec ¶
RegisterCodec registers all the necessary types and interfaces for governance.
func RegisterProposalType ¶
func RegisterProposalType(ty string)
RegisterProposalType registers a proposal type. It will panic if the type is already registered.
func RegisterProposalTypeCodec ¶
func RegisterProposalTypeCodec(o interface{}, name string)
RegisterProposalTypeCodec registers an external proposal content type defined in another module for the internal ModuleCdc. This allows the MsgSubmitProposal to be correctly Amino encoded and decoded.
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
func ValidProposalStatus ¶
func ValidProposalStatus(status ProposalStatus) bool
ValidProposalStatus returns true if the proposal status is valid and false otherwise.
func ValidVoteOption ¶
func ValidVoteOption(option VoteOption) bool
ValidVoteOption returns true if the vote option is valid and false otherwise.
func ValidateAbstract ¶
ValidateAbstract validates a proposal's abstract contents returning an error if invalid.
func ValidateGenesis ¶
func ValidateGenesis(data GenesisState) error
ValidateGenesis checks if parameters are within valid ranges
Types ¶
type AccountKeeper ¶
type AccountKeeper interface {
GetAccount(ctx sdk.Context, addr sdk.AccAddress) authexported.Account
}
AccountKeeper defines the expected account keeper (noalias)
type Content ¶
type Content interface { GetTitle() string GetDescription() string ProposalRoute() string ProposalType() string ValidateBasic() error String() string }
Content defines an interface that a proposal must implement. It contains information such as the title and description along with the type and routing information for the appropriate handler to process the proposal. Content can have additional fields, which will handled by a proposal's Handler.
func ContentFromProposalType ¶
ContentFromProposalType returns a Content object based on the proposal type.
func NewTextProposal ¶
NewTextProposal creates a text proposal Content
type Deposit ¶
type Deposit struct { ProposalID uint64 `json:"proposal_id" yaml:"proposal_id"` // proposalID of the proposal Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"` // Address of the depositor Amount sdk.Coins `json:"amount" yaml:"amount"` // Deposit amount }
Deposit defines an amount deposited by an account address to an active proposal
func NewDeposit ¶
NewDeposit creates a new Deposit instance
type DepositParams ¶
type DepositParams struct { MinDeposit sdk.Coins `json:"min_deposit,omitempty" yaml:"min_deposit,omitempty"` // Minimum deposit for a proposal to enter voting period. MaxDepositPeriod time.Duration `json:"max_deposit_period,omitempty" yaml:"max_deposit_period,omitempty"` // Maximum period for Atom holders to deposit on a proposal. Initial value: 2 months }
DepositParams defines the params around deposits for governance
func DefaultDepositParams ¶
func DefaultDepositParams() DepositParams
DefaultDepositParams default parameters for deposits
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
Equal checks equality of DepositParams
func (DepositParams) String ¶
func (dp DepositParams) String() string
String implements stringer insterface
type GenesisState ¶
type GenesisState struct { StartingProposalID uint64 `json:"starting_proposal_id" yaml:"starting_proposal_id"` Deposits Deposits `json:"deposits" yaml:"deposits"` Votes Votes `json:"votes" yaml:"votes"` Proposals Proposals `json:"proposals" yaml:"proposals"` DepositParams DepositParams `json:"deposit_params" yaml:"deposit_params"` VotingParams VotingParams `json:"voting_params" yaml:"voting_params"` TallyParams TallyParams `json:"tally_params" yaml:"tally_params"` }
GenesisState - all staking state that must be provided at genesis
func DefaultGenesisState ¶
func DefaultGenesisState() GenesisState
DefaultGenesisState defines the default governance genesis state
func NewGenesisState ¶
func NewGenesisState(startingProposalID uint64, dp DepositParams, vp VotingParams, tp TallyParams) GenesisState
NewGenesisState creates a new genesis state for the governance module
func (GenesisState) Equal ¶
func (data GenesisState) Equal(data2 GenesisState) bool
Equal checks whether two gov GenesisState structs are equivalent
func (GenesisState) IsEmpty ¶
func (data GenesisState) IsEmpty() bool
IsEmpty returns true if a GenesisState is empty
type Handler ¶
Handler defines a function that handles a proposal after it has passed the governance process.
type MsgDeposit ¶
type MsgDeposit struct { ProposalID uint64 `json:"proposal_id" yaml:"proposal_id"` // ID of the proposal Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"` // Address of the depositor Amount sdk.Coins `json:"amount" yaml:"amount"` // Coins to add to the proposal's deposit }
MsgDeposit defines a message to submit a deposit to an existing proposal
func NewMsgDeposit ¶
func NewMsgDeposit(depositor sdk.AccAddress, proposalID uint64, amount sdk.Coins) MsgDeposit
NewMsgDeposit creates a new MsgDeposit instance
func (MsgDeposit) GetSignBytes ¶
func (msg MsgDeposit) GetSignBytes() []byte
GetSignBytes implements Msg
func (MsgDeposit) GetSigners ¶
func (msg MsgDeposit) GetSigners() []sdk.AccAddress
GetSigners implements Msg
func (MsgDeposit) String ¶
func (msg MsgDeposit) String() string
String implements the Stringer interface
func (MsgDeposit) ValidateBasic ¶
func (msg MsgDeposit) ValidateBasic() error
ValidateBasic implements Msg
type MsgSubmitProposal ¶
type MsgSubmitProposal struct { Content Content `json:"content" yaml:"content"` InitialDeposit sdk.Coins `json:"initial_deposit" yaml:"initial_deposit"` // Initial deposit paid by sender. Must be strictly positive Proposer sdk.AccAddress `json:"proposer" yaml:"proposer"` // Address of the proposer }
MsgSubmitProposal defines a message to create a governance proposal with a given content and initial deposit
func NewMsgSubmitProposal ¶
func NewMsgSubmitProposal(content Content, initialDeposit sdk.Coins, proposer sdk.AccAddress) MsgSubmitProposal
NewMsgSubmitProposal creates a new MsgSubmitProposal instance
func (MsgSubmitProposal) GetSignBytes ¶
func (msg MsgSubmitProposal) GetSignBytes() []byte
GetSignBytes implements Msg
func (MsgSubmitProposal) GetSigners ¶
func (msg MsgSubmitProposal) GetSigners() []sdk.AccAddress
GetSigners implements Msg
func (MsgSubmitProposal) String ¶
func (msg MsgSubmitProposal) String() string
String implements the Stringer interface
func (MsgSubmitProposal) ValidateBasic ¶
func (msg MsgSubmitProposal) ValidateBasic() error
ValidateBasic implements Msg
type MsgVote ¶
type MsgVote struct { ProposalID uint64 `json:"proposal_id" yaml:"proposal_id"` // ID of the proposal Voter sdk.AccAddress `json:"voter" yaml:"voter"` // address of the voter Option VoteOption `json:"option" yaml:"option"` // option from OptionSet chosen by the voter }
MsgVote defines a message to cast a vote
func NewMsgVote ¶
func NewMsgVote(voter sdk.AccAddress, proposalID uint64, option VoteOption) MsgVote
NewMsgVote creates a message to cast a vote on an active proposal
func (MsgVote) GetSigners ¶
func (msg MsgVote) GetSigners() []sdk.AccAddress
GetSigners implements Msg
func (MsgVote) ValidateBasic ¶
ValidateBasic implements Msg
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 Params ¶
type Params struct { VotingParams VotingParams `json:"voting_params" yaml:"voting_params"` TallyParams TallyParams `json:"tally_params" yaml:"tally_params"` DepositParams DepositParams `json:"deposit_params" yaml:"deposit_parmas"` }
Params returns all of the governance params
func NewParams ¶
func NewParams(vp VotingParams, tp TallyParams, dp DepositParams) Params
NewParams creates a new gov Params instance
type Proposal ¶
type Proposal struct { Content `json:"content" yaml:"content"` // Proposal content interface ProposalID uint64 `json:"id" yaml:"id"` // ID of the proposal Status ProposalStatus `json:"proposal_status" yaml:"proposal_status"` // Status of the Proposal {Pending, Active, Passed, Rejected} FinalTallyResult TallyResult `json:"final_tally_result" yaml:"final_tally_result"` // Result of Tallys SubmitTime time.Time `json:"submit_time" yaml:"submit_time"` // Time of the block where TxGovSubmitProposal was included DepositEndTime time.Time `json:"deposit_end_time" yaml:"deposit_end_time"` // Time that the Proposal would expire if deposit amount isn't met TotalDeposit sdk.Coins `json:"total_deposit" yaml:"total_deposit"` // Current deposit on this proposal. Initial value is set at InitialDeposit VotingStartTime time.Time `json:"voting_start_time" yaml:"voting_start_time"` // Time of the block where MinDeposit was reached. -1 if MinDeposit is not reached VotingEndTime time.Time `json:"voting_end_time" yaml:"voting_end_time"` // Time that the VotingPeriod for this proposal will end and votes will be tallied }
Proposal defines a struct used by the governance module to allow for voting on network changes.
func NewProposal ¶
NewProposal creates a new Proposal instance
type ProposalStatus ¶
type ProposalStatus byte
ProposalStatus is a type alias that represents a proposal status as a byte
const ( StatusNil ProposalStatus = 0x00 StatusDepositPeriod ProposalStatus = 0x01 StatusVotingPeriod ProposalStatus = 0x02 StatusPassed ProposalStatus = 0x03 StatusRejected ProposalStatus = 0x04 StatusFailed ProposalStatus = 0x05 )
Valid Proposal statuses
func ProposalStatusFromString ¶
func ProposalStatusFromString(str string) (ProposalStatus, error)
ProposalStatusFromString turns a string into a ProposalStatus
func (ProposalStatus) Format ¶
func (status ProposalStatus) Format(s fmt.State, verb rune)
Format implements the fmt.Formatter interface. nolint: errcheck
func (ProposalStatus) Marshal ¶
func (status ProposalStatus) Marshal() ([]byte, error)
Marshal needed for protobuf compatibility
func (ProposalStatus) MarshalJSON ¶
func (status ProposalStatus) MarshalJSON() ([]byte, error)
MarshalJSON Marshals to JSON using string representation of the status
func (ProposalStatus) String ¶
func (status ProposalStatus) String() string
String implements the Stringer interface.
func (*ProposalStatus) Unmarshal ¶
func (status *ProposalStatus) Unmarshal(data []byte) error
Unmarshal needed for protobuf compatibility
func (*ProposalStatus) UnmarshalJSON ¶
func (status *ProposalStatus) UnmarshalJSON(data []byte) error
UnmarshalJSON Unmarshals from JSON assuming Bech32 encoding
type QueryDepositParams ¶
type QueryDepositParams struct { ProposalID uint64 Depositor sdk.AccAddress }
QueryDepositParams params for query 'custom/gov/deposit'
func NewQueryDepositParams ¶
func NewQueryDepositParams(proposalID uint64, depositor sdk.AccAddress) QueryDepositParams
NewQueryDepositParams creates a new instance of QueryDepositParams
type QueryProposalParams ¶
type QueryProposalParams struct {
ProposalID uint64
}
QueryProposalParams Params for queries: - 'custom/gov/proposal' - 'custom/gov/deposits' - 'custom/gov/tally'
func NewQueryProposalParams ¶
func NewQueryProposalParams(proposalID uint64) QueryProposalParams
NewQueryProposalParams creates a new instance of QueryProposalParams
type QueryProposalVotesParams ¶
QueryProposalVotesParams used for queries to 'custom/gov/votes'.
func NewQueryProposalVotesParams ¶
func NewQueryProposalVotesParams(proposalID uint64, page, limit int) QueryProposalVotesParams
NewQueryProposalVotesParams creates new instance of the QueryProposalVotesParams.
type QueryProposalsParams ¶
type QueryProposalsParams struct { Page int Limit int Voter sdk.AccAddress Depositor sdk.AccAddress ProposalStatus ProposalStatus }
QueryProposalsParams Params for query 'custom/gov/proposals'
func NewQueryProposalsParams ¶
func NewQueryProposalsParams(page, limit int, status ProposalStatus, voter, depositor sdk.AccAddress) QueryProposalsParams
NewQueryProposalsParams creates a new instance of QueryProposalsParams
type QueryVoteParams ¶
type QueryVoteParams struct { ProposalID uint64 Voter sdk.AccAddress }
QueryVoteParams Params for query 'custom/gov/vote'
func NewQueryVoteParams ¶
func NewQueryVoteParams(proposalID uint64, voter sdk.AccAddress) QueryVoteParams
NewQueryVoteParams 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 StakingKeeper ¶
type StakingKeeper interface { // iterate through bonded validators by operator address, execute func for each validator IterateBondedValidatorsByPower( sdk.Context, func(index int64, validator stakingexported.ValidatorI) (stop bool), ) TotalBondedTokens(sdk.Context) sdk.Dec // total bonded tokens within the validator set IterateDelegations( ctx sdk.Context, delegator sdk.AccAddress, fn func(index int64, delegation stakingexported.DelegationI) (stop bool), ) }
StakingKeeper expected staking keeper (Validator and Delegator sets) (noalias)
type SupplyKeeper ¶
type SupplyKeeper interface { GetModuleAddress(name string) sdk.AccAddress GetModuleAccount(ctx sdk.Context, name string) supplyexported.ModuleAccountI // TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862 SetModuleAccount(sdk.Context, supplyexported.ModuleAccountI) 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 }
SupplyKeeper defines the expected supply keeper for module accounts (noalias)
type TallyParams ¶
type TallyParams struct { Quorum sdk.Dec `json:"quorum,omitempty" yaml:"quorum,omitempty"` // Minimum percentage of total stake needed to vote for a result to be considered valid Threshold sdk.Dec `json:"threshold,omitempty" yaml:"threshold,omitempty"` // Minimum proportion of Yes votes for proposal to pass. Initial value: 0.5 Veto sdk.Dec `json:"veto,omitempty" yaml:"veto,omitempty"` // Minimum value of Veto votes to Total votes ratio for proposal to be vetoed. Initial value: 1/3 }
TallyParams defines the params around Tallying votes in governance
func DefaultTallyParams ¶
func DefaultTallyParams() TallyParams
DefaultTallyParams default parameters for tallying
func NewTallyParams ¶
func NewTallyParams(quorum, threshold, veto sdk.Dec) TallyParams
NewTallyParams creates a new TallyParams object
func (TallyParams) String ¶
func (tp TallyParams) String() string
String implements stringer insterface
type TallyResult ¶
type TallyResult struct { Yes sdk.Int `json:"yes" yaml:"yes"` Abstain sdk.Int `json:"abstain" yaml:"abstain"` No sdk.Int `json:"no" yaml:"no"` NoWithVeto sdk.Int `json:"no_with_veto" yaml:"no_with_veto"` }
TallyResult defines a standard tally for a proposal
func EmptyTallyResult ¶
func EmptyTallyResult() TallyResult
EmptyTallyResult returns an empty TallyResult.
func NewTallyResult ¶
func NewTallyResult(yes, abstain, no, noWithVeto sdk.Int) TallyResult
NewTallyResult creates a new TallyResult instance
func NewTallyResultFromMap ¶
func NewTallyResultFromMap(results map[VoteOption]sdk.Dec) TallyResult
NewTallyResultFromMap creates a new TallyResult instance from a Option -> Dec map
func (TallyResult) Equals ¶
func (tr TallyResult) Equals(comp TallyResult) bool
Equals returns if two proposals are equal.
func (TallyResult) String ¶
func (tr TallyResult) String() string
String implements stringer interface
type TextProposal ¶
type TextProposal struct { Title string `json:"title" yaml:"title"` Description string `json:"description" yaml:"description"` }
TextProposal defines a standard text proposal whose changes need to be manually updated in case of approval
func (TextProposal) GetDescription ¶
func (tp TextProposal) GetDescription() string
GetDescription returns the proposal description
func (TextProposal) GetTitle ¶
func (tp TextProposal) GetTitle() string
GetTitle returns the proposal title
func (TextProposal) ProposalRoute ¶
func (tp TextProposal) ProposalRoute() string
ProposalRoute returns the proposal router key
func (TextProposal) ProposalType ¶
func (tp TextProposal) ProposalType() string
ProposalType is "Text"
func (TextProposal) String ¶
func (tp TextProposal) String() string
String implements Stringer interface
func (TextProposal) ValidateBasic ¶
func (tp TextProposal) ValidateBasic() error
ValidateBasic validates the content's title and description of the proposal
type ValidatorGovInfo ¶
type ValidatorGovInfo struct { Address sdk.ValAddress // address of the validator operator BondedTokens sdk.Int // Power of a Validator DelegatorDeductions sdk.Dec // Delegator deductions from validator's delegators voting independently Vote VoteOption // Vote of the validator }
ValidatorGovInfo used for tallying
func NewValidatorGovInfo ¶
func NewValidatorGovInfo(address sdk.ValAddress, bondedTokens sdk.Int, delegatorShares, delegatorDeductions sdk.Dec, vote VoteOption) ValidatorGovInfo
NewValidatorGovInfo creates a ValidatorGovInfo instance
type Vote ¶
type Vote struct { ProposalID uint64 `json:"proposal_id" yaml:"proposal_id"` // proposalID of the proposal Voter sdk.AccAddress `json:"voter" yaml:"voter"` // address of the voter Option VoteOption `json:"option" yaml:"option"` // option from OptionSet chosen by the voter }
Vote
func NewVote ¶
func NewVote(proposalID uint64, voter sdk.AccAddress, option VoteOption) Vote
NewVote creates a new Vote instance
type VoteOption ¶
type VoteOption byte
VoteOption defines a vote option
const ( OptionEmpty VoteOption = 0x00 OptionYes VoteOption = 0x01 OptionAbstain VoteOption = 0x02 OptionNo VoteOption = 0x03 OptionNoWithVeto VoteOption = 0x04 )
Vote options
func VoteOptionFromString ¶
func VoteOptionFromString(str string) (VoteOption, error)
VoteOptionFromString returns a VoteOption from a string. It returns an error if the string is invalid.
func (VoteOption) Format ¶
func (vo VoteOption) Format(s fmt.State, verb rune)
Format implements the fmt.Formatter interface.
func (VoteOption) Marshal ¶
func (vo VoteOption) Marshal() ([]byte, error)
Marshal needed for protobuf compatibility.
func (VoteOption) MarshalJSON ¶
func (vo VoteOption) MarshalJSON() ([]byte, error)
Marshals to JSON using string.
func (VoteOption) String ¶
func (vo VoteOption) String() string
String implements the Stringer interface.
func (*VoteOption) Unmarshal ¶
func (vo *VoteOption) Unmarshal(data []byte) error
Unmarshal needed for protobuf compatibility.
func (*VoteOption) UnmarshalJSON ¶
func (vo *VoteOption) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes from JSON assuming Bech32 encoding.
type VotingParams ¶
type VotingParams struct {
VotingPeriod time.Duration `json:"voting_period,omitempty" yaml:"voting_period,omitempty"` // Length of the voting period.
}
VotingParams defines the params around Voting in governance
func DefaultVotingParams ¶
func DefaultVotingParams() VotingParams
DefaultVotingParams default parameters for voting
func NewVotingParams ¶
func NewVotingParams(votingPeriod time.Duration) VotingParams
NewVotingParams creates a new VotingParams object
func (VotingParams) String ¶
func (vp VotingParams) String() string
String implements stringer interface