gov

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

nolint

Index

Constants

View Source
const (
	DefaultCodespace sdk.CodespaceType = "gov"

	CodeUnknownProposal         sdk.CodeType = 1
	CodeInactiveProposal        sdk.CodeType = 2
	CodeAlreadyActiveProposal   sdk.CodeType = 3
	CodeAlreadyFinishedProposal sdk.CodeType = 4
	CodeAddressNotStaked        sdk.CodeType = 5
	CodeInvalidTitle            sdk.CodeType = 6
	CodeInvalidDescription      sdk.CodeType = 7
	CodeInvalidProposalType     sdk.CodeType = 8
	CodeInvalidVote             sdk.CodeType = 9
	CodeInvalidGenesis          sdk.CodeType = 10
	CodeInvalidProposalStatus   sdk.CodeType = 11
	////////////////////  iris begin  ///////////////////////////
	CodeInvalidParam          sdk.CodeType = 12
	CodeInvalidParamOp        sdk.CodeType = 13
	CodeSwitchPeriodInProcess sdk.CodeType = 14
	CodeInvalidPercent        sdk.CodeType = 15
	CodeInvalidUsageType      sdk.CodeType = 16
	CodeInvalidInput          sdk.CodeType = 17
	CodeInvalidVersion        sdk.CodeType = 18
	CodeInvalidSwitchHeight   sdk.CodeType = 19

	CodeVoteDeleted       sdk.CodeType = 20
	CodeDepositDeleted    sdk.CodeType = 21
	CodeVoteNotExisted    sdk.CodeType = 22
	CodeDepositNotExisted sdk.CodeType = 23
)
View Source
const (
	Insert string = "insert"
	Update string = "update"
)

Variables

This section is empty.

Functions

func ErrAddressNotStaked

func ErrAddressNotStaked(codespace sdk.CodespaceType, address sdk.AccAddress) sdk.Error

func ErrAlreadyActiveProposal

func ErrAlreadyActiveProposal(codespace sdk.CodespaceType, proposalID uint64) sdk.Error

func ErrAlreadyFinishedProposal

func ErrAlreadyFinishedProposal(codespace sdk.CodespaceType, proposalID uint64) sdk.Error

func ErrCodeDepositDeleted

func ErrCodeDepositDeleted(codespace sdk.CodespaceType, proposalID uint64) sdk.Error

func ErrCodeDepositNotExisted

func ErrCodeDepositNotExisted(codespace sdk.CodespaceType, address sdk.AccAddress, proposalID uint64) sdk.Error

func ErrCodeInvalidSwitchHeight

func ErrCodeInvalidSwitchHeight(codespace sdk.CodespaceType, blockHeight uint64, switchHeight uint64) sdk.Error

func ErrCodeInvalidVersion

func ErrCodeInvalidVersion(codespace sdk.CodespaceType, version uint64) sdk.Error

func ErrCodeVoteDeleted

func ErrCodeVoteDeleted(codespace sdk.CodespaceType, proposalID uint64) sdk.Error

func ErrCodeVoteNotExisted

func ErrCodeVoteNotExisted(codespace sdk.CodespaceType, address sdk.AccAddress, proposalID uint64) sdk.Error

func ErrInactiveProposal

func ErrInactiveProposal(codespace sdk.CodespaceType, proposalID uint64) sdk.Error

func ErrInvalidDescription

func ErrInvalidDescription(codespace sdk.CodespaceType, description string) sdk.Error

func ErrInvalidGenesis

func ErrInvalidGenesis(codespace sdk.CodespaceType, msg string) sdk.Error

func ErrInvalidParam

func ErrInvalidParam(codespace sdk.CodespaceType) sdk.Error

////////////////// iris begin ///////////////////////////

func ErrInvalidParamOp

func ErrInvalidParamOp(codespace sdk.CodespaceType, opStr string) sdk.Error

func ErrInvalidPercent

