v14

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModuleName                           = "committee"
	RouterKey                            = ModuleName // RouterKey Top level router key
	MaxCommitteeDescriptionLength int    = 512
	DefaultNextProposalID         uint64 = 1                            // DefaultNextProposalID is the starting poiint for proposal IDs
	TypeMsgSubmitProposal                = "commmittee_submit_proposal" // 'committee' prefix appended to avoid potential conflicts with gov msg types
	TypeMsgVote                          = "committee_vote"
)

Variables

View Source
var (
	ErrInvalidPubProposal = sdkerrors.New(ModuleName, 6, "invalid pubproposal") // Declare custom error type, but don't register it here
	ModuleCdc             *codec.Codec                                          // ModuleCdc is a generic codec to be used throughout module

)

Functions

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers the necessary types for the module

Types

type AllowedAssetParam

type AllowedAssetParam struct {
	Denom         string `json:"denom" yaml:"denom"`
	CoinID        bool   `json:"coin_id" yaml:"coin_id"`
	Limit         bool   `json:"limit" yaml:"limit"`
	Active        bool   `json:"active" yaml:"active"`
	MaxSwapAmount bool   `json:"max_swap_amount" yaml:"max_swap_amount"`
	MinBlockLock  bool   `json:"min_block_lock" yaml:"min_block_lock"`
}

AllowedAssetParam bep3 asset parameters that can be changed by committee

func (AllowedAssetParam) Allows

func (aap AllowedAssetParam) Allows(current, incoming bep3types.AssetParam) bool

Allows bep3 AssetParam parameters than can be changed by committee

type AllowedAssetParams

type AllowedAssetParams []AllowedAssetParam

AllowedAssetParams slice of AllowedAssetParam

func (AllowedAssetParams) Allows

func (aaps AllowedAssetParams) Allows(current, incoming bep3types.AssetParams) bool

Allows determines if asset params changes are permitted

type AllowedCollateralParam

type AllowedCollateralParam struct {
	Type                             string `json:"type" yaml:"type"`
	Denom                            bool   `json:"denom" yaml:"denom"`
	LiquidationRatio                 bool   `json:"liquidation_ratio" yaml:"liquidation_ratio"`
	DebtLimit                        bool   `json:"debt_limit" yaml:"debt_limit"`
	StabilityFee                     bool   `json:"stability_fee" yaml:"stability_fee"`
	AuctionSize                      bool   `json:"auction_size" yaml:"auction_size"`
	LiquidationPenalty               bool   `json:"liquidation_penalty" yaml:"liquidation_penalty"`
	Prefix                           bool   `json:"prefix" yaml:"prefix"`
	SpotMarketID                     bool   `json:"spot_market_id" yaml:"spot_market_id"`
	LiquidationMarketID              bool   `json:"liquidation_market_id" yaml:"liquidation_market_id"`
	ConversionFactor                 bool   `json:"conversion_factor" yaml:"conversion_factor"`
	KeeperRewardPercentage           bool   `json:"keeper_reward_percentage" yaml:"keeper_reward_percentage"`
	CheckCollateralizationIndexCount bool   `json:"check_collateralization_index_count" yaml:"check_collateralization_index_count"`
}

AllowedCollateralParam permission struct for changes to collateral parameter keys (cdp module)

func NewAllowedCollateralParam

func NewAllowedCollateralParam(
	ctype string, denom, liqRatio, debtLimit,
	stabilityFee, auctionSize, liquidationPenalty,
	prefix, spotMarket, liquidationMarket, conversionFactor, keeperReward, ltvIndexCount bool) AllowedCollateralParam

NewAllowedCollateralParam return a new AllowedCollateralParam

func (AllowedCollateralParam) Allows

func (acp AllowedCollateralParam) Allows(current, incoming v0_14cdp.CollateralParam) bool

Allows determine if collateral param changes are permitted

type AllowedCollateralParams

type AllowedCollateralParams []AllowedCollateralParam

AllowedCollateralParams slice of AllowedCollateralParam

func (AllowedCollateralParams) Allows

func (acps AllowedCollateralParams) Allows(current, incoming v0_14cdp.CollateralParams) bool

Allows determine if collateral params changes are permitted

type AllowedDebtParam

