Skip to content

Commit

Permalink
fix: add nominations in staking-info endpoint (#1448)
Browse files Browse the repository at this point in the history
  • Loading branch information
Imod7 committed Jun 6, 2024
1 parent 1fe1b46 commit b048648
Show file tree
Hide file tree
Showing 27 changed files with 39 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"stash": null
},
"numSlashingSpans": "2",
"nominations": null,
"staking": {
"stash": "HP8qJ8P4u4W2QgsJ8jzVuSsjfFTT6orQomFD6eTRSGEbiTK",
"total": "497576923500",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"stash": null
},
"numSlashingSpans": "2",
"nominations": null,
"staking": {
"stash": "HP8qJ8P4u4W2QgsJ8jzVuSsjfFTT6orQomFD6eTRSGEbiTK",
"total": "497576923500",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"stash": null
},
"numSlashingSpans": "3",
"nominations": null,
"staking": {
"stash": "HP8qJ8P4u4W2QgsJ8jzVuSsjfFTT6orQomFD6eTRSGEbiTK",
"total": "497576923500",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"stash": null
},
"numSlashingSpans": "3",
"nominations": null,
"staking": {
"stash": "HP8qJ8P4u4W2QgsJ8jzVuSsjfFTT6orQomFD6eTRSGEbiTK",
"total": "497576923500",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"stash": null
},
"numSlashingSpans": "3",
"nominations": null,
"staking": {
"stash": "HP8qJ8P4u4W2QgsJ8jzVuSsjfFTT6orQomFD6eTRSGEbiTK",
"total": "497576923500",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"stash": null
},
"numSlashingSpans": "3",
"nominations": null,
"staking": {
"stash": "HP8qJ8P4u4W2QgsJ8jzVuSsjfFTT6orQomFD6eTRSGEbiTK",
"total": "497576923500",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"stash": null
},
"numSlashingSpans": "2",
"nominations": null,
"staking": {
"stash": "HP8qJ8P4u4W2QgsJ8jzVuSsjfFTT6orQomFD6eTRSGEbiTK",
"total": "497576923500",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"stash": null
},
"numSlashingSpans": "2",
"nominations": null,
"staking": {
"stash": "HP8qJ8P4u4W2QgsJ8jzVuSsjfFTT6orQomFD6eTRSGEbiTK",
"total": "497576923500",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"stash": null
},
"numSlashingSpans": "3",
"nominations": null,
"staking": {
"stash": "HP8qJ8P4u4W2QgsJ8jzVuSsjfFTT6orQomFD6eTRSGEbiTK",
"total": "497576923500",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"stash": null
},
"numSlashingSpans": "2",
"nominations": null,
"staking": {
"stash": "HP8qJ8P4u4W2QgsJ8jzVuSsjfFTT6orQomFD6eTRSGEbiTK",
"total": "497576923500",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"stash": null
},
"numSlashingSpans": "2",
"nominations": null,
"staking": {
"stash": "HP8qJ8P4u4W2QgsJ8jzVuSsjfFTT6orQomFD6eTRSGEbiTK",
"total": "497576923500",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"staked": null
},
"numSlashingSpans": "0",
"nominations": null,
"staking": {
"stash": "16SpacegeUTft9v3ts27CEC3tJaxgvE4uZeCctThFH3Vb24p",
"total": "146275200613711",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"stash": null
},
"numSlashingSpans": "0",
"nominations": null,
"staking": {
"stash": "16SpacegeUTft9v3ts27CEC3tJaxgvE4uZeCctThFH3Vb24p",
"total": "155514320103496",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"staked": null
},
"numSlashingSpans": "0",
"nominations": null,
"staking": {
"stash": "16SpacegeUTft9v3ts27CEC3tJaxgvE4uZeCctThFH3Vb24p",
"total": "138910737119627",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"staked": null
},
"numSlashingSpans": "0",
"nominations": null,
"staking": {
"stash": "16SpacegeUTft9v3ts27CEC3tJaxgvE4uZeCctThFH3Vb24p",
"total": "155902410746517",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"stash": null
},
"numSlashingSpans": "0",
"nominations": null,
"staking": {
"stash": "16SpacegeUTft9v3ts27CEC3tJaxgvE4uZeCctThFH3Vb24p",
"total": "161445433495009",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"account": "12imiRFgMGpPPVRiXLhQixuk1jMeTrQbzSJcZ4Bj7a3idmWT"
},
"numSlashingSpans": "0",
"nominations": null,
"staking": {
"stash": "13HtFCrxyz55KgkPWcnhHPwE8f8GmZrfXR3uC6jNrihGzmqz",
"total": "200000000000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"account": "12imiRFgMGpPPVRiXLhQixuk1jMeTrQbzSJcZ4Bj7a3idmWT"
},
"numSlashingSpans": "0",
"nominations": null,
"staking": {
"stash": "13HtFCrxyz55KgkPWcnhHPwE8f8GmZrfXR3uC6jNrihGzmqz",
"total": "200000000000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"stash": null
},
"numSlashingSpans": "0",
"nominations": null,
"staking": {
"stash": "16SpacegeUTft9v3ts27CEC3tJaxgvE4uZeCctThFH3Vb24p",
"total": "10000000495009",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"stash": null
},
"numSlashingSpans": "0",
"nominations": null,
"staking": {
"stash": "16SpacegeUTft9v3ts27CEC3tJaxgvE4uZeCctThFH3Vb24p",
"total": "10000000495009",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"stash": null
},
"numSlashingSpans": "0",
"nominations": null,
"staking": {
"stash": "16SpacegeUTft9v3ts27CEC3tJaxgvE4uZeCctThFH3Vb24p",
"total": "10000000495009",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"stash": null
},
"numSlashingSpans": "0",
"nominations": null,
"staking": {
"stash": "16SpacegeUTft9v3ts27CEC3tJaxgvE4uZeCctThFH3Vb24p",
"total": "10000000495009",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"staked": null
},
"numSlashingSpans": "0",
"nominations": null,
"staking": {
"stash": "5Ek5JCnrRsyUGYNRaEvkufG1i1EUxEE9cytuWBBjA9oNZVsf",
"total": "10199950300000000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"staked": null
},
"numSlashingSpans": "0",
"nominations": null,
"staking": {
"stash": "5ENXqYmc5m6VLMm5i1mun832xAv2Qm9t3M4PWAFvvyCJLNoR",
"total": "42423015315073767",
Expand Down
9 changes: 8 additions & 1 deletion src/services/accounts/AccountsStakingInfoService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017-2022 Parity Technologies (UK) Ltd.
// Copyright 2017-2024 Parity Technologies (UK) Ltd.
// This file is part of Substrate API Sidecar.
//
// Substrate API Sidecar is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -68,11 +68,18 @@ export class AccountsStakingInfoService extends AbstractService {

const numSlashingSpans = slashingSpansOption.isSome ? slashingSpansOption.unwrap().prior.length + 1 : 0;

let nominations = null;
if (historicApi.query.staking.nominators) {
const nominationsOption = await historicApi.query.staking.nominators(stash);
nominations = nominationsOption.unwrapOr(null);
}

return {
at,
controller,
rewardDestination,
numSlashingSpans,
nominations,
staking: stakingLedger,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"controller": null
},
"numSlashingSpans": "0",
"nominations": null,
"staking": {
"stash": "1zugcapKRuHy2C1PceJxTvXWiq6FHEDm2xa5XSU7KYP3rJE",
"total": "100000000000",
Expand Down
7 changes: 6 additions & 1 deletion src/types/responses/AccountStakingInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

import type { Option } from '@polkadot/types/codec';
import type { AccountId } from '@polkadot/types/interfaces/runtime';
import type { PalletStakingRewardDestination, PalletStakingStakingLedger } from '@polkadot/types/lookup';
import type {
PalletStakingNominations,
PalletStakingRewardDestination,
PalletStakingStakingLedger,
} from '@polkadot/types/lookup';

import { IAt } from '.';

Expand All @@ -25,5 +29,6 @@ export interface IAccountStakingInfo {
controller: AccountId;
rewardDestination: Option<PalletStakingRewardDestination>;
numSlashingSpans: number;
nominations: PalletStakingNominations | null;
staking: PalletStakingStakingLedger;
}

0 comments on commit b048648

Please sign in to comment.