func ErrInvalidPercent(codespace sdk.CodespaceType, percent sdk.Dec) sdk.Error

func ErrInvalidProposalType

func ErrInvalidProposalType(codespace sdk.CodespaceType, proposalType ProposalKind) sdk.Error

func ErrInvalidTitle

func ErrInvalidTitle(codespace sdk.CodespaceType, title string) sdk.Error

func ErrInvalidUsageType

func ErrInvalidUsageType(codespace sdk.CodespaceType, usageType UsageType) sdk.Error

func ErrInvalidVote

func ErrInvalidVote(codespace sdk.CodespaceType, voteOption VoteOption) sdk.Error

func ErrNotProfiler

func ErrNotProfiler(codespace sdk.CodespaceType, profiler sdk.AccAddress) sdk.Error

func ErrNotTrustee

func ErrNotTrustee(codespace sdk.CodespaceType, trustee sdk.AccAddress) sdk.Error

func ErrSwitchPeriodInProcess

func ErrSwitchPeriodInProcess(codespace sdk.CodespaceType) sdk.Error

func ErrUnknownProposal

func ErrUnknownProposal(codespace sdk.CodespaceType, proposalID uint64) sdk.Error

func ProposalEqual

func ProposalEqual(proposalA Proposal, proposalB Proposal) bool

checks if two proposals are equal

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

Register concrete types on codec codec

func ValidProposalStatus

func ValidProposalStatus(status ProposalStatus) bool

is defined ProposalType?

func ValidProposalType

func ValidProposalType(pt ProposalKind) bool

is defined ProposalType?

func ValidUsageType

func ValidUsageType(ut UsageType) bool

is defined UsageType?

func ValidVoteOption

func ValidVoteOption(option VoteOption) bool

Is defined VoteOption

Types

type Deposit

type Deposit struct {
	Depositor  sdk.AccAddress `json:"depositor"`   //  Address of the depositor
	ProposalID uint64         `json:"proposal_id"` //  proposalID of the proposal
	Amount     sdk.Coins      `json:"amount"`      //  Deposit amount
}

Deposit

func (Deposit) Empty

func (depositA Deposit) Empty() bool

Returns whether a deposit is empty

func (Deposit) Equals

func (depositA Deposit) Equals(depositB Deposit) bool

Returns whether 2 deposits are equal

type HaltProposal

type HaltProposal struct {
	TextProposal
}

type Param

type Param struct {
	Key   string `json:"key"`
	Value string `json:"value"`
	Op    string `json:"op"`
}

type ParameterConfigFile

type ParameterConfigFile struct {
	Govparams govparams.ParamSet `json:"gov"`
}

func (*ParameterConfigFile) GetParamFromKey

func (pd *ParameterConfigFile) GetParamFromKey(keyStr string, opStr string) (Param, error)

func (*ParameterConfigFile) ReadFile

func (pd *ParameterConfigFile) ReadFile(cdc *codec.Codec, pathStr string) error

func (*ParameterConfigFile) WriteFile

func (pd *ParameterConfigFile) WriteFile(cdc *codec.Codec, res []sdk.KVPair, pathStr string) error

type ParameterProposal

type ParameterProposal struct {
	TextProposal
	Param Param `json:"params"`
}

type Proposal

type Proposal interface {
	GetProposalID() uint64
	SetProposalID(uint64)

	GetTitle() string
	SetTitle(string)

	GetDescription() string
	SetDescription(string)

	GetProposalType() ProposalKind
	SetProposalType(ProposalKind)

	GetStatus() ProposalStatus
	SetStatus(ProposalStatus)

	GetTallyResult() TallyResult
	SetTallyResult(TallyResult)

	GetSubmitTime() time.Time
	SetSubmitTime(time.Time)

	GetDepositEndTime() time.Time
	SetDepositEndTime(time.Time)

	GetTotalDeposit() sdk.Coins
	SetTotalDeposit(sdk.Coins)

	GetVotingStartTime() time.Time
	SetVotingStartTime(time.Time)

	GetVotingEndTime() time.Time
	SetVotingEndTime(time.Time)
}