type AllowedDebtParam struct {
	Denom            bool `json:"denom" yaml:"denom"`
	ReferenceAsset   bool `json:"reference_asset" yaml:"reference_asset"`
	ConversionFactor bool `json:"conversion_factor" yaml:"conversion_factor"`
	DebtFloor        bool `json:"debt_floor" yaml:"debt_floor"`
}

AllowedDebtParam permission struct for changes to debt parameter keys (cdp module)

func (AllowedDebtParam) Allows

func (adp AllowedDebtParam) Allows(current, incoming v0_14cdp.DebtParam) bool

Allows determines if debt params changes are permitted

type AllowedMarket

type AllowedMarket struct {
	MarketID   string `json:"market_id" yaml:"market_id"`
	BaseAsset  bool   `json:"base_asset" yaml:"base_asset"`
	QuoteAsset bool   `json:"quote_asset" yaml:"quote_asset"`
	Oracles    bool   `json:"oracles" yaml:"oracles"`
	Active     bool   `json:"active" yaml:"active"`
}

AllowedMarket permission struct for market parameters (pricefeed module)

func (AllowedMarket) Allows

func (am AllowedMarket) Allows(current, incoming pricefeedtypes.Market) bool

Allows determines if market param changes are permitted

type AllowedMarkets

type AllowedMarkets []AllowedMarket

AllowedMarkets slice of AllowedMarket

func (AllowedMarkets) Allows

func (ams AllowedMarkets) Allows(current, incoming pricefeedtypes.Markets) bool

Allows determines if markets params changed are permitted

type AllowedMoneyMarket

type AllowedMoneyMarket struct {
	Denom                  string `json:"denom" yaml:"denom"`
	BorrowLimit            bool   `json:"borrow_limit" yaml:"borrow_limit"`
	SpotMarketID           bool   `json:"spot_market_id" yaml:"spot_market_id"`
	ConversionFactor       bool   `json:"conversion_factor" yaml:"conversion_factor"`
	InterestRateModel      bool   `json:"interest_rate_model" yaml:"interest_rate_model"`
	ReserveFactor          bool   `json:"reserve_factor" yaml:"reserve_factor"`
	KeeperRewardPercentage bool   `json:"keeper_reward_percentage" yaml:"keeper_reward_percentage"`
}

AllowedMoneyMarket permission struct for money market parameters (hard module)

func NewAllowedMoneyMarket

func NewAllowedMoneyMarket(denom string, bl, sm, cf, irm, rf, kr bool) AllowedMoneyMarket

NewAllowedMoneyMarket returns a new AllowedMoneyMarket

func (AllowedMoneyMarket) Allows

func (amm AllowedMoneyMarket) Allows(current, incoming hard.MoneyMarket) bool

Allows determines if money market param changes are permitted

type AllowedMoneyMarkets

type AllowedMoneyMarkets []AllowedMoneyMarket

AllowedMoneyMarkets slice of AllowedMoneyMarket

func (AllowedMoneyMarkets) Allows

func (amms AllowedMoneyMarkets) Allows(current, incoming hard.MoneyMarkets) bool

Allows determins if money market params changes are permitted

type AllowedParam

type AllowedParam struct {
	Subspace string `json:"subspace" yaml:"subspace"`
	Key      string `json:"key" yaml:"key"`
}

AllowedParam permission type for module parameter keys

type AllowedParams

type AllowedParams []AllowedParam

AllowedParams slice of AllowedParam

func (AllowedParams) Contains

func (allowed AllowedParams) Contains(paramChange paramstypes.ParamChange) bool

Contains checks if a key is included in param permissions

type Committee

type Committee struct {
	ID               uint64           `json:"id" yaml:"id"`
	Description      string           `json:"description" yaml:"description"`
	Members          []sdk.AccAddress `json:"members" yaml:"members"`
	Permissions      []Permission     `json:"permissions" yaml:"permissions"`
	VoteThreshold    sdk.Dec          `json:"vote_threshold" yaml:"vote_threshold"`       // Smallest percentage of members that must vote for a proposal to pass.
	ProposalDuration time.Duration    `json:"proposal_duration" yaml:"proposal_duration"` // The length of time a proposal remains active for. Proposals will close earlier if they get enough votes.
}

