types

package
v0.19.9 Latest Latest
Warning

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

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

Documentation

Overview

nolint

nolint

Index

Constants

View Source
const (
	DefaultCodespace string = ModuleName

	CodeNilDelegatorAddr                            uint32 = 67800
	CodeNoValidatorCommission                       uint32 = 67801
	CodeSetWithdrawAddrDisabled                     uint32 = 67802
	CodeInvalidRoute                                uint32 = 67803
	CodeWithdrawValidatorRewardsAndCommissionFailed uint32 = 67804
	CodeAccAddressFromBech32Failed                  uint32 = 67805
	CodeValAddressFromBech32                        uint32 = 67806
	CodeSendCoinsFromModuleToAccountFailed          uint32 = 67807
	CodeWithdrawValidatorCommissionFailed           uint32 = 67808
	CodeUnknownDistributionMsgType                  uint32 = 67809
	CodeUnknownDistributionCommunityPoolProposaType uint32 = 67810
	CodeUnknownDistributionQueryType                uint32 = 67811
	CodeUnknownDistributionParamType                uint32 = 67812
	CodeWithdrawAddrInBlacklist                     uint32 = 67813
	CodeNilWithdrawAddr                             uint32 = 67814
	CodeNilValidatorAddr                            uint32 = 67815
	CodeBadDistribution                             uint32 = 67816
	CodeInvalidProposalAmount                       uint32 = 67817
	CodeEmptyProposalRecipient                      uint32 = 67818
)
View Source
const (
	EventTypeSetWithdrawAddress = "set_withdraw_address"
	EventTypeCommission         = "commission"
	EventTypeWithdrawCommission = "withdraw_commission"
	EventTypeProposerReward     = "proposer_reward"

	AttributeKeyWithdrawAddress = "withdraw_address"
	AttributeKeyValidator       = "validator"

	AttributeValueCategory = ModuleName
)

distribution module event types

View Source
const (
	// ModuleName is the module name constant used in many places
	ModuleName = "distribution"

	// StoreKey is the store key string for distribution
	StoreKey = ModuleName

	// RouterKey is the message route for distribution
	RouterKey = ModuleName

	// QuerierRoute is the querier route for distribution
	QuerierRoute = ModuleName

	// ShortUseByCli added for exchaincli
	ShortUseByCli = "distr"
)
View Source
const (
	QueryParams              = "params"
	QueryValidatorCommission = "validator_commission"
	QueryWithdrawAddr        = "withdraw_addr"
	QueryCommunityPool       = "community_pool"

	ParamCommunityTax        = "community_tax"
	ParamWithdrawAddrEnabled = "withdraw_addr_enabled"
)

querier keys

View Source
const (
	// default paramspace for params keeper
	DefaultParamspace = ModuleName
)
View Source
const (
	// ProposalTypeCommunityPoolSpend defines the type for a CommunityPoolSpendProposal
	ProposalTypeCommunityPoolSpend = "CommunityPoolSpend"
)

Variables

View Source
var (
	FeePoolKey                           = []byte{0x00} // key for global distribution state
	ProposerKey                          = []byte{0x01} // key for the proposer operator address
	DelegatorWithdrawAddrPrefix          = []byte{0x03} // key for delegator withdraw address
	ValidatorAccumulatedCommissionPrefix = []byte{0x07} // key for accumulated validator commission
)

Keys for distribution store Items are stored with the following key: values

- 0x01: sdk.ConsAddress

- 0x03<accAddr_Bytes>: sdk.AccAddress

- 0x07<valAddr_Bytes>: ValidatorCurrentRewards

View Source
var (
	ParamStoreKeyCommunityTax        = []byte("communitytax")
	ParamStoreKeyWithdrawAddrEnabled = []byte("withdrawaddrenabled")
)

Parameter keys

View Source
var ModuleCdc *codec.Codec

ModuleCdc generic sealed codec to be used throughout module

Functions

func ErrBadDistribution

func ErrBadDistribution() sdk.Error

func ErrEmptyProposalRecipient

func ErrEmptyProposalRecipient() sdk.Error

func ErrInvalidProposalAmount

func ErrInvalidProposalAmount() sdk.Error

func ErrNilDelegatorAddr

