distribution

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2025 License: Apache-2.0 Imports: 21 Imported by: 12

Documentation

Index

Constants

View Source
const (
	// ErrDifferentValidator is raised when the origin address is not the same as the validator address.
	ErrDifferentValidator = "origin address %s is not the same as validator address %s"
	// ErrInvalidAmount is raised when the given sdk coins amount is invalid
	ErrInvalidAmount = "invalid amount %s"
)
View Source
const (
	// EventTypeSetWithdrawAddress defines the event type for the distribution SetWithdrawAddressMethod transaction.
	EventTypeSetWithdrawAddress = "SetWithdrawerAddress"
	// EventTypeWithdrawDelegatorReward defines the event type for the distribution WithdrawDelegatorRewardMethod transaction.
	EventTypeWithdrawDelegatorReward = "WithdrawDelegatorReward"
	// EventTypeWithdrawValidatorCommission defines the event type for the distribution WithdrawValidatorCommissionMethod transaction.
	EventTypeWithdrawValidatorCommission = "WithdrawValidatorCommission"
	// EventTypeFundCommunityPool defines the event type for the distribution FundCommunityPoolMethod transaction.
	EventTypeFundCommunityPool = "FundCommunityPool"
	// EventTypeClaimRewards defines the event type for the distribution ClaimRewardsMethod transaction.
	EventTypeClaimRewards = "ClaimRewards"
	// EventTypeDepositValidatorRewardsPool defines the event type for the distribution DepositValidatorRewardsPoolMethod transaction.
	EventTypeDepositValidatorRewardsPool = "DepositValidatorRewardsPool"
)
View Source
const (
	// ValidatorDistributionInfoMethod defines the ABI method name for the
	// ValidatorDistributionInfo query.
	ValidatorDistributionInfoMethod = "validatorDistributionInfo"
	// ValidatorOutstandingRewardsMethod defines the ABI method name for the
	// ValidatorOutstandingRewards query.
	ValidatorOutstandingRewardsMethod = "validatorOutstandingRewards"
	// ValidatorCommissionMethod defines the ABI method name for the
	// ValidatorCommission query.
	ValidatorCommissionMethod = "validatorCommission"
	// ValidatorSlashesMethod defines the ABI method name for the
	// ValidatorSlashes query.
	ValidatorSlashesMethod = "validatorSlashes"
	// DelegationRewardsMethod defines the ABI method name for the
	// DelegationRewards query.
	DelegationRewardsMethod = "delegationRewards"
	// DelegationTotalRewardsMethod defines the ABI method name for the
	// DelegationTotalRewards query.
	DelegationTotalRewardsMethod = "delegationTotalRewards"
	// DelegatorValidatorsMethod defines the ABI method name for the
	// DelegatorValidators query.
	DelegatorValidatorsMethod = "delegatorValidators"
	// DelegatorWithdrawAddressMethod defines the ABI method name for the
	// DelegatorWithdrawAddress query.
	DelegatorWithdrawAddressMethod = "delegatorWithdrawAddress"
	// CommunityPoolMethod defines the ABI method name for the
	// CommunityPool query.
	CommunityPoolMethod = "communityPool"
)
View Source
const (
	// SetWithdrawAddressMethod defines the ABI method name for the distribution
	// SetWithdrawAddress transaction.
	SetWithdrawAddressMethod = "setWithdrawAddress"
	// WithdrawDelegatorRewardMethod defines the ABI method name for the distribution
	// WithdrawDelegatorReward transaction.
	WithdrawDelegatorRewardMethod = "withdrawDelegatorRewards"
	// WithdrawValidatorCommissionMethod defines the ABI method name for the distribution
	// WithdrawValidatorCommission transaction.
	WithdrawValidatorCommissionMethod = "withdrawValidatorCommission"
	// FundCommunityPoolMethod defines the ABI method name for the fundCommunityPool transaction
	FundCommunityPoolMethod = "fundCommunityPool"
	// ClaimRewardsMethod defines the ABI method name for the custom ClaimRewards transaction
	ClaimRewardsMethod = "claimRewards"
	// DepositValidatorRewardsPoolMethod defines the ABI method name for the distribution
	// DepositValidatorRewardsPool transaction
	DepositValidatorRewardsPoolMethod = "depositValidatorRewardsPool"
)

