staking

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: 20 Imported by: 0

README

Staking module

Usage

(Tx) Create validator
// Create validator using json file in the home directory
createValidatorMsg := types.CreateValidatorMsg{	
    ValidatorAddress: "xplavaloper10gv4zj9633v6cje6s2sc0a0xl52hjr6f9jp0q7",
    Website: "website",
    HomeDir: "/ABSPATH/.xpla",
    SecurityContact: "contact point",
    Identity: "identity",
    NodeID: "nodeid",
    ChainID: "chainid",
    Moniker: "moniker",
    Details: "details",
    Amount: "100000",
}

// Create validator using string values
createValidatorMsg := types.CreateValidatorMsg{
    NodeKey:                 NodeKey,
    PrivValidatorKey:        PrivValidatorKey,
    ValidatorAddress:        "xplavaloper10gv4zj9633v6cje6s2sc0a0xl52hjr6f9jp0q7",
    Moniker:                 "moniker",
    Identity:                "identity",
    Website:                 "website",
    SecurityContact:         "securityContact",
    Details:                 "details",
    Amount:                  "amount",
    CommissionRate:          "commissionRate",
    CommissionMaxRate:       "commissionMaxRate",
    CommissionMaxChangeRate: "commissionMaxChangeRate",
    MinSelfDelegation:       "minSelfDelegation",
}

txbytes, err := xplac.CreateValidator(createValidatorMsg).CreateAndSignTx()
(Tx) Edit validator
editValidatorMsg := types.EditValidatorMsg{		
    Website: "website",
    SecurityContact: "securitycontact",
    Identity: "identity",    
    Details: "details",
    Moniker: "moniker",
    CommissionRate: "commissionRate",	
    MinSelfDelegation: "minSelfDelegation",
}
txbytes, err := xplac.EditValidator(editValidatorMsg).CreateAndSignTx()
res, err := xplac.Broadcast(txbytes)
(Tx) Delegate
delegateMsg := types.DelegateMsg{
    Amount: "1000axpla",
    ValAddr: "xplavaloper19yq7kjcgse7x672faptju0lxmy4cvdlcsx9ftw",
}
txbytes, err := xplac.Delegate(delegateMsg).CreateAndSignTx()
res, err := xplac.Broadcast(txbytes)
(Tx) Unbond
unbondMsg := types.UnbondMsg{
    Amount: "100axpla",
    ValAddr: "xplavaloper19yq7kjcgse7x672faptju0lxmy4cvdlcsx9ftw",
}
txbytes, err := xplac.Unbond(unbondMsg).CreateAndSignTx()
res, err := xplac.Broadcast(txbytes)
(Tx) Redelegate
redelegateMsg := types.RedelegateMsg{
    Amount: "100axpla",
    ValSrcAddr: "xplavaloper19yq7kjcgse7x672faptju0lxmy4cvdlcsx9ftw",
    ValDstAddr: "xplavaloper1r7tdqs8zgtkty2u06yp5nw6dc6c9hvz9ak98r5",
}
txbytes, err := xplac.Redelegate(redelegateMsg).CreateAndSignTx()
res, err := xplac.Broadcast(txbytes)
(Query) validators
// Query all validators
res, err := xplac.QueryValidators().Query()

// Query validator by retrieving validator address
queryValidatorMsg := types.QueryValidatorMsg {
    ValidatorAddr: "xplavaloper13trl452wgle9qxpxhse9605k9x0399cm85pf34",
}
res, err := xplac.QueryValidators(queryValidatorMsg).Query()
(Query) delegation
// Query a delegation based on address and validator address 
queryDelegationMsg := types.QueryDelegationMsg {
    DelegatorAddr: "xpla1e4f6k98es55vxxv2pcfzpsjrf3mvazeyqpw8g9",
    ValidatorAddr: "xplavaloper19yq7kjcgse7x672faptju0lxmy4cvdlcsx9ftw",
}

// Query all delegations made by one delegator 
queryDelegationMsg := types.QueryDelegationMsg {
    DelegatorAddr: "xpla1e4f6k98es55vxxv2pcfzpsjrf3mvazeyqpw8g9",
}

