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() + ); }