func ErrNilDelegatorAddr() sdk.Error

func ErrNilValidatorAddr

func ErrNilValidatorAddr() sdk.Error

func ErrNilWithdrawAddr

func ErrNilWithdrawAddr() sdk.Error

func ErrNoValidatorCommission

func ErrNoValidatorCommission() sdk.Error

func ErrSendCoinsFromModuleToAccountFailed

func ErrSendCoinsFromModuleToAccountFailed() sdk.Error

func ErrSetWithdrawAddrDisabled

func ErrSetWithdrawAddrDisabled() sdk.Error

func ErrUnknownDistributionCommunityPoolProposaType

func ErrUnknownDistributionCommunityPoolProposaType() sdk.Error

func ErrUnknownDistributionMsgType

func ErrUnknownDistributionMsgType() sdk.Error

func ErrUnknownDistributionParamType

func ErrUnknownDistributionParamType() sdk.Error

func ErrUnknownDistributionQueryType

func ErrUnknownDistributionQueryType() sdk.Error

func ErrWithdrawAddrInblacklist

func ErrWithdrawAddrInblacklist() sdk.Error

func ErrWithdrawValidatorCommissionFailed

func ErrWithdrawValidatorCommissionFailed() sdk.Error

func GetDelegatorWithdrawAddrKey

func GetDelegatorWithdrawAddrKey(delAddr sdk.AccAddress) []byte

GetDelegatorWithdrawAddrKey returns the key for a delegator's withdraw addr

func GetDelegatorWithdrawInfoAddress

func GetDelegatorWithdrawInfoAddress(key []byte) (delAddr sdk.AccAddress)

GetDelegatorWithdrawInfoAddress returns an address from a delegator's withdraw info key

func GetValidatorAccumulatedCommissionAddress

func GetValidatorAccumulatedCommissionAddress(key []byte) (valAddr sdk.ValAddress)

GetValidatorAccumulatedCommissionAddress returns the address from a validator's accumulated commission key

func GetValidatorAccumulatedCommissionKey

func GetValidatorAccumulatedCommissionKey(v sdk.ValAddress) []byte

GetValidatorAccumulatedCommissionKey returns the key for a validator's current commission

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamKeyTable returns the parameter key table.

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers concrete types on codec codec

func ValidateGenesis

func ValidateGenesis(gs GenesisState) error

ValidateGenesis validates the genesis state of distribution genesis input

Types

type CommunityPoolSpendProposal

type CommunityPoolSpendProposal struct {
	Title       string         `json:"title" yaml:"title"`
	Description string         `json:"description" yaml:"description"`
	Recipient   sdk.AccAddress `json:"recipient" yaml:"recipient"`
	Amount      sdk.SysCoins   `json:"amount" yaml:"amount"`
}

CommunityPoolSpendProposal spends from the community pool

func NewCommunityPoolSpendProposal

func NewCommunityPoolSpendProposal(title, description string, recipient sdk.AccAddress, amount sdk.SysCoins) CommunityPoolSpendProposal

NewCommunityPoolSpendProposal creates a new community pool spned proposal.

func (CommunityPoolSpendProposal) GetDescription

func (csp CommunityPoolSpendProposal) GetDescription() string

GetDescription returns the description of a community pool spend proposal.

func (CommunityPoolSpendProposal) GetTitle

func (csp CommunityPoolSpendProposal) GetTitle() string

GetTitle returns the title of a community pool spend proposal.

func (CommunityPoolSpendProposal) ProposalRoute

func (csp CommunityPoolSpendProposal) ProposalRoute() string

GetDescription returns the routing key of a community pool spend proposal.

func (CommunityPoolSpendProposal) ProposalType

func (csp CommunityPoolSpendProposal) ProposalType() string

ProposalType returns the type of a community pool spend proposal.

func (CommunityPoolSpendProposal) String

func (csp CommunityPoolSpendProposal) String() string

String implements the Stringer interface.

func (CommunityPoolSpendProposal) ValidateBasic

func (csp CommunityPoolSpendProposal) ValidateBasic() error

ValidateBasic runs basic stateless validity checks

type DelegatorWithdrawInfo