// Query all delegations made to one validator
queryDelegationMsg := types.QueryDelegationMsg {
    ValidatorAddr: "xplavaloper19yq7kjcgse7x672faptju0lxmy4cvdlcsx9ftw",
}

res, err := xplac.QueryDelegation(queryDelegationMsg).Query()
(Query) unbonding delegation
// Query an unbonding-delegation record based on delegator and validator address
queryUnbondingDelegationMsg := types.QueryUnbondingDelegationMsg {
    DelegatorAddr: "xpla1e4f6k98es55vxxv2pcfzpsjrf3mvazeyqpw8g9",
    ValidatorAddr: "xplavaloper19yq7kjcgse7x672faptju0lxmy4cvdlcsx9ftw",
}

// Query all unbonding-delegations records for one delegator
queryUnbondingDelegationMsg := types.QueryUnbondingDelegationMsg {
    DelegatorAddr: "xpla1e4f6k98es55vxxv2pcfzpsjrf3mvazeyqpw8g9",
}

// Query all unbonding delegatations from a validator
queryUnbondingDelegationMsg := types.QueryUnbondingDelegationMsg {    
    ValidatorAddr: "xplavaloper19yq7kjcgse7x672faptju0lxmy4cvdlcsx9ftw",
}

res, err := xplac.QueryUnbondingDelegation(queryUnbondingDelegationMsg).Query()
(Query) Redelegations
// Query a redelegation record based on delegator and a source and destination validator
queryRedelegationMsg := types.QueryRedelegationMsg{
    DelegatorAddr: "xpla1e4f6k98es55vxxv2pcfzpsjrf3mvazeyqpw8g9",    	
    SrcValidatorAddr: "xplavaloper19yq7kjcgse7x672faptju0lxmy4cvdlcsx9ftw",
    DstValidatorAddr: "xplavaloper1r7tdqs8zgtkty2u06yp5nw6dc6c9hvz9ak98r5",
}

// Query all redelegations records for one delegator
queryRedelegationMsg := types.QueryRedelegationMsg{
    DelegatorAddr: "xpla1e4f6k98es55vxxv2pcfzpsjrf3mvazeyqpw8g9",    		
}

// Query all outgoing redelegations from a validator
queryRedelegationMsg := types.QueryRedelegationMsg{
    SrcValidatorAddr: "xplavaloper19yq7kjcgse7x672faptju0lxmy4cvdlcsx9ftw",
}

res, err := xplac.QueryRedelegation(queryRedelegationMsg).Query()
(Query) Historical info
historicalInfoMsg := types.HistoricalInfoMsg{
    Height: "2000",
}

res, err := xplac.HistoricalInfo(historicalInfoMsg).Query()
(Query) staking pool
res, err := xplac.StakingPool().Query()
(Query) staking params
res, err := xplac.StakingParams().Query()

Documentation

Index

Constants

View Source
const (
	StakingModule                               = "staking"
	StakingCreateValidatorMsgType               = "create-validator"
	StakingEditValidatorMsgType                 = "edit-validator"
	StakingDelegateMsgType                      = "delegate"
	StakingRedelegateMsgType                    = "redelegate"
	StakingUnbondMsgType                        = "unbond"
	StakingQueryValidatorMsgType                = "query-validator"
	StakingQueryValidatorsMsgType               = "query-validators"
	StakingQueryDelegationMsgType               = "query-delegation"
	StakingQueryDelegationsMsgType              = "query-delegations"
	StakingQueryDelegationsToMsgType            = "query-delegations-to"
	StakingQueryUnbondingDelegationMsgType      = "query-unbonding-delegation"
	StakingQueryUnbondingDelegationsMsgType     = "query-unbonding-delegations"
	StakingQueryUnbondingDelegationsFromMsgType = "query-unbonding-delegations-from"
	StakingQueryRedelegationMsgType             = "query-redelegation"
	StakingQueryRedelegationsMsgType            = "query-redelegations"
	StakingQueryRedelegationsFromMsgType        = "query-redelegations-from"
	StakingHistoricalInfoMsgType                = "historical-info"
	StakingQueryStakingPoolMsgType              = "query-staking-pool"
	StakingQueryStakingParamsMsgType            = "query-staking-params"
)