----------------------------------------------------------- Proposal interface

type ProposalKind

type ProposalKind byte

Type that represents Proposal Type as a byte

const (
	ProposalTypeNil             ProposalKind = 0x00
	ProposalTypeText            ProposalKind = 0x01
	ProposalTypeParameterChange ProposalKind = 0x02
	ProposalTypeSoftwareUpgrade ProposalKind = 0x03
	////////////////////  iris begin  /////////////////////////////
	ProposalTypeSoftwareHalt ProposalKind = 0x04
	ProposalTypeTxTaxUsage   ProposalKind = 0x05
)

nolint

func ProposalTypeFromString

func ProposalTypeFromString(str string) (ProposalKind, error)

String to proposalType byte. Returns ff if invalid.

func (ProposalKind) Format

func (pt ProposalKind) Format(s fmt.State, verb rune)

For Printf / Sprintf, returns bech32 when using %s nolint: errcheck

func (ProposalKind) Marshal

func (pt ProposalKind) Marshal() ([]byte, error)

Marshal needed for protobuf compatibility

func (ProposalKind) MarshalJSON

func (pt ProposalKind) MarshalJSON() ([]byte, error)

Marshals to JSON using string

func (ProposalKind) String

func (pt ProposalKind) String() string

Turns VoteOption byte to String

func (*ProposalKind) Unmarshal

func (pt *ProposalKind) Unmarshal(data []byte) error

Unmarshal needed for protobuf compatibility

func (*ProposalKind) UnmarshalJSON

func (pt *ProposalKind) UnmarshalJSON(data []byte) error

Unmarshals from JSON assuming Bech32 encoding

type ProposalQueue

type ProposalQueue []uint64

----------------------------------------------------------- ProposalQueue

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)

ProposalStatusToString turns a string into a ProposalStatus

func (ProposalStatus) Format

func (status ProposalStatus) Format(s fmt.State, verb rune)

For Printf / Sprintf, returns bech32 when using %s 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)

Marshals to JSON using string

func (ProposalStatus) String

func (status ProposalStatus) String() string

Turns VoteStatus byte to String

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

Unmarshals from JSON assuming Bech32 encoding

type SoftwareUpgradeProposal

type SoftwareUpgradeProposal struct {
	TextProposal
	Version      uint64
	Software     string
	SwitchHeight uint64
}

type TallyResult

type TallyResult struct {
	Yes        sdk.Dec `json:"yes"`
	Abstain    sdk.Dec `json:"abstain"`
	No         sdk.Dec `json:"no"`
	NoWithVeto sdk.Dec `json:"no_with_veto"`
}

----------------------------------------------------------- Tally Results

func EmptyTallyResult

func EmptyTallyResult() TallyResult

checks if two proposals are equal

func (TallyResult) Equals

func (resultA TallyResult) Equals(resultB TallyResult) bool

checks if two proposals are equal

type TaxUsageProposal

type TaxUsageProposal struct {
	TextProposal
	Usage       UsageType
	DestAddress sdk.AccAddress
	Percent     sdk.Dec
}

type TextProposal

type TextProposal struct {
	ProposalID   uint64       `json:"proposal_id"`   //  ID of the proposal
	Title        string       `json:"title"`         //  Title of the proposal
	Description  string       `json:"description"`   //  Description of the proposal
	ProposalType ProposalKind `json:"proposal_type"` //  Type of proposal. Initial set {PlainTextProposal, SoftwareUpgradeProposal}

	Status      ProposalStatus `json:"proposal_status"` //  Status of the Proposal {Pending, Active, Passed, Rejected}
	TallyResult TallyResult    `json:"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   sdk.Coins `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
	VotingEndTime   time.Time `json:"voting_end_time"`   // Time that the VotingPeriod for this proposal will end and votes will be tallied
}

