From 451da40ed2802763b73652f5a76f1b7e9a81de30 Mon Sep 17 00:00:00 2001 From: Edd Date: Tue, 25 Jul 2023 14:34:04 +0100 Subject: [PATCH] feat(explorer): iceberg details on order tx (#4380) --- .../txs/details/order/tx-order-iceberg.tsx | 52 +++++++++++++++++++ .../app/components/txs/details/tx-order.tsx | 11 ++++ .../src/app/components/txs/tx-order-type.tsx | 4 ++ 3 files changed, 67 insertions(+) create mode 100644 apps/explorer/src/app/components/txs/details/order/tx-order-iceberg.tsx diff --git a/apps/explorer/src/app/components/txs/details/order/tx-order-iceberg.tsx b/apps/explorer/src/app/components/txs/details/order/tx-order-iceberg.tsx new file mode 100644 index 000000000..d9e3bea69 --- /dev/null +++ b/apps/explorer/src/app/components/txs/details/order/tx-order-iceberg.tsx @@ -0,0 +1,52 @@ +import { t } from '@vegaprotocol/i18n'; +import type { components } from '../../../../../types/explorer'; +import { Tooltip } from '@vegaprotocol/ui-toolkit'; + +export interface TxDetailsOrderIcebergDetailsProps { + iceberg: components['schemas']['v1IcebergOpts']; + size: components['schemas']['v1OrderSubmission']['size']; +} + +/** + +.iceberg .sub { + vertical-align: bottom; + color: #954F01; +} + +.iceberg .sup { + vertical-align: top; + color: #515E1E; +} + + */ + +/** + * Visualises the iceberg details of an order, showing the minimum visible size, + * the full size and the peak size. + */ +export const TxOrderIcebergDetails = ({ + iceberg, + size, +}: TxDetailsOrderIcebergDetailsProps) => { + return ( +
+ + + {iceberg.minimumVisibleSize || '-'} + + + + {size} + + + + {iceberg.peakSize || '-'} + + +
+ ); +}; diff --git a/apps/explorer/src/app/components/txs/details/tx-order.tsx b/apps/explorer/src/app/components/txs/details/tx-order.tsx index 577fb34dd..9009a55a4 100644 --- a/apps/explorer/src/app/components/txs/details/tx-order.tsx +++ b/apps/explorer/src/app/components/txs/details/tx-order.tsx @@ -8,6 +8,7 @@ import { txSignatureToDeterministicId } from '../lib/deterministic-ids'; import DeterministicOrderDetails from '../../order-details/deterministic-order-details'; import Hash from '../../links/hash'; import { TxOrderPeggedReferenceRow } from './order/tx-order-peg'; +import { TxOrderIcebergDetails } from './order/tx-order-iceberg'; interface TxDetailsOrderProps { txData: BlockExplorerTransactionResult | undefined; @@ -32,6 +33,8 @@ export const TxDetailsOrder = ({ const marketId = txData.command.orderSubmission.marketId || '-'; const reference = txData.command.orderSubmission.peggedOrder; const side = txData.command.orderSubmission.side; + const iceberg = txData.command.orderSubmission.icebergOpts; + const size = txData.command.orderSubmission.size; let deterministicId = ''; @@ -74,6 +77,14 @@ export const TxDetailsOrder = ({ marketId={marketId} /> ) : null} + {iceberg ? ( + + {t('Iceberg details')} + + + + + ) : null} {deterministicId.length > 0 ? ( diff --git a/apps/explorer/src/app/components/txs/tx-order-type.tsx b/apps/explorer/src/app/components/txs/tx-order-type.tsx index aea469ee0..c8a0d9c13 100644 --- a/apps/explorer/src/app/components/txs/tx-order-type.tsx +++ b/apps/explorer/src/app/components/txs/tx-order-type.tsx @@ -166,6 +166,7 @@ export const TxOrderType = ({ orderType, command }: TxOrderTypeProps) => { 'text-white dark:text-white bg-vega-dark-150 dark:bg-vega-dark-250'; // This will get unwieldy and should probably produce a different colour of tag + // Note that colours are currently arbitrary if (type === 'Chain Event' && !!command?.chainEvent) { type = getLabelForChainEvent(command.chainEvent); colours = 'text-white dark-text-white bg-vega-pink dark:bg-vega-pink'; @@ -177,6 +178,9 @@ export const TxOrderType = ({ orderType, command }: TxOrderTypeProps) => { type = getLabelForProposal(command.proposalSubmission); } colours = 'text-black bg-vega-yellow'; + } else if (type === 'Order' && command) { + type = getLabelForOrderType(orderType, command); + colours = 'text-white dark-text-white bg-vega-blue dark:bg-vega-blue'; } if (type === 'Vote on Proposal') {