feat(#2039): add tooltips for transfer types in ledger entries (#2100)

This commit is contained in:
m.ray 2022-11-16 14:42:53 -05:00 committed by GitHub
parent b9202237b4
commit 53609bf93c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 1 deletions

View File

@ -7,8 +7,25 @@ import {
import type { VegaValueFormatterParams } from '@vegaprotocol/ui-toolkit';
import { AgGridDynamic as AgGrid } from '@vegaprotocol/ui-toolkit';
import { AgGridColumn } from 'ag-grid-react';
import { AccountTypeMapping, TransferTypeMapping } from '@vegaprotocol/types';
import {
AccountTypeMapping,
DescriptionTransferTypeMapping,
TransferTypeMapping,
} from '@vegaprotocol/types';
import type { LedgerEntry } from './ledger-entries-data-provider';
import type { ITooltipParams } from 'ag-grid-community';
export const TransferTooltipCellComponent = ({ value }: ITooltipParams) => {
return (
<p className="max-w-sm bg-neutral-200 px-4 py-2 z-20 rounded text-sm break-word text-black">
{value
? DescriptionTransferTypeMapping[
value as keyof typeof TransferTypeMapping
]
: ''}
</p>
);
};
export const LedgerTable = ({ ...props }) => (
<AgGrid
@ -16,10 +33,12 @@ export const LedgerTable = ({ ...props }) => (
overlayNoRowsTemplate={t('No entries')}
rowHeight={34}
getRowId={({ data }) => data.id}
tooltipShowDelay={500}
defaultColDef={{
flex: 1,
resizable: true,
sortable: true,
tooltipComponent: TransferTooltipCellComponent,
}}
{...props}
>
@ -37,6 +56,7 @@ export const LedgerTable = ({ ...props }) => (
<AgGridColumn
headerName={t('Transfer Type')}
field="transferType"
tooltipField="transferType"
valueFormatter={({
value,
}: VegaValueFormatterParams<LedgerEntry, 'transferType'>) =>

View File

@ -312,3 +312,31 @@ export enum TransferTypeMapping {
TRANSFER_TYPE_CLEAR_ACCOUNT = 'Market is closed, accounts are cleared',
TRANSFER_TYPE_CHECKPOINT_BALANCE_RESTORE = 'Restore a balance from a checkpoint',
}
export enum DescriptionTransferTypeMapping {
TRANSFER_TYPE_LOSS = `Final settlement loss: Funds deducted after final settlement loss`,
TRANSFER_TYPE_WIN = `Final settlement gain: Funds added to your general account after final settlement gain`,
TRANSFER_TYPE_MTM_LOSS = `Mark to market loss: Funds deducted from your margin account after mark to market loss`,
TRANSFER_TYPE_MTM_WIN = `Mark to market gain: Funds added to your margin account after mark to market gain`,
TRANSFER_TYPE_MARGIN_LOW = `Margin topped up: Funds deducted from your general account to meet margin requirement`,
TRANSFER_TYPE_MARGIN_HIGH = `Margin returned: Excess margin amount returned to your general account`,
TRANSFER_TYPE_MARGIN_CONFISCATED = `Margin confiscated: Margin confiscated from your margin account to fulfil closeout`,
TRANSFER_TYPE_MAKER_FEE_PAY = `Maker fee paid: Maker fee paid from your general account when your aggressive trade was filled`,
TRANSFER_TYPE_MAKER_FEE_RECEIVE = `Maker fee received: Maker fee received into your general account when your passive trade was filled`,
TRANSFER_TYPE_INFRASTRUCTURE_FEE_PAY = `Infrastructure fee paid: Infrastructure fee paid from your general account when your trade was filled`,
TRANSFER_TYPE_INFRASTRUCTURE_FEE_DISTRIBUTE = `Infrastructure fee received: Infrastructure fee, paid by traders, received into your general account`,
TRANSFER_TYPE_LIQUIDITY_FEE_PAY = `Liquidity fee paid: Liquidity fee paid from your general account to market's liquidity providers`,
TRANSFER_TYPE_LIQUIDITY_FEE_DISTRIBUTE = `Liquidity fee received: Liquidity fee received into your general account from traders`,
TRANSFER_TYPE_BOND_LOW = `Bond account funded: Funds deducted from your general account to meet your required liquidity bond amount`,
TRANSFER_TYPE_BOND_HIGH = `Bond returned: Bond returned to your general account after your liquidity commitment was reduced`,
TRANSFER_TYPE_WITHDRAW = `Withdrawal: Funds withdrawn from your general account`,
TRANSFER_TYPE_DEPOSIT = `Deposit: Funds deposited to your general account`,
TRANSFER_TYPE_BOND_SLASHING = `Bond slashed: Bond account penalized when liquidity commitment not met`,
TRANSFER_TYPE_STAKE_REWARD = `Staking reward received: Rewards for staking received into your general account`,
TRANSFER_TYPE_TRANSFER_FUNDS_SEND = `Transfer sent: Funds deducted from your general account to fulfil a transfer`,
TRANSFER_TYPE_TRANSFER_FUNDS_DISTRIBUTE = `Transfer received: Funds added to your general account to fulfil a transfer`,
TRANSFER_TYPE_CLEAR_ACCOUNT = `Market accounts cleared: Market-related accounts emptied, and balances moved, because the market has closed`,
TRANSFER_TYPE_CHECKPOINT_BALANCE_RESTORE = `Balances restored: Your balances were restored after a network restart`,
TRANSFER_TYPE_UNSPECIFIED = 'Default value, always invalid',
TRANSFER_TYPE_CLOSE = 'Close',
TRANSFER_TYPE_WITHDRAW_LOCK = 'Lock amount for withdraw',
}