feat(explorer): update liquidity submission view (#5187)
This commit is contained in:
parent
6e31fb03ae
commit
b43ea0f60b
@ -77,7 +77,7 @@
|
|||||||
"executor": "nx:run-commands",
|
"executor": "nx:run-commands",
|
||||||
"options": {
|
"options": {
|
||||||
"commands": [
|
"commands": [
|
||||||
"npx openapi-typescript https://raw.githubusercontent.com/vegaprotocol/documentation/main/specs/v0.73.0/blockexplorer.openapi.json --output apps/explorer/src/types/explorer.d.ts --immutable-types"
|
"npx openapi-typescript https://raw.githubusercontent.com/vegaprotocol/documentation/main/specs/v0.73.1/blockexplorer.openapi.json --output apps/explorer/src/types/explorer.d.ts --immutable-types"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
query ExplorerSettlementAssetForMarket($id: ID!) {
|
|
||||||
market(id: $id) {
|
|
||||||
id
|
|
||||||
decimalPlaces
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
import * as Types from '@vegaprotocol/types';
|
|
||||||
|
|
||||||
import { gql } from '@apollo/client';
|
|
||||||
import * as Apollo from '@apollo/client';
|
|
||||||
const defaultOptions = {} as const;
|
|
||||||
export type ExplorerSettlementAssetForMarketQueryVariables = Types.Exact<{
|
|
||||||
id: Types.Scalars['ID'];
|
|
||||||
}>;
|
|
||||||
|
|
||||||
|
|
||||||
export type ExplorerSettlementAssetForMarketQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, decimalPlaces: number } | null };
|
|
||||||
|
|
||||||
|
|
||||||
export const ExplorerSettlementAssetForMarketDocument = gql`
|
|
||||||
query ExplorerSettlementAssetForMarket($id: ID!) {
|
|
||||||
market(id: $id) {
|
|
||||||
id
|
|
||||||
decimalPlaces
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* __useExplorerSettlementAssetForMarketQuery__
|
|
||||||
*
|
|
||||||
* To run a query within a React component, call `useExplorerSettlementAssetForMarketQuery` and pass it any options that fit your needs.
|
|
||||||
* When your component renders, `useExplorerSettlementAssetForMarketQuery` returns an object from Apollo Client that contains loading, error, and data properties
|
|
||||||
* you can use to render your UI.
|
|
||||||
*
|
|
||||||
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* const { data, loading, error } = useExplorerSettlementAssetForMarketQuery({
|
|
||||||
* variables: {
|
|
||||||
* id: // value for 'id'
|
|
||||||
* },
|
|
||||||
* });
|
|
||||||
*/
|
|
||||||
export function useExplorerSettlementAssetForMarketQuery(baseOptions: Apollo.QueryHookOptions<ExplorerSettlementAssetForMarketQuery, ExplorerSettlementAssetForMarketQueryVariables>) {
|
|
||||||
const options = {...defaultOptions, ...baseOptions}
|
|
||||||
return Apollo.useQuery<ExplorerSettlementAssetForMarketQuery, ExplorerSettlementAssetForMarketQueryVariables>(ExplorerSettlementAssetForMarketDocument, options);
|
|
||||||
}
|
|
||||||
export function useExplorerSettlementAssetForMarketLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<ExplorerSettlementAssetForMarketQuery, ExplorerSettlementAssetForMarketQueryVariables>) {
|
|
||||||
const options = {...defaultOptions, ...baseOptions}
|
|
||||||
return Apollo.useLazyQuery<ExplorerSettlementAssetForMarketQuery, ExplorerSettlementAssetForMarketQueryVariables>(ExplorerSettlementAssetForMarketDocument, options);
|
|
||||||
}
|
|
||||||
export type ExplorerSettlementAssetForMarketQueryHookResult = ReturnType<typeof useExplorerSettlementAssetForMarketQuery>;
|
|
||||||
export type ExplorerSettlementAssetForMarketLazyQueryHookResult = ReturnType<typeof useExplorerSettlementAssetForMarketLazyQuery>;
|
|
||||||
export type ExplorerSettlementAssetForMarketQueryResult = Apollo.QueryResult<ExplorerSettlementAssetForMarketQuery, ExplorerSettlementAssetForMarketQueryVariables>;
|
|
@ -1,12 +1,20 @@
|
|||||||
import { t } from '@vegaprotocol/i18n';
|
import { t } from '@vegaprotocol/i18n';
|
||||||
|
import type { components } from '../../../../../types/explorer';
|
||||||
import { TableCell, TableRow } from '../../../table';
|
import { TableCell, TableRow } from '../../../table';
|
||||||
import { Side, PeggedReferenceMapping } from '@vegaprotocol/types';
|
import { Side, PeggedReferenceMapping } from '@vegaprotocol/types';
|
||||||
import { useExplorerMarketQuery } from '../../../links/market-link/__generated__/Market';
|
import { useExplorerMarketQuery } from '../../../links/market-link/__generated__/Market';
|
||||||
import type { ExplorerMarketQuery } from '../../../links/market-link/__generated__/Market';
|
import type { ExplorerMarketQuery } from '../../../links/market-link/__generated__/Market';
|
||||||
import { addDecimalsFormatNumber } from '@vegaprotocol/utils';
|
import { addDecimalsFormatNumber } from '@vegaprotocol/utils';
|
||||||
import type { components } from '../../../../../types/explorer';
|
|
||||||
export type VegaPeggedReference = components['schemas']['vegaPeggedReference'];
|
export type VegaPeggedReference = components['schemas']['vegaPeggedReference'];
|
||||||
|
|
||||||
|
export const LiquidityReferenceLabel: Record<VegaPeggedReference, string> = {
|
||||||
|
PEGGED_REFERENCE_BEST_ASK: t('Best Ask'),
|
||||||
|
PEGGED_REFERENCE_BEST_BID: t('Best Bid'),
|
||||||
|
PEGGED_REFERENCE_MID: t('Mid'),
|
||||||
|
PEGGED_REFERENCE_UNSPECIFIED: '-',
|
||||||
|
};
|
||||||
|
|
||||||
export interface TxDetailsOrderProps {
|
export interface TxDetailsOrderProps {
|
||||||
offset: string;
|
offset: string;
|
||||||
reference: VegaPeggedReference;
|
reference: VegaPeggedReference;
|
||||||
|
@ -16,7 +16,6 @@ import { TxDetailsOrderAmend } from './tx-order-amend';
|
|||||||
import { TxDetailsWithdrawSubmission } from './tx-withdraw-submission';
|
import { TxDetailsWithdrawSubmission } from './tx-withdraw-submission';
|
||||||
import { TxDetailsDelegate } from './tx-delegation';
|
import { TxDetailsDelegate } from './tx-delegation';
|
||||||
import { TxDetailsUndelegate } from './tx-undelegation';
|
import { TxDetailsUndelegate } from './tx-undelegation';
|
||||||
import { TxDetailsLiquiditySubmission } from './tx-liquidity-submission';
|
|
||||||
import { TxDetailsLiquidityAmendment } from './tx-liquidity-amend';
|
import { TxDetailsLiquidityAmendment } from './tx-liquidity-amend';
|
||||||
import { TxDetailsLiquidityCancellation } from './tx-liquidity-cancel';
|
import { TxDetailsLiquidityCancellation } from './tx-liquidity-cancel';
|
||||||
import { TxDetailsDataSubmission } from './tx-data-submission';
|
import { TxDetailsDataSubmission } from './tx-data-submission';
|
||||||
@ -28,6 +27,7 @@ import { TxDetailsStateVariable } from './tx-state-variable-proposal';
|
|||||||
import { TxProposal } from './tx-proposal';
|
import { TxProposal } from './tx-proposal';
|
||||||
import { TxDetailsTransfer } from './tx-transfer';
|
import { TxDetailsTransfer } from './tx-transfer';
|
||||||
import { TxDetailsStopOrderSubmission } from './tx-stop-order-submission';
|
import { TxDetailsStopOrderSubmission } from './tx-stop-order-submission';
|
||||||
|
import { TxDetailsLiquiditySubmission } from './tx-liquidity-submission';
|
||||||
|
|
||||||
interface TxDetailsWrapperProps {
|
interface TxDetailsWrapperProps {
|
||||||
txData: BlockExplorerTransactionResult | undefined;
|
txData: BlockExplorerTransactionResult | undefined;
|
||||||
|
@ -1,86 +0,0 @@
|
|||||||
import { render } from '@testing-library/react';
|
|
||||||
import { TxDetailsLiquiditySubmission } from './tx-liquidity-submission';
|
|
||||||
import type { TendermintBlocksResponse } from '../../../routes/blocks/tendermint-blocks-response';
|
|
||||||
import type { BlockExplorerTransactionResult } from '../../../routes/types/block-explorer-response';
|
|
||||||
import { MockedProvider } from '@apollo/client/testing';
|
|
||||||
import { MemoryRouter } from 'react-router-dom';
|
|
||||||
|
|
||||||
describe('TxDetailsLiquiditySubmission', () => {
|
|
||||||
const mockTxData = {
|
|
||||||
hash: 'test',
|
|
||||||
command: {
|
|
||||||
liquidityProvisionSubmission: {
|
|
||||||
marketId: 'BTC-USD',
|
|
||||||
commitmentAmount: 100,
|
|
||||||
fee: '0.01',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const mockPubKey = '123';
|
|
||||||
const mockBlockData = {
|
|
||||||
result: {
|
|
||||||
block: {
|
|
||||||
header: {
|
|
||||||
height: '123',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
it('should render the component with correct data', () => {
|
|
||||||
const { getByText } = render(
|
|
||||||
<MockedProvider>
|
|
||||||
<MemoryRouter>
|
|
||||||
<TxDetailsLiquiditySubmission
|
|
||||||
txData={mockTxData as BlockExplorerTransactionResult}
|
|
||||||
pubKey={mockPubKey}
|
|
||||||
blockData={mockBlockData as TendermintBlocksResponse}
|
|
||||||
/>
|
|
||||||
</MemoryRouter>
|
|
||||||
</MockedProvider>
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(getByText('Market')).toBeInTheDocument();
|
|
||||||
expect(getByText('BTC-USD')).toBeInTheDocument();
|
|
||||||
expect(getByText('Commitment amount')).toBeInTheDocument();
|
|
||||||
expect(getByText('100')).toBeInTheDocument();
|
|
||||||
expect(getByText('Fee')).toBeInTheDocument();
|
|
||||||
expect(getByText('1%')).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should display awaiting message when tx data is undefined', () => {
|
|
||||||
const { getByText } = render(
|
|
||||||
<MockedProvider>
|
|
||||||
<MemoryRouter>
|
|
||||||
<TxDetailsLiquiditySubmission
|
|
||||||
txData={undefined}
|
|
||||||
pubKey={mockPubKey}
|
|
||||||
blockData={mockBlockData as TendermintBlocksResponse}
|
|
||||||
/>
|
|
||||||
</MemoryRouter>
|
|
||||||
</MockedProvider>
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
getByText('Awaiting Block Explorer transaction details')
|
|
||||||
).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should display awaiting message when liquidityProvisionSubmission is undefined', () => {
|
|
||||||
const { getByText } = render(
|
|
||||||
<MockedProvider>
|
|
||||||
<MemoryRouter>
|
|
||||||
<TxDetailsLiquiditySubmission
|
|
||||||
txData={{ command: {} } as BlockExplorerTransactionResult}
|
|
||||||
pubKey={mockPubKey}
|
|
||||||
blockData={mockBlockData as TendermintBlocksResponse}
|
|
||||||
/>
|
|
||||||
</MemoryRouter>
|
|
||||||
</MockedProvider>
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
getByText('Awaiting Block Explorer transaction details')
|
|
||||||
).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,6 +1,6 @@
|
|||||||
import { t } from '@vegaprotocol/i18n';
|
import { t } from '@vegaprotocol/i18n';
|
||||||
import type { BlockExplorerTransactionResult } from '../../../routes/types/block-explorer-response';
|
import type { BlockExplorerTransactionResult } from '../../../routes/types/block-explorer-response';
|
||||||
import { MarketLink } from '../../links/';
|
import { MarketLink } from '../../links';
|
||||||
import type { TendermintBlocksResponse } from '../../../routes/blocks/tendermint-blocks-response';
|
import type { TendermintBlocksResponse } from '../../../routes/blocks/tendermint-blocks-response';
|
||||||
import { TxDetailsShared } from './shared/tx-details-shared';
|
import { TxDetailsShared } from './shared/tx-details-shared';
|
||||||
import { TableCell, TableRow, TableWithTbody } from '../../table';
|
import { TableCell, TableRow, TableWithTbody } from '../../table';
|
||||||
@ -11,20 +11,20 @@ import BigNumber from 'bignumber.js';
|
|||||||
export type LiquiditySubmission =
|
export type LiquiditySubmission =
|
||||||
components['schemas']['v1LiquidityProvisionSubmission'];
|
components['schemas']['v1LiquidityProvisionSubmission'];
|
||||||
|
|
||||||
interface TxDetailsLiquiditySubmissionProps {
|
interface TxDetailsLiquidityAmendmentProps {
|
||||||
txData: BlockExplorerTransactionResult | undefined;
|
txData: BlockExplorerTransactionResult | undefined;
|
||||||
pubKey: string | undefined;
|
pubKey: string | undefined;
|
||||||
blockData: TendermintBlocksResponse | undefined;
|
blockData: TendermintBlocksResponse | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Someone cancelled an order
|
* An existing liquidity order is being created.
|
||||||
*/
|
*/
|
||||||
export const TxDetailsLiquiditySubmission = ({
|
export const TxDetailsLiquiditySubmission = ({
|
||||||
txData,
|
txData,
|
||||||
pubKey,
|
pubKey,
|
||||||
blockData,
|
blockData,
|
||||||
}: TxDetailsLiquiditySubmissionProps) => {
|
}: TxDetailsLiquidityAmendmentProps) => {
|
||||||
if (!txData || !txData.command.liquidityProvisionSubmission) {
|
if (!txData || !txData.command.liquidityProvisionSubmission) {
|
||||||
return <>{t('Awaiting Block Explorer transaction details')}</>;
|
return <>{t('Awaiting Block Explorer transaction details')}</>;
|
||||||
}
|
}
|
||||||
@ -64,6 +64,12 @@ export const TxDetailsLiquiditySubmission = ({
|
|||||||
<TableCell>{fee}%</TableCell>
|
<TableCell>{fee}%</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
) : null}
|
) : null}
|
||||||
|
{submission.reference ? (
|
||||||
|
<TableRow modifier="bordered">
|
||||||
|
<TableCell>{t('Reference')}</TableCell>
|
||||||
|
<TableCell>{submission.reference}</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
) : null}
|
||||||
</TableWithTbody>
|
</TableWithTbody>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -18,11 +18,13 @@ import { FilterLabel } from './tx-filter-label';
|
|||||||
export type FilterOption =
|
export type FilterOption =
|
||||||
| 'Amend LiquidityProvision Order'
|
| 'Amend LiquidityProvision Order'
|
||||||
| 'Amend Order'
|
| 'Amend Order'
|
||||||
|
| 'Apply Referral Code'
|
||||||
| 'Batch Market Instructions'
|
| 'Batch Market Instructions'
|
||||||
| 'Cancel LiquidityProvision Order'
|
| 'Cancel LiquidityProvision Order'
|
||||||
| 'Cancel Order'
|
| 'Cancel Order'
|
||||||
| 'Cancel Transfer Funds'
|
| 'Cancel Transfer Funds'
|
||||||
| 'Chain Event'
|
| 'Chain Event'
|
||||||
|
| 'Create Referral Set'
|
||||||
| 'Delegate'
|
| 'Delegate'
|
||||||
| 'Ethereum Key Rotate Submission'
|
| 'Ethereum Key Rotate Submission'
|
||||||
| 'Issue Signatures'
|
| 'Issue Signatures'
|
||||||
@ -40,6 +42,7 @@ export type FilterOption =
|
|||||||
| 'Submit Order'
|
| 'Submit Order'
|
||||||
| 'Transfer Funds'
|
| 'Transfer Funds'
|
||||||
| 'Undelegate'
|
| 'Undelegate'
|
||||||
|
| 'Update Referral Set'
|
||||||
| 'Validator Heartbeat'
|
| 'Validator Heartbeat'
|
||||||
| 'Vote on Proposal'
|
| 'Vote on Proposal'
|
||||||
| 'Withdraw';
|
| 'Withdraw';
|
||||||
|
@ -43,7 +43,7 @@ export const getTxsDataUrl = (params: IGetTxsDataUrl) => {
|
|||||||
url.searchParams.append('first', count);
|
url.searchParams.append('first', count);
|
||||||
url.searchParams.append('after', params.after);
|
url.searchParams.append('after', params.after);
|
||||||
} else {
|
} else {
|
||||||
url.searchParams.append('first', count);
|
url.searchParams.append('last', count);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hacky fix for param as array
|
// Hacky fix for param as array
|
||||||
|
@ -6,7 +6,7 @@ describe('getTxsDataUrl', () => {
|
|||||||
count: 10,
|
count: 10,
|
||||||
baseUrl: 'https://example.com/transactions',
|
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);
|
expect(getTxsDataUrl(params)).toEqual(expectedUrl);
|
||||||
});
|
});
|
||||||
@ -41,7 +41,7 @@ describe('getTxsDataUrl', () => {
|
|||||||
baseUrl: 'https://example.com/transactions',
|
baseUrl: 'https://example.com/transactions',
|
||||||
};
|
};
|
||||||
const expectedUrl =
|
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);
|
expect(getTxsDataUrl(params)).toEqual(expectedUrl);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user