Variables

This section is empty.

Functions

func MakeCreateValidatorMsg

func MakeCreateValidatorMsg(createValidatorMsg types.CreateValidatorMsg, from sdk.AccAddress, output string) (sdk.Msg, error)

(Tx) make msg - create validator

func MakeDelegateMsg

func MakeDelegateMsg(delegateMsg types.DelegateMsg, delAddr sdk.AccAddress) (stakingtypes.MsgDelegate, error)

(Tx) make msg - delegate

func MakeEditValidatorMsg

func MakeEditValidatorMsg(editValidatorMsg types.EditValidatorMsg, addr sdk.AccAddress) (stakingtypes.MsgEditValidator, error)

(Tx) make msg - edit validator

func MakeHistoricalInfoMsg

func MakeHistoricalInfoMsg(historicalInfoMsg types.HistoricalInfoMsg) (stakingtypes.QueryHistoricalInfoRequest, error)

(Query) make msg - historical

func MakeQueryDelegationMsg

func MakeQueryDelegationMsg(queryDelegationMsg types.QueryDelegationMsg) (stakingtypes.QueryDelegationRequest, error)

(Query) make msg - query delegation

func MakeQueryDelegationsMsg

func MakeQueryDelegationsMsg(queryDelegationMsg types.QueryDelegationMsg) (stakingtypes.QueryDelegatorDelegationsRequest, error)

(Query) make msg - query delegations

func MakeQueryDelegationsToMsg

func MakeQueryDelegationsToMsg(queryDelegationMsg types.QueryDelegationMsg) (stakingtypes.QueryValidatorDelegationsRequest, error)

(Query) make msg - query delegations to

func MakeQueryRedelegationMsg

func MakeQueryRedelegationMsg(queryRedelegationMsg types.QueryRedelegationMsg) (stakingtypes.QueryRedelegationsRequest, error)

(Query) make msg - query redelegation

func MakeQueryRedelegationsFromMsg

func MakeQueryRedelegationsFromMsg(queryRedelegationMsg types.QueryRedelegationMsg) (stakingtypes.QueryRedelegationsRequest, error)

(Query) make msg - query redelegations from

func MakeQueryRedelegationsMsg

func MakeQueryRedelegationsMsg(queryRedelegationMsg types.QueryRedelegationMsg) (stakingtypes.QueryRedelegationsRequest, error)

(Query) make msg - query redelegations

func MakeQueryStakingParamsMsg

func MakeQueryStakingParamsMsg() (stakingtypes.QueryParamsRequest, error)

(Query) make msg - staking params

func MakeQueryStakingPoolMsg

func MakeQueryStakingPoolMsg() (stakingtypes.QueryPoolRequest, error)

(Query) make msg - staking pool

func MakeQueryUnbondingDelegationMsg

func MakeQueryUnbondingDelegationMsg(queryUnbondingDelegationMsg types.QueryUnbondingDelegationMsg) (stakingtypes.QueryUnbondingDelegationRequest, error)

(Query) make msg - query unbonding delegation

func MakeQueryUnbondingDelegationsFromMsg

func MakeQueryUnbondingDelegationsFromMsg(queryUnbondingDelegationMsg types.QueryUnbondingDelegationMsg) (stakingtypes.QueryValidatorUnbondingDelegationsRequest, error)

(Query) make msg - query unbonding delegations from

func MakeQueryUnbondingDelegationsMsg

func MakeQueryUnbondingDelegationsMsg(queryUnbondingDelegationMsg types.QueryUnbondingDelegationMsg) (stakingtypes.QueryDelegatorUnbondingDelegationsRequest, error)

(Query) make msg - query unbonding delegations

func MakeQueryValidatorMsg

func MakeQueryValidatorMsg(queryValidatorMsg types.QueryValidatorMsg) (stakingtypes.QueryValidatorRequest, error)

(Query) make msg - validator

func MakeQueryValidatorsMsg

