types

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxDescriptionLength int = 5000
	MaxTitleLength       int = 140
)

Constants pertaining to a Content object

View Source
const (
	// Default coin codespace
	DefaultCodespace string = ModuleName

	DurationInMonth  int = 3
	DurationInBlocks int = 1296000

	CodeUnknownProposal       CodeType = 100
	CodeInactiveProposal      CodeType = 200
	CodeAlreadyActiveProposal CodeType = 300
	// proposal content
	CodeInvalidProposalContent           CodeType = 400
	CodeInvalidProposalContentTitleBlank CodeType = 401
	CodeInvalidProposalContentTitleLong  CodeType = 402
	CodeInvalidProposalContentDescrBlank CodeType = 403
	CodeInvalidProposalContentDescrLong  CodeType = 404

	CodeInvalidProposalType     CodeType = 500
	CodeInvalidVote             CodeType = 600
	CodeInvalidGenesis          CodeType = 700
	CodeNoProposalHandlerExists CodeType = 800
	CodeInvalidStartEndBlocks   CodeType = 900
	CodeSubmitProposal          CodeType = 1000
	CodeStartBlock              CodeType = 1100
	CodeDurationTooLong         CodeType = 1200
	CodeNotAllowed              CodeType = 1300
)
View Source
const (
	EventTypeSubmitProposal   = "submit_proposal"
	EventTypeProposalVote     = "proposal_vote"
	EventTypeInactiveProposal = "inactive_proposal"
	EventTypeActiveProposal   = "active_proposal"

	AttributeKeyProposalResult           = "proposal_result"
	AttributeKeyOption                   = "option"
	AttributeKeyProposalID               = "proposal_id"
	AttributeKeyVotingPeriodStart        = "voting_period_start"
	AttributeValueCategory               = "governance"
	AttributeValueProposalPassed         = "proposal_passed"   // met vote quorum
	AttributeValueProposalRejected       = "proposal_rejected" // didn't meet vote quorum
	AttributeValueProposalFailed         = "proposal_failed"   // error on proposal handler
	AttributeKeyProposalType             = "proposal_type"
	AttributeKeyProposalTitle            = "proposal_title"
	AttributeKeyProposalDescription      = "proposal_description"
	AttributeKeyProposalVotingStartBlock = "proposal_voting_start_block"
	AttributeKeyProposalVotingEndBlock   = "proposal_voting_end_block"

	AttributeKeyResultVoteYes     = "result_vote_yes"
	AttributeKeyResultVoteAbstain = "result_vote_abstain"
	AttributeKeyResultVoteNo      = "result_vote_no"
	AttributeKeyTotalVotingPower  = "total_voting_power"
	AttributeKeyUpgradeHeight     = "upgrade_height"
)

Governance module event types

View Source
const (
	// ModuleName is the name of the module
	ModuleName = "gov"

	// StoreKey is the store key string for gov
	StoreKey = coin.StoreKey

	// 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

	KeyUpgradedIBCState = "upgradedIBCState"

	KeyUpgradedClient = "upgradedClient"

	KeyUpgradedConsState = "upgradedConsState"
)
View Source
const (
	TypeMsgVote            = "vote"
	TypeMsgSubmitProposal  = "submit_proposal"
	TypeMsgSoftwareUpgrade = "software_upgrade"
)

Governance message types and routes

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

View Source
const AddressForSoftwareUpgrade = "dx15gflwp3lj4neh2gt9p4ljrv9vtlda836xj7kev"
View Source
const DefaultStartingProposalID uint64 = 1

DefaultStartingProposalID is 1

Variables

View Source
var (
	ProposalsKeyPrefix          = []byte{0x00}
	ActiveProposalQueuePrefix   = []byte{0x01}
	InactiveProposalQueuePrefix = []byte{0x02}
	ProposalIDKey               = []byte{0x03}

	VotesKeyPrefix = []byte{0x10}

	PlanPrefix = []byte{0x20}
	DoneByte   = []byte{0x21}
)

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><voterAddr_Bytes>: Voter

View Source
var (
	DefaultQuorum    = sdk.NewDecWithPrec(667, 3)
	DefaultThreshold = sdk.NewDecWithPrec(5, 1)
)

Default governance params

View Source
var ModuleCdc = codec.New()
View Source
var (
	ParamStoreKeyTallyParams = []byte("tallyparams")
)

Parameter store key

Functions

func ActiveProposalByTimeKey

func ActiveProposalByTimeKey(endBlock uint64) []byte

ActiveProposalByTimeKey gets the active proposal queue key by endTime

func ActiveProposalQueueKey

func ActiveProposalQueueKey(proposalID uint64, endBlock uint64) []byte

