Documentation ¶
Overview ¶
Package staking provides staking functionalities for validators and delegators. [More Details](https://www.junjie-bianjie.org/docs/features/stake.html)
As a quick start:
baseTx := sdk.BaseTx{ From: "test1", Gas: 20000, Memo: "test", Mode: sdk.Commit, } //test QueryValidators validators, _ := sts.Staking().QueryValidators(1, 10) validator := validators[0].OperatorAddress amt, _ := sdk.NewIntFromString("20000000000000000000") amount := sdk.NewCoin("iris-atto", amt) //test Delegate rs, err := sts.Staking().Delegate(validator, amount, baseTx) require.NoError(sts.T(), err) require.NotEmpty(sts.T(), rs.Hash) //test QueryDelegation delegator := sts.Sender().String() d, err := sts.Staking().QueryDelegation(delegator, validator) require.NoError(sts.T(), err) require.Equal(sts.T(), validator, d.ValidatorAddr) require.Equal(sts.T(), delegator, d.DelegatorAddr) //test QueryDelegations ds, err := sts.Staking().QueryDelegations(delegator) require.NoError(sts.T(), err) require.NotEmpty(sts.T(), ds) //test QueryDelegationsTo ds, err = sts.Staking().QueryDelegationsTo(validator) require.NoError(sts.T(), err) require.NotEmpty(sts.T(), ds) //test Undelegate amt, _ = sdk.NewIntFromString("10000000000000000000") amount = sdk.NewCoin("iris-atto", amt) rs, err = sts.Staking().Undelegate(validator, amount, baseTx) require.NoError(sts.T(), err) require.NotEmpty(sts.T(), rs.Hash) //test QueryUnbondingDelegation ubd, err := sts.Staking().QueryUnbondingDelegation(delegator, validator) require.NoError(sts.T(), err) require.Equal(sts.T(), validator, ubd.ValidatorAddr) require.Equal(sts.T(), delegator, ubd.DelegatorAddr) //test QueryUnbondingDelegations ubds, err := sts.Staking().QueryUnbondingDelegations(delegator) require.NoError(sts.T(), err) require.NotEmpty(sts.T(), ubds) //test QueryUnbondingDelegationsFrom uds, err := sts.Staking().QueryUnbondingDelegationsFrom(validator) require.NoError(sts.T(), err) require.NotEmpty(sts.T(), uds)
Index ¶
Constants ¶
const ( Unbonded bondStatus = 1 Unbonding bondStatus = 2 Bonded bondStatus = 3 BondStatusUnbonded = "Unbonded" BondStatusUnbonding = "Unbonding" BondStatusBonded = "Bonded" )
nolint
const (
ModuleName = "stake"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Commission ¶
type Commission struct {
CommissionRates `json:"commission_rates"`
}
Commission defines a commission parameters for a given validator.
type CommissionMsg ¶
type CommissionMsg struct { Rate sdk.Dec `json:"rate"` // the commission rate charged to delegators MaxRate sdk.Dec `json:"max_rate"` // maximum commission rate which validator can ever charge MaxChangeRate sdk.Dec `json:"max_change_rate"` // maximum daily increase of the validator commission }
CommissionMsg defines a commission message to be used for creating a validator.
type CommissionRates ¶
type CommissionRates struct { Rate sdk.Dec `json:"rate"` // the commission rate charged to delegators MaxRate sdk.Dec `json:"max_rate"` // maximum commission rate which validator can ever charge MaxChangeRate sdk.Dec `json:"max_change_rate"` // maximum daily increase of the validator commission UpdateTime time.Time `json:"update_time"` // the last time the commission rate was changed }
CommissionRates defines the initial commission rates to be used for creating a validator.
type Description ¶
type Description struct { Moniker string `json:"moniker"` // name Identity string `json:"identity"` // optional identity signature (ex. UPort or Keybase) Website string `json:"website"` // optional website link SecurityContact string `json:"security_contact"` // optional securityContact Details string `json:"details"` // optional details }
Description - description fields for a validator
type MsgBeginRedelegate ¶
type MsgBeginRedelegate struct { DelegatorAddr sdk.AccAddress `json:"delegator_addr"` ValidatorSrcAddr sdk.ValAddress `json:"validator_src_addr"` ValidatorDstAddr sdk.ValAddress `json:"validator_dst_addr"` }
______________________________________________________________________ MsgBeginRedelegate - struct for bonding transactions
func NewMsgBeginRedelegate ¶
func NewMsgBeginRedelegate(delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.ValAddress, sharesAmount sdk.Dec) MsgBeginRedelegate
func (MsgBeginRedelegate) GetSignBytes ¶
func (msg MsgBeginRedelegate) GetSignBytes() []byte
get the bytes for the message signer to sign on
func (MsgBeginRedelegate) GetSigners ¶
func (msg MsgBeginRedelegate) GetSigners() []sdk.AccAddress
func (MsgBeginRedelegate) Type ¶
func (msg MsgBeginRedelegate) Type() string
func (MsgBeginRedelegate) ValidateBasic ¶
func (msg MsgBeginRedelegate) ValidateBasic() error
quick validity check
type MsgCreateValidator ¶
type MsgCreateValidator struct { Description Commission CommissionMsg DelegatorAddr sdk.AccAddress `json:"delegator_address"` ValidatorAddr sdk.ValAddress `json:"validator_address"` PubKey crypto.PubKey `json:"pubkey"` Delegation sdk.Coin `json:"delegation"` }
MsgCreateValidator - struct for bonding transactions
func (MsgCreateValidator) GetSignBytes ¶
func (msg MsgCreateValidator) GetSignBytes() []byte
get the bytes for the message signer to sign on
func (MsgCreateValidator) GetSigners ¶
func (msg MsgCreateValidator) GetSigners() []sdk.AccAddress
Return address(es) that must sign over msg.GetSignBytes()
func (MsgCreateValidator) Type ¶
func (msg MsgCreateValidator) Type() string
func (MsgCreateValidator) ValidateBasic ¶
func (msg MsgCreateValidator) ValidateBasic() error
quick validity check
type MsgDelegate ¶
type MsgDelegate struct { DelegatorAddr sdk.AccAddress `json:"delegator_addr"` ValidatorAddr sdk.ValAddress `json:"validator_addr"` Delegation sdk.Coin `json:"delegation"` }
MsgDelegate - struct for bonding transactions
func (MsgDelegate) GetSignBytes ¶
func (msg MsgDelegate) GetSignBytes() []byte
get the bytes for the message signer to sign on
func (MsgDelegate) GetSigners ¶
func (msg MsgDelegate) GetSigners() []sdk.AccAddress
func (MsgDelegate) Route ¶
func (msg MsgDelegate) Route() string
func (MsgDelegate) ValidateBasic ¶
func (msg MsgDelegate) ValidateBasic() error
quick validity check
type MsgEditValidator ¶
type MsgEditValidator struct { Description ValidatorAddr sdk.ValAddress `json:"address"` // We pass a reference to the new commission rate as it's not mandatory to // update. If not updated, the deserialized rate will be zero with no way to // distinguish if an update was intended. // // REF: #2373 CommissionRate *sdk.Dec `json:"commission_rate"` }
MsgEditValidator - struct for editing a validator
func (MsgEditValidator) GetSignBytes ¶
func (msg MsgEditValidator) GetSignBytes() []byte
get the bytes for the message signer to sign on
func (MsgEditValidator) GetSigners ¶
func (msg MsgEditValidator) GetSigners() []sdk.AccAddress
func (MsgEditValidator) Type ¶
func (msg MsgEditValidator) Type() string
func (MsgEditValidator) ValidateBasic ¶
func (msg MsgEditValidator) ValidateBasic() error
quick validity check
type MsgUndelegate ¶
type MsgUndelegate struct { DelegatorAddr sdk.AccAddress `json:"delegator_addr"` ValidatorAddr sdk.ValAddress `json:"validator_addr"` }
MsgUndelegate - struct for unbonding transactions
func (MsgUndelegate) GetSignBytes ¶
func (msg MsgUndelegate) GetSignBytes() []byte
get the bytes for the message signer to sign on
func (MsgUndelegate) GetSigners ¶
func (msg MsgUndelegate) GetSigners() []sdk.AccAddress
func (MsgUndelegate) Type ¶
func (msg MsgUndelegate) Type() string
func (MsgUndelegate) ValidateBasic ¶
func (msg MsgUndelegate) ValidateBasic() error
quick validity check