type DelegatorWithdrawInfo struct {
	DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"`
	WithdrawAddress  sdk.AccAddress `json:"withdraw_address" yaml:"withdraw_address"`
}

DelegatorWithdrawInfo is the address for where distributions rewards are withdrawn to by default this struct is only used at genesis to feed in default withdraw addresses

type FeePool

type FeePool struct {
	CommunityPool sdk.SysCoins `json:"community_pool" yaml:"community_pool"` // pool for community funds yet to be spent
}

FeePool is the struct of the global fee pool for distribution

func InitialFeePool

func InitialFeePool() FeePool

InitialFeePool zero fee pool

func (FeePool) ValidateGenesis

func (f FeePool) ValidateGenesis() error

ValidateGenesis validates the fee pool for a genesis state

type GenesisState

type GenesisState struct {
	Params                          Params                                 `json:"params" yaml:"params"`
	FeePool                         FeePool                                `json:"fee_pool" yaml:"fee_pool"`
	DelegatorWithdrawInfos          []DelegatorWithdrawInfo                `json:"delegator_withdraw_infos" yaml:"delegator_withdraw_infos"`
	PreviousProposer                sdk.ConsAddress                        `json:"previous_proposer" yaml:"previous_proposer"`
	ValidatorAccumulatedCommissions []ValidatorAccumulatedCommissionRecord `json:"validator_accumulated_commissions" yaml:"validator_accumulated_commissions"`
}

GenesisState - all distribution state that must be provided at genesis

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState returns default genesis

func NewGenesisState

func NewGenesisState(params Params, feePool FeePool,
	dwis []DelegatorWithdrawInfo, pp sdk.ConsAddress, acc []ValidatorAccumulatedCommissionRecord) GenesisState

NewGenesisState creates a new object of GenesisState

type MsgSetWithdrawAddress

type MsgSetWithdrawAddress struct {
	DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"`
	WithdrawAddress  sdk.AccAddress `json:"withdraw_address" yaml:"withdraw_address"`
}

msg struct for changing the withdraw address for a delegator (or validator self-delegation)

func NewMsgSetWithdrawAddress

func NewMsgSetWithdrawAddress(delAddr, withdrawAddr sdk.AccAddress) MsgSetWithdrawAddress

func (MsgSetWithdrawAddress) GetSignBytes

func (msg MsgSetWithdrawAddress) GetSignBytes() []byte

get the bytes for the message signer to sign on

func (MsgSetWithdrawAddress) GetSigners

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

Return address that must sign over msg.GetSignBytes()

func (MsgSetWithdrawAddress) Route

func (msg MsgSetWithdrawAddress) Route() string

func (MsgSetWithdrawAddress) Type

func (msg MsgSetWithdrawAddress) Type() string

func (MsgSetWithdrawAddress) ValidateBasic

func (msg MsgSetWithdrawAddress) ValidateBasic() sdk.Error

quick validity check

type MsgWithdrawValidatorCommission

type MsgWithdrawValidatorCommission struct {
	ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"`
}

msg struct for validator withdraw

func NewMsgWithdrawValidatorCommission

func NewMsgWithdrawValidatorCommission(valAddr sdk.ValAddress) MsgWithdrawValidatorCommission

func (MsgWithdrawValidatorCommission) GetSignBytes

func (msg MsgWithdrawValidatorCommission) GetSignBytes() []byte

get the bytes for the message signer to sign on

func (MsgWithdrawValidatorCommission) GetSigners

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

Return address that must sign over msg.GetSignBytes()

func (MsgWithdrawValidatorCommission) Route

func (MsgWithdrawValidatorCommission) Type

func (MsgWithdrawValidatorCommission) ValidateBasic

func (msg MsgWithdrawValidatorCommission) ValidateBasic() sdk.Error

quick validity check

type Params

type Params struct {
	CommunityTax        sdk.Dec `json:"community_tax" yaml:"community_tax"`
	WithdrawAddrEnabled bool    `json:"withdraw_addr_enabled" yaml:"withdraw_addr_enabled"`
}

Params defines the set of distribution parameters.

func DefaultParams

func DefaultParams() Params

DefaultParams returns default distribution parameters

func NewParams

func NewParams(communityTax sdk.Dec, withdrawAddrEnabled bool) Params

