fix(#2209): make asset dialog use asset id rather than symbol (#2217)

* fix: make asset dialog use asset id rather than symbol

* fix: tests that relied on asset symbol rather than id

* chore: add missing asset id to mocks

* chore: add asset id to mocks for e2e tests

* chore: add missing asset id for orders mock

* chore: fix console-lite build

* chore: add missing asset ids to mocks
This commit is contained in:
Matthew Russell 2022-11-23 17:42:22 -06:00 committed by GitHub
parent ad7f263811
commit 9dfce9e723
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 111 additions and 80 deletions

View File

@ -116,7 +116,12 @@ export const protoMarket: Market = {
product: {
__typename: 'Future',
quoteName: 'DAI',
settlementAsset: { symbol: 'tDAI', __typename: 'Asset', decimals: 5 },
settlementAsset: {
__typename: 'Asset',
id: 'asset-id',
symbol: 'tDAI',
decimals: 5,
},
},
__typename: 'Instrument',
},

View File

@ -39,8 +39,9 @@ export const generateSimpleMarkets = (): MarketsQuery => {
__typename: 'Future',
quoteName: 'USD',
settlementAsset: {
symbol: 'XYZalpha',
__typename: 'Asset',
id: 'asset-XYZalpha',
symbol: 'XYZalpha',
decimals: 5,
},
},
@ -73,8 +74,9 @@ export const generateSimpleMarkets = (): MarketsQuery => {
__typename: 'Future',
quoteName: 'USD',
settlementAsset: {
symbol: 'XYZbeta',
__typename: 'Asset',
id: 'asset-XYZbeta',
symbol: 'XYZbeta',
decimals: 5,
},
},
@ -108,8 +110,9 @@ export const generateSimpleMarkets = (): MarketsQuery => {
__typename: 'Future',
quoteName: 'DAI',
settlementAsset: {
symbol: 'tDAI',
__typename: 'Asset',
id: 'asset-tDAI',
symbol: 'tDAI',
decimals: 5,
},
},
@ -142,8 +145,9 @@ export const generateSimpleMarkets = (): MarketsQuery => {
__typename: 'Future',
quoteName: 'USD',
settlementAsset: {
symbol: 'XYZbeta',
__typename: 'Asset',
id: 'asset-XYZbeta',
symbol: 'XYZbeta',
decimals: 5,
},
},
@ -175,8 +179,9 @@ export const generateSimpleMarkets = (): MarketsQuery => {
__typename: 'Future',
quoteName: 'USD',
settlementAsset: {
symbol: 'tUSDC',
__typename: 'Asset',
id: 'asset-tUSDC',
symbol: 'tUSDC',
decimals: 5,
},
},
@ -210,8 +215,9 @@ export const generateSimpleMarkets = (): MarketsQuery => {
__typename: 'Future',
quoteName: 'USD',
settlementAsset: {
symbol: 'tBTC',
__typename: 'Asset',
id: 'asset-tBTC',
symbol: 'tBTC',
decimals: 5,
},
},
@ -244,8 +250,9 @@ export const generateSimpleMarkets = (): MarketsQuery => {
__typename: 'Future',
quoteName: 'USD',
settlementAsset: {
symbol: 'XYZgamma',
__typename: 'Asset',
id: 'asset-XYZgamma',
symbol: 'XYZgamma',
decimals: 5,
},
},
@ -279,8 +286,9 @@ export const generateSimpleMarkets = (): MarketsQuery => {
__typename: 'Future',
quoteName: 'USD',
settlementAsset: {
symbol: 'tBTC',
__typename: 'Asset',
id: 'asset-tBTC',
symbol: 'tBTC',
decimals: 5,
},
},
@ -314,8 +322,9 @@ export const generateSimpleMarkets = (): MarketsQuery => {
__typename: 'Future',
quoteName: 'BTC',
settlementAsset: {
symbol: 'tBTC',
__typename: 'Asset',
id: 'asset-tBTC',
symbol: 'tBTC',
decimals: 5,
},
},
@ -350,8 +359,9 @@ export const generateSimpleMarkets = (): MarketsQuery => {
__typename: 'Future',
quoteName: 'USD',
settlementAsset: {
symbol: 'tUSDC',
__typename: 'Asset',
id: 'asset-tUSDC',
symbol: 'tUSDC',
decimals: 5,
},
},
@ -386,8 +396,9 @@ export const generateSimpleMarkets = (): MarketsQuery => {
__typename: 'Future',
quoteName: 'EURO',
settlementAsset: {
symbol: 'tEURO',
__typename: 'Asset',
id: 'asset-tEURO',
symbol: 'tEURO',
decimals: 5,
},
},
@ -420,8 +431,9 @@ export const generateSimpleMarkets = (): MarketsQuery => {
__typename: 'Future',
quoteName: 'USD',
settlementAsset: {
symbol: 'XYZgamma',
__typename: 'Asset',
id: 'asset-XYZgamma',
symbol: 'XYZgamma',
decimals: 5,
},
},
@ -455,8 +467,9 @@ export const generateSimpleMarkets = (): MarketsQuery => {
__typename: 'Future',
quoteName: 'USD',
settlementAsset: {
symbol: 'tBTC',
__typename: 'Asset',
id: 'asset-tBTC',
symbol: 'tBTC',
decimals: 5,
},
},
@ -490,8 +503,9 @@ export const generateSimpleMarkets = (): MarketsQuery => {
__typename: 'Future',
quoteName: 'USD',
settlementAsset: {
symbol: 'tBTC',
__typename: 'Asset',
id: 'asset-tBTC',
symbol: 'tBTC',
decimals: 5,
},
},
@ -1240,9 +1254,10 @@ export const generatePositionsMarkets = () => {
},
product: {
settlementAsset: {
__typename: 'Asset',
id: 'asset-tDAI',
symbol: 'tDAI',
decimals: 5,
__typename: 'Asset',
},
quoteName: 'DAI',
__typename: 'Future',
@ -1294,9 +1309,10 @@ export const generatePositionsMarkets = () => {
},
product: {
settlementAsset: {
__typename: 'Asset',
id: 'asset-tDAI',
symbol: 'tDAI',
decimals: 5,
__typename: 'Asset',
},
quoteName: 'DAI',
__typename: 'Future',
@ -1349,9 +1365,10 @@ export const generatePositionsMarkets = () => {
},
product: {
settlementAsset: {
__typename: 'Asset',
id: 'asset-tEURO',
symbol: 'tEURO',
decimals: 5,
__typename: 'Asset',
},
quoteName: 'EURO',
__typename: 'Future',

View File

@ -16,7 +16,7 @@ import { useAccountColumnDefinitions } from '.';
const AccountsManager = () => {
const { partyId = '' } = useOutletContext<{ partyId: string }>();
const { isOpen, symbol, setOpen } = useAssetDetailsDialogStore();
const { isOpen, id, setOpen } = useAssetDetailsDialogStore();
const gridRef = useRef<AgGridReact | null>(null);
const dataRef = useRef<AccountFields[] | null>(null);
const variables = useMemo(() => ({ partyId }), [partyId]);
@ -66,7 +66,7 @@ const AccountsManager = () => {
/>
</AsyncRenderer>
<AssetDetailsDialog
assetSymbol={symbol}
assetId={id}
open={isOpen}
onChange={(open) => setOpen(open)}
/>

View File

@ -15,14 +15,14 @@ const useAccountColumnDefinitions = () => {
field: 'asset.symbol',
headerClass: 'uppercase justify-start',
cellClass: 'uppercase flex h-full items-center md:pl-4',
cellRenderer: ({ value }: GroupCellRendererParams) =>
cellRenderer: ({ value, data }: GroupCellRendererParams) =>
value && value.length > 0 ? (
<div className="md:pl-4 grid h-full items-center" title={value}>
<div className="truncate min-w-0">
<button
className="hover:underline"
onClick={() => {
open(value);
open(data.asset.id);
}}
>
{value}

View File

@ -44,6 +44,7 @@ export const generateMarkets = (
},
product: {
settlementAsset: {
id: 'asset-0',
symbol: 'tDAI',
decimals: 5,
__typename: 'Asset',
@ -88,6 +89,7 @@ export const generateMarkets = (
},
product: {
settlementAsset: {
id: 'asset-1',
symbol: 'XYZalpha',
decimals: 5,
__typename: 'Asset',
@ -132,6 +134,7 @@ export const generateMarkets = (
},
product: {
settlementAsset: {
id: 'asset-2',
symbol: 'tUSDC',
decimals: 5,
__typename: 'Asset',
@ -176,6 +179,7 @@ export const generateMarkets = (
},
product: {
settlementAsset: {
id: 'asset-3',
symbol: 'tBTC',
decimals: 5,
__typename: 'Asset',

View File

@ -125,8 +125,7 @@ export const TradeMarketHeader = ({
const { VEGA_EXPLORER_URL } = useEnvironment();
const { open: openAssetDetailsDialog } = useAssetDetailsDialogStore();
const symbol =
market?.tradableInstrument.instrument.product?.settlementAsset?.symbol;
const asset = market?.tradableInstrument.instrument.product?.settlementAsset;
const onCellClick: OnCellClickHandler = (e, kind, value) => {
if (value && kind === ColumnKind.Asset) {
@ -162,7 +161,7 @@ export const TradeMarketHeader = ({
<Last24hPriceChange marketId={market?.id} />
<Last24hVolume marketId={market?.id} />
<MarketTradingModeComponent marketId={market?.id} onSelect={onSelect} />
{symbol ? (
{asset ? (
<HeaderStat
heading={t('Settlement asset')}
testId="market-settlement-asset"
@ -170,10 +169,10 @@ export const TradeMarketHeader = ({
<div>
<ButtonLink
onClick={(e) => {
openAssetDetailsDialog(symbol, e.target as HTMLElement);
openAssetDetailsDialog(asset.id, e.target as HTMLElement);
}}
>
{symbol}
{asset.symbol}
</ButtonLink>
</div>
</HeaderStat>

View File

@ -2,7 +2,6 @@ import { useCallback } from 'react';
import { Button } from '@vegaprotocol/ui-toolkit';
import { t } from '@vegaprotocol/react-helpers';
import { useWithdrawalDialog } from '@vegaprotocol/withdraws';
import type { AssetFieldsFragment } from '@vegaprotocol/assets';
import { useAssetDetailsDialogStore } from '@vegaprotocol/assets';
import { Splash } from '@vegaprotocol/ui-toolkit';
import { useVegaWallet } from '@vegaprotocol/wallet';
@ -16,8 +15,8 @@ export const AccountsContainer = () => {
const openDepositDialog = useDepositDialog((store) => store.open);
const onClickAsset = useCallback(
(value?: string | AssetFieldsFragment) => {
value && openAssetDetailsDialog(value);
(assetId?: string) => {
assetId && openAssetDetailsDialog(assetId);
},
[openAssetDetailsDialog]
);

View File

@ -298,8 +298,7 @@ export const columns = (
onCellClick(
e,
ColumnKind.Asset,
market.tradableInstrument.instrument.product.settlementAsset
.symbol
market.tradableInstrument.instrument.product.settlementAsset.id
);
}}
>
@ -480,8 +479,7 @@ export const columnsPositionMarkets = (
onCellClick(
e,
ColumnKind.Asset,
market.tradableInstrument.instrument.product.settlementAsset
.symbol
market.tradableInstrument.instrument.product.settlementAsset.id
);
}}
>

View File

@ -35,6 +35,7 @@ const MARKET_A: PartialMarket = {
quoteName: 'ABCDEF',
settlementAsset: {
__typename: 'Asset',
id: 'asset-ABC',
decimals: 2,
symbol: 'ABC',
},
@ -103,6 +104,7 @@ const MARKET_B: PartialMarket = {
quoteName: 'XYZ',
settlementAsset: {
__typename: 'Asset',
id: 'asset-XYZ',
decimals: 2,
symbol: 'XYZ',
},

View File

@ -12,12 +12,12 @@ import { Web3ConnectUncontrolledDialog } from '@vegaprotocol/web3';
import { WelcomeNoticeDialog } from '../components/welcome-notice';
const DialogsContainer = () => {
const { isOpen, symbol, trigger, setOpen } = useAssetDetailsDialogStore();
const { isOpen, id, trigger, setOpen } = useAssetDetailsDialogStore();
return (
<>
<VegaConnectDialog connectors={Connectors} />
<AssetDetailsDialog
assetSymbol={symbol}
assetId={id}
trigger={trigger || null}
open={isOpen}
onChange={setOpen}

View File

@ -1,4 +1,3 @@
import type { Asset } from '@vegaprotocol/assets';
import { useDataProvider } from '@vegaprotocol/react-helpers';
import { AsyncRenderer } from '@vegaprotocol/ui-toolkit';
import type { AgGridReact } from 'ag-grid-react';
@ -10,7 +9,7 @@ import { AccountTable } from './accounts-table';
interface AccountManagerProps {
partyId: string;
onClickAsset: (asset?: string | Asset) => void;
onClickAsset: (assetId: string) => void;
onClickWithdraw?: (assetId?: string) => void;
onClickDeposit?: (assetId?: string) => void;
}

View File

@ -1,6 +1,5 @@
import { forwardRef, useState } from 'react';
import type { ValueFormatterParams } from 'ag-grid-community';
import type { Asset } from '@vegaprotocol/assets';
import {
addDecimalsFormatNumber,
isNumeric,
@ -64,7 +63,7 @@ export interface Datasource extends IDatasource {
export interface AccountTableProps extends AgGridReactProps {
rowData?: AccountFields[] | null;
datasource?: Datasource;
onClickAsset: (asset: string | Asset) => void;
onClickAsset: (assetId: string) => void;
onClickWithdraw?: (assetId: string) => void;
onClickDeposit?: (assetId: string) => void;
}
@ -98,12 +97,15 @@ export const AccountTable = forwardRef<AgGridReact, AccountTableProps>(
)}
cellRenderer={({
value,
data,
}: VegaICellRendererParams<AccountFields, 'asset.symbol'>) => {
return value ? (
<ButtonLink
data-testid="deposit"
onClick={() => {
onClickAsset(value);
if (data) {
onClickAsset(data.asset.id);
}
}}
>
{value}

View File

@ -49,14 +49,10 @@ const mocks = [
},
];
const WrappedAssetDetailsDialog = ({
assetSymbol,
}: {
assetSymbol: string;
}) => (
const WrappedAssetDetailsDialog = ({ assetId }: { assetId: string }) => (
<MockedProvider mocks={mocks}>
<AssetDetailsDialog
assetSymbol={assetSymbol}
assetId={assetId}
open={true}
onChange={() => false}
></AssetDetailsDialog>
@ -65,15 +61,18 @@ const WrappedAssetDetailsDialog = ({
describe('AssetDetailsDialog', () => {
it('should show no data message given unknown asset symbol', async () => {
render(<WrappedAssetDetailsDialog assetSymbol={'UNKNOWN_FOR_SURE'} />);
render(<WrappedAssetDetailsDialog assetId={'UNKNOWN_FOR_SURE'} />);
expect((await screen.findByTestId('splash')).textContent).toContain(
'No data'
);
});
const cases: [string, { key: AssetDetail; value: string }[]][] = [
const cases: [
string, // generated asset id
{ key: AssetDetail; value: string }[]
][] = [
[
'EA01',
'E-01',
[
{ key: AssetDetail.ID, value: 'E-01' },
{ key: AssetDetail.TYPE, value: 'ERC20' },
@ -106,7 +105,7 @@ describe('AssetDetailsDialog', () => {
],
],
[
'BIA01',
'B-01',
[
{ key: AssetDetail.ID, value: 'B-01' },
{ key: AssetDetail.TYPE, value: 'Builtin asset' },
@ -123,7 +122,7 @@ describe('AssetDetailsDialog', () => {
],
],
[
'BIA02',
'B-02',
[
{ key: AssetDetail.ID, value: 'B-02' },
{ key: AssetDetail.TYPE, value: 'Builtin asset' },
@ -140,7 +139,7 @@ describe('AssetDetailsDialog', () => {
],
],
[
'BIA03',
'B-03',
[
{ key: AssetDetail.ID, value: 'B-03' },
{ key: AssetDetail.TYPE, value: 'Builtin asset' },
@ -157,7 +156,7 @@ describe('AssetDetailsDialog', () => {
],
],
[
'BIA04',
'B-04',
[
{ key: AssetDetail.ID, value: 'B-04' },
{ key: AssetDetail.TYPE, value: 'Builtin asset' },
@ -174,10 +173,11 @@ describe('AssetDetailsDialog', () => {
],
],
];
it.each(cases)(
'should show correct data given %p symbol',
async (symbol, details) => {
render(<WrappedAssetDetailsDialog assetSymbol={symbol} />);
'should show correct data given %p id',
async (id, details) => {
render(<WrappedAssetDetailsDialog assetId={id} />);
for (const detail of details) {
expect(
(await screen.findByTestId(testId(detail.key, 'value'))).textContent

View File

@ -3,51 +3,49 @@ import { useAssetsDataProvider } from './assets-data-provider';
import { Button, Dialog, Icon, Splash } from '@vegaprotocol/ui-toolkit';
import create from 'zustand';
import { AssetDetailsTable } from './asset-details-table';
import type { Asset } from './asset-data-provider';
export type AssetDetailsDialogStore = {
isOpen: boolean;
symbol: string | Asset;
id: string;
trigger: HTMLElement | null | undefined;
setOpen: (isOpen: boolean) => void;
open: (symbol: string | Asset, trigger?: HTMLElement | null) => void;
open: (id: string, trigger?: HTMLElement | null) => void;
};
export const useAssetDetailsDialogStore = create<AssetDetailsDialogStore>(
(set) => ({
isOpen: false,
symbol: '',
id: '',
trigger: null,
setOpen: (isOpen) => {
set({ isOpen: isOpen });
},
open: (symbol, trigger?) => {
open: (id, trigger?) => {
set({
isOpen: true,
symbol: symbol,
trigger: trigger,
id,
trigger,
});
},
})
);
export interface AssetDetailsDialogProps {
assetSymbol: string | Asset;
assetId: string;
trigger?: HTMLElement | null;
open: boolean;
onChange: (open: boolean) => void;
}
export const AssetDetailsDialog = ({
assetSymbol,
assetId,
trigger,
open,
onChange,
}: AssetDetailsDialogProps) => {
const { data } = useAssetsDataProvider();
const symbol =
typeof assetSymbol === 'string' ? assetSymbol : assetSymbol.symbol;
const asset = data?.find((a) => a?.symbol === symbol);
const asset = data?.find((a) => a.id === assetId);
const content = asset ? (
<div className="my-2">
@ -58,10 +56,13 @@ export const AssetDetailsDialog = ({
<Splash>{t('No data')}</Splash>
</div>
);
const title = asset
? t(`Asset details - ${asset.symbol}`)
: t('Asset not found');
return (
<Dialog
title={t(`Asset details - ${symbol}`)}
title={title}
icon={<Icon name="info-sign"></Icon>}
open={open}
onChange={(isOpen) => onChange(isOpen)}

View File

@ -191,7 +191,7 @@ export const DepositForm = ({
className="text-sm underline"
onClick={(e) => {
e.preventDefault();
openAssetDetailsDialog(selectedAsset, e.target as HTMLElement);
openAssetDetailsDialog(selectedAsset.id, e.target as HTMLElement);
}}
>
{t('View asset details')}

View File

@ -71,6 +71,7 @@ export const generateFill = (override?: PartialDeep<Trade>) => {
__typename: 'Future',
settlementAsset: {
__typename: 'Asset',
id: 'assset-id',
symbol: 'SYM',
decimals: 18,
},

View File

@ -3,14 +3,14 @@ import { Schema as Types } from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';
const defaultOptions = {} as const;
export type SingleMarketFieldsFragment = { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, fees: { __typename?: 'Fees', factors: { __typename?: 'FeeFactors', makerFee: string, infrastructureFee: string, liquidityFee: string } }, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null }, product: { __typename?: 'Future', quoteName: string, dataSourceSpecForTradingTermination: { __typename?: 'DataSourceSpec', id: string }, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number } } } }, marketTimestamps: { __typename?: 'MarketTimestamps', open?: string | null, close?: string | null }, depth: { __typename?: 'MarketDepth', lastTrade?: { __typename?: 'Trade', price: string } | null } };
export type SingleMarketFieldsFragment = { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, fees: { __typename?: 'Fees', factors: { __typename?: 'FeeFactors', makerFee: string, infrastructureFee: string, liquidityFee: string } }, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null }, product: { __typename?: 'Future', quoteName: string, dataSourceSpecForTradingTermination: { __typename?: 'DataSourceSpec', id: string }, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number } } } }, marketTimestamps: { __typename?: 'MarketTimestamps', open?: any | null, close?: any | null }, depth: { __typename?: 'MarketDepth', lastTrade?: { __typename?: 'Trade', price: string } | null } };
export type MarketQueryVariables = Types.Exact<{
marketId: Types.Scalars['ID'];
}>;
export type MarketQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, fees: { __typename?: 'Fees', factors: { __typename?: 'FeeFactors', makerFee: string, infrastructureFee: string, liquidityFee: string } }, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null }, product: { __typename?: 'Future', quoteName: string, dataSourceSpecForTradingTermination: { __typename?: 'DataSourceSpec', id: string }, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number } } } }, marketTimestamps: { __typename?: 'MarketTimestamps', open?: string | null, close?: string | null }, depth: { __typename?: 'MarketDepth', lastTrade?: { __typename?: 'Trade', price: string } | null } } | null };
export type MarketQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, fees: { __typename?: 'Fees', factors: { __typename?: 'FeeFactors', makerFee: string, infrastructureFee: string, liquidityFee: string } }, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null }, product: { __typename?: 'Future', quoteName: string, dataSourceSpecForTradingTermination: { __typename?: 'DataSourceSpec', id: string }, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number } } } }, marketTimestamps: { __typename?: 'MarketTimestamps', open?: any | null, close?: any | null }, depth: { __typename?: 'MarketDepth', lastTrade?: { __typename?: 'Trade', price: string } | null } } | null };
export const SingleMarketFieldsFragmentDoc = gql`
fragment SingleMarketFields on Market {

View File

@ -3,12 +3,12 @@ import { Schema as Types } from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';
const defaultOptions = {} as const;
export type MarketFieldsFragment = { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, fees: { __typename?: 'Fees', factors: { __typename?: 'FeeFactors', makerFee: string, infrastructureFee: string, liquidityFee: string } }, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null }, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', symbol: string, decimals: number } } } }, marketTimestamps: { __typename?: 'MarketTimestamps', open?: string | null, close?: string | null } };
export type MarketFieldsFragment = { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, fees: { __typename?: 'Fees', factors: { __typename?: 'FeeFactors', makerFee: string, infrastructureFee: string, liquidityFee: string } }, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null }, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, decimals: number } } } }, marketTimestamps: { __typename?: 'MarketTimestamps', open?: any | null, close?: any | null } };
export type MarketsQueryVariables = Types.Exact<{ [key: string]: never; }>;
export type MarketsQuery = { __typename?: 'Query', marketsConnection?: { __typename?: 'MarketConnection', edges: Array<{ __typename?: 'MarketEdge', node: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, fees: { __typename?: 'Fees', factors: { __typename?: 'FeeFactors', makerFee: string, infrastructureFee: string, liquidityFee: string } }, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null }, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', symbol: string, decimals: number } } } }, marketTimestamps: { __typename?: 'MarketTimestamps', open?: string | null, close?: string | null } } }> } | null };
export type MarketsQuery = { __typename?: 'Query', marketsConnection?: { __typename?: 'MarketConnection', edges: Array<{ __typename?: 'MarketEdge', node: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, fees: { __typename?: 'Fees', factors: { __typename?: 'FeeFactors', makerFee: string, infrastructureFee: string, liquidityFee: string } }, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null }, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, decimals: number } } } }, marketTimestamps: { __typename?: 'MarketTimestamps', open?: any | null, close?: any | null } } }> } | null };
export const MarketFieldsFragmentDoc = gql`
fragment MarketFields on Market {
@ -35,6 +35,7 @@ export const MarketFieldsFragmentDoc = gql`
product {
... on Future {
settlementAsset {
id
symbol
decimals
}

View File

@ -54,21 +54,21 @@ export const MarketListTable = forwardRef<
/>
<AgGridColumn
headerName={t('Settlement asset')}
field="tradableInstrument.instrument.product.settlementAsset.symbol"
field="tradableInstrument.instrument.product.settlementAsset"
cellRenderer={({
value,
}: VegaICellRendererParams<
MarketWithData,
'tradableInstrument.instrument.product.settlementAsset.symbol'
'tradableInstrument.instrument.product.settlementAsset'
>) =>
value && value.length > 0 ? (
value ? (
<button
className="hover:underline"
onClick={(e) => {
openAssetDetailsDialog(value, e.target as HTMLElement);
openAssetDetailsDialog(value.id, e.target as HTMLElement);
}}
>
{value}
{value.symbol}
</button>
) : (
''

View File

@ -22,6 +22,7 @@ fragment MarketFields on Market {
product {
... on Future {
settlementAsset {
id
symbol
decimals
}

View File

@ -43,6 +43,7 @@ export const generateOrder = (partialOrder?: PartialDeep<Order>) => {
quoteName: '',
settlementAsset: {
__typename: 'Asset',
id: 'asset-id',
decimals: 1,
symbol: 'XYZ',
},

View File

@ -142,6 +142,7 @@ describe('WithdrawFormContainer', () => {
__typename: 'Future',
settlementAsset: {
__typename: 'Asset',
id: 'asset-id',
symbol: 'tUSDC',
decimals: 5,
},