distribution

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 15 Imported by: 0

README

Distribution module

Usage

(Tx) Fund community pool
fundCommunityPoolMsg := types.FundCommunityPoolMsg {
    Amount: "1000",
}

txbytes, err := xplac.FundCommunityPool(fundCommunityPoolMsg).CreateAndSignTx()
res, err := xplac.Broadcast(txbytes)
(Tx) Proposal community pool spend
// Input data
communityPoolSpendMsg := types.CommunityPoolSpendMsg{
    Title: "community pool spend",
    Description: "pay me",
    Recipient: "xpla1ka84cuec6339t8s4nh3sp5zf2fre6dh2v2g9mp",
    Amount: "10000",
    Deposit: "1000",
}

// Use json file
communityPoolSpendMsg := types.CommunityPoolSpendMsg{
    JsonFilePath: "./proposal.json"
}

txbytes, err := xplac.CommunityPoolSpend(communityPoolSpendMsg).CreateAndSignTx()
res, err := xplac.Broadcast(txbytes)
(Tx) Withdraw rewards
withdrawRewardsMsg := types.WithdrawRewardsMsg{
    DelegatorAddr: "xpla1e4f6k98es55vxxv2pcfzpsjrf3mvazeyqpw8g9",
    ValidatorAddr: "xplavaloper19yq7kjcgse7x672faptju0lxmy4cvdlcsx9ftw",
}
txbytes, err := xplac.WithdrawRewards(withdrawRewardsMsg).CreateAndSignTx()
res, err := xplac.Broadcast(txbytes)
(Tx) Withdraw all rewards
txbytes, err := xplac.WithdrawAllRewards().CreateAndSignTx()
res, err := xplac.Broadcast(txbytes)
(Tx) Set withdraw address
setWithdrawAddrMsg := types.SetwithdrawAddrMsg {
    WithdrawAddr: "xpla1e4f6k98es55vxxv2pcfzpsjrf3mvazeyqpw8g9",
}
txbytes, err := xplac.SetWithdrawAddr(setWithdrawAddrMsg).CreateAndSignTx()
res, err := xplac.Broadcast(txbytes)
(Query) distribution parameters
res, err := xplac.DistributionParams().Query()
(Query) validator outstanding rewards
validatorOutstandingRewardsMsg := types.ValidatorOutstandingRewardsMsg {
    ValidatorAddr: "xplavaloper19yq7kjcgse7x672faptju0lxmy4cvdlcsx9ftw",
}
res, err := xplac.ValidatorOutstandingRewards(validatorOutstandingRewardsMsg).Query()
(Query) commission
queryDistCommissionMsg := types.QueryDistCommissionMsg {
    ValidatorAddr: "xplavaloper19yq7kjcgse7x672faptju0lxmy4cvdlcsx9ftw",
}
res, err := xplac.DistCommission(queryDistCommissionMsg).Query()
(Query) validator slashes
queryDistSlashesMsg := types.QueryDistSlashesMsg{
    ValidatorAddr: "xplavaloper19yq7kjcgse7x672faptju0lxmy4cvdlcsx9ftw",
}

res, err := xplac.DistSlashes(queryDistSlashesMsg).Query()
(Query) rewards
// reward for a validator
queryDistRewardsMsg := types.QueryDistRewardsMsg{
    ValidatorAddr: "xplavaloper19yq7kjcgse7x672faptju0lxmy4cvdlcsx9ftw",
    DelegatorAddr: "xpla1e4f6k98es55vxxv2pcfzpsjrf3mvazeyqpw8g9",
}

// total rewards
queryDistRewardsMsg := types.QueryDistRewardsMsg{
    DelegatorAddr: "xpla1e4f6k98es55vxxv2pcfzpsjrf3mvazeyqpw8g9",
}
res, err := xplac.DistRewards(queryDistRewardsMsg).Query()
(Query) community pool
res, err := xplac.CommunityPool().Query()

Documentation

Index

Constants

View Source
const (
	DistributionModule                             = "distribution"
	DistributionFundCommunityPoolMsgType           = "fund-community-pool"
	DistributionProposalCommunityPoolSpendMsgType  = "proposal-community-pool-spend"
	DistributionWithdrawRewardsMsgType             = "withdraw-rewards"
	DistributionWithdrawAllRewardsMsgType          = "withdraw-all-rewards"
	DistributionSetWithdrawAddrMsgType             = "set-withdraw-addr"
	DistributionQueryDistributionParamsMsgType     = "query-distribution-params"
	DistributionValidatorOutstandingRewardsMsgType = "validator-outstanding-rewards"
	DistributionQueryDistCommissionMsgType         = "dist-query-commission"
	DistributionQuerySlashesMsgType                = "dist-slashes"
	DistributionQueryRewardsMsgType                = "dist-rewards"
	DistributionQueryTotalRewardsMsgType           = "dist-total-rewards"
	DistributionQueryCommunityPoolMsgType          = "query-community-pool"
)

Variables

This section is empty.

Functions

func MakeFundCommunityPoolMsg

func MakeFundCommunityPoolMsg(fundCommunityPoolMsg types.FundCommunityPoolMsg, depositorAddr sdk.AccAddress) (disttypes.MsgFundCommunityPool, error)

(Tx) make msg - fund community pool

func MakeProposalCommunityPoolSpendMsg

func MakeProposalCommunityPoolSpendMsg(communityPoolSpendMsg types.CommunityPoolSpendMsg, from sdk.AccAddress, encodingConfig params.EncodingConfig) (govtypes.MsgSubmitProposal, error)

(Tx) make msg - proposal community pool

