From 77a391448b79d679e53f98dba871cb62b339fae2 Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Mon, 26 Jun 2023 13:43:28 -0700 Subject: [PATCH] fix(liquidity): use LiquidityProvision id (#4191) --- libs/liquidity/src/lib/MarketLiquidity.graphql | 1 + libs/liquidity/src/lib/__generated__/MarketLiquidity.ts | 5 +++-- libs/liquidity/src/lib/liquidity-data-provider.ts | 4 ++-- libs/liquidity/src/lib/liquidity-table.tsx | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/libs/liquidity/src/lib/MarketLiquidity.graphql b/libs/liquidity/src/lib/MarketLiquidity.graphql index d86469b55..576d4fd33 100644 --- a/libs/liquidity/src/lib/MarketLiquidity.graphql +++ b/libs/liquidity/src/lib/MarketLiquidity.graphql @@ -1,6 +1,7 @@ # Liquidity Provisions fragment LiquidityProvisionFields on LiquidityProvision { + id party { id accountsConnection(marketId: $marketId, type: ACCOUNT_TYPE_BOND) { diff --git a/libs/liquidity/src/lib/__generated__/MarketLiquidity.ts b/libs/liquidity/src/lib/__generated__/MarketLiquidity.ts index 88b7d364f..e8d67a088 100644 --- a/libs/liquidity/src/lib/__generated__/MarketLiquidity.ts +++ b/libs/liquidity/src/lib/__generated__/MarketLiquidity.ts @@ -3,14 +3,14 @@ import * as Types from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; const defaultOptions = {} as const; -export type LiquidityProvisionFieldsFragment = { __typename?: 'LiquidityProvision', createdAt: any, updatedAt?: any | null, commitmentAmount: string, fee: string, status: Types.LiquidityProvisionStatus, party: { __typename?: 'Party', id: string, accountsConnection?: { __typename?: 'AccountsConnection', edges?: Array<{ __typename?: 'AccountEdge', node: { __typename?: 'AccountBalance', type: Types.AccountType, balance: string } } | null> | null } | null } }; +export type LiquidityProvisionFieldsFragment = { __typename?: 'LiquidityProvision', id?: string | null, createdAt: any, updatedAt?: any | null, commitmentAmount: string, fee: string, status: Types.LiquidityProvisionStatus, party: { __typename?: 'Party', id: string, accountsConnection?: { __typename?: 'AccountsConnection', edges?: Array<{ __typename?: 'AccountEdge', node: { __typename?: 'AccountBalance', type: Types.AccountType, balance: string } } | null> | null } | null } }; export type LiquidityProvisionsQueryVariables = Types.Exact<{ marketId: Types.Scalars['ID']; }>; -export type LiquidityProvisionsQuery = { __typename?: 'Query', market?: { __typename?: 'Market', liquidityProvisionsConnection?: { __typename?: 'LiquidityProvisionsConnection', edges?: Array<{ __typename?: 'LiquidityProvisionsEdge', node: { __typename?: 'LiquidityProvision', createdAt: any, updatedAt?: any | null, commitmentAmount: string, fee: string, status: Types.LiquidityProvisionStatus, party: { __typename?: 'Party', id: string, accountsConnection?: { __typename?: 'AccountsConnection', edges?: Array<{ __typename?: 'AccountEdge', node: { __typename?: 'AccountBalance', type: Types.AccountType, balance: string } } | null> | null } | null } } } | null> | null } | null } | null }; +export type LiquidityProvisionsQuery = { __typename?: 'Query', market?: { __typename?: 'Market', liquidityProvisionsConnection?: { __typename?: 'LiquidityProvisionsConnection', edges?: Array<{ __typename?: 'LiquidityProvisionsEdge', node: { __typename?: 'LiquidityProvision', id?: string | null, createdAt: any, updatedAt?: any | null, commitmentAmount: string, fee: string, status: Types.LiquidityProvisionStatus, party: { __typename?: 'Party', id: string, accountsConnection?: { __typename?: 'AccountsConnection', edges?: Array<{ __typename?: 'AccountEdge', node: { __typename?: 'AccountBalance', type: Types.AccountType, balance: string } } | null> | null } | null } } } | null> | null } | null } | null }; export type LiquidityProvisionsUpdateSubscriptionVariables = Types.Exact<{ partyId?: Types.InputMaybe; @@ -31,6 +31,7 @@ export type LiquidityProviderFeeShareQuery = { __typename?: 'Query', market?: { export const LiquidityProvisionFieldsFragmentDoc = gql` fragment LiquidityProvisionFields on LiquidityProvision { + id party { id accountsConnection(marketId: $marketId, type: ACCOUNT_TYPE_BOND) { diff --git a/libs/liquidity/src/lib/liquidity-data-provider.ts b/libs/liquidity/src/lib/liquidity-data-provider.ts index 7384635f7..1fdfb7f25 100644 --- a/libs/liquidity/src/lib/liquidity-data-provider.ts +++ b/libs/liquidity/src/lib/liquidity-data-provider.ts @@ -38,8 +38,7 @@ export const liquidityProvisionsDataProvider = makeDataProvider< ) => { return produce(data || [], (draft) => { deltas?.forEach((delta) => { - const id = delta.id; - const index = draft.findIndex((a) => delta.id === id); + const index = draft.findIndex((a) => delta.id === a.id); if (index !== -1) { draft[index].commitmentAmount = delta.commitmentAmount; draft[index].fee = delta.fee; @@ -47,6 +46,7 @@ export const liquidityProvisionsDataProvider = makeDataProvider< draft[index].status = delta.status; } else { draft.unshift({ + id: delta.id, commitmentAmount: delta.commitmentAmount, fee: delta.fee, status: delta.status, diff --git a/libs/liquidity/src/lib/liquidity-table.tsx b/libs/liquidity/src/lib/liquidity-table.tsx index 9487497bc..2ad2ecdc4 100644 --- a/libs/liquidity/src/lib/liquidity-table.tsx +++ b/libs/liquidity/src/lib/liquidity-table.tsx @@ -188,7 +188,7 @@ export const LiquidityTable = forwardRef( `${data.party.id}-${data.status}`} + getRowId={({ data }) => data.id} ref={ref} tooltipShowDelay={500} defaultColDef={{ @@ -200,7 +200,7 @@ export const LiquidityTable = forwardRef( storeKey="liquidityProvisionTable" {...props} columnDefs={colDefs} - > + /> ); } );