Documentation
¶
Index ¶
- Constants
- Variables
- func ErrFinishedProposal(proposalID uint64) btypes.Error
- func ErrInactiveProposal(proposalID uint64) btypes.Error
- func ErrInvalidGenesis(msg string) btypes.Error
- func ErrInvalidInput(msg string) btypes.Error
- func ErrInvalidVote(voteOption VoteOption) btypes.Error
- func ErrUnknownProposal(proposalID uint64) btypes.Error
- func ErrWrongProposalStatus(proposalID uint64) btypes.Error
- func KeyActiveProposalQueueProposal(endTime time.Time, proposalID uint64) []byte
- func KeyDeposit(proposalID uint64, depositorAddr btypes.Address) []byte
- func KeyDepositsSubspace(proposalID uint64) []byte
- func KeyInactiveProposalQueueProposal(endTime time.Time, proposalID uint64) []byte
- func KeyProposal(proposalID uint64) []byte
- func KeyProposalSubspace() []byte
- func KeyVote(proposalID uint64, voterAddr btypes.Address) []byte
- func KeyVotesSubspace(proposalID uint64) []byte
- func KeyVotingPeriodValidators(proposalID uint64) []byte
- func PrefixActiveProposalQueueTime(endTime time.Time) []byte
- func PrefixInactiveProposalQueueTime(endTime time.Time) []byte
- func ValidProposalStatus(status ProposalStatus) bool
- func ValidProposalType(pt ProposalType) bool
- func ValidVoteOption(option VoteOption) bool
- func ValidateGenesis(data GenesisState) error
- type DeductOption
- type Deposit
- type Deposits
- type GenesisProposal
- type GenesisState
- type ModifyInflationProposal
- type Param
- type ParameterProposal
- type Params
- type Proposal
- type ProposalContent
- type ProposalResult
- type ProposalStatus
- type ProposalType
- type SoftwareUpgradeProposal
- type TallyResult
- type TaxUsageProposal
- type TextProposal
- type Vote
- type VoteOption
- type Votes
Constants ¶
const ( DefaultCodeSpace btypes.CodespaceType = "gov" CodeInvalidInput btypes.CodeType = 601 // invalid input CodeInvalidGenesis btypes.CodeType = 602 // invalid genesis CodeUnknownProposal btypes.CodeType = 603 // unknown proposal CodeInactiveProposal btypes.CodeType = 604 // inactive proposal CodeInvalidVote btypes.CodeType = 605 // invalid vote CodeFinishedProposal btypes.CodeType = 606 // finished proposal CodeWrongProposalStatus btypes.CodeType = 607 // wrong status of proposal )
QCP errors reserve 600 ~ 699.
const ( // Default period for deposits & voting DefaultPeriod = 60 * 2 * time.Second // 2 days )
Variables ¶
var ( EventTypeSubmitProposal = "submit-proposal" EventTypeDepositProposal = "deposit-proposal" EventTypeVoteProposal = "vote-proposal" EventTypeInactiveProposal = "inactive-proposal" EventTypeActiveProposal = "active-proposal" AttributeKeyModule = "gov" AttributeKeyProposer = "proposer" AttributeKeyProposalID = "proposal-id" AttributeKeyDepositor = "depositor" AttributeKeyVoter = "voter" AttributeKeyProposalResult = "proposal-result" AttributeKeyProposalType = "proposal-type" AttributeKeyDropped = "proposal-dropped" AttributeKeyResultPassed = "proposal-passed" AttributeKeyResultRejected = "proposal-rejected" AttributeKeyResultVetoRejected = "proposal-veto-rejected" )
Governance tags
var ( KeyDelimiter = []byte(":") KeyNextProposalID = []byte("newProposalID") PrefixActiveProposalQueue = []byte("activeProposalQueue") PrefixInactiveProposalQueue = []byte("inactiveProposalQueue") KeySoftUpgradeProposal = []byte("upgradeProposal") )
Key for getting a the next available proposalID from the store
var ( ParamSpace = "gov" KeyMinDeposit = []byte("min_deposit") KeyMaxDepositPeriod = []byte("max_deposit_period") KeyVotingPeriod = []byte("voting_period") KeyQuorum = []byte("quorum") KeyThreshold = []byte("threshold") KeyVeto = []byte("veto") KeyPenalty = []byte("penalty") KeyBurnRate = []byte("burn_rate") )
Functions ¶
func ErrFinishedProposal ¶
func ErrInactiveProposal ¶
func ErrInvalidGenesis ¶
func ErrInvalidInput ¶
func ErrInvalidVote ¶
func ErrInvalidVote(voteOption VoteOption) btypes.Error
func ErrUnknownProposal ¶
func ErrWrongProposalStatus ¶
func KeyActiveProposalQueueProposal ¶
Returns the key for a proposalID in the activeProposalQueue
func KeyDeposit ¶
Key for getting a specific deposit from the store
func KeyDepositsSubspace ¶
Key for getting all deposits on a proposal from the store
func KeyInactiveProposalQueueProposal ¶
Returns the key for a proposalID in the activeProposalQueue
func KeyProposal ¶
Key for getting a specific proposal from the store
func KeyProposalSubspace ¶
func KeyProposalSubspace() []byte
func KeyVotesSubspace ¶
Key for getting all votes on a proposal from the store
func KeyVotingPeriodValidators ¶
Key for validators set at entering voting period.
func PrefixActiveProposalQueueTime ¶
Returns the key for a proposalID in the activeProposalQueue
func PrefixInactiveProposalQueueTime ¶
Returns the key for a proposalID in the activeProposalQueue
func ValidProposalStatus ¶
func ValidProposalStatus(status ProposalStatus) bool
Types ¶
type DeductOption ¶
type DeductOption byte
Type that deduct deposits
const ( DepositDeductNone DeductOption = 0x00 DepositDeductPart DeductOption = 0x01 DepositDeductAll DeductOption = 0x02 )
nolint
type Deposit ¶
type Deposit struct {
Depositor types.Address `json:"depositor"` // Address of the depositor
ProposalID uint64 `json:"proposal_id"` // proposalID of the proposal
Amount uint64 `json:"amount"` // Deposit amount
}
Deposit
type GenesisProposal ¶
type GenesisState ¶
type GenesisState struct {
StartingProposalID uint64 `json:"starting_proposal_id"`
Params Params `json:"params"`
Proposals []GenesisProposal `json:"proposals"`
}
func DefaultGenesisState ¶
func DefaultGenesisState() GenesisState
get raw genesis raw message for testing
func NewGenesisState ¶
func NewGenesisState(startingProposalID uint64, params Params) GenesisState
type ModifyInflationProposal ¶
type ModifyInflationProposal struct {
TextProposal
TotalAmount uint64 `json:"total_amount"`
InflationPhrases mint.InflationPhrases `json:"inflation_phrases"`
}
Add Inflation Phrase Proposal
func NewAddInflationPhrase ¶
func NewAddInflationPhrase(title, description string, deposit uint64, totalAmount uint64, phrases mint.InflationPhrases) ModifyInflationProposal
func (ModifyInflationProposal) GetDeposit ¶
func (tp ModifyInflationProposal) GetDeposit() uint64
func (ModifyInflationProposal) GetDescription ¶
func (tp ModifyInflationProposal) GetDescription() string
func (ModifyInflationProposal) GetProposalType ¶
func (tp ModifyInflationProposal) GetProposalType() ProposalType
func (ModifyInflationProposal) GetTitle ¶
func (tp ModifyInflationProposal) GetTitle() string
nolint
type Param ¶
type ParameterProposal ¶
type ParameterProposal struct {
TextProposal
Params []Param `json:"params"`
}
Parameters change Proposal
func NewParameterProposal ¶
func NewParameterProposal(title, description string, deposit uint64, params []Param) ParameterProposal
func (ParameterProposal) GetDeposit ¶
func (tp ParameterProposal) GetDeposit() uint64
func (ParameterProposal) GetDescription ¶
func (tp ParameterProposal) GetDescription() string
func (ParameterProposal) GetProposalType ¶
func (tp ParameterProposal) GetProposalType() ProposalType
type Params ¶
type Params struct {
// DepositParams
MinDeposit uint64 `json:"min_deposit"` // Minimum deposit for a proposal to enter voting period.
MinProposerDepositRate qtypes.Dec `json:"min_proposer_deposit_rate"` // Minimum deposit rate for proposer to submit a proposal. Initial value: 1/3
MaxDepositPeriod time.Duration `json:"max_deposit_period"` // Maximum period for Atom holders to deposit on a proposal. Initial value: 2 months
// VotingParams
VotingPeriod time.Duration `json:"voting_period"` // Length of the voting period.
// TallyParams
Quorum qtypes.Dec `json:"quorum"` // Minimum percentage of total stake needed to vote for a result to be considered valid
Threshold qtypes.Dec `json:"threshold"` // Minimum propotion of Yes votes for proposal to pass. Initial value: 0.5
Veto qtypes.Dec `json:"veto"` // Minimum value of Veto votes to Total votes ratio for proposal to be vetoed. Initial value: 1/3
Penalty qtypes.Dec `json:"penalty"` // Penalty if validator does not vote
BurnRate qtypes.Dec `json:"burn_rate"` // Deposit burning rate when proposals pass or reject. Initial value: 1/2
}
Params returns all of the governance p
func DefaultParams ¶
func DefaultParams() Params
func (*Params) GetParamSpace ¶
func (*Params) KeyValuePairs ¶
func (p *Params) KeyValuePairs() params.KeyValuePairs
type Proposal ¶
type Proposal struct {
ProposalContent `json:"proposal_content"` // Proposal content interface
ProposalID uint64 `json:"proposal_id"` // ID of the proposal
Status ProposalStatus `json:"proposal_status"` // Status of the Proposal {Pending, Active, Passed, Rejected}
FinalTallyResult TallyResult `json:"final_tally_result"` // Result of Tallys
SubmitTime time.Time `json:"submit_time"` // Time of the block where TxGovSubmitProposal was included
DepositEndTime time.Time `json:"deposit_end_time"` // Time that the Proposal would expire if deposit amount isn't met
TotalDeposit uint64 `json:"total_deposit"` // Current deposit on this proposal. Initial value is set at InitialDeposit
VotingStartTime time.Time `json:"voting_start_time"` // Time of the block where MinDeposit was reached. -1 if MinDeposit is not reached
VotingStartHeight uint64 `json:"voting_start_height"`
VotingEndTime time.Time `json:"voting_end_time"` // Time that the VotingPeriod for this proposal will end and votes will be tallied
}
type ProposalContent ¶
type ProposalContent interface {
GetTitle() string
GetDescription() string
GetDeposit() uint64
GetProposalType() ProposalType
}
type ProposalResult ¶
type ProposalResult string
const ( PASS ProposalResult = "pass" REJECT ProposalResult = "reject" REJECTVETO ProposalResult = "reject-veto" )
type ProposalStatus ¶
type ProposalStatus byte
Type that represents Proposal Status as a byte
const ( StatusNil ProposalStatus = 0x00 StatusDepositPeriod ProposalStatus = 0x01 StatusVotingPeriod ProposalStatus = 0x02 StatusPassed ProposalStatus = 0x03 StatusRejected ProposalStatus = 0x04 )
nolint
func ProposalStatusFromString ¶
func ProposalStatusFromString(str string) (ProposalStatus, error)
String to proposalStatus byte. Returns ff if invalid.
func (ProposalStatus) Marshal ¶
func (ps ProposalStatus) Marshal() ([]byte, error)
Marshal needed for protobuf compatibility
func (ProposalStatus) MarshalJSON ¶
func (ps ProposalStatus) MarshalJSON() ([]byte, error)
Marshals to JSON using string
func (ProposalStatus) String ¶
func (ps ProposalStatus) String() string
Turns VoteOption byte to String
func (*ProposalStatus) Unmarshal ¶
func (ps *ProposalStatus) Unmarshal(data []byte) error
Unmarshal needed for protobuf compatibility
func (*ProposalStatus) UnmarshalJSON ¶
func (ps *ProposalStatus) UnmarshalJSON(data []byte) error
Unmarshals from JSON assuming Bech32 encoding
type ProposalType ¶
type ProposalType byte
Type that represents Proposal Type as a byte
const ( ProposalTypeNil ProposalType = 0x00 ProposalTypeText ProposalType = 0x01 ProposalTypeParameterChange ProposalType = 0x02 ProposalTypeTaxUsage ProposalType = 0x03 ProposalTypeModifyInflation ProposalType = 0x04 ProposalTypeSoftwareUpgrade ProposalType = 0x05 )
func ProposalTypeFromString ¶
func ProposalTypeFromString(str string) (ProposalType, error)
String to proposalType byte. Returns 0xff if invalid.
type SoftwareUpgradeProposal ¶
type SoftwareUpgradeProposal struct {
TextProposal
Version string `json:"version"`
DataHeight uint64 `json:"data_height"`
GenesisFile string `json:"genesis_file"`
GenesisMD5 string `json:"genesis_md5"`
ForZeroHeight bool `json:"for_zero_height"`
}
func (SoftwareUpgradeProposal) GetDeposit ¶
func (tp SoftwareUpgradeProposal) GetDeposit() uint64
func (SoftwareUpgradeProposal) GetDescription ¶
func (tp SoftwareUpgradeProposal) GetDescription() string
func (SoftwareUpgradeProposal) GetProposalType ¶
func (tp SoftwareUpgradeProposal) GetProposalType() ProposalType
func (SoftwareUpgradeProposal) GetTitle ¶
func (tp SoftwareUpgradeProposal) GetTitle() string
nolint
type TallyResult ¶
type TallyResult struct {
Yes int64 `json:"yes"`
Abstain int64 `json:"abstain"`
No int64 `json:"no"`
NoWithVeto int64 `json:"no_with_veto"`
}
Tally Results
func EmptyTallyResult ¶
func EmptyTallyResult() TallyResult
func NewTallyResult ¶
func NewTallyResult(yes, abstain, no, noWithVeto int64) TallyResult
func (TallyResult) Equals ¶
func (tr TallyResult) Equals(comp TallyResult) bool
func (TallyResult) String ¶
func (tr TallyResult) String() string
type TaxUsageProposal ¶
type TaxUsageProposal struct {
TextProposal
DestAddress btypes.Address `json:"dest_address"`
Percent types.Dec `json:"percent"`
}
TaxUsage Proposal
func NewTaxUsageProposal ¶
func (TaxUsageProposal) GetDeposit ¶
func (tp TaxUsageProposal) GetDeposit() uint64
func (TaxUsageProposal) GetDescription ¶
func (tp TaxUsageProposal) GetDescription() string
func (TaxUsageProposal) GetProposalType ¶
func (tp TaxUsageProposal) GetProposalType() ProposalType
type TextProposal ¶
type TextProposal struct {
Title string `json:"title"` // Title of the proposal
Description string `json:"description"` // Description of the proposal
Deposit uint64 `json:"deposit"` // Deposit of the proposal
}
Text Proposal
func NewTextProposal ¶
func NewTextProposal(title, description string, deposit uint64) TextProposal
func (TextProposal) GetDeposit ¶
func (tp TextProposal) GetDeposit() uint64
func (TextProposal) GetDescription ¶
func (tp TextProposal) GetDescription() string
func (TextProposal) GetProposalType ¶
func (tp TextProposal) GetProposalType() ProposalType
type Vote ¶
type Vote struct {
Voter types.Address `json:"voter"` // address of the voter
ProposalID uint64 `json:"proposal_id"` // proposalID of the proposal
Option VoteOption `json:"option"` // option from OptionSet chosen by the voter
}
Vote
type VoteOption ¶
type VoteOption byte
Type that represents VoteOption as a byte
const ( OptionEmpty VoteOption = 0x00 OptionYes VoteOption = 0x01 OptionAbstain VoteOption = 0x02 OptionNo VoteOption = 0x03 OptionNoWithVeto VoteOption = 0x04 )
nolint
func VoteOptionFromString ¶
func VoteOptionFromString(str string) (VoteOption, error)
String to proposalType byte. Returns ff if invalid.
func (VoteOption) Format ¶
func (vo VoteOption) Format(s fmt.State, verb rune)
For Printf / Sprintf, returns bech32 when using %s nolint: errcheck
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) Unmarshal ¶
func (vo *VoteOption) Unmarshal(data []byte) error
Unmarshal needed for protobuf compatibility
func (*VoteOption) UnmarshalJSON ¶
func (vo *VoteOption) UnmarshalJSON(data []byte) error
Unmarshals from JSON assuming Bech32 encoding