ActiveProposalQueueKey returns the key for a proposalID in the activeProposalQueue

func CheckProposalAddress

func CheckProposalAddress(address sdk.AccAddress) bool

func ErrAlreadyActiveProposal

func ErrAlreadyActiveProposal() *sdkerrors.Error

func ErrDurationTooLong

func ErrDurationTooLong() *sdkerrors.Error

func ErrInactiveProposal

func ErrInactiveProposal(proposalID string) *sdkerrors.Error

func ErrInvalidGenesis

func ErrInvalidGenesis() *sdkerrors.Error

func ErrInvalidProposalContent

func ErrInvalidProposalContent() *sdkerrors.Error

func ErrInvalidProposalContentDescrBlank

func ErrInvalidProposalContentDescrBlank() *sdkerrors.Error

func ErrInvalidProposalContentDescrLong

func ErrInvalidProposalContentDescrLong(MaxDescriptionLength string) *sdkerrors.Error

func ErrInvalidProposalContentTitleBlank

func ErrInvalidProposalContentTitleBlank() *sdkerrors.Error

func ErrInvalidProposalContentTitleLong

func ErrInvalidProposalContentTitleLong(MaxTitleLength string) *sdkerrors.Error

func ErrInvalidProposalType

func ErrInvalidProposalType(ProposalType string) *sdkerrors.Error

func ErrInvalidStartEndBlocks

func ErrInvalidStartEndBlocks(StartBlock string, EndBlock string) *sdkerrors.Error

func ErrInvalidVote

func ErrInvalidVote(option string) *sdkerrors.Error

func ErrNoProposalHandlerExists

func ErrNoProposalHandlerExists() *sdkerrors.Error

func ErrNotAllowed

func ErrNotAllowed() *sdkerrors.Error

func ErrStartBlock

func ErrStartBlock() *sdkerrors.Error

func ErrSubmitProposal

func ErrSubmitProposal(error string) *sdkerrors.Error

func ErrUnknownProposal

func ErrUnknownProposal(proposalID string) *sdkerrors.Error

func GetBytesFromUint64

func GetBytesFromUint64(i uint64) []byte

func GetProposalIDBytes

func GetProposalIDBytes(proposalID uint64) (proposalIDBz []byte)

GetProposalIDBytes returns the byte representation of the proposalID

func GetProposalIDFromBytes

func GetProposalIDFromBytes(bz []byte) (proposalID uint64)

GetProposalIDFromBytes returns proposalID in uint64 format from a byte array

func GetUint64FromBytes

func GetUint64FromBytes(b []byte) uint64

func InactiveProposalByTimeKey

func InactiveProposalByTimeKey(endBlock uint64) []byte

InactiveProposalByTimeKey gets the inactive proposal queue key by endTime

func InactiveProposalQueueKey

func InactiveProposalQueueKey(proposalID uint64, endBlock uint64) []byte

InactiveProposalQueueKey returns the key for a proposalID in the inactiveProposalQueue

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamKeyTable - Key declaration for parameters

func PlanKey

func PlanKey() []byte

PlanKey is the key under which the current plan is saved We store PlanByte as a const to keep it immutable (unlike a []byte)

func ProposalKey

func ProposalKey(proposalID uint64) []byte

ProposalKey gets a specific proposal from the store

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers all the necessary types and interfaces for governance.

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

func SplitActiveProposalQueueKey(key []byte) (proposalID uint64, endBlock uint64)

SplitActiveProposalQueueKey split the active proposal key and returns the proposal id and endBlock

func SplitInactiveProposalQueueKey

func SplitInactiveProposalQueueKey(key []byte) (proposalID uint64, endBlock uint64)

SplitInactiveProposalQueueKey split the inactive proposal key and returns the proposal id and endBlock

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

func SplitProposalKey(key []byte) (proposalID uint64)

SplitProposalKey split the proposal key and returns the proposal id

func UpgradedClientKey

func UpgradedClientKey(height int64) []byte

func UpgradedConsStateKey

func UpgradedConsStateKey(height int64) []byte

UpgradedConsStateKey is the key under which the upgraded consensus state is saved Connecting IBC chains can verify against the upgraded consensus state in this path before upgrading their clients.

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 Validate

func Validate(c Content) error

Validate 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

func VoteKey

func VoteKey(proposalID uint64, voterAddr sdk.ValAddress) []byte

VoteKey key of a specific vote from the store

func VotesKey

func VotesKey(proposalID uint64) []byte

VotesKey gets the first part of the votes key based on the proposalID

Types

type AccountKeeper

type AccountKeeper interface {
	GetAccount(ctx sdk.Context, addr sdk.AccAddress) authexported.Account
}