NewParams creates a new instance of Params

func (Params) MarshalYAML

func (p Params) MarshalYAML() (interface{}, error)

MarshalYAML implements the text format for yaml marshaling

func (*Params) ParamSetPairs

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

ParamSetPairs returns the parameter set pairs.

func (Params) String

func (p Params) String() string

String returns a human readable string representation of Params

func (Params) ValidateBasic

func (p Params) ValidateBasic() error

ValidateBasic performs basic validation on distribution parameters.

type QueryDelegatorWithdrawAddrParams

type QueryDelegatorWithdrawAddrParams struct {
	DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"`
}

QueryDelegatorWithdrawAddrParams is the struct of params for query 'custom/distr/withdraw_addr'

func NewQueryDelegatorWithdrawAddrParams

func NewQueryDelegatorWithdrawAddrParams(delegatorAddr sdk.AccAddress) QueryDelegatorWithdrawAddrParams

NewQueryDelegatorWithdrawAddrParams creates a new instance of QueryDelegatorWithdrawAddrParams.

type QueryValidatorCommissionParams

type QueryValidatorCommissionParams struct {
	ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"`
}

QueryValidatorCommissionParams is the struct of params for query 'custom/distr/validator_commission'

func NewQueryValidatorCommissionParams

func NewQueryValidatorCommissionParams(validatorAddr sdk.ValAddress) QueryValidatorCommissionParams

NewQueryValidatorCommissionParams creates a new instance of QueryValidatorCommissionParams

type StakingHooks

type StakingHooks interface {
	// Must be called when a validator is created
	AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress)
	// Must be called when a validator is deleted
	AfterValidatorRemoved(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress)
	// Must be called when a delegation is created
	BeforeDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress)
	// Must be called when a delegation's shares are modified
	BeforeDelegationSharesModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress)
	AfterDelegationModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress)
	BeforeValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, fraction sdk.Dec)
}

StakingHooks event hooks for staking validator object (noalias)

type StakingKeeper

type StakingKeeper interface {
	// iterate through validators by operator address, execute func for each validator
	IterateValidators(sdk.Context,
		func(index int64, validator stakingexported.ValidatorI) (stop bool))

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

	// iterate through the consensus validator set of the last block by operator address
	// execute func for each validator
	IterateLastValidators(sdk.Context,
		func(index int64, validator stakingexported.ValidatorI) (stop bool))

	// get a particular validator by operator address
	Validator(sdk.Context, sdk.ValAddress) stakingexported.ValidatorI
	// get a particular validator by consensus address
	ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) stakingexported.ValidatorI

	Jail(sdk.Context, sdk.ConsAddress)   // jail a validator
	Unjail(sdk.Context, sdk.ConsAddress) // unjail a validator

	// MaxValidators returns the maximum amount of bonded validators
	MaxValidators(sdk.Context) uint16

	GetLastTotalPower(ctx sdk.Context) sdk.Int
	GetLastValidatorPower(ctx sdk.Context, valAddr sdk.ValAddress) int64
}

StakingKeeper expected staking keeper (noalias)

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)

	SendCoinsFromModuleToModule(ctx sdk.Context, senderModule string, recipientModule string, amt sdk.Coins) error
	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
}

SupplyKeeper defines the expected supply Keeper (noalias)

type ValidatorAccumulatedCommission

type ValidatorAccumulatedCommission = sdk.SysCoins

ValidatorAccumulatedCommission is the accumulated commission for a validator kept as a running counter, can be withdrawn at any time

func InitialValidatorAccumulatedCommission

func InitialValidatorAccumulatedCommission() ValidatorAccumulatedCommission

InitialValidatorAccumulatedCommission returns the initial accumulated commission (zero)

type ValidatorAccumulatedCommissionRecord

type ValidatorAccumulatedCommissionRecord struct {
	ValidatorAddress sdk.ValAddress                 `json:"validator_address" yaml:"validator_address"`
	Accumulated      ValidatorAccumulatedCommission `json:"accumulated" yaml:"accumulated"`
}

ValidatorAccumulatedCommissionRecord is used for import / export via genesis json

Jump to

Keyboard shortcuts

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