Skip to main content
Version: Next

staking_delegations_to_bonded_validators/2

Module​

This predicate is provided by staking.pl.

Load this module before using the predicate:

:- consult('/v1/lib/staking.pl').

Description​

Unifies Delegations with the delegations of Delegator whose validators have bond status bonded. It preserves delegation order and balances. It does not additionally filter jailed validators. Unbondings, redelegation entries, and distribution rewards are not included. Delegator must be an AXONE account address atom in Bech32 format.

Signature​

staking_delegations_to_bonded_validators(+Delegator, -Delegations) is det

Examples​

Keep balances and order for bonded validators only​

Here is the feature setup:

  • Given the program:
:- consult('/v1/lib/staking.pl').
  • And the staking validators:
operatorstatusjailed
axonevaloper1bondedbondedfalse
axonevaloper1jailedbondedtrue
axonevaloper1unusedbondedfalse
axonevaloper1unbondingunbondingfalse
axonevaloper1unbondedunbondedfalse

Here are the steps of the scenario:

  • Given the account "axone1ffd5wx65l407yvm478cxzlgygw07h79sw4jwpa" has the following staking delegations:
validatordenomamount
axonevaloper1unbondinguaxone900
axonevaloper1jaileduaxone75
axonevaloper1unbondeduaxone800
axonevaloper1bondeduaxone25
axonevaloper1absentuaxone700
  • And the query:
staking_delegations_to_bonded_validators('axone1ffd5wx65l407yvm478cxzlgygw07h79sw4jwpa', Delegations).
  • When the query is run
  • Then the logical answer we get is:
answer:
has_more: false
variables: [Delegations]
results:
- substitutions:
- variable: Delegations
expression: "[delegation{balance:coin(uaxone,75),validator:axonevaloper1jailed},delegation{balance:coin(uaxone,25),validator:axonevaloper1bonded}]"