Skip to content

Commit e11955a

Browse files
authored
fix: claimed in staking info endpoint (#1445)
* fix: claimed in staking info endpoint * fix existing tests * add test for kusama (includes era 6508) * updated docs * implement new logic & update test responses * add test for partially claimed & overview = null * updated docs * output up until 84 eras & update tests * Remove yarn.lock files from PR * check before unwrapping & fix types * run linter * docs: added links & updated schema description * updated logic of claimed field for validator account - removed `partially claimed` value - added `undefined` value - updated tests * fix for claimed in case of validator account - bringing back `partially claimed` for validator * moved validator logic in separate function * adding first draft of nominator logic * nominator logic when validator era partially claimed - Added validator and nominator status types to allow specific status values for each - Updated existing test * added test for nominator * run linter * abstracting logic into separate functions * add implementation_details guide * remove docs dist * kept historical tests data but changed format * docs small update * Updated eras section & code comments * updated cases section in implementation guide * implemented optimization changes from Filippo * optimized era and depth calculation * updated claimedRewards & removed redundant check * updated eras function * updated implementation guide based on Filippos questions * updated the docs * add code_flow image in guide * updated copyright
1 parent 194f3e7 commit e11955a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+10463
-1855
lines changed

docs/src/openapi-v1.yaml

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,8 @@ paths:
415415
- staking
416416
summary: Get staking information for a _Stash_ account.
417417
description: Returns information about a _Stash_ account's staking activity.
418-
Replaces `/staking/{address}` from versions < v1.0.0.
418+
Replaces `/staking/{address}` from versions < v1.0.0. The _Stash_ account
419+
can be either a validator or nominator account.
419420
operationId: getStakingSummaryByAccountId
420421
parameters:
421422
- name: accountId
@@ -2819,11 +2820,15 @@ components:
28192820
format: unsignedInteger
28202821
nominations:
28212822
$ref: '#/components/schemas/Nominations'
2822-
stakingLedger:
2823+
staking:
28232824
$ref: '#/components/schemas/StakingLedger'
28242825
description: >-
2825-
Note: Runtime versions of Kusama less than 1062 will either have `lastReward` in place of
2826-
`claimedRewards`, or no field at all. This is related to changes in reward distribution. See: [Lazy Payouts](https://github.com/paritytech/substrate/pull/4474), [Simple Payouts](https://github.com/paritytech/substrate/pull/5406)
2826+
Note: For Sidecar versions prior to v.20.0.0, in field `claimedRewards` under `staking`, we return whatever we would find under `StakingLedger` with no further calculations.
2827+
From v.20.0.0 onwards, `claimedRewards` is calculated based on different calls: `lastReward`, `claimedRewards` or `legacyClaimedRewards`.
2828+
Note on lastReward: Runtime versions of Kusama less than 1062 will either have `lastReward` in place of
2829+
`claimedRewards`, or no field at all. This is related to changes in reward distribution.
2830+
See: [Lazy Payouts](https://github.com/paritytech/substrate/pull/4474),
2831+
[Simple Payouts](https://github.com/paritytech/substrate/pull/5406)
28272832
AccountStakingPayouts:
28282833
type: object
28292834
properties:
@@ -4822,11 +4827,28 @@ components:
48224827
format: unsignedInteger
48234828
claimedRewards:
48244829
type: array
4825-
description: Array of eras for which the stakers behind a validator have
4826-
claimed rewards. Only updated for _validators._
4830+
description: Array of objects, each containing an `era` and its corresponding `status`,
4831+
which represents the rewards status of the queried Stash account. The queried account can either be
4832+
a validator or nominator account. This array is populated with values from `stakingLedger.lastReward`,
4833+
`stakingLedger.legacyClaimedRewards` or `stakingLedger.claimedRewards`, as well as the
4834+
`query.staking.claimedRewards` call, depending on whether the queried block is before or after the migration.
4835+
For more details on the implementation and the migration, refer to the related PR
4836+
(https://github.com/paritytech/substrate-api-sidecar/pull/1445) and linked issue
4837+
(https://github.com/paritytech/substrate-api-sidecar/issues/1433#issuecomment-2075914389).
48274838
items:
4828-
type: string
4829-
format: unsignedInteger
4839+
type: object
4840+
properties:
4841+
era:
4842+
type: string
4843+
description: The era for which we check the rewards status.
4844+
format: unsignedInteger
4845+
status:
4846+
type: string
4847+
description: The rewards status of the stakers backing a validator.
4848+
enum:
4849+
- claimed
4850+
- unclaimed
4851+
- partially claimed
48304852
description: The staking ledger.
48314853
StakingProgress:
48324854
type: object

0 commit comments

Comments
 (0)