From 17a10fbffe87bb94469589139e67c2ab59d5da2d Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Wed, 2 Oct 2019 12:15:50 +0200 Subject: [PATCH] Allow approvalsOf to take string as "who" input (#1434) * Allow approvalsOf to take string as "who" input * Re-add (build fails) --- .../api-derive/src/elections/approvalsOf.ts | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/packages/api-derive/src/elections/approvalsOf.ts b/packages/api-derive/src/elections/approvalsOf.ts index 6456146dd9..4cbc879e2c 100644 --- a/packages/api-derive/src/elections/approvalsOf.ts +++ b/packages/api-derive/src/elections/approvalsOf.ts @@ -24,21 +24,20 @@ import { drr } from '../util/drr'; * ``` */ export function approvalsOf (api: ApiInterfaceRx): (who: AccountId) => Observable { - return (who: AccountId): Observable => - (api.query.elections.nextVoterSet()) - .pipe( - switchMap((nextVoterSet: SetIndex): Observable[]> => - api.query.elections.approvalsOf.multi( - [...Array(nextVoterSet.toNumber() + 1).keys()].map((i): [string, number] => [ - who.toString(), i] - ) - ) as any as Observable[]> - ), - map((votes: Vec[]): boolean[][] => - votes.map((flags: Vec): boolean[] => - approvalFlagsToBools(flags) + return (who: AccountId | string): Observable => + api.query.elections.nextVoterSet().pipe( + switchMap((nextVoterSet: SetIndex): Observable[]> => + api.query.elections.approvalsOf.multi( + [...Array(nextVoterSet.toNumber() + 1).keys()].map((i): [string, number] => [ + who.toString(), i] ) - ), - drr() - ); + ) as any as Observable[]> + ), + map((votes: Vec[]): boolean[][] => + votes.map((flags: Vec): boolean[] => + approvalFlagsToBools(flags) + ) + ), + drr() + ); }