func MakeQueryCommunityPoolMsg

func MakeQueryCommunityPoolMsg() (disttypes.QueryCommunityPoolRequest, error)

(Query) make msg - community pool

func MakeQueryDistCommissionMsg

func MakeQueryDistCommissionMsg(queryDistCommissionMsg types.QueryDistCommissionMsg) (disttypes.QueryValidatorCommissionRequest, error)

(Query) make msg - commission

func MakeQueryDistRewardsMsg

func MakeQueryDistRewardsMsg(queryDistRewardsMsg types.QueryDistRewardsMsg) (disttypes.QueryDelegationRewardsRequest, error)

(Query) make msg - distribution rewards

func MakeQueryDistSlashesMsg

func MakeQueryDistSlashesMsg(queryDistSlashesMsg types.QueryDistSlashesMsg) (disttypes.QueryValidatorSlashesRequest, error)

(Query) make msg - distribution slashes

func MakeQueryDistTotalRewardsMsg

func MakeQueryDistTotalRewardsMsg(queryDistRewardsMsg types.QueryDistRewardsMsg) (disttypes.QueryDelegationTotalRewardsRequest, error)

(Query) make msg - distribution all rewards

func MakeQueryDistributionParamsMsg

func MakeQueryDistributionParamsMsg() (disttypes.QueryParamsRequest, error)

(Query) make msg - distribution params

func MakeSetWithdrawAddrMsg

func MakeSetWithdrawAddrMsg(setWithdrawAddrMsg types.SetWithdrawAddrMsg, delAddr sdk.AccAddress) (disttypes.MsgSetWithdrawAddress, error)

(Tx) make msg - withdraw address

func MakeValidatorOutstandingRewardsMsg

func MakeValidatorOutstandingRewardsMsg(validatorOutstandingRewardsMsg types.ValidatorOutstandingRewardsMsg) (disttypes.QueryValidatorOutstandingRewardsRequest, error)

(Query) make msg - validator outstanding rewards

func MakeWithdrawAllRewardsMsg

func MakeWithdrawAllRewardsMsg(delAddr sdk.AccAddress, grpcConn grpc.ClientConn, ctx context.Context) ([]sdk.Msg, error)

(Tx) make msg - withdraw all rewards

func MakeWithdrawRewardsMsg

func MakeWithdrawRewardsMsg(withdrawRewardsMsg types.WithdrawRewardsMsg, delAddr sdk.AccAddress) ([]sdk.Msg, error)

(Tx) make msg - withdraw rewards

func NewCoreModule added in v0.1.2

func NewCoreModule() core.CoreModule

func QueryDistribution

func QueryDistribution(i core.QueryClient) (string, error)

Query client for distribution module.

Types

type DistributionExternal added in v0.1.2

type DistributionExternal struct {
	Xplac provider.XplaClient
}

func NewDistributionExternal added in v0.1.2

func NewDistributionExternal(xplac provider.XplaClient) (e DistributionExternal)

func (DistributionExternal) CommunityPool added in v0.1.2

func (e DistributionExternal) CommunityPool() provider.XplaClient

Query the amount of coins in the community pool.

func (DistributionExternal) CommunityPoolSpend added in v0.1.2

func (e DistributionExternal) CommunityPoolSpend(communityPoolSpendMsg types.CommunityPoolSpendMsg) provider.XplaClient

Submit a community pool spend proposal.

func (DistributionExternal) DistCommission added in v0.1.2

func (e DistributionExternal) DistCommission(queryDistCommissionMsg types.QueryDistCommissionMsg) provider.XplaClient

Query distribution validator commission.

func (DistributionExternal) DistRewards added in v0.1.2

func (e DistributionExternal) DistRewards(queryDistRewardsMsg types.QueryDistRewardsMsg) provider.XplaClient

Query all ditribution delegator rewards or rewards from a particular validator.

func (DistributionExternal) DistSlashes added in v0.1.2

func (e DistributionExternal) DistSlashes(queryDistSlashesMsg types.QueryDistSlashesMsg) provider.XplaClient

Query distribution validator slashes.

func (DistributionExternal) DistributionParams added in v0.1.2

func (e DistributionExternal) DistributionParams() provider.XplaClient

Query distribution parameters.

func (DistributionExternal) FundCommunityPool added in v0.1.2

func (e DistributionExternal) FundCommunityPool(fundCommunityPoolMsg types.FundCommunityPoolMsg) provider.XplaClient

Funds the community pool with the specified amount.

func (DistributionExternal) SetWithdrawAddr added in v0.1.2

func (e DistributionExternal) SetWithdrawAddr(setWithdrawAddrMsg types.SetWithdrawAddrMsg) provider.XplaClient

Change the default withdraw address for rewards associated with an address.

func (DistributionExternal) ValidatorOutstandingRewards added in v0.1.2

func (e DistributionExternal) ValidatorOutstandingRewards(validatorOutstandingRewardsMsg types.ValidatorOutstandingRewardsMsg) provider.XplaClient

Query distribution outstanding (un-withdrawn) rewards for a validator and all their delegations.

func (DistributionExternal) WithdrawAllRewards added in v0.1.2

func (e DistributionExternal) WithdrawAllRewards() provider.XplaClient

Withdraw all delegations rewards for a delegator.

func (DistributionExternal) WithdrawRewards added in v0.1.2

func (e DistributionExternal) WithdrawRewards(withdrawRewardsMsg types.WithdrawRewardsMsg) provider.XplaClient

Withdraw rewards from a given delegation address, and optionally withdraw validator commission if the delegation address given is a validator operator.

Jump to

Keyboard shortcuts

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