types

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

nolint

nolint

Index

Constants

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 okexchaincli
	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 (
	// ProposalTypeCommunityPoolSpend defines the type for a CommunityPoolSpendProposal
	ProposalTypeCommunityPoolSpend = "CommunityPoolSpend"
)

Variables

View Source
var ModuleCdc *codec.Codec

ModuleCdc generic sealed codec to be used throughout module

Functions

func ErrBadDistribution

func ErrBadDistribution(codespace sdk.CodespaceType) sdk.Error

func ErrEmptyProposalRecipient

func ErrEmptyProposalRecipient(codespace sdk.CodespaceType) sdk.Error

func ErrInvalidProposalAmount

func ErrInvalidProposalAmount(codespace sdk.CodespaceType) sdk.Error

func ErrNilDelegatorAddr

func ErrNilDelegatorAddr(codespace sdk.CodespaceType) sdk.Error

func ErrNilValidatorAddr

func ErrNilValidatorAddr(codespace sdk.CodespaceType) sdk.Error

func ErrNilWithdrawAddr

func ErrNilWithdrawAddr(codespace sdk.CodespaceType) sdk.Error

func ErrNoValidatorCommission

func ErrNoValidatorCommission(codespace sdk.CodespaceType) sdk.Error

func ErrSetWithdrawAddrDisabled

func ErrSetWithdrawAddrDisabled(codespace sdk.CodespaceType) sdk.Error

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers concrete types on codec codec

func ValidateGenesis

func ValidateGenesis(data GenesisState) error

ValidateGenesis validates the genesis state of distribution genesis input

Types

type CodeType

type CodeType = sdk.CodeType
const (
	DefaultCodespace            sdk.CodespaceType = "distr"
	CodeInvalidInput            CodeType          = 103
	CodeNoValidatorCommission   CodeType          = 105
	CodeSetWithdrawAddrDisabled CodeType          = 106
)

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.Coins      `json:"amount" yaml:"amount"`
}

CommunityPoolSpendProposal spends from the community pool

func NewCommunityPoolSpendProposal

func NewCommunityPoolSpendProposal(title, description string, recipient sdk.AccAddress, amount sdk.Coins) 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() sdk.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.DecCoins `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 {
	FeePool                         FeePool                                `json:"fee_pool" yaml:"fee_pool"`
	CommunityTax                    sdk.Dec                                `json:"community_tax" yaml:"community_tax"`
	WithdrawAddrEnabled             bool                                   `json:"withdraw_addr_enabled" yaml:"withdraw_addr_enabled"`
	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(feePool FeePool, communityTax sdk.Dec,
	withdrawAddrEnabled bool, 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"`
	WithdrawAddrEnabled bool    `json:"withdraw_addr_enabled"`
}

Params - structure for params query

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

func (p Params) String() string

String returns a human readable string representation of Params

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) sdk.Error
	SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string,
		recipientAddr sdk.AccAddress, amt sdk.Coins) sdk.Error
	SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress,
		recipientModule string, amt sdk.Coins) sdk.Error
}

SupplyKeeper defines the expected supply Keeper (noalias)

type ValidatorAccumulatedCommission

type ValidatorAccumulatedCommission = sdk.DecCoins

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