Staking overview derive (#1537)

* Staking overview derive

* Expand derives

* Extract currentIndex/currentEra

* WIP

* Controllers opt

* Add memo

* Memomize the whole lot

* Doc building fixes

* Doc fixes #2
This commit is contained in:
Jaco Greeff
2019-11-02 23:10:10 +01:00
committed by GitHub
parent 1d92b7bead
commit 7cc961f789
44 changed files with 493 additions and 307 deletions
+5 -5
View File
@@ -9,7 +9,7 @@ import BN from 'bn.js';
import { Observable, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { drr } from '../util';
import { drr, memo } from '../util';
type ResultV2 = [BN, BN, BN, BN, BN, BN, BN, BN, BN, BN];
@@ -103,8 +103,8 @@ function queryConstants (api: ApiInterfaceRx): Observable<ResultV2> {
* });
* ```
*/
export function fees (api: ApiInterfaceRx): () => Observable<DerivedContractFees> {
return (): Observable<DerivedContractFees> => {
export const fees = memo((api: ApiInterfaceRx): () => Observable<DerivedContractFees> => {
return memo((): Observable<DerivedContractFees> => {
if (api.query.contract && !api.query.contract.rentByteFee) {
return queryV1(api);
}
@@ -122,5 +122,5 @@ export function fees (api: ApiInterfaceRx): () => Observable<DerivedContractFees
),
drr()
);
};
}
});
}, true);