----------------------------------------------------------- Text Proposals

func (TextProposal) GetDepositEndTime

func (tp TextProposal) GetDepositEndTime() time.Time

func (TextProposal) GetDescription

func (tp TextProposal) GetDescription() string

func (TextProposal) GetProposalID

func (tp TextProposal) GetProposalID() uint64

nolint

func (TextProposal) GetProposalType

func (tp TextProposal) GetProposalType() ProposalKind

func (TextProposal) GetStatus

func (tp TextProposal) GetStatus() ProposalStatus

func (TextProposal) GetSubmitTime

func (tp TextProposal) GetSubmitTime() time.Time

func (TextProposal) GetTallyResult

func (tp TextProposal) GetTallyResult() TallyResult

func (TextProposal) GetTitle

func (tp TextProposal) GetTitle() string

func (TextProposal) GetTotalDeposit

func (tp TextProposal) GetTotalDeposit() sdk.Coins

func (TextProposal) GetVotingEndTime

func (tp TextProposal) GetVotingEndTime() time.Time

func (TextProposal) GetVotingStartTime

func (tp TextProposal) GetVotingStartTime() time.Time

func (*TextProposal) SetDepositEndTime

func (tp *TextProposal) SetDepositEndTime(depositEndTime time.Time)

func (*TextProposal) SetDescription

func (tp *TextProposal) SetDescription(description string)

func (*TextProposal) SetProposalID

func (tp *TextProposal) SetProposalID(proposalID uint64)

func (*TextProposal) SetProposalType

func (tp *TextProposal) SetProposalType(proposalType ProposalKind)

func (*TextProposal) SetStatus

func (tp *TextProposal) SetStatus(status ProposalStatus)

func (*TextProposal) SetSubmitTime

func (tp *TextProposal) SetSubmitTime(submitTime time.Time)

func (*TextProposal) SetTallyResult

func (tp *TextProposal) SetTallyResult(tallyResult TallyResult)

func (*TextProposal) SetTitle

func (tp *TextProposal) SetTitle(title string)

func (*TextProposal) SetTotalDeposit

func (tp *TextProposal) SetTotalDeposit(totalDeposit sdk.Coins)

func (*TextProposal) SetVotingEndTime

func (tp *TextProposal) SetVotingEndTime(votingEndTime time.Time)

func (*TextProposal) SetVotingStartTime

func (tp *TextProposal) SetVotingStartTime(votingStartTime time.Time)

type UsageType

type UsageType byte
const (
	UsageTypeBurn       UsageType = 0x01
	UsageTypeDistribute UsageType = 0x02
	UsageTypeGrant      UsageType = 0x03
)

func UsageTypeFromString

func UsageTypeFromString(str string) (UsageType, error)

String to UsageType byte. Returns ff if invalid.

func (UsageType) Format

func (ut UsageType) Format(s fmt.State, verb rune)

For Printf / Sprintf, returns bech32 when using %s nolint: errcheck

func (UsageType) Marshal

func (ut UsageType) Marshal() ([]byte, error)

Marshal needed for protobuf compatibility

func (UsageType) MarshalJSON

func (ut UsageType) MarshalJSON() ([]byte, error)

Marshals to JSON using string

func (UsageType) String

func (ut UsageType) String() string

Turns VoteOption byte to String

func (*UsageType) Unmarshal

func (ut *UsageType) Unmarshal(data []byte) error

Unmarshal needed for protobuf compatibility

func (*UsageType) UnmarshalJSON

func (ut *UsageType) UnmarshalJSON(data []byte) error

Unmarshals from JSON assuming Bech32 encoding

type Vote

type Vote struct {
	Voter      sdk.AccAddress `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) Empty

func (voteA Vote) Empty() bool

Returns whether a vote is empty

func (Vote) Equals

func (voteA Vote) Equals(voteB Vote) bool

Returns whether 2 votes are equal

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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