AccountKeeper defines the expected account keeper (noalias)

type CodeType

type CodeType = uint32

type Content

type Content struct {
	Title       string `json:"title" yaml:"title"`             // Proposal title
	Description string `json:"description" yaml:"description"` // Proposal description
}

func (*Content) GetDescription

func (c *Content) GetDescription() string

func (*Content) GetTitle

func (c *Content) GetTitle() string

type GenesisState

type GenesisState struct {
	StartingProposalID uint64      `json:"starting_proposal_id" yaml:"starting_proposal_id"`
	Votes              Votes       `json:"votes" yaml:"votes"`
	Proposals          Proposals   `json:"proposals" yaml:"proposals"`
	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, 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

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 MsgSoftwareUpgradeProposal

type MsgSoftwareUpgradeProposal struct {
	Title       string         `json:"title" yaml:"title"`
	Description string         `json:"description" yaml:"description"`
	Plan        Plan           `json:"plan" yaml:"plan"`
	Proposer    sdk.AccAddress `json:"proposer" yaml:"proposer"` //  Address of the proposer
}

Software Upgrade Proposals

func NewSoftwareUpgradeProposal

func NewSoftwareUpgradeProposal(title, description string, plan Plan, proposer sdk.AccAddress) MsgSoftwareUpgradeProposal

func (MsgSoftwareUpgradeProposal) GetSignBytes

func (msg MsgSoftwareUpgradeProposal) GetSignBytes() []byte

GetSignBytes implements Msg

func (MsgSoftwareUpgradeProposal) GetSigners

func (msg MsgSoftwareUpgradeProposal) GetSigners() []sdk.AccAddress

GetSigners implements Msg

func (MsgSoftwareUpgradeProposal) Route

func (msg MsgSoftwareUpgradeProposal) Route() string

Route implements Msg

func (MsgSoftwareUpgradeProposal) String

func (msg MsgSoftwareUpgradeProposal) String() string

String implements the Stringer interface

func (MsgSoftwareUpgradeProposal) Type

Type implements Msg

func (MsgSoftwareUpgradeProposal) ValidateBasic

func (msg MsgSoftwareUpgradeProposal) ValidateBasic() error

ValidateBasic implements Msg

type MsgSubmitProposal

type MsgSubmitProposal struct {
	Content          Content        `json:"content" yaml:"content"`
	Proposer         sdk.AccAddress `json:"proposer" yaml:"proposer"` //  Address of the proposer
	VotingStartBlock uint64         `json:"voting_start_block" yaml:"voting_start_block"`
	VotingEndBlock   uint64         `json:"voting_end_block" yaml:"voting_end_block"`
}

MsgSubmitProposal defines a message to create a governance proposal with a given content and initial deposit

func NewMsgSubmitProposal

func NewMsgSubmitProposal(content Content, proposer sdk.AccAddress, votingStartBlock, votingEndBlock uint64) 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) Route

func (msg MsgSubmitProposal) Route() string

Route implements Msg

func (MsgSubmitProposal) String

func (msg MsgSubmitProposal) String() string

String implements the Stringer interface

func (MsgSubmitProposal) Type

func (msg MsgSubmitProposal) Type() string

