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
This commit is contained in:
Amaury Martiny
2019-01-10 17:39:25 +01:00
committed by GitHub
parent a93b2f70c7
commit 2a2df9a1c3
26 changed files with 591 additions and 5 deletions
+4 -1
View File
@@ -7,6 +7,8 @@ import { filter, map } from 'rxjs/operators';
import ApiRx from '@polkadot/api/rx';
import { BlockNumber, Header } from '@polkadot/types/index';
import { drr } from '../util/drr';
/**
* Get the latest block number.
*/
@@ -15,6 +17,7 @@ export function bestNumber (api: ApiRx) {
api.rpc.chain.subscribeNewHead()
.pipe(
filter((header: Header) => header && !!header.blockNumber),
map(({ blockNumber }: Header) => blockNumber)
map(({ blockNumber }: Header) => blockNumber),
drr()
);
}
@@ -0,0 +1,23 @@
// 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 { Observable } from 'rxjs';
import { filter, map } from 'rxjs/operators';
import ApiRx from '@polkadot/api/rx';
import { BlockNumber, Header } from '@polkadot/types/index';
import { drr } from '../util/drr';
/**
* Get the latest finalised block number.
*/
export function bestNumberFinalised (api: ApiRx) {
return (): Observable<BlockNumber> =>
api.rpc.chain.subscribeFinalisedHeads()
.pipe(
filter((header: Header) => header && !!header.blockNumber),
map(({ blockNumber }: Header) => blockNumber),
drr()
);
}
+1
View File
@@ -3,3 +3,4 @@
// of the Apache-2.0 license. See the LICENSE file for details.
export * from './bestNumber';
export * from './bestNumberFinalised';