Variables

This section is empty.

Functions

func NewCommunityPoolRequest added in v0.3.0

func NewCommunityPoolRequest(args []interface{}) (*distributiontypes.QueryCommunityPoolRequest, error)

NewCommunityPoolRequest creates a new QueryCommunityPoolRequest instance and does sanity checks on the provided arguments.

func NewDelegationRewardsRequest

func NewDelegationRewardsRequest(args []interface{}) (*distributiontypes.QueryDelegationRewardsRequest, error)

NewDelegationRewardsRequest creates a new QueryDelegationRewardsRequest instance and does sanity checks on the provided arguments.

func NewDelegationTotalRewardsRequest

func NewDelegationTotalRewardsRequest(args []interface{}) (*distributiontypes.QueryDelegationTotalRewardsRequest, error)

NewDelegationTotalRewardsRequest creates a new QueryDelegationTotalRewardsRequest instance and does sanity checks on the provided arguments.

func NewDelegatorValidatorsRequest

func NewDelegatorValidatorsRequest(args []interface{}) (*distributiontypes.QueryDelegatorValidatorsRequest, error)

NewDelegatorValidatorsRequest creates a new QueryDelegatorValidatorsRequest instance and does sanity checks on the provided arguments.

func NewDelegatorWithdrawAddressRequest

func NewDelegatorWithdrawAddressRequest(args []interface{}) (*distributiontypes.QueryDelegatorWithdrawAddressRequest, error)

NewDelegatorWithdrawAddressRequest creates a new QueryDelegatorWithdrawAddressRequest instance and does sanity checks on the provided arguments.

func NewMsgDepositValidatorRewardsPool added in v0.3.0

func NewMsgDepositValidatorRewardsPool(args []interface{}) (*distributiontypes.MsgDepositValidatorRewardsPool, common.Address, error)

NewMsgDepositValidatorRewardsPool creates a new MsgDepositValidatorRewardsPool message.

func NewMsgFundCommunityPool

func NewMsgFundCommunityPool(args []interface{}) (*distributiontypes.MsgFundCommunityPool, common.Address, error)

NewMsgFundCommunityPool creates a new NewMsgFundCommunityPool message.

func NewMsgSetWithdrawAddress

func NewMsgSetWithdrawAddress(args []interface{}) (*distributiontypes.MsgSetWithdrawAddress, common.Address, error)

NewMsgSetWithdrawAddress creates a new MsgSetWithdrawAddress instance.

func NewMsgWithdrawDelegatorReward

func NewMsgWithdrawDelegatorReward(args []interface{}) (*distributiontypes.MsgWithdrawDelegatorReward, common.Address, error)

NewMsgWithdrawDelegatorReward creates a new MsgWithdrawDelegatorReward instance.

func NewMsgWithdrawValidatorCommission

func NewMsgWithdrawValidatorCommission(args []interface{}) (*distributiontypes.MsgWithdrawValidatorCommission, common.Address, error)

NewMsgWithdrawValidatorCommission creates a new MsgWithdrawValidatorCommission message.

func NewValidatorCommissionRequest

func NewValidatorCommissionRequest(args []interface{}) (*distributiontypes.QueryValidatorCommissionRequest, error)

NewValidatorCommissionRequest creates a new QueryValidatorCommissionRequest instance and does sanity checks on the provided arguments.

func NewValidatorDistributionInfoRequest

func NewValidatorDistributionInfoRequest(args []interface{}) (*distributiontypes.QueryValidatorDistributionInfoRequest, error)

NewValidatorDistributionInfoRequest creates a new QueryValidatorDistributionInfoRequest instance and does sanity checks on the provided arguments.

func NewValidatorOutstandingRewardsRequest

func NewValidatorOutstandingRewardsRequest(args []interface{}) (*distributiontypes.QueryValidatorOutstandingRewardsRequest, error)

NewValidatorOutstandingRewardsRequest creates a new QueryValidatorOutstandingRewardsRequest instance and does sanity checks on the provided arguments.

