From fb1326c352f024ffe1412cce20fc883eeff41329 Mon Sep 17 00:00:00 2001 From: Edd Date: Thu, 2 Nov 2023 17:00:13 +0000 Subject: [PATCH] feat(explorer): new lp submission view --- .../txs/details/order/tx-order-peg.tsx | 2 - .../txs/details/tx-details-wrapper.tsx | 5 +- .../txs/details/tx-liquidity-submission.tsx | 75 +++++++++++++++++++ .../src/app/components/txs/tx-filter.tsx | 3 + .../src/app/hooks/get-txs-data-url.ts | 2 +- .../src/app/hooks/get-txs-data-urls.spec.ts | 4 +- 6 files changed, 85 insertions(+), 6 deletions(-) create mode 100644 apps/explorer/src/app/components/txs/details/tx-liquidity-submission.tsx diff --git a/apps/explorer/src/app/components/txs/details/order/tx-order-peg.tsx b/apps/explorer/src/app/components/txs/details/order/tx-order-peg.tsx index 734fee55f..539a32831 100644 --- a/apps/explorer/src/app/components/txs/details/order/tx-order-peg.tsx +++ b/apps/explorer/src/app/components/txs/details/order/tx-order-peg.tsx @@ -5,8 +5,6 @@ import { Side, PeggedReferenceMapping } from '@vegaprotocol/types'; import { useExplorerMarketQuery } from '../../../links/market-link/__generated__/Market'; import type { ExplorerMarketQuery } from '../../../links/market-link/__generated__/Market'; import { addDecimalsFormatNumber } from '@vegaprotocol/utils'; -import type { components } from '../../../../../types/explorer'; -export type VegaPeggedReference = components['schemas']['vegaPeggedReference']; export type VegaPeggedReference = components['schemas']['vegaPeggedReference']; diff --git a/apps/explorer/src/app/components/txs/details/tx-details-wrapper.tsx b/apps/explorer/src/app/components/txs/details/tx-details-wrapper.tsx index 7b32c8a8e..f8292e9fd 100644 --- a/apps/explorer/src/app/components/txs/details/tx-details-wrapper.tsx +++ b/apps/explorer/src/app/components/txs/details/tx-details-wrapper.tsx @@ -27,6 +27,7 @@ import { TxDetailsStateVariable } from './tx-state-variable-proposal'; import { TxProposal } from './tx-proposal'; import { TxDetailsTransfer } from './tx-transfer'; import { TxDetailsStopOrderSubmission } from './tx-stop-order-submission'; +import { TxDetailsLiquiditySubmission } from './tx-liquidity-submission'; interface TxDetailsWrapperProps { txData: BlockExplorerTransactionResult | undefined; @@ -104,7 +105,9 @@ function getTransactionComponent(txData?: BlockExplorerTransactionResult) { return TxDetailsNodeVote; case 'Withdraw': return TxDetailsWithdrawSubmission; - case 'Amend LiquidityProvision Order': + case 'Liquidity Provision Order': + return TxDetailsLiquiditySubmission; + case 'Amend Liquidity Provision Order': return TxDetailsLiquidityAmendment; case 'Cancel LiquidityProvision Order': return TxDetailsLiquidityCancellation; diff --git a/apps/explorer/src/app/components/txs/details/tx-liquidity-submission.tsx b/apps/explorer/src/app/components/txs/details/tx-liquidity-submission.tsx new file mode 100644 index 000000000..d74f86be0 --- /dev/null +++ b/apps/explorer/src/app/components/txs/details/tx-liquidity-submission.tsx @@ -0,0 +1,75 @@ +import { t } from '@vegaprotocol/i18n'; +import type { BlockExplorerTransactionResult } from '../../../routes/types/block-explorer-response'; +import { MarketLink } from '../../links'; +import type { TendermintBlocksResponse } from '../../../routes/blocks/tendermint-blocks-response'; +import { TxDetailsShared } from './shared/tx-details-shared'; +import { TableCell, TableRow, TableWithTbody } from '../../table'; +import type { components } from '../../../../types/explorer'; +import PriceInMarket from '../../price-in-market/price-in-market'; +import BigNumber from 'bignumber.js'; + +export type LiquiditySubmission = + components['schemas']['v1LiquidityProvisionSubmission']; + +interface TxDetailsLiquidityAmendmentProps { + txData: BlockExplorerTransactionResult | undefined; + pubKey: string | undefined; + blockData: TendermintBlocksResponse | undefined; +} + +/** + * An existing liquidity order is being created. + */ +export const TxDetailsLiquiditySubmission = ({ + txData, + pubKey, + blockData, +}: TxDetailsLiquidityAmendmentProps) => { + if (!txData || !txData.command.liquidityProvisionSubmission) { + return <>{t('Awaiting Block Explorer transaction details')}; + } + + const submission: LiquiditySubmission = + txData.command.liquidityProvisionSubmission; + const marketId: string = submission.marketId || '-'; + + const fee = submission.fee + ? new BigNumber(submission.fee).times(100).toString() + : '-'; + + return ( + + + + {t('Market')} + + + + + {submission.commitmentAmount ? ( + + {t('Commitment amount')} + + + + + ) : null} + {submission.fee ? ( + + {t('Fee')} + {fee}% + + ) : null} + {submission.reference ? ( + + {t('Reference')} + {submission.reference} + + ) : null} + + ); +}; diff --git a/apps/explorer/src/app/components/txs/tx-filter.tsx b/apps/explorer/src/app/components/txs/tx-filter.tsx index aeb7e6061..60ea0fc06 100644 --- a/apps/explorer/src/app/components/txs/tx-filter.tsx +++ b/apps/explorer/src/app/components/txs/tx-filter.tsx @@ -18,11 +18,13 @@ import { FilterLabel } from './tx-filter-label'; export type FilterOption = | 'Amend LiquidityProvision Order' | 'Amend Order' + | 'Apply Referral Code' | 'Batch Market Instructions' | 'Cancel LiquidityProvision Order' | 'Cancel Order' | 'Cancel Transfer Funds' | 'Chain Event' + | 'Create Referral Set' | 'Delegate' | 'Ethereum Key Rotate Submission' | 'Issue Signatures' @@ -40,6 +42,7 @@ export type FilterOption = | 'Submit Order' | 'Transfer Funds' | 'Undelegate' + | 'Update Referral Set' | 'Validator Heartbeat' | 'Vote on Proposal' | 'Withdraw'; diff --git a/apps/explorer/src/app/hooks/get-txs-data-url.ts b/apps/explorer/src/app/hooks/get-txs-data-url.ts index fe3851490..04b1e3be9 100644 --- a/apps/explorer/src/app/hooks/get-txs-data-url.ts +++ b/apps/explorer/src/app/hooks/get-txs-data-url.ts @@ -43,7 +43,7 @@ export const getTxsDataUrl = (params: IGetTxsDataUrl) => { url.searchParams.append('first', count); url.searchParams.append('after', params.after); } else { - url.searchParams.append('first', count); + url.searchParams.append('last', count); } // Hacky fix for param as array diff --git a/apps/explorer/src/app/hooks/get-txs-data-urls.spec.ts b/apps/explorer/src/app/hooks/get-txs-data-urls.spec.ts index 675f7ef79..bb3489f7f 100644 --- a/apps/explorer/src/app/hooks/get-txs-data-urls.spec.ts +++ b/apps/explorer/src/app/hooks/get-txs-data-urls.spec.ts @@ -6,7 +6,7 @@ describe('getTxsDataUrl', () => { count: 10, baseUrl: 'https://example.com/transactions', }; - const expectedUrl = 'https://example.com/transactions?first=10'; + const expectedUrl = 'https://example.com/transactions?last=10'; expect(getTxsDataUrl(params)).toEqual(expectedUrl); }); @@ -41,7 +41,7 @@ describe('getTxsDataUrl', () => { baseUrl: 'https://example.com/transactions', }; const expectedUrl = - 'https://example.com/transactions?first=10&filters[cmd.type]=Made%20Up%20Transaction&filters[tx.submitter]=1234'; + 'https://example.com/transactions?last=10&filters[cmd.type]=Made%20Up%20Transaction&filters[tx.submitter]=1234'; expect(getTxsDataUrl(params)).toEqual(expectedUrl); });