chore(2170): console update ledger entries columns (#2221)

* chore: update ledger entries columns

* chore: update ledger entries columns - remove labels from sender and receiver

* chore: update ledger entries columns - remove labels from sender and receiver

* chore: update ledger entries columns - remove labels from sender and receiver

Co-authored-by: Madalina Raicu <madalina@raygroup.uk>
This commit is contained in:
macqbat 2022-11-25 17:17:21 +01:00 committed by GitHub
parent 5b826f89d8
commit de1f8b5895
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 461 additions and 70 deletions

View File

@ -0,0 +1,42 @@
import { aliasQuery } from '@vegaprotocol/cypress';
import { generateLedgerEntries } from '../support/mocks/generate-ledger-entries';
import { connectVegaWallet } from '../support/vega-wallet';
import { generateAssets } from '../support/mocks/generate-assets';
import { generateMarkets } from '../support/mocks/generate-markets';
describe('Portfolio page', { tags: '@regression' }, () => {
beforeEach(() => {
cy.mockGQL((req) => {
aliasQuery(req, 'LedgerEntries', generateLedgerEntries());
aliasQuery(req, 'Assets', generateAssets());
aliasQuery(req, 'Markets', generateMarkets());
});
cy.mockGQLSubscription();
});
describe('Ledger entries', () => {
it('List should be properly rendered', () => {
cy.visit('/#/portfolio');
connectVegaWallet();
cy.get('[data-testid="Ledger entries"]').click();
const headers = [
'Sender',
'Receiver',
'Transfer Type',
'Quantity',
'Asset',
'Vega Time',
];
cy.get('.ag-header-row.ag-header-row-column').within(($headers) => {
cy.wrap($headers)
.get('.ag-header-cell-text')
.each(($header, i) => {
cy.wrap($header).should('have.text', headers[i]);
});
});
cy.get('.ag-center-cols-container .ag-row').should(
'have.length',
generateLedgerEntries().ledgerEntries.edges.length
);
});
});
});

View File

@ -0,0 +1,258 @@
import type { LedgerEntriesQuery } from '@vegaprotocol/ledger';
import { Schema as Types } from '@vegaprotocol/types';
const ledgerEntries: LedgerEntriesQuery = {
ledgerEntries: {
edges: [
{
node: {
vegaTime: '1669224476734364000',
quantity: '0',
assetId: 'asset-id',
transferType: Types.TransferType.TRANSFER_TYPE_MARGIN_HIGH,
receiverAccountType: Types.AccountType.ACCOUNT_TYPE_EXTERNAL,
receiverMarketId: 'market-1',
receiverPartyId: 'network',
senderAccountType: Types.AccountType.ACCOUNT_TYPE_GENERAL,
senderMarketId: 'market-0',
senderPartyId:
'2e1ef32e5804e14232406aebaad719087d326afa5c648b7824d0823d8a46c8d1',
__typename: 'AggregatedLedgerEntry',
},
__typename: 'AggregatedLedgerEntriesEdge',
},
{
node: {
vegaTime: '1669221452175594000',
quantity: '0',
assetId: 'asset-id-2',
transferType: Types.TransferType.TRANSFER_TYPE_MARGIN_HIGH,
receiverAccountType: Types.AccountType.ACCOUNT_TYPE_EXTERNAL,
receiverMarketId: 'market-0',
receiverPartyId: 'network',
senderAccountType: Types.AccountType.ACCOUNT_TYPE_GENERAL,
senderMarketId: 'market-2',
senderPartyId:
'2e1ef32e5804e14232406aebaad719087d326afa5c648b7824d0823d8a46c8d1',
__typename: 'AggregatedLedgerEntry',
},
__typename: 'AggregatedLedgerEntriesEdge',
},
{
node: {
vegaTime: '1669209347054198000',
quantity: '0',
assetId: 'asset-id',
transferType: Types.TransferType.TRANSFER_TYPE_MARGIN_HIGH,
receiverAccountType: Types.AccountType.ACCOUNT_TYPE_EXTERNAL,
receiverMarketId: 'market-3',
receiverPartyId: 'network',
senderAccountType: Types.AccountType.ACCOUNT_TYPE_GENERAL,
senderMarketId: 'market-2',
senderPartyId: 'sender party id',
__typename: 'AggregatedLedgerEntry',
},
__typename: 'AggregatedLedgerEntriesEdge',
},
{
node: {
vegaTime: '1669209345512806000',
quantity: '0',
assetId: 'asset-id',
transferType: Types.TransferType.TRANSFER_TYPE_MARGIN_HIGH,
__typename: 'AggregatedLedgerEntry',
},
__typename: 'AggregatedLedgerEntriesEdge',
},
{
node: {
vegaTime: '1669209316163397000',
quantity: '0',
assetId: 'asset-id-2',
transferType: Types.TransferType.TRANSFER_TYPE_MARGIN_HIGH,
__typename: 'AggregatedLedgerEntry',
},
__typename: 'AggregatedLedgerEntriesEdge',
},
{
node: {
vegaTime: '1669209299051286000',
quantity: '1326783',
assetId: 'asset-id-2',
transferType: Types.TransferType.TRANSFER_TYPE_MTM_WIN,
__typename: 'AggregatedLedgerEntry',
},
__typename: 'AggregatedLedgerEntriesEdge',
},
{
node: {
vegaTime: '1669209151328614000',
quantity: '0',
assetId:
'5cfa87844724df6069b94e4c8a6f03af21907d7bc251593d08e4251043ee9f7c',
transferType: Types.TransferType.TRANSFER_TYPE_MARGIN_HIGH,
__typename: 'AggregatedLedgerEntry',
},
__typename: 'AggregatedLedgerEntriesEdge',
},
{
node: {
vegaTime: '1669209117655380000',
quantity: '0',
assetId:
'5cfa87844724df6069b94e4c8a6f03af21907d7bc251593d08e4251043ee9f7c',
transferType: Types.TransferType.TRANSFER_TYPE_MARGIN_HIGH,
__typename: 'AggregatedLedgerEntry',
},
__typename: 'AggregatedLedgerEntriesEdge',
},
{
node: {
vegaTime: '1669209082788024000',
quantity: '1326783',
assetId:
'5cfa87844724df6069b94e4c8a6f03af21907d7bc251593d08e4251043ee9f7c',
transferType: Types.TransferType.TRANSFER_TYPE_MTM_WIN,
__typename: 'AggregatedLedgerEntry',
},
__typename: 'AggregatedLedgerEntriesEdge',
},
{
node: {
vegaTime: '1669209076546363000',
quantity: '0',
assetId:
'cee709223217281d7893b650850ae8ee8a18b7539b5658f9b4cc24de95dd18ad',
transferType: Types.TransferType.TRANSFER_TYPE_MARGIN_HIGH,
__typename: 'AggregatedLedgerEntry',
},
__typename: 'AggregatedLedgerEntriesEdge',
},
{
node: {
vegaTime: '2022-11-24T13:36:42.13989Z',
quantity: '9078407730948615',
assetId:
'cee709223217281d7893b650850ae8ee8a18b7539b5658f9b4cc24de95dd18ad',
transferType: Types.TransferType.TRANSFER_TYPE_MARGIN_LOW,
receiverAccountType: Types.AccountType.ACCOUNT_TYPE_GENERAL,
receiverMarketId: null,
receiverPartyId:
'2e1ef32e5804e14232406aebaad719087d326afa5c648b7824d0823d8a46c8d1',
senderAccountType: Types.AccountType.ACCOUNT_TYPE_MARGIN,
senderMarketId:
'0942d767cb2cb5a795e14216e8e53c2b6f75e46dc1732c5aeda8a5aba4ad193d',
senderPartyId:
'2e1ef32e5804e14232406aebaad719087d326afa5c648b7824d0823d8a46c8d1',
__typename: 'AggregatedLedgerEntry',
},
__typename: 'AggregatedLedgerEntriesEdge',
},
{
node: {
vegaTime: '2022-11-24T13:35:49.257039Z',
quantity: '263142253070974',
assetId:
'cee709223217281d7893b650850ae8ee8a18b7539b5658f9b4cc24de95dd18ad',
transferType: Types.TransferType.TRANSFER_TYPE_MARGIN_LOW,
receiverAccountType: Types.AccountType.ACCOUNT_TYPE_GENERAL,
receiverMarketId: null,
receiverPartyId:
'2e1ef32e5804e14232406aebaad719087d326afa5c648b7824d0823d8a46c8d1',
senderAccountType: Types.AccountType.ACCOUNT_TYPE_MARGIN,
senderMarketId:
'0942d767cb2cb5a795e14216e8e53c2b6f75e46dc1732c5aeda8a5aba4ad193d',
senderPartyId:
'2e1ef32e5804e14232406aebaad719087d326afa5c648b7824d0823d8a46c8d1',
__typename: 'AggregatedLedgerEntry',
},
__typename: 'AggregatedLedgerEntriesEdge',
},
{
node: {
vegaTime: '2022-11-24T12:41:22.054428Z',
quantity: '1000000000',
assetId:
'4e4e80abff30cab933b8c4ac6befc618372eb76b2cbddc337eff0b4a3a4d25b8',
transferType: Types.TransferType.TRANSFER_TYPE_DEPOSIT,
receiverAccountType: Types.AccountType.ACCOUNT_TYPE_EXTERNAL,
receiverMarketId: null,
receiverPartyId: 'network',
senderAccountType: Types.AccountType.ACCOUNT_TYPE_GENERAL,
senderMarketId: null,
senderPartyId:
'2e1ef32e5804e14232406aebaad719087d326afa5c648b7824d0823d8a46c8d1',
__typename: 'AggregatedLedgerEntry',
},
__typename: 'AggregatedLedgerEntriesEdge',
},
{
node: {
vegaTime: '2022-11-24T12:39:11.516154Z',
quantity: '1000000000000',
assetId:
'c9fe6fc24fce121b2cc72680543a886055abb560043fda394ba5376203b7527d',
transferType: Types.TransferType.TRANSFER_TYPE_DEPOSIT,
receiverAccountType: Types.AccountType.ACCOUNT_TYPE_EXTERNAL,
receiverMarketId: null,
receiverPartyId: 'network',
senderAccountType: Types.AccountType.ACCOUNT_TYPE_GENERAL,
senderMarketId: null,
senderPartyId:
'2e1ef32e5804e14232406aebaad719087d326afa5c648b7824d0823d8a46c8d1',
__typename: 'AggregatedLedgerEntry',
},
__typename: 'AggregatedLedgerEntriesEdge',
},
{
node: {
vegaTime: '2022-11-24T12:37:26.832226Z',
quantity: '10000000000000000000000',
assetId:
'c9fe6fc24fce121b2cc72680543a886055abb560043fda394ba5376203b7527d',
transferType: Types.TransferType.TRANSFER_TYPE_DEPOSIT,
receiverAccountType: Types.AccountType.ACCOUNT_TYPE_EXTERNAL,
receiverMarketId: null,
receiverPartyId: 'network',
senderAccountType: Types.AccountType.ACCOUNT_TYPE_GENERAL,
senderMarketId: null,
senderPartyId:
'2e1ef32e5804e14232406aebaad719087d326afa5c648b7824d0823d8a46c8d1',
__typename: 'AggregatedLedgerEntry',
},
__typename: 'AggregatedLedgerEntriesEdge',
},
{
node: {
vegaTime: '2022-11-24T12:24:52.844901Z',
quantity: '49390000000000000000000',
assetId:
'c9fe6fc24fce121b2cc72680543a886055abb560043fda394ba5376203b7527d',
transferType: Types.TransferType.TRANSFER_TYPE_DEPOSIT,
receiverAccountType: Types.AccountType.ACCOUNT_TYPE_EXTERNAL,
receiverMarketId: null,
receiverPartyId: 'network',
senderAccountType: Types.AccountType.ACCOUNT_TYPE_GENERAL,
senderMarketId: null,
senderPartyId:
'2e1ef32e5804e14232406aebaad719087d326afa5c648b7824d0823d8a46c8d1',
__typename: 'AggregatedLedgerEntry',
},
__typename: 'AggregatedLedgerEntriesEdge',
},
],
pageInfo: {
startCursor:
'eyJ2ZWdhX3RpbWUiOiIyMDIyLTExLTIzVDE3OjI3OjU2LjczNDM2NFoifQ==',
endCursor: 'eyJ2ZWdhX3RpbWUiOiIyMDIyLTExLTIzVDEzOjExOjE2LjU0NjM2M1oifQ==',
hasNextPage: true,
hasPreviousPage: false,
__typename: 'PageInfo',
},
__typename: 'AggregatedLedgerEntriesConnection',
},
};
export const generateLedgerEntries = () => {
return { ...ledgerEntries };
};

View File

@ -1,2 +1,3 @@
export * from './lib/ledger-container'; export * from './lib/ledger-container';
export * from './lib/ledger-manager'; export * from './lib/ledger-manager';
export * from './lib/__generated__/LedgerEntries';

View File

@ -1,26 +1,34 @@
fragment LedgerEntry on AggregatedLedgerEntries { fragment LedgerEntry on AggregatedLedgerEntry {
vegaTime vegaTime
quantity quantity
partyId
assetId assetId
marketId
accountType
transferType transferType
receiverAccountType
receiverMarketId
receiverPartyId
senderAccountType
senderMarketId
senderPartyId
} }
query LedgerEntries($partyId: ID!) { query LedgerEntries($partyId: ID!, $pagination: Pagination) {
ledgerEntries( ledgerEntries(
filter: { AccountFromFilter: { partyIds: [$partyId] } } filter: {
groupOptions: { SenderAccountFilter: { partyIds: [$partyId] }
ByAccountField: [PartyId, AccountType, AssetId, MarketId] ReceiverAccountFilter: { partyIds: [$partyId] }
ByLedgerEntryField: [TransferType]
} }
pagination: { first: 500 } pagination: $pagination
) { ) {
edges { edges {
node { node {
...LedgerEntry ...LedgerEntry
} }
} }
pageInfo {
startCursor
endCursor
hasNextPage
hasPreviousPage
}
} }
} }

View File

@ -3,38 +3,47 @@ import { Schema as Types } from '@vegaprotocol/types';
import { gql } from '@apollo/client'; import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client'; import * as Apollo from '@apollo/client';
const defaultOptions = {} as const; const defaultOptions = {} as const;
export type LedgerEntryFragment = { __typename?: 'AggregatedLedgerEntries', vegaTime: string, quantity: string, partyId?: string | null, assetId?: string | null, marketId?: string | null, accountType?: Types.AccountType | null, transferType?: string | null }; export type LedgerEntryFragment = { __typename?: 'AggregatedLedgerEntry', vegaTime: any, quantity: string, assetId?: string | null, transferType?: Types.TransferType | null, receiverAccountType?: Types.AccountType | null, receiverMarketId?: string | null, receiverPartyId?: string | null, senderAccountType?: Types.AccountType | null, senderMarketId?: string | null, senderPartyId?: string | null };
export type LedgerEntriesQueryVariables = Types.Exact<{ export type LedgerEntriesQueryVariables = Types.Exact<{
partyId: Types.Scalars['ID']; partyId: Types.Scalars['ID'];
pagination?: Types.InputMaybe<Types.Pagination>;
}>; }>;
export type LedgerEntriesQuery = { __typename?: 'Query', ledgerEntries: { __typename?: 'AggregatedLedgerEntriesConnection', edges: Array<{ __typename?: 'AggregatedLedgerEntriesEdge', node: { __typename?: 'AggregatedLedgerEntries', vegaTime: string, quantity: string, partyId?: string | null, assetId?: string | null, marketId?: string | null, accountType?: Types.AccountType | null, transferType?: string | null } } | null> } }; export type LedgerEntriesQuery = { __typename?: 'Query', ledgerEntries: { __typename?: 'AggregatedLedgerEntriesConnection', edges: Array<{ __typename?: 'AggregatedLedgerEntriesEdge', node: { __typename?: 'AggregatedLedgerEntry', vegaTime: any, quantity: string, assetId?: string | null, transferType?: Types.TransferType | null, receiverAccountType?: Types.AccountType | null, receiverMarketId?: string | null, receiverPartyId?: string | null, senderAccountType?: Types.AccountType | null, senderMarketId?: string | null, senderPartyId?: string | null } } | null>, pageInfo: { __typename?: 'PageInfo', startCursor: string, endCursor: string, hasNextPage: boolean, hasPreviousPage: boolean } } };
export const LedgerEntryFragmentDoc = gql` export const LedgerEntryFragmentDoc = gql`
fragment LedgerEntry on AggregatedLedgerEntries { fragment LedgerEntry on AggregatedLedgerEntry {
vegaTime vegaTime
quantity quantity
partyId
assetId assetId
marketId
accountType
transferType transferType
receiverAccountType
receiverMarketId
receiverPartyId
senderAccountType
senderMarketId
senderPartyId
} }
`; `;
export const LedgerEntriesDocument = gql` export const LedgerEntriesDocument = gql`
query LedgerEntries($partyId: ID!) { query LedgerEntries($partyId: ID!, $pagination: Pagination) {
ledgerEntries( ledgerEntries(
filter: {AccountFromFilter: {partyIds: [$partyId]}} filter: {SenderAccountFilter: {partyIds: [$partyId]}, ReceiverAccountFilter: {partyIds: [$partyId]}}
groupOptions: {ByAccountField: [PartyId, AccountType, AssetId, MarketId], ByLedgerEntryField: [TransferType]} pagination: $pagination
pagination: {first: 500}
) { ) {
edges { edges {
node { node {
...LedgerEntry ...LedgerEntry
} }
} }
pageInfo {
startCursor
endCursor
hasNextPage
hasPreviousPage
}
} }
} }
${LedgerEntryFragmentDoc}`; ${LedgerEntryFragmentDoc}`;
@ -52,6 +61,7 @@ export const LedgerEntriesDocument = gql`
* const { data, loading, error } = useLedgerEntriesQuery({ * const { data, loading, error } = useLedgerEntriesQuery({
* variables: { * variables: {
* partyId: // value for 'partyId' * partyId: // value for 'partyId'
* pagination: // value for 'pagination'
* }, * },
* }); * });
*/ */

View File

@ -2,7 +2,9 @@ import type { Asset } from '@vegaprotocol/assets';
import { assetsProvider } from '@vegaprotocol/assets'; import { assetsProvider } from '@vegaprotocol/assets';
import type { Market } from '@vegaprotocol/market-list'; import type { Market } from '@vegaprotocol/market-list';
import { marketsProvider } from '@vegaprotocol/market-list'; import { marketsProvider } from '@vegaprotocol/market-list';
import type { PageInfo } from '@vegaprotocol/react-helpers';
import { import {
defaultAppend as append,
makeDataProvider, makeDataProvider,
makeDerivedDataProvider, makeDerivedDataProvider,
useDataProvider, useDataProvider,
@ -17,20 +19,36 @@ import { LedgerEntriesDocument } from './__generated__/LedgerEntries';
export type LedgerEntry = LedgerEntryFragment & { export type LedgerEntry = LedgerEntryFragment & {
id: number; id: number;
asset: Asset | null | undefined; asset: Asset | null | undefined;
market: Market | null | undefined; marketSender: Market | null | undefined;
marketReceiver: Market | null | undefined;
}; };
const getData = (responseData: LedgerEntriesQuery): LedgerEntry[] => const getData = (responseData: LedgerEntriesQuery): LedgerEntry[] => {
responseData.ledgerEntries?.edges console.log('responseData', responseData);
?.filter((e) => Boolean(e?.node)) return (
.map((e, i) => ({ id: i, ...e?.node } as LedgerEntry)) ?? []; responseData.ledgerEntries?.edges
?.filter((e) => Boolean(e?.node))
.map((e, i) => ({ id: i, ...e?.node } as LedgerEntry)) ?? []
);
};
const getPageInfo = (responseData: LedgerEntriesQuery): PageInfo | null =>
responseData.ledgerEntries?.pageInfo || null;
const ledgerEntriesOnlyProvider = makeDataProvider< const ledgerEntriesOnlyProvider = makeDataProvider<
LedgerEntriesQuery, LedgerEntriesQuery,
LedgerEntry[] | null, LedgerEntry[] | null,
never, never,
never never
>({ query: LedgerEntriesDocument, getData }); >({
query: LedgerEntriesDocument,
getData,
pagination: {
getPageInfo,
append,
first: 100,
},
});
export const ledgerEntriesProvider = makeDerivedDataProvider< export const ledgerEntriesProvider = makeDerivedDataProvider<
LedgerEntry[], LedgerEntry[],
@ -40,10 +58,13 @@ export const ledgerEntriesProvider = makeDerivedDataProvider<
([entries, assets, markets]): LedgerEntry[] => ([entries, assets, markets]): LedgerEntry[] =>
entries.map((entry: LedgerEntry) => { entries.map((entry: LedgerEntry) => {
const asset = assets.find((asset: Asset) => asset.id === entry.assetId); const asset = assets.find((asset: Asset) => asset.id === entry.assetId);
const market = markets.find( const marketSender = markets.find(
(market: Market) => market.id === entry.marketId (market: Market) => market.id === entry.senderMarketId
); );
return { ...entry, asset, market }; const marketReceiver = markets.find(
(market: Market) => market.id === entry.receiverMarketId
);
return { ...entry, asset, marketSender, marketReceiver };
}) })
); );

View File

@ -5,6 +5,7 @@ import { LedgerTable } from './ledger-table';
// '3ac37999796c2be3546e0c1d87daa8ec7e99d8c423969be44c2f63256c415004' // '3ac37999796c2be3546e0c1d87daa8ec7e99d8c423969be44c2f63256c415004'
type LedgerManagerProps = { partyId: string }; type LedgerManagerProps = { partyId: string };
export const LedgerManager = ({ partyId }: LedgerManagerProps) => { export const LedgerManager = ({ partyId }: LedgerManagerProps) => {
console.log('partyId', partyId);
const { data, error, loading } = useLedgerEntriesDataProvider(partyId); const { data, error, loading } = useLedgerEntriesDataProvider(partyId);
return ( return (

View File

@ -3,11 +3,15 @@ import {
fromNanoSeconds, fromNanoSeconds,
getDateTimeFormat, getDateTimeFormat,
t, t,
truncateByChars,
} from '@vegaprotocol/react-helpers'; } from '@vegaprotocol/react-helpers';
import type { VegaValueFormatterParams } from '@vegaprotocol/ui-toolkit'; import type {
VegaValueFormatterParams,
VegaICellRendererParams,
} from '@vegaprotocol/ui-toolkit';
import { AgGridDynamic as AgGrid } from '@vegaprotocol/ui-toolkit'; import { AgGridDynamic as AgGrid } from '@vegaprotocol/ui-toolkit';
import { AgGridColumn } from 'ag-grid-react'; import { AgGridColumn } from 'ag-grid-react';
import type { Schema } from '@vegaprotocol/types'; import type { Schema as Types } from '@vegaprotocol/types';
import { import {
AccountTypeMapping, AccountTypeMapping,
DescriptionTransferTypeMapping, DescriptionTransferTypeMapping,
@ -18,7 +22,7 @@ import type { LedgerEntry } from './ledger-entries-data-provider';
export const TransferTooltipCellComponent = ({ export const TransferTooltipCellComponent = ({
value, value,
}: { }: {
value: Schema.TransferType; value: Types.TransferType;
}) => { }) => {
return ( return (
<p className="max-w-sm bg-neutral-200 px-4 py-2 z-20 rounded text-sm break-word text-black"> <p className="max-w-sm bg-neutral-200 px-4 py-2 z-20 rounded text-sm break-word text-black">
@ -27,11 +31,63 @@ export const TransferTooltipCellComponent = ({
); );
}; };
type LedgerCellRendererProps = {
accountType?: Types.AccountType | null;
partyId?: string | null;
marketName?: string;
};
const LedgerCellRenderer = ({
accountType,
partyId,
marketName,
}: LedgerCellRendererProps) => {
return (
<div className="flex flex-col justify-around leading-5 h-full">
<div
className="flex"
title={`${t('ID')}: ${truncateByChars(partyId || '-')}`}
>
{truncateByChars(partyId || '')}
</div>
<div
className="flex"
title={`${t('Account type')}: ${
accountType ? AccountTypeMapping[accountType] : '-'
}`}
>
{accountType && AccountTypeMapping[accountType]}
</div>
<div className="flex" title={`${t('Market')}: ${marketName || '-'}`}>
{marketName}
</div>
</div>
);
};
const SenderCellRenderer = ({ data }: VegaICellRendererParams<LedgerEntry>) => {
const props = {
accountType: data?.senderAccountType,
partyId: data?.senderPartyId,
marketName: data?.marketSender?.tradableInstrument?.instrument?.code,
};
return <LedgerCellRenderer {...props} />;
};
const ReceiverCellRenderer = ({
data,
}: VegaICellRendererParams<LedgerEntry>) => {
const props = {
accountType: data?.receiverAccountType,
partyId: data?.receiverPartyId,
marketName: data?.marketReceiver?.tradableInstrument?.instrument?.code,
};
return <LedgerCellRenderer {...props} />;
};
export const LedgerTable = ({ ...props }) => ( export const LedgerTable = ({ ...props }) => (
<AgGrid <AgGrid
style={{ width: '100%', height: '100%' }} style={{ width: '100%', height: '100%' }}
overlayNoRowsTemplate={t('No entries')} overlayNoRowsTemplate={t('No entries')}
rowHeight={34} rowHeight={70}
getRowId={({ data }) => data.id} getRowId={({ data }) => data.id}
tooltipShowDelay={500} tooltipShowDelay={500}
defaultColDef={{ defaultColDef={{
@ -43,13 +99,14 @@ export const LedgerTable = ({ ...props }) => (
{...props} {...props}
> >
<AgGridColumn <AgGridColumn
headerName={t('Account Type')} headerName={t('Sender')}
field="accountType" field="senderAccountType"
valueFormatter={({ cellRenderer={SenderCellRenderer}
value, />
}: VegaValueFormatterParams<LedgerEntry, 'accountType'>) => <AgGridColumn
value ? AccountTypeMapping[value] : '' headerName={t('Receiver')}
} field="receiverAccountType"
cellRenderer={ReceiverCellRenderer}
/> />
<AgGridColumn <AgGridColumn
headerName={t('Transfer Type')} headerName={t('Transfer Type')}
@ -70,7 +127,7 @@ export const LedgerTable = ({ ...props }) => (
value, value,
data, data,
}: VegaValueFormatterParams<LedgerEntry, 'quantity'>) => { }: VegaValueFormatterParams<LedgerEntry, 'quantity'>) => {
const marketDecimalPlaces = data?.market?.decimalPlaces; const marketDecimalPlaces = data?.marketSender?.decimalPlaces;
const assetDecimalPlaces = data?.asset?.decimals || 0; const assetDecimalPlaces = data?.asset?.decimals || 0;
return value return value
? addDecimalsFormatNumber( ? addDecimalsFormatNumber(
@ -91,20 +148,11 @@ export const LedgerTable = ({ ...props }) => (
data?.asset?.symbol || value data?.asset?.symbol || value
} }
/> />
<AgGridColumn
headerName={t('Market')}
field="marketId"
valueFormatter={({
data,
}: VegaValueFormatterParams<LedgerEntry, 'market'>) =>
data?.market?.tradableInstrument.instrument.code || '-'
}
/>
<AgGridColumn <AgGridColumn
headerName={t('Vega Time')} headerName={t('Vega Time')}
field="vegaTime" field="vegaTime"
valueFormatter={({ value }: { value: string }) => valueFormatter={({ value }: { value?: string }) =>
getDateTimeFormat().format(fromNanoSeconds(value)) value ? getDateTimeFormat().format(fromNanoSeconds(value)) : '-'
} }
filter="agDateColumnFilter" filter="agDateColumnFilter"
filterParams={{ filterParams={{

View File

@ -1,9 +1,10 @@
import { parseISO, isValid } from 'date-fns';
export const toNanoSeconds = (date: Date | string) => { export const toNanoSeconds = (date: Date | string) => {
return new Date(date).getTime().toString() + '000000'; return new Date(date).getTime().toString() + '000000';
}; };
export const fromNanoSeconds = (ts: string) => { export const fromNanoSeconds = (ts: string) => {
if (typeof ts !== 'string') return new Date(0); const val = parseISO(ts);
const validTs = ts.substring(0, ts.length - 6); return new Date(isValid(val) ? val : 0);
return new Date(Number(validTs));
}; };

View File

@ -177,8 +177,20 @@ export type AggregatedBalanceEdge = {
node: AggregatedBalance; node: AggregatedBalance;
}; };
export type AggregatedLedgerEntries = { export type AggregatedLedgerEntriesConnection = {
__typename?: 'AggregatedLedgerEntries'; __typename?: 'AggregatedLedgerEntriesConnection';
edges: Array<Maybe<AggregatedLedgerEntriesEdge>>;
pageInfo: PageInfo;
};
export type AggregatedLedgerEntriesEdge = {
__typename?: 'AggregatedLedgerEntriesEdge';
cursor: Scalars['String'];
node: AggregatedLedgerEntry;
};
export type AggregatedLedgerEntry = {
__typename?: 'AggregatedLedgerEntry';
/** Asset identifier, if query was grouped by asset - else null */ /** Asset identifier, if query was grouped by asset - else null */
assetId?: Maybe<Scalars['ID']>; assetId?: Maybe<Scalars['ID']>;
/** Net amount of ledger entries for the accounts specified in the filter at this time */ /** Net amount of ledger entries for the accounts specified in the filter at this time */
@ -195,23 +207,12 @@ export type AggregatedLedgerEntries = {
senderMarketId?: Maybe<Scalars['ID']>; senderMarketId?: Maybe<Scalars['ID']>;
/** Party identifier, if query was grouped by sender party - else null */ /** Party identifier, if query was grouped by sender party - else null */
senderPartyId?: Maybe<Scalars['ID']>; senderPartyId?: Maybe<Scalars['ID']>;
transferType?: Maybe<Scalars['String']>; /** Type of the transfer for this ledger entry */
transferType?: Maybe<TransferType>;
/** RFC3339Nano time from at which this ledger entries records were relevant */ /** RFC3339Nano time from at which this ledger entries records were relevant */
vegaTime: Scalars['Timestamp']; vegaTime: Scalars['Timestamp'];
}; };
export type AggregatedLedgerEntriesConnection = {
__typename?: 'AggregatedLedgerEntriesConnection';
edges: Array<Maybe<AggregatedLedgerEntriesEdge>>;
pageInfo: PageInfo;
};
export type AggregatedLedgerEntriesEdge = {
__typename?: 'AggregatedLedgerEntriesEdge';
cursor: Scalars['String'];
node: AggregatedLedgerEntries;
};
/** Represents an asset in Vega */ /** Represents an asset in Vega */
export type Asset = { export type Asset = {
__typename?: 'Asset'; __typename?: 'Asset';