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:
parent
5b826f89d8
commit
de1f8b5895
42
apps/trading-e2e/src/integration/trading-portfolio.cy.ts
Normal file
42
apps/trading-e2e/src/integration/trading-portfolio.cy.ts
Normal 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
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
258
apps/trading-e2e/src/support/mocks/generate-ledger-entries.ts
Normal file
258
apps/trading-e2e/src/support/mocks/generate-ledger-entries.ts
Normal 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 };
|
||||
};
|
@ -1,2 +1,3 @@
|
||||
export * from './lib/ledger-container';
|
||||
export * from './lib/ledger-manager';
|
||||
export * from './lib/__generated__/LedgerEntries';
|
||||
|
@ -1,26 +1,34 @@
|
||||
fragment LedgerEntry on AggregatedLedgerEntries {
|
||||
fragment LedgerEntry on AggregatedLedgerEntry {
|
||||
vegaTime
|
||||
quantity
|
||||
partyId
|
||||
assetId
|
||||
marketId
|
||||
accountType
|
||||
transferType
|
||||
receiverAccountType
|
||||
receiverMarketId
|
||||
receiverPartyId
|
||||
senderAccountType
|
||||
senderMarketId
|
||||
senderPartyId
|
||||
}
|
||||
|
||||
query LedgerEntries($partyId: ID!) {
|
||||
query LedgerEntries($partyId: ID!, $pagination: Pagination) {
|
||||
ledgerEntries(
|
||||
filter: { AccountFromFilter: { partyIds: [$partyId] } }
|
||||
groupOptions: {
|
||||
ByAccountField: [PartyId, AccountType, AssetId, MarketId]
|
||||
ByLedgerEntryField: [TransferType]
|
||||
filter: {
|
||||
SenderAccountFilter: { partyIds: [$partyId] }
|
||||
ReceiverAccountFilter: { partyIds: [$partyId] }
|
||||
}
|
||||
pagination: { first: 500 }
|
||||
pagination: $pagination
|
||||
) {
|
||||
edges {
|
||||
node {
|
||||
...LedgerEntry
|
||||
}
|
||||
}
|
||||
pageInfo {
|
||||
startCursor
|
||||
endCursor
|
||||
hasNextPage
|
||||
hasPreviousPage
|
||||
}
|
||||
}
|
||||
}
|
||||
|
30
libs/ledger/src/lib/__generated__/LedgerEntries.ts
generated
30
libs/ledger/src/lib/__generated__/LedgerEntries.ts
generated
@ -3,38 +3,47 @@ import { Schema as Types } from '@vegaprotocol/types';
|
||||
import { gql } from '@apollo/client';
|
||||
import * as Apollo from '@apollo/client';
|
||||
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<{
|
||||
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`
|
||||
fragment LedgerEntry on AggregatedLedgerEntries {
|
||||
fragment LedgerEntry on AggregatedLedgerEntry {
|
||||
vegaTime
|
||||
quantity
|
||||
partyId
|
||||
assetId
|
||||
marketId
|
||||
accountType
|
||||
transferType
|
||||
receiverAccountType
|
||||
receiverMarketId
|
||||
receiverPartyId
|
||||
senderAccountType
|
||||
senderMarketId
|
||||
senderPartyId
|
||||
}
|
||||
`;
|
||||
export const LedgerEntriesDocument = gql`
|
||||
query LedgerEntries($partyId: ID!) {
|
||||
query LedgerEntries($partyId: ID!, $pagination: Pagination) {
|
||||
ledgerEntries(
|
||||
filter: {AccountFromFilter: {partyIds: [$partyId]}}
|
||||
groupOptions: {ByAccountField: [PartyId, AccountType, AssetId, MarketId], ByLedgerEntryField: [TransferType]}
|
||||
pagination: {first: 500}
|
||||
filter: {SenderAccountFilter: {partyIds: [$partyId]}, ReceiverAccountFilter: {partyIds: [$partyId]}}
|
||||
pagination: $pagination
|
||||
) {
|
||||
edges {
|
||||
node {
|
||||
...LedgerEntry
|
||||
}
|
||||
}
|
||||
pageInfo {
|
||||
startCursor
|
||||
endCursor
|
||||
hasNextPage
|
||||
hasPreviousPage
|
||||
}
|
||||
}
|
||||
}
|
||||
${LedgerEntryFragmentDoc}`;
|
||||
@ -52,6 +61,7 @@ export const LedgerEntriesDocument = gql`
|
||||
* const { data, loading, error } = useLedgerEntriesQuery({
|
||||
* variables: {
|
||||
* partyId: // value for 'partyId'
|
||||
* pagination: // value for 'pagination'
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
|
@ -2,7 +2,9 @@ import type { Asset } from '@vegaprotocol/assets';
|
||||
import { assetsProvider } from '@vegaprotocol/assets';
|
||||
import type { Market } from '@vegaprotocol/market-list';
|
||||
import { marketsProvider } from '@vegaprotocol/market-list';
|
||||
import type { PageInfo } from '@vegaprotocol/react-helpers';
|
||||
import {
|
||||
defaultAppend as append,
|
||||
makeDataProvider,
|
||||
makeDerivedDataProvider,
|
||||
useDataProvider,
|
||||
@ -17,20 +19,36 @@ import { LedgerEntriesDocument } from './__generated__/LedgerEntries';
|
||||
export type LedgerEntry = LedgerEntryFragment & {
|
||||
id: number;
|
||||
asset: Asset | null | undefined;
|
||||
market: Market | null | undefined;
|
||||
marketSender: Market | null | undefined;
|
||||
marketReceiver: Market | null | undefined;
|
||||
};
|
||||
|
||||
const getData = (responseData: LedgerEntriesQuery): LedgerEntry[] =>
|
||||
responseData.ledgerEntries?.edges
|
||||
?.filter((e) => Boolean(e?.node))
|
||||
.map((e, i) => ({ id: i, ...e?.node } as LedgerEntry)) ?? [];
|
||||
const getData = (responseData: LedgerEntriesQuery): LedgerEntry[] => {
|
||||
console.log('responseData', responseData);
|
||||
return (
|
||||
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<
|
||||
LedgerEntriesQuery,
|
||||
LedgerEntry[] | null,
|
||||
never,
|
||||
never
|
||||
>({ query: LedgerEntriesDocument, getData });
|
||||
>({
|
||||
query: LedgerEntriesDocument,
|
||||
getData,
|
||||
pagination: {
|
||||
getPageInfo,
|
||||
append,
|
||||
first: 100,
|
||||
},
|
||||
});
|
||||
|
||||
export const ledgerEntriesProvider = makeDerivedDataProvider<
|
||||
LedgerEntry[],
|
||||
@ -40,10 +58,13 @@ export const ledgerEntriesProvider = makeDerivedDataProvider<
|
||||
([entries, assets, markets]): LedgerEntry[] =>
|
||||
entries.map((entry: LedgerEntry) => {
|
||||
const asset = assets.find((asset: Asset) => asset.id === entry.assetId);
|
||||
const market = markets.find(
|
||||
(market: Market) => market.id === entry.marketId
|
||||
const marketSender = markets.find(
|
||||
(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 };
|
||||
})
|
||||
);
|
||||
|
||||
|
@ -5,6 +5,7 @@ import { LedgerTable } from './ledger-table';
|
||||
// '3ac37999796c2be3546e0c1d87daa8ec7e99d8c423969be44c2f63256c415004'
|
||||
type LedgerManagerProps = { partyId: string };
|
||||
export const LedgerManager = ({ partyId }: LedgerManagerProps) => {
|
||||
console.log('partyId', partyId);
|
||||
const { data, error, loading } = useLedgerEntriesDataProvider(partyId);
|
||||
|
||||
return (
|
||||
|
@ -3,11 +3,15 @@ import {
|
||||
fromNanoSeconds,
|
||||
getDateTimeFormat,
|
||||
t,
|
||||
truncateByChars,
|
||||
} 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 { AgGridColumn } from 'ag-grid-react';
|
||||
import type { Schema } from '@vegaprotocol/types';
|
||||
import type { Schema as Types } from '@vegaprotocol/types';
|
||||
import {
|
||||
AccountTypeMapping,
|
||||
DescriptionTransferTypeMapping,
|
||||
@ -18,7 +22,7 @@ import type { LedgerEntry } from './ledger-entries-data-provider';
|
||||
export const TransferTooltipCellComponent = ({
|
||||
value,
|
||||
}: {
|
||||
value: Schema.TransferType;
|
||||
value: Types.TransferType;
|
||||
}) => {
|
||||
return (
|
||||
<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 }) => (
|
||||
<AgGrid
|
||||
style={{ width: '100%', height: '100%' }}
|
||||
overlayNoRowsTemplate={t('No entries')}
|
||||
rowHeight={34}
|
||||
rowHeight={70}
|
||||
getRowId={({ data }) => data.id}
|
||||
tooltipShowDelay={500}
|
||||
defaultColDef={{
|
||||
@ -43,13 +99,14 @@ export const LedgerTable = ({ ...props }) => (
|
||||
{...props}
|
||||
>
|
||||
<AgGridColumn
|
||||
headerName={t('Account Type')}
|
||||
field="accountType"
|
||||
valueFormatter={({
|
||||
value,
|
||||
}: VegaValueFormatterParams<LedgerEntry, 'accountType'>) =>
|
||||
value ? AccountTypeMapping[value] : ''
|
||||
}
|
||||
headerName={t('Sender')}
|
||||
field="senderAccountType"
|
||||
cellRenderer={SenderCellRenderer}
|
||||
/>
|
||||
<AgGridColumn
|
||||
headerName={t('Receiver')}
|
||||
field="receiverAccountType"
|
||||
cellRenderer={ReceiverCellRenderer}
|
||||
/>
|
||||
<AgGridColumn
|
||||
headerName={t('Transfer Type')}
|
||||
@ -70,7 +127,7 @@ export const LedgerTable = ({ ...props }) => (
|
||||
value,
|
||||
data,
|
||||
}: VegaValueFormatterParams<LedgerEntry, 'quantity'>) => {
|
||||
const marketDecimalPlaces = data?.market?.decimalPlaces;
|
||||
const marketDecimalPlaces = data?.marketSender?.decimalPlaces;
|
||||
const assetDecimalPlaces = data?.asset?.decimals || 0;
|
||||
return value
|
||||
? addDecimalsFormatNumber(
|
||||
@ -91,20 +148,11 @@ export const LedgerTable = ({ ...props }) => (
|
||||
data?.asset?.symbol || value
|
||||
}
|
||||
/>
|
||||
<AgGridColumn
|
||||
headerName={t('Market')}
|
||||
field="marketId"
|
||||
valueFormatter={({
|
||||
data,
|
||||
}: VegaValueFormatterParams<LedgerEntry, 'market'>) =>
|
||||
data?.market?.tradableInstrument.instrument.code || '-'
|
||||
}
|
||||
/>
|
||||
<AgGridColumn
|
||||
headerName={t('Vega Time')}
|
||||
field="vegaTime"
|
||||
valueFormatter={({ value }: { value: string }) =>
|
||||
getDateTimeFormat().format(fromNanoSeconds(value))
|
||||
valueFormatter={({ value }: { value?: string }) =>
|
||||
value ? getDateTimeFormat().format(fromNanoSeconds(value)) : '-'
|
||||
}
|
||||
filter="agDateColumnFilter"
|
||||
filterParams={{
|
||||
|
@ -1,9 +1,10 @@
|
||||
import { parseISO, isValid } from 'date-fns';
|
||||
|
||||
export const toNanoSeconds = (date: Date | string) => {
|
||||
return new Date(date).getTime().toString() + '000000';
|
||||
};
|
||||
|
||||
export const fromNanoSeconds = (ts: string) => {
|
||||
if (typeof ts !== 'string') return new Date(0);
|
||||
const validTs = ts.substring(0, ts.length - 6);
|
||||
return new Date(Number(validTs));
|
||||
const val = parseISO(ts);
|
||||
return new Date(isValid(val) ? val : 0);
|
||||
};
|
||||
|
31
libs/types/src/__generated__/types.ts
generated
31
libs/types/src/__generated__/types.ts
generated
@ -177,8 +177,20 @@ export type AggregatedBalanceEdge = {
|
||||
node: AggregatedBalance;
|
||||
};
|
||||
|
||||
export type AggregatedLedgerEntries = {
|
||||
__typename?: 'AggregatedLedgerEntries';
|
||||
export type AggregatedLedgerEntriesConnection = {
|
||||
__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 */
|
||||
assetId?: Maybe<Scalars['ID']>;
|
||||
/** 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']>;
|
||||
/** Party identifier, if query was grouped by sender party - else null */
|
||||
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 */
|
||||
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 */
|
||||
export type Asset = {
|
||||
__typename?: 'Asset';
|
||||
|
Loading…
Reference in New Issue
Block a user