diff --git a/.gitignore b/.gitignore index 2e0ac11d118..a408297d893 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ tmp/ .yarn/* !.yarn/releases !.yarn/plugins +!.yarn/patches .pnp.* cc-test-reporter package-lock.json diff --git a/.yarn/patches/@polkadot-api-derive-npm-13.2.1-19d2cc1087.patch b/.yarn/patches/@polkadot-api-derive-npm-13.2.1-19d2cc1087.patch index e391a0578bf..22d963b8fee 100644 --- a/.yarn/patches/@polkadot-api-derive-npm-13.2.1-19d2cc1087.patch +++ b/.yarn/patches/@polkadot-api-derive-npm-13.2.1-19d2cc1087.patch @@ -1,49 +1,62 @@ diff --git a/cjs/staking/query.js b/cjs/staking/query.js -index 24826c714d1c6609d65ec379c385e9331e9e30cf..5da18f5c8beb005023beb078051ec22fd5f40210 100644 +index 24826c714d1c6609d65ec379c385e9331e9e30cf..bb28bdbf59b6a0d73563b36e634df9cf2fc645e7 100644 --- a/cjs/staking/query.js +++ b/cjs/staking/query.js -@@ -58,7 +58,8 @@ function filterRewards(stashIds, eras, claimedRewards, stakersOverview) { +@@ -58,7 +58,7 @@ function filterRewards(stashIds, eras, claimedRewards, stakersOverview) { }); }); } -function parseDetails(api, stashId, controllerIdOpt, nominatorsOpt, rewardDestinationOpts, validatorPrefs, exposure, stakingLedgerOpt, exposureMeta, claimedRewards, exposureEraStakers) { -+function parseDetails(api, stashId, controllerIdOpt, nominatorsOpt, rewardDestinationOpts, validatorPrefs, exposure, stakingLedgerOpt, exposureMeta, claimedRewards, exposureEraStakers, exposurePagedAll) { -+ ++function parseDetails(api, stashId, controllerIdOpt, nominatorsOpt, rewardDestinationOpts, validatorPrefs, exposure, stakingLedgerOpt, exposureMeta, claimedRewards, exposureEraStakers, allOtherNominators) { return { accountId: stashId, claimedRewardsEras: filterClaimedRewards(api, claimedRewards), -@@ -72,7 +73,8 @@ function parseDetails(api, stashId, controllerIdOpt, nominatorsOpt, rewardDestin +@@ -72,8 +72,9 @@ function parseDetails(api, stashId, controllerIdOpt, nominatorsOpt, rewardDestin rewardDestination: rewardDestinationCompat(rewardDestinationOpts), stakingLedger: stakingLedgerOpt.unwrapOrDefault(), stashId, - validatorPrefs +- }; + validatorPrefs, -+ allOtherNominators: exposurePagedAll.flatMap(([_, exposurePage]) => exposurePage.others) - }; ++ allOtherNominators ++}; } function getLedgers(api, optIds, { withLedger = false }) { -@@ -133,11 +135,14 @@ function getStashInfo(api, stashIds, activeEra, { withClaimedRewardsEras, withCo + const ids = optIds +@@ -133,11 +134,26 @@ function getStashInfo(api, stashIds, activeEra, { withClaimedRewardsEras, withCo : (0, rxjs_1.of)(stashIds.map(() => emptyClaimedRewards)), withExposureErasStakersLegacy && api.query.staking.erasStakers ? (0, rxjs_1.combineLatest)(stashIds.map((s) => api.query.staking.erasStakers(activeEra, s))) - : (0, rxjs_1.of)(stashIds.map(() => emptyExpoEraStakers)) + : (0, rxjs_1.of)(stashIds.map(() => emptyExpoEraStakers)), + withExposure && api.query.staking.erasStakersPaged -+ ? (0, rxjs_1.combineLatest)(stashIds.map((s) => api.query.staking.erasStakersPaged.entries(activeEra, s))) ++ ? (0, rxjs_1.combineLatest)( ++ stashIds.map( ++ (s) => api.query.staking.erasStakersPaged.entries(activeEra, s).pipe( ++ (0, rxjs_1.map)((exposurePagedAll) => exposurePagedAll.flatMap(([_, exposurePage]) => exposurePage.unwrapOrDefault().others)), ++ (0, rxjs_1.switchMap)((allOtherNominators) => allOtherNominators.length === 0 && api.query.staking.erasStakers ++ ? api.query.staking.erasStakers(activeEra, s).pipe( ++ (0, rxjs_1.map)((erasStakers) => erasStakers.others) ++ ) ++ : of(allOtherNominators) ++ ), ++ ) ++ ) ++ ) + : (0, rxjs_1.of)(stashIds.map(() => [])), ]); } function getBatch(api, activeEra, stashIds, flags, page) { - return getStashInfo(api, stashIds, activeEra, flags, page).pipe((0, rxjs_1.switchMap)(([controllerIdOpt, nominatorsOpt, rewardDestination, validatorPrefs, exposure, exposureMeta, claimedRewardsEras, exposureEraStakers]) => getLedgers(api, controllerIdOpt, flags).pipe((0, rxjs_1.map)((stakingLedgerOpts) => stashIds.map((stashId, index) => parseDetails(api, stashId, controllerIdOpt[index], nominatorsOpt[index], rewardDestination[index], validatorPrefs[index], exposure[index], stakingLedgerOpts[index], exposureMeta[index], claimedRewardsEras[index], exposureEraStakers[index])))))); -+ return getStashInfo(api, stashIds, activeEra, flags, page).pipe((0, rxjs_1.switchMap)(([controllerIdOpt, nominatorsOpt, rewardDestination, validatorPrefs, exposure, exposureMeta, claimedRewardsEras, exposureEraStakers, exposurePagedAll]) => getLedgers(api, controllerIdOpt, flags).pipe((0, rxjs_1.map)((stakingLedgerOpts) => stashIds.map((stashId, index) => parseDetails(api, stashId, controllerIdOpt[index], nominatorsOpt[index], rewardDestination[index], validatorPrefs[index], exposure[index], stakingLedgerOpts[index], exposureMeta[index], claimedRewardsEras[index], exposureEraStakers[index], exposurePagedAll[index])))))); ++ return getStashInfo(api, stashIds, activeEra, flags, page).pipe((0, rxjs_1.switchMap)(([controllerIdOpt, nominatorsOpt, rewardDestination, validatorPrefs, exposure, exposureMeta, claimedRewardsEras, exposureEraStakers, allOtherNominators]) => getLedgers(api, controllerIdOpt, flags).pipe((0, rxjs_1.map)((stakingLedgerOpts) => stashIds.map((stashId, index) => parseDetails(api, stashId, controllerIdOpt[index], nominatorsOpt[index], rewardDestination[index], validatorPrefs[index], exposure[index], stakingLedgerOpts[index], exposureMeta[index], claimedRewardsEras[index], exposureEraStakers[index], allOtherNominators[index])))))); } /** * @description From a stash, retrieve the controllerId and all relevant details diff --git a/cjs/staking/validators.js b/cjs/staking/validators.js -index 5d74f9b00630b7cbfe1fbab5cf584b18465be262..d1cb3892e363ef18209e048785cecfc6e7311b23 100644 +index 5d74f9b00630b7cbfe1fbab5cf584b18465be262..26bb503f74371b64256faddb8fc60a0df02e7637 100644 --- a/cjs/staking/validators.js +++ b/cjs/staking/validators.js -@@ -7,11 +7,12 @@ const index_js_1 = require("../util/index.js"); +@@ -7,7 +7,7 @@ const index_js_1 = require("../util/index.js"); function nextElected(instanceId, api) { return (0, index_js_1.memo)(instanceId, () => // Compatibility for future generation changes in staking. @@ -52,14 +65,18 @@ index 5d74f9b00630b7cbfe1fbab5cf584b18465be262..d1cb3892e363ef18209e048785cecfc6 ? api.derive.session.indexes().pipe( // only populate for next era in the last session, so track both here - entries are not // subscriptions, so we need a trigger - currentIndex acts as that trigger to refresh -- (0, rxjs_1.switchMap)(({ currentEra }) => api.query.staking.erasStakersPaged.keys(currentEra)), -+ (0, rxjs_1.switchMap)(({ currentEra }) => api.query.staking.erasStakersOverview.keys(currentEra).pipe(map((keys) => [keys, currentEra]))), -+ (0, rxjs_1.switchMap)(([keys, currentEra]) => keys.length === 0 && api.query.staking.erasStakers ? api.query.staking.erasStakers.keys(currentEra) : of(keys)), - // Dedupe any duplicates - (0, rxjs_1.map)((keys) => [...new Set(keys.map(({ args: [, accountId] }) => accountId.toString()))].map((a) => api.registry.createType('AccountId', a)))) - : api.query.staking.erasStakers +@@ -18,7 +18,8 @@ function nextElected(instanceId, api) { + ? api.derive.session.indexes().pipe( + // only populate for next era in the last session, so track both here - entries are not + // subscriptions, so we need a trigger - currentIndex acts as that trigger to refresh +- (0, rxjs_1.switchMap)(({ currentEra }) => api.query.staking.erasStakers.keys(currentEra)), ++ (0, rxjs_1.switchMap)(({ currentEra }) => api.query.staking.erasStakersOverview.keys(currentEra).pipe(map((keys) => [keys, currentEra]))), ++ (0, rxjs_1.switchMap)(([keys, currentEra]) => keys.length === 0 && api.query.staking.erasStakers ? api.query.staking.erasStakers.keys(currentEra) : of(keys)), + // Dedupe any duplicates + (0, rxjs_1.map)((keys) => [...new Set(keys.map(({ args: [, accountId] }) => accountId.toString()))].map((a) => api.registry.createType('AccountId', a)))) + : api.query.staking['currentElected']()); diff --git a/staking/query.js b/staking/query.js -index f9448e7b554df170c96971eccbe0c3c94f0fd695..0a3c5465701ca9438d9c4909161adb8229978eb4 100644 +index f9448e7b554df170c96971eccbe0c3c94f0fd695..342d569897e25dc40f9fdf7815f6dcf2e174772c 100644 --- a/staking/query.js +++ b/staking/query.js @@ -54,7 +54,7 @@ function filterRewards(stashIds, eras, claimedRewards, stakersOverview) { @@ -67,42 +84,76 @@ index f9448e7b554df170c96971eccbe0c3c94f0fd695..0a3c5465701ca9438d9c4909161adb82 }); } -function parseDetails(api, stashId, controllerIdOpt, nominatorsOpt, rewardDestinationOpts, validatorPrefs, exposure, stakingLedgerOpt, exposureMeta, claimedRewards, exposureEraStakers) { -+function parseDetails(api, stashId, controllerIdOpt, nominatorsOpt, rewardDestinationOpts, validatorPrefs, exposure, stakingLedgerOpt, exposureMeta, claimedRewards, exposureEraStakers, exposurePagedAll) { ++function parseDetails(api, stashId, controllerIdOpt, nominatorsOpt, rewardDestinationOpts, validatorPrefs, exposure, stakingLedgerOpt, exposureMeta, claimedRewards, exposureEraStakers, allOtherNominators) { return { accountId: stashId, claimedRewardsEras: filterClaimedRewards(api, claimedRewards), -@@ -68,7 +68,8 @@ function parseDetails(api, stashId, controllerIdOpt, nominatorsOpt, rewardDestin +@@ -68,8 +68,9 @@ function parseDetails(api, stashId, controllerIdOpt, nominatorsOpt, rewardDestin rewardDestination: rewardDestinationCompat(rewardDestinationOpts), stakingLedger: stakingLedgerOpt.unwrapOrDefault(), stashId, - validatorPrefs +- }; + validatorPrefs, -+ allOtherNominators: exposurePagedAll.flatMap(([_, exposurePage]) => exposurePage.unwrapOrDefault().others) - }; ++ allOtherNominators ++}; } function getLedgers(api, optIds, { withLedger = false }) { -@@ -129,11 +130,14 @@ function getStashInfo(api, stashIds, activeEra, { withClaimedRewardsEras, withCo + const ids = optIds +@@ -129,11 +130,26 @@ function getStashInfo(api, stashIds, activeEra, { withClaimedRewardsEras, withCo : of(stashIds.map(() => emptyClaimedRewards)), withExposureErasStakersLegacy && api.query.staking.erasStakers ? combineLatest(stashIds.map((s) => api.query.staking.erasStakers(activeEra, s))) - : of(stashIds.map(() => emptyExpoEraStakers)) + : of(stashIds.map(() => emptyExpoEraStakers)), + withExposure && api.query.staking.erasStakersPaged -+ ? combineLatest(stashIds.map((s) => api.query.staking.erasStakersPaged.entries(activeEra, s))) ++ ? combineLatest( ++ stashIds.map( ++ (s) => api.query.staking.erasStakersPaged.entries(activeEra, s).pipe( ++ map((exposurePagedAll) => exposurePagedAll.flatMap(([_, exposurePage]) => exposurePage.unwrapOrDefault().others)), ++ switchMap((allOtherNominators) => allOtherNominators.length === 0 && api.query.staking.erasStakers ++ ? api.query.staking.erasStakers(activeEra, s).pipe( ++ map((erasStakers) => erasStakers.others) ++ ) ++ : of(allOtherNominators) ++ ), ++ ) ++ ) ++ ) + : of(stashIds.map(() => [])), ]); } function getBatch(api, activeEra, stashIds, flags, page) { - return getStashInfo(api, stashIds, activeEra, flags, page).pipe(switchMap(([controllerIdOpt, nominatorsOpt, rewardDestination, validatorPrefs, exposure, exposureMeta, claimedRewardsEras, exposureEraStakers]) => getLedgers(api, controllerIdOpt, flags).pipe(map((stakingLedgerOpts) => stashIds.map((stashId, index) => parseDetails(api, stashId, controllerIdOpt[index], nominatorsOpt[index], rewardDestination[index], validatorPrefs[index], exposure[index], stakingLedgerOpts[index], exposureMeta[index], claimedRewardsEras[index], exposureEraStakers[index])))))); -+ return getStashInfo(api, stashIds, activeEra, flags, page).pipe(switchMap(([controllerIdOpt, nominatorsOpt, rewardDestination, validatorPrefs, exposure, exposureMeta, claimedRewardsEras, exposureEraStakers, exposurePagedAll]) => getLedgers(api, controllerIdOpt, flags).pipe(map((stakingLedgerOpts) => stashIds.map((stashId, index) => parseDetails(api, stashId, controllerIdOpt[index], nominatorsOpt[index], rewardDestination[index], validatorPrefs[index], exposure[index], stakingLedgerOpts[index], exposureMeta[index], claimedRewardsEras[index], exposureEraStakers[index], exposurePagedAll[index])))))); ++ return getStashInfo(api, stashIds, activeEra, flags, page).pipe(switchMap(([controllerIdOpt, nominatorsOpt, rewardDestination, validatorPrefs, exposure, exposureMeta, claimedRewardsEras, exposureEraStakers, allOtherNominators]) => getLedgers(api, controllerIdOpt, flags).pipe(map((stakingLedgerOpts) => stashIds.map((stashId, index) => parseDetails(api, stashId, controllerIdOpt[index], nominatorsOpt[index], rewardDestination[index], validatorPrefs[index], exposure[index], stakingLedgerOpts[index], exposureMeta[index], claimedRewardsEras[index], exposureEraStakers[index], allOtherNominators[index])))))); } /** * @description From a stash, retrieve the controllerId and all relevant details +diff --git a/staking/types.d.ts b/staking/types.d.ts +index 74e54287d69b3cfc7c9713cd744737bc7ac1078f..4dd7d49cb6baf9fea6f4b99e7cf91b40c0b4d2b0 100644 +--- a/staking/types.d.ts ++++ b/staking/types.d.ts +@@ -1,6 +1,6 @@ + import type { Option, u32, Vec } from '@polkadot/types'; + import type { AccountId, Balance, EraIndex, RewardPoint } from '@polkadot/types/interfaces'; +-import type { PalletStakingRewardDestination, PalletStakingStakingLedger, PalletStakingValidatorPrefs, SpStakingExposure, SpStakingExposurePage, SpStakingPagedExposureMetadata } from '@polkadot/types/lookup'; ++import type { PalletStakingRewardDestination, PalletStakingStakingLedger, PalletStakingValidatorPrefs, SpStakingExposure, SpStakingExposurePage, SpStakingPagedExposureMetadata, SpStakingIndividualExposure } from '@polkadot/types/lookup'; + import type { BN } from '@polkadot/util'; + import type { DeriveSessionIndexes } from '../session/types.js'; + export type DeriveEraValPoints = Record; +@@ -99,6 +99,7 @@ export interface DeriveStakingStash { + stashId: AccountId; + validatorPrefs: PalletStakingValidatorPrefs; + claimedRewardsEras: Vec; ++ allOtherNominators: Vec; + } + export interface DeriveStakingQuery extends DeriveStakingStash { + accountId: AccountId; diff --git a/staking/validators.js b/staking/validators.js -index bfaae2c0e0da493cc09b60fbb45ad9ceef0faf27..fa49037f2e822dd95b7208199d454d66cb8eddbf 100644 +index bfaae2c0e0da493cc09b60fbb45ad9ceef0faf27..f1930245c21969d5e502791dac0f6b61aa8cee68 100644 --- a/staking/validators.js +++ b/staking/validators.js -@@ -3,11 +3,12 @@ import { memo } from '../util/index.js'; +@@ -3,7 +3,7 @@ import { memo } from '../util/index.js'; export function nextElected(instanceId, api) { return memo(instanceId, () => // Compatibility for future generation changes in staking. @@ -111,9 +162,13 @@ index bfaae2c0e0da493cc09b60fbb45ad9ceef0faf27..fa49037f2e822dd95b7208199d454d66 ? api.derive.session.indexes().pipe( // only populate for next era in the last session, so track both here - entries are not // subscriptions, so we need a trigger - currentIndex acts as that trigger to refresh -- switchMap(({ currentEra }) => api.query.staking.erasStakersPaged.keys(currentEra)), -+ switchMap(({ currentEra }) => api.query.staking.erasStakersOverview.keys(currentEra).pipe(map((keys) => [keys, currentEra]))), -+ switchMap(([keys, currentEra]) => keys.length === 0 && api.query.staking.erasStakers ? api.query.staking.erasStakers.keys(currentEra) : of(keys)), - // Dedupe any duplicates - map((keys) => [...new Set(keys.map(({ args: [, accountId] }) => accountId.toString()))].map((a) => api.registry.createType('AccountId', a)))) - : api.query.staking.erasStakers +@@ -14,7 +14,8 @@ export function nextElected(instanceId, api) { + ? api.derive.session.indexes().pipe( + // only populate for next era in the last session, so track both here - entries are not + // subscriptions, so we need a trigger - currentIndex acts as that trigger to refresh +- switchMap(({ currentEra }) => api.query.staking.erasStakers.keys(currentEra)), ++ switchMap(({ currentEra }) => api.query.staking.erasStakersOverview.keys(currentEra).pipe(map((keys) => [keys, currentEra]))), ++ switchMap(([keys, currentEra]) => keys.length === 0 && api.query.staking.erasStakers ? api.query.staking.erasStakers.keys(currentEra) : of(keys)), + // Dedupe any duplicates + map((keys) => [...new Set(keys.map(({ args: [, accountId] }) => accountId.toString()))].map((a) => api.registry.createType('AccountId', a)))) + : api.query.staking['currentElected']()); diff --git a/packages/page-staking/src/Targets/Validator.tsx b/packages/page-staking/src/Targets/Validator.tsx index 645daf6607e..ab2a114f9b8 100644 --- a/packages/page-staking/src/Targets/Validator.tsx +++ b/packages/page-staking/src/Targets/Validator.tsx @@ -67,8 +67,6 @@ function Validator ({ allSlashes, canSelect, filterName, info: { accountId, bond return null; } - console.log(nominatedBy); - return ( ({ + nominatorsParsed = nominators.map(({ value, who }) => ({ nominatorId: who.toString(), value: value.unwrap() })); @@ -60,7 +60,7 @@ function expandInfo ({ exposureMeta, exposurePaged, validatorPrefs }: ValidatorI return { commission: commission?.toHuman(), - nominators, + nominators: nominatorsParsed, stakeOther, stakeOwn, stakeTotal diff --git a/packages/page-staking/src/types.ts b/packages/page-staking/src/types.ts index 15ae4499df7..e1bd9194ed6 100644 --- a/packages/page-staking/src/types.ts +++ b/packages/page-staking/src/types.ts @@ -4,7 +4,7 @@ import type { Inflation } from '@polkadot/react-hooks/types'; import type { Vec } from '@polkadot/types'; import type { AccountId, Balance, BlockNumber, EraIndex, Hash, SessionIndex, ValidatorPrefs, ValidatorPrefsTo196 } from '@polkadot/types/interfaces'; -import type { SpStakingExposurePage, SpStakingPagedExposureMetadata } from '@polkadot/types/lookup'; +import type { SpStakingExposurePage, SpStakingIndividualExposure, SpStakingPagedExposureMetadata } from '@polkadot/types/lookup'; import type { BN } from '@polkadot/util'; export type Nominators = Record; @@ -69,6 +69,7 @@ export interface ValidatorInfo extends ValidatorInfoRank { knownLength: BN; lastPayout?: BN; minNominated: BN; + nominators: Vec; numNominators: number; numRecentPayouts: number; skipRewards: boolean; diff --git a/packages/page-staking/src/useSortedTargets.ts b/packages/page-staking/src/useSortedTargets.ts index 0fdec73eccb..6ffe81b2637 100644 --- a/packages/page-staking/src/useSortedTargets.ts +++ b/packages/page-staking/src/useSortedTargets.ts @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 import type { ApiPromise } from '@polkadot/api'; -import type { DeriveSessionInfo, DeriveStakingElected, DeriveStakingQuery, DeriveStakingWaiting } from '@polkadot/api-derive/types'; +import type { DeriveSessionInfo, DeriveStakingElected, DeriveStakingWaiting } from '@polkadot/api-derive/types'; import type { Inflation } from '@polkadot/react-hooks/types'; import type { Option, u32, Vec } from '@polkadot/types'; -import type { PalletStakingStakingLedger, SpStakingExposure, SpStakingExposurePage, SpStakingIndividualExposure, SpStakingPagedExposureMetadata } from '@polkadot/types/lookup'; +import type { PalletStakingStakingLedger, SpStakingExposure, SpStakingExposurePage, SpStakingPagedExposureMetadata } from '@polkadot/types/lookup'; import type { EraValidators, SortedTargets, TargetSortBy, ValidatorInfo } from './types.js'; import { useMemo } from 'react'; @@ -35,18 +35,6 @@ interface OldLedger { claimedRewards: Vec; } -interface PatchedDeriveStakingQuery extends DeriveStakingQuery { - allOtherNominators: Vec; -} - -interface PatchedDeriveStakingElected extends DeriveStakingElected { - info: PatchedDeriveStakingQuery[]; -} - -interface PatchedDeriveStakingWaiting extends DeriveStakingWaiting { - info: PatchedDeriveStakingQuery[]; -} - const EMPTY_PARTIAL: Partial = {}; const DEFAULT_FLAGS_ELECTED = { withController: true, withExposure: true, withExposureErasStakersLegacy: true, withExposureMeta: true, withPrefs: true }; const DEFAULT_FLAGS_WAITING = { withController: true, withExposureErasStakersLegacy: true, withExposureMeta: true, withPrefs: true }; @@ -187,7 +175,7 @@ function getForwardCompatibleExposureData (api: ApiPromise, legacyExposure: SpSt }; } -function extractSingle (api: ApiPromise, allAccounts: string[], derive: PatchedDeriveStakingElected | PatchedDeriveStakingWaiting, favorites: string[], { activeEra, lastEra }: LastEra, historyDepth?: BN, withReturns?: boolean): [ValidatorInfo[], Record] { +function extractSingle (api: ApiPromise, allAccounts: string[], derive: DeriveStakingElected | DeriveStakingWaiting, favorites: string[], { activeEra, lastEra }: LastEra, historyDepth?: BN, withReturns?: boolean): [ValidatorInfo[], Record] { const nominators: Record = {}; const emptyExposure = api.createType('SpStakingExposurePage'); const emptyExposureMeta = api.createType('SpStakingPagedExposureMetadata'); @@ -254,6 +242,7 @@ function extractSingle (api: ApiPromise, allAccounts: string[], derive: PatchedD ? lastEraPayout : undefined, minNominated, + nominators: allOtherNominators, numNominators: expMeta?.nominatorCount.toNumber() ?? 0, numRecentPayouts: earliestEra ? rewards.filter((era) => era.gte(earliestEra)).length @@ -292,7 +281,7 @@ function addReturns (inflation: Inflation, baseInfo: Partial): Pa return { ...baseInfo, validators: sortValidators(validators) }; } -function extractBaseInfo (api: ApiPromise, allAccounts: string[], electedDerive: PatchedDeriveStakingElected, waitingDerive: PatchedDeriveStakingWaiting, favorites: string[], totalIssuance: BN, lastEraInfo: LastEra, historyDepth?: BN): Partial { +function extractBaseInfo (api: ApiPromise, allAccounts: string[], electedDerive: DeriveStakingElected, waitingDerive: DeriveStakingWaiting, favorites: string[], totalIssuance: BN, lastEraInfo: LastEra, historyDepth?: BN): Partial { const [elected, nominators] = extractSingle(api, allAccounts, electedDerive, favorites, lastEraInfo, historyDepth, true); const [waiting] = extractSingle(api, allAccounts, waitingDerive, favorites, lastEraInfo); const activeTotals = elected @@ -351,8 +340,8 @@ function useSortedTargetsImpl (favorites: string[], withLedger: boolean): Sorted api.query.staking.minValidatorBond, api.query.balances?.totalIssuance ], OPT_MULTI); - const electedInfo = useCall(api.derive.staking.electedInfo, [{ ...DEFAULT_FLAGS_ELECTED, withClaimedRewardsEras: withLedger, withLedger }]); - const waitingInfo = useCall(api.derive.staking.waitingInfo, [{ ...DEFAULT_FLAGS_WAITING, withClaimedRewardsEras: withLedger, withLedger }]); + const electedInfo = useCall(api.derive.staking.electedInfo, [{ ...DEFAULT_FLAGS_ELECTED, withClaimedRewardsEras: withLedger, withLedger }]); + const waitingInfo = useCall(api.derive.staking.waitingInfo, [{ ...DEFAULT_FLAGS_WAITING, withClaimedRewardsEras: withLedger, withLedger }]); const lastEraInfo = useCall(api.derive.session.info, undefined, OPT_ERA); const eraValidators = useCall(api.query.elections.currentEraValidators); diff --git a/yarn.lock b/yarn.lock index 5304a2b17e9..299057cd575 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1404,7 +1404,7 @@ __metadata: "@polkadot/api-derive@patch:@polkadot/api-derive@npm%3A13.2.1#~/.yarn/patches/@polkadot-api-derive-npm-13.2.1-19d2cc1087.patch": version: 13.2.1 - resolution: "@polkadot/api-derive@patch:@polkadot/api-derive@npm%3A13.2.1#~/.yarn/patches/@polkadot-api-derive-npm-13.2.1-19d2cc1087.patch::version=13.2.1&hash=50f2f4" + resolution: "@polkadot/api-derive@patch:@polkadot/api-derive@npm%3A13.2.1#~/.yarn/patches/@polkadot-api-derive-npm-13.2.1-19d2cc1087.patch::version=13.2.1&hash=ebde46" dependencies: "@polkadot/api": "npm:13.2.1" "@polkadot/api-augment": "npm:13.2.1" @@ -1416,7 +1416,7 @@ __metadata: "@polkadot/util-crypto": "npm:^13.1.1" rxjs: "npm:^7.8.1" tslib: "npm:^2.7.0" - checksum: 10/634a405935c195c741167ae9420010f4a8104fc36a7f5012b26eeb99b37e906a70494d4d8ba7bdf0c295a70a05e3c57fa35b36b0760adabf6e2ce316ef390d88 + checksum: 10/9e61105efbd24dc76b3e04a83edc05f7b7d777fd05946f06780442f9175b309fbc0190a45d80d4b042127b3da09bd7db353bca82af3fb699a9ac83926bcaf800 languageName: node linkType: hard