Refactor api-promise/rx (#566)
* Use a generic abstract OnCall * Add OnCall for Promise * First run at fixing extrinsics * Fix types * Make submittable extrinsic work * Move file * Make derive work * Fix types * Only call metadata once * Make tests pass * Put event emitter in apirx * Fix small bugs * Fix tests * Fix bug decorateStorage * Make tests pass for tx * Move rpc base to apirx * Fix lint * Fix small bugs * Fix bug with isSubscription * Fix codeclimate * Revert * Add tslint disable line * Fix lint * Skip e2e * Typo * Lint * Re-add combinator back * Add ._rx in Base * Make extrinsics work * Update derivex * Fix bug lint * Fix circular dep * Fix bug e2e * Remove useless check * Add description comment * Clean stuff * Move assert to Base * Bump version, update CHANGELOG * Make _rx private * Private emit
This commit is contained in:
committed by
Jaco Greeff
parent
38d2d06772
commit
d07ed8ac38
@@ -5,12 +5,12 @@
|
||||
import BN from 'bn.js';
|
||||
import { combineLatest, Observable } from 'rxjs';
|
||||
import { filter } from 'rxjs/operators';
|
||||
import ApiRx from '@polkadot/api/rx';
|
||||
import { ApiInterface$Rx } from '@polkadot/api/types';
|
||||
import { ReferendumInfo } from '@polkadot/types/index';
|
||||
|
||||
import { drr } from '../util/drr';
|
||||
|
||||
export function referendumInfos (api: ApiRx) {
|
||||
export function referendumInfos (api: ApiInterface$Rx) {
|
||||
return (...params: Array<any>): Observable<Array<ReferendumInfo>> => {
|
||||
const ids: Array<BN | number> = params.slice(0, params.length - 1);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import BN from 'bn.js';
|
||||
import { combineLatest, Observable, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import ApiRx from '@polkadot/api/rx';
|
||||
import { ApiInterface$Rx } from '@polkadot/api/types';
|
||||
import { Vector } from '@polkadot/types/codec';
|
||||
import { AccountId, Balance, Vote } from '@polkadot/types/index';
|
||||
|
||||
@@ -14,7 +14,7 @@ import { drr } from '../util/drr';
|
||||
import { votes } from './votes';
|
||||
import { votingBalances } from '../balances/votingBalances';
|
||||
|
||||
export function referendumVotesFor (api: ApiRx) {
|
||||
export function referendumVotesFor (api: ApiInterface$Rx) {
|
||||
return (referendumId: BN | number): Observable<Array<DerivedReferendumVote>> =>
|
||||
(api.query.democracy.votersFor(referendumId) as Observable<Vector<AccountId>>).pipe(
|
||||
switchMap((votersFor) =>
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
|
||||
import { combineLatest, Observable, of } from 'rxjs';
|
||||
import { switchMap } from 'rxjs/operators';
|
||||
import ApiRx from '@polkadot/api/rx';
|
||||
import { ApiInterface$Rx } from '@polkadot/api/types';
|
||||
import { ReferendumIndex, ReferendumInfo } from '@polkadot/types/index';
|
||||
|
||||
import { referendumInfos } from './referendumInfos';
|
||||
import { drr } from '../util/drr';
|
||||
|
||||
export function referendums (api: ApiRx) {
|
||||
export function referendums (api: ApiInterface$Rx) {
|
||||
return (): Observable<Array<ReferendumInfo>> =>
|
||||
(combineLatest(
|
||||
api.query.democracy.nextTally(),
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { combineLatest, Observable } from 'rxjs';
|
||||
import ApiRx from '@polkadot/api/rx';
|
||||
import { ApiInterface$Rx } from '@polkadot/api/types';
|
||||
import { AccountId, Vote } from '@polkadot/types/index';
|
||||
|
||||
import { drr } from '../util/drr';
|
||||
|
||||
export function votes (api: ApiRx) {
|
||||
export function votes (api: ApiInterface$Rx) {
|
||||
return (referendumId: BN, ...accountIds: Array<AccountId>): Observable<Array<Vote>> =>
|
||||
combineLatest(
|
||||
accountIds.map(
|
||||
|
||||
Reference in New Issue
Block a user