From 6559b1ad118bbc6acdfa145f54cfe1c567021e9d Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Wed, 2 Dec 2020 20:30:40 +0100 Subject: [PATCH] Retrieve ledger for payouts (#2901) --- packages/api-derive/src/staking/electedInfo.ts | 2 +- packages/api-derive/src/staking/query.ts | 10 +++++----- packages/api-derive/src/staking/waitingInfo.ts | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/api-derive/src/staking/electedInfo.ts b/packages/api-derive/src/staking/electedInfo.ts index bc407a8b0d..d8044ed1ef 100644 --- a/packages/api-derive/src/staking/electedInfo.ts +++ b/packages/api-derive/src/staking/electedInfo.ts @@ -18,7 +18,7 @@ export function electedInfo (instanceId: string, api: ApiInterfaceRx): () => Obs return memo(instanceId, (): Observable => api.derive.staking.validators().pipe( switchMap(({ nextElected, validators }): Observable => - api.derive.staking.queryMulti(combineAccounts(nextElected, validators), { withExposure: true, withPrefs: true }).pipe( + api.derive.staking.queryMulti(combineAccounts(nextElected, validators), { withExposure: true, withLedger: true, withPrefs: true }).pipe( map((info): DeriveStakingElected => ({ info, nextElected, diff --git a/packages/api-derive/src/staking/query.ts b/packages/api-derive/src/staking/query.ts index 8989ea62fc..d962299f40 100644 --- a/packages/api-derive/src/staking/query.ts +++ b/packages/api-derive/src/staking/query.ts @@ -22,11 +22,11 @@ interface QueryFlags { withPrefs?: boolean; } -type MultiResultPrev = [Option, Option>, RewardDestination, ITuple<[ValidatorPrefs]> | ValidatorPrefs, Exposure]; +type MultiResult = [Option, Option | Nominations>, RewardDestination, ITuple<[ValidatorPrefs]> | ValidatorPrefs, Exposure]; -type MultiResultCombo = [Option, Option | Nominations>, RewardDestination, ITuple<[ValidatorPrefs]> | ValidatorPrefs, Exposure]; +type MultiResultCombo = [Option, Option, RewardDestination, ValidatorPrefs, Exposure]; -function parseDetails (stashId: AccountId, [controllerIdOpt, nominatorsOpt, rewardDestination, validatorPrefs, exposure]: MultiResultCombo, stakingLedgerOpt: Option): DeriveStakingQuery { +function parseDetails (stashId: AccountId, [controllerIdOpt, nominatorsOpt, rewardDestination, validatorPrefs, exposure]: MultiResult, stakingLedgerOpt: Option): DeriveStakingQuery { const nominators = nominatorsOpt && nominatorsOpt.unwrapOr(null); return { @@ -47,8 +47,8 @@ function parseDetails (stashId: AccountId, [controllerIdOpt, nominatorsOpt, rewa }; } -function retrievePrev (api: ApiInterfaceRx, stashId: AccountId): Observable { - return api.queryMulti([ +function retrievePrev (api: ApiInterfaceRx, stashId: AccountId): Observable { + return api.queryMulti([ [api.query.staking.bonded, stashId], [api.query.staking.nominators, stashId], [api.query.staking.payee, stashId], diff --git a/packages/api-derive/src/staking/waitingInfo.ts b/packages/api-derive/src/staking/waitingInfo.ts index 761e6d22a1..a271264685 100644 --- a/packages/api-derive/src/staking/waitingInfo.ts +++ b/packages/api-derive/src/staking/waitingInfo.ts @@ -20,7 +20,7 @@ export function waitingInfo (instanceId: string, api: ApiInterfaceRx): () => Obs const elected = nextElected.map((a) => a.toString()); const waiting = stashes.filter((v) => !elected.includes(v.toString())); - return api.derive.staking.queryMulti(waiting, { withPrefs: true }).pipe( + return api.derive.staking.queryMulti(waiting, { withLedger: true, withPrefs: true }).pipe( map((info): DeriveStakingWaiting => ({ info, waiting