A Committee is a collection of addresses that are allowed to vote and enact any governance proposal that passes their permissions.

func NewCommittee

func NewCommittee(id uint64, description string, members []sdk.AccAddress, permissions []Permission, threshold sdk.Dec, duration time.Duration) Committee

func (Committee) HasMember

func (c Committee) HasMember(addr sdk.AccAddress) bool

func (Committee) HasPermissionsFor

func (c Committee) HasPermissionsFor(ctx sdk.Context, appCdc *codec.Codec, pk ParamKeeper, proposal PubProposal) bool

HasPermissionsFor returns whether the committee is authorized to enact a proposal. As long as one permission allows the proposal then it goes through. Its the OR of all permissions.

func (Committee) Validate

func (c Committee) Validate() error

type GenesisState

type GenesisState struct {
	NextProposalID uint64      `json:"next_proposal_id" yaml:"next_proposal_id"`
	Committees     []Committee `json:"committees" yaml:"committees"`
	Proposals      []Proposal  `json:"proposals" yaml:"proposals"`
	Votes          []Vote      `json:"votes" yaml:"votes"`
}

GenesisState is state that must be provided at chain genesis.

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState returns the default genesis state for the module.

func NewGenesisState

func NewGenesisState(nextProposalID uint64, committees []Committee, proposals []Proposal, votes []Vote) GenesisState

NewGenesisState returns a new genesis state object for the 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

func (GenesisState) Validate

func (gs GenesisState) Validate() error

Validate performs basic validation of genesis data.

type GodPermission

type GodPermission struct{}

GodPermission allows any governance proposal. It is used mainly for testing.

func (GodPermission) Allows

Allows implement permission interface

func (GodPermission) MarshalYAML

func (GodPermission) MarshalYAML() (interface{}, error)

MarshalYAML implement yaml marshalling

type MsgSubmitProposal

type MsgSubmitProposal struct {
	PubProposal PubProposal    `json:"pub_proposal" yaml:"pub_proposal"`
	Proposer    sdk.AccAddress `json:"proposer" yaml:"proposer"`
	CommitteeID uint64         `json:"committee_id" yaml:"committee_id"`
}

MsgSubmitProposal is used by committee members to create a new proposal that they can vote on.

func NewMsgSubmitProposal

func NewMsgSubmitProposal(pubProposal PubProposal, proposer sdk.AccAddress, committeeID uint64) MsgSubmitProposal

NewMsgSubmitProposal creates a new MsgSubmitProposal instance

func (MsgSubmitProposal) GetSignBytes

func (msg MsgSubmitProposal) GetSignBytes() []byte

GetSignBytes gets the canonical byte representation of the Msg.

func (MsgSubmitProposal) GetSigners

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

GetSigners returns the addresses of signers that must sign.

func (MsgSubmitProposal) Route

func (msg MsgSubmitProposal) Route() string

Route return the message type used for routing the message.

func (MsgSubmitProposal) Type

func (msg MsgSubmitProposal) Type() string

Type returns a human-readable string for the message, intended for utilization within events.

func (MsgSubmitProposal) ValidateBasic

func (msg MsgSubmitProposal) ValidateBasic() error

ValidateBasic does a simple validation check that doesn't require access to any other information.

type MsgVote

type MsgVote struct {
	ProposalID uint64         `json:"proposal_id" yaml:"proposal_id"`
	Voter      sdk.AccAddress `json:"voter" yaml:"voter"`
}

MsgVote is submitted by committee members to vote on proposals.

func NewMsgVote

func NewMsgVote(voter sdk.AccAddress, proposalID uint64) MsgVote

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

func (MsgVote) GetSignBytes

func (msg MsgVote) GetSignBytes() []byte

GetSignBytes gets the canonical byte representation of the Msg.

func (MsgVote) GetSigners

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

GetSigners returns the addresses of signers that must sign.

func (MsgVote) Route

func (msg MsgVote) Route() string

Route return the message type used for routing the message.

func (MsgVote) Type

func (msg MsgVote) Type() string

Type returns a human-readable string for the message, intended for utilization within events.

func (MsgVote) ValidateBasic

func (msg MsgVote) ValidateBasic() error