func NewValidatorSlashesRequest

func NewValidatorSlashesRequest(method *abi.Method, args []interface{}) (*distributiontypes.QueryValidatorSlashesRequest, error)

NewValidatorSlashesRequest creates a new QueryValidatorSlashesRequest instance and does sanity checks on the provided arguments.

Types

type CommunityPoolOutput added in v0.3.0

type CommunityPoolOutput struct {
	Pool []cmn.DecCoin
}

CommunityPoolOutput is a struct to represent the key information from a CommunityPool response.

func (*CommunityPoolOutput) FromResponse added in v0.3.0

FromResponse populates the CommunityPoolOutput from a QueryCommunityPoolResponse.

func (*CommunityPoolOutput) Pack added in v0.3.0

func (cp *CommunityPoolOutput) Pack(args abi.Arguments) ([]byte, error)

Pack packs a given slice of abi arguments into a byte array.

type DelegationDelegatorReward

type DelegationDelegatorReward struct {
	ValidatorAddress string
	Reward           []cmn.DecCoin
}

DelegationDelegatorReward is a struct to represent the key information from a query for the rewards of a delegation to a given validator.

type DelegationTotalRewardsOutput

type DelegationTotalRewardsOutput struct {
	Rewards []DelegationDelegatorReward
	Total   []cmn.DecCoin
}

DelegationTotalRewardsOutput is a struct to represent the key information from a DelegationTotalRewards response.

func (*DelegationTotalRewardsOutput) FromResponse

FromResponse populates the DelegationTotalRewardsOutput from a QueryDelegationTotalRewardsResponse.

func (*DelegationTotalRewardsOutput) Pack

func (dtr *DelegationTotalRewardsOutput) Pack(args abi.Arguments) ([]byte, error)

Pack packs a given slice of abi arguments into a byte array.

type EventClaimRewards

type EventClaimRewards struct {
	DelegatorAddress common.Address
	Amount           *big.Int
}

EventClaimRewards defines the event data for the ClaimRewards transaction.

type EventDepositValidatorRewardsPool added in v0.3.0

type EventDepositValidatorRewardsPool struct {
	Depositor        common.Address
	ValidatorAddress common.Address
	Denom            string
	Amount           *big.Int
}

EventDepositValidatorRewardsPool defines the event data for the DepositValidatorRewardsPool transaction.

type EventFundCommunityPool

type EventFundCommunityPool struct {
	Depositor common.Address
	Denom     string
	Amount    *big.Int
}

EventFundCommunityPool defines the event data for the FundCommunityPool transaction.

type EventSetWithdrawAddress

type EventSetWithdrawAddress struct {
	Caller            common.Address
	WithdrawerAddress string
}

EventSetWithdrawAddress defines the event data for the SetWithdrawAddress transaction.

type EventWithdrawDelegatorReward added in v0.3.0

type EventWithdrawDelegatorReward struct {
	DelegatorAddress common.Address
	ValidatorAddress common.Address
	Amount           *big.Int
}

EventWithdrawDelegatorReward defines the event data for the WithdrawDelegatorReward transaction.

type EventWithdrawValidatorRewards

type EventWithdrawValidatorRewards struct {
	ValidatorAddress common.Hash
	Commission       *big.Int
}

EventWithdrawValidatorRewards defines the event data for the WithdrawValidatorRewards transaction.

type Precompile

type Precompile struct {
	cmn.Precompile
	// contains filtered or unexported fields
}

Precompile defines the precompiled contract for distribution.

func NewPrecompile

func NewPrecompile(
	distributionKeeper distributionkeeper.Keeper,
	stakingKeeper stakingkeeper.Keeper,
	evmKeeper *evmkeeper.Keeper,
) (*Precompile, error)

NewPrecompile creates a new distribution Precompile instance as a PrecompiledContract interface.

func (*Precompile) ClaimRewards

func (p *Precompile) ClaimRewards(
	ctx sdk.Context,
	contract *vm.Contract,
	stateDB vm.StateDB,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

ClaimRewards claims the rewards accumulated by a delegator from multiple or all validators.

func (Precompile) CommunityPool added in v0.3.0

func (p Precompile) CommunityPool(
	ctx sdk.Context,
	_ *vm.Contract,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

CommunityPool returns the community pool coins.

func (Precompile) DelegationRewards

func (p Precompile) DelegationRewards(
	ctx sdk.Context,
	_ *vm.Contract,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

DelegationRewards returns the total rewards accrued by a delegation.

func (Precompile) DelegationTotalRewards

func (p Precompile) DelegationTotalRewards(
	ctx sdk.Context,
	_ *vm.Contract,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

DelegationTotalRewards returns the total rewards accrued by a delegation.

func (Precompile) DelegatorValidators

func (p Precompile) DelegatorValidators(
	ctx sdk.Context,
	_ *vm.Contract,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

DelegatorValidators returns the validators a delegator is bonded to.

func (Precompile) DelegatorWithdrawAddress

func (p Precompile) DelegatorWithdrawAddress(
	ctx sdk.Context,
	_ *vm.Contract,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

DelegatorWithdrawAddress returns the withdraw address for a delegator.

func (*Precompile) DepositValidatorRewardsPool added in v0.3.0

func (p *Precompile) DepositValidatorRewardsPool(
	ctx sdk.Context,
	contract *vm.Contract,
	stateDB vm.StateDB,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

DepositValidatorRewardsPool deposits rewards into the validator rewards pool for a specific validator.

func (Precompile) EmitClaimRewardsEvent

func (p Precompile) EmitClaimRewardsEvent(ctx sdk.Context, stateDB vm.StateDB, delegatorAddress common.Address, totalCoins sdk.Coins) error

EmitClaimRewardsEvent creates a new event emitted on a ClaimRewards transaction.

func (Precompile) EmitDepositValidatorRewardsPoolEvent added in v0.3.0

func (p Precompile) EmitDepositValidatorRewardsPoolEvent(ctx sdk.Context, stateDB vm.StateDB, depositor common.Address, validatorAddress string, coins sdk.Coins) error

EmitDepositValidatorRewardsPoolEvent creates a new event emitted on a DepositValidatorRewardsPool transaction.

func (Precompile) EmitFundCommunityPoolEvent

func (p Precompile) EmitFundCommunityPoolEvent(ctx sdk.Context, stateDB vm.StateDB, depositor common.Address, coins sdk.Coins) error

EmitFundCommunityPoolEvent creates a new event emitted per Coin on a FundCommunityPool transaction.

func (Precompile) EmitSetWithdrawAddressEvent

func (p Precompile) EmitSetWithdrawAddressEvent(ctx sdk.Context, stateDB vm.StateDB, caller common.Address, withdrawerAddress string) error

EmitSetWithdrawAddressEvent creates a new event emitted on a SetWithdrawAddressMethod transaction.

func (Precompile) EmitWithdrawDelegatorRewardEvent added in v0.3.0

func (p Precompile) EmitWithdrawDelegatorRewardEvent(ctx sdk.Context, stateDB vm.StateDB, delegatorAddress common.Address, validatorAddress string, coins sdk.Coins) error

EmitWithdrawDelegatorRewardEvent creates a new event emitted on a WithdrawDelegatorReward transaction.

func (Precompile) EmitWithdrawValidatorCommissionEvent

func (p Precompile) EmitWithdrawValidatorCommissionEvent(ctx sdk.Context, stateDB vm.StateDB, validatorAddress string, coins sdk.Coins) error

EmitWithdrawValidatorCommissionEvent creates a new event emitted on a WithdrawValidatorCommission transaction.

func (*Precompile) FundCommunityPool

func (p *Precompile) FundCommunityPool(
	ctx sdk.Context,
	contract *vm.Contract,
	stateDB vm.StateDB,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

FundCommunityPool directly fund the community pool

func (Precompile) IsTransaction

func (Precompile) IsTransaction(method *abi.Method) bool

IsTransaction checks if the given method name corresponds to a transaction or query.

Available distribution transactions are:

  • ClaimRewards
  • SetWithdrawAddress
  • WithdrawDelegatorReward
  • WithdrawValidatorCommission
  • FundCommunityPool
  • DepositValidatorRewardsPool

func (Precompile) RequiredGas

func (p Precompile) RequiredGas(input []byte) uint64

RequiredGas calculates the precompiled contract's base gas rate.

func (Precompile) Run

func (p Precompile) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) (bz []byte, err error)

Run executes the precompiled contract distribution methods defined in the ABI.

func (Precompile) SetWithdrawAddress

func (p Precompile) SetWithdrawAddress(
	ctx sdk.Context,
	contract *vm.Contract,
	stateDB vm.StateDB,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

SetWithdrawAddress sets the withdrawal address for a delegator (or validator self-delegation).

func (Precompile) ValidatorCommission

func (p Precompile) ValidatorCommission(
	ctx sdk.Context,
	_ *vm.Contract,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

ValidatorCommission returns the commission for a validator.

func (Precompile) ValidatorDistributionInfo

func (p Precompile) ValidatorDistributionInfo(
	ctx sdk.Context,
	_ *vm.Contract,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

ValidatorDistributionInfo returns the distribution info for a validator.

func (Precompile) ValidatorOutstandingRewards

func (p Precompile) ValidatorOutstandingRewards(
	ctx sdk.Context,
	_ *vm.Contract,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

ValidatorOutstandingRewards returns the outstanding rewards for a validator.

func (Precompile) ValidatorSlashes

func (p Precompile) ValidatorSlashes(
	ctx sdk.Context,
	_ *vm.Contract,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

ValidatorSlashes returns the slashes for a validator.

func (*Precompile) WithdrawDelegatorReward added in v0.3.0

func (p *Precompile) WithdrawDelegatorReward(
	ctx sdk.Context,
	contract *vm.Contract,
	stateDB vm.StateDB,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

WithdrawDelegatorReward withdraws the rewards of a delegator from a single validator.

func (*Precompile) WithdrawValidatorCommission

func (p *Precompile) WithdrawValidatorCommission(
	ctx sdk.Context,
	contract *vm.Contract,
	stateDB vm.StateDB,
	method *abi.Method,
	args []interface{},
) ([]byte, error)

WithdrawValidatorCommission withdraws the rewards of a validator.

type ValidatorDistributionInfo

type ValidatorDistributionInfo struct {
	OperatorAddress string        `abi:"operatorAddress"`
	SelfBondRewards []cmn.DecCoin `abi:"selfBondRewards"`
	Commission      []cmn.DecCoin `abi:"commission"`
}

ValidatorDistributionInfo is a struct to represent the key information from a ValidatorDistributionInfoResponse.

type ValidatorDistributionInfoOutput

type ValidatorDistributionInfoOutput struct {
	DistributionInfo ValidatorDistributionInfo `abi:"distributionInfo"`
}

ValidatorDistributionInfoOutput is a wrapper for ValidatorDistributionInfo to return in the response.

func (*ValidatorDistributionInfoOutput) FromResponse

FromResponse converts a response to a ValidatorDistributionInfo.

type ValidatorSlashEvent

type ValidatorSlashEvent struct {
	ValidatorPeriod uint64  `abi:"validatorPeriod"`
	Fraction        cmn.Dec `abi:"fraction"`
}

ValidatorSlashEvent is a struct to represent the key information from a ValidatorSlashEvent response.

type ValidatorSlashesInput

type ValidatorSlashesInput struct {
	ValidatorAddress string
	StartingHeight   uint64
	EndingHeight     uint64
	PageRequest      query.PageRequest
}

ValidatorSlashesInput is a struct to represent the key information to perform a ValidatorSlashes query.

type ValidatorSlashesOutput

type ValidatorSlashesOutput struct {
	Slashes      []ValidatorSlashEvent
	PageResponse query.PageResponse
}

ValidatorSlashesOutput is a struct to represent the key information from a ValidatorSlashes response.

func (*ValidatorSlashesOutput) FromResponse

FromResponse populates the ValidatorSlashesOutput from a QueryValidatorSlashesResponse.

func (*ValidatorSlashesOutput) Pack

func (vs *ValidatorSlashesOutput) Pack(args abi.Arguments) ([]byte, error)

Pack packs a given slice of abi arguments into a byte array.

Jump to

Keyboard shortcuts

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