utils

package
v0.0.0-...-82415a5 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2021 License: MIT Imports: 19 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ErrDelegationNotFound = "rpc error: code = %s desc = rpc error: code = %s"
)

Variables

This section is empty.

Functions

func ConvertDelegationResponse

func ConvertDelegationResponse(height int64, response stakingtypes.DelegationResponse) types.Delegation

ConvertDelegationResponse converts the given response to a BDJuno Delegation instance

func ConvertRedelegationResponse

func ConvertRedelegationResponse(
	height int64, bondDenom string, response stakingtypes.RedelegationResponse,
) []types.Redelegation

ConvertRedelegationResponse converts the given response into a slice of BDJuno redelegation objects

func ConvertUnbondingResponse

func ConvertUnbondingResponse(
	height int64, bondDenom string, response stakingtypes.UnbondingDelegation,
) []types.UnbondingDelegation

ConvertUnbondingResponse converts the given UnbondingDelegation response into a slice of BDJuno UnbondingDelegation

func ConvertValidator

func ConvertValidator(
	cdc codec.Marshaler, validator stakingtypes.Validator, height int64,
) (types.Validator, error)

ConvertValidator converts the given staking validator into a BDJuno validator

func ConvertValidatorDescription

func ConvertValidatorDescription(
	opAddr string, description stakingtypes.Description, height int64,
) (types.ValidatorDescription, error)

ConvertValidatorDescription returns a new types.ValidatorDescription object by fetching the avatar URL using the Keybase APIs

func GetDelegatorDelegations

func GetDelegatorDelegations(height int64, delegator string, client stakingtypes.QueryClient) ([]types.Delegation, error)

GetDelegatorDelegations returns the current delegations for the given delegator

func GetDelegatorRedelegations

func GetDelegatorRedelegations(
	height int64, address string, bondDenom string, stakingClient stakingtypes.QueryClient,
) ([]types.Redelegation, error)

GetDelegatorRedelegations returns the current redelegations for the user having the given address

func GetDelegatorUnbondingDelegations

func GetDelegatorUnbondingDelegations(
	height int64, address string, bondDenom string, stakingClient stakingtypes.QueryClient,
) ([]types.UnbondingDelegation, error)

GetDelegatorUnbondingDelegations returns the current unbonding delegations for the user having the given address

func GetStakingPool

func GetStakingPool(height int64, stakingClient stakingtypes.QueryClient) (*types.Pool, error)

func GetValidatorConsAddr

func GetValidatorConsAddr(cdc codec.Marshaler, validator stakingtypes.Validator) (sdk.ConsAddress, error)

GetValidatorConsAddr returns the consensus address of the given validator

func GetValidatorConsPubKey

func GetValidatorConsPubKey(cdc codec.Marshaler, validator stakingtypes.Validator) (cryptotypes.PubKey, error)

GetValidatorConsPubKey returns the consensus public key of the given validator

func GetValidators

func GetValidators(
	height int64, stakingClient stakingtypes.QueryClient, cdc codec.Marshaler,
) ([]stakingtypes.Validator, []types.Validator, error)

GetValidators returns the validators list at the given height

func GetValidatorsStatuses

func GetValidatorsStatuses(height int64, validators []stakingtypes.Validator, cdc codec.Marshaler) ([]types.ValidatorStatus, error)

func GetValidatorsVotingPowers

func GetValidatorsVotingPowers(height int64, vals *tmctypes.ResultValidators, db *database.Db) []types.ValidatorVotingPower

func GetValidatorsWithStatus

func GetValidatorsWithStatus(
	height int64, status string, stakingClient stakingtypes.QueryClient, cdc codec.Marshaler,
) ([]stakingtypes.Validator, []types.Validator, error)

GetValidatorsWithStatus returns the list of all the validators having the given status at the given height

func RefreshDelegations

func RefreshDelegations(
	height int64, delegator string,
	stakingClient stakingtypes.QueryClient, distrClient distrtypes.QueryClient,
	db *database.Db,
) error

RefreshDelegations updates the delegations of the given delegator by querying them at the required height, and then stores them inside the database by replacing all existing ones.

func StoreDelegationFromMessage

func StoreDelegationFromMessage(
	height int64, msg *stakingtypes.MsgDelegate, stakingClient stakingtypes.QueryClient, db *database.Db,
) error

StoreDelegationFromMessage handles a MsgDelegate and saves the delegation inside the database

func StoreRedelegationFromMessage

func StoreRedelegationFromMessage(
	tx *juno.Tx, index int, msg *stakingtypes.MsgBeginRedelegate, db *database.Db,
) (*types.Redelegation, error)

StoreRedelegationFromMessage handles a MsgBeginRedelegate by saving the redelegation inside the database, and returns the new redelegation instance

func StoreUnbondingDelegationFromMessage

func StoreUnbondingDelegationFromMessage(
	tx *juno.Tx, index int, msg *stakingtypes.MsgUndelegate, db *database.Db,
) (*types.UnbondingDelegation, error)

StoreUnbondingDelegationFromMessage handles a MsgUndelegate storing the new unbonding delegation inside the database, and returns the new unbonding delegation instance

func StoreValidatorFromMsgCreateValidator

func StoreValidatorFromMsgCreateValidator(
	height int64, msg *stakingtypes.MsgCreateValidator, cdc codec.Marshaler, db *database.Db,
) error

StoreValidatorFromMsgCreateValidator handles properly a MsgCreateValidator instance by saving into the database all the data associated to such validator

func UpdateValidators

func UpdateValidators(
	height int64, client stakingtypes.QueryClient, cdc codec.Marshaler, db *database.Db,
) ([]stakingtypes.Validator, error)

UpdateValidators updates the list of validators that are present at the given height

func UpdateValidatorsDelegations

func UpdateValidatorsDelegations(
	height int64, validators []stakingtypes.Validator, client stakingtypes.QueryClient, db *database.Db,
)

UpdateValidatorsDelegations updates the delegations for all the given validators at the provided height

func UpdateValidatorsRedelegations

func UpdateValidatorsRedelegations(
	height int64, bondDenom string, validators []stakingtypes.Validator, client stakingtypes.QueryClient, db *database.Db,
)

UpdateValidatorsRedelegations updates the redelegations for all the validators provided

func UpdateValidatorsUnbondingDelegations

func UpdateValidatorsUnbondingDelegations(
	height int64, bondDenom string, validators []stakingtypes.Validator,
	client stakingtypes.QueryClient, db *database.Db,
)

UpdateValidatorsUnbondingDelegations updates the unbonding delegations for all the validators provided

Types

This section is empty.

Jump to

Keyboard shortcuts

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