types

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2019 License: Apache-2.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

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

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

Variables

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

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

View Source
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 ErrFinishedProposal(proposalID uint64) btypes.Error

func ErrInactiveProposal

func ErrInactiveProposal(proposalID uint64) btypes.Error

func ErrInvalidGenesis

func ErrInvalidGenesis(msg string) btypes.Error

func ErrInvalidInput

func ErrInvalidInput(msg string) btypes.Error

func ErrInvalidVote

func ErrInvalidVote(voteOption VoteOption) btypes.Error

func ErrUnknownProposal

func ErrUnknownProposal(proposalID uint64) btypes.Error

func ErrWrongProposalStatus

func ErrWrongProposalStatus(proposalID uint64) btypes.Error

func KeyActiveProposalQueueProposal

func KeyActiveProposalQueueProposal(endTime time.Time, proposalID uint64) []byte

Returns the key for a proposalID in the activeProposalQueue

func KeyDeposit

func KeyDeposit(proposalID uint64, depositorAddr btypes.Address) []byte

Key for getting a specific deposit from the store

func KeyDepositsSubspace

func KeyDepositsSubspace(proposalID uint64) []byte

Key for getting all deposits on a proposal from the store

func KeyInactiveProposalQueueProposal

func KeyInactiveProposalQueueProposal(endTime time.Time, proposalID uint64) []byte

Returns the key for a proposalID in the activeProposalQueue

func KeyProposal

func KeyProposal(proposalID uint64) []byte

Key for getting a specific proposal from the store

func KeyProposalSubspace

func KeyProposalSubspace() []byte

func KeyVote

func KeyVote(proposalID uint64, voterAddr btypes.Address) []byte

Key for getting a specific vote from the store

func KeyVotesSubspace

func KeyVotesSubspace(proposalID uint64) []byte

Key for getting all votes on a proposal from the store

func KeyVotingPeriodValidators

func KeyVotingPeriodValidators(proposalID uint64) []byte

Key for validators set at entering voting period.

func PrefixActiveProposalQueueTime

func PrefixActiveProposalQueueTime(endTime time.Time) []byte

Returns the key for a proposalID in the activeProposalQueue

func PrefixInactiveProposalQueueTime

func PrefixInactiveProposalQueueTime(endTime time.Time) []byte

Returns the key for a proposalID in the activeProposalQueue

func ValidProposalStatus

func ValidProposalStatus(status ProposalStatus) bool

func ValidProposalType

func ValidProposalType(pt ProposalType) bool

is defined GetProposalType?

func ValidVoteOption

func ValidVoteOption(option VoteOption) bool

Is defined VoteOption

func ValidateGenesis

func ValidateGenesis(data GenesisState) error

ValidateGenesis

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

func (Deposit) Equals

func (d Deposit) Equals(comp Deposit) bool

func (Deposit) String

func (d Deposit) String() string

type Deposits

type Deposits []Deposit

func (Deposits) String

func (d Deposits) String() string

type GenesisProposal

type GenesisProposal struct {
	Proposal Proposal  `json:"proposal"`
	Deposits []Deposit `json:"deposits"`
	Votes    []Vote    `json:"votes"`
}

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 Param struct {
	Module string `json:"module"`
	Key    string `json:"key"`
	Value  string `json:"value"`
}

func NewParam

func NewParam(module, key, value string) Param

func (Param) String

func (param Param) String() string

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

func (ParameterProposal) GetTitle

func (tp ParameterProposal) GetTitle() string

nolint

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 (p *Params) GetParamSpace() string

func (*Params) KeyValuePairs

func (p *Params) KeyValuePairs() params.KeyValuePairs

func (*Params) Validate

func (p *Params) Validate(key string, value string) (interface{}, btypes.Error)

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.

func (ProposalType) String

func (pt ProposalType) String() string

Turns VoteOption byte to String

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 NewSoftwareUpgradeProposal

func NewSoftwareUpgradeProposal(title, description string, deposit uint64,
	version string, dataHeight uint64, genesisFile string, genesisMd5 string, forZeroHeight bool) SoftwareUpgradeProposal

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 NewTaxUsageProposal(title, description string, deposit uint64, destAddress btypes.Address, percent types.Dec) TaxUsageProposal

func (TaxUsageProposal) GetDeposit

func (tp TaxUsageProposal) GetDeposit() uint64

func (TaxUsageProposal) GetDescription

func (tp TaxUsageProposal) GetDescription() string

func (TaxUsageProposal) GetProposalType

func (tp TaxUsageProposal) GetProposalType() ProposalType

func (TaxUsageProposal) GetTitle

func (tp TaxUsageProposal) GetTitle() string

nolint

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

func (TextProposal) GetTitle

func (tp TextProposal) GetTitle() string

nolint

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

func (Vote) Equals

func (v Vote) Equals(comp Vote) bool

func (Vote) String

func (v Vote) String() string

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

func (vo VoteOption) String() string

Turns VoteOption byte to 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

type Votes

type Votes []Vote

Votes is a collection of Vote

func (Votes) String

func (v Votes) String() string

Jump to

Keyboard shortcuts

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