ValidateBasic does a simple validation check that doesn't require access to any other information.

type ParamKeeper

type ParamKeeper interface {
	GetSubspace(string) (params.Subspace, bool)
}

type Permission

type Permission interface {
	Allows(sdk.Context, *codec.Codec, ParamKeeper, PubProposal) bool
}

Permission is anything with a method that validates whether a proposal is allowed by it or not.

type Proposal

type Proposal struct {
	PubProposal `json:"pub_proposal" yaml:"pub_proposal"`
	ID          uint64    `json:"id" yaml:"id"`
	CommitteeID uint64    `json:"committee_id" yaml:"committee_id"`
	Deadline    time.Time `json:"deadline" yaml:"deadline"`
}

Proposal is an internal record of a governance proposal submitted to a committee.

func NewProposal

func NewProposal(pubProposal PubProposal, id uint64, committeeID uint64, deadline time.Time) Proposal

func (Proposal) HasExpiredBy

func (p Proposal) HasExpiredBy(time time.Time) bool

HasExpiredBy calculates if the proposal will have expired by a certain time. All votes must be cast before deadline, those cast at time == deadline are not valid

func (Proposal) String

func (p Proposal) String() string

String implements the fmt.Stringer interface, and importantly overrides the String methods inherited from the embedded PubProposal type.

type PubProposal

type PubProposal govtypes.Content

PubProposal is the interface that all proposals must fulfill to be submitted to a committee. Proposal types can be created external to this module. For example a ParamChangeProposal, or CommunityPoolSpendProposal. It is pinned to the equivalent type in the gov module to create compatibility between proposal types.

type SimpleParamChangePermission

type SimpleParamChangePermission struct {
	AllowedParams AllowedParams `json:"allowed_params" yaml:"allowed_params"`
}

SimpleParamChangePermission only allows changes to certain params

func (SimpleParamChangePermission) Allows

Allows implement permission interface

func (SimpleParamChangePermission) MarshalYAML

func (perm SimpleParamChangePermission) MarshalYAML() (interface{}, error)

MarshalYAML implement yaml marshalling

type SoftwareUpgradePermission

type SoftwareUpgradePermission struct{}

SoftwareUpgradePermission permission type for software upgrade proposals

func (SoftwareUpgradePermission) Allows

Allows implement permission interface

func (SoftwareUpgradePermission) MarshalYAML

func (SoftwareUpgradePermission) MarshalYAML() (interface{}, error)

MarshalYAML implement yaml marshalling

type SubParamChangePermission

type SubParamChangePermission struct {
	AllowedParams           AllowedParams           `json:"allowed_params" yaml:"allowed_params"`
	AllowedCollateralParams AllowedCollateralParams `json:"allowed_collateral_params" yaml:"allowed_collateral_params"`
	AllowedDebtParam        AllowedDebtParam        `json:"allowed_debt_param" yaml:"allowed_debt_param"`
	AllowedAssetParams      AllowedAssetParams      `json:"allowed_asset_params" yaml:"allowed_asset_params"`
	AllowedMarkets          AllowedMarkets          `json:"allowed_markets" yaml:"allowed_markets"`
	AllowedMoneyMarkets     AllowedMoneyMarkets     `json:"allowed_money_markets" yaml:"allowed_money_markets"`
}

SubParamChangePermission permission type for allowing changes to specific sub-keys within module parameter keys

func (SubParamChangePermission) Allows

func (perm SubParamChangePermission) Allows(ctx sdk.Context, appCdc *codec.Codec, pk ParamKeeper, p PubProposal) bool

Allows implement permission interface

func (SubParamChangePermission) MarshalYAML

func (perm SubParamChangePermission) MarshalYAML() (interface{}, error)

MarshalYAML implement yaml marshalling

type TextPermission

type TextPermission struct{}

TextPermission allows any text governance proposal.

func (TextPermission) Allows

Allows implement permission interface

func (TextPermission) MarshalYAML

func (TextPermission) MarshalYAML() (interface{}, error)

MarshalYAML implement yaml marshalling

type Vote

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

func NewVote

func NewVote(proposalID uint64, voter sdk.AccAddress) Vote

func (Vote) Validate

func (v Vote) Validate() error

Jump to

Keyboard shortcuts

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