Skip to content

Commit

Permalink
fix operations displaying
Browse files Browse the repository at this point in the history
  • Loading branch information
Ridel1e committed Oct 16, 2023
1 parent f588f35 commit 7102ffb
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 28 deletions.
52 changes: 28 additions & 24 deletions src/network/cardano/api/ammPools/ammPools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,37 +66,41 @@ const getPoolsV2 = () =>
refCount(),
);

export const unverifiedAmmPools$ = networkContext$.pipe(
exhaustMap(() => combineLatest([getPools(), getPoolsV2()])),
catchError(() => of(undefined)),
filter(Boolean),
map(([[poolsV1], [poolsV2]]: [[AmmPool[], number], [AmmPool[], number]]) =>
poolsV1.concat(poolsV2),
),
switchMap((pools: AmmPool[]) =>
defaultTokenList$.pipe(
map((defaultTokenList) =>
pools.filter(
(pool) => !defaultTokenList.tokensMap.has(mkSubject(pool.y.asset)),
export const getUnverifiedAmmPools = () =>
combineLatest([getPools(), getPoolsV2()]).pipe(
catchError(() => of(undefined)),
filter(Boolean),
map(([[poolsV1], [poolsV2]]: [[AmmPool[], number], [AmmPool[], number]]) =>
poolsV1.concat(poolsV2),
),
switchMap((pools: AmmPool[]) =>
defaultTokenList$.pipe(
map((defaultTokenList) =>
pools.filter(
(pool) => !defaultTokenList.tokensMap.has(mkSubject(pool.y.asset)),
),
),
),
),
),
switchMap((pools: AmmPool[]) =>
combineLatest(
pools.map((p) =>
combineLatest(
[p.lp.asset, p.x.asset, p.y.asset].map((asset) =>
mapAssetClassToAssetInfo(asset),
switchMap((pools: AmmPool[]) =>
combineLatest(
pools.map((p) =>
combineLatest(
[p.lp.asset, p.x.asset, p.y.asset].map((asset) =>
mapAssetClassToAssetInfo(asset),
),
).pipe(
map(([lp, x, y]) => {
return new CardanoAmmPool(p, { lp, x, y }, undefined, true);
}),
),
).pipe(
map(([lp, x, y]) => {
return new CardanoAmmPool(p, { lp, x, y }, undefined, true);
}),
),
),
),
),
);

export const unverifiedAmmPools$ = networkContext$.pipe(
exhaustMap(() => getUnverifiedAmmPools()),
publishReplay(1),
refCount(),
);
Expand Down
15 changes: 11 additions & 4 deletions src/network/cardano/api/transactionHistory/operationsHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { applicationConfig } from '../../../../applicationConfig';
import { AmmPool } from '../../../../common/models/AmmPool';
import { TxId } from '../../../../common/types';
import { getAddresses } from '../addresses/addresses';
import { allAmmPools$ } from '../ammPools/ammPools';
import { allAmmPools$, getUnverifiedAmmPools } from '../ammPools/ammPools';
import { mapRawAddLiquidityItemToAddLiquidityItem } from './types/AddLiquidityOperation';
import { OperationMapper } from './types/BaseOperation';
import { OperationItem, RawOperationItem } from './types/OperationItem';
Expand Down Expand Up @@ -158,13 +158,20 @@ export const getOperations = (
limit: number,
offset: number,
): Observable<[OperationItem[], number]> =>
combineLatest([getRawOperations(limit, offset), allAmmPools$]).pipe(
combineLatest([
getRawOperations(limit, offset),
allAmmPools$,
getUnverifiedAmmPools(),
]).pipe(
debounceTime(200),
map(
([[rawOperations, total], ammPools]) =>
([[rawOperations, total], ammPools, unverifiedAmmPools]) =>
[
rawOperations.map((rawOp) =>
mapRawOperationItemToOperationItem(rawOp, ammPools),
mapRawOperationItemToOperationItem(
rawOp,
ammPools.concat(unverifiedAmmPools || []),
),
),
total,
] as [OperationItem[], number],
Expand Down

0 comments on commit 7102ffb

Please sign in to comment.