v034

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

DONTCOVER nolint

Index

Constants

View Source
const (
	ModuleName = "gov"

	StatusNil           ProposalStatus = 0x00
	StatusDepositPeriod ProposalStatus = 0x01
	StatusVotingPeriod  ProposalStatus = 0x02
	StatusPassed        ProposalStatus = 0x03
	StatusRejected      ProposalStatus = 0x04
	StatusFailed        ProposalStatus = 0x05

	OptionEmpty      VoteOption = 0x00
	OptionYes        VoteOption = 0x01
	OptionAbstain    VoteOption = 0x02
	OptionNo         VoteOption = 0x03
	OptionNoWithVeto VoteOption = 0x04

	ProposalTypeNil             ProposalKind = 0x00
	ProposalTypeText            ProposalKind = 0x01
	ProposalTypeParameterChange ProposalKind = 0x02
)
View Source
const (
	MaxDescriptionLength int = 5000
	MaxTitleLength       int = 140
)

Constants pertaining to a Content object

Variables

This section is empty.

Functions

func ValidateAbstract

func ValidateAbstract(c Content) error

ValidateAbstract validates a proposal's abstract contents returning an error if invalid.

Types

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.

type Deposit

type Deposit struct {
	ProposalID uint64         `json:"proposal_id"`
	Depositor  sdk.AccAddress `json:"depositor"`
	Amount     sdk.Coins      `json:"amount"`
}

type DepositParams

type DepositParams struct {
	MinDeposit       sdk.Coins     `json:"min_deposit,omitempty"`
	MaxDepositPeriod time.Duration `json:"max_deposit_period,omitempty"`
}

type DepositWithMetadata

type DepositWithMetadata struct {
	ProposalID uint64  `json:"proposal_id"`
	Deposit    Deposit `json:"deposit"`
}

type Deposits

type Deposits []Deposit

type GenesisState

type GenesisState struct {
	StartingProposalID uint64                `json:"starting_proposal_id"`
	Deposits           []DepositWithMetadata `json:"deposits"`
	Votes              []VoteWithMetadata    `json:"votes"`
	Proposals          []Proposal            `json:"proposals"`
	DepositParams      DepositParams         `json:"deposit_params"`
	VotingParams       VotingParams          `json:"voting_params"`
	TallyParams        TallyParams           `json:"tally_params"`
}

type Handler

type Handler func(ctx sdk.Context, content Content) error

Handler defines a function that handles a proposal after it has passed the governance process.

type Proposal

type Proposal struct {
	ProposalContent `json:"proposal_content"`

	ProposalID uint64 `json:"proposal_id"`

	Status           ProposalStatus `json:"proposal_status"`
	FinalTallyResult TallyResult    `json:"final_tally_result"`

	SubmitTime     time.Time `json:"submit_time"`
	DepositEndTime time.Time `json:"deposit_end_time"`
	TotalDeposit   sdk.Coins `json:"total_deposit"`

	VotingStartTime time.Time `json:"voting_start_time"`
	VotingEndTime   time.Time `json:"voting_end_time"`
}

type ProposalContent

type ProposalContent interface {
	GetTitle() string
	GetDescription() string
	ProposalType() ProposalKind
}

type ProposalKind

type ProposalKind byte

func ProposalTypeFromString

func ProposalTypeFromString(str string) (ProposalKind, error)

func (ProposalKind) Marshal

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

func (ProposalKind) MarshalJSON

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

func (ProposalKind) String

func (pt ProposalKind) String() string

func (*ProposalKind) Unmarshal

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

func (*ProposalKind) UnmarshalJSON

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

type ProposalQueue

type ProposalQueue []uint64

type ProposalStatus

type ProposalStatus byte

func ProposalStatusFromString

func ProposalStatusFromString(str string) (ProposalStatus, error)

ProposalStatusToString turns a string into a ProposalStatus

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 Proposals

type Proposals []Proposal

type TallyParams

type TallyParams struct {
	Quorum    string `json:"quorum,omitempty"`
	Threshold string `json:"threshold,omitempty"`
	Veto      string `json:"veto,omitempty"`
}

type TallyResult

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

type TextProposal

type TextProposal struct {
	Title       string `json:"title"`
	Description string `json:"description"`
}

func (TextProposal) GetDescription

func (tp TextProposal) GetDescription() string

func (TextProposal) GetTitle

func (tp TextProposal) GetTitle() string

func (TextProposal) ProposalType

func (tp TextProposal) ProposalType() ProposalKind

type Vote

type Vote struct {
	ProposalID uint64         `json:"proposal_id"`
	Voter      sdk.AccAddress `json:"voter"`
	Option     VoteOption     `json:"option"`
}

type VoteOption

type VoteOption byte

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 VoteWithMetadata

type VoteWithMetadata struct {
	ProposalID uint64 `json:"proposal_id"`
	Vote       Vote   `json:"vote"`
}

type Votes

type Votes []Vote

type VotingParams

type VotingParams struct {
	VotingPeriod time.Duration `json:"voting_period,omitempty"`
}

Jump to

Keyboard shortcuts

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