chore: stagnet3 api updates (#1321)
* chore: update account, fills and orders subscriptions in data providers * chore: update account, fills and orders subscriptions in data providers * fixing console-lite * fixing types in general - regen * chore: update account, fills and orders subscriptions in data providers * fixed console-lite unit tests, uncommented quote name * chore: update account, fills and orders subscriptions in data providers * type aligning of assets and proposals * fixes liquidity data provider * fixed accounts build errors and unit tests * regen types, removed market name * regen types * fixed positions * chore: handle updates in derived market provider, update orders * removed taker fee mapping (renamed to maker fee) * chore: update account, fills and orders subscriptions in data providers * chore: update account, fills and orders subscriptions in data providers * chore: fix Order type * chore: fix possible null types * chore: revert order-list.stories.tsx * chore: derivedDataProvider fixes * fills unit tests fixes * orders unit tests fixes * added eslint ingore for generated files in liquidity * added unique key to the list element of simple market toolbar * changed main-branch-name to develop for pr workflows * removed redundant waitFor * increased test timeout to 10s * removed mocked response * chore: disable simple market list tests * chore: fix e2e projects mock types * feat: [subscription-update] - uncomment some console-lite tests * cypress: trading-accounts * chore: replace market candles with candlesConnection * chore: ignore gql errors, to be reverted after candlesConnectio n will be fixed * feat: [subscription-update] - improve wrongly renamed hook * feat: [subscription-update] - improve wrongly renamed hook * feat: [subscription-update] - improve wrongly renamed hook 3 * chore: add pagination hangdling to derived data provier * cypress: trading-fills * feat: [stagnet3 api update] - remove redundant command in tests * feat: [stagnet3 api update] - remove redundant command in tests * chore: fix trading orders e2e tests * chore: fix console lite e2e mocks * chore: fix market-trade tests * chore: use markets only in market selector, change Instrument cache policy * chore: fix market-selector tests * feat: [subscription-update] - improve ag grid conf for unit tests * feat: [subscription-update] - improve ag grid conf for unit tests * chore: fix candle types in console lite market mocks * chore: revert error policy ignore * chore: revert jest timeout * chore: remove unused AccountFields * chore: revert remove unused AccountFields * chore: simplify node subscription probe * chore: remove unused generated types in candles-chart * chore: improve useMarketsList mock * feat: [subscription-update] - increase jest timeout * feat: [subscription-update] - fix jest timeout * feat: [subscription-update] - fix jest timeout * feat: [subscription-update] - try to fix failing test again * chore: fix candles-chart types * feat: [subscription-update] - temporary skip failing test * feat: [subscription-update] - temporary skip failing test * feat: [subscription-update] - temporary skip failing test * feat: [subscription-update] - fix failling int test * feat: [subscription-update] - try to restore commented unit tests * feat: [subscription-update] - try to restore commented unit tests * feat: [subscription-update] - improve fixed unit tests Co-authored-by: asiaznik <artur@vegaprotocol.io> Co-authored-by: maciek <maciek@vegaprotocol.io>
This commit is contained in:
parent
df3b79478e
commit
3bf5d823ee
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -55,7 +55,7 @@ jobs:
|
||||
- name: Derive appropriate SHAs for base and head for `nx affected` commands
|
||||
uses: nrwl/nx-set-shas@v2
|
||||
with:
|
||||
main-branch-name: master
|
||||
main-branch-name: develop
|
||||
- name: Use Node.js 16
|
||||
id: Node
|
||||
uses: actions/setup-node@v3
|
||||
|
@ -1,14 +1,19 @@
|
||||
import { aliasQuery } from '@vegaprotocol/cypress';
|
||||
import type { Markets } from '@vegaprotocol/market-list';
|
||||
import {
|
||||
generateLongListMarkets,
|
||||
generateSimpleMarkets,
|
||||
generateMarketsData,
|
||||
generateMarketsCandles,
|
||||
} from '../support/mocks/generate-markets';
|
||||
|
||||
describe('market list', () => {
|
||||
describe('simple url', () => {
|
||||
beforeEach(() => {
|
||||
cy.mockGQL((req) => {
|
||||
aliasQuery(req, 'SimpleMarkets', generateSimpleMarkets());
|
||||
aliasQuery(req, 'Markets', generateSimpleMarkets());
|
||||
aliasQuery(req, 'MarketsDataQuery', generateMarketsData());
|
||||
aliasQuery(req, 'MarketsCandlesQuery', generateMarketsCandles());
|
||||
});
|
||||
cy.visit('/markets');
|
||||
});
|
||||
@ -62,7 +67,9 @@ describe('market list', () => {
|
||||
describe('url params should select filters', () => {
|
||||
beforeEach(() => {
|
||||
cy.mockGQL((req) => {
|
||||
aliasQuery(req, 'SimpleMarkets', generateSimpleMarkets());
|
||||
aliasQuery(req, 'Markets', generateSimpleMarkets());
|
||||
aliasQuery(req, 'MarketsDataQuery', generateMarketsData());
|
||||
aliasQuery(req, 'MarketsCandlesQuery', generateMarketsCandles());
|
||||
});
|
||||
});
|
||||
|
||||
@ -73,10 +80,11 @@ describe('market list', () => {
|
||||
|
||||
it('last asset (if exists)', () => {
|
||||
cy.visit('/markets');
|
||||
cy.wait('@SimpleMarkets').then((filters) => {
|
||||
if (filters?.response?.body?.data?.markets?.length) {
|
||||
cy.wait('@Markets').then((filters) => {
|
||||
const data: Markets | undefined = filters?.response?.body?.data;
|
||||
if (data.marketsConnection.edges.length) {
|
||||
const asset =
|
||||
filters.response.body.data.markets[0].tradableInstrument.instrument
|
||||
data.marketsConnection.edges[0].node.tradableInstrument.instrument
|
||||
.product.settlementAsset.symbol;
|
||||
cy.visit(`/markets/Suspended/Future/${asset}`);
|
||||
cy.getByTestId('market-assets-menu')
|
||||
@ -98,7 +106,9 @@ describe('market list', () => {
|
||||
it('handles 1000 markets', () => {
|
||||
cy.viewport(1440, 900);
|
||||
cy.mockGQL((req) => {
|
||||
aliasQuery(req, 'SimpleMarkets', generateLongListMarkets(1000));
|
||||
aliasQuery(req, 'Markets', generateLongListMarkets(1000));
|
||||
aliasQuery(req, 'MarketsDataQuery', generateMarketsData());
|
||||
aliasQuery(req, 'MarketsCandlesQuery', generateMarketsCandles());
|
||||
});
|
||||
performance.mark('start-1k');
|
||||
cy.visit('/markets');
|
||||
|
@ -1,6 +1,10 @@
|
||||
import { connectVegaWallet } from '../support/connect-wallet';
|
||||
import { aliasQuery } from '@vegaprotocol/cypress';
|
||||
import { generateSimpleMarkets } from '../support/mocks/generate-markets';
|
||||
import {
|
||||
generateMarketsCandles,
|
||||
generateMarketsData,
|
||||
generateSimpleMarkets,
|
||||
} from '../support/mocks/generate-markets';
|
||||
import { generateDealTicket } from '../support/mocks/generate-deal-ticket';
|
||||
import { generateMarketTags } from '../support/mocks/generate-market-tags';
|
||||
import { generateMarketPositions } from '../support/mocks/generate-market-positions';
|
||||
@ -10,12 +14,15 @@ import { generatePartyMarketData } from '../support/mocks/generate-party-market-
|
||||
import { generateMarketMarkPrice } from '../support/mocks/generate-market-mark-price';
|
||||
import { generateMarketNames } from '../support/mocks/generate-market-names';
|
||||
import { generateMarketDepth } from '../support/mocks/generate-market-depth';
|
||||
import type { Market, Markets } from '@vegaprotocol/market-list';
|
||||
|
||||
describe('market selector', () => {
|
||||
let markets;
|
||||
let markets: Market[];
|
||||
beforeEach(() => {
|
||||
cy.mockGQL((req) => {
|
||||
aliasQuery(req, 'SimpleMarkets', generateSimpleMarkets());
|
||||
aliasQuery(req, 'Markets', generateSimpleMarkets());
|
||||
aliasQuery(req, 'MarketsCandlesQuery', generateMarketsCandles());
|
||||
aliasQuery(req, 'MarketsDataQuery', generateMarketsData());
|
||||
aliasQuery(req, 'DealTicketQuery', generateDealTicket());
|
||||
aliasQuery(req, 'MarketTags', generateMarketTags());
|
||||
aliasQuery(req, 'MarketPositions', generateMarketPositions());
|
||||
@ -28,9 +35,10 @@ describe('market selector', () => {
|
||||
});
|
||||
|
||||
cy.visit('/markets');
|
||||
cy.wait('@SimpleMarkets').then((response) => {
|
||||
if (response.response.body.data?.markets?.length) {
|
||||
markets = response.response.body.data.markets;
|
||||
cy.wait('@Markets').then((response) => {
|
||||
const data: Markets | undefined = response?.response?.body?.data;
|
||||
if (data.marketsConnection.edges.length) {
|
||||
markets = data.marketsConnection.edges.map((edge) => edge.node);
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -128,7 +136,7 @@ describe('market selector', () => {
|
||||
cy.getByTestId('market-pane')
|
||||
.children()
|
||||
.find('[role="button"]')
|
||||
.should('have.length', 3);
|
||||
.should('have.length', 9);
|
||||
cy.get('div[role="dialog"]').should('have.class', 'w-screen');
|
||||
cy.getByTestId('dialog-close').click();
|
||||
cy.get('input[placeholder="Search"]').should(
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { aliasQuery } from '@vegaprotocol/cypress';
|
||||
import {
|
||||
generateSimpleMarkets,
|
||||
generateMarkets,
|
||||
generateMarketsCandles,
|
||||
generateMarketsData,
|
||||
} from '../support/mocks/generate-markets';
|
||||
import { generateDealTicket } from '../support/mocks/generate-deal-ticket';
|
||||
import { generateMarketTags } from '../support/mocks/generate-market-tags';
|
||||
@ -12,12 +13,15 @@ import { generatePartyMarketData } from '../support/mocks/generate-party-market-
|
||||
import { generateMarketMarkPrice } from '../support/mocks/generate-market-mark-price';
|
||||
import { generateMarketDepth } from '../support/mocks/generate-market-depth';
|
||||
import { connectVegaWallet } from '../support/connect-wallet';
|
||||
import type { Markets, Market } from '@vegaprotocol/market-list';
|
||||
|
||||
describe('Market trade', () => {
|
||||
let markets;
|
||||
let markets: Market[];
|
||||
beforeEach(() => {
|
||||
cy.mockGQL((req) => {
|
||||
aliasQuery(req, 'Markets', generateMarkets());
|
||||
aliasQuery(req, 'Markets', generateSimpleMarkets());
|
||||
aliasQuery(req, 'MarketsCandlesQuery', generateMarketsCandles());
|
||||
aliasQuery(req, 'MarketsDataQuery', generateMarketsData());
|
||||
aliasQuery(req, 'SimpleMarkets', generateSimpleMarkets());
|
||||
aliasQuery(req, 'DealTicketQuery', generateDealTicket());
|
||||
aliasQuery(req, 'MarketTags', generateMarketTags());
|
||||
@ -29,9 +33,10 @@ describe('Market trade', () => {
|
||||
aliasQuery(req, 'MarketDepth', generateMarketDepth());
|
||||
});
|
||||
cy.visit('/markets');
|
||||
cy.wait('@SimpleMarkets').then((response) => {
|
||||
if (response.response.body.data?.markets?.length) {
|
||||
markets = response.response.body.data.markets;
|
||||
cy.wait('@Markets').then((response) => {
|
||||
const data: Markets | undefined = response?.response?.body?.data;
|
||||
if (data.marketsConnection.edges.length) {
|
||||
markets = data.marketsConnection.edges.map((edge) => edge.node);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,7 @@
|
||||
const protoCandles = [
|
||||
import type { Market } from '@vegaprotocol/market-list';
|
||||
import { MarketState, MarketTradingMode } from '@vegaprotocol/types';
|
||||
|
||||
export const protoCandles = [
|
||||
{ open: '9556163', close: '9587028', __typename: 'Candle' },
|
||||
{
|
||||
open: '9587028',
|
||||
@ -73,11 +76,29 @@ const protoCandles = [
|
||||
},
|
||||
];
|
||||
|
||||
export const protoMarket = {
|
||||
export const protoMarket: Market = {
|
||||
id: 'first-btcusd-id',
|
||||
state: 'STATE_ACTIVE',
|
||||
tradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS,
|
||||
state: MarketState.STATE_ACTIVE,
|
||||
decimalPlaces: 5,
|
||||
positionDecimalPlaces: 0,
|
||||
marketTimestamps: {
|
||||
__typename: 'MarketTimestamps',
|
||||
close: '',
|
||||
open: '',
|
||||
},
|
||||
fees: {
|
||||
__typename: 'Fees',
|
||||
factors: {
|
||||
__typename: 'FeeFactors',
|
||||
makerFee: '',
|
||||
infrastructureFee: '',
|
||||
liquidityFee: '',
|
||||
},
|
||||
},
|
||||
tradableInstrument: {
|
||||
instrument: {
|
||||
id: '',
|
||||
code: 'AAVEDAI.MF21',
|
||||
name: 'AAVEDAI Monthly (30 Jun 2022)',
|
||||
metadata: {
|
||||
@ -94,12 +115,11 @@ export const protoMarket = {
|
||||
product: {
|
||||
__typename: 'Future',
|
||||
quoteName: 'DAI',
|
||||
settlementAsset: { symbol: 'tDAI', __typename: 'Asset' },
|
||||
settlementAsset: { symbol: 'tDAI', __typename: 'Asset', decimals: 5 },
|
||||
},
|
||||
__typename: 'Instrument',
|
||||
},
|
||||
__typename: 'TradableInstrument',
|
||||
},
|
||||
candles: protoCandles,
|
||||
__typename: 'Market',
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,5 @@
|
||||
import '@testing-library/jest-dom';
|
||||
import 'jest-canvas-mock';
|
||||
import { defaultFallbackInView } from 'react-intersection-observer';
|
||||
import ResizeObserver from 'resize-observer-polyfill';
|
||||
|
||||
@ -38,3 +39,5 @@ Object.defineProperty(window, 'matchMedia', {
|
||||
dispatchEvent: jest.fn(),
|
||||
})),
|
||||
});
|
||||
|
||||
jest.setTimeout(30000);
|
||||
|
@ -53,6 +53,9 @@ export interface Deposits_assetsConnection_edges_node {
|
||||
|
||||
export interface Deposits_assetsConnection_edges {
|
||||
__typename: "AssetEdge";
|
||||
/**
|
||||
* The asset information
|
||||
*/
|
||||
node: Deposits_assetsConnection_edges_node;
|
||||
}
|
||||
|
||||
@ -68,5 +71,5 @@ export interface Deposits {
|
||||
/**
|
||||
* The list of all assets in use in the Vega network or the specified asset if ID is provided
|
||||
*/
|
||||
assetsConnection: Deposits_assetsConnection;
|
||||
assetsConnection: Deposits_assetsConnection | null;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ const defaultOptions = {} as const;
|
||||
export type DepositsQueryVariables = Types.Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
export type DepositsQuery = { __typename?: 'Query', assetsConnection: { __typename?: 'AssetsConnection', edges?: Array<{ __typename?: 'AssetEdge', node: { __typename?: 'Asset', id: string, name: string, symbol: string, decimals: number, source: { __typename?: 'BuiltinAsset' } | { __typename?: 'ERC20', contractAddress: string } } } | null> | null } };
|
||||
export type DepositsQuery = { __typename?: 'Query', assetsConnection?: { __typename?: 'AssetsConnection', edges?: Array<{ __typename?: 'AssetEdge', node: { __typename?: 'Asset', id: string, name: string, symbol: string, decimals: number, source: { __typename?: 'BuiltinAsset' } | { __typename?: 'ERC20', contractAddress: string } } } | null> | null } | null };
|
||||
|
||||
|
||||
export const DepositsDocument = gql`
|
||||
|
@ -1,5 +0,0 @@
|
||||
subscription CandleLive($marketId: ID!) {
|
||||
candles(marketId: $marketId, interval: INTERVAL_I1H) {
|
||||
close
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
fragment SimpleMarketDataFields on MarketData {
|
||||
market {
|
||||
id
|
||||
state
|
||||
}
|
||||
}
|
||||
|
||||
query SimpleMarkets($CandleSince: String!) {
|
||||
markets {
|
||||
id
|
||||
name
|
||||
state
|
||||
data {
|
||||
...SimpleMarketDataFields
|
||||
}
|
||||
tradableInstrument {
|
||||
instrument {
|
||||
code
|
||||
metadata {
|
||||
tags
|
||||
}
|
||||
product {
|
||||
__typename
|
||||
... on Future {
|
||||
quoteName
|
||||
settlementAsset {
|
||||
symbol
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
candles(interval: INTERVAL_I1H, since: $CandleSince) {
|
||||
open
|
||||
close
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
subscription SimpleMarketDataSub {
|
||||
marketData {
|
||||
...SimpleMarketDataFields
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
import { MarketState } from "@vegaprotocol/types";
|
||||
|
||||
// ====================================================
|
||||
// GraphQL fragment: SimpleMarketDataFields
|
||||
// ====================================================
|
||||
|
||||
export interface SimpleMarketDataFields_market {
|
||||
__typename: "Market";
|
||||
/**
|
||||
* Market ID
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* Current state of the market
|
||||
*/
|
||||
state: MarketState;
|
||||
}
|
||||
|
||||
export interface SimpleMarketDataFields {
|
||||
__typename: "MarketData";
|
||||
/**
|
||||
* market ID of the associated mark price
|
||||
*/
|
||||
market: SimpleMarketDataFields_market;
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
import { MarketState } from "@vegaprotocol/types";
|
||||
|
||||
// ====================================================
|
||||
// GraphQL subscription operation: SimpleMarketDataSub
|
||||
// ====================================================
|
||||
|
||||
export interface SimpleMarketDataSub_marketData_market {
|
||||
__typename: "Market";
|
||||
/**
|
||||
* Market ID
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* Current state of the market
|
||||
*/
|
||||
state: MarketState;
|
||||
}
|
||||
|
||||
export interface SimpleMarketDataSub_marketData {
|
||||
__typename: "MarketData";
|
||||
/**
|
||||
* market ID of the associated mark price
|
||||
*/
|
||||
market: SimpleMarketDataSub_marketData_market;
|
||||
}
|
||||
|
||||
export interface SimpleMarketDataSub {
|
||||
/**
|
||||
* Subscribe to the mark price changes
|
||||
*/
|
||||
marketData: SimpleMarketDataSub_marketData;
|
||||
}
|
@ -1,109 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
import { MarketState } from "@vegaprotocol/types";
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: SimpleMarkets
|
||||
// ====================================================
|
||||
|
||||
export interface SimpleMarkets_markets_tradableInstrument_instrument_metadata {
|
||||
__typename: "InstrumentMetadata";
|
||||
/**
|
||||
* An arbitrary list of tags to associated to associate to the Instrument (string list)
|
||||
*/
|
||||
tags: string[] | null;
|
||||
}
|
||||
|
||||
export interface SimpleMarkets_markets_tradableInstrument_instrument_product_settlementAsset {
|
||||
__typename: "Asset";
|
||||
/**
|
||||
* The symbol of the asset (e.g: GBP)
|
||||
*/
|
||||
symbol: string;
|
||||
}
|
||||
|
||||
export interface SimpleMarkets_markets_tradableInstrument_instrument_product {
|
||||
__typename: "Future";
|
||||
/**
|
||||
* String representing the quote (e.g. BTCUSD -> USD is quote)
|
||||
*/
|
||||
quoteName: string;
|
||||
/**
|
||||
* The name of the asset (string)
|
||||
*/
|
||||
settlementAsset: SimpleMarkets_markets_tradableInstrument_instrument_product_settlementAsset;
|
||||
}
|
||||
|
||||
export interface SimpleMarkets_markets_tradableInstrument_instrument {
|
||||
__typename: "Instrument";
|
||||
/**
|
||||
* A short non necessarily unique code used to easily describe the instrument (e.g: FX:BTCUSD/DEC18) (string)
|
||||
*/
|
||||
code: string;
|
||||
/**
|
||||
* Full and fairly descriptive name for the instrument
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* Metadata for this instrument
|
||||
*/
|
||||
metadata: SimpleMarkets_markets_tradableInstrument_instrument_metadata;
|
||||
/**
|
||||
* A reference to or instance of a fully specified product, including all required product parameters for that product (Product union)
|
||||
*/
|
||||
product: SimpleMarkets_markets_tradableInstrument_instrument_product;
|
||||
}
|
||||
|
||||
export interface SimpleMarkets_markets_tradableInstrument {
|
||||
__typename: "TradableInstrument";
|
||||
/**
|
||||
* An instance of, or reference to, a fully specified instrument.
|
||||
*/
|
||||
instrument: SimpleMarkets_markets_tradableInstrument_instrument;
|
||||
}
|
||||
|
||||
export interface SimpleMarkets_markets_candles {
|
||||
__typename: "Candle";
|
||||
/**
|
||||
* Open price (uint64)
|
||||
*/
|
||||
open: string;
|
||||
/**
|
||||
* Close price (uint64)
|
||||
*/
|
||||
close: string;
|
||||
}
|
||||
|
||||
export interface SimpleMarkets_markets {
|
||||
__typename: "Market";
|
||||
/**
|
||||
* Market ID
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* Current state of the market
|
||||
*/
|
||||
state: MarketState;
|
||||
/**
|
||||
* An instance of, or reference to, a tradable instrument.
|
||||
*/
|
||||
tradableInstrument: SimpleMarkets_markets_tradableInstrument;
|
||||
/**
|
||||
* Candles on a market, for the 'last' n candles, at 'interval' seconds as specified by parameters
|
||||
*/
|
||||
candles: (SimpleMarkets_markets_candles | null)[] | null;
|
||||
}
|
||||
|
||||
export interface SimpleMarkets {
|
||||
/**
|
||||
* One or more instruments that are trading on the VEGA network
|
||||
*/
|
||||
markets: SimpleMarkets_markets[] | null;
|
||||
}
|
||||
|
||||
export interface SimpleMarketsVariables {
|
||||
CandleSince: string;
|
||||
}
|
@ -1,117 +0,0 @@
|
||||
import { Schema as Types } from '@vegaprotocol/types';
|
||||
|
||||
import { gql } from '@apollo/client';
|
||||
import * as Apollo from '@apollo/client';
|
||||
const defaultOptions = {} as const;
|
||||
export type SimpleMarketDataFieldsFragment = { __typename?: 'MarketData', market: { __typename?: 'Market', id: string, state: Types.MarketState } };
|
||||
|
||||
export type SimpleMarketsQueryVariables = Types.Exact<{
|
||||
CandleSince: Types.Scalars['String'];
|
||||
}>;
|
||||
|
||||
|
||||
export type SimpleMarketsQuery = { __typename?: 'Query', markets?: Array<{ __typename?: 'Market', id: string, name: string, state: Types.MarketState, data?: { __typename?: 'MarketData', market: { __typename?: 'Market', id: string, state: Types.MarketState } } | null, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null }, product: { __typename: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', symbol: string } } } }, candles?: Array<{ __typename?: 'Candle', open: string, close: string } | null> | null }> | null };
|
||||
|
||||
export type SimpleMarketDataSubSubscriptionVariables = Types.Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
export type SimpleMarketDataSubSubscription = { __typename?: 'Subscription', marketData: { __typename?: 'MarketData', market: { __typename?: 'Market', id: string, state: Types.MarketState } } };
|
||||
|
||||
export const SimpleMarketDataFieldsFragmentDoc = gql`
|
||||
fragment SimpleMarketDataFields on MarketData {
|
||||
market {
|
||||
id
|
||||
state
|
||||
}
|
||||
}
|
||||
`;
|
||||
export const SimpleMarketsDocument = gql`
|
||||
query SimpleMarkets($CandleSince: String!) {
|
||||
markets {
|
||||
id
|
||||
name
|
||||
state
|
||||
data {
|
||||
...SimpleMarketDataFields
|
||||
}
|
||||
tradableInstrument {
|
||||
instrument {
|
||||
code
|
||||
metadata {
|
||||
tags
|
||||
}
|
||||
product {
|
||||
__typename
|
||||
... on Future {
|
||||
quoteName
|
||||
settlementAsset {
|
||||
symbol
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
candles(interval: INTERVAL_I1H, since: $CandleSince) {
|
||||
open
|
||||
close
|
||||
}
|
||||
}
|
||||
}
|
||||
${SimpleMarketDataFieldsFragmentDoc}`;
|
||||
|
||||
/**
|
||||
* __useSimpleMarketsQuery__
|
||||
*
|
||||
* To run a query within a React component, call `useSimpleMarketsQuery` and pass it any options that fit your needs.
|
||||
* When your component renders, `useSimpleMarketsQuery` 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 } = useSimpleMarketsQuery({
|
||||
* variables: {
|
||||
* CandleSince: // value for 'CandleSince'
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useSimpleMarketsQuery(baseOptions: Apollo.QueryHookOptions<SimpleMarketsQuery, SimpleMarketsQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useQuery<SimpleMarketsQuery, SimpleMarketsQueryVariables>(SimpleMarketsDocument, options);
|
||||
}
|
||||
export function useSimpleMarketsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<SimpleMarketsQuery, SimpleMarketsQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useLazyQuery<SimpleMarketsQuery, SimpleMarketsQueryVariables>(SimpleMarketsDocument, options);
|
||||
}
|
||||
export type SimpleMarketsQueryHookResult = ReturnType<typeof useSimpleMarketsQuery>;
|
||||
export type SimpleMarketsLazyQueryHookResult = ReturnType<typeof useSimpleMarketsLazyQuery>;
|
||||
export type SimpleMarketsQueryResult = Apollo.QueryResult<SimpleMarketsQuery, SimpleMarketsQueryVariables>;
|
||||
export const SimpleMarketDataSubDocument = gql`
|
||||
subscription SimpleMarketDataSub {
|
||||
marketData {
|
||||
...SimpleMarketDataFields
|
||||
}
|
||||
}
|
||||
${SimpleMarketDataFieldsFragmentDoc}`;
|
||||
|
||||
/**
|
||||
* __useSimpleMarketDataSubSubscription__
|
||||
*
|
||||
* To run a query within a React component, call `useSimpleMarketDataSubSubscription` and pass it any options that fit your needs.
|
||||
* When your component renders, `useSimpleMarketDataSubSubscription` 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 } = useSimpleMarketDataSubSubscription({
|
||||
* variables: {
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useSimpleMarketDataSubSubscription(baseOptions?: Apollo.SubscriptionHookOptions<SimpleMarketDataSubSubscription, SimpleMarketDataSubSubscriptionVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useSubscription<SimpleMarketDataSubSubscription, SimpleMarketDataSubSubscriptionVariables>(SimpleMarketDataSubDocument, options);
|
||||
}
|
||||
export type SimpleMarketDataSubSubscriptionHookResult = ReturnType<typeof useSimpleMarketDataSubSubscription>;
|
||||
export type SimpleMarketDataSubSubscriptionResult = Apollo.SubscriptionResult<SimpleMarketDataSubSubscription>;
|
@ -2,8 +2,8 @@ import { t } from '@vegaprotocol/react-helpers';
|
||||
import { themelite as theme } from '@vegaprotocol/tailwindcss-config';
|
||||
import { MarketState } from '@vegaprotocol/types';
|
||||
import { IS_MARKET_TRADABLE } from '../../constants';
|
||||
import type { SimpleMarkets_markets } from './__generated__/SimpleMarkets';
|
||||
import colors from 'tailwindcss/colors';
|
||||
import type { Market } from '@vegaprotocol/market-list';
|
||||
|
||||
export const STATES_FILTER = [
|
||||
{ value: 'all', text: t('All') },
|
||||
@ -192,8 +192,10 @@ export const agGridDarkVariables = `
|
||||
`;
|
||||
|
||||
export const ROW_CLASS_RULES = {
|
||||
'cursor-pointer': ({ data }: { data: SimpleMarkets_markets }) =>
|
||||
'cursor-pointer': ({ data }: { data: Market }) =>
|
||||
IS_MARKET_TRADABLE(data || {}),
|
||||
};
|
||||
|
||||
export const LARGE_SCREENS = ['xl', 'xxl'];
|
||||
|
||||
export const AG_GRID_CONTAINER_STYLES = { width: '100%', height: '100%' };
|
||||
|
@ -1,94 +0,0 @@
|
||||
import produce from 'immer';
|
||||
import { gql } from '@apollo/client';
|
||||
import { makeDataProvider } from '@vegaprotocol/react-helpers';
|
||||
import type {
|
||||
SimpleMarkets,
|
||||
SimpleMarkets_markets,
|
||||
} from './__generated__/SimpleMarkets';
|
||||
import type {
|
||||
SimpleMarketDataSub,
|
||||
SimpleMarketDataSub_marketData,
|
||||
} from './__generated__/SimpleMarketDataSub';
|
||||
|
||||
export const MARKETS_QUERY = gql`
|
||||
query SimpleMarkets($CandleSince: String!) {
|
||||
markets {
|
||||
id
|
||||
state
|
||||
tradableInstrument {
|
||||
instrument {
|
||||
code
|
||||
name
|
||||
metadata {
|
||||
tags
|
||||
}
|
||||
product {
|
||||
__typename
|
||||
... on Future {
|
||||
quoteName
|
||||
settlementAsset {
|
||||
symbol
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
candles(interval: INTERVAL_I1H, since: $CandleSince) {
|
||||
open
|
||||
close
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const MARKET_DATA_SUB = gql`
|
||||
subscription SimpleMarketDataSub {
|
||||
marketData {
|
||||
market {
|
||||
id
|
||||
state
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const CANDLE_SUB = gql`
|
||||
subscription CandleLive($marketId: ID!) {
|
||||
candles(marketId: $marketId, interval: INTERVAL_I1H) {
|
||||
close
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const update = (
|
||||
data: SimpleMarkets_markets[],
|
||||
delta: SimpleMarketDataSub_marketData
|
||||
) => {
|
||||
return produce(data, (draft) => {
|
||||
const index = draft.findIndex((m) => m.id === delta.market.id);
|
||||
if (index !== -1) {
|
||||
draft[index].state = delta.market.state;
|
||||
}
|
||||
// @TODO - else push new market to draft
|
||||
});
|
||||
};
|
||||
|
||||
const getData = (responseData: SimpleMarkets) => responseData.markets;
|
||||
const getDelta = (
|
||||
subscriptionData: SimpleMarketDataSub
|
||||
): SimpleMarketDataSub_marketData => subscriptionData.marketData;
|
||||
|
||||
export const dataProvider = makeDataProvider<
|
||||
SimpleMarkets,
|
||||
SimpleMarkets_markets[],
|
||||
SimpleMarketDataSub,
|
||||
SimpleMarketDataSub_marketData
|
||||
>({
|
||||
query: MARKETS_QUERY,
|
||||
subscriptionQuery: MARKET_DATA_SUB,
|
||||
update,
|
||||
getData,
|
||||
getDelta,
|
||||
});
|
||||
|
||||
export default dataProvider;
|
@ -4,21 +4,14 @@ import {
|
||||
render,
|
||||
screen,
|
||||
waitFor,
|
||||
cleanup,
|
||||
getAllByRole,
|
||||
fireEvent,
|
||||
} from '@testing-library/react';
|
||||
import { MockedProvider } from '@apollo/client/testing';
|
||||
import type { MockedResponse } from '@apollo/client/testing';
|
||||
import { BrowserRouter } from 'react-router-dom';
|
||||
import { MarketState } from '@vegaprotocol/types';
|
||||
import type { Market } from '@vegaprotocol/market-list';
|
||||
import SimpleMarketList from './simple-market-list';
|
||||
import { MARKETS_QUERY } from './data-provider';
|
||||
import type {
|
||||
SimpleMarkets_markets,
|
||||
SimpleMarkets,
|
||||
} from './__generated__/SimpleMarkets';
|
||||
import type { SimpleMarketDataSub_marketData } from './__generated__/SimpleMarketDataSub';
|
||||
|
||||
const mockedNavigate = jest.fn();
|
||||
|
||||
@ -28,20 +21,11 @@ jest.mock('react-router-dom', () => ({
|
||||
useParams: () => ({}),
|
||||
}));
|
||||
|
||||
jest.mock('date-fns', () => ({
|
||||
subDays: () => new Date('2022-06-02T11:11:21.721Z'),
|
||||
}));
|
||||
jest.mock('./simple-market-percent-change', () => jest.fn());
|
||||
|
||||
let updateMock: ({
|
||||
delta,
|
||||
}: {
|
||||
delta: SimpleMarketDataSub_marketData;
|
||||
}) => boolean;
|
||||
|
||||
let mockData = [
|
||||
let marketsMock = [
|
||||
{
|
||||
id: '1',
|
||||
name: 'Market 1',
|
||||
id: 'MARKET_A',
|
||||
state: MarketState.STATE_ACTIVE,
|
||||
tradableInstrument: {
|
||||
instrument: {
|
||||
@ -57,8 +41,7 @@ let mockData = [
|
||||
},
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
name: 'Market 2',
|
||||
id: 'MARKET_B',
|
||||
state: MarketState.STATE_ACTIVE,
|
||||
tradableInstrument: {
|
||||
instrument: {
|
||||
@ -73,20 +56,26 @@ let mockData = [
|
||||
},
|
||||
},
|
||||
},
|
||||
] as unknown as SimpleMarkets_markets[];
|
||||
] as unknown as Market[];
|
||||
|
||||
const mockUseDataProvider = ({ update }: { update: () => boolean }) => {
|
||||
updateMock = update;
|
||||
return { data: mockData, loading: false, error: false };
|
||||
const LIB = '@vegaprotocol/market-list';
|
||||
const useMarketList = () => {
|
||||
return {
|
||||
data: {
|
||||
markets: marketsMock,
|
||||
marketsData: [],
|
||||
marketsCandles: [],
|
||||
},
|
||||
loading: false,
|
||||
error: false,
|
||||
};
|
||||
|
||||
jest.mock('@vegaprotocol/react-helpers', () => ({
|
||||
...jest.requireActual('@vegaprotocol/react-helpers'),
|
||||
useDataProvider: jest.fn((args) => mockUseDataProvider(args)),
|
||||
};
|
||||
jest.mock(LIB, () => ({
|
||||
...jest.requireActual(LIB),
|
||||
useMarketList: jest.fn(() => useMarketList()),
|
||||
}));
|
||||
|
||||
const mockIsTradable = jest.fn((_arg) => true);
|
||||
|
||||
jest.mock('../../constants', () => ({
|
||||
...jest.requireActual('../../constants'),
|
||||
IS_MARKET_TRADABLE: jest.fn((arg) => mockIsTradable(arg)),
|
||||
@ -95,25 +84,12 @@ jest.mock('../../constants', () => ({
|
||||
describe('SimpleMarketList', () => {
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
cleanup();
|
||||
});
|
||||
|
||||
const mocks: MockedResponse<SimpleMarkets> = {
|
||||
request: {
|
||||
query: MARKETS_QUERY,
|
||||
variables: {
|
||||
CandleSince: '2022-06-02T11:11:21.721Z',
|
||||
},
|
||||
},
|
||||
result: {
|
||||
data: { markets: mockData },
|
||||
},
|
||||
};
|
||||
|
||||
it('should be properly rendered with some data', async () => {
|
||||
await act(async () => {
|
||||
render(
|
||||
<MockedProvider mocks={[mocks]}>
|
||||
<MockedProvider mocks={[]}>
|
||||
<SimpleMarketList />
|
||||
</MockedProvider>,
|
||||
{ wrapper: BrowserRouter }
|
||||
@ -124,95 +100,49 @@ describe('SimpleMarketList', () => {
|
||||
expect(
|
||||
document.querySelector('.ag-center-cols-container')
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
await waitFor(() => {
|
||||
const container = document.querySelector('.ag-center-cols-container');
|
||||
expect(getAllByRole(container as HTMLDivElement, 'row')).toHaveLength(2);
|
||||
});
|
||||
});
|
||||
|
||||
it('update should return proper boolean value', async () => {
|
||||
await act(async () => {
|
||||
render(
|
||||
<MockedProvider mocks={[mocks]}>
|
||||
<SimpleMarketList />
|
||||
</MockedProvider>,
|
||||
{ wrapper: BrowserRouter }
|
||||
);
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
});
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
document.querySelector('.ag-center-cols-container')
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
await expect(
|
||||
updateMock({
|
||||
delta: {
|
||||
__typename: 'MarketData',
|
||||
market: {
|
||||
__typename: 'Market',
|
||||
id: '2',
|
||||
state: MarketState.STATE_ACTIVE,
|
||||
},
|
||||
},
|
||||
})
|
||||
).toEqual(true);
|
||||
|
||||
await expect(
|
||||
updateMock({
|
||||
delta: {
|
||||
__typename: 'MarketData',
|
||||
market: {
|
||||
__typename: 'Market',
|
||||
id: '2',
|
||||
state: MarketState.STATE_SUSPENDED,
|
||||
},
|
||||
},
|
||||
})
|
||||
).toEqual(false);
|
||||
});
|
||||
|
||||
it('click on row should be properly handled', async () => {
|
||||
await act(async () => {
|
||||
render(
|
||||
<MockedProvider mocks={[mocks]}>
|
||||
<MockedProvider mocks={[]}>
|
||||
<SimpleMarketList />
|
||||
</MockedProvider>,
|
||||
{ wrapper: BrowserRouter }
|
||||
);
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
});
|
||||
await waitFor(() => {
|
||||
expect(
|
||||
document.querySelector('.ag-center-cols-container')
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
mockIsTradable.mockClear();
|
||||
const container = document.querySelector('.ag-center-cols-container');
|
||||
const firstRow = getAllByRole(container as HTMLDivElement, 'row')[0];
|
||||
expect(firstRow).toHaveAttribute('row-id', '1');
|
||||
expect(firstRow).toHaveAttribute('row-id', marketsMock[0].id);
|
||||
await act(async () => {
|
||||
fireEvent.click(firstRow);
|
||||
await waitFor(() => {
|
||||
expect(mockIsTradable).toHaveBeenCalledWith({
|
||||
...mockData[0],
|
||||
percentChange: '-',
|
||||
});
|
||||
expect(mockedNavigate).toHaveBeenCalledWith(`/trading/${mockData[0].id}`);
|
||||
await waitFor(() => {
|
||||
expect(mockIsTradable).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
id: marketsMock[0].id,
|
||||
state: MarketState.STATE_ACTIVE,
|
||||
})
|
||||
);
|
||||
expect(mockedNavigate).toHaveBeenCalledWith(
|
||||
`/trading/${marketsMock[0].id}`
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('should be properly renderer as empty', async () => {
|
||||
mockData = [];
|
||||
marketsMock = [];
|
||||
await act(async () => {
|
||||
render(
|
||||
<MockedProvider mocks={[mocks]}>
|
||||
<MockedProvider mocks={[]}>
|
||||
<SimpleMarketList />
|
||||
</MockedProvider>,
|
||||
{ wrapper: BrowserRouter }
|
||||
);
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
});
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('No data to display')).toBeInTheDocument();
|
||||
|
@ -1,29 +1,16 @@
|
||||
import React, {
|
||||
useCallback,
|
||||
useContext,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
} from 'react';
|
||||
import { useCallback, useContext, useEffect, useMemo, useRef } from 'react';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { subDays } from 'date-fns';
|
||||
import type { AgGridReact } from 'ag-grid-react';
|
||||
import { AgGridDynamic as AgGrid } from '@vegaprotocol/ui-toolkit';
|
||||
import {
|
||||
useDataProvider,
|
||||
useScreenDimensions,
|
||||
} from '@vegaprotocol/react-helpers';
|
||||
import { useScreenDimensions } from '@vegaprotocol/react-helpers';
|
||||
import { t } from '@vegaprotocol/react-helpers';
|
||||
import { AsyncRenderer } from '@vegaprotocol/ui-toolkit';
|
||||
import { ThemeContext } from '@vegaprotocol/react-helpers';
|
||||
import type { MarketState } from '@vegaprotocol/types';
|
||||
import useMarketsFilterData from '../../hooks/use-markets-filter-data';
|
||||
import useColumnDefinitions from '../../hooks/use-column-definitions';
|
||||
import dataProvider from './data-provider';
|
||||
import useMarketsFilterData from './use-markets-filter-data';
|
||||
import useColumnDefinitions from './use-column-definitions';
|
||||
import * as constants from './constants';
|
||||
import SimpleMarketToolbar from './simple-market-toolbar';
|
||||
import type { SimpleMarkets_markets } from './__generated__/SimpleMarkets';
|
||||
import type { SimpleMarketDataSub_marketData } from './__generated__/SimpleMarketDataSub';
|
||||
import { IS_MARKET_TRADABLE } from '../../constants';
|
||||
import type {
|
||||
CellKeyDownEvent,
|
||||
@ -33,8 +20,10 @@ import type {
|
||||
GetRowIdParams,
|
||||
TabToNextCellParams,
|
||||
} from 'ag-grid-community/dist/lib/entities/iCallbackParams';
|
||||
import type { Market, MarketsListData } from '@vegaprotocol/market-list';
|
||||
import { useMarketList } from '@vegaprotocol/market-list';
|
||||
|
||||
export type SimpleMarketsType = SimpleMarkets_markets & {
|
||||
export type MarketWithPercentChange = Market & {
|
||||
percentChange?: number | '-';
|
||||
};
|
||||
|
||||
@ -51,27 +40,9 @@ const SimpleMarketList = () => {
|
||||
const theme = useContext(ThemeContext);
|
||||
const statusesRef = useRef<Record<string, MarketState | ''>>({});
|
||||
const gridRef = useRef<AgGridReact | null>(null);
|
||||
const variables = useMemo(
|
||||
() => ({
|
||||
CandleSince: subDays(Date.now(), 1).toJSON(),
|
||||
}),
|
||||
[]
|
||||
);
|
||||
const update = useCallback(
|
||||
({ delta }: { delta: SimpleMarketDataSub_marketData }) =>
|
||||
statusesRef.current[delta.market.id] === delta.market.state,
|
||||
[statusesRef]
|
||||
);
|
||||
|
||||
const { data, error, loading } = useDataProvider({
|
||||
dataProvider,
|
||||
update,
|
||||
variables,
|
||||
});
|
||||
const localData: Array<SimpleMarketsType> = useMarketsFilterData(
|
||||
data || [],
|
||||
params
|
||||
);
|
||||
const { data, error, loading } = useMarketList();
|
||||
const localData = useMarketsFilterData(data as MarketsListData, params);
|
||||
|
||||
const handleOnGridReady = useCallback(() => {
|
||||
gridRef.current?.api?.sizeColumnsToFit();
|
||||
@ -79,7 +50,7 @@ const SimpleMarketList = () => {
|
||||
|
||||
useEffect(() => {
|
||||
const statuses: Record<string, MarketState | ''> = {};
|
||||
data?.forEach((market) => {
|
||||
data?.markets?.forEach((market) => {
|
||||
statuses[market.id] = market.state || '';
|
||||
});
|
||||
statusesRef.current = statuses;
|
||||
@ -95,7 +66,7 @@ const SimpleMarketList = () => {
|
||||
const getRowId = useCallback(({ data }: GetRowIdParams) => data.id, []);
|
||||
|
||||
const handleRowClicked = useCallback(
|
||||
({ data }: { data: SimpleMarketsType }) => {
|
||||
({ data }: { data: Market }) => {
|
||||
if (IS_MARKET_TRADABLE(data)) {
|
||||
navigate(`/trading/${data.id}`);
|
||||
}
|
||||
@ -135,10 +106,11 @@ const SimpleMarketList = () => {
|
||||
|
||||
return (
|
||||
<div className="h-full p-4 md:p-6 grid grid-rows-[min-content,1fr]">
|
||||
<SimpleMarketToolbar data={data || []} />
|
||||
<SimpleMarketToolbar data={data?.markets || []} />
|
||||
<AsyncRenderer loading={loading} error={error} data={localData}>
|
||||
<AgGrid
|
||||
className="mb-32 min-h-[300px]"
|
||||
className="mb-32 min-h-[300px] w-full"
|
||||
style={constants.AG_GRID_CONTAINER_STYLES}
|
||||
defaultColDef={defaultColDef}
|
||||
columnDefs={columnDefs}
|
||||
rowData={localData}
|
||||
|
@ -2,10 +2,10 @@ import React from 'react';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { MockedProvider } from '@apollo/react-testing';
|
||||
import SimpleMarketPercentChange from './simple-market-percent-change';
|
||||
import type { SimpleMarkets_markets_candles } from './__generated__/SimpleMarkets';
|
||||
import type { Candle } from '@vegaprotocol/market-list';
|
||||
|
||||
describe('SimpleMarketPercentChange should parse proper change', () => {
|
||||
let candles: (SimpleMarkets_markets_candles | null)[] | null;
|
||||
let candles: (Candle | null)[] | null;
|
||||
const setValue = () => undefined;
|
||||
it('empty array', () => {
|
||||
candles = [];
|
||||
@ -34,11 +34,7 @@ describe('SimpleMarketPercentChange should parse proper change', () => {
|
||||
expect(screen.getByText('-')).toBeInTheDocument();
|
||||
});
|
||||
it('an appreciated one', () => {
|
||||
candles = [
|
||||
{ open: '50' } as SimpleMarkets_markets_candles,
|
||||
{ close: '100' } as SimpleMarkets_markets_candles,
|
||||
null,
|
||||
];
|
||||
candles = [{ open: '50' } as Candle, { close: '100' } as Candle, null];
|
||||
render(
|
||||
<MockedProvider>
|
||||
<SimpleMarketPercentChange
|
||||
@ -54,11 +50,7 @@ describe('SimpleMarketPercentChange should parse proper change', () => {
|
||||
);
|
||||
});
|
||||
it('a depreciated one', () => {
|
||||
candles = [
|
||||
{ open: '100' } as SimpleMarkets_markets_candles,
|
||||
{ close: '50' } as SimpleMarkets_markets_candles,
|
||||
null,
|
||||
];
|
||||
candles = [{ open: '100' } as Candle, { close: '50' } as Candle, null];
|
||||
render(
|
||||
<MockedProvider>
|
||||
<SimpleMarketPercentChange
|
||||
|
@ -1,26 +1,20 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import classNames from 'classnames';
|
||||
import { InView } from 'react-intersection-observer';
|
||||
import { useSubscription } from '@apollo/client';
|
||||
import type { SimpleMarkets_markets_candles } from './__generated__/SimpleMarkets';
|
||||
import type {
|
||||
CandleLive,
|
||||
CandleLiveVariables,
|
||||
} from './__generated__/CandleLive';
|
||||
import { CANDLE_SUB } from './data-provider';
|
||||
import { useDataProvider } from '@vegaprotocol/react-helpers';
|
||||
import type { Candle } from '@vegaprotocol/market-list';
|
||||
import { marketCandlesProvider } from '@vegaprotocol/market-list';
|
||||
import { Interval } from '@vegaprotocol/types';
|
||||
|
||||
interface Props {
|
||||
candles: (SimpleMarkets_markets_candles | null)[] | null;
|
||||
candles: (Candle | null)[] | null;
|
||||
marketId: string;
|
||||
setValue: (arg: unknown) => void;
|
||||
}
|
||||
|
||||
const EMPTY_VALUE = ' - ';
|
||||
|
||||
const getChange = (
|
||||
candles: (SimpleMarkets_markets_candles | null)[] | null,
|
||||
lastClose?: string
|
||||
) => {
|
||||
const getChange = (candles: (Candle | null)[] | null, lastClose?: string) => {
|
||||
if (candles) {
|
||||
const first = parseInt(candles.find((item) => item?.open)?.open || '-1');
|
||||
const last =
|
||||
@ -74,11 +68,14 @@ const SimpleMarketPercentChangeWrapper = (props: Props) => {
|
||||
};
|
||||
|
||||
const SimpleMarketPercentChange = ({ candles, marketId, setValue }: Props) => {
|
||||
const { data: { candles: { close = undefined } = {} } = {} } =
|
||||
useSubscription<CandleLive, CandleLiveVariables>(CANDLE_SUB, {
|
||||
variables: { marketId },
|
||||
const { data } = useDataProvider({
|
||||
dataProvider: marketCandlesProvider,
|
||||
variables: { marketId, interval: Interval.INTERVAL_I1D },
|
||||
});
|
||||
const change = getChange(candles, close);
|
||||
|
||||
const close = data?.map((m) => m.close);
|
||||
|
||||
const change = getChange(candles, close?.[0]);
|
||||
const colorClasses = getClassColor(change);
|
||||
useEffect(() => {
|
||||
const value = parseFloat(change);
|
||||
|
@ -1,36 +1,36 @@
|
||||
import React from 'react';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import type { MarketNames_markets } from '@vegaprotocol/deal-ticket';
|
||||
import { MarketState } from '@vegaprotocol/types';
|
||||
import MarketNameRenderer from './simple-market-renderer';
|
||||
import type { Market } from '@vegaprotocol/market-list';
|
||||
|
||||
describe('SimpleMarketRenderer', () => {
|
||||
const market = {
|
||||
id: 'marketId',
|
||||
id: 'MARKET_A',
|
||||
state: MarketState.STATE_ACTIVE,
|
||||
tradableInstrument: {
|
||||
instrument: {
|
||||
code: 'Market code',
|
||||
name: 'Market Name',
|
||||
code: 'MARKET_A_CODE',
|
||||
name: 'MARKET_A_NAME',
|
||||
product: {
|
||||
quoteName: 'Quote name',
|
||||
quoteName: 'MARKET_A_QUOTE_NAME',
|
||||
},
|
||||
metadata: {
|
||||
tags: null,
|
||||
},
|
||||
},
|
||||
},
|
||||
} as MarketNames_markets;
|
||||
} as Market;
|
||||
|
||||
it('should properly render not mobile', () => {
|
||||
render(<MarketNameRenderer market={market} isMobile={false} />);
|
||||
expect(screen.getByText('Market Name')).toBeInTheDocument();
|
||||
expect(screen.getByText('Quote name')).toBeInTheDocument();
|
||||
expect(screen.getByText('MARKET_A_NAME')).toBeInTheDocument();
|
||||
expect(screen.getByText('MARKET_A_QUOTE_NAME')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should properly render mobile', () => {
|
||||
render(<MarketNameRenderer market={market} isMobile={true} />);
|
||||
expect(screen.getByText('Market code')).toBeInTheDocument();
|
||||
expect(screen.getByText('Quote name')).toBeInTheDocument();
|
||||
expect(screen.getByText('MARKET_A_CODE')).toBeInTheDocument();
|
||||
expect(screen.getByText('MARKET_A_QUOTE_NAME')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
@ -1,10 +1,9 @@
|
||||
import React from 'react';
|
||||
import classNames from 'classnames';
|
||||
import type { MarketNames_markets } from '@vegaprotocol/deal-ticket';
|
||||
import SimpleMarketExpires from './simple-market-expires';
|
||||
import type { Market } from '@vegaprotocol/market-list';
|
||||
|
||||
interface Props {
|
||||
market: MarketNames_markets;
|
||||
market: Market;
|
||||
isMobile?: boolean;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import classNames from 'classnames';
|
||||
import { useNavigate, useParams, Link } from 'react-router-dom';
|
||||
import {
|
||||
@ -17,10 +17,10 @@ import {
|
||||
import { MarketState } from '@vegaprotocol/types';
|
||||
import useMarketFiltersData from '../../hooks/use-markets-filter';
|
||||
import { STATES_FILTER } from './constants';
|
||||
import type { SimpleMarkets_markets } from './__generated__/SimpleMarkets';
|
||||
import type { Markets_marketsConnection_edges_node } from '@vegaprotocol/market-list';
|
||||
|
||||
interface Props {
|
||||
data: SimpleMarkets_markets[];
|
||||
data: Markets_marketsConnection_edges_node[];
|
||||
}
|
||||
|
||||
const SimpleMarketToolbar = ({ data }: Props) => {
|
||||
@ -98,7 +98,7 @@ const SimpleMarketToolbar = ({ data }: Props) => {
|
||||
</Link>
|
||||
</li>
|
||||
{products.map((product, i) => (
|
||||
<li key={product} className="mx-2 whitespace-nowrap">
|
||||
<li key={`${product}-${i}`} className="mx-2 whitespace-nowrap">
|
||||
<Link
|
||||
to={`/markets/${
|
||||
params.state || MarketState.STATE_ACTIVE
|
||||
|
@ -1,14 +1,13 @@
|
||||
import React, { useMemo } from 'react';
|
||||
import { useMemo } from 'react';
|
||||
import classNames from 'classnames';
|
||||
import { t } from '@vegaprotocol/react-helpers';
|
||||
import type { SimpleMarkets_markets } from '../components/simple-market-list/__generated__/SimpleMarkets';
|
||||
import MarketNameRenderer from '../components/simple-market-list/simple-market-renderer';
|
||||
import SimpleMarketPercentChange from '../components/simple-market-list/simple-market-percent-change';
|
||||
import MarketNameRenderer from './simple-market-renderer';
|
||||
import SimpleMarketPercentChange from './simple-market-percent-change';
|
||||
import { Icon } from '@vegaprotocol/ui-toolkit';
|
||||
import type { ValueSetterParams } from 'ag-grid-community';
|
||||
import type { SimpleMarketsType } from '../components/simple-market-list/simple-market-list';
|
||||
import { IconNames } from '@blueprintjs/icons';
|
||||
import { IS_MARKET_TRADABLE, MARKET_STATES_MAP } from '../constants';
|
||||
import { IS_MARKET_TRADABLE, MARKET_STATES_MAP } from '../../constants';
|
||||
import type { Candle, Market } from '@vegaprotocol/market-list';
|
||||
|
||||
interface Props {
|
||||
isMobile: boolean;
|
||||
@ -24,7 +23,7 @@ const useColumnDefinitions = ({ isMobile }: Props) => {
|
||||
minWidth: isMobile ? 160 : 350,
|
||||
field: 'tradableInstrument.instrument.name',
|
||||
cellClass: 'overflow-visible',
|
||||
cellRenderer: ({ data }: { data: SimpleMarketsType }) => (
|
||||
cellRenderer: ({ data }: { data: Market }) => (
|
||||
<MarketNameRenderer market={data} isMobile={isMobile} />
|
||||
),
|
||||
},
|
||||
@ -35,7 +34,7 @@ const useColumnDefinitions = ({ isMobile }: Props) => {
|
||||
minWidth: isMobile ? 50 : 80,
|
||||
cellClass: 'uppercase flex h-full items-center',
|
||||
field: 'tradableInstrument.instrument.product.settlementAsset.symbol',
|
||||
cellRenderer: ({ data }: { data: SimpleMarketsType }) => (
|
||||
cellRenderer: ({ data }: { data: Market }) => (
|
||||
<div
|
||||
className="grid h-full items-center text-center"
|
||||
title={
|
||||
@ -70,7 +69,7 @@ const useColumnDefinitions = ({ isMobile }: Props) => {
|
||||
data,
|
||||
setValue,
|
||||
}: {
|
||||
data: SimpleMarketsType;
|
||||
data: { id: string; candles: Candle[] };
|
||||
setValue: (arg: unknown) => void;
|
||||
}) => (
|
||||
<SimpleMarketPercentChange
|
||||
@ -96,7 +95,7 @@ const useColumnDefinitions = ({ isMobile }: Props) => {
|
||||
field: 'state',
|
||||
headerClass: 'uppercase',
|
||||
minWidth: 100,
|
||||
cellRenderer: ({ data }: { data: SimpleMarkets_markets }) => (
|
||||
cellRenderer: ({ data }: { data: Market }) => (
|
||||
<div className="uppercase flex h-full items-center justify-center">
|
||||
<div className="border text-center px-2 md:px-6 leading-4 md:leading-6">
|
||||
{MARKET_STATES_MAP[data.state || '']}
|
||||
@ -110,7 +109,7 @@ const useColumnDefinitions = ({ isMobile }: Props) => {
|
||||
headerClass: 'uppercase',
|
||||
sortable: false,
|
||||
width: isMobile ? 35 : 100,
|
||||
cellRenderer: ({ data }: { data: SimpleMarkets_markets }) => (
|
||||
cellRenderer: ({ data }: { data: Market }) => (
|
||||
<div className="h-full flex h-full items-center justify-end">
|
||||
<div className="uppercase text-center pr-2">
|
||||
{!isMobile && t('Trade')}
|
@ -0,0 +1,52 @@
|
||||
import { useMemo } from 'react';
|
||||
import { MarketState } from '@vegaprotocol/types';
|
||||
import type { MarketsListData } from '@vegaprotocol/market-list';
|
||||
import type { RouterParams } from './simple-market-list';
|
||||
|
||||
const useMarketsFilterData = (data: MarketsListData, params: RouterParams) => {
|
||||
return useMemo(() => {
|
||||
const markets =
|
||||
data?.markets?.filter((item) => {
|
||||
if (
|
||||
params.product &&
|
||||
params.product !==
|
||||
item.tradableInstrument.instrument.product.__typename
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
params.asset &&
|
||||
params.asset !== 'all' &&
|
||||
params.asset !==
|
||||
item.tradableInstrument.instrument.product.settlementAsset.symbol
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
const state =
|
||||
params.state === 'all'
|
||||
? ''
|
||||
: params.state
|
||||
? params.state
|
||||
: MarketState.STATE_ACTIVE;
|
||||
if (state && state !== item.state) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}) || [];
|
||||
|
||||
return markets.map((market) => ({
|
||||
...market,
|
||||
candles: (data?.marketsCandles || [])
|
||||
.filter((c) => c.marketId === market.id)
|
||||
.map((c) => c.candles),
|
||||
}));
|
||||
}, [
|
||||
data?.marketsCandles,
|
||||
data?.markets,
|
||||
params.product,
|
||||
params.asset,
|
||||
params.state,
|
||||
]);
|
||||
};
|
||||
|
||||
export default useMarketsFilterData;
|
@ -1,6 +1,6 @@
|
||||
import type { SimpleMarkets_markets } from '../components/simple-market-list/__generated__/SimpleMarkets';
|
||||
import { MarketState } from '@vegaprotocol/types';
|
||||
import { t } from '@vegaprotocol/react-helpers';
|
||||
import type { Market } from '@vegaprotocol/market-list';
|
||||
|
||||
export const DATE_FORMAT = 'dd MMMM yyyy HH:mm';
|
||||
export const EXPIRE_DATE_FORMAT = 'MMM dd';
|
||||
@ -9,7 +9,7 @@ export const TRADABLE_STATES = {
|
||||
[MarketState.STATE_ACTIVE]: true,
|
||||
};
|
||||
|
||||
export const IS_MARKET_TRADABLE = (market: SimpleMarkets_markets) =>
|
||||
export const IS_MARKET_TRADABLE = (market: Market) =>
|
||||
Boolean((market.state ?? '') in TRADABLE_STATES && market?.id);
|
||||
|
||||
export const MARKET_STATES_MAP: Record<MarketState | '', string> = {
|
||||
|
@ -10,7 +10,7 @@
|
||||
export interface MarketMarkPrice_market_data {
|
||||
__typename: "MarketData";
|
||||
/**
|
||||
* the mark price (an unsigned integer)
|
||||
* The mark price (an unsigned integer)
|
||||
*/
|
||||
markPrice: string;
|
||||
}
|
||||
@ -18,7 +18,7 @@ export interface MarketMarkPrice_market_data {
|
||||
export interface MarketMarkPrice_market {
|
||||
__typename: "Market";
|
||||
/**
|
||||
* decimalPlaces indicates the number of decimal places that an integer must be shifted by in order to get a correct
|
||||
* The number of decimal places that an integer must be shifted by in order to get a correct
|
||||
* number denominated in the currency of the market. (uint64)
|
||||
*
|
||||
* Examples:
|
||||
|
@ -60,19 +60,19 @@ export interface PartyMarketData_party_marginsConnection_edges_node_market {
|
||||
export interface PartyMarketData_party_marginsConnection_edges_node {
|
||||
__typename: "MarginLevels";
|
||||
/**
|
||||
* market in which the margin is required for this party
|
||||
* Market in which the margin is required for this party
|
||||
*/
|
||||
market: PartyMarketData_party_marginsConnection_edges_node_market;
|
||||
/**
|
||||
* this is the minimum margin required for a party to place a new order on the network (unsigned integer)
|
||||
* This is the minimum margin required for a party to place a new order on the network (unsigned integer)
|
||||
*/
|
||||
initialLevel: string;
|
||||
/**
|
||||
* minimal margin for the position to be maintained in the network (unsigned integer)
|
||||
* Minimal margin for the position to be maintained in the network (unsigned integer)
|
||||
*/
|
||||
maintenanceLevel: string;
|
||||
/**
|
||||
* if the margin is between maintenance and search, the network will initiate a collateral search (unsigned integer)
|
||||
* If the margin is between maintenance and search, the network will initiate a collateral search (unsigned integer)
|
||||
*/
|
||||
searchLevel: string;
|
||||
}
|
||||
@ -103,7 +103,7 @@ export interface PartyMarketData_party {
|
||||
/**
|
||||
* Margin levels for a market
|
||||
*/
|
||||
marginsConnection: PartyMarketData_party_marginsConnection;
|
||||
marginsConnection: PartyMarketData_party_marginsConnection | null;
|
||||
}
|
||||
|
||||
export interface PartyMarketData {
|
||||
|
@ -28,7 +28,7 @@ export interface EstimateOrder_estimateOrder_fee {
|
||||
export interface EstimateOrder_estimateOrder_marginLevels {
|
||||
__typename: "MarginLevels";
|
||||
/**
|
||||
* this is the minimum margin required for a party to place a new order on the network (unsigned integer)
|
||||
* This is the minimum margin required for a party to place a new order on the network (unsigned integer)
|
||||
*/
|
||||
initialLevel: string;
|
||||
}
|
||||
@ -47,7 +47,7 @@ export interface EstimateOrder_estimateOrder {
|
||||
|
||||
export interface EstimateOrder {
|
||||
/**
|
||||
* return an estimation of the potential cost for a new order
|
||||
* Return an estimation of the potential cost for a new order
|
||||
*/
|
||||
estimateOrder: EstimateOrder_estimateOrder;
|
||||
}
|
||||
|
@ -67,6 +67,9 @@ export interface MarketPositions_party_positionsConnection_edges_node {
|
||||
|
||||
export interface MarketPositions_party_positionsConnection_edges {
|
||||
__typename: "PositionEdge";
|
||||
/**
|
||||
* The position
|
||||
*/
|
||||
node: MarketPositions_party_positionsConnection_edges_node;
|
||||
}
|
||||
|
||||
@ -91,7 +94,7 @@ export interface MarketPositions_party {
|
||||
/**
|
||||
* Trading positions relating to a party
|
||||
*/
|
||||
positionsConnection: MarketPositions_party_positionsConnection;
|
||||
positionsConnection: MarketPositions_party_positionsConnection | null;
|
||||
}
|
||||
|
||||
export interface MarketPositions {
|
||||
|
@ -8,7 +8,7 @@ export type MarketPositionsQueryVariables = Types.Exact<{
|
||||
}>;
|
||||
|
||||
|
||||
export type MarketPositionsQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, accounts?: Array<{ __typename?: 'Account', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', decimals: number }, market?: { __typename?: 'Market', id: string } | null }> | null, positionsConnection: { __typename?: 'PositionConnection', edges?: Array<{ __typename?: 'PositionEdge', node: { __typename?: 'Position', openVolume: string, market: { __typename?: 'Market', id: string } } }> | null } } | null };
|
||||
export type MarketPositionsQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, accounts?: Array<{ __typename?: 'Account', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', decimals: number }, market?: { __typename?: 'Market', id: string } | null }> | null, positionsConnection?: { __typename?: 'PositionConnection', edges?: Array<{ __typename?: 'PositionEdge', node: { __typename?: 'Position', openVolume: string, market: { __typename?: 'Market', id: string } } }> | null } | null } | null };
|
||||
|
||||
|
||||
export const MarketPositionsDocument = gql`
|
||||
|
@ -8,7 +8,7 @@ export type PartyMarketDataQueryVariables = Types.Exact<{
|
||||
}>;
|
||||
|
||||
|
||||
export type PartyMarketDataQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, accounts?: Array<{ __typename?: 'Account', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', id: string, decimals: number }, market?: { __typename?: 'Market', id: string } | null }> | null, marginsConnection: { __typename?: 'MarginConnection', edges?: Array<{ __typename?: 'MarginEdge', node: { __typename?: 'MarginLevels', initialLevel: string, maintenanceLevel: string, searchLevel: string, market: { __typename?: 'Market', id: string } } }> | null } } | null };
|
||||
export type PartyMarketDataQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, accounts?: Array<{ __typename?: 'Account', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', id: string, decimals: number }, market?: { __typename?: 'Market', id: string } | null }> | null, marginsConnection?: { __typename?: 'MarginConnection', edges?: Array<{ __typename?: 'MarginEdge', node: { __typename?: 'MarginLevels', initialLevel: string, maintenanceLevel: string, searchLevel: string, market: { __typename?: 'Market', id: string } } }> | null } | null } | null };
|
||||
|
||||
|
||||
export const PartyMarketDataDocument = gql`
|
||||
|
@ -1,37 +0,0 @@
|
||||
import type { SimpleMarkets_markets } from '../components/simple-market-list/__generated__/SimpleMarkets';
|
||||
import type { RouterParams } from '../components/simple-market-list/simple-market-list';
|
||||
import { MarketState } from '@vegaprotocol/types';
|
||||
|
||||
const useMarketsFilterData = (
|
||||
data: SimpleMarkets_markets[] = [],
|
||||
params: RouterParams
|
||||
) => {
|
||||
return data.filter((item) => {
|
||||
if (
|
||||
params.product &&
|
||||
params.product !== item.tradableInstrument.instrument.product.__typename
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
params.asset &&
|
||||
params.asset !== 'all' &&
|
||||
params.asset !==
|
||||
item.tradableInstrument.instrument.product.settlementAsset.symbol
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
const state =
|
||||
params.state === 'all'
|
||||
? ''
|
||||
: params.state
|
||||
? params.state
|
||||
: MarketState.STATE_ACTIVE;
|
||||
if (state && state !== item.state) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
};
|
||||
|
||||
export default useMarketsFilterData;
|
@ -1,7 +1,7 @@
|
||||
import type { Market } from '@vegaprotocol/market-list';
|
||||
import { useEffect, useState } from 'react';
|
||||
import type { SimpleMarkets_markets } from '../components/simple-market-list/__generated__/SimpleMarkets';
|
||||
|
||||
const useMarketFilters = (data: SimpleMarkets_markets[]) => {
|
||||
const useMarketFilters = (data: Market[]) => {
|
||||
const [products, setProducts] = useState<string[]>([]);
|
||||
const [assetsPerProduct, setAssetsPerProduct] = useState<
|
||||
Record<string, string[]>
|
||||
|
@ -74,7 +74,7 @@ const useOrderCloseOut = ({ order, market, partyData }: Props): string => {
|
||||
|
||||
const marginMaintenanceLevel = new BigNumber(
|
||||
addDecimal(
|
||||
data?.party?.marginsConnection.edges?.find(
|
||||
data?.party?.marginsConnection?.edges?.find(
|
||||
(nodes) => nodes.node.market.id === market.id
|
||||
)?.node.maintenanceLevel || 0,
|
||||
market.decimalPlaces
|
||||
|
@ -38,6 +38,9 @@ export function createClient(base?: string) {
|
||||
Node: {
|
||||
keyFields: false,
|
||||
},
|
||||
Instrument: {
|
||||
keyFields: false,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -81,6 +81,9 @@ export interface AssetsQuery_assetsConnection_edges_node {
|
||||
|
||||
export interface AssetsQuery_assetsConnection_edges {
|
||||
__typename: "AssetEdge";
|
||||
/**
|
||||
* The asset information
|
||||
*/
|
||||
node: AssetsQuery_assetsConnection_edges_node;
|
||||
}
|
||||
|
||||
@ -96,5 +99,5 @@ export interface AssetsQuery {
|
||||
/**
|
||||
* The list of all assets in use in the Vega network or the specified asset if ID is provided
|
||||
*/
|
||||
assetsConnection: AssetsQuery_assetsConnection;
|
||||
assetsConnection: AssetsQuery_assetsConnection | null;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ const defaultOptions = {} as const;
|
||||
export type AssetsQueryQueryVariables = Types.Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
export type AssetsQueryQuery = { __typename?: 'Query', assetsConnection: { __typename?: 'AssetsConnection', edges?: Array<{ __typename?: 'AssetEdge', node: { __typename?: 'Asset', id: string, name: string, symbol: string, decimals: number, source: { __typename?: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename?: 'ERC20', contractAddress: string }, infrastructureFeeAccount: { __typename?: 'Account', type: Types.AccountType, balance: string, market?: { __typename?: 'Market', id: string } | null } } } | null> | null } };
|
||||
export type AssetsQueryQuery = { __typename?: 'Query', assetsConnection?: { __typename?: 'AssetsConnection', edges?: Array<{ __typename?: 'AssetEdge', node: { __typename?: 'Asset', id: string, name: string, symbol: string, decimals: number, source: { __typename?: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename?: 'ERC20', contractAddress: string }, infrastructureFeeAccount: { __typename?: 'Account', type: Types.AccountType, balance: string, market?: { __typename?: 'Market', id: string } | null } } } | null> | null } | null };
|
||||
|
||||
|
||||
export const AssetsQueryDocument = gql`
|
||||
|
@ -265,7 +265,7 @@ export interface ProposalsQuery_proposalsConnection_edges_node {
|
||||
*/
|
||||
datetime: string;
|
||||
/**
|
||||
* Reason for the proposal to be rejected by the core
|
||||
* Why the proposal was rejected by the core
|
||||
*/
|
||||
rejectionReason: ProposalRejectionReason | null;
|
||||
/**
|
||||
@ -302,5 +302,5 @@ export interface ProposalsQuery {
|
||||
/**
|
||||
* All governance proposals in the Vega network
|
||||
*/
|
||||
proposalsConnection: ProposalsQuery_proposalsConnection;
|
||||
proposalsConnection: ProposalsQuery_proposalsConnection | null;
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
query MarketsQuery {
|
||||
markets {
|
||||
id
|
||||
name
|
||||
fees {
|
||||
factors {
|
||||
makerFee
|
||||
|
@ -104,15 +104,15 @@ export interface MarketsQuery_markets_tradableInstrument_instrument {
|
||||
export interface MarketsQuery_markets_tradableInstrument_riskModel_LogNormalRiskModel_params {
|
||||
__typename: "LogNormalModelParams";
|
||||
/**
|
||||
* r parameter
|
||||
* R parameter
|
||||
*/
|
||||
r: number;
|
||||
/**
|
||||
* sigma parameter, annualised volatility of the underlying asset, must be a strictly non-negative real number
|
||||
* Sigma parameter, annualised volatility of the underlying asset, must be a strictly non-negative real number
|
||||
*/
|
||||
sigma: number;
|
||||
/**
|
||||
* mu parameter, annualised growth rate of the underlying asset
|
||||
* Mu parameter, annualised growth rate of the underlying asset
|
||||
*/
|
||||
mu: number;
|
||||
}
|
||||
@ -158,15 +158,15 @@ export type MarketsQuery_markets_tradableInstrument_riskModel = MarketsQuery_mar
|
||||
export interface MarketsQuery_markets_tradableInstrument_marginCalculator_scalingFactors {
|
||||
__typename: "ScalingFactors";
|
||||
/**
|
||||
* the scaling factor that determines the margin level at which Vega has to search for more money
|
||||
* The scaling factor that determines the margin level at which Vega has to search for more money
|
||||
*/
|
||||
searchLevel: number;
|
||||
/**
|
||||
* the scaling factor that determines the optimal margin level
|
||||
* The scaling factor that determines the optimal margin level
|
||||
*/
|
||||
initialMargin: number;
|
||||
/**
|
||||
* the scaling factor that determines the overflow margin level
|
||||
* The scaling factor that determines the overflow margin level
|
||||
*/
|
||||
collateralRelease: number;
|
||||
}
|
||||
@ -362,47 +362,47 @@ export interface MarketsQuery_markets_data_liquidityProviderFeeShare {
|
||||
export interface MarketsQuery_markets_data {
|
||||
__typename: "MarketData";
|
||||
/**
|
||||
* the mark price (an unsigned integer)
|
||||
* The mark price (an unsigned integer)
|
||||
*/
|
||||
markPrice: string;
|
||||
/**
|
||||
* the highest price level on an order book for buy orders.
|
||||
* The highest price level on an order book for buy orders.
|
||||
*/
|
||||
bestBidPrice: string;
|
||||
/**
|
||||
* the aggregated volume being bid at the best bid price.
|
||||
* The aggregated volume being bid at the best bid price.
|
||||
*/
|
||||
bestBidVolume: string;
|
||||
/**
|
||||
* the lowest price level on an order book for offer orders.
|
||||
* The lowest price level on an order book for offer orders.
|
||||
*/
|
||||
bestOfferPrice: string;
|
||||
/**
|
||||
* the aggregated volume being offered at the best offer price.
|
||||
* The aggregated volume being offered at the best offer price.
|
||||
*/
|
||||
bestOfferVolume: string;
|
||||
/**
|
||||
* the highest price level on an order book for buy orders not including pegged orders.
|
||||
* The highest price level on an order book for buy orders not including pegged orders.
|
||||
*/
|
||||
bestStaticBidPrice: string;
|
||||
/**
|
||||
* the aggregated volume being offered at the best static bid price, excluding pegged orders
|
||||
* The aggregated volume being offered at the best static bid price, excluding pegged orders
|
||||
*/
|
||||
bestStaticBidVolume: string;
|
||||
/**
|
||||
* the lowest price level on an order book for offer orders not including pegged orders.
|
||||
* The lowest price level on an order book for offer orders not including pegged orders.
|
||||
*/
|
||||
bestStaticOfferPrice: string;
|
||||
/**
|
||||
* the aggregated volume being offered at the best static offer price, excluding pegged orders.
|
||||
* The aggregated volume being offered at the best static offer price, excluding pegged orders.
|
||||
*/
|
||||
bestStaticOfferVolume: string;
|
||||
/**
|
||||
* the arithmetic average of the best bid price and best offer price.
|
||||
* The arithmetic average of the best bid price and best offer price.
|
||||
*/
|
||||
midPrice: string;
|
||||
/**
|
||||
* the arithmetic average of the best static bid price and best static offer price
|
||||
* The arithmetic average of the best static bid price and best static offer price
|
||||
*/
|
||||
staticMidPrice: string;
|
||||
/**
|
||||
@ -410,7 +410,7 @@ export interface MarketsQuery_markets_data {
|
||||
*/
|
||||
timestamp: string;
|
||||
/**
|
||||
* the sum of the size of all positions greater than 0.
|
||||
* The sum of the size of all positions greater than 0.
|
||||
*/
|
||||
openInterest: string;
|
||||
/**
|
||||
@ -422,39 +422,39 @@ export interface MarketsQuery_markets_data {
|
||||
*/
|
||||
auctionStart: string | null;
|
||||
/**
|
||||
* indicative price if the auction ended now, 0 if not in auction mode
|
||||
* Indicative price if the auction ended now, 0 if not in auction mode
|
||||
*/
|
||||
indicativePrice: string;
|
||||
/**
|
||||
* indicative volume if the auction ended now, 0 if not in auction mode
|
||||
* Indicative volume if the auction ended now, 0 if not in auction mode
|
||||
*/
|
||||
indicativeVolume: string;
|
||||
/**
|
||||
* what triggered an auction (if an auction was started)
|
||||
* What triggered an auction (if an auction was started)
|
||||
*/
|
||||
trigger: AuctionTrigger;
|
||||
/**
|
||||
* what extended the ongoing auction (if an auction was extended)
|
||||
* What extended the ongoing auction (if an auction was extended)
|
||||
*/
|
||||
extensionTrigger: AuctionTrigger;
|
||||
/**
|
||||
* the amount of stake targeted for this market
|
||||
* The amount of stake targeted for this market
|
||||
*/
|
||||
targetStake: string | null;
|
||||
/**
|
||||
* the supplied stake for the market
|
||||
* The supplied stake for the market
|
||||
*/
|
||||
suppliedStake: string | null;
|
||||
/**
|
||||
* a list of valid price ranges per associated trigger
|
||||
* A list of valid price ranges per associated trigger
|
||||
*/
|
||||
priceMonitoringBounds: MarketsQuery_markets_data_priceMonitoringBounds[] | null;
|
||||
/**
|
||||
* the market value proxy
|
||||
* The market value proxy
|
||||
*/
|
||||
marketValueProxy: string;
|
||||
/**
|
||||
* the equity like share of liquidity fee for each liquidity provider
|
||||
* The equity like share of liquidity fee for each liquidity provider
|
||||
*/
|
||||
liquidityProviderFeeShare: MarketsQuery_markets_data_liquidityProviderFeeShare[] | null;
|
||||
}
|
||||
@ -474,7 +474,7 @@ export interface MarketsQuery_markets {
|
||||
*/
|
||||
tradableInstrument: MarketsQuery_markets_tradableInstrument;
|
||||
/**
|
||||
* decimalPlaces indicates the number of decimal places that an integer must be shifted by in order to get a correct
|
||||
* The number of decimal places that an integer must be shifted by in order to get a correct
|
||||
* number denominated in the currency of the market. (uint64)
|
||||
*
|
||||
* Examples:
|
||||
|
@ -6,14 +6,13 @@ const defaultOptions = {} as const;
|
||||
export type MarketsQueryQueryVariables = Types.Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
export type MarketsQueryQuery = { __typename?: 'Query', markets?: Array<{ __typename?: 'Market', id: string, name: string, decimalPlaces: number, tradingMode: Types.MarketTradingMode, state: Types.MarketState, fees: { __typename?: 'Fees', factors: { __typename?: 'FeeFactors', makerFee: string, infrastructureFee: string, liquidityFee: string } }, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string, id: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null }, product: { __typename?: 'Future', settlementAsset: { __typename?: 'Asset', id: string, name: string, decimals: number, globalRewardPoolAccount?: { __typename?: 'Account', balance: string } | null } } }, riskModel: { __typename?: 'LogNormalRiskModel', tau: number, riskAversionParameter: number, params: { __typename?: 'LogNormalModelParams', r: number, sigma: number, mu: number } } | { __typename?: 'SimpleRiskModel', params: { __typename?: 'SimpleRiskModelParams', factorLong: number, factorShort: number } }, marginCalculator?: { __typename?: 'MarginCalculator', scalingFactors: { __typename?: 'ScalingFactors', searchLevel: number, initialMargin: number, collateralRelease: number } } | null }, openingAuction: { __typename?: 'AuctionDuration', durationSecs: number, volume: number }, priceMonitoringSettings: { __typename?: 'PriceMonitoringSettings', parameters?: { __typename?: 'PriceMonitoringParameters', triggers?: Array<{ __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number }> | null } | null }, liquidityMonitoringParameters: { __typename?: 'LiquidityMonitoringParameters', triggeringRatio: number, targetStakeParameters: { __typename?: 'TargetStakeParameters', timeWindow: number, scalingFactor: number } }, proposal?: { __typename?: 'Proposal', id?: string | null } | null, accounts?: Array<{ __typename?: 'Account', balance: string, type: Types.AccountType, asset: { __typename?: 'Asset', id: string, name: string } }> | null, data?: { __typename?: 'MarketData', markPrice: string, bestBidPrice: string, bestBidVolume: string, bestOfferPrice: string, bestOfferVolume: string, bestStaticBidPrice: string, bestStaticBidVolume: string, bestStaticOfferPrice: string, bestStaticOfferVolume: string, midPrice: string, staticMidPrice: string, timestamp: string, openInterest: string, auctionEnd?: string | null, auctionStart?: string | null, indicativePrice: string, indicativeVolume: string, trigger: Types.AuctionTrigger, extensionTrigger: Types.AuctionTrigger, targetStake?: string | null, suppliedStake?: string | null, marketValueProxy: string, priceMonitoringBounds?: Array<{ __typename?: 'PriceMonitoringBounds', minValidPrice: string, maxValidPrice: string, referencePrice: string, trigger: { __typename?: 'PriceMonitoringTrigger', auctionExtensionSecs: number, probability: number } }> | null, liquidityProviderFeeShare?: Array<{ __typename?: 'LiquidityProviderFeeShare', equityLikeShare: string, averageEntryValuation: string, party: { __typename?: 'Party', id: string } }> | null } | null }> | null };
|
||||
export type MarketsQueryQuery = { __typename?: 'Query', markets?: Array<{ __typename?: 'Market', id: string, decimalPlaces: number, tradingMode: Types.MarketTradingMode, state: Types.MarketState, fees: { __typename?: 'Fees', factors: { __typename?: 'FeeFactors', makerFee: string, infrastructureFee: string, liquidityFee: string } }, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string, id: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null }, product: { __typename?: 'Future', settlementAsset: { __typename?: 'Asset', id: string, name: string, decimals: number, globalRewardPoolAccount?: { __typename?: 'Account', balance: string } | null } } }, riskModel: { __typename?: 'LogNormalRiskModel', tau: number, riskAversionParameter: number, params: { __typename?: 'LogNormalModelParams', r: number, sigma: number, mu: number } } | { __typename?: 'SimpleRiskModel', params: { __typename?: 'SimpleRiskModelParams', factorLong: number, factorShort: number } }, marginCalculator?: { __typename?: 'MarginCalculator', scalingFactors: { __typename?: 'ScalingFactors', searchLevel: number, initialMargin: number, collateralRelease: number } } | null }, openingAuction: { __typename?: 'AuctionDuration', durationSecs: number, volume: number }, priceMonitoringSettings: { __typename?: 'PriceMonitoringSettings', parameters?: { __typename?: 'PriceMonitoringParameters', triggers?: Array<{ __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number }> | null } | null }, liquidityMonitoringParameters: { __typename?: 'LiquidityMonitoringParameters', triggeringRatio: number, targetStakeParameters: { __typename?: 'TargetStakeParameters', timeWindow: number, scalingFactor: number } }, proposal?: { __typename?: 'Proposal', id?: string | null } | null, accounts?: Array<{ __typename?: 'Account', balance: string, type: Types.AccountType, asset: { __typename?: 'Asset', id: string, name: string } }> | null, data?: { __typename?: 'MarketData', markPrice: string, bestBidPrice: string, bestBidVolume: string, bestOfferPrice: string, bestOfferVolume: string, bestStaticBidPrice: string, bestStaticBidVolume: string, bestStaticOfferPrice: string, bestStaticOfferVolume: string, midPrice: string, staticMidPrice: string, timestamp: string, openInterest: string, auctionEnd?: string | null, auctionStart?: string | null, indicativePrice: string, indicativeVolume: string, trigger: Types.AuctionTrigger, extensionTrigger: Types.AuctionTrigger, targetStake?: string | null, suppliedStake?: string | null, marketValueProxy: string, priceMonitoringBounds?: Array<{ __typename?: 'PriceMonitoringBounds', minValidPrice: string, maxValidPrice: string, referencePrice: string, trigger: { __typename?: 'PriceMonitoringTrigger', auctionExtensionSecs: number, probability: number } }> | null, liquidityProviderFeeShare?: Array<{ __typename?: 'LiquidityProviderFeeShare', equityLikeShare: string, averageEntryValuation: string, party: { __typename?: 'Party', id: string } }> | null } | null }> | null };
|
||||
|
||||
|
||||
export const MarketsQueryDocument = gql`
|
||||
query MarketsQuery {
|
||||
markets {
|
||||
id
|
||||
name
|
||||
fees {
|
||||
factors {
|
||||
makerFee
|
||||
|
@ -21,7 +21,7 @@ export interface NetworkParametersQuery_networkParameters {
|
||||
|
||||
export interface NetworkParametersQuery {
|
||||
/**
|
||||
* return the full list of network parameters
|
||||
* Return the full list of network parameters
|
||||
*/
|
||||
networkParameters: NetworkParametersQuery_networkParameters[] | null;
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
query OracleSpecs {
|
||||
oracleSpecs {
|
||||
oracleSpecsConnection {
|
||||
edges {
|
||||
node {
|
||||
status
|
||||
id
|
||||
createdAt
|
||||
@ -20,3 +22,5 @@ query OracleSpecs {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,11 +12,11 @@ import { OracleSpecStatus, PropertyKeyType, ConditionOperator } from "@vegaproto
|
||||
export interface OracleSpecs_oracleSpecs_filters_key {
|
||||
__typename: "PropertyKey";
|
||||
/**
|
||||
* name is the name of the property.
|
||||
* The name of the property.
|
||||
*/
|
||||
name: string | null;
|
||||
/**
|
||||
* type is the type of the property.
|
||||
* The type of the property.
|
||||
*/
|
||||
type: PropertyKeyType;
|
||||
}
|
||||
@ -24,11 +24,11 @@ export interface OracleSpecs_oracleSpecs_filters_key {
|
||||
export interface OracleSpecs_oracleSpecs_filters_conditions {
|
||||
__typename: "Condition";
|
||||
/**
|
||||
* value is used by the comparator.
|
||||
* The value to compare against.
|
||||
*/
|
||||
value: string | null;
|
||||
/**
|
||||
* comparator is the type of comparison to make on the value.
|
||||
* The type of comparison to make on the value.
|
||||
*/
|
||||
operator: ConditionOperator;
|
||||
}
|
||||
@ -36,11 +36,11 @@ export interface OracleSpecs_oracleSpecs_filters_conditions {
|
||||
export interface OracleSpecs_oracleSpecs_filters {
|
||||
__typename: "Filter";
|
||||
/**
|
||||
* key is the oracle data property key targeted by the filter.
|
||||
* The oracle data property key targeted by the filter.
|
||||
*/
|
||||
key: OracleSpecs_oracleSpecs_filters_key;
|
||||
/**
|
||||
* conditions are the conditions that should be matched by the data to be
|
||||
* The conditions that should be matched by the data to be
|
||||
* considered of interest.
|
||||
*/
|
||||
conditions: OracleSpecs_oracleSpecs_filters_conditions[] | null;
|
||||
@ -49,7 +49,7 @@ export interface OracleSpecs_oracleSpecs_filters {
|
||||
export interface OracleSpecs_oracleSpecs_data {
|
||||
__typename: "OracleData";
|
||||
/**
|
||||
* pubKeys is the list of public keys that signed the data
|
||||
* The list of public keys that signed the data
|
||||
*/
|
||||
pubKeys: string[] | null;
|
||||
}
|
||||
@ -57,7 +57,7 @@ export interface OracleSpecs_oracleSpecs_data {
|
||||
export interface OracleSpecs_oracleSpecs {
|
||||
__typename: "OracleSpec";
|
||||
/**
|
||||
* status describes the status of the oracle spec
|
||||
* Status describes the status of the oracle spec
|
||||
*/
|
||||
status: OracleSpecStatus;
|
||||
/**
|
||||
@ -73,18 +73,18 @@ export interface OracleSpecs_oracleSpecs {
|
||||
*/
|
||||
updatedAt: string | null;
|
||||
/**
|
||||
* pubKeys is the list of authorized public keys that signed the data for this
|
||||
* The list of authorized public keys that signed the data for this
|
||||
* oracle. All the public keys in the oracle data should be contained in these
|
||||
* public keys.
|
||||
*/
|
||||
pubKeys: string[] | null;
|
||||
/**
|
||||
* filters describes which oracle data are considered of interest or not for
|
||||
* Filters describes which oracle data are considered of interest or not for
|
||||
* the product (or the risk model).
|
||||
*/
|
||||
filters: OracleSpecs_oracleSpecs_filters[] | null;
|
||||
/**
|
||||
* data list all the oracle data broadcast to this spec
|
||||
* Data list all the oracle data broadcast to this spec
|
||||
*/
|
||||
data: OracleSpecs_oracleSpecs_data[];
|
||||
}
|
||||
|
@ -6,12 +6,14 @@ const defaultOptions = {} as const;
|
||||
export type OracleSpecsQueryVariables = Types.Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
export type OracleSpecsQuery = { __typename?: 'Query', oracleSpecs?: Array<{ __typename?: 'OracleSpec', status: Types.OracleSpecStatus, id: string, createdAt: string, updatedAt?: string | null, pubKeys?: Array<string> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null, data: Array<{ __typename?: 'OracleData', pubKeys?: Array<string> | null }> }> | null };
|
||||
export type OracleSpecsQuery = { __typename?: 'Query', oracleSpecsConnection?: { __typename?: 'OracleSpecsConnection', edges?: Array<{ __typename?: 'OracleSpecEdge', node: { __typename?: 'OracleSpec', status: Types.OracleSpecStatus, id: string, createdAt: string, updatedAt?: string | null, pubKeys?: Array<string> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null, data: Array<{ __typename?: 'OracleData', pubKeys?: Array<string> | null }> } } | null> | null } | null };
|
||||
|
||||
|
||||
export const OracleSpecsDocument = gql`
|
||||
query OracleSpecs {
|
||||
oracleSpecs {
|
||||
oracleSpecsConnection {
|
||||
edges {
|
||||
node {
|
||||
status
|
||||
id
|
||||
createdAt
|
||||
@ -31,6 +33,8 @@ export const OracleSpecsDocument = gql`
|
||||
pubKeys
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
|
@ -18,6 +18,5 @@ query NodesQuery {
|
||||
online
|
||||
}
|
||||
status
|
||||
name
|
||||
}
|
||||
}
|
||||
|
@ -69,13 +69,19 @@ export interface NodesQuery_nodes {
|
||||
* Amount of stake on the next epoch
|
||||
*/
|
||||
pendingStake: string;
|
||||
/**
|
||||
* Summary of epoch data across all nodes
|
||||
*/
|
||||
epochData: NodesQuery_nodes_epochData | null;
|
||||
/**
|
||||
* Validator status of the node
|
||||
*/
|
||||
status: NodeStatus;
|
||||
}
|
||||
|
||||
export interface NodesQuery {
|
||||
/**
|
||||
* all known network nodes
|
||||
* All known network nodes
|
||||
*/
|
||||
nodes: NodesQuery_nodes[] | null;
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ export const NodesQueryDocument = gql`
|
||||
online
|
||||
}
|
||||
status
|
||||
name
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
@ -12,7 +12,7 @@ import { AccountType } from "@vegaprotocol/types";
|
||||
export interface Delegations_epoch {
|
||||
__typename: "Epoch";
|
||||
/**
|
||||
* Presumably this is an integer or something. If there's no such thing, disregard
|
||||
* Numeric sequence number used to identify the epoch
|
||||
*/
|
||||
id: string;
|
||||
}
|
||||
@ -131,7 +131,7 @@ export interface Delegations_party {
|
||||
|
||||
export interface Delegations {
|
||||
/**
|
||||
* get data for a specific epoch, if ID omitted it gets the current epoch. If the string is 'next', fetch the next epoch
|
||||
* Get data for a specific epoch, if ID omitted it gets the current epoch. If the string is 'next', fetch the next epoch
|
||||
*/
|
||||
epoch: Delegations_epoch;
|
||||
/**
|
||||
|
@ -48,7 +48,7 @@ export interface ProposalFields_terms_change_NewMarket_instrument_futureProduct_
|
||||
export interface ProposalFields_terms_change_NewMarket_instrument_futureProduct {
|
||||
__typename: "FutureProduct";
|
||||
/**
|
||||
* Product asset ID
|
||||
* Product asset
|
||||
*/
|
||||
settlementAsset: ProposalFields_terms_change_NewMarket_instrument_futureProduct_settlementAsset;
|
||||
}
|
||||
@ -293,7 +293,7 @@ export interface ProposalFields {
|
||||
*/
|
||||
datetime: string;
|
||||
/**
|
||||
* Reason for the proposal to be rejected by the core
|
||||
* Why the proposal was rejected by the core
|
||||
*/
|
||||
rejectionReason: ProposalRejectionReason | null;
|
||||
/**
|
||||
|
@ -10,7 +10,7 @@ export type ProposalQueryVariables = Types.Exact<{
|
||||
}>;
|
||||
|
||||
|
||||
export type ProposalQuery = { __typename?: 'Query', proposal: { __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, datetime: string, rejectionReason?: Types.ProposalRejectionReason | null, errorDetails?: string | null, party: { __typename?: 'Party', id: string }, terms: { __typename?: 'ProposalTerms', closingDatetime: string, enactmentDatetime?: string | null, change: { __typename: 'NewAsset', name: string, symbol: string, source: { __typename: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename: 'ERC20', contractAddress: string } } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket', decimalPlaces: number, metadata?: Array<string> | null, instrument: { __typename?: 'InstrumentConfiguration', name: string, code: string, futureProduct?: { __typename?: 'FutureProduct', settlementAsset: { __typename?: 'Asset', symbol: string } } | null } } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket', marketId: string } | { __typename?: 'UpdateNetworkParameter', networkParameter: { __typename?: 'NetworkParameter', key: string, value: string } } }, votes: { __typename?: 'ProposalVotes', yes: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, votes?: Array<{ __typename?: 'Vote', value: Types.VoteValue, datetime: string, party: { __typename?: 'Party', id: string, stake: { __typename?: 'PartyStake', currentStakeAvailable: string } } }> | null }, no: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, votes?: Array<{ __typename?: 'Vote', value: Types.VoteValue, datetime: string, party: { __typename?: 'Party', id: string, stake: { __typename?: 'PartyStake', currentStakeAvailable: string } } }> | null } } } };
|
||||
export type ProposalQuery = { __typename?: 'Query', proposal?: { __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, datetime: string, rejectionReason?: Types.ProposalRejectionReason | null, errorDetails?: string | null, party: { __typename?: 'Party', id: string }, terms: { __typename?: 'ProposalTerms', closingDatetime: string, enactmentDatetime?: string | null, change: { __typename: 'NewAsset', name: string, symbol: string, source: { __typename: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename: 'ERC20', contractAddress: string } } | { __typename?: 'NewFreeform' } | { __typename?: 'NewMarket', decimalPlaces: number, metadata?: Array<string> | null, instrument: { __typename?: 'InstrumentConfiguration', name: string, code: string, futureProduct?: { __typename?: 'FutureProduct', settlementAsset: { __typename?: 'Asset', symbol: string } } | null } } | { __typename?: 'UpdateAsset' } | { __typename?: 'UpdateMarket', marketId: string } | { __typename?: 'UpdateNetworkParameter', networkParameter: { __typename?: 'NetworkParameter', key: string, value: string } } }, votes: { __typename?: 'ProposalVotes', yes: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, votes?: Array<{ __typename?: 'Vote', value: Types.VoteValue, datetime: string, party: { __typename?: 'Party', id: string, stake: { __typename?: 'PartyStake', currentStakeAvailable: string } } }> | null }, no: { __typename?: 'ProposalVoteSide', totalTokens: string, totalNumber: string, votes?: Array<{ __typename?: 'Vote', value: Types.VoteValue, datetime: string, party: { __typename?: 'Party', id: string, stake: { __typename?: 'PartyStake', currentStakeAvailable: string } } }> | null } } } | null };
|
||||
|
||||
export type ProposalsQueryVariables = Types.Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
@ -48,7 +48,7 @@ export interface Proposal_proposal_terms_change_NewMarket_instrument_futureProdu
|
||||
export interface Proposal_proposal_terms_change_NewMarket_instrument_futureProduct {
|
||||
__typename: "FutureProduct";
|
||||
/**
|
||||
* Product asset ID
|
||||
* Product asset
|
||||
*/
|
||||
settlementAsset: Proposal_proposal_terms_change_NewMarket_instrument_futureProduct_settlementAsset;
|
||||
}
|
||||
@ -293,7 +293,7 @@ export interface Proposal_proposal {
|
||||
*/
|
||||
datetime: string;
|
||||
/**
|
||||
* Reason for the proposal to be rejected by the core
|
||||
* Why the proposal was rejected by the core
|
||||
*/
|
||||
rejectionReason: ProposalRejectionReason | null;
|
||||
/**
|
||||
@ -318,7 +318,7 @@ export interface Proposal {
|
||||
/**
|
||||
* A governance proposal located by either its ID or reference. If both are set, ID is used.
|
||||
*/
|
||||
proposal: Proposal_proposal;
|
||||
proposal: Proposal_proposal | null;
|
||||
}
|
||||
|
||||
export interface ProposalVariables {
|
||||
|
@ -37,7 +37,7 @@ export const ProposalContainer = () => {
|
||||
|
||||
return (
|
||||
<AsyncRenderer loading={loading} error={error} data={data}>
|
||||
{data && <Proposal proposal={data.proposal} />}
|
||||
{data && data.proposal && <Proposal proposal={data.proposal} />}
|
||||
</AsyncRenderer>
|
||||
);
|
||||
};
|
||||
|
@ -48,7 +48,7 @@ export interface Proposals_proposalsConnection_edges_node_terms_change_NewMarket
|
||||
export interface Proposals_proposalsConnection_edges_node_terms_change_NewMarket_instrument_futureProduct {
|
||||
__typename: "FutureProduct";
|
||||
/**
|
||||
* Product asset ID
|
||||
* Product asset
|
||||
*/
|
||||
settlementAsset: Proposals_proposalsConnection_edges_node_terms_change_NewMarket_instrument_futureProduct_settlementAsset;
|
||||
}
|
||||
@ -293,7 +293,7 @@ export interface Proposals_proposalsConnection_edges_node {
|
||||
*/
|
||||
datetime: string;
|
||||
/**
|
||||
* Reason for the proposal to be rejected by the core
|
||||
* Why the proposal was rejected by the core
|
||||
*/
|
||||
rejectionReason: ProposalRejectionReason | null;
|
||||
/**
|
||||
@ -334,5 +334,5 @@ export interface Proposals {
|
||||
/**
|
||||
* All governance proposals in the Vega network
|
||||
*/
|
||||
proposalsConnection: Proposals_proposalsConnection;
|
||||
proposalsConnection: Proposals_proposalsConnection | null;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ export interface NodeData_nodeData {
|
||||
|
||||
export interface NodeData {
|
||||
/**
|
||||
* returns information about nodes
|
||||
* Returns information about nodes
|
||||
*/
|
||||
nodeData: NodeData_nodeData | null;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ export interface Rewards_party_rewardDetails_rewards_party {
|
||||
export interface Rewards_party_rewardDetails_rewards_epoch {
|
||||
__typename: "Epoch";
|
||||
/**
|
||||
* Presumably this is an integer or something. If there's no such thing, disregard
|
||||
* Numeric sequence number used to identify the epoch
|
||||
*/
|
||||
id: string;
|
||||
}
|
||||
@ -124,7 +124,7 @@ export interface Rewards_party {
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* return reward information
|
||||
* Return reward information
|
||||
*/
|
||||
rewardDetails: (Rewards_party_rewardDetails | null)[] | null;
|
||||
delegations: Rewards_party_delegations[] | null;
|
||||
@ -149,7 +149,7 @@ export interface Rewards_epoch_timestamps {
|
||||
export interface Rewards_epoch {
|
||||
__typename: "Epoch";
|
||||
/**
|
||||
* Presumably this is an integer or something. If there's no such thing, disregard
|
||||
* Numeric sequence number used to identify the epoch
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
@ -164,7 +164,7 @@ export interface Rewards {
|
||||
*/
|
||||
party: Rewards_party | null;
|
||||
/**
|
||||
* get data for a specific epoch, if ID omitted it gets the current epoch. If the string is 'next', fetch the next epoch
|
||||
* Get data for a specific epoch, if ID omitted it gets the current epoch. If the string is 'next', fetch the next epoch
|
||||
*/
|
||||
epoch: Rewards_epoch;
|
||||
}
|
||||
|
@ -81,11 +81,11 @@ export interface Nodes_nodeData {
|
||||
|
||||
export interface Nodes {
|
||||
/**
|
||||
* all known network nodes
|
||||
* All known network nodes
|
||||
*/
|
||||
nodes: Nodes_nodes[] | null;
|
||||
/**
|
||||
* returns information about nodes
|
||||
* Returns information about nodes
|
||||
*/
|
||||
nodeData: Nodes_nodeData | null;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ export interface PartyDelegations_party {
|
||||
export interface PartyDelegations_epoch {
|
||||
__typename: "Epoch";
|
||||
/**
|
||||
* Presumably this is an integer or something. If there's no such thing, disregard
|
||||
* Numeric sequence number used to identify the epoch
|
||||
*/
|
||||
id: string;
|
||||
}
|
||||
@ -58,7 +58,7 @@ export interface PartyDelegations {
|
||||
*/
|
||||
party: PartyDelegations_party | null;
|
||||
/**
|
||||
* get data for a specific epoch, if ID omitted it gets the current epoch. If the string is 'next', fetch the next epoch
|
||||
* Get data for a specific epoch, if ID omitted it gets the current epoch. If the string is 'next', fetch the next epoch
|
||||
*/
|
||||
epoch: PartyDelegations_epoch;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ export interface Staking_epoch_timestamps {
|
||||
export interface Staking_epoch {
|
||||
__typename: "Epoch";
|
||||
/**
|
||||
* Presumably this is an integer or something. If there's no such thing, disregard
|
||||
* Numeric sequence number used to identify the epoch
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
@ -181,7 +181,13 @@ export interface Staking_nodes {
|
||||
* The pending staked field formatted by the client
|
||||
*/
|
||||
pendingStakeFormatted: string;
|
||||
/**
|
||||
* Summary of epoch data across all nodes
|
||||
*/
|
||||
epochData: Staking_nodes_epochData | null;
|
||||
/**
|
||||
* Validator status of the node
|
||||
*/
|
||||
status: NodeStatus;
|
||||
/**
|
||||
* Ranking scores and status for the validator for the current epoch
|
||||
@ -223,15 +229,15 @@ export interface Staking {
|
||||
*/
|
||||
party: Staking_party | null;
|
||||
/**
|
||||
* get data for a specific epoch, if ID omitted it gets the current epoch. If the string is 'next', fetch the next epoch
|
||||
* Get data for a specific epoch, if ID omitted it gets the current epoch. If the string is 'next', fetch the next epoch
|
||||
*/
|
||||
epoch: Staking_epoch;
|
||||
/**
|
||||
* all known network nodes
|
||||
* All known network nodes
|
||||
*/
|
||||
nodes: Staking_nodes[] | null;
|
||||
/**
|
||||
* returns information about nodes
|
||||
* Returns information about nodes
|
||||
*/
|
||||
nodeData: Staking_nodeData | null;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ beforeEach(() => {
|
||||
|
||||
describe('accounts', () => {
|
||||
it('renders accounts', () => {
|
||||
const tradingAccountRowId = '[row-id="ACCOUNT_TYPE_GENERAL-tEURO-null"]';
|
||||
const tradingAccountRowId = '[row-id="ACCOUNT_TYPE_GENERAL-asset-id-null"]';
|
||||
cy.getByTestId('Collateral').click();
|
||||
cy.getByTestId('tab-accounts').contains('Please connect Vega wallet');
|
||||
|
||||
|
@ -1,76 +1,14 @@
|
||||
import { aliasQuery } from '@vegaprotocol/cypress';
|
||||
import { generateFill, generateFills } from '../support/mocks/generate-fills';
|
||||
import { Side } from '@vegaprotocol/types';
|
||||
import { generateFills } from '../support/mocks/generate-fills';
|
||||
import { MarketState } from '@vegaprotocol/types';
|
||||
import { connectVegaWallet } from '../support/vega-wallet';
|
||||
import { mockTradingPage } from '../support/trading';
|
||||
import { generateNetworkParameters } from '../support/mocks/generate-network-parameters';
|
||||
|
||||
const fills = [
|
||||
generateFill({
|
||||
buyer: {
|
||||
id: Cypress.env('VEGA_PUBLIC_KEY'),
|
||||
},
|
||||
}),
|
||||
generateFill({
|
||||
id: '1',
|
||||
seller: {
|
||||
id: Cypress.env('VEGA_PUBLIC_KEY'),
|
||||
},
|
||||
aggressor: Side.SIDE_SELL,
|
||||
buyerFee: {
|
||||
infrastructureFee: '5000',
|
||||
},
|
||||
market: {
|
||||
tradableInstrument: {
|
||||
instrument: {
|
||||
name: 'Apples Daily v3',
|
||||
},
|
||||
},
|
||||
positionDecimalPlaces: 2,
|
||||
},
|
||||
}),
|
||||
generateFill({
|
||||
id: '2',
|
||||
seller: {
|
||||
id: Cypress.env('VEGA_PUBLIC_KEY'),
|
||||
},
|
||||
aggressor: Side.SIDE_BUY,
|
||||
}),
|
||||
generateFill({
|
||||
id: '3',
|
||||
aggressor: Side.SIDE_SELL,
|
||||
market: {
|
||||
tradableInstrument: {
|
||||
instrument: {
|
||||
name: 'ETHBTC Quarterly (30 Jun 2022)',
|
||||
},
|
||||
},
|
||||
},
|
||||
buyer: {
|
||||
id: Cypress.env('VEGA_PUBLIC_KEY'),
|
||||
},
|
||||
}),
|
||||
];
|
||||
const result = generateFills({
|
||||
party: {
|
||||
tradesConnection: {
|
||||
edges: fills.map((f, i) => {
|
||||
return {
|
||||
__typename: 'TradeEdge',
|
||||
node: f,
|
||||
cursor: i.toString(),
|
||||
};
|
||||
}),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
describe('fills', () => {
|
||||
beforeEach(() => {
|
||||
cy.mockGQL((req) => {
|
||||
aliasQuery(req, 'Fills', result);
|
||||
aliasQuery(req, 'NetworkParamsQuery', generateNetworkParameters());
|
||||
mockTradingPage(req, MarketState.STATE_ACTIVE);
|
||||
aliasQuery(req, 'Fills', generateFills());
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -86,11 +86,11 @@ describe('orders', () => {
|
||||
|
||||
it('orders are sorted by most recent order', () => {
|
||||
const expectedOrderList = [
|
||||
'AAVEDAI.MF21',
|
||||
'TSLA.QM21',
|
||||
'BTCUSD.MF21',
|
||||
'UNIDAI.MF21',
|
||||
'UNIDAI.MF21',
|
||||
'SOLUSD',
|
||||
'AAPL.MF21',
|
||||
'ETHBTC.QM21',
|
||||
'ETHBTC.QM21',
|
||||
];
|
||||
|
||||
cy.getByTestId('tab-orders')
|
||||
|
@ -10,7 +10,7 @@ export const generateCandles = (
|
||||
): CandlesQuery => {
|
||||
const candles: CandleFieldsFragment[] = [
|
||||
{
|
||||
timestamp: '1661515200000000000',
|
||||
periodStart: '1661515200000000000',
|
||||
high: '17481092',
|
||||
low: '17403651',
|
||||
open: '17458833',
|
||||
@ -19,7 +19,7 @@ export const generateCandles = (
|
||||
__typename: 'Candle',
|
||||
},
|
||||
{
|
||||
timestamp: '1661516100000000000',
|
||||
periodStart: '1661516100000000000',
|
||||
high: '17491202',
|
||||
low: '17361138',
|
||||
open: '17446470',
|
||||
@ -28,7 +28,7 @@ export const generateCandles = (
|
||||
__typename: 'Candle',
|
||||
},
|
||||
{
|
||||
timestamp: '1661517000000000000',
|
||||
periodStart: '1661517000000000000',
|
||||
high: '17424522',
|
||||
low: '17337719',
|
||||
open: '17367174',
|
||||
@ -37,7 +37,7 @@ export const generateCandles = (
|
||||
__typename: 'Candle',
|
||||
},
|
||||
];
|
||||
const defaultResult = {
|
||||
const defaultResult: CandlesQuery = {
|
||||
market: {
|
||||
id: 'market-0',
|
||||
decimalPlaces: 5,
|
||||
@ -50,7 +50,11 @@ export const generateCandles = (
|
||||
},
|
||||
__typename: 'TradableInstrument',
|
||||
},
|
||||
candles,
|
||||
candlesConnection: {
|
||||
edges: candles.map((node) => ({
|
||||
node,
|
||||
})),
|
||||
},
|
||||
__typename: 'Market',
|
||||
},
|
||||
};
|
||||
|
@ -23,12 +23,7 @@ export const generateFills = (override?: PartialDeep<Fills>): Fills => {
|
||||
infrastructureFee: '5000',
|
||||
},
|
||||
market: {
|
||||
tradableInstrument: {
|
||||
instrument: {
|
||||
name: 'Apples Daily v3',
|
||||
},
|
||||
},
|
||||
positionDecimalPlaces: 2,
|
||||
id: 'market-1',
|
||||
},
|
||||
}),
|
||||
generateFill({
|
||||
@ -42,11 +37,7 @@ export const generateFills = (override?: PartialDeep<Fills>): Fills => {
|
||||
id: '3',
|
||||
aggressor: Side.SIDE_SELL,
|
||||
market: {
|
||||
tradableInstrument: {
|
||||
instrument: {
|
||||
name: 'ETHBTC Quarterly (30 Jun 2022)',
|
||||
},
|
||||
},
|
||||
id: 'market-2',
|
||||
},
|
||||
buyer: {
|
||||
id: Cypress.env('VEGA_PUBLIC_KEY'),
|
||||
@ -115,27 +106,7 @@ export const generateFill = (
|
||||
},
|
||||
market: {
|
||||
__typename: 'Market',
|
||||
id: 'market-id',
|
||||
positionDecimalPlaces: 0,
|
||||
decimalPlaces: 5,
|
||||
tradableInstrument: {
|
||||
__typename: 'TradableInstrument',
|
||||
instrument: {
|
||||
__typename: 'Instrument',
|
||||
id: 'instrument-id',
|
||||
code: 'instrument-code',
|
||||
name: 'UNIDAI Monthly (30 Jun 2022)',
|
||||
product: {
|
||||
__typename: 'Future',
|
||||
settlementAsset: {
|
||||
__typename: 'Asset',
|
||||
id: 'asset-id',
|
||||
symbol: 'SYM',
|
||||
decimals: 18,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
id: 'market-0',
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -71,13 +71,6 @@ export const generateMarketInfoQuery = (
|
||||
],
|
||||
},
|
||||
},
|
||||
riskFactors: {
|
||||
__typename: 'RiskFactor',
|
||||
market:
|
||||
'54b78c1b877e106842ae156332ccec740ad98d6bad43143ac6a029501dd7c6e0',
|
||||
short: '0.008571790367285281',
|
||||
long: '0.008508132993273576',
|
||||
},
|
||||
data: {
|
||||
__typename: 'MarketData',
|
||||
market: {
|
||||
@ -120,7 +113,7 @@ export const generateMarketInfoQuery = (
|
||||
},
|
||||
__typename: 'LiquidityMonitoringParameters',
|
||||
},
|
||||
candles: [],
|
||||
candlesConnection: null,
|
||||
tradableInstrument: {
|
||||
__typename: 'TradableInstrument',
|
||||
instrument: {
|
||||
|
@ -18,7 +18,7 @@ export const generateMarket = (override?: PartialDeep<Market>): Market => {
|
||||
positionDecimalPlaces: 0,
|
||||
data: {
|
||||
market: {
|
||||
id: '10cd0a793ad2887b340940337fa6d97a212e0e517fe8e9eab2b5ef3a38633f35',
|
||||
id: 'market-0',
|
||||
__typename: 'Market',
|
||||
},
|
||||
auctionStart: '2022-08-12T11:13:47.611014117Z',
|
||||
@ -75,20 +75,29 @@ export const generateMarket = (override?: PartialDeep<Market>): Market => {
|
||||
close: null,
|
||||
__typename: 'MarketTimestamps',
|
||||
},
|
||||
candles: [
|
||||
candlesConnection: {
|
||||
__typename: 'CandleDataConnection',
|
||||
edges: [
|
||||
{
|
||||
__typename: 'CandleEdge',
|
||||
node: {
|
||||
open: '2095312844',
|
||||
close: '2090090607',
|
||||
volume: '4847',
|
||||
__typename: 'Candle',
|
||||
},
|
||||
},
|
||||
{
|
||||
__typename: 'CandleEdge',
|
||||
node: {
|
||||
open: '2090090000',
|
||||
close: '2090090607',
|
||||
volume: '4847',
|
||||
__typename: 'Candle',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
__typename: 'Market',
|
||||
},
|
||||
};
|
||||
|
@ -48,8 +48,10 @@ export const generateMarkets = (override?: PartialDeep<Markets>): Markets => {
|
||||
product: {
|
||||
settlementAsset: {
|
||||
symbol: 'tDAI',
|
||||
decimals: 5,
|
||||
__typename: 'Asset',
|
||||
},
|
||||
quoteName: 'DAI',
|
||||
__typename: 'Future',
|
||||
},
|
||||
__typename: 'Instrument',
|
||||
@ -90,8 +92,10 @@ export const generateMarkets = (override?: PartialDeep<Markets>): Markets => {
|
||||
product: {
|
||||
settlementAsset: {
|
||||
symbol: 'XYZalpha',
|
||||
decimals: 5,
|
||||
__typename: 'Asset',
|
||||
},
|
||||
quoteName: 'USD',
|
||||
__typename: 'Future',
|
||||
},
|
||||
__typename: 'Instrument',
|
||||
@ -132,8 +136,10 @@ export const generateMarkets = (override?: PartialDeep<Markets>): Markets => {
|
||||
product: {
|
||||
settlementAsset: {
|
||||
symbol: 'tUSDC',
|
||||
decimals: 5,
|
||||
__typename: 'Asset',
|
||||
},
|
||||
quoteName: 'USDC',
|
||||
__typename: 'Future',
|
||||
},
|
||||
__typename: 'Instrument',
|
||||
@ -174,8 +180,10 @@ export const generateMarkets = (override?: PartialDeep<Markets>): Markets => {
|
||||
product: {
|
||||
settlementAsset: {
|
||||
symbol: 'tBTC',
|
||||
decimals: 5,
|
||||
__typename: 'Asset',
|
||||
},
|
||||
quoteName: 'BTC',
|
||||
__typename: 'Future',
|
||||
},
|
||||
__typename: 'Instrument',
|
||||
@ -311,7 +319,7 @@ export const generateMarketsCandles = (
|
||||
{
|
||||
__typename: 'CandleEdge',
|
||||
node: {
|
||||
__typename: 'CandleNode',
|
||||
__typename: 'Candle',
|
||||
open: '100',
|
||||
close: '100',
|
||||
high: '110',
|
||||
@ -331,7 +339,7 @@ export const generateMarketsCandles = (
|
||||
{
|
||||
__typename: 'CandleEdge',
|
||||
node: {
|
||||
__typename: 'CandleNode',
|
||||
__typename: 'Candle',
|
||||
open: '100',
|
||||
close: '100',
|
||||
high: '110',
|
||||
@ -351,7 +359,7 @@ export const generateMarketsCandles = (
|
||||
{
|
||||
__typename: 'CandleEdge',
|
||||
node: {
|
||||
__typename: 'CandleNode',
|
||||
__typename: 'Candle',
|
||||
open: '100',
|
||||
close: '100',
|
||||
high: '110',
|
||||
@ -371,7 +379,7 @@ export const generateMarketsCandles = (
|
||||
{
|
||||
__typename: 'CandleEdge',
|
||||
node: {
|
||||
__typename: 'CandleNode',
|
||||
__typename: 'Candle',
|
||||
open: '100',
|
||||
close: '100',
|
||||
high: '110',
|
||||
|
@ -18,18 +18,7 @@ export const generateOrders = (override?: PartialDeep<Orders>): Orders => {
|
||||
id: '066468C06549101DAF7BC51099E1412A0067DC08C246B7D8013C9D0CBF1E8EE7',
|
||||
market: {
|
||||
__typename: 'Market',
|
||||
id: 'c9f5acd348796011c075077e4d58d9b7f1689b7c1c8e030a5e886b83aa96923d',
|
||||
decimalPlaces: 5,
|
||||
positionDecimalPlaces: 0,
|
||||
tradableInstrument: {
|
||||
__typename: 'TradableInstrument',
|
||||
instrument: {
|
||||
id: '',
|
||||
__typename: 'Instrument',
|
||||
code: 'AAVEDAI.MF21',
|
||||
name: 'AAVEDAI Monthly (30 Jun 2022)',
|
||||
},
|
||||
},
|
||||
id: 'market-0',
|
||||
},
|
||||
size: '10',
|
||||
type: OrderType.TYPE_LIMIT,
|
||||
@ -48,18 +37,7 @@ export const generateOrders = (override?: PartialDeep<Orders>): Orders => {
|
||||
id: '48DB6767E4E4E0F649C5A13ABFADE39F8451C27DA828DAF14B7A1E8E5EBDAD99',
|
||||
market: {
|
||||
__typename: 'Market',
|
||||
id: '5a4b0b9e9c0629f0315ec56fcb7bd444b0c6e4da5ec7677719d502626658a376',
|
||||
decimalPlaces: 5,
|
||||
positionDecimalPlaces: 0,
|
||||
tradableInstrument: {
|
||||
__typename: 'TradableInstrument',
|
||||
instrument: {
|
||||
id: '',
|
||||
__typename: 'Instrument',
|
||||
code: 'TSLA.QM21',
|
||||
name: 'Tesla Quarterly (30 Jun 2022)',
|
||||
},
|
||||
},
|
||||
id: 'market-1',
|
||||
},
|
||||
size: '1',
|
||||
type: OrderType.TYPE_LIMIT,
|
||||
@ -78,19 +56,7 @@ export const generateOrders = (override?: PartialDeep<Orders>): Orders => {
|
||||
id: '4e93702990712c41f6995fcbbd94f60bb372ad12d64dfa7d96d205c49f790336',
|
||||
market: {
|
||||
__typename: 'Market',
|
||||
id: 'c6f4337b31ed57a961969c3ba10297b369d01b9e75a4cbb96db4fc62886444e6',
|
||||
|
||||
decimalPlaces: 5,
|
||||
positionDecimalPlaces: 0,
|
||||
tradableInstrument: {
|
||||
__typename: 'TradableInstrument',
|
||||
instrument: {
|
||||
id: '',
|
||||
__typename: 'Instrument',
|
||||
code: 'BTCUSD.MF21',
|
||||
name: 'BTCUSD Monthly (30 Jun 2022)',
|
||||
},
|
||||
},
|
||||
id: 'market-2',
|
||||
},
|
||||
size: '1',
|
||||
type: OrderType.TYPE_LIMIT,
|
||||
@ -109,18 +75,7 @@ export const generateOrders = (override?: PartialDeep<Orders>): Orders => {
|
||||
id: '94737d2bafafa4bc3b80a56ef084ae52a983b91aa067c31e243c61a0f962a836',
|
||||
market: {
|
||||
__typename: 'Market',
|
||||
id: 'a316fa51dab97d76a1472c2f22906f4e461728e04355096788165d5b13999ed5',
|
||||
decimalPlaces: 5,
|
||||
positionDecimalPlaces: 0,
|
||||
tradableInstrument: {
|
||||
__typename: 'TradableInstrument',
|
||||
instrument: {
|
||||
id: '',
|
||||
__typename: 'Instrument',
|
||||
code: 'UNIDAI.MF21',
|
||||
name: 'UNIDAI Monthly (30 Jun 2022)',
|
||||
},
|
||||
},
|
||||
id: 'market-3',
|
||||
},
|
||||
size: '1',
|
||||
type: OrderType.TYPE_LIMIT,
|
||||
@ -139,18 +94,7 @@ export const generateOrders = (override?: PartialDeep<Orders>): Orders => {
|
||||
id: '94aead3ca92dc932efcb503631b03a410e2a5d4606cae6083e2406dc38e52f78',
|
||||
market: {
|
||||
__typename: 'Market',
|
||||
id: 'a316fa51dab97d76a1472c2f22906f4e461728e04355096788165d5b13999ed5',
|
||||
decimalPlaces: 5,
|
||||
positionDecimalPlaces: 0,
|
||||
tradableInstrument: {
|
||||
__typename: 'TradableInstrument',
|
||||
instrument: {
|
||||
id: '',
|
||||
__typename: 'Instrument',
|
||||
code: 'UNIDAI.MF21',
|
||||
name: 'UNIDAI Monthly (30 Jun 2022)',
|
||||
},
|
||||
},
|
||||
id: 'market-3',
|
||||
},
|
||||
size: '10',
|
||||
type: OrderType.TYPE_LIMIT,
|
||||
|
@ -13,9 +13,7 @@ export const generateTrades = (override?: PartialDeep<Trades>): Trades => {
|
||||
size: '24',
|
||||
createdAt: '2022-04-06T16:19:42.692598951Z',
|
||||
market: {
|
||||
id: '0c3c1490db767f926d24fb674b4235a9aa339614915a4ab96cbfc0e1ad83c0ff',
|
||||
decimalPlaces: 5,
|
||||
positionDecimalPlaces: 0,
|
||||
id: 'market-0',
|
||||
__typename: 'Market',
|
||||
},
|
||||
__typename: 'Trade',
|
||||
@ -26,9 +24,7 @@ export const generateTrades = (override?: PartialDeep<Trades>): Trades => {
|
||||
size: '7',
|
||||
createdAt: '2022-04-07T06:59:44.835686754Z',
|
||||
market: {
|
||||
id: '0c3c1490db767f926d24fb674b4235a9aa339614915a4ab96cbfc0e1ad83c0ff',
|
||||
decimalPlaces: 5,
|
||||
positionDecimalPlaces: 0,
|
||||
id: 'market-0',
|
||||
__typename: 'Market',
|
||||
},
|
||||
__typename: 'Trade',
|
||||
@ -39,9 +35,7 @@ export const generateTrades = (override?: PartialDeep<Trades>): Trades => {
|
||||
size: '18',
|
||||
createdAt: '2022-04-07T17:56:47.997938583Z',
|
||||
market: {
|
||||
id: '0c3c1490db767f926d24fb674b4235a9aa339614915a4ab96cbfc0e1ad83c0ff',
|
||||
decimalPlaces: 5,
|
||||
positionDecimalPlaces: 0,
|
||||
id: 'market-0',
|
||||
__typename: 'Market',
|
||||
},
|
||||
__typename: 'Trade',
|
||||
|
@ -15,7 +15,9 @@ export const PageQueryContainer = <TData, TVariables = OperationVariables>({
|
||||
options,
|
||||
render,
|
||||
}: PageQueryContainerProps<TData, TVariables>) => {
|
||||
const { data, loading, error } = useQuery<TData, TVariables>(query, options);
|
||||
const { data, loading, error } = useQuery<TData, TVariables>(query, {
|
||||
...options,
|
||||
});
|
||||
|
||||
return (
|
||||
<AsyncRenderer<TData>
|
||||
|
@ -1,7 +1,6 @@
|
||||
query Market($marketId: ID!, $interval: Interval!, $since: String!) {
|
||||
market(id: $marketId) {
|
||||
id
|
||||
name
|
||||
tradingMode
|
||||
state
|
||||
decimalPlaces
|
||||
@ -51,10 +50,14 @@ query Market($marketId: ID!, $interval: Interval!, $since: String!) {
|
||||
open
|
||||
close
|
||||
}
|
||||
candles(interval: $interval, since: $since) {
|
||||
candlesConnection(interval: $interval, since: $since) {
|
||||
edges {
|
||||
node {
|
||||
open
|
||||
close
|
||||
volume
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,13 +65,17 @@ const MARKET_QUERY = gql`
|
||||
open
|
||||
close
|
||||
}
|
||||
candles(interval: $interval, since: $since) {
|
||||
candlesConnection(interval: $interval, since: $since) {
|
||||
edges {
|
||||
node {
|
||||
open
|
||||
close
|
||||
volume
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const MarketPage = ({ id }: { id?: string }) => {
|
||||
|
50
apps/trading/pages/markets/__generated__/Market.ts
generated
50
apps/trading/pages/markets/__generated__/Market.ts
generated
@ -20,7 +20,7 @@ export interface Market_market_data_market {
|
||||
export interface Market_market_data {
|
||||
__typename: "MarketData";
|
||||
/**
|
||||
* market ID of the associated mark price
|
||||
* Market of the associated mark price
|
||||
*/
|
||||
market: Market_market_data_market;
|
||||
/**
|
||||
@ -32,43 +32,43 @@ export interface Market_market_data {
|
||||
*/
|
||||
auctionEnd: string | null;
|
||||
/**
|
||||
* the mark price (an unsigned integer)
|
||||
* The mark price (an unsigned integer)
|
||||
*/
|
||||
markPrice: string;
|
||||
/**
|
||||
* indicative volume if the auction ended now, 0 if not in auction mode
|
||||
* Indicative volume if the auction ended now, 0 if not in auction mode
|
||||
*/
|
||||
indicativeVolume: string;
|
||||
/**
|
||||
* indicative price if the auction ended now, 0 if not in auction mode
|
||||
* Indicative price if the auction ended now, 0 if not in auction mode
|
||||
*/
|
||||
indicativePrice: string;
|
||||
/**
|
||||
* the supplied stake for the market
|
||||
* The supplied stake for the market
|
||||
*/
|
||||
suppliedStake: string | null;
|
||||
/**
|
||||
* the amount of stake targeted for this market
|
||||
* The amount of stake targeted for this market
|
||||
*/
|
||||
targetStake: string | null;
|
||||
/**
|
||||
* the aggregated volume being bid at the best bid price.
|
||||
* The aggregated volume being bid at the best bid price.
|
||||
*/
|
||||
bestBidVolume: string;
|
||||
/**
|
||||
* the aggregated volume being offered at the best offer price.
|
||||
* The aggregated volume being offered at the best offer price.
|
||||
*/
|
||||
bestOfferVolume: string;
|
||||
/**
|
||||
* the aggregated volume being offered at the best static bid price, excluding pegged orders
|
||||
* The aggregated volume being offered at the best static bid price, excluding pegged orders
|
||||
*/
|
||||
bestStaticBidVolume: string;
|
||||
/**
|
||||
* the aggregated volume being offered at the best static offer price, excluding pegged orders.
|
||||
* The aggregated volume being offered at the best static offer price, excluding pegged orders.
|
||||
*/
|
||||
bestStaticOfferVolume: string;
|
||||
/**
|
||||
* what triggered an auction (if an auction was started)
|
||||
* What triggered an auction (if an auction was started)
|
||||
*/
|
||||
trigger: AuctionTrigger;
|
||||
}
|
||||
@ -169,7 +169,7 @@ export interface Market_market_marketTimestamps {
|
||||
close: string | null;
|
||||
}
|
||||
|
||||
export interface Market_market_candles {
|
||||
export interface Market_market_candlesConnection_edges_node {
|
||||
__typename: "Candle";
|
||||
/**
|
||||
* Open price (uint64)
|
||||
@ -185,6 +185,22 @@ export interface Market_market_candles {
|
||||
volume: string;
|
||||
}
|
||||
|
||||
export interface Market_market_candlesConnection_edges {
|
||||
__typename: "CandleEdge";
|
||||
/**
|
||||
* The candle
|
||||
*/
|
||||
node: Market_market_candlesConnection_edges_node;
|
||||
}
|
||||
|
||||
export interface Market_market_candlesConnection {
|
||||
__typename: "CandleDataConnection";
|
||||
/**
|
||||
* The candles
|
||||
*/
|
||||
edges: (Market_market_candlesConnection_edges | null)[] | null;
|
||||
}
|
||||
|
||||
export interface Market_market {
|
||||
__typename: "Market";
|
||||
/**
|
||||
@ -200,7 +216,7 @@ export interface Market_market {
|
||||
*/
|
||||
state: MarketState;
|
||||
/**
|
||||
* decimalPlaces indicates the number of decimal places that an integer must be shifted by in order to get a correct
|
||||
* The number of decimal places that an integer must be shifted by in order to get a correct
|
||||
* number denominated in the currency of the market. (uint64)
|
||||
*
|
||||
* Examples:
|
||||
@ -217,7 +233,7 @@ export interface Market_market {
|
||||
*/
|
||||
decimalPlaces: number;
|
||||
/**
|
||||
* positionDecimalPlaces indicates the number of decimal places that an integer must be shifted in order to get a correct size (uint64).
|
||||
* The number of decimal places that an integer must be shifted in order to get a correct size (uint64).
|
||||
* i.e. 0 means there are no fractional orders for the market, and order sizes are always whole sizes.
|
||||
* 2 means sizes given as 10^2 * desired size, e.g. a desired size of 1.23 is represented as 123 in this market.
|
||||
* This sets how big the smallest order / position on the market can be.
|
||||
@ -232,13 +248,13 @@ export interface Market_market {
|
||||
*/
|
||||
tradableInstrument: Market_market_tradableInstrument;
|
||||
/**
|
||||
* timestamps for state changes in the market
|
||||
* Timestamps for state changes in the market
|
||||
*/
|
||||
marketTimestamps: Market_market_marketTimestamps;
|
||||
/**
|
||||
* Candles on a market, for the 'last' n candles, at 'interval' seconds as specified by parameters
|
||||
* Candles on a market, for the 'last' n candles, at 'interval' seconds as specified by parameters using cursor based pagination
|
||||
*/
|
||||
candles: (Market_market_candles | null)[] | null;
|
||||
candlesConnection: Market_market_candlesConnection | null;
|
||||
}
|
||||
|
||||
export interface Market {
|
||||
|
@ -10,14 +10,13 @@ export type MarketQueryVariables = Types.Exact<{
|
||||
}>;
|
||||
|
||||
|
||||
export type MarketQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, name: string, tradingMode: Types.MarketTradingMode, state: Types.MarketState, decimalPlaces: number, positionDecimalPlaces: number, data?: { __typename?: 'MarketData', auctionStart?: string | null, auctionEnd?: string | null, markPrice: string, indicativeVolume: string, indicativePrice: string, suppliedStake?: string | null, targetStake?: string | null, bestBidVolume: string, bestOfferVolume: string, bestStaticBidVolume: string, bestStaticOfferVolume: string, trigger: Types.AuctionTrigger, market: { __typename?: 'Market', id: string } } | null, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null }, product: { __typename?: 'Future', quoteName: string, oracleSpecForTradingTermination: { __typename?: 'OracleSpec', id: string }, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string } } } }, marketTimestamps: { __typename?: 'MarketTimestamps', open?: string | null, close?: string | null }, candles?: Array<{ __typename?: 'Candle', open: string, close: string, volume: string } | null> | null } | null };
|
||||
export type MarketQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, tradingMode: Types.MarketTradingMode, state: Types.MarketState, decimalPlaces: number, positionDecimalPlaces: number, data?: { __typename?: 'MarketData', auctionStart?: string | null, auctionEnd?: string | null, markPrice: string, indicativeVolume: string, indicativePrice: string, suppliedStake?: string | null, targetStake?: string | null, bestBidVolume: string, bestOfferVolume: string, bestStaticBidVolume: string, bestStaticOfferVolume: string, trigger: Types.AuctionTrigger, market: { __typename?: 'Market', id: string } } | null, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null }, product: { __typename?: 'Future', quoteName: string, oracleSpecForTradingTermination: { __typename?: 'OracleSpec', id: string }, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number } } } }, marketTimestamps: { __typename?: 'MarketTimestamps', open?: string | null, close?: string | null }, candlesConnection?: { __typename?: 'CandleDataConnection', edges?: Array<{ __typename?: 'CandleEdge', node: { __typename?: 'Candle', open: string, close: string, volume: string } } | null> | null } | null } | null };
|
||||
|
||||
|
||||
export const MarketDocument = gql`
|
||||
query Market($marketId: ID!, $interval: Interval!, $since: String!) {
|
||||
market(id: $marketId) {
|
||||
id
|
||||
name
|
||||
tradingMode
|
||||
state
|
||||
decimalPlaces
|
||||
@ -57,6 +56,7 @@ export const MarketDocument = gql`
|
||||
id
|
||||
symbol
|
||||
name
|
||||
decimals
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -66,12 +66,16 @@ export const MarketDocument = gql`
|
||||
open
|
||||
close
|
||||
}
|
||||
candles(interval: $interval, since: $since) {
|
||||
candlesConnection(interval: $interval, since: $since) {
|
||||
edges {
|
||||
node {
|
||||
open
|
||||
close
|
||||
volume
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
|
@ -121,8 +121,8 @@ export const TradeMarketHeader = ({
|
||||
const { setAssetDetailsDialogOpen, setAssetDetailsDialogSymbol } =
|
||||
useAssetDetailsDialogStore();
|
||||
|
||||
const candlesClose: string[] = (market?.candles || [])
|
||||
.map((candle) => candle?.close)
|
||||
const candlesClose: string[] = (market?.candlesConnection?.edges || [])
|
||||
.map((candle) => candle?.node.close)
|
||||
.filter((c): c is CandleClose => c !== null);
|
||||
const symbol =
|
||||
market.tradableInstrument.instrument.product?.settlementAsset?.symbol;
|
||||
|
@ -53,6 +53,9 @@ export interface DepositPage_assetsConnection_edges_node {
|
||||
|
||||
export interface DepositPage_assetsConnection_edges {
|
||||
__typename: "AssetEdge";
|
||||
/**
|
||||
* The asset information
|
||||
*/
|
||||
node: DepositPage_assetsConnection_edges_node;
|
||||
}
|
||||
|
||||
@ -68,5 +71,5 @@ export interface DepositPage {
|
||||
/**
|
||||
* The list of all assets in use in the Vega network or the specified asset if ID is provided
|
||||
*/
|
||||
assetsConnection: DepositPage_assetsConnection;
|
||||
assetsConnection: DepositPage_assetsConnection | null;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ const defaultOptions = {} as const;
|
||||
export type DepositPageQueryVariables = Types.Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
export type DepositPageQuery = { __typename?: 'Query', assetsConnection: { __typename?: 'AssetsConnection', edges?: Array<{ __typename?: 'AssetEdge', node: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, source: { __typename?: 'BuiltinAsset' } | { __typename?: 'ERC20', contractAddress: string } } } | null> | null } };
|
||||
export type DepositPageQuery = { __typename?: 'Query', assetsConnection?: { __typename?: 'AssetsConnection', edges?: Array<{ __typename?: 'AssetEdge', node: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, source: { __typename?: 'BuiltinAsset' } | { __typename?: 'ERC20', contractAddress: string } } } | null> | null } | null };
|
||||
|
||||
|
||||
export const DepositPageDocument = gql`
|
||||
|
@ -27,6 +27,9 @@ query Accounts($partyId: ID!) {
|
||||
|
||||
subscription AccountEvents($partyId: ID!) {
|
||||
accounts(partyId: $partyId) {
|
||||
...AccountFields
|
||||
type
|
||||
balance
|
||||
assetId
|
||||
marketId
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ export type AccountEventsSubscriptionVariables = Types.Exact<{
|
||||
}>;
|
||||
|
||||
|
||||
export type AccountEventsSubscription = { __typename?: 'Subscription', accounts: { __typename?: 'Account', type: Types.AccountType, balance: string, market?: { __typename?: 'Market', id: string, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string } } } | null, asset: { __typename?: 'Asset', id: string, symbol: string, decimals: number } } };
|
||||
export type AccountEventsSubscription = { __typename?: 'Subscription', accounts: Array<{ __typename?: 'AccountUpdate', type: Types.AccountType, balance: string, assetId: string, marketId?: string | null }> };
|
||||
|
||||
export const AccountFieldsFragmentDoc = gql`
|
||||
fragment AccountFields on Account {
|
||||
@ -79,10 +79,13 @@ export type AccountsQueryResult = Apollo.QueryResult<AccountsQuery, AccountsQuer
|
||||
export const AccountEventsDocument = gql`
|
||||
subscription AccountEvents($partyId: ID!) {
|
||||
accounts(partyId: $partyId) {
|
||||
...AccountFields
|
||||
type
|
||||
balance
|
||||
assetId
|
||||
marketId
|
||||
}
|
||||
}
|
||||
${AccountFieldsFragmentDoc}`;
|
||||
`;
|
||||
|
||||
/**
|
||||
* __useAccountEventsSubscription__
|
@ -1,31 +1,48 @@
|
||||
import produce from 'immer';
|
||||
import type { IterableElement } from 'type-fest';
|
||||
import {
|
||||
AccountsDocument,
|
||||
AccountEventsDocument,
|
||||
} from './__generated__/Accounts';
|
||||
} from './__generated___/Accounts';
|
||||
import type {
|
||||
AccountFieldsFragment,
|
||||
AccountsQuery,
|
||||
AccountEventsSubscription,
|
||||
} from './__generated__/Accounts';
|
||||
} from './__generated___/Accounts';
|
||||
import { makeDataProvider } from '@vegaprotocol/react-helpers';
|
||||
|
||||
export const getId = (data: AccountFieldsFragment) =>
|
||||
`${data.type}-${data.asset.symbol}-${data.market?.id ?? 'null'}`;
|
||||
function isAccount(
|
||||
account:
|
||||
| AccountFieldsFragment
|
||||
| IterableElement<AccountEventsSubscription['accounts']>
|
||||
): account is AccountFieldsFragment {
|
||||
return (account as AccountFieldsFragment).__typename === 'Account';
|
||||
}
|
||||
|
||||
export const getId = (
|
||||
account:
|
||||
| AccountFieldsFragment
|
||||
| IterableElement<AccountEventsSubscription['accounts']>
|
||||
) =>
|
||||
isAccount(account)
|
||||
? `${account.type}-${account.asset.id}-${account.market?.id ?? 'null'}`
|
||||
: `${account.type}-${account.assetId}-${account.marketId}`;
|
||||
|
||||
const update = (
|
||||
data: AccountFieldsFragment[],
|
||||
delta: AccountFieldsFragment
|
||||
deltas: AccountEventsSubscription['accounts']
|
||||
) => {
|
||||
return produce(data, (draft) => {
|
||||
deltas.forEach((delta) => {
|
||||
const id = getId(delta);
|
||||
const index = draft.findIndex((a) => getId(a) === id);
|
||||
if (index !== -1) {
|
||||
draft[index] = delta;
|
||||
draft[index].balance = delta.balance;
|
||||
} else {
|
||||
draft.push(delta);
|
||||
// #TODO handle new account
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const getData = (
|
||||
@ -36,13 +53,13 @@ const getData = (
|
||||
|
||||
const getDelta = (
|
||||
subscriptionData: AccountEventsSubscription
|
||||
): AccountFieldsFragment => subscriptionData.accounts;
|
||||
): AccountEventsSubscription['accounts'] => subscriptionData.accounts;
|
||||
|
||||
export const accountsDataProvider = makeDataProvider<
|
||||
AccountsQuery,
|
||||
AccountFieldsFragment[],
|
||||
AccountEventsSubscription,
|
||||
AccountFieldsFragment
|
||||
AccountEventsSubscription['accounts']
|
||||
>({
|
||||
query: AccountsDocument,
|
||||
subscriptionQuery: AccountEventsDocument,
|
||||
|
@ -3,7 +3,10 @@ import { produce } from 'immer';
|
||||
import merge from 'lodash/merge';
|
||||
import { AsyncRenderer } from '@vegaprotocol/ui-toolkit';
|
||||
import { useDataProvider, addSummaryRows } from '@vegaprotocol/react-helpers';
|
||||
import type { AccountFieldsFragment } from './__generated__/Accounts';
|
||||
import type {
|
||||
AccountFieldsFragment,
|
||||
AccountEventsSubscription,
|
||||
} from './__generated___/Accounts';
|
||||
|
||||
import type { AgGridReact } from 'ag-grid-react';
|
||||
import {
|
||||
@ -21,13 +24,15 @@ export const AccountsManager = ({ partyId }: AccountsManagerProps) => {
|
||||
const gridRef = useRef<AgGridReact | null>(null);
|
||||
const variables = useMemo(() => ({ partyId }), [partyId]);
|
||||
const update = useCallback(
|
||||
({ delta }: { delta: AccountFieldsFragment }) => {
|
||||
({ delta: deltas }: { delta: AccountEventsSubscription['accounts'] }) => {
|
||||
const update: AccountFieldsFragment[] = [];
|
||||
const add: AccountFieldsFragment[] = [];
|
||||
if (!gridRef.current?.api) {
|
||||
return false;
|
||||
}
|
||||
const rowNode = gridRef.current.api.getRowNode(getId(delta));
|
||||
const api = gridRef.current.api;
|
||||
deltas.forEach((delta) => {
|
||||
const rowNode = api.getRowNode(getId(delta));
|
||||
if (rowNode) {
|
||||
const updatedData = produce<AccountFieldsFragment>(
|
||||
rowNode.data,
|
||||
@ -39,8 +44,9 @@ export const AccountsManager = ({ partyId }: AccountsManagerProps) => {
|
||||
update.push(updatedData);
|
||||
}
|
||||
} else {
|
||||
add.push(delta);
|
||||
// #TODO handle new account (or leave it to data provider to handle it)
|
||||
}
|
||||
});
|
||||
if (update.length || add.length) {
|
||||
gridRef.current.api.applyTransactionAsync({
|
||||
update,
|
||||
@ -62,7 +68,7 @@ export const AccountsManager = ({ partyId }: AccountsManagerProps) => {
|
||||
);
|
||||
const { data, error, loading } = useDataProvider<
|
||||
AccountFieldsFragment[],
|
||||
AccountFieldsFragment
|
||||
AccountEventsSubscription['accounts']
|
||||
>({ dataProvider: accountsDataProvider, update, variables });
|
||||
return (
|
||||
<AsyncRenderer loading={loading} error={error} data={data}>
|
||||
|
@ -1,11 +1,11 @@
|
||||
import AccountsTable from './accounts-table';
|
||||
import { act, render, screen, waitFor } from '@testing-library/react';
|
||||
import type { AccountFieldsFragment } from './__generated__/Accounts';
|
||||
import { AccountType } from '@vegaprotocol/types';
|
||||
import type { AccountFieldsFragment } from './__generated___/Accounts';
|
||||
import { Schema as Types } from '@vegaprotocol/types';
|
||||
|
||||
const singleRow: AccountFieldsFragment = {
|
||||
__typename: 'Account',
|
||||
type: AccountType.ACCOUNT_TYPE_MARGIN,
|
||||
type: Types.AccountType.ACCOUNT_TYPE_MARGIN,
|
||||
balance: '125600000',
|
||||
market: {
|
||||
__typename: 'Market',
|
||||
|
@ -14,7 +14,7 @@ import type { SummaryRow } from '@vegaprotocol/react-helpers';
|
||||
import { AgGridDynamic as AgGrid } from '@vegaprotocol/ui-toolkit';
|
||||
import { AgGridColumn } from 'ag-grid-react';
|
||||
import type { AgGridReact } from 'ag-grid-react';
|
||||
import type { AccountFieldsFragment } from './__generated__/Accounts';
|
||||
import type { AccountFieldsFragment } from './__generated___/Accounts';
|
||||
import { getId } from './accounts-data-provider';
|
||||
import { useAssetDetailsDialogStore } from '@vegaprotocol/assets';
|
||||
import type { AccountType } from '@vegaprotocol/types';
|
||||
|
@ -3,8 +3,6 @@ import {
|
||||
addDecimalsFormatNumber,
|
||||
useDataProvider,
|
||||
} from '@vegaprotocol/react-helpers';
|
||||
import type { AccountFieldsFragment } from './__generated__/Accounts';
|
||||
|
||||
import { accountsDataProvider } from './accounts-data-provider';
|
||||
|
||||
interface AssetBalanceProps {
|
||||
@ -14,10 +12,7 @@ interface AssetBalanceProps {
|
||||
|
||||
export const AssetBalance = ({ partyId, assetSymbol }: AssetBalanceProps) => {
|
||||
const variables = useMemo(() => ({ partyId }), [partyId]);
|
||||
const { data } = useDataProvider<
|
||||
AccountFieldsFragment[],
|
||||
AccountFieldsFragment
|
||||
>({
|
||||
const { data } = useDataProvider({
|
||||
dataProvider: accountsDataProvider,
|
||||
variables,
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
export * from './__generated__/Accounts';
|
||||
export * from './__generated___/Accounts';
|
||||
export * from './accounts-container';
|
||||
export * from './accounts-data-provider';
|
||||
export * from './accounts-manager';
|
||||
|
2
libs/assets/src/lib/__generated__/Assets.ts
generated
2
libs/assets/src/lib/__generated__/Assets.ts
generated
@ -6,7 +6,7 @@ const defaultOptions = {} as const;
|
||||
export type AssetsConnectionQueryVariables = Types.Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
export type AssetsConnectionQuery = { __typename?: 'Query', assetsConnection: { __typename?: 'AssetsConnection', edges?: Array<{ __typename?: 'AssetEdge', node: { __typename?: 'Asset', id: string, name: string, symbol: string, decimals: number, quantum: string, source: { __typename?: 'BuiltinAsset' } | { __typename?: 'ERC20', contractAddress: string, lifetimeLimit: string, withdrawThreshold: string } } } | null> | null } };
|
||||
export type AssetsConnectionQuery = { __typename?: 'Query', assetsConnection?: { __typename?: 'AssetsConnection', edges?: Array<{ __typename?: 'AssetEdge', node: { __typename?: 'Asset', id: string, name: string, symbol: string, decimals: number, quantum: string, source: { __typename?: 'BuiltinAsset' } | { __typename?: 'ERC20', contractAddress: string, lifetimeLimit: string, withdrawThreshold: string } } } | null> | null } | null };
|
||||
|
||||
|
||||
export const AssetsConnectionDocument = gql`
|
||||
|
60
libs/assets/src/lib/__generated___/Assets.ts
Normal file
60
libs/assets/src/lib/__generated___/Assets.ts
Normal file
@ -0,0 +1,60 @@
|
||||
import { Schema as Types } from '@vegaprotocol/types';
|
||||
|
||||
import { gql } from '@apollo/client';
|
||||
import * as Apollo from '@apollo/client';
|
||||
const defaultOptions = {} as const;
|
||||
export type AssetsConnectionQueryVariables = Types.Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
export type AssetsConnectionQuery = { __typename?: 'Query', assetsConnection?: { __typename?: 'AssetsConnection', edges?: Array<{ __typename?: 'AssetEdge', node: { __typename?: 'Asset', id: string, name: string, symbol: string, decimals: number, quantum: string, source: { __typename?: 'BuiltinAsset' } | { __typename?: 'ERC20', contractAddress: string, lifetimeLimit: string, withdrawThreshold: string } } } | null> | null } | null };
|
||||
|
||||
|
||||
export const AssetsConnectionDocument = gql`
|
||||
query AssetsConnection {
|
||||
assetsConnection {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
name
|
||||
symbol
|
||||
decimals
|
||||
quantum
|
||||
source {
|
||||
... on ERC20 {
|
||||
contractAddress
|
||||
lifetimeLimit
|
||||
withdrawThreshold
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
/**
|
||||
* __useAssetsConnectionQuery__
|
||||
*
|
||||
* To run a query within a React component, call `useAssetsConnectionQuery` and pass it any options that fit your needs.
|
||||
* When your component renders, `useAssetsConnectionQuery` 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 } = useAssetsConnectionQuery({
|
||||
* variables: {
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useAssetsConnectionQuery(baseOptions?: Apollo.QueryHookOptions<AssetsConnectionQuery, AssetsConnectionQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useQuery<AssetsConnectionQuery, AssetsConnectionQueryVariables>(AssetsConnectionDocument, options);
|
||||
}
|
||||
export function useAssetsConnectionLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<AssetsConnectionQuery, AssetsConnectionQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useLazyQuery<AssetsConnectionQuery, AssetsConnectionQueryVariables>(AssetsConnectionDocument, options);
|
||||
}
|
||||
export type AssetsConnectionQueryHookResult = ReturnType<typeof useAssetsConnectionQuery>;
|
||||
export type AssetsConnectionLazyQueryHookResult = ReturnType<typeof useAssetsConnectionLazyQuery>;
|
||||
export type AssetsConnectionQueryResult = Apollo.QueryResult<AssetsConnectionQuery, AssetsConnectionQueryVariables>;
|
@ -54,7 +54,7 @@ export const AssetDetailsDialog = ({
|
||||
const { data } = useAssetsConnectionQuery();
|
||||
const symbol =
|
||||
typeof assetSymbol === 'string' ? assetSymbol : assetSymbol.symbol;
|
||||
const asset = data?.assetsConnection.edges?.find(
|
||||
const asset = data?.assetsConnection?.edges?.find(
|
||||
(e) => e?.node.symbol === symbol
|
||||
);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
fragment CandleFields on Candle {
|
||||
timestamp
|
||||
periodStart
|
||||
high
|
||||
low
|
||||
open
|
||||
@ -18,11 +18,15 @@ query Candles($marketId: ID!, $interval: Interval!, $since: String!) {
|
||||
code
|
||||
}
|
||||
}
|
||||
candles(interval: $interval, since: $since) {
|
||||
candlesConnection(interval: $interval, since: $since) {
|
||||
edges {
|
||||
node {
|
||||
...CandleFields
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
subscription CandlesEvents($marketId: ID!, $interval: Interval!) {
|
||||
candles(marketId: $marketId, interval: $interval) {
|
||||
|
@ -3,7 +3,7 @@ import { Schema as Types } from '@vegaprotocol/types';
|
||||
import { gql } from '@apollo/client';
|
||||
import * as Apollo from '@apollo/client';
|
||||
const defaultOptions = {} as const;
|
||||
export type CandleFieldsFragment = { __typename?: 'Candle', timestamp: string, high: string, low: string, open: string, close: string, volume: string };
|
||||
export type CandleFieldsFragment = { __typename?: 'Candle', periodStart: string, high: string, low: string, open: string, close: string, volume: string };
|
||||
|
||||
export type CandlesQueryVariables = Types.Exact<{
|
||||
marketId: Types.Scalars['ID'];
|
||||
@ -12,7 +12,7 @@ export type CandlesQueryVariables = Types.Exact<{
|
||||
}>;
|
||||
|
||||
|
||||
export type CandlesQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, decimalPlaces: number, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string } }, candles?: Array<{ __typename?: 'Candle', timestamp: string, high: string, low: string, open: string, close: string, volume: string } | null> | null } | null };
|
||||
export type CandlesQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, decimalPlaces: number, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string } }, candlesConnection?: { __typename?: 'CandleDataConnection', edges?: Array<{ __typename?: 'CandleEdge', node: { __typename?: 'Candle', periodStart: string, high: string, low: string, open: string, close: string, volume: string } } | null> | null } | null } | null };
|
||||
|
||||
export type CandlesEventsSubscriptionVariables = Types.Exact<{
|
||||
marketId: Types.Scalars['ID'];
|
||||
@ -20,11 +20,11 @@ export type CandlesEventsSubscriptionVariables = Types.Exact<{
|
||||
}>;
|
||||
|
||||
|
||||
export type CandlesEventsSubscription = { __typename?: 'Subscription', candles: { __typename?: 'Candle', timestamp: string, high: string, low: string, open: string, close: string, volume: string } };
|
||||
export type CandlesEventsSubscription = { __typename?: 'Subscription', candles: { __typename?: 'Candle', periodStart: string, high: string, low: string, open: string, close: string, volume: string } };
|
||||
|
||||
export const CandleFieldsFragmentDoc = gql`
|
||||
fragment CandleFields on Candle {
|
||||
timestamp
|
||||
periodStart
|
||||
high
|
||||
low
|
||||
open
|
||||
@ -44,10 +44,14 @@ export const CandlesDocument = gql`
|
||||
code
|
||||
}
|
||||
}
|
||||
candles(interval: $interval, since: $since) {
|
||||
candlesConnection(interval: $interval, since: $since) {
|
||||
edges {
|
||||
node {
|
||||
...CandleFields
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
${CandleFieldsFragmentDoc}`;
|
||||
|
@ -3,19 +3,19 @@ import type { Candle, DataSource } from 'pennant';
|
||||
import { Interval as PennantInterval } from 'pennant';
|
||||
|
||||
import { addDecimal } from '@vegaprotocol/react-helpers';
|
||||
import { ChartDocument } from './__generated__/Chart';
|
||||
import type { ChartQuery, ChartQueryVariables } from './__generated__/Chart';
|
||||
import { ChartDocument } from './__generated___/Chart';
|
||||
import type { ChartQuery, ChartQueryVariables } from './__generated___/Chart';
|
||||
import {
|
||||
CandlesDocument,
|
||||
CandlesEventsDocument,
|
||||
} from './__generated__/Candles';
|
||||
} from './__generated___/Candles';
|
||||
import type {
|
||||
CandlesQuery,
|
||||
CandlesQueryVariables,
|
||||
CandleFieldsFragment,
|
||||
CandlesEventsSubscription,
|
||||
CandlesEventsSubscriptionVariables,
|
||||
} from './__generated__/Candles';
|
||||
} from './__generated___/Candles';
|
||||
import type { Subscription } from 'zen-observable-ts';
|
||||
import { Interval } from '@vegaprotocol/types';
|
||||
|
||||
@ -143,12 +143,13 @@ export class VegaDataSource implements DataSource {
|
||||
fetchPolicy: 'no-cache',
|
||||
});
|
||||
|
||||
if (data && data.market && data.market.candles) {
|
||||
if (data?.market?.candlesConnection?.edges) {
|
||||
const decimalPlaces = data.market.decimalPlaces;
|
||||
|
||||
const candles = data.market.candles
|
||||
.filter((d): d is CandleFieldsFragment => d !== null)
|
||||
.map((d) => parseCandle(d, decimalPlaces));
|
||||
const candles = data.market.candlesConnection.edges
|
||||
.map((edge) => edge?.node)
|
||||
.filter((node): node is CandleFieldsFragment => !!node)
|
||||
.map((node) => parseCandle(node, decimalPlaces));
|
||||
|
||||
return candles;
|
||||
} else {
|
||||
@ -199,7 +200,7 @@ function parseCandle(
|
||||
decimalPlaces: number
|
||||
): Candle {
|
||||
return {
|
||||
date: new Date(Number(candle.timestamp) / 1_000_000),
|
||||
date: new Date(Number(candle.periodStart) / 1_000_000),
|
||||
high: Number(addDecimal(candle.high, decimalPlaces)),
|
||||
low: Number(addDecimal(candle.low, decimalPlaces)),
|
||||
open: Number(addDecimal(candle.open, decimalPlaces)),
|
||||
|
@ -1,4 +1,4 @@
|
||||
export * from './__generated__/Candles';
|
||||
export * from './__generated__/Chart';
|
||||
export * from './__generated___/Candles';
|
||||
export * from './__generated___/Chart';
|
||||
export * from './candles-chart';
|
||||
export * from './data-source';
|
||||
|
@ -1,7 +1,6 @@
|
||||
query DealTicketQuery($marketId: ID!) {
|
||||
market(id: $marketId) {
|
||||
id
|
||||
name
|
||||
decimalPlaces
|
||||
positionDecimalPlaces
|
||||
state
|
||||
|
@ -8,14 +8,13 @@ export type DealTicketQueryQueryVariables = Types.Exact<{
|
||||
}>;
|
||||
|
||||
|
||||
export type DealTicketQueryQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, name: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string } } } }, depth: { __typename?: 'MarketDepth', lastTrade?: { __typename?: 'Trade', price: string } | null } } | null };
|
||||
export type DealTicketQueryQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string } } } }, depth: { __typename?: 'MarketDepth', lastTrade?: { __typename?: 'Trade', price: string } | null } } | null };
|
||||
|
||||
|
||||
export const DealTicketQueryDocument = gql`
|
||||
query DealTicketQuery($marketId: ID!) {
|
||||
market(id: $marketId) {
|
||||
id
|
||||
name
|
||||
decimalPlaces
|
||||
positionDecimalPlaces
|
||||
state
|
||||
|
@ -84,7 +84,7 @@ export interface DealTicketQuery_market {
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* decimalPlaces indicates the number of decimal places that an integer must be shifted by in order to get a correct
|
||||
* The number of decimal places that an integer must be shifted by in order to get a correct
|
||||
* number denominated in the currency of the market. (uint64)
|
||||
*
|
||||
* Examples:
|
||||
@ -101,7 +101,7 @@ export interface DealTicketQuery_market {
|
||||
*/
|
||||
decimalPlaces: number;
|
||||
/**
|
||||
* positionDecimalPlaces indicates the number of decimal places that an integer must be shifted in order to get a correct size (uint64).
|
||||
* The number of decimal places that an integer must be shifted in order to get a correct size (uint64).
|
||||
* i.e. 0 means there are no fractional orders for the market, and order sizes are always whole sizes.
|
||||
* 2 means sizes given as 10^2 * desired size, e.g. a desired size of 1.23 is represented as 123 in this market.
|
||||
* This sets how big the smallest order / position on the market can be.
|
||||
|
@ -7,7 +7,6 @@ import React, {
|
||||
useMemo,
|
||||
} from 'react';
|
||||
import * as DialogPrimitives from '@radix-ui/react-dialog';
|
||||
import { gql, useQuery } from '@apollo/client';
|
||||
import classNames from 'classnames';
|
||||
import type { DealTicketQuery_market } from './';
|
||||
import {
|
||||
@ -21,41 +20,20 @@ import {
|
||||
t,
|
||||
useScreenDimensions,
|
||||
useOutsideClick,
|
||||
useDataProvider,
|
||||
} from '@vegaprotocol/react-helpers';
|
||||
import type {
|
||||
MarketNames,
|
||||
MarketNames_markets,
|
||||
} from './__generated__/MarketNames';
|
||||
import { IconNames } from '@blueprintjs/icons';
|
||||
import { MarketState } from '@vegaprotocol/types';
|
||||
|
||||
export const MARKET_NAMES_QUERY = gql`
|
||||
query MarketNames {
|
||||
markets {
|
||||
id
|
||||
state
|
||||
tradableInstrument {
|
||||
instrument {
|
||||
code
|
||||
name
|
||||
metadata {
|
||||
tags
|
||||
}
|
||||
product {
|
||||
... on Future {
|
||||
quoteName
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
import type { Market } from '@vegaprotocol/market-list';
|
||||
import { marketsProvider } from '@vegaprotocol/market-list';
|
||||
|
||||
interface Props {
|
||||
market: DealTicketQuery_market;
|
||||
setMarket: (marketId: string) => void;
|
||||
ItemRenderer?: React.FC<{ market: MarketNames_markets; isMobile?: boolean }>;
|
||||
ItemRenderer?: React.FC<{
|
||||
market: Market;
|
||||
isMobile?: boolean;
|
||||
}>;
|
||||
}
|
||||
|
||||
function escapeRegExp(str: string) {
|
||||
@ -67,8 +45,7 @@ export const MarketSelector = ({ market, setMarket, ItemRenderer }: Props) => {
|
||||
const contRef = useRef<HTMLDivElement | null>(null);
|
||||
const inputRef = useRef<HTMLInputElement | null>(null);
|
||||
const arrowButtonRef = useRef<HTMLButtonElement | null>(null);
|
||||
const [skip, setSkip] = useState(true);
|
||||
const [results, setResults] = useState<MarketNames_markets[]>([]);
|
||||
const [results, setResults] = useState<Market[]>([]);
|
||||
const [showPane, setShowPane] = useState(false);
|
||||
const [lookup, setLookup] = useState(
|
||||
market.tradableInstrument.instrument.name || ''
|
||||
@ -77,8 +54,9 @@ export const MarketSelector = ({ market, setMarket, ItemRenderer }: Props) => {
|
||||
null
|
||||
);
|
||||
|
||||
const { data, loading, error } = useQuery<MarketNames>(MARKET_NAMES_QUERY, {
|
||||
skip,
|
||||
const { data, loading, error } = useDataProvider({
|
||||
dataProvider: marketsProvider,
|
||||
noUpdate: true,
|
||||
});
|
||||
|
||||
const outsideClickCb = useCallback(() => {
|
||||
@ -96,11 +74,8 @@ export const MarketSelector = ({ market, setMarket, ItemRenderer }: Props) => {
|
||||
} = event;
|
||||
setLookup(value);
|
||||
setShowPane(true);
|
||||
if (value) {
|
||||
setSkip(false);
|
||||
}
|
||||
},
|
||||
[setLookup, setShowPane, setSkip]
|
||||
[setLookup, setShowPane]
|
||||
);
|
||||
|
||||
const handleMarketSelect = useCallback(
|
||||
@ -117,11 +92,7 @@ export const MarketSelector = ({ market, setMarket, ItemRenderer }: Props) => {
|
||||
);
|
||||
|
||||
const handleItemKeyDown = useCallback(
|
||||
(
|
||||
event: React.KeyboardEvent,
|
||||
market: MarketNames_markets,
|
||||
index: number
|
||||
) => {
|
||||
(event: React.KeyboardEvent, market: Market, index: number) => {
|
||||
switch (event.key) {
|
||||
case 'ArrowDown':
|
||||
if (index < results.length - 1) {
|
||||
@ -170,9 +141,8 @@ export const MarketSelector = ({ market, setMarket, ItemRenderer }: Props) => {
|
||||
|
||||
const openPane = useCallback(() => {
|
||||
setShowPane(!showPane);
|
||||
setSkip(false);
|
||||
inputRef.current?.focus();
|
||||
}, [showPane, setShowPane, setSkip, inputRef]);
|
||||
}, [showPane, setShowPane, inputRef]);
|
||||
|
||||
const handleDialogOnchange = useCallback(
|
||||
(isOpen: boolean) => {
|
||||
@ -274,8 +244,8 @@ export const MarketSelector = ({ market, setMarket, ItemRenderer }: Props) => {
|
||||
|
||||
useEffect(() => {
|
||||
setResults(
|
||||
data?.markets?.filter(
|
||||
(item: MarketNames_markets) =>
|
||||
data?.filter(
|
||||
(item) =>
|
||||
item.state === MarketState.STATE_ACTIVE &&
|
||||
item.tradableInstrument.instrument.name.match(
|
||||
new RegExp(escapeRegExp(lookup), 'i')
|
||||
|
@ -34,7 +34,7 @@ export type DepositEvent_busEvents_event = DepositEvent_busEvents_event_TimeUpda
|
||||
export interface DepositEvent_busEvents {
|
||||
__typename: "BusEvent";
|
||||
/**
|
||||
* the payload - the wrapped event
|
||||
* The payload - the wrapped event
|
||||
*/
|
||||
event: DepositEvent_busEvents_event;
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user