From 85e293f3ec785a6aad7b9222aa2543814e81b6bf Mon Sep 17 00:00:00 2001 From: "m.ray" <16125548+MadalinaRaicu@users.noreply.github.com> Date: Fri, 5 May 2023 02:23:33 +0300 Subject: [PATCH] fix(liquidity): use LP order ID as ag-grid row ID (#3615) --- .../src/lib/liquidity-data-provider.ts | 26 ++----------------- libs/liquidity/src/lib/liquidity-table.tsx | 3 +-- 2 files changed, 3 insertions(+), 26 deletions(-) diff --git a/libs/liquidity/src/lib/liquidity-data-provider.ts b/libs/liquidity/src/lib/liquidity-data-provider.ts index 03fc94988..821567c42 100644 --- a/libs/liquidity/src/lib/liquidity-data-provider.ts +++ b/libs/liquidity/src/lib/liquidity-data-provider.ts @@ -22,7 +22,6 @@ import type { LiquidityProvisionsQueryVariables, LiquidityProvisionsUpdateSubscription, } from './__generated__/MarketLiquidity'; -import type { IterableElement } from 'type-fest'; export const liquidityProvisionsDataProvider = makeDataProvider< LiquidityProvisionsQuery, @@ -39,8 +38,8 @@ export const liquidityProvisionsDataProvider = makeDataProvider< ) => { return produce(data || [], (draft) => { deltas?.forEach((delta) => { - const id = getId(delta); - const index = draft.findIndex((a) => getId(a) === id); + const id = delta.id; + const index = draft.findIndex((a) => delta.id === id); if (index !== -1) { draft[index].commitmentAmount = delta.commitmentAmount; draft[index].fee = delta.fee; @@ -76,27 +75,6 @@ export const liquidityProvisionsDataProvider = makeDataProvider< }, }); -function isLpFragment( - entry: - | LiquidityProvisionFieldsFragment - | IterableElement< - LiquidityProvisionsUpdateSubscription['liquidityProvisions'] - > -): entry is LiquidityProvisionFieldsFragment { - return entry.__typename === 'LiquidityProvision'; -} - -export const getId = ( - entry: - | LiquidityProvisionFieldsFragment - | IterableElement< - LiquidityProvisionsUpdateSubscription['liquidityProvisions'] - > -) => - isLpFragment(entry) - ? `${entry.party.id}${entry.status}${entry.createdAt}` - : `${entry.partyID}${entry.status}${entry.createdAt}`; - export const marketLiquidityDataProvider = makeDataProvider< MarketLpQuery, MarketLpQuery, diff --git a/libs/liquidity/src/lib/liquidity-table.tsx b/libs/liquidity/src/lib/liquidity-table.tsx index e9b408681..47865558c 100644 --- a/libs/liquidity/src/lib/liquidity-table.tsx +++ b/libs/liquidity/src/lib/liquidity-table.tsx @@ -17,7 +17,6 @@ import type { ValueFormatterParams } from 'ag-grid-community'; import BigNumber from 'bignumber.js'; import { LiquidityProvisionStatusMapping } from '@vegaprotocol/types'; import type { LiquidityProvisionData } from './liquidity-data-provider'; -import { getId } from './liquidity-data-provider'; const percentageFormatter = ({ value }: ValueFormatterParams) => { if (!value) return '-'; @@ -56,7 +55,7 @@ export const LiquidityTable = forwardRef( getId(data)} + getRowId={({ data }) => data.id} ref={ref} tooltipShowDelay={500} defaultColDef={{