Type implements Msg

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.ValAddress `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.ValAddress, proposalID uint64, option VoteOption) MsgVote

NewMsgVote creates a message to cast a vote on an active proposal

func (MsgVote) GetSignBytes

func (msg MsgVote) GetSignBytes() []byte

GetSignBytes implements Msg

func (MsgVote) GetSigners

func (msg MsgVote) GetSigners() []sdk.AccAddress

GetSigners implements Msg

func (MsgVote) Route

func (msg MsgVote) Route() string

Route implements Msg

func (MsgVote) String

func (msg MsgVote) String() string

String implements the Stringer interface

func (MsgVote) Type

func (msg MsgVote) Type() string

Type implements Msg

func (MsgVote) ValidateBasic

func (msg MsgVote) ValidateBasic() error

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 {
	TallyParams TallyParams `json:"tally_params" yaml:"tally_params"`
}

Params returns all of the governance params

func DefaultParams

func DefaultParams() Params

DefaultParams default governance params

func NewParams

func NewParams(tp TallyParams) Params

NewParams creates a new gov Params instance

func (Params) String

func (gp Params) String() string

type Plan

type Plan struct {
	// Sets the name for the upgrade. This name will be used by the upgraded version of the software to apply any
	// special "on-upgrade" commands during the first BeginBlock method after the upgrade is applied. It is also used
	// to detect whether a software version can handle a given upgrade. If no upgrade handler with this name has been
	// set in the software, it will be assumed that the software is out-of-date when the upgrade Time or Height
	// is reached and the software will exit.
	Name string `json:"name,omitempty"`

	// The time after which the upgrade must be performed.
	// Leave set to its zero value to use a pre-defined Height instead.
	Time time.Time `json:"time,omitempty"`

	// The height at which the upgrade must be performed.
	// Only used if Time is not set.
	Height int64 `json:"height,omitempty"`

	// Any application specific upgrade info to be included on-chain
	// such as a git commit that validators could automatically upgrade to
	Info string `json:"info,omitempty"`

	ToDownload int64 `json:"to_update,omitempty"`
}

Plan specifies information about a planned upgrade and when it should occur

func (Plan) DueAt

func (p Plan) DueAt() string

DueAt is a string representation of when this plan is due to be executed

func (Plan) Mapping

func (p Plan) Mapping() map[string][]string

func (Plan) ShouldExecute

func (p Plan) ShouldExecute(ctx sdk.Context) bool

ShouldExecute returns true if the Plan is ready to execute given the current context

func (Plan) String

func (p Plan) String() string

func (Plan) ValidateBasic

func (p Plan) ValidateBasic() error

ValidateBasic does basic validation of a Plan

type Proposal

type Proposal struct {
	Content

	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

	VotingStartBlock uint64 `json:"voting_start_time" yaml:"voting_start_time"` // Time of the block where MinDeposit was reached. -1 if MinDeposit is not reached
	VotingEndBlock   uint64 `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

func NewProposal(content Content, id, votingStartBlock, VotingEndBlock uint64) Proposal

NewProposal creates a new Proposal instance

func (Proposal) String

func (p Proposal) String() string

String implements stringer interface

type ProposalQueue

type ProposalQueue []uint64

ProposalQueue defines a queue for proposal ids

type ProposalStatus

type ProposalStatus byte

ProposalStatus is a type alias that represents a proposal status as a byte

const (
	StatusNil          ProposalStatus = 0x00
	StatusWaiting      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 Proposals

type Proposals []Proposal

Proposals is an array of proposal

func (Proposals) String

func (p Proposals) String() string

String implements stringer interface

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

type QueryProposalVotesParams struct {
	ProposalID uint64
	Page       int
	Limit      int
}

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

func NewRouter

func NewRouter() Router

NewRouter creates a new Router interface instance

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
}

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 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"`
}

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 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 UpgradeConfig

type UpgradeConfig struct {
	Binaries map[string]string `json:"binaries"`
}

UpgradeConfig is expected format for the info field to allow auto-download

type ValidatorGovInfo

type ValidatorGovInfo struct {
	Address      sdk.ValAddress // address of the validator operator
	BondedTokens sdk.Int        // Power of a Validator
	Vote         VoteOption     // Vote of the validator
}

ValidatorGovInfo used for tallying

func NewValidatorGovInfo

func NewValidatorGovInfo(address sdk.ValAddress, bondedTokens sdk.Int, vote VoteOption) ValidatorGovInfo

NewValidatorGovInfo creates a ValidatorGovInfo instance

type ValidatorKeeper

type ValidatorKeeper interface {
	// iterate through bonded validators by operator address, execute func for each validator
	IterateBondedValidatorsByPower(
		sdk.Context, func(index int64, validator valexported.ValidatorI) (stop bool),
	)

	TotalBondedTokens(sdk.Context) sdk.Int // total bonded tokens within the validator set
	IterateDelegations(
		ctx sdk.Context, delegator sdk.AccAddress,
		fn func(index int64, delegation valexported.DelegationI) (stop bool),
	)

	HasValidator(sdk.Context, sdk.ValAddress) bool
}

StakingKeeper expected staking keeper (Validator and Delegator sets) (noalias)

type Vote

type Vote struct {
	ProposalID uint64         `json:"proposal_id" yaml:"proposal_id"` //  proposalID of the proposal
	Voter      sdk.ValAddress `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.ValAddress, option VoteOption) Vote

NewVote creates a new Vote instance

func (Vote) Empty

func (v Vote) Empty() bool

Empty returns whether a vote is empty.

func (Vote) Equals

func (v Vote) Equals(comp Vote) bool

Equals returns whether two votes are equal.

func (Vote) String

func (v Vote) String() string

type VoteOption

type VoteOption byte

VoteOption defines a vote option

const (
	OptionEmpty   VoteOption = 0x00
	OptionYes     VoteOption = 0x01
	OptionAbstain VoteOption = 0x02
	OptionNo      VoteOption = 0x03
)

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 Votes

type Votes []Vote

Votes is a collection of Vote objects

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