Files
api/packages/api-derive/src/democracy/votes.ts
T
Amaury Martiny 2a2df9a1c3 Add derive functions (#564)
* Add drr

* Update headers

* Lint

* Copy other functions

* Account indexes

* accountIndexToId

* accountIdAndIndex

* Fees

* votingBalance

* votingBalances

* votingBalancesNominatorsFor

* validatingBalance

* validatingBalances

* bestNumberFinalised

* eraLength

* Add drr

* eraProgress

* votes

* referendumInfos

* referendumVotesFor

* referendums

* Clean code

* Add tests

* Fix lint

* Fix bug eraProgress

* Fix bug fees

* combineLatest without array

* Fix lint
2019-01-10 17:39:25 +01:00

22 lines
708 B
TypeScript

// Copyright 2017-2019 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import BN from 'bn.js';
import { combineLatest, Observable } from 'rxjs';
import ApiRx from '@polkadot/api/rx';
import { AccountId, Vote } from '@polkadot/types/index';
import { drr } from '../util/drr';
export function votes (api: ApiRx) {
return (referendumId: BN, ...accountIds: Array<AccountId>): Observable<Array<Vote>> =>
combineLatest(
accountIds.map(
(accountId) => api.query.democracy.voteOf([referendumId, accountId]) as Observable<Vote>
)
).pipe(
drr()
);
}