func MakeQueryValidatorsMsg() (stakingtypes.QueryValidatorsRequest, error)

(Query) make msg - validators

func MakeRedelegateMsg

func MakeRedelegateMsg(redelegateMsg types.RedelegateMsg, delAddr sdk.AccAddress) (stakingtypes.MsgBeginRedelegate, error)

(Tx) make msg - redelegate

func MakeUnbondMsg

func MakeUnbondMsg(unbondMsg types.UnbondMsg, delAddr sdk.AccAddress) (stakingtypes.MsgUndelegate, error)

(Tx) make msg - unbond

func NewCoreModule added in v0.1.2

func NewCoreModule() core.CoreModule

func QueryStaking

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

Query client for staking module.

Types

type FilePVKey

type FilePVKey struct {
	Address tmtypes.Address `json:"address"`
	PubKey  crypto.PubKey   `json:"pub_key"`
	PrivKey crypto.PrivKey  `json:"priv_key"`
}

type NodeKey

type NodeKey struct {
	PrivKey crypto.PrivKey `json:"priv_key"` // our priv key
}

type StakingExternal added in v0.1.2

type StakingExternal struct {
	Xplac provider.XplaClient
}

func NewStakingExternal added in v0.1.2

func NewStakingExternal(xplac provider.XplaClient) (e StakingExternal)

func (StakingExternal) CreateValidator added in v0.1.2

func (e StakingExternal) CreateValidator(createValidatorMsg types.CreateValidatorMsg) provider.XplaClient

Create new validator initialized with a self-delegation to it.

func (StakingExternal) Delegate added in v0.1.2

func (e StakingExternal) Delegate(delegateMsg types.DelegateMsg) provider.XplaClient

Delegate liquid tokens to a validator.

func (StakingExternal) EditValidator added in v0.1.2

func (e StakingExternal) EditValidator(editValidatorMsg types.EditValidatorMsg) provider.XplaClient

Edit an existing validator account.

func (StakingExternal) HistoricalInfo added in v0.1.2

func (e StakingExternal) HistoricalInfo(historicalInfoMsg types.HistoricalInfoMsg) provider.XplaClient

Query historical info at given height.

func (StakingExternal) QueryDelegation added in v0.1.2

func (e StakingExternal) QueryDelegation(queryDelegationMsg types.QueryDelegationMsg) provider.XplaClient

Query a delegation based on address and validator address, all out going redelegations from a validator or all delegations made by on delegator.

func (StakingExternal) QueryRedelegation added in v0.1.2

func (e StakingExternal) QueryRedelegation(queryRedelegationMsg types.QueryRedelegationMsg) provider.XplaClient

Query a redelegation record based on delegator and a source and destination validator. Also, query all outgoing redelegatations from a validator or all redelegations records for one delegator.

func (StakingExternal) QueryUnbondingDelegation added in v0.1.2

func (e StakingExternal) QueryUnbondingDelegation(queryUnbondingDelegationMsg types.QueryUnbondingDelegationMsg) provider.XplaClient

Query all unbonding delegatations from a validator, an unbonding-delegation record based on delegator and validator address or all unbonding-delegations records for one delegator.

func (StakingExternal) QueryValidators added in v0.1.2

func (e StakingExternal) QueryValidators(queryValidatorMsg ...types.QueryValidatorMsg) provider.XplaClient

Query a validator or for all validators.

func (StakingExternal) Redelegate added in v0.1.2

func (e StakingExternal) Redelegate(redelegateMsg types.RedelegateMsg) provider.XplaClient

Redelegate illiquid tokens from one validator to another.

func (StakingExternal) StakingParams added in v0.1.2

func (e StakingExternal) StakingParams() provider.XplaClient

Query the current staking parameters information.

func (StakingExternal) StakingPool added in v0.1.2

func (e StakingExternal) StakingPool() provider.XplaClient

Query the current staking pool values.

func (StakingExternal) Unbond added in v0.1.2

func (e StakingExternal) Unbond(unbondMsg types.UnbondMsg) provider.XplaClient

Unbond shares from a validator.

Jump to

Keyboard shortcuts

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