Remove derive memos (#1538)

* Remove derive memos

* Remove outer memo

* Over-eager replace
This commit is contained in:
Jaco Greeff
2019-11-03 11:38:36 +01:00
committed by GitHub
parent 0e037de1b1
commit 506b042f8c
44 changed files with 273 additions and 305 deletions
+5 -5
View File
@@ -14,7 +14,7 @@ import { bnMax } from '@polkadot/util';
import { info } from '../accounts/info';
import { bestNumber } from '../chain/bestNumber';
import { DerivedBalances } from '../types';
import { drr, memo } from '../util';
import { drr } from '../util';
type ResultBalance = [Balance, Balance, BalanceLock[], Option<VestingSchedule>];
type Result = [AccountId, BlockNumber, ResultBalance, Index];
@@ -77,11 +77,11 @@ function queryBalances (api: ApiInterfaceRx, accountId: AccountId): Observable<R
* });
* ```
*/
export const all = memo((api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DerivedBalances> => {
export function all (api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DerivedBalances> {
const bestNumberCall = bestNumber(api);
const infoCall = info(api);
return memo((address: AccountIndex | AccountId | Address | string): Observable<DerivedBalances> => {
return (address: AccountIndex | AccountId | Address | string): Observable<DerivedBalances> => {
return infoCall(address).pipe(
switchMap(({ accountId }): Observable<Result> =>
(accountId
@@ -102,5 +102,5 @@ export const all = memo((api: ApiInterfaceRx): (address: AccountIndex | AccountI
map(calcBalances),
drr()
);
});
}, true);
};
}
+10 -10
View File
@@ -9,7 +9,7 @@ import { DerivedFees } from '../types';
import { Observable, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { drr, memo } from '../util';
import { drr } from '../util';
type Result = [Balance, Balance, Balance, Balance, Balance];
@@ -51,13 +51,13 @@ function queryV1 (api: ApiInterfaceRx): Observable<Result> {
* });
* ```
*/
export const fees = memo((api: ApiInterfaceRx): () => Observable<DerivedFees> => {
return memo((): Observable<DerivedFees> => {
return (
api.consts.balances
? queryV2(api)
: queryV1(api)
).pipe(
export function fees (api: ApiInterfaceRx): () => Observable<DerivedFees> {
const query = api.consts.balances
? queryV2
: queryV1;
return (): Observable<DerivedFees> => {
return query(api).pipe(
map(([creationFee, existentialDeposit, transferFee, transactionBaseFee, transactionByteFee]): DerivedFees => ({
creationFee,
existentialDeposit,
@@ -67,5 +67,5 @@ export const fees = memo((api: ApiInterfaceRx): () => Observable<DerivedFees> =>
})),
drr()
);
});
}, true);
};
}
@@ -8,11 +8,11 @@ import { combineLatest, Observable, of } from 'rxjs';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { DerivedBalances } from '../types';
import { drr, memo } from '../util';
import { drr } from '../util';
import { all } from './all';
export const votingBalances = memo((api: ApiInterfaceRx): (addresses?: (AccountId | AccountIndex | Address | string)[]) => Observable<DerivedBalances[]> => {
return memo((addresses?: (AccountId | AccountIndex | Address | string)[]): Observable<DerivedBalances[]> => {
export function votingBalances (api: ApiInterfaceRx): (addresses?: (AccountId | AccountIndex | Address | string)[]) => Observable<DerivedBalances[]> {
return (addresses?: (AccountId | AccountIndex | Address | string)[]): Observable<DerivedBalances[]> => {
return (
!addresses || !addresses.length
? of([] as DerivedBalances[])
@@ -20,5 +20,5 @@ export const votingBalances = memo((api: ApiInterfaceRx): (addresses?: (AccountI
).pipe(
drr()
);
});
}, true);
};
}
@@ -11,13 +11,13 @@ import { Vec } from '@polkadot/types';
import { info } from '../accounts/info';
import { DerivedBalances } from '../types';
import { drr, memo } from '../util';
import { drr } from '../util';
import { votingBalances } from './votingBalances';
export const votingBalancesNominatorsFor = memo((api: ApiInterfaceRx): (address: AccountId | AccountIndex | Address | string) => Observable<DerivedBalances[]> => {
export function votingBalancesNominatorsFor (api: ApiInterfaceRx): (address: AccountId | AccountIndex | Address | string) => Observable<DerivedBalances[]> {
const infoCall = info(api);
return memo((address: AccountId | AccountIndex | Address | string): Observable<DerivedBalances[]> => {
return (address: AccountId | AccountIndex | Address | string): Observable<DerivedBalances[]> => {
return infoCall(address).pipe(
switchMap(({ accountId }): Observable<AccountId[]> =>
accountId
@@ -27,5 +27,5 @@ export const votingBalancesNominatorsFor = memo((api: ApiInterfaceRx): (address:
switchMap(votingBalances(api)),
drr()
);
});
}, true);
};
}