distribution

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrSetWithdrawAddrAuth is raised when no authorization to set the withdraw address exists.
	ErrSetWithdrawAddrAuth = "set withdrawer address authorization for address %s does not exist"
	// ErrWithdrawDelRewardsAuth is raised when no authorization to withdraw delegation rewards exists.
	ErrWithdrawDelRewardsAuth = "withdraw delegation rewards authorization for address %s does not exist"
	// ErrWithdrawValCommissionAuth is raised when no authorization to withdraw validator commission exists.
	ErrWithdrawValCommissionAuth = "withdraw validator commission authorization for address %s does not exist"
	// 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"
)
View Source
const (
	// EventTypeSetWithdrawAddress defines the event type for the distribution SetWithdrawAddressMethod transaction.
	EventTypeSetWithdrawAddress = "SetWithdrawerAddress"
	// EventTypeWithdrawDelegatorRewards defines the event type for the distribution WithdrawDelegatorRewardsMethod transaction.
	EventTypeWithdrawDelegatorRewards = "WithdrawDelegatorRewards"
	// EventTypeWithdrawValidatorCommission defines the event type for the distribution WithdrawValidatorCommissionMethod transaction.
	EventTypeWithdrawValidatorCommission = "WithdrawValidatorCommission"
	// EventTypeClaimRewards defines the event type for the distribution ClaimRewardsMethod transaction.
	EventTypeClaimRewards = "ClaimRewards"
)
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"
)
View Source
const (
	// SetWithdrawAddressMethod defines the ABI method name for the distribution
	// SetWithdrawAddress transaction.
	SetWithdrawAddressMethod = "setWithdrawAddress"
	// WithdrawDelegatorRewardsMethod defines the ABI method name for the distribution
	// WithdrawDelegatorRewards transaction.
	WithdrawDelegatorRewardsMethod = "withdrawDelegatorRewards"
	// WithdrawValidatorCommissionMethod defines the ABI method name for the distribution
	// WithdrawValidatorCommission transaction.
	WithdrawValidatorCommissionMethod = "withdrawValidatorCommission"
	// ClaimRewardsMethod defines the ABI method name for the custom ClaimRewards transaction
	ClaimRewardsMethod = "claimRewards"
)

Variables

This section is empty.

Functions

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 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 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 EventSetWithdrawAddress

type EventSetWithdrawAddress struct {
	Caller            common.Address
	WithdrawerAddress string
}

EventSetWithdrawAddress defines the event data for the SetWithdrawAddress transaction.

type EventWithdrawDelegatorRewards

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

EventWithdrawDelegatorRewards defines the event data for the WithdrawDelegatorRewards 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,
	authzKeeper authzkeeper.Keeper,
) (*Precompile, error)

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

func (Precompile) Address

func (p Precompile) Address() common.Address

Address defines the address of the distribution compile contract. address: 0x0000000000000000000000000000000000000801

func (Precompile) ClaimRewards

func (p Precompile) ClaimRewards(
	ctx sdk.Context,
	origin common.Address,
	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) 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) 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) 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) EmitWithdrawDelegatorRewardsEvent

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

EmitWithdrawDelegatorRewardsEvent creates a new event emitted on a WithdrawDelegatorRewards 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) IsTransaction

func (Precompile) IsTransaction(methodName string) bool

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

Available distribution transactions are:

  • ClaimRewards
  • SetWithdrawAddress
  • WithdrawDelegatorRewards
  • WithdrawValidatorCommission

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,
	origin common.Address,
	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) WithdrawDelegatorRewards

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

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

func (Precompile) WithdrawValidatorCommission

func (p Precompile) WithdrawValidatorCommission(
	ctx sdk.Context,
	origin common.Address,
	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