Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64bf2b3b52 | ||
|
|
28f9e169e7 |
@@ -32,7 +32,6 @@ import {
|
||||
import { TradingViews } from './trade-views';
|
||||
import { MarketSelector } from './market-selector';
|
||||
import { HeaderStats } from './header-stats';
|
||||
import { PositionsMultiKey } from '@vegaprotocol/positions';
|
||||
|
||||
interface TradeGridProps {
|
||||
market: Market | null;
|
||||
@@ -131,11 +130,6 @@ const MarketBottomPanel = memo(
|
||||
>
|
||||
<TradeGridChild>
|
||||
<Tabs storageKey="console-trade-grid-bottom-right">
|
||||
<Tab id="positions-multi" name={t('Positions v2')}>
|
||||
<VegaWalletContainer>
|
||||
<PositionsMultiKey />
|
||||
</VegaWalletContainer>
|
||||
</Tab>
|
||||
<Tab id="positions" name={t('Positions')}>
|
||||
<VegaWalletContainer>
|
||||
<TradingViews.positions.component
|
||||
|
||||
@@ -20,7 +20,6 @@ export const SettlementDateCell = ({
|
||||
}: SettlementDataCellProps) => {
|
||||
const linkCreator = useLinks(DApp.Explorer);
|
||||
const date = closeTimestamp ? new Date(closeTimestamp) : metaDate;
|
||||
console.log(metaDate);
|
||||
|
||||
let text = '';
|
||||
if (!date) {
|
||||
|
||||
@@ -92,8 +92,5 @@ const cacheConfig: InMemoryCacheConfig = {
|
||||
Fees: {
|
||||
keyFields: false,
|
||||
},
|
||||
Position: {
|
||||
keyFields: ['market', ['id'], 'party', ['id']],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -46,7 +46,7 @@ export const Navbar = ({
|
||||
return (
|
||||
<Navigation
|
||||
appName="Console"
|
||||
theme={'dark'}
|
||||
theme={theme}
|
||||
actions={
|
||||
<>
|
||||
<ProtocolUpgradeCountdown
|
||||
|
||||
@@ -115,7 +115,19 @@ export function createClient({
|
||||
)
|
||||
: httpLink;
|
||||
|
||||
const errorLink = onError(({ graphQLErrors, networkError }) => {
|
||||
const errorLink = onError(({ graphQLErrors, networkError, operation }) => {
|
||||
// if any of these queries error don't capture any errors, its
|
||||
// likely the user is connecting to a dodgy node, NodeGuard gets
|
||||
// called on startup, NodeCheck and NodeCheckTimeUpdate are called
|
||||
// by the NodeSwitcher component and the useNodeHealth hook
|
||||
if (
|
||||
['NodeGuard', 'NodeCheck', 'NodeCheckTimeUpdate'].includes(
|
||||
operation.operationName
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (graphQLErrors) {
|
||||
graphQLErrors.forEach((e) => {
|
||||
if (e.extensions && e.extensions['type'] !== NOT_FOUND) {
|
||||
|
||||
@@ -3,11 +3,13 @@ import { MockedProvider } from '@apollo/react-testing';
|
||||
import { act, render, screen, waitFor } from '@testing-library/react';
|
||||
import { RadioGroup } from '@vegaprotocol/ui-toolkit';
|
||||
import type {
|
||||
BlockTimeSubscription,
|
||||
StatisticsQuery,
|
||||
} from '../../utils/__generated__/Node';
|
||||
import { BlockTimeDocument } from '../../utils/__generated__/Node';
|
||||
import { StatisticsDocument } from '../../utils/__generated__/Node';
|
||||
NodeCheckTimeUpdateSubscription,
|
||||
NodeCheckQuery,
|
||||
} from '../../utils/__generated__/NodeCheck';
|
||||
import {
|
||||
NodeCheckDocument,
|
||||
NodeCheckTimeUpdateDocument,
|
||||
} from '../../utils/__generated__/NodeCheck';
|
||||
import type { RowDataProps } from './row-data';
|
||||
import { POLL_INTERVAL } from './row-data';
|
||||
import { BLOCK_THRESHOLD, RowData } from './row-data';
|
||||
@@ -19,9 +21,9 @@ jest.mock('@vegaprotocol/apollo-client', () => ({
|
||||
useHeaderStore: jest.fn().mockReturnValue({}),
|
||||
}));
|
||||
|
||||
const statsQueryMock: MockedResponse<StatisticsQuery> = {
|
||||
const statsQueryMock: MockedResponse<NodeCheckQuery> = {
|
||||
request: {
|
||||
query: StatisticsDocument,
|
||||
query: NodeCheckDocument,
|
||||
},
|
||||
result: {
|
||||
data: {
|
||||
@@ -34,9 +36,9 @@ const statsQueryMock: MockedResponse<StatisticsQuery> = {
|
||||
},
|
||||
};
|
||||
|
||||
const subMock: MockedResponse<BlockTimeSubscription> = {
|
||||
const subMock: MockedResponse<NodeCheckTimeUpdateSubscription> = {
|
||||
request: {
|
||||
query: BlockTimeDocument,
|
||||
query: NodeCheckTimeUpdateDocument,
|
||||
},
|
||||
result: {
|
||||
data: {
|
||||
@@ -71,8 +73,8 @@ const mockHeaders = (
|
||||
|
||||
const renderComponent = (
|
||||
props: RowDataProps,
|
||||
queryMock: MockedResponse<StatisticsQuery>,
|
||||
subMock: MockedResponse<BlockTimeSubscription>
|
||||
queryMock: MockedResponse<NodeCheckQuery>,
|
||||
subMock: MockedResponse<NodeCheckTimeUpdateSubscription>
|
||||
) => {
|
||||
return (
|
||||
<MockedProvider mocks={[queryMock, subMock, subMock, subMock]}>
|
||||
@@ -127,16 +129,16 @@ describe('RowData', () => {
|
||||
it('radio button still enabled if query fails', async () => {
|
||||
mockHeaders(props.url, {});
|
||||
|
||||
const failedQueryMock: MockedResponse<StatisticsQuery> = {
|
||||
const failedQueryMock: MockedResponse<NodeCheckQuery> = {
|
||||
request: {
|
||||
query: StatisticsDocument,
|
||||
query: NodeCheckDocument,
|
||||
},
|
||||
error: new Error('failed'),
|
||||
};
|
||||
|
||||
const failedSubMock: MockedResponse<BlockTimeSubscription> = {
|
||||
const failedSubMock: MockedResponse<NodeCheckTimeUpdateSubscription> = {
|
||||
request: {
|
||||
query: BlockTimeDocument,
|
||||
query: NodeCheckTimeUpdateDocument,
|
||||
},
|
||||
error: new Error('failed'),
|
||||
};
|
||||
@@ -244,10 +246,10 @@ describe('RowData', () => {
|
||||
jest.useFakeTimers();
|
||||
const createStatsQueryMock = (
|
||||
blockHeight: string
|
||||
): MockedResponse<StatisticsQuery> => {
|
||||
): MockedResponse<NodeCheckQuery> => {
|
||||
return {
|
||||
request: {
|
||||
query: StatisticsDocument,
|
||||
query: NodeCheckDocument,
|
||||
},
|
||||
result: {
|
||||
data: {
|
||||
@@ -261,10 +263,10 @@ describe('RowData', () => {
|
||||
};
|
||||
};
|
||||
|
||||
const createFailedStatsQueryMock = (): MockedResponse<StatisticsQuery> => {
|
||||
const createFailedStatsQueryMock = (): MockedResponse<NodeCheckQuery> => {
|
||||
return {
|
||||
request: {
|
||||
query: StatisticsDocument,
|
||||
query: NodeCheckDocument,
|
||||
},
|
||||
result: {
|
||||
data: undefined,
|
||||
|
||||
@@ -6,9 +6,9 @@ import { Radio } from '@vegaprotocol/ui-toolkit';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { CUSTOM_NODE_KEY } from '../../types';
|
||||
import {
|
||||
useBlockTimeSubscription,
|
||||
useStatisticsQuery,
|
||||
} from '../../utils/__generated__/Node';
|
||||
useNodeCheckQuery,
|
||||
useNodeCheckTimeUpdateSubscription,
|
||||
} from '../../utils/__generated__/NodeCheck';
|
||||
import { LayoutCell } from './layout-cell';
|
||||
|
||||
export const POLL_INTERVAL = 1000;
|
||||
@@ -30,13 +30,14 @@ export const RowData = ({
|
||||
const [subFailed, setSubFailed] = useState(false);
|
||||
const [time, setTime] = useState<number>();
|
||||
// no use of data here as we need the data nodes reference to block height
|
||||
const { data, error, loading, startPolling, stopPolling } =
|
||||
useStatisticsQuery({
|
||||
const { data, error, loading, startPolling, stopPolling } = useNodeCheckQuery(
|
||||
{
|
||||
pollInterval: POLL_INTERVAL,
|
||||
// fix for pollInterval
|
||||
// https://github.com/apollographql/apollo-client/issues/9819
|
||||
ssr: false,
|
||||
});
|
||||
}
|
||||
);
|
||||
const headerStore = useHeaderStore();
|
||||
const headers = headerStore[url];
|
||||
|
||||
@@ -44,7 +45,7 @@ export const RowData = ({
|
||||
data: subData,
|
||||
error: subError,
|
||||
loading: subLoading,
|
||||
} = useBlockTimeSubscription();
|
||||
} = useNodeCheckTimeUpdateSubscription();
|
||||
|
||||
useEffect(() => {
|
||||
const timeout = setTimeout(() => {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import {
|
||||
StatisticsDocument,
|
||||
BlockTimeDocument,
|
||||
} from '../../utils/__generated__/Node';
|
||||
NodeCheckDocument,
|
||||
NodeCheckTimeUpdateDocument,
|
||||
} from '../../utils/__generated__/NodeCheck';
|
||||
import type {
|
||||
StatisticsQuery,
|
||||
BlockTimeSubscription,
|
||||
} from '../../utils/__generated__/Node';
|
||||
NodeCheckQuery,
|
||||
NodeCheckTimeUpdateSubscription,
|
||||
} from '../../utils/__generated__/NodeCheck';
|
||||
import { Networks } from '../../types';
|
||||
import type { RequestHandlerResponse } from 'mock-apollo-client';
|
||||
import { createMockClient } from 'mock-apollo-client';
|
||||
@@ -21,7 +21,7 @@ type MockClientProps = {
|
||||
busEvents?: MockRequestConfig;
|
||||
};
|
||||
|
||||
export const getMockBusEventsResult = (): BlockTimeSubscription => ({
|
||||
export const getMockBusEventsResult = (): NodeCheckTimeUpdateSubscription => ({
|
||||
busEvents: [
|
||||
{
|
||||
__typename: 'BusEvent',
|
||||
@@ -32,19 +32,21 @@ export const getMockBusEventsResult = (): BlockTimeSubscription => ({
|
||||
|
||||
export const getMockStatisticsResult = (
|
||||
env: Networks = Networks.TESTNET
|
||||
): StatisticsQuery => ({
|
||||
): NodeCheckQuery => ({
|
||||
statistics: {
|
||||
__typename: 'Statistics',
|
||||
chainId: `${env.toLowerCase()}-0123`,
|
||||
blockHeight: '11',
|
||||
vegaTime: new Date().toISOString(),
|
||||
},
|
||||
});
|
||||
|
||||
export const getMockQueryResult = (env: Networks): StatisticsQuery => ({
|
||||
export const getMockQueryResult = (env: Networks): NodeCheckQuery => ({
|
||||
statistics: {
|
||||
__typename: 'Statistics',
|
||||
chainId: `${env.toLowerCase()}-0123`,
|
||||
blockHeight: '11',
|
||||
vegaTime: new Date().toISOString(),
|
||||
},
|
||||
});
|
||||
|
||||
@@ -72,11 +74,11 @@ export default function ({
|
||||
const mockClient = createMockClient();
|
||||
|
||||
mockClient.setRequestHandler(
|
||||
StatisticsDocument,
|
||||
NodeCheckDocument,
|
||||
getHandler(statistics, getMockStatisticsResult(network))
|
||||
);
|
||||
mockClient.setRequestHandler(
|
||||
BlockTimeDocument,
|
||||
NodeCheckTimeUpdateDocument,
|
||||
getHandler(busEvents, getMockBusEventsResult())
|
||||
);
|
||||
|
||||
|
||||
@@ -5,11 +5,13 @@ import { useEffect } from 'react';
|
||||
import { create } from 'zustand';
|
||||
import { createClient } from '@vegaprotocol/apollo-client';
|
||||
import type {
|
||||
BlockTimeSubscription,
|
||||
StatisticsQuery,
|
||||
} from '../utils/__generated__/Node';
|
||||
import { BlockTimeDocument } from '../utils/__generated__/Node';
|
||||
import { StatisticsDocument } from '../utils/__generated__/Node';
|
||||
NodeCheckTimeUpdateSubscription,
|
||||
NodeCheckQuery,
|
||||
} from '../utils/__generated__/NodeCheck';
|
||||
import {
|
||||
NodeCheckDocument,
|
||||
NodeCheckTimeUpdateDocument,
|
||||
} from '../utils/__generated__/NodeCheck';
|
||||
import type { Environment } from '../types';
|
||||
import { Networks } from '../types';
|
||||
import { compileErrors } from '../utils/compile-errors';
|
||||
@@ -220,8 +222,8 @@ const testNode = async (
|
||||
*/
|
||||
const testQuery = async (client: Client) => {
|
||||
try {
|
||||
const result = await client.query<StatisticsQuery>({
|
||||
query: StatisticsDocument,
|
||||
const result = await client.query<NodeCheckQuery>({
|
||||
query: NodeCheckDocument,
|
||||
});
|
||||
if (!result || result.error) {
|
||||
return false;
|
||||
@@ -240,8 +242,8 @@ const testQuery = async (client: Client) => {
|
||||
const testSubscription = (client: Client) => {
|
||||
return new Promise((resolve) => {
|
||||
const sub = client
|
||||
.subscribe<BlockTimeSubscription>({
|
||||
query: BlockTimeDocument,
|
||||
.subscribe<NodeCheckTimeUpdateSubscription>({
|
||||
query: NodeCheckTimeUpdateDocument,
|
||||
errorPolicy: 'all',
|
||||
})
|
||||
.subscribe({
|
||||
|
||||
@@ -2,8 +2,8 @@ import { renderHook, waitFor } from '@testing-library/react';
|
||||
import { useNodeHealth } from './use-node-health';
|
||||
import type { MockedResponse } from '@apollo/react-testing';
|
||||
import { MockedProvider } from '@apollo/react-testing';
|
||||
import type { StatisticsQuery } from '../utils/__generated__/Node';
|
||||
import { StatisticsDocument } from '../utils/__generated__/Node';
|
||||
import type { NodeCheckQuery } from '../utils/__generated__/NodeCheck';
|
||||
import { NodeCheckDocument } from '../utils/__generated__/NodeCheck';
|
||||
import { useHeaderStore } from '@vegaprotocol/apollo-client';
|
||||
import { Intent } from '@vegaprotocol/ui-toolkit';
|
||||
|
||||
@@ -16,10 +16,10 @@ jest.mock('@vegaprotocol/apollo-client');
|
||||
|
||||
const createStatsMock = (
|
||||
blockHeight: number
|
||||
): MockedResponse<StatisticsQuery> => {
|
||||
): MockedResponse<NodeCheckQuery> => {
|
||||
return {
|
||||
request: {
|
||||
query: StatisticsDocument,
|
||||
query: NodeCheckDocument,
|
||||
},
|
||||
result: {
|
||||
data: {
|
||||
@@ -34,7 +34,7 @@ const createStatsMock = (
|
||||
};
|
||||
|
||||
function setup(
|
||||
mock: MockedResponse<StatisticsQuery>,
|
||||
mock: MockedResponse<NodeCheckQuery>,
|
||||
headers:
|
||||
| {
|
||||
blockHeight: number;
|
||||
@@ -93,9 +93,9 @@ describe('useNodeHealth', () => {
|
||||
);
|
||||
|
||||
it('block diff is null if query fails indicating non operational', async () => {
|
||||
const failedQuery: MockedResponse<StatisticsQuery> = {
|
||||
const failedQuery: MockedResponse<NodeCheckQuery> = {
|
||||
request: {
|
||||
query: StatisticsDocument,
|
||||
query: NodeCheckDocument,
|
||||
},
|
||||
result: {
|
||||
// @ts-ignore failed query with no result
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useEffect, useMemo } from 'react';
|
||||
import { useStatisticsQuery } from '../utils/__generated__/Node';
|
||||
import { useNodeCheckQuery } from '../utils/__generated__/NodeCheck';
|
||||
import { useHeaderStore } from '@vegaprotocol/apollo-client';
|
||||
import { useEnvironment } from './use-environment';
|
||||
import { useNavigatorOnline } from '@vegaprotocol/react-helpers';
|
||||
@@ -16,7 +16,7 @@ export const useNodeHealth = () => {
|
||||
const url = useEnvironment((store) => store.VEGA_URL);
|
||||
const headerStore = useHeaderStore();
|
||||
const headers = url ? headerStore[url] : undefined;
|
||||
const { data, error, startPolling, stopPolling } = useStatisticsQuery({
|
||||
const { data, error, startPolling, stopPolling } = useNodeCheckQuery({
|
||||
fetchPolicy: 'no-cache',
|
||||
});
|
||||
|
||||
|
||||
@@ -8,4 +8,4 @@ export * from './hooks';
|
||||
export * from './types';
|
||||
|
||||
// Utils
|
||||
export * from './utils/__generated__/Node';
|
||||
export * from './utils/__generated__/NodeCheck';
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
query Statistics {
|
||||
query NodeCheck {
|
||||
statistics {
|
||||
chainId
|
||||
blockHeight
|
||||
@@ -6,7 +6,7 @@ query Statistics {
|
||||
}
|
||||
}
|
||||
|
||||
subscription BlockTime {
|
||||
subscription NodeCheckTimeUpdate {
|
||||
busEvents(types: TimeUpdate, batchSize: 1) {
|
||||
id
|
||||
}
|
||||
-81
@@ -1,81 +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 StatisticsQueryVariables = Types.Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
export type StatisticsQuery = { __typename?: 'Query', statistics: { __typename?: 'Statistics', chainId: string, blockHeight: string, vegaTime: any } };
|
||||
|
||||
export type BlockTimeSubscriptionVariables = Types.Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
export type BlockTimeSubscription = { __typename?: 'Subscription', busEvents?: Array<{ __typename?: 'BusEvent', id: string }> | null };
|
||||
|
||||
|
||||
export const StatisticsDocument = gql`
|
||||
query Statistics {
|
||||
statistics {
|
||||
chainId
|
||||
blockHeight
|
||||
vegaTime
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
/**
|
||||
* __useStatisticsQuery__
|
||||
*
|
||||
* To run a query within a React component, call `useStatisticsQuery` and pass it any options that fit your needs.
|
||||
* When your component renders, `useStatisticsQuery` 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 } = useStatisticsQuery({
|
||||
* variables: {
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useStatisticsQuery(baseOptions?: Apollo.QueryHookOptions<StatisticsQuery, StatisticsQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useQuery<StatisticsQuery, StatisticsQueryVariables>(StatisticsDocument, options);
|
||||
}
|
||||
export function useStatisticsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<StatisticsQuery, StatisticsQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useLazyQuery<StatisticsQuery, StatisticsQueryVariables>(StatisticsDocument, options);
|
||||
}
|
||||
export type StatisticsQueryHookResult = ReturnType<typeof useStatisticsQuery>;
|
||||
export type StatisticsLazyQueryHookResult = ReturnType<typeof useStatisticsLazyQuery>;
|
||||
export type StatisticsQueryResult = Apollo.QueryResult<StatisticsQuery, StatisticsQueryVariables>;
|
||||
export const BlockTimeDocument = gql`
|
||||
subscription BlockTime {
|
||||
busEvents(types: TimeUpdate, batchSize: 1) {
|
||||
id
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
/**
|
||||
* __useBlockTimeSubscription__
|
||||
*
|
||||
* To run a query within a React component, call `useBlockTimeSubscription` and pass it any options that fit your needs.
|
||||
* When your component renders, `useBlockTimeSubscription` 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 subscription, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
|
||||
*
|
||||
* @example
|
||||
* const { data, loading, error } = useBlockTimeSubscription({
|
||||
* variables: {
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useBlockTimeSubscription(baseOptions?: Apollo.SubscriptionHookOptions<BlockTimeSubscription, BlockTimeSubscriptionVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useSubscription<BlockTimeSubscription, BlockTimeSubscriptionVariables>(BlockTimeDocument, options);
|
||||
}
|
||||
export type BlockTimeSubscriptionHookResult = ReturnType<typeof useBlockTimeSubscription>;
|
||||
export type BlockTimeSubscriptionResult = Apollo.SubscriptionResult<BlockTimeSubscription>;
|
||||
@@ -0,0 +1,81 @@
|
||||
import * as Types from '@vegaprotocol/types';
|
||||
|
||||
import { gql } from '@apollo/client';
|
||||
import * as Apollo from '@apollo/client';
|
||||
const defaultOptions = {} as const;
|
||||
export type NodeCheckQueryVariables = Types.Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
export type NodeCheckQuery = { __typename?: 'Query', statistics: { __typename?: 'Statistics', chainId: string, blockHeight: string, vegaTime: any } };
|
||||
|
||||
export type NodeCheckTimeUpdateSubscriptionVariables = Types.Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
export type NodeCheckTimeUpdateSubscription = { __typename?: 'Subscription', busEvents?: Array<{ __typename?: 'BusEvent', id: string }> | null };
|
||||
|
||||
|
||||
export const NodeCheckDocument = gql`
|
||||
query NodeCheck {
|
||||
statistics {
|
||||
chainId
|
||||
blockHeight
|
||||
vegaTime
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
/**
|
||||
* __useNodeCheckQuery__
|
||||
*
|
||||
* To run a query within a React component, call `useNodeCheckQuery` and pass it any options that fit your needs.
|
||||
* When your component renders, `useNodeCheckQuery` 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 } = useNodeCheckQuery({
|
||||
* variables: {
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useNodeCheckQuery(baseOptions?: Apollo.QueryHookOptions<NodeCheckQuery, NodeCheckQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useQuery<NodeCheckQuery, NodeCheckQueryVariables>(NodeCheckDocument, options);
|
||||
}
|
||||
export function useNodeCheckLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<NodeCheckQuery, NodeCheckQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useLazyQuery<NodeCheckQuery, NodeCheckQueryVariables>(NodeCheckDocument, options);
|
||||
}
|
||||
export type NodeCheckQueryHookResult = ReturnType<typeof useNodeCheckQuery>;
|
||||
export type NodeCheckLazyQueryHookResult = ReturnType<typeof useNodeCheckLazyQuery>;
|
||||
export type NodeCheckQueryResult = Apollo.QueryResult<NodeCheckQuery, NodeCheckQueryVariables>;
|
||||
export const NodeCheckTimeUpdateDocument = gql`
|
||||
subscription NodeCheckTimeUpdate {
|
||||
busEvents(types: TimeUpdate, batchSize: 1) {
|
||||
id
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
/**
|
||||
* __useNodeCheckTimeUpdateSubscription__
|
||||
*
|
||||
* To run a query within a React component, call `useNodeCheckTimeUpdateSubscription` and pass it any options that fit your needs.
|
||||
* When your component renders, `useNodeCheckTimeUpdateSubscription` 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 subscription, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
|
||||
*
|
||||
* @example
|
||||
* const { data, loading, error } = useNodeCheckTimeUpdateSubscription({
|
||||
* variables: {
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useNodeCheckTimeUpdateSubscription(baseOptions?: Apollo.SubscriptionHookOptions<NodeCheckTimeUpdateSubscription, NodeCheckTimeUpdateSubscriptionVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useSubscription<NodeCheckTimeUpdateSubscription, NodeCheckTimeUpdateSubscriptionVariables>(NodeCheckTimeUpdateDocument, options);
|
||||
}
|
||||
export type NodeCheckTimeUpdateSubscriptionHookResult = ReturnType<typeof useNodeCheckTimeUpdateSubscription>;
|
||||
export type NodeCheckTimeUpdateSubscriptionResult = Apollo.SubscriptionResult<NodeCheckTimeUpdateSubscription>;
|
||||
@@ -1,11 +1,11 @@
|
||||
import type { StatisticsQuery } from './__generated__/Node';
|
||||
import type { NodeCheckQuery } from './__generated__/NodeCheck';
|
||||
import merge from 'lodash/merge';
|
||||
import type { PartialDeep } from 'type-fest';
|
||||
|
||||
export const statisticsQuery = (
|
||||
override?: PartialDeep<StatisticsQuery>
|
||||
): StatisticsQuery => {
|
||||
const defaultResult: StatisticsQuery = {
|
||||
override?: PartialDeep<NodeCheckQuery>
|
||||
): NodeCheckQuery => {
|
||||
const defaultResult: NodeCheckQuery = {
|
||||
statistics: {
|
||||
__typename: 'Statistics',
|
||||
chainId: 'chain-id',
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
export * from './lib/__generated__/Positions';
|
||||
export * from './lib/positions-container';
|
||||
export * from './lib/positions-data-providers';
|
||||
export * from './lib/positions-multi-key';
|
||||
export * from './lib/margin-data-provider';
|
||||
export * from './lib/positions-table';
|
||||
export * from './lib/use-market-margin';
|
||||
|
||||
@@ -9,9 +9,6 @@ fragment PositionFields on Position {
|
||||
market {
|
||||
id
|
||||
}
|
||||
party {
|
||||
id
|
||||
}
|
||||
}
|
||||
|
||||
query Positions($partyId: ID!) {
|
||||
@@ -37,8 +34,6 @@ subscription PositionsSubscription($partyId: ID!) {
|
||||
marketId
|
||||
lossSocializationAmount
|
||||
positionStatus
|
||||
partyId
|
||||
marketId
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
fragment PositionMultiFields on Position {
|
||||
realisedPNL
|
||||
openVolume
|
||||
unrealisedPNL
|
||||
averageEntryPrice
|
||||
updatedAt
|
||||
positionStatus
|
||||
lossSocializationAmount
|
||||
market {
|
||||
id
|
||||
}
|
||||
party {
|
||||
id
|
||||
}
|
||||
}
|
||||
|
||||
query PositionsMulti($partyIds: [ID!]!) {
|
||||
positions(filter: { partyIds: $partyIds }) {
|
||||
edges {
|
||||
node {
|
||||
...PositionMultiFields
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query MarketName($marketId: ID!) {
|
||||
market(id: $marketId) {
|
||||
id
|
||||
tradableInstrument {
|
||||
instrument {
|
||||
code
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query MarketDecimals($marketId: ID!) {
|
||||
market(id: $marketId) {
|
||||
id
|
||||
decimalPlaces
|
||||
}
|
||||
}
|
||||
+3
-8
@@ -3,21 +3,21 @@ import * as Types from '@vegaprotocol/types';
|
||||
import { gql } from '@apollo/client';
|
||||
import * as Apollo from '@apollo/client';
|
||||
const defaultOptions = {} as const;
|
||||
export type PositionFieldsFragment = { __typename?: 'Position', realisedPNL: string, openVolume: string, unrealisedPNL: string, averageEntryPrice: string, updatedAt?: any | null, positionStatus: Types.PositionStatus, lossSocializationAmount: string, market: { __typename?: 'Market', id: string }, party: { __typename?: 'Party', id: string } };
|
||||
export type PositionFieldsFragment = { __typename?: 'Position', realisedPNL: string, openVolume: string, unrealisedPNL: string, averageEntryPrice: string, updatedAt?: any | null, positionStatus: Types.PositionStatus, lossSocializationAmount: string, market: { __typename?: 'Market', id: string } };
|
||||
|
||||
export type PositionsQueryVariables = Types.Exact<{
|
||||
partyId: Types.Scalars['ID'];
|
||||
}>;
|
||||
|
||||
|
||||
export type PositionsQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, positionsConnection?: { __typename?: 'PositionConnection', edges?: Array<{ __typename?: 'PositionEdge', node: { __typename?: 'Position', realisedPNL: string, openVolume: string, unrealisedPNL: string, averageEntryPrice: string, updatedAt?: any | null, positionStatus: Types.PositionStatus, lossSocializationAmount: string, market: { __typename?: 'Market', id: string }, party: { __typename?: 'Party', id: string } } }> | null } | null } | null };
|
||||
export type PositionsQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, positionsConnection?: { __typename?: 'PositionConnection', edges?: Array<{ __typename?: 'PositionEdge', node: { __typename?: 'Position', realisedPNL: string, openVolume: string, unrealisedPNL: string, averageEntryPrice: string, updatedAt?: any | null, positionStatus: Types.PositionStatus, lossSocializationAmount: string, market: { __typename?: 'Market', id: string } } }> | null } | null } | null };
|
||||
|
||||
export type PositionsSubscriptionSubscriptionVariables = Types.Exact<{
|
||||
partyId: Types.Scalars['ID'];
|
||||
}>;
|
||||
|
||||
|
||||
export type PositionsSubscriptionSubscription = { __typename?: 'Subscription', positions: Array<{ __typename?: 'PositionUpdate', realisedPNL: string, openVolume: string, unrealisedPNL: string, averageEntryPrice: string, updatedAt?: any | null, marketId: string, lossSocializationAmount: string, positionStatus: Types.PositionStatus, partyId: string }> };
|
||||
export type PositionsSubscriptionSubscription = { __typename?: 'Subscription', positions: Array<{ __typename?: 'PositionUpdate', realisedPNL: string, openVolume: string, unrealisedPNL: string, averageEntryPrice: string, updatedAt?: any | null, marketId: string, lossSocializationAmount: string, positionStatus: Types.PositionStatus }> };
|
||||
|
||||
export type MarginFieldsFragment = { __typename?: 'MarginLevels', maintenanceLevel: string, searchLevel: string, initialLevel: string, collateralReleaseLevel: string, asset: { __typename?: 'Asset', id: string }, market: { __typename?: 'Market', id: string } };
|
||||
|
||||
@@ -57,9 +57,6 @@ export const PositionFieldsFragmentDoc = gql`
|
||||
market {
|
||||
id
|
||||
}
|
||||
party {
|
||||
id
|
||||
}
|
||||
}
|
||||
`;
|
||||
export const MarginFieldsFragmentDoc = gql`
|
||||
@@ -129,8 +126,6 @@ export const PositionsSubscriptionDocument = gql`
|
||||
marketId
|
||||
lossSocializationAmount
|
||||
positionStatus
|
||||
partyId
|
||||
marketId
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
-160
@@ -1,160 +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 PositionMultiFieldsFragment = { __typename?: 'Position', realisedPNL: string, openVolume: string, unrealisedPNL: string, averageEntryPrice: string, updatedAt?: any | null, positionStatus: Types.PositionStatus, lossSocializationAmount: string, market: { __typename?: 'Market', id: string }, party: { __typename?: 'Party', id: string } };
|
||||
|
||||
export type PositionsMultiQueryVariables = Types.Exact<{
|
||||
partyIds: Array<Types.Scalars['ID']> | Types.Scalars['ID'];
|
||||
}>;
|
||||
|
||||
|
||||
export type PositionsMultiQuery = { __typename?: 'Query', positions?: { __typename?: 'PositionConnection', edges?: Array<{ __typename?: 'PositionEdge', node: { __typename?: 'Position', realisedPNL: string, openVolume: string, unrealisedPNL: string, averageEntryPrice: string, updatedAt?: any | null, positionStatus: Types.PositionStatus, lossSocializationAmount: string, market: { __typename?: 'Market', id: string }, party: { __typename?: 'Party', id: string } } }> | null } | null };
|
||||
|
||||
export type MarketNameQueryVariables = Types.Exact<{
|
||||
marketId: Types.Scalars['ID'];
|
||||
}>;
|
||||
|
||||
|
||||
export type MarketNameQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', code: string } } } | null };
|
||||
|
||||
export type MarketDecimalsQueryVariables = Types.Exact<{
|
||||
marketId: Types.Scalars['ID'];
|
||||
}>;
|
||||
|
||||
|
||||
export type MarketDecimalsQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, decimalPlaces: number } | null };
|
||||
|
||||
export const PositionMultiFieldsFragmentDoc = gql`
|
||||
fragment PositionMultiFields on Position {
|
||||
realisedPNL
|
||||
openVolume
|
||||
unrealisedPNL
|
||||
averageEntryPrice
|
||||
updatedAt
|
||||
positionStatus
|
||||
lossSocializationAmount
|
||||
market {
|
||||
id
|
||||
}
|
||||
party {
|
||||
id
|
||||
}
|
||||
}
|
||||
`;
|
||||
export const PositionsMultiDocument = gql`
|
||||
query PositionsMulti($partyIds: [ID!]!) {
|
||||
positions(filter: {partyIds: $partyIds}) {
|
||||
edges {
|
||||
node {
|
||||
...PositionMultiFields
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
${PositionMultiFieldsFragmentDoc}`;
|
||||
|
||||
/**
|
||||
* __usePositionsMultiQuery__
|
||||
*
|
||||
* To run a query within a React component, call `usePositionsMultiQuery` and pass it any options that fit your needs.
|
||||
* When your component renders, `usePositionsMultiQuery` 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 } = usePositionsMultiQuery({
|
||||
* variables: {
|
||||
* partyIds: // value for 'partyIds'
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function usePositionsMultiQuery(baseOptions: Apollo.QueryHookOptions<PositionsMultiQuery, PositionsMultiQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useQuery<PositionsMultiQuery, PositionsMultiQueryVariables>(PositionsMultiDocument, options);
|
||||
}
|
||||
export function usePositionsMultiLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<PositionsMultiQuery, PositionsMultiQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useLazyQuery<PositionsMultiQuery, PositionsMultiQueryVariables>(PositionsMultiDocument, options);
|
||||
}
|
||||
export type PositionsMultiQueryHookResult = ReturnType<typeof usePositionsMultiQuery>;
|
||||
export type PositionsMultiLazyQueryHookResult = ReturnType<typeof usePositionsMultiLazyQuery>;
|
||||
export type PositionsMultiQueryResult = Apollo.QueryResult<PositionsMultiQuery, PositionsMultiQueryVariables>;
|
||||
export const MarketNameDocument = gql`
|
||||
query MarketName($marketId: ID!) {
|
||||
market(id: $marketId) {
|
||||
id
|
||||
tradableInstrument {
|
||||
instrument {
|
||||
code
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
/**
|
||||
* __useMarketNameQuery__
|
||||
*
|
||||
* To run a query within a React component, call `useMarketNameQuery` and pass it any options that fit your needs.
|
||||
* When your component renders, `useMarketNameQuery` 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 } = useMarketNameQuery({
|
||||
* variables: {
|
||||
* marketId: // value for 'marketId'
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useMarketNameQuery(baseOptions: Apollo.QueryHookOptions<MarketNameQuery, MarketNameQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useQuery<MarketNameQuery, MarketNameQueryVariables>(MarketNameDocument, options);
|
||||
}
|
||||
export function useMarketNameLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<MarketNameQuery, MarketNameQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useLazyQuery<MarketNameQuery, MarketNameQueryVariables>(MarketNameDocument, options);
|
||||
}
|
||||
export type MarketNameQueryHookResult = ReturnType<typeof useMarketNameQuery>;
|
||||
export type MarketNameLazyQueryHookResult = ReturnType<typeof useMarketNameLazyQuery>;
|
||||
export type MarketNameQueryResult = Apollo.QueryResult<MarketNameQuery, MarketNameQueryVariables>;
|
||||
export const MarketDecimalsDocument = gql`
|
||||
query MarketDecimals($marketId: ID!) {
|
||||
market(id: $marketId) {
|
||||
id
|
||||
decimalPlaces
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
/**
|
||||
* __useMarketDecimalsQuery__
|
||||
*
|
||||
* To run a query within a React component, call `useMarketDecimalsQuery` and pass it any options that fit your needs.
|
||||
* When your component renders, `useMarketDecimalsQuery` 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 } = useMarketDecimalsQuery({
|
||||
* variables: {
|
||||
* marketId: // value for 'marketId'
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useMarketDecimalsQuery(baseOptions: Apollo.QueryHookOptions<MarketDecimalsQuery, MarketDecimalsQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useQuery<MarketDecimalsQuery, MarketDecimalsQueryVariables>(MarketDecimalsDocument, options);
|
||||
}
|
||||
export function useMarketDecimalsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<MarketDecimalsQuery, MarketDecimalsQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useLazyQuery<MarketDecimalsQuery, MarketDecimalsQueryVariables>(MarketDecimalsDocument, options);
|
||||
}
|
||||
export type MarketDecimalsQueryHookResult = ReturnType<typeof useMarketDecimalsQuery>;
|
||||
export type MarketDecimalsLazyQueryHookResult = ReturnType<typeof useMarketDecimalsLazyQuery>;
|
||||
export type MarketDecimalsQueryResult = Apollo.QueryResult<MarketDecimalsQuery, MarketDecimalsQueryVariables>;
|
||||
@@ -1,159 +0,0 @@
|
||||
import { useVegaWallet } from '@vegaprotocol/wallet';
|
||||
import {
|
||||
useMarketDecimalsQuery,
|
||||
useMarketNameQuery,
|
||||
usePositionsMultiQuery,
|
||||
} from './__generated__/PositionsMulti';
|
||||
import { AgGridLazy } from '@vegaprotocol/datagrid';
|
||||
import { useEffect, useMemo } from 'react';
|
||||
import type {
|
||||
PositionsSubscriptionSubscription,
|
||||
PositionsSubscriptionSubscriptionVariables,
|
||||
} from './__generated__/Positions';
|
||||
import { PositionsSubscriptionDocument } from './__generated__/Positions';
|
||||
import { addDecimalsFormatNumber, truncateByChars } from '@vegaprotocol/utils';
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
|
||||
export const PositionsMultiKey = () => {
|
||||
const { pubKeys } = useVegaWallet();
|
||||
const { data } = usePositions();
|
||||
const colDefs = useMemo(() => {
|
||||
return [
|
||||
{
|
||||
field: 'party.id',
|
||||
valueFormatter: ({ value }) => {
|
||||
const truncated = truncateByChars(value);
|
||||
const pk = pubKeys?.find((pk) => pk.publicKey === value);
|
||||
return pk ? pk.name + ' ' + truncated : truncated;
|
||||
},
|
||||
},
|
||||
{
|
||||
headerName: 'Market',
|
||||
field: 'market.id',
|
||||
cellRenderer: ({ value }) => {
|
||||
return <MarketCell id={value} />;
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'openVolume',
|
||||
},
|
||||
{
|
||||
field: 'unrealisedPNL',
|
||||
cellRenderer: ({ data }) => {
|
||||
return (
|
||||
<PNLCell marketId={data.market.id} value={data.unrealisedPNL} />
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'realisedPNL',
|
||||
cellRenderer: ({ data }) => {
|
||||
return <PNLCell marketId={data.market.id} value={data.realisedPNL} />;
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'updatedAt',
|
||||
},
|
||||
];
|
||||
}, [pubKeys]);
|
||||
|
||||
const rowData = data?.positions?.edges?.length
|
||||
? data.positions.edges.map((e) => e.node)
|
||||
: [];
|
||||
|
||||
return (
|
||||
<AgGridLazy
|
||||
getRowId={({ data }) => `${data.party.id}:${data.market.id}`}
|
||||
style={{ width: '100%', height: '100%' }}
|
||||
columnDefs={colDefs}
|
||||
rowData={rowData}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
const usePositions = () => {
|
||||
const { pubKeys } = useVegaWallet();
|
||||
const client = useApolloClient();
|
||||
const { data, loading, error } = usePositionsMultiQuery({
|
||||
variables: {
|
||||
partyIds: pubKeys ? pubKeys.map((pk) => pk.publicKey) : [],
|
||||
},
|
||||
skip: !pubKeys || pubKeys.length === 0,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (!pubKeys?.length) return;
|
||||
const subs = pubKeys.map((p) => {
|
||||
return client
|
||||
.subscribe<
|
||||
PositionsSubscriptionSubscription,
|
||||
PositionsSubscriptionSubscriptionVariables
|
||||
>({
|
||||
query: PositionsSubscriptionDocument,
|
||||
variables: {
|
||||
partyId: p.publicKey,
|
||||
},
|
||||
// no cache as we only want to store data in the root Position query,
|
||||
// we modify this cache entry directly below
|
||||
fetchPolicy: 'no-cache',
|
||||
})
|
||||
.subscribe(({ data }) => {
|
||||
data?.positions.forEach((position) => {
|
||||
const id = client.cache.identify({
|
||||
__typename: 'Position',
|
||||
party: { id: position.partyId },
|
||||
market: { id: position.marketId },
|
||||
});
|
||||
client.cache.modify({
|
||||
id,
|
||||
fields: {
|
||||
realisedPNL: () => position.realisedPNL,
|
||||
unrealisedPNL: () => position.unrealisedPNL,
|
||||
openVolume: () => position.openVolume,
|
||||
averageEntryPrice: () => position.averageEntryPrice,
|
||||
positionStatus: () => position.positionStatus,
|
||||
lossSocializationAmount: () => position.lossSocializationAmount,
|
||||
updatedAt: () => position.updatedAt,
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return () => {
|
||||
subs.forEach((sub) => {
|
||||
sub.unsubscribe();
|
||||
});
|
||||
};
|
||||
}, [pubKeys, client]);
|
||||
|
||||
return { data, loading, error };
|
||||
};
|
||||
|
||||
const MarketCell = ({ id }: { id: string }) => {
|
||||
const { data } = useMarketNameQuery({
|
||||
variables: {
|
||||
marketId: id,
|
||||
},
|
||||
// We should cache all static market data higher up the render tree so this
|
||||
// can be cache only
|
||||
// fetchPolicy: 'cache-only',
|
||||
});
|
||||
if (!data?.market) return <span>-</span>;
|
||||
return <span>{data.market.tradableInstrument.instrument.code}</span>;
|
||||
};
|
||||
|
||||
const PNLCell = ({ marketId, value }: { marketId: string; value: string }) => {
|
||||
const { data } = useMarketDecimalsQuery({
|
||||
variables: {
|
||||
marketId,
|
||||
},
|
||||
// We should cache all static market data higher up the render tree so this
|
||||
// can be cache only
|
||||
// fetchPolicy: 'cache-only'
|
||||
});
|
||||
if (!data?.market) return <span>-</span>;
|
||||
return (
|
||||
<span>{addDecimalsFormatNumber(value, data.market.decimalPlaces)}</span>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user