types

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventTypeSetWithdrawAddress = "set_withdraw_address"
	EventTypeRewards            = "rewards"
	EventTypeCommission         = "commission"
	EventTypeWithdrawRewards    = "withdraw_rewards"
	EventTypeWithdrawCommission = "withdraw_commission"
	EventTypeProposerReward     = "proposer_reward"

	AttributeKeyWithdrawAddress = "withdraw_address"
	AttributeKeyValidator       = "validator"
	AttributeKeyDelegator       = "delegator"
	AttributeKeyEmission        = "emission"
)

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
)
View Source
const (
	QueryParams                      = "params"
	QueryValidatorOutstandingRewards = "validator_outstanding_rewards"
	QueryValidatorCommission         = "validator_commission"
	QueryValidatorSlashes            = "validator_slashes"
	QueryDelegationRewards           = "delegation_rewards"
	QueryDelegatorTotalRewards       = "delegator_total_rewards"
	QueryDelegatorValidators         = "delegator_validators"
	QueryWithdrawAddr                = "withdraw_addr"
	QueryCommunityPool               = "community_pool"
)

querier keys

Variables

View Source
var (
	ErrEmptyDelegatorAddr      = types.ErrEmptyDelegatorAddr
	ErrEmptyWithdrawAddr       = types.ErrEmptyWithdrawAddr
	ErrEmptyValidatorAddr      = types.ErrEmptyValidatorAddr
	ErrEmptyDelegationDistInfo = types.ErrEmptyDelegationDistInfo
	ErrNoValidatorDistInfo     = types.ErrNoValidatorDistInfo
	ErrNoValidatorCommission   = types.ErrNoValidatorCommission
	ErrSetWithdrawAddrDisabled = types.ErrSetWithdrawAddrDisabled
	ErrBadDistribution         = types.ErrBadDistribution
	ErrInvalidProposalAmount   = types.ErrInvalidProposalAmount
	ErrEmptyProposalRecipient  = types.ErrEmptyProposalRecipient
	ErrNoValidatorExists       = types.ErrNoValidatorExists
	ErrNoDelegationExists      = types.ErrNoDelegationExists
)

x/distribution module sentinel errors

View Source
var (
	FeePoolKey                        = collections.NewPrefix(0) // key for global distribution state
	ProposerKey                       = []byte{0x01}             // key for the proposer operator address
	ValidatorOutstandingRewardsPrefix = []byte{0x02}             // key for outstanding rewards

	DelegatorWithdrawAddrPrefix          = []byte{0x03} // key for delegator withdraw address
	DelegatorStartingInfoPrefix          = []byte{0x04} // key for delegator starting info
	ValidatorHistoricalRewardsPrefix     = []byte{0x05} // key for historical validators rewards / stake
	ValidatorCurrentRewardsPrefix        = []byte{0x06} // key for current validator rewards
	ValidatorAccumulatedCommissionPrefix = []byte{0x07} // key for accumulated validator commission
	ValidatorSlashEventPrefix            = []byte{0x08} // key for validator slash fraction

	ParamsKey = collections.NewPrefix(9) // key for distribution module params
)

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

- 0x00<proposalID_Bytes>: FeePol

- 0x01: sdk.ConsAddress

- 0x02<valAddrLen (1 Byte)><valAddr_Bytes>: ValidatorOutstandingRewards

- 0x03<accAddrLen (1 Byte)><accAddr_Bytes>: sdk.AccAddress

- 0x04<valAddrLen (1 Byte)><valAddr_Bytes><accAddrLen (1 Byte)><accAddr_Bytes>: DelegatorStartingInfo

- 0x05<valAddrLen (1 Byte)><valAddr_Bytes><period_Bytes>: ValidatorHistoricalRewards

- 0x06<valAddrLen (1 Byte)><valAddr_Bytes>: ValidatorCurrentRewards

- 0x07<valAddrLen (1 Byte)><valAddr_Bytes>: ValidatorCurrentCommission

- 0x08<valAddrLen (1 Byte)><valAddr_Bytes><height>: ValidatorSlashEvent

- 0x09: Params

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

Parameter keys

Functions

func GetDelegatorStartingInfoAddresses

func GetDelegatorStartingInfoAddresses(key []byte) (valAddr sdk.ValAddress, delAddr sdk.AccAddress)

GetDelegatorStartingInfoAddresses creates the addresses from a delegator starting info key.

func GetDelegatorStartingInfoKey

func GetDelegatorStartingInfoKey(v sdk.ValAddress, d sdk.AccAddress) []byte

GetDelegatorStartingInfoKey creates the key for a delegator's starting info.

func GetDelegatorWithdrawAddrKey

func GetDelegatorWithdrawAddrKey(delAddr sdk.AccAddress) []byte

GetDelegatorWithdrawAddrKey creates the key for a delegator's withdraw addr.

func GetDelegatorWithdrawInfoAddress

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

GetDelegatorWithdrawInfoAddress creates an address from a delegator's withdraw info key.

func GetValidatorAccumulatedCommissionAddress

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

GetValidatorAccumulatedCommissionAddress creates the address from a validator's accumulated commission key.

func GetValidatorAccumulatedCommissionKey

func GetValidatorAccumulatedCommissionKey(v sdk.ValAddress) []byte

GetValidatorAccumulatedCommissionKey creates the key for a validator's current commission.

func GetValidatorCurrentRewardsAddress

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

GetValidatorCurrentRewardsAddress creates the address from a validator's current rewards key.

func GetValidatorCurrentRewardsKey

func GetValidatorCurrentRewardsKey(v sdk.ValAddress) []byte

GetValidatorCurrentRewardsKey creates the key for a validator's current rewards.

func GetValidatorHistoricalRewardsAddressPeriod

func GetValidatorHistoricalRewardsAddressPeriod(key []byte) (valAddr sdk.ValAddress, period uint64)

GetValidatorHistoricalRewardsAddressPeriod creates the address & period from a validator's historical rewards key.

func GetValidatorHistoricalRewardsKey

func GetValidatorHistoricalRewardsKey(v sdk.ValAddress, k uint64) []byte

GetValidatorHistoricalRewardsKey creates the key for a validator's historical rewards.

func GetValidatorHistoricalRewardsPrefix

func GetValidatorHistoricalRewardsPrefix(v sdk.ValAddress) []byte

GetValidatorHistoricalRewardsPrefix creates the prefix key for a validator's historical rewards.

func GetValidatorOutstandingRewardsAddress

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

GetValidatorOutstandingRewardsAddress creates an address from a validator's outstanding rewards key.

func GetValidatorOutstandingRewardsKey

func GetValidatorOutstandingRewardsKey(valAddr sdk.ValAddress) []byte

GetValidatorOutstandingRewardsKey creates the outstanding rewards key for a validator.

func GetValidatorSlashEventAddressHeight

func GetValidatorSlashEventAddressHeight(key []byte) (valAddr sdk.ValAddress, height uint64)

GetValidatorSlashEventAddressHeight creates the height from a validator's slash event key.

func GetValidatorSlashEventKey

func GetValidatorSlashEventKey(v sdk.ValAddress, height, period uint64) []byte

GetValidatorSlashEventKey creates the key for a validator's slash fraction.

func GetValidatorSlashEventKeyPrefix

func GetValidatorSlashEventKeyPrefix(v sdk.ValAddress, height uint64) []byte

GetValidatorSlashEventKeyPrefix creates the prefix key for a validator's slash fraction (ValidatorSlashEventPrefix + height).

func GetValidatorSlashEventPrefix

func GetValidatorSlashEventPrefix(v sdk.ValAddress) []byte

GetValidatorSlashEventPrefix creates the prefix key for a validator's slash fractions.

func ParamKeyTable deprecated

func ParamKeyTable() paramtypes.KeyTable

Deprecated: ParamKeyTable returns the parameter key table.

func RegisterInterfaces

func RegisterInterfaces(registry types.InterfaceRegistry)

func RegisterLegacyAminoCodec

func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino)

RegisterLegacyAminoCodec registers the necessary x/distribution interfaces and concrete types on the provided LegacyAmino codec. These types are used for Amino JSON serialization.

func ValidateGenesis

func ValidateGenesis(gs *GenesisState) error

ValidateGenesis validates the genesis state of distribution genesis input

Types

type AccountKeeper

type AccountKeeper interface {
	AddressCodec() address.Codec
	GetAccount(ctx context.Context, addr sdk.AccAddress) sdk.AccountI
	GetModuleAddress(name string) sdk.AccAddress
	GetModuleAccount(ctx context.Context, name string) sdk.ModuleAccountI
	// TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862
	SetModuleAccount(context.Context, sdk.ModuleAccountI)
}

AccountKeeper defines the expected account keeper used for simulations (noalias)

type BankKeeper

type BankKeeper interface {
	GetAllBalances(ctx context.Context, addr sdk.AccAddress) sdk.Coins

	SpendableCoins(ctx context.Context, addr sdk.AccAddress) sdk.Coins

	SendCoinsFromModuleToModule(ctx context.Context, senderModule, recipientModule string, amt sdk.Coins) error
	SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
	SendCoinsFromAccountToModule(ctx context.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error

	BlockedAddr(addr sdk.AccAddress) bool

	MintCoins(ctx context.Context, name string, amt sdk.Coins) error

	BurnCoins(ctx context.Context, name string, amt sdk.Coins) error
}

BankKeeper defines the expected interface needed to retrieve account balances.

type QueryDelegationRewardsParams

type QueryDelegationRewardsParams struct {
	DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"`
	ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"`
}

params for query 'custom/distr/delegation_rewards'

func NewQueryDelegationRewardsParams

func NewQueryDelegationRewardsParams(delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress) QueryDelegationRewardsParams

creates a new instance of QueryDelegationRewardsParams

type QueryDelegatorParams

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

params for query 'custom/distr/delegator_total_rewards' and 'custom/distr/delegator_validators'

func NewQueryDelegatorParams

func NewQueryDelegatorParams(delegatorAddr sdk.AccAddress) QueryDelegatorParams

creates a new instance of QueryDelegationRewardsParams

type QueryDelegatorTotalRewardsResponse

type QueryDelegatorTotalRewardsResponse struct {
	Rewards []DelegationDelegatorReward `json:"rewards" yaml:"rewards"`
	Total   sdk.DecCoins                `json:"total" yaml:"total"`
}

QueryDelegatorTotalRewardsResponse defines the properties of QueryDelegatorTotalRewards query's response.

func NewQueryDelegatorTotalRewardsResponse

func NewQueryDelegatorTotalRewardsResponse(rewards []DelegationDelegatorReward, total sdk.DecCoins) QueryDelegatorTotalRewardsResponse

NewQueryDelegatorTotalRewardsResponse constructs a QueryDelegatorTotalRewardsResponse

func (QueryDelegatorTotalRewardsResponse) String

type QueryDelegatorWithdrawAddrParams

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

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

params for query 'custom/distr/validator_commission'

func NewQueryValidatorCommissionParams

func NewQueryValidatorCommissionParams(validatorAddr sdk.ValAddress) QueryValidatorCommissionParams

creates a new instance of QueryValidatorCommissionParams

type QueryValidatorOutstandingRewardsParams

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

params for query 'custom/distr/validator_outstanding_rewards'

func NewQueryValidatorOutstandingRewardsParams

func NewQueryValidatorOutstandingRewardsParams(validatorAddr sdk.ValAddress) QueryValidatorOutstandingRewardsParams

creates a new instance of QueryValidatorOutstandingRewardsParams

type QueryValidatorSlashesParams

type QueryValidatorSlashesParams struct {
	ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"`
	StartingHeight   uint64         `json:"starting_height" yaml:"starting_height"`
	EndingHeight     uint64         `json:"ending_height" yaml:"ending_height"`
}

params for query 'custom/distr/validator_slashes'

func NewQueryValidatorSlashesParams

func NewQueryValidatorSlashesParams(validatorAddr sdk.ValAddress, startingHeight, endingHeight uint64) QueryValidatorSlashesParams

creates a new instance of QueryValidatorSlashesParams

type StakingHooks

type StakingHooks interface {
	AfterValidatorCreated(ctx context.Context, valAddr sdk.ValAddress) error // Must be called when a validator is created
	AfterDelegationModified(ctx context.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error
}

StakingHooks event hooks for staking validator object (noalias)

type StakingKeeper

type StakingKeeper interface {
	ValidatorAddressCodec() address.Codec
	ConsensusAddressCodec() address.Codec
	// iterate through validators by operator address, execute func for each validator
	IterateValidators(context.Context,
		func(index int64, validator stakingtypes.ValidatorI) (stop bool)) error

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

	// Delegation allows for getting a particular delegation for a given validator
	// and delegator outside the scope of the staking module.
	Delegation(context.Context, sdk.AccAddress, sdk.ValAddress) (stakingtypes.DelegationI, error)

	IterateDelegations(ctx context.Context, delegator sdk.AccAddress,
		fn func(index int64, delegation stakingtypes.DelegationI) (stop bool)) error

	GetAllSDKDelegations(ctx context.Context) ([]stakingtypes.Delegation, error)
	GetAllValidators(ctx context.Context) ([]stakingtypes.Validator, error)
	GetAllDelegatorDelegations(ctx context.Context, delegator sdk.AccAddress) ([]stakingtypes.Delegation, error)
	MaximumMonthlyPoints(ctx context.Context) (uint64, error)

	BondDenom(ctx context.Context) (string, error)

	UpdateEmissionPoints(ctx context.Context, del stakingtypes.DelegationI, points uint64) error
	DecrementEmission(ctx context.Context, valAddr sdk.ValAddress, amount math.LegacyDec) error
	ValidatorEmissionRate(ctx context.Context) (math.LegacyDec, error)
}

StakingKeeper expected staking keeper (noalias)

Jump to

Keyboard shortcuts

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