diff --git a/apps/console-lite-e2e/src/integration/market-selector.test.ts b/apps/console-lite-e2e/src/integration/market-selector.test.ts index 4d0b3895c..ad8074bf6 100644 --- a/apps/console-lite-e2e/src/integration/market-selector.test.ts +++ b/apps/console-lite-e2e/src/integration/market-selector.test.ts @@ -23,7 +23,7 @@ describe('market selector', { tags: '@smoke' }, () => { aliasQuery(req, 'Markets', generateSimpleMarkets()); aliasQuery(req, 'MarketsCandlesQuery', generateMarketsCandles()); aliasQuery(req, 'MarketsDataQuery', generateMarketsData()); - aliasQuery(req, 'DealTicketQuery', generateDealTicket()); + aliasQuery(req, 'DealTicket', generateDealTicket()); aliasQuery(req, 'MarketTags', generateMarketTags()); aliasQuery(req, 'MarketPositions', generateMarketPositions()); aliasQuery(req, 'EstimateOrder', generateEstimateOrder()); diff --git a/apps/console-lite-e2e/src/integration/market-trade.test.ts b/apps/console-lite-e2e/src/integration/market-trade.test.ts index 87145ca6b..0128aa7c9 100644 --- a/apps/console-lite-e2e/src/integration/market-trade.test.ts +++ b/apps/console-lite-e2e/src/integration/market-trade.test.ts @@ -23,7 +23,7 @@ describe('Market trade', { tags: '@smoke' }, () => { aliasQuery(req, 'MarketsCandlesQuery', generateMarketsCandles()); aliasQuery(req, 'MarketsDataQuery', generateMarketsData()); aliasQuery(req, 'SimpleMarkets', generateSimpleMarkets()); - aliasQuery(req, 'DealTicketQuery', generateDealTicket()); + aliasQuery(req, 'DealTicket', generateDealTicket()); aliasQuery(req, 'MarketTags', generateMarketTags()); aliasQuery(req, 'MarketPositions', generateMarketPositions()); aliasQuery(req, 'EstimateOrder', generateEstimateOrder()); diff --git a/apps/console-lite-e2e/src/support/mocks/generate-fills.ts b/apps/console-lite-e2e/src/support/mocks/generate-fills.ts index 9ad465473..8214b42e5 100644 --- a/apps/console-lite-e2e/src/support/mocks/generate-fills.ts +++ b/apps/console-lite-e2e/src/support/mocks/generate-fills.ts @@ -1,13 +1,12 @@ -import type { - Fills, - Fills_party_tradesConnection_edges_node, -} from '@vegaprotocol/fills'; +import type { FillsQuery, FillFieldsFragment } from '@vegaprotocol/fills'; import { Side } from '@vegaprotocol/types'; import merge from 'lodash/merge'; import type { PartialDeep } from 'type-fest'; -export const generateFills = (override?: PartialDeep): Fills => { - const fills: Fills_party_tradesConnection_edges_node[] = [ +export const generateFills = ( + override?: PartialDeep +): FillsQuery => { + const fills: FillFieldsFragment[] = [ generateFill({ buyer: { id: Cypress.env('VEGA_PUBLIC_KEY'), @@ -45,7 +44,7 @@ export const generateFills = (override?: PartialDeep): Fills => { }), ]; - const defaultResult: Fills = { + const defaultResult: FillsQuery = { party: { id: 'buyer-id', tradesConnection: { @@ -72,10 +71,8 @@ export const generateFills = (override?: PartialDeep): Fills => { return merge(defaultResult, override); }; -export const generateFill = ( - override?: PartialDeep -) => { - const defaultFill: Fills_party_tradesConnection_edges_node = { +export const generateFill = (override?: PartialDeep) => { + const defaultFill: FillFieldsFragment = { __typename: 'Trade', id: '0', createdAt: new Date().toISOString(), diff --git a/apps/console-lite/.env.testnet b/apps/console-lite/.env.testnet index 34be5e279..ec2a25e07 100644 --- a/apps/console-lite/.env.testnet +++ b/apps/console-lite/.env.testnet @@ -1,6 +1,6 @@ # App configuration variables NX_VEGA_CONFIG_URL=https://static.vega.xyz/assets/testnet-network.json -NX_VEGA_URL=https://api.n11.testnet.vega.xyz/graphql +NX_VEGA_URL=https://api.n12.testnet.vega.xyz/graphql NX_VEGA_ENV=TESTNET NX_VEGA_NETWORKS='{\"MAINNET\":\"https://alpha.console.vega.xyz\"}' NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8 diff --git a/apps/console-lite/src/app/components/deal-ticket/deal-ticket-balance.tsx b/apps/console-lite/src/app/components/deal-ticket/deal-ticket-balance.tsx index 5b61e5bfd..24d229d16 100644 --- a/apps/console-lite/src/app/components/deal-ticket/deal-ticket-balance.tsx +++ b/apps/console-lite/src/app/components/deal-ticket/deal-ticket-balance.tsx @@ -1,13 +1,13 @@ import * as React from 'react'; import classNames from 'classnames'; -import type { DealTicketQuery_market_tradableInstrument_instrument_product_settlementAsset } from '@vegaprotocol/deal-ticket'; +import type { DealTicketMarketFragment } from '@vegaprotocol/deal-ticket'; import type { PartyBalanceQuery_party_accounts } from './__generated__/PartyBalanceQuery'; import { useSettlementAccount } from '../../hooks/use-settlement-account'; import { addDecimalsFormatNumber, t } from '@vegaprotocol/react-helpers'; import { AccountType } from '@vegaprotocol/types'; interface DealTicketBalanceProps { - settlementAsset: DealTicketQuery_market_tradableInstrument_instrument_product_settlementAsset; + settlementAsset: DealTicketMarketFragment['tradableInstrument']['instrument']['product']['settlementAsset']; accounts: PartyBalanceQuery_party_accounts[]; isWalletConnected: boolean; className?: string; diff --git a/apps/console-lite/src/app/components/deal-ticket/deal-ticket-container.tsx b/apps/console-lite/src/app/components/deal-ticket/deal-ticket-container.tsx index 8591e0cad..7d55ade20 100644 --- a/apps/console-lite/src/app/components/deal-ticket/deal-ticket-container.tsx +++ b/apps/console-lite/src/app/components/deal-ticket/deal-ticket-container.tsx @@ -52,6 +52,10 @@ export const DealTicketContainer = () => { const container = marketId ? ( {(data) => { + if (!data.market) { + return null as unknown as JSX.Element; + } + const balance = ( ; +export type DepositAssetsQueryVariables = 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 } | null }; +export type DepositAssetsQuery = { __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` - query Deposits { +export const DepositAssetsDocument = gql` + query DepositAssets { assetsConnection { edges { node { @@ -30,28 +30,28 @@ export const DepositsDocument = gql` `; /** - * __useDepositsQuery__ + * __useDepositAssetsQuery__ * - * To run a query within a React component, call `useDepositsQuery` and pass it any options that fit your needs. - * When your component renders, `useDepositsQuery` returns an object from Apollo Client that contains loading, error, and data properties + * To run a query within a React component, call `useDepositAssetsQuery` and pass it any options that fit your needs. + * When your component renders, `useDepositAssetsQuery` 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 } = useDepositsQuery({ + * const { data, loading, error } = useDepositAssetsQuery({ * variables: { * }, * }); */ -export function useDepositsQuery(baseOptions?: Apollo.QueryHookOptions) { +export function useDepositAssetsQuery(baseOptions?: Apollo.QueryHookOptions) { const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(DepositsDocument, options); + return Apollo.useQuery(DepositAssetsDocument, options); } -export function useDepositsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { +export function useDepositAssetsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(DepositsDocument, options); + return Apollo.useLazyQuery(DepositAssetsDocument, options); } -export type DepositsQueryHookResult = ReturnType; -export type DepositsLazyQueryHookResult = ReturnType; -export type DepositsQueryResult = Apollo.QueryResult; \ No newline at end of file +export type DepositAssetsQueryHookResult = ReturnType; +export type DepositAssetsLazyQueryHookResult = ReturnType; +export type DepositAssetsQueryResult = Apollo.QueryResult; \ No newline at end of file diff --git a/apps/console-lite/src/app/components/deposits/deposits.tsx b/apps/console-lite/src/app/components/deposits/deposits.tsx index ad2ed2d09..188818c8f 100644 --- a/apps/console-lite/src/app/components/deposits/deposits.tsx +++ b/apps/console-lite/src/app/components/deposits/deposits.tsx @@ -5,10 +5,10 @@ import { Networks, useEnvironment } from '@vegaprotocol/environment'; import { AsyncRenderer, Splash } from '@vegaprotocol/ui-toolkit'; import { useVegaWallet } from '@vegaprotocol/wallet'; import { Web3Container } from '@vegaprotocol/web3'; -import type { Deposits } from './__generated__/Deposits'; +import type { DepositAssets } from './__generated__/DepositAssets'; const DEPOSITS_QUERY = gql` - query Deposits { + query DepositAssets { assetsConnection { edges { node { @@ -35,7 +35,7 @@ export const DepositContainer = () => { const { VEGA_ENV } = useEnvironment(); const { keypair } = useVegaWallet(); - const { data, loading, error } = useQuery(DEPOSITS_QUERY, { + const { data, loading, error } = useQuery(DEPOSITS_QUERY, { variables: { partyId: keypair?.pub }, skip: !keypair?.pub, }); @@ -43,7 +43,7 @@ export const DepositContainer = () => { const assets = getEnabledAssets(data); return ( - data={data} loading={loading} error={error}> + data={data} loading={loading} error={error}> {assets.length ? ( { }; const SimpleMarketPercentChange = ({ candles, marketId, setValue }: Props) => { + const yesterday = Math.round(new Date().getTime() / 1000) - 24 * 3600; const { data } = useDataProvider({ dataProvider: marketCandlesProvider, - variables: { marketId, interval: Interval.INTERVAL_I1D }, + variables: { + marketId, + interval: Interval.INTERVAL_I1D, + since: new Date(yesterday * 1000).toISOString(), + }, }); const close = data?.map((m) => m.close); diff --git a/apps/console-lite/src/app/hooks/use-order-closeout.spec.tsx b/apps/console-lite/src/app/hooks/use-order-closeout.spec.tsx index a1026fa5f..3a7a10085 100644 --- a/apps/console-lite/src/app/hooks/use-order-closeout.spec.tsx +++ b/apps/console-lite/src/app/hooks/use-order-closeout.spec.tsx @@ -3,7 +3,7 @@ import { renderHook } from '@testing-library/react'; import { MockedProvider } from '@apollo/client/testing'; import useOrderCloseOut from './use-order-closeout'; import type { Order } from '@vegaprotocol/orders'; -import type { DealTicketQuery_market } from '@vegaprotocol/deal-ticket'; +import type { DealTicketMarketFragment } from '@vegaprotocol/deal-ticket'; import type { PartyBalanceQuery } from '../components/deal-ticket/__generated__/PartyBalanceQuery'; jest.mock('@vegaprotocol/wallet', () => ({ @@ -49,7 +49,7 @@ describe('useOrderCloseOut Hook', () => { () => useOrderCloseOut({ order: order as Order, - market: market as DealTicketQuery_market, + market: market as DealTicketMarketFragment, partyData: partyData as PartyBalanceQuery, }), { @@ -66,7 +66,7 @@ describe('useOrderCloseOut Hook', () => { () => useOrderCloseOut({ order: { ...order, side: 'SIDE_SELL' } as Order, - market: market as DealTicketQuery_market, + market: market as DealTicketMarketFragment, partyData: partyData as PartyBalanceQuery, }), { @@ -83,7 +83,7 @@ describe('useOrderCloseOut Hook', () => { () => useOrderCloseOut({ order: { ...order, side: 'SIDE_SELL' } as Order, - market: market as DealTicketQuery_market, + market: market as DealTicketMarketFragment, }), { wrapper: ({ children }: { children: React.ReactNode }) => ( diff --git a/apps/console-lite/src/app/hooks/use-order-closeout.ts b/apps/console-lite/src/app/hooks/use-order-closeout.ts index 0ef58c27d..c87f96eff 100644 --- a/apps/console-lite/src/app/hooks/use-order-closeout.ts +++ b/apps/console-lite/src/app/hooks/use-order-closeout.ts @@ -1,6 +1,6 @@ import { BigNumber } from 'bignumber.js'; import type { Order } from '@vegaprotocol/orders'; -import type { DealTicketQuery_market } from '@vegaprotocol/deal-ticket'; +import type { DealTicketMarketFragment } from '@vegaprotocol/deal-ticket'; import type { PartyBalanceQuery } from '../components/deal-ticket/__generated__/PartyBalanceQuery'; import { useSettlementAccount } from './use-settlement-account'; import { useVegaWallet } from '@vegaprotocol/wallet'; @@ -47,7 +47,7 @@ const CLOSEOUT_PRICE_QUERY = gql` interface Props { order: Order; - market: DealTicketQuery_market; + market: DealTicketMarketFragment; partyData?: PartyBalanceQuery; } diff --git a/apps/console-lite/src/app/hooks/use-order-margin.spec.ts b/apps/console-lite/src/app/hooks/use-order-margin.spec.ts index 2625045eb..72307b258 100644 --- a/apps/console-lite/src/app/hooks/use-order-margin.spec.ts +++ b/apps/console-lite/src/app/hooks/use-order-margin.spec.ts @@ -2,7 +2,7 @@ import { renderHook } from '@testing-library/react'; import { useQuery } from '@apollo/client'; import { BigNumber } from 'bignumber.js'; import type { Order } from '@vegaprotocol/orders'; -import type { DealTicketQuery_market } from '@vegaprotocol/deal-ticket'; +import type { DealTicketMarketFragment } from '@vegaprotocol/deal-ticket'; import type { PositionMargin } from './use-market-positions'; import useOrderMargin from './use-order-margin'; @@ -54,7 +54,7 @@ describe('useOrderMargin Hook', () => { const { result } = renderHook(() => useOrderMargin({ order: order as Order, - market: market as DealTicketQuery_market, + market: market as DealTicketMarketFragment, partyId, }) ); @@ -72,7 +72,7 @@ describe('useOrderMargin Hook', () => { const { result } = renderHook(() => useOrderMargin({ order: order as Order, - market: market as DealTicketQuery_market, + market: market as DealTicketMarketFragment, partyId, }) ); @@ -84,7 +84,7 @@ describe('useOrderMargin Hook', () => { const { result } = renderHook(() => useOrderMargin({ order: order as Order, - market: market as DealTicketQuery_market, + market: market as DealTicketMarketFragment, partyId, }) ); @@ -111,7 +111,7 @@ describe('useOrderMargin Hook', () => { const { result } = renderHook(() => useOrderMargin({ order: order as Order, - market: market as DealTicketQuery_market, + market: market as DealTicketMarketFragment, partyId, }) ); diff --git a/apps/console-lite/src/app/hooks/use-order-margin.ts b/apps/console-lite/src/app/hooks/use-order-margin.ts index 0a574a0fc..4c3ad1b50 100644 --- a/apps/console-lite/src/app/hooks/use-order-margin.ts +++ b/apps/console-lite/src/app/hooks/use-order-margin.ts @@ -6,7 +6,7 @@ import type { EstimateOrderVariables, EstimateOrder_estimateOrder_fee, } from './__generated__/estimateOrder'; -import type { DealTicketQuery_market } from '@vegaprotocol/deal-ticket'; +import type { DealTicketMarketFragment } from '@vegaprotocol/deal-ticket'; import { Side } from '@vegaprotocol/types'; import { addDecimal, removeDecimal } from '@vegaprotocol/react-helpers'; import useMarketPositions from './use-market-positions'; @@ -47,7 +47,7 @@ export const ESTIMATE_ORDER_QUERY = gql` interface Props { order: Order; - market: DealTicketQuery_market; + market: DealTicketMarketFragment; partyId: string; } diff --git a/apps/trading-e2e/src/integration/global.cy.ts b/apps/trading-e2e/src/integration/global.cy.ts index 17e5e0481..475070b41 100644 --- a/apps/trading-e2e/src/integration/global.cy.ts +++ b/apps/trading-e2e/src/integration/global.cy.ts @@ -56,7 +56,7 @@ describe('vega wallet', { tags: '@smoke' }, () => { cy.getByTestId('manage-vega-wallet').click(); cy.getByTestId('keypair-list').should('exist'); cy.getByTestId(`key-${key2}`).click(); - cy.getByTestId('manage-vega-wallet').contains(truncatedKey2); + cy.getByTestId('keypair-list').contains(truncatedKey2); cy.getByTestId('disconnect').click(); cy.getByTestId('connect-vega-wallet').should('exist'); cy.getByTestId('manage-vega-wallet').should('not.exist'); diff --git a/apps/trading-e2e/src/support/mocks/generate-fills.ts b/apps/trading-e2e/src/support/mocks/generate-fills.ts index 9ad465473..8214b42e5 100644 --- a/apps/trading-e2e/src/support/mocks/generate-fills.ts +++ b/apps/trading-e2e/src/support/mocks/generate-fills.ts @@ -1,13 +1,12 @@ -import type { - Fills, - Fills_party_tradesConnection_edges_node, -} from '@vegaprotocol/fills'; +import type { FillsQuery, FillFieldsFragment } from '@vegaprotocol/fills'; import { Side } from '@vegaprotocol/types'; import merge from 'lodash/merge'; import type { PartialDeep } from 'type-fest'; -export const generateFills = (override?: PartialDeep): Fills => { - const fills: Fills_party_tradesConnection_edges_node[] = [ +export const generateFills = ( + override?: PartialDeep +): FillsQuery => { + const fills: FillFieldsFragment[] = [ generateFill({ buyer: { id: Cypress.env('VEGA_PUBLIC_KEY'), @@ -45,7 +44,7 @@ export const generateFills = (override?: PartialDeep): Fills => { }), ]; - const defaultResult: Fills = { + const defaultResult: FillsQuery = { party: { id: 'buyer-id', tradesConnection: { @@ -72,10 +71,8 @@ export const generateFills = (override?: PartialDeep): Fills => { return merge(defaultResult, override); }; -export const generateFill = ( - override?: PartialDeep -) => { - const defaultFill: Fills_party_tradesConnection_edges_node = { +export const generateFill = (override?: PartialDeep) => { + const defaultFill: FillFieldsFragment = { __typename: 'Trade', id: '0', createdAt: new Date().toISOString(), diff --git a/libs/assets/src/lib/__generated___/Assets.ts b/libs/assets/src/lib/__generated___/Assets.ts deleted file mode 100644 index a4d53232e..000000000 --- a/libs/assets/src/lib/__generated___/Assets.ts +++ /dev/null @@ -1,60 +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 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) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(AssetsConnectionDocument, options); - } -export function useAssetsConnectionLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(AssetsConnectionDocument, options); - } -export type AssetsConnectionQueryHookResult = ReturnType; -export type AssetsConnectionLazyQueryHookResult = ReturnType; -export type AssetsConnectionQueryResult = Apollo.QueryResult; \ No newline at end of file diff --git a/libs/candles-chart/src/lib/__generated___/Candles.ts b/libs/candles-chart/src/lib/__generated__/Candles.ts similarity index 100% rename from libs/candles-chart/src/lib/__generated___/Candles.ts rename to libs/candles-chart/src/lib/__generated__/Candles.ts diff --git a/libs/candles-chart/src/lib/__generated___/Chart.ts b/libs/candles-chart/src/lib/__generated__/Chart.ts similarity index 100% rename from libs/candles-chart/src/lib/__generated___/Chart.ts rename to libs/candles-chart/src/lib/__generated__/Chart.ts diff --git a/libs/candles-chart/src/lib/data-source.ts b/libs/candles-chart/src/lib/data-source.ts index c9856b98d..f600f93a9 100644 --- a/libs/candles-chart/src/lib/data-source.ts +++ b/libs/candles-chart/src/lib/data-source.ts @@ -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'; diff --git a/libs/candles-chart/src/lib/index.ts b/libs/candles-chart/src/lib/index.ts index b09081938..fec9df1f3 100644 --- a/libs/candles-chart/src/lib/index.ts +++ b/libs/candles-chart/src/lib/index.ts @@ -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'; diff --git a/libs/deal-ticket/src/components/DealTicket.graphql b/libs/deal-ticket/src/components/DealTicket.graphql deleted file mode 100644 index 69802ec4b..000000000 --- a/libs/deal-ticket/src/components/DealTicket.graphql +++ /dev/null @@ -1,30 +0,0 @@ -query DealTicketQuery($marketId: ID!) { - market(id: $marketId) { - id - decimalPlaces - positionDecimalPlaces - state - tradingMode - tradableInstrument { - instrument { - id - name - product { - ... on Future { - quoteName - settlementAsset { - id - symbol - name - } - } - } - } - } - depth { - lastTrade { - price - } - } - } -} diff --git a/libs/deal-ticket/src/components/MarketNames.graphql b/libs/deal-ticket/src/components/MarketNames.graphql deleted file mode 100644 index 1bebfcdb6..000000000 --- a/libs/deal-ticket/src/components/MarketNames.graphql +++ /dev/null @@ -1,20 +0,0 @@ -query MarketNames { - markets { - id - state - tradableInstrument { - instrument { - code - name - metadata { - tags - } - product { - ... on Future { - quoteName - } - } - } - } - } -} diff --git a/libs/deal-ticket/src/components/__generated___/DealTicket.ts b/libs/deal-ticket/src/components/__generated___/DealTicket.ts deleted file mode 100644 index 2b0a7470c..000000000 --- a/libs/deal-ticket/src/components/__generated___/DealTicket.ts +++ /dev/null @@ -1,73 +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 DealTicketQueryQueryVariables = Types.Exact<{ - marketId: Types.Scalars['ID']; -}>; - - -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 - decimalPlaces - positionDecimalPlaces - state - tradingMode - tradableInstrument { - instrument { - id - name - product { - ... on Future { - quoteName - settlementAsset { - id - symbol - name - } - } - } - } - } - depth { - lastTrade { - price - } - } - } -} - `; - -/** - * __useDealTicketQueryQuery__ - * - * To run a query within a React component, call `useDealTicketQueryQuery` and pass it any options that fit your needs. - * When your component renders, `useDealTicketQueryQuery` 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 } = useDealTicketQueryQuery({ - * variables: { - * marketId: // value for 'marketId' - * }, - * }); - */ -export function useDealTicketQueryQuery(baseOptions: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(DealTicketQueryDocument, options); - } -export function useDealTicketQueryLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(DealTicketQueryDocument, options); - } -export type DealTicketQueryQueryHookResult = ReturnType; -export type DealTicketQueryLazyQueryHookResult = ReturnType; -export type DealTicketQueryQueryResult = Apollo.QueryResult; \ No newline at end of file diff --git a/libs/deal-ticket/src/components/__generated___/MarketInfo.ts b/libs/deal-ticket/src/components/__generated___/MarketInfo.ts deleted file mode 100644 index 03a931d63..000000000 --- a/libs/deal-ticket/src/components/__generated___/MarketInfo.ts +++ /dev/null @@ -1,185 +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 MarketInfoQueryQueryVariables = Types.Exact<{ - marketId: Types.Scalars['ID']; - interval: Types.Interval; - since: Types.Scalars['String']; -}>; - - -export type MarketInfoQueryQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, accounts?: Array<{ __typename?: 'Account', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', id: string } }> | null, fees: { __typename?: 'Fees', factors: { __typename?: 'FeeFactors', makerFee: string, infrastructureFee: string, liquidityFee: string } }, priceMonitoringSettings: { __typename?: 'PriceMonitoringSettings', parameters?: { __typename?: 'PriceMonitoringParameters', triggers?: Array<{ __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number }> | null } | null }, riskFactors?: { __typename?: 'RiskFactor', market: string, short: string, long: string } | null, data?: { __typename?: 'MarketData', markPrice: string, indicativeVolume: string, bestBidVolume: string, bestOfferVolume: string, bestStaticBidVolume: string, bestStaticOfferVolume: string, openInterest: string, bestBidPrice: string, bestOfferPrice: string, trigger: Types.AuctionTrigger, market: { __typename?: 'Market', id: string }, priceMonitoringBounds?: Array<{ __typename?: 'PriceMonitoringBounds', minValidPrice: string, maxValidPrice: string, referencePrice: string, trigger: { __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number } }> | null } | null, liquidityMonitoringParameters: { __typename?: 'LiquidityMonitoringParameters', triggeringRatio: number, targetStakeParameters: { __typename?: 'TargetStakeParameters', timeWindow: number, scalingFactor: number } }, candles?: Array<{ __typename?: 'Candle', volume: string } | null> | null, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array | null }, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string }, oracleSpecForSettlementPrice: { __typename?: 'OracleSpec', id: string }, oracleSpecForTradingTermination: { __typename?: 'OracleSpec', id: string }, oracleSpecBinding: { __typename?: 'OracleSpecToFutureBinding', settlementPriceProperty: string, tradingTerminationProperty: string } } }, 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 } } }, depth: { __typename?: 'MarketDepth', lastTrade?: { __typename?: 'Trade', price: string } | null } } | null }; - - -export const MarketInfoQueryDocument = gql` - query MarketInfoQuery($marketId: ID!, $interval: Interval!, $since: String!) { - market(id: $marketId) { - id - decimalPlaces - positionDecimalPlaces - state - accounts { - type - asset { - id - } - balance - } - tradingMode - accounts { - type - asset { - id - } - balance - } - fees { - factors { - makerFee - infrastructureFee - liquidityFee - } - } - priceMonitoringSettings { - parameters { - triggers { - horizonSecs - probability - auctionExtensionSecs - } - } - } - riskFactors { - market - short - long - } - accounts { - type - asset { - id - } - balance - } - data { - market { - id - } - markPrice - indicativeVolume - bestBidVolume - bestOfferVolume - bestStaticBidVolume - bestStaticOfferVolume - openInterest - bestBidPrice - bestOfferPrice - trigger - priceMonitoringBounds { - minValidPrice - maxValidPrice - trigger { - horizonSecs - probability - auctionExtensionSecs - } - referencePrice - } - } - liquidityMonitoringParameters { - triggeringRatio - targetStakeParameters { - timeWindow - scalingFactor - } - } - candles(interval: $interval, since: $since) { - volume - } - tradableInstrument { - instrument { - id - name - code - metadata { - tags - } - product { - ... on Future { - quoteName - settlementAsset { - id - symbol - name - } - oracleSpecForSettlementPrice { - id - } - oracleSpecForTradingTermination { - id - } - oracleSpecBinding { - settlementPriceProperty - tradingTerminationProperty - } - } - } - } - riskModel { - ... on LogNormalRiskModel { - tau - riskAversionParameter - params { - r - sigma - mu - } - } - ... on SimpleRiskModel { - params { - factorLong - factorShort - } - } - } - } - depth { - lastTrade { - price - } - } - } -} - `; - -/** - * __useMarketInfoQueryQuery__ - * - * To run a query within a React component, call `useMarketInfoQueryQuery` and pass it any options that fit your needs. - * When your component renders, `useMarketInfoQueryQuery` 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 } = useMarketInfoQueryQuery({ - * variables: { - * marketId: // value for 'marketId' - * interval: // value for 'interval' - * since: // value for 'since' - * }, - * }); - */ -export function useMarketInfoQueryQuery(baseOptions: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(MarketInfoQueryDocument, options); - } -export function useMarketInfoQueryLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(MarketInfoQueryDocument, options); - } -export type MarketInfoQueryQueryHookResult = ReturnType; -export type MarketInfoQueryLazyQueryHookResult = ReturnType; -export type MarketInfoQueryQueryResult = Apollo.QueryResult; \ No newline at end of file diff --git a/libs/deal-ticket/src/components/__generated___/MarketNames.ts b/libs/deal-ticket/src/components/__generated___/MarketNames.ts deleted file mode 100644 index 99a191096..000000000 --- a/libs/deal-ticket/src/components/__generated___/MarketNames.ts +++ /dev/null @@ -1,60 +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 MarketNamesQueryVariables = Types.Exact<{ [key: string]: never; }>; - - -export type MarketNamesQuery = { __typename?: 'Query', markets?: Array<{ __typename?: 'Market', id: string, state: Types.MarketState, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', code: string, name: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array | null }, product: { __typename?: 'Future', quoteName: string } } } }> | null }; - - -export const MarketNamesDocument = gql` - query MarketNames { - markets { - id - state - tradableInstrument { - instrument { - code - name - metadata { - tags - } - product { - ... on Future { - quoteName - } - } - } - } - } -} - `; - -/** - * __useMarketNamesQuery__ - * - * To run a query within a React component, call `useMarketNamesQuery` and pass it any options that fit your needs. - * When your component renders, `useMarketNamesQuery` 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 } = useMarketNamesQuery({ - * variables: { - * }, - * }); - */ -export function useMarketNamesQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(MarketNamesDocument, options); - } -export function useMarketNamesLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(MarketNamesDocument, options); - } -export type MarketNamesQueryHookResult = ReturnType; -export type MarketNamesLazyQueryHookResult = ReturnType; -export type MarketNamesQueryResult = Apollo.QueryResult; \ No newline at end of file diff --git a/libs/deal-ticket/src/components/deal-ticket/DealTicket.graphql b/libs/deal-ticket/src/components/deal-ticket/DealTicket.graphql new file mode 100644 index 000000000..c612f2594 --- /dev/null +++ b/libs/deal-ticket/src/components/deal-ticket/DealTicket.graphql @@ -0,0 +1,34 @@ +fragment DealTicketMarket on Market { + id + decimalPlaces + positionDecimalPlaces + state + tradingMode + tradableInstrument { + instrument { + id + name + product { + ... on Future { + quoteName + settlementAsset { + id + symbol + name + } + } + } + } + } + depth { + lastTrade { + price + } + } +} + +query DealTicket($marketId: ID!) { + market(id: $marketId) { + ...DealTicketMarket + } +} diff --git a/libs/deal-ticket/src/components/deal-ticket/__generated__/DealTicket.ts b/libs/deal-ticket/src/components/deal-ticket/__generated__/DealTicket.ts new file mode 100644 index 000000000..0f67de30d --- /dev/null +++ b/libs/deal-ticket/src/components/deal-ticket/__generated__/DealTicket.ts @@ -0,0 +1,79 @@ +import { Schema as Types } from '@vegaprotocol/types'; + +import { gql } from '@apollo/client'; +import * as Apollo from '@apollo/client'; +const defaultOptions = {} as const; +export type DealTicketMarketFragment = { __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 } }; + +export type DealTicketQueryVariables = Types.Exact<{ + marketId: Types.Scalars['ID']; +}>; + + +export type DealTicketQuery = { __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 DealTicketMarketFragmentDoc = gql` + fragment DealTicketMarket on Market { + id + decimalPlaces + positionDecimalPlaces + state + tradingMode + tradableInstrument { + instrument { + id + name + product { + ... on Future { + quoteName + settlementAsset { + id + symbol + name + } + } + } + } + } + depth { + lastTrade { + price + } + } +} + `; +export const DealTicketDocument = gql` + query DealTicket($marketId: ID!) { + market(id: $marketId) { + ...DealTicketMarket + } +} + ${DealTicketMarketFragmentDoc}`; + +/** + * __useDealTicketQuery__ + * + * To run a query within a React component, call `useDealTicketQuery` and pass it any options that fit your needs. + * When your component renders, `useDealTicketQuery` 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 } = useDealTicketQuery({ + * variables: { + * marketId: // value for 'marketId' + * }, + * }); + */ +export function useDealTicketQuery(baseOptions: Apollo.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useQuery(DealTicketDocument, options); + } +export function useDealTicketLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useLazyQuery(DealTicketDocument, options); + } +export type DealTicketQueryHookResult = ReturnType; +export type DealTicketLazyQueryHookResult = ReturnType; +export type DealTicketQueryResult = Apollo.QueryResult; \ No newline at end of file diff --git a/libs/deal-ticket/src/components/deal-ticket/__generated__/DealTicketQuery.ts b/libs/deal-ticket/src/components/deal-ticket/__generated__/DealTicketQuery.ts deleted file mode 100644 index a1a6bf1d9..000000000 --- a/libs/deal-ticket/src/components/deal-ticket/__generated__/DealTicketQuery.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// @generated -// This file was automatically generated and should not be edited. - -import { MarketState, MarketTradingMode } from "@vegaprotocol/types"; - -// ==================================================== -// GraphQL query operation: DealTicketQuery -// ==================================================== - -export interface DealTicketQuery_market_tradableInstrument_instrument_product_settlementAsset { - __typename: "Asset"; - /** - * The ID of the asset - */ - id: string; - /** - * The symbol of the asset (e.g: GBP) - */ - symbol: string; - /** - * The full name of the asset (e.g: Great British Pound) - */ - name: string; -} - -export interface DealTicketQuery_market_tradableInstrument_instrument_product { - __typename: "Future"; - /** - * String representing the quote (e.g. BTCUSD -> USD is quote) - */ - quoteName: string; - /** - * The name of the asset (string) - */ - settlementAsset: DealTicketQuery_market_tradableInstrument_instrument_product_settlementAsset; -} - -export interface DealTicketQuery_market_tradableInstrument_instrument { - __typename: "Instrument"; - /** - * Uniquely identify an instrument across all instruments available on Vega (string) - */ - id: string; - /** - * Full and fairly descriptive name for the instrument - */ - name: string; - /** - * A reference to or instance of a fully specified product, including all required product parameters for that product (Product union) - */ - product: DealTicketQuery_market_tradableInstrument_instrument_product; -} - -export interface DealTicketQuery_market_tradableInstrument { - __typename: "TradableInstrument"; - /** - * An instance of, or reference to, a fully specified instrument. - */ - instrument: DealTicketQuery_market_tradableInstrument_instrument; -} - -export interface DealTicketQuery_market_depth_lastTrade { - __typename: "Trade"; - /** - * The price of the trade (probably initially the passive order price, other determination algorithms are possible though) (uint64) - */ - price: string; -} - -export interface DealTicketQuery_market_depth { - __typename: "MarketDepth"; - /** - * Last trade for the given market (if available) - */ - lastTrade: DealTicketQuery_market_depth_lastTrade | null; -} - -export interface DealTicketQuery_market { - __typename: "Market"; - /** - * Market ID - */ - id: string; - /** - * decimalPlaces indicates 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: - * Currency Balance decimalPlaces Real Balance - * GBP 100 0 GBP 100 - * GBP 100 2 GBP 1.00 - * GBP 100 4 GBP 0.01 - * GBP 1 4 GBP 0.0001 ( 0.01p ) - * - * GBX (pence) 100 0 GBP 1.00 (100p ) - * GBX (pence) 100 2 GBP 0.01 ( 1p ) - * GBX (pence) 100 4 GBP 0.0001 ( 0.01p ) - * GBX (pence) 1 4 GBP 0.000001 ( 0.0001p) - */ - decimalPlaces: number; - /** - * positionDecimalPlaces indicates 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. - */ - positionDecimalPlaces: number; - /** - * Current state of the market - */ - state: MarketState; - /** - * Current mode of execution of the market - */ - tradingMode: MarketTradingMode; - /** - * An instance of, or reference to, a tradable instrument. - */ - tradableInstrument: DealTicketQuery_market_tradableInstrument; - /** - * Current depth on the order book for this market - */ - depth: DealTicketQuery_market_depth; -} - -export interface DealTicketQuery { - /** - * An instrument that is trading on the Vega network - */ - market: DealTicketQuery_market | null; -} - -export interface DealTicketQueryVariables { - marketId: string; -} diff --git a/libs/deal-ticket/src/components/deal-ticket/__generated__/MarketNames.ts b/libs/deal-ticket/src/components/deal-ticket/__generated__/MarketNames.ts deleted file mode 100644 index c91ec7e1f..000000000 --- a/libs/deal-ticket/src/components/deal-ticket/__generated__/MarketNames.ts +++ /dev/null @@ -1,77 +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: MarketNames -// ==================================================== - -export interface MarketNames_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 MarketNames_markets_tradableInstrument_instrument_product { - __typename: "Future"; - /** - * String representing the quote (e.g. BTCUSD -> USD is quote) - */ - quoteName: string; -} - -export interface MarketNames_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: MarketNames_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: MarketNames_markets_tradableInstrument_instrument_product; -} - -export interface MarketNames_markets_tradableInstrument { - __typename: "TradableInstrument"; - /** - * An instance of, or reference to, a fully specified instrument. - */ - instrument: MarketNames_markets_tradableInstrument_instrument; -} - -export interface MarketNames_markets { - __typename: "Market"; - /** - * Market ID - */ - id: string; - /** - * Current state of the market - */ - state: MarketState; - /** - * An instance of, or reference to, a tradable instrument. - */ - tradableInstrument: MarketNames_markets_tradableInstrument; -} - -export interface MarketNames { - /** - * One or more instruments that are trading on the VEGA network - */ - markets: MarketNames_markets[] | null; -} diff --git a/libs/deal-ticket/src/components/deal-ticket/__generated__/index.ts b/libs/deal-ticket/src/components/deal-ticket/__generated__/index.ts deleted file mode 100644 index 1a861aa78..000000000 --- a/libs/deal-ticket/src/components/deal-ticket/__generated__/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './DealTicketQuery'; -export * from './MarketNames'; diff --git a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-amount.tsx b/libs/deal-ticket/src/components/deal-ticket/deal-ticket-amount.tsx index e3f288aeb..3279a9a72 100644 --- a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-amount.tsx +++ b/libs/deal-ticket/src/components/deal-ticket/deal-ticket-amount.tsx @@ -2,12 +2,12 @@ import type { UseFormRegister } from 'react-hook-form'; import type { Order } from '@vegaprotocol/orders'; import { DealTicketMarketAmount } from './deal-ticket-market-amount'; import { DealTicketLimitAmount } from './deal-ticket-limit-amount'; -import type { DealTicketQuery_market } from './__generated__/DealTicketQuery'; -import { OrderType } from '@vegaprotocol/types'; +import type { DealTicketMarketFragment } from './__generated__/DealTicket'; +import { Schema } from '@vegaprotocol/types'; export interface DealTicketAmountProps { - orderType: OrderType; - market: DealTicketQuery_market; + orderType: Schema.OrderType; + market: DealTicketMarketFragment; register: UseFormRegister; quoteName: string; price?: string; @@ -18,9 +18,9 @@ export const DealTicketAmount = ({ ...props }: DealTicketAmountProps) => { switch (orderType) { - case OrderType.TYPE_MARKET: + case Schema.OrderType.TYPE_MARKET: return ; - case OrderType.TYPE_LIMIT: + case Schema.OrderType.TYPE_LIMIT: return ; default: { throw new Error('Invalid ticket type'); diff --git a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-container.tsx b/libs/deal-ticket/src/components/deal-ticket/deal-ticket-container.tsx index 3282ac731..ad02e48db 100644 --- a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-container.tsx +++ b/libs/deal-ticket/src/components/deal-ticket/deal-ticket-container.tsx @@ -1,56 +1,19 @@ -import { gql, useQuery } from '@apollo/client'; import { AsyncRenderer, Splash } from '@vegaprotocol/ui-toolkit'; import { DealTicketManager } from './deal-ticket-manager'; import { t } from '@vegaprotocol/react-helpers'; -import type { DealTicketQuery_market, DealTicketQuery } from './'; - -const DEAL_TICKET_QUERY = gql` - query DealTicketQuery($marketId: ID!) { - market(id: $marketId) { - id - decimalPlaces - positionDecimalPlaces - state - tradingMode - tradableInstrument { - instrument { - id - name - product { - ... on Future { - quoteName - settlementAsset { - id - symbol - name - } - } - } - } - } - depth { - lastTrade { - price - } - } - } - } -`; - -type childrenProps = { - market: DealTicketQuery_market; -}; +import { useDealTicketQuery } from './__generated__/DealTicket'; +import type { DealTicketQuery } from './__generated__/DealTicket'; export interface DealTicketContainerProps { marketId: string; - children?(props: childrenProps): JSX.Element; + children?(props: DealTicketQuery): JSX.Element; } export const DealTicketContainer = ({ marketId, children, }: DealTicketContainerProps) => { - const { data, loading, error } = useQuery(DEAL_TICKET_QUERY, { + const { data, loading, error } = useDealTicketQuery({ variables: { marketId }, }); diff --git a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-limit-amount.tsx b/libs/deal-ticket/src/components/deal-ticket/deal-ticket-limit-amount.tsx index 4d5e169ea..edf9c079b 100644 --- a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-limit-amount.tsx +++ b/libs/deal-ticket/src/components/deal-ticket/deal-ticket-limit-amount.tsx @@ -13,8 +13,8 @@ export const DealTicketLimitAmount = ({ market, quoteName, }: DealTicketLimitAmountProps) => { - const priceStep = toDecimal(market.decimalPlaces); - const sizeStep = toDecimal(market.positionDecimalPlaces); + const priceStep = toDecimal(market?.decimalPlaces); + const sizeStep = toDecimal(market?.positionDecimalPlaces); return (
diff --git a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-manager.tsx b/libs/deal-ticket/src/components/deal-ticket/deal-ticket-manager.tsx index fa16dc3af..65734c522 100644 --- a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-manager.tsx +++ b/libs/deal-ticket/src/components/deal-ticket/deal-ticket-manager.tsx @@ -1,14 +1,14 @@ import type { ReactNode } from 'react'; import { VegaTxStatus } from '@vegaprotocol/wallet'; import { DealTicket } from './deal-ticket'; -import type { DealTicketQuery_market } from './__generated__/DealTicketQuery'; +import type { DealTicketMarketFragment } from './__generated__/DealTicket'; import { useOrderSubmit, OrderFeedback } from '@vegaprotocol/orders'; -import { OrderStatus } from '@vegaprotocol/types'; +import { Schema } from '@vegaprotocol/types'; import { Icon, Intent } from '@vegaprotocol/ui-toolkit'; import { t } from '@vegaprotocol/react-helpers'; export interface DealTicketManagerProps { - market: DealTicketQuery_market; + market: DealTicketMarketFragment; children?: ReactNode | ReactNode[]; } @@ -44,28 +44,28 @@ export const DealTicketManager = ({ }; export const getOrderDialogTitle = ( - status?: OrderStatus + status?: Schema.OrderStatus ): string | undefined => { if (!status) { return; } switch (status) { - case OrderStatus.STATUS_ACTIVE: + case Schema.OrderStatus.STATUS_ACTIVE: return t('Order submitted'); - case OrderStatus.STATUS_FILLED: + case Schema.OrderStatus.STATUS_FILLED: return t('Order filled'); - case OrderStatus.STATUS_PARTIALLY_FILLED: + case Schema.OrderStatus.STATUS_PARTIALLY_FILLED: return t('Order partially filled'); - case OrderStatus.STATUS_PARKED: + case Schema.OrderStatus.STATUS_PARKED: return t('Order parked'); - case OrderStatus.STATUS_STOPPED: + case Schema.OrderStatus.STATUS_STOPPED: return t('Order stopped'); - case OrderStatus.STATUS_CANCELLED: + case Schema.OrderStatus.STATUS_CANCELLED: return t('Order cancelled'); - case OrderStatus.STATUS_EXPIRED: + case Schema.OrderStatus.STATUS_EXPIRED: return t('Order expired'); - case OrderStatus.STATUS_REJECTED: + case Schema.OrderStatus.STATUS_REJECTED: return t('Order rejected'); default: return t('Submission failed'); @@ -73,22 +73,22 @@ export const getOrderDialogTitle = ( }; export const getOrderDialogIntent = ( - status?: OrderStatus + status?: Schema.OrderStatus ): Intent | undefined => { if (!status) { return; } switch (status) { - case OrderStatus.STATUS_PARKED: - case OrderStatus.STATUS_EXPIRED: - case OrderStatus.STATUS_PARTIALLY_FILLED: + case Schema.OrderStatus.STATUS_PARKED: + case Schema.OrderStatus.STATUS_EXPIRED: + case Schema.OrderStatus.STATUS_PARTIALLY_FILLED: return Intent.Warning; - case OrderStatus.STATUS_REJECTED: - case OrderStatus.STATUS_STOPPED: - case OrderStatus.STATUS_CANCELLED: + case Schema.OrderStatus.STATUS_REJECTED: + case Schema.OrderStatus.STATUS_STOPPED: + case Schema.OrderStatus.STATUS_CANCELLED: return Intent.Danger; - case OrderStatus.STATUS_FILLED: - case OrderStatus.STATUS_ACTIVE: + case Schema.OrderStatus.STATUS_FILLED: + case Schema.OrderStatus.STATUS_ACTIVE: return Intent.Success; default: return; @@ -96,19 +96,19 @@ export const getOrderDialogIntent = ( }; export const getOrderDialogIcon = ( - status?: OrderStatus + status?: Schema.OrderStatus ): ReactNode | undefined => { if (!status) { return; } switch (status) { - case OrderStatus.STATUS_PARKED: - case OrderStatus.STATUS_EXPIRED: + case Schema.OrderStatus.STATUS_PARKED: + case Schema.OrderStatus.STATUS_EXPIRED: return ; - case OrderStatus.STATUS_REJECTED: - case OrderStatus.STATUS_STOPPED: - case OrderStatus.STATUS_CANCELLED: + case Schema.OrderStatus.STATUS_REJECTED: + case Schema.OrderStatus.STATUS_STOPPED: + case Schema.OrderStatus.STATUS_CANCELLED: return ; default: return; diff --git a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-market-amount.tsx b/libs/deal-ticket/src/components/deal-ticket/deal-ticket-market-amount.tsx index 9ff846975..2dffa482b 100644 --- a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-market-amount.tsx +++ b/libs/deal-ticket/src/components/deal-ticket/deal-ticket-market-amount.tsx @@ -14,7 +14,7 @@ export const DealTicketMarketAmount = ({ market, quoteName, }: DealTicketMarketAmountProps) => { - const sizeStep = toDecimal(market.positionDecimalPlaces); + const sizeStep = toDecimal(market?.positionDecimalPlaces); return (
diff --git a/libs/deal-ticket/src/components/deal-ticket/deal-ticket.spec.tsx b/libs/deal-ticket/src/components/deal-ticket/deal-ticket.spec.tsx index eeba722d5..4acb94ca3 100644 --- a/libs/deal-ticket/src/components/deal-ticket/deal-ticket.spec.tsx +++ b/libs/deal-ticket/src/components/deal-ticket/deal-ticket.spec.tsx @@ -2,27 +2,23 @@ import { VegaWalletContext } from '@vegaprotocol/wallet'; import { addDecimal } from '@vegaprotocol/react-helpers'; import { fireEvent, render, screen, act } from '@testing-library/react'; import { DealTicket } from './deal-ticket'; -import type { DealTicketQuery_market } from './__generated__/DealTicketQuery'; -import { - MarketState, - MarketTradingMode, - OrderTimeInForce, - OrderType, -} from '@vegaprotocol/types'; +import type { DealTicketMarketFragment } from './__generated__/DealTicket'; +import { Schema } from '@vegaprotocol/types'; import type { Order } from '@vegaprotocol/orders'; -const market: DealTicketQuery_market = { +const market: DealTicketMarketFragment = { __typename: 'Market', id: 'market-id', - name: 'market-name', decimalPlaces: 2, positionDecimalPlaces: 1, - tradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, - state: MarketState.STATE_ACTIVE, + tradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS, + state: Schema.MarketState.STATE_ACTIVE, tradableInstrument: { __typename: 'TradableInstrument', instrument: { __typename: 'Instrument', + id: '1', + name: 'Instrument name', product: { __typename: 'Future', quoteName: 'quote-name', @@ -66,7 +62,7 @@ describe('DealTicket', () => { // Assert defaults are used expect( - screen.getByTestId(`order-type-${OrderType.TYPE_MARKET}-selected`) + screen.getByTestId(`order-type-${Schema.OrderType.TYPE_MARKET}-selected`) ).toBeInTheDocument(); expect( screen.queryByTestId('order-side-SIDE_BUY-selected') @@ -78,7 +74,7 @@ describe('DealTicket', () => { String(1 / Math.pow(10, market.positionDecimalPlaces)) ); expect(screen.getByTestId('order-tif')).toHaveValue( - OrderTimeInForce.TIME_IN_FORCE_IOC + Schema.OrderTimeInForce.TIME_IN_FORCE_IOC ); // Assert last price is shown @@ -105,10 +101,10 @@ describe('DealTicket', () => { expect(screen.getByTestId('order-size')).toHaveDisplayValue('200'); fireEvent.change(screen.getByTestId('order-tif'), { - target: { value: OrderTimeInForce.TIME_IN_FORCE_IOC }, + target: { value: Schema.OrderTimeInForce.TIME_IN_FORCE_IOC }, }); expect(screen.getByTestId('order-tif')).toHaveValue( - OrderTimeInForce.TIME_IN_FORCE_IOC + Schema.OrderTimeInForce.TIME_IN_FORCE_IOC ); // Switch to limit order @@ -116,7 +112,7 @@ describe('DealTicket', () => { // Check all TIF options shown expect(screen.getByTestId('order-tif').children).toHaveLength( - Object.keys(OrderTimeInForce).length + Object.keys(Schema.OrderTimeInForce).length ); }); @@ -133,35 +129,35 @@ describe('DealTicket', () => { // Switch to limit order and check all TIF options shown fireEvent.click(screen.getByTestId('order-type-TYPE_LIMIT')); expect(screen.getByTestId('order-tif').children).toHaveLength( - Object.keys(OrderTimeInForce).length + Object.keys(Schema.OrderTimeInForce).length ); // Change to GTC fireEvent.change(screen.getByTestId('order-tif'), { - target: { value: OrderTimeInForce.TIME_IN_FORCE_GTC }, + target: { value: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC }, }); expect(screen.getByTestId('order-tif')).toHaveValue( - OrderTimeInForce.TIME_IN_FORCE_GTC + Schema.OrderTimeInForce.TIME_IN_FORCE_GTC ); // Switch back to market order and TIF should now be IOC fireEvent.click(screen.getByTestId('order-type-TYPE_MARKET')); expect(screen.getByTestId('order-tif')).toHaveValue( - OrderTimeInForce.TIME_IN_FORCE_IOC + Schema.OrderTimeInForce.TIME_IN_FORCE_IOC ); // Switch tif to FOK fireEvent.change(screen.getByTestId('order-tif'), { - target: { value: OrderTimeInForce.TIME_IN_FORCE_FOK }, + target: { value: Schema.OrderTimeInForce.TIME_IN_FORCE_FOK }, }); expect(screen.getByTestId('order-tif')).toHaveValue( - OrderTimeInForce.TIME_IN_FORCE_FOK + Schema.OrderTimeInForce.TIME_IN_FORCE_FOK ); // Change back to limit and check we are still on FOK fireEvent.click(screen.getByTestId('order-type-TYPE_LIMIT')); expect(screen.getByTestId('order-tif')).toHaveValue( - OrderTimeInForce.TIME_IN_FORCE_GTC + Schema.OrderTimeInForce.TIME_IN_FORCE_GTC ); }); }); diff --git a/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx b/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx index c1ed43607..0d0821c80 100644 --- a/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx +++ b/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx @@ -10,7 +10,7 @@ import { TypeSelector } from './type-selector'; import { SideSelector } from './side-selector'; import { DealTicketAmount } from './deal-ticket-amount'; import { TimeInForceSelector } from './time-in-force-selector'; -import type { DealTicketQuery_market } from './__generated__/DealTicketQuery'; +import type { DealTicketMarketFragment } from './__generated__/DealTicket'; import { ExpirySelector } from './expiry-selector'; import type { Order } from '@vegaprotocol/orders'; import { getDefaultOrder, useOrderValidation } from '@vegaprotocol/orders'; @@ -19,7 +19,7 @@ import { OrderTimeInForce, OrderType } from '@vegaprotocol/types'; export type TransactionStatus = 'default' | 'pending'; export interface DealTicketProps { - market: DealTicketQuery_market; + market: DealTicketMarketFragment; submit: (order: Order) => void; transactionStatus: TransactionStatus; defaultOrder?: Order; diff --git a/libs/deal-ticket/src/components/deal-ticket/index.ts b/libs/deal-ticket/src/components/deal-ticket/index.ts index 97827ec50..d9f11eae6 100644 --- a/libs/deal-ticket/src/components/deal-ticket/index.ts +++ b/libs/deal-ticket/src/components/deal-ticket/index.ts @@ -1,4 +1,4 @@ -export * from './__generated__'; +export * from './__generated__/DealTicket'; export * from './deal-ticket-amount'; export * from './deal-ticket-container'; export * from './deal-ticket-limit-amount'; diff --git a/libs/deal-ticket/src/components/deal-ticket/market-selector.tsx b/libs/deal-ticket/src/components/deal-ticket/market-selector.tsx index 7082ef50d..fb5ddd2cc 100644 --- a/libs/deal-ticket/src/components/deal-ticket/market-selector.tsx +++ b/libs/deal-ticket/src/components/deal-ticket/market-selector.tsx @@ -8,7 +8,7 @@ import React, { } from 'react'; import * as DialogPrimitives from '@radix-ui/react-dialog'; import classNames from 'classnames'; -import type { DealTicketQuery_market } from './'; +import type { DealTicketMarketFragment } from './'; import { ButtonLink, Icon, @@ -28,7 +28,7 @@ import type { Market } from '@vegaprotocol/market-list'; import { marketsProvider } from '@vegaprotocol/market-list'; interface Props { - market: DealTicketQuery_market; + market: DealTicketMarketFragment; setMarket: (marketId: string) => void; ItemRenderer?: React.FC<{ market: Market; diff --git a/libs/deal-ticket/src/components/deal-ticket/side-selector.tsx b/libs/deal-ticket/src/components/deal-ticket/side-selector.tsx index 59e5d9e14..4b7b06a95 100644 --- a/libs/deal-ticket/src/components/deal-ticket/side-selector.tsx +++ b/libs/deal-ticket/src/components/deal-ticket/side-selector.tsx @@ -1,17 +1,17 @@ import { FormGroup } from '@vegaprotocol/ui-toolkit'; import { Toggle } from '@vegaprotocol/ui-toolkit'; import { t } from '@vegaprotocol/react-helpers'; -import { Side } from '@vegaprotocol/types'; +import { Schema } from '@vegaprotocol/types'; interface SideSelectorProps { - value: Side; - onSelect: (side: Side) => void; + value: Schema.Side; + onSelect: (side: Schema.Side) => void; } export const SideSelector = ({ value, onSelect }: SideSelectorProps) => { const toggles = [ - { label: t('Long'), value: Side.SIDE_BUY }, - { label: t('Short'), value: Side.SIDE_SELL }, + { label: t('Long'), value: Schema.Side.SIDE_BUY }, + { label: t('Short'), value: Schema.Side.SIDE_SELL }, ]; return ( @@ -21,7 +21,7 @@ export const SideSelector = ({ value, onSelect }: SideSelectorProps) => { name="order-side" toggles={toggles} checkedValue={value} - onChange={(e) => onSelect(e.target.value as Side)} + onChange={(e) => onSelect(e.target.value as Schema.Side)} /> ); diff --git a/libs/deal-ticket/src/components/deal-ticket/time-in-force-selector.tsx b/libs/deal-ticket/src/components/deal-ticket/time-in-force-selector.tsx index f4f200be1..0a953f2b9 100644 --- a/libs/deal-ticket/src/components/deal-ticket/time-in-force-selector.tsx +++ b/libs/deal-ticket/src/components/deal-ticket/time-in-force-selector.tsx @@ -1,27 +1,27 @@ import { FormGroup, Select } from '@vegaprotocol/ui-toolkit'; -import { OrderTimeInForce, OrderType } from '@vegaprotocol/types'; +import { Schema } from '@vegaprotocol/types'; import { t } from '@vegaprotocol/react-helpers'; interface TimeInForceSelectorProps { - value: OrderTimeInForce; - orderType: OrderType; - onSelect: (tif: OrderTimeInForce) => void; + value: Schema.OrderTimeInForce; + orderType: Schema.OrderType; + onSelect: (tif: Schema.OrderTimeInForce) => void; } // More detail in https://docs.vega.xyz/docs/mainnet/graphql/enums/order-time-in-force export const timeInForceLabel = (tif: string) => { switch (tif) { - case OrderTimeInForce.TIME_IN_FORCE_GTC: + case Schema.OrderTimeInForce.TIME_IN_FORCE_GTC: return t(`Good 'til Cancelled (GTC)`); - case OrderTimeInForce.TIME_IN_FORCE_IOC: + case Schema.OrderTimeInForce.TIME_IN_FORCE_IOC: return t('Immediate or Cancel (IOC)'); - case OrderTimeInForce.TIME_IN_FORCE_FOK: + case Schema.OrderTimeInForce.TIME_IN_FORCE_FOK: return t('Fill or Kill (FOK)'); - case OrderTimeInForce.TIME_IN_FORCE_GTT: + case Schema.OrderTimeInForce.TIME_IN_FORCE_GTT: return t(`Good 'til Time (GTT)`); - case OrderTimeInForce.TIME_IN_FORCE_GFN: + case Schema.OrderTimeInForce.TIME_IN_FORCE_GFN: return t('Good for Normal (GFN)'); - case OrderTimeInForce.TIME_IN_FORCE_GFA: + case Schema.OrderTimeInForce.TIME_IN_FORCE_GFA: return t('Good for Auction (GFA)'); default: return t(tif); @@ -34,12 +34,12 @@ export const TimeInForceSelector = ({ onSelect, }: TimeInForceSelectorProps) => { const options = - orderType === OrderType.TYPE_LIMIT - ? Object.entries(OrderTimeInForce) - : Object.entries(OrderTimeInForce).filter( + orderType === Schema.OrderType.TYPE_LIMIT + ? Object.entries(Schema.OrderTimeInForce) + : Object.entries(Schema.OrderTimeInForce).filter( ([_, timeInForce]) => - timeInForce === OrderTimeInForce.TIME_IN_FORCE_FOK || - timeInForce === OrderTimeInForce.TIME_IN_FORCE_IOC + timeInForce === Schema.OrderTimeInForce.TIME_IN_FORCE_FOK || + timeInForce === Schema.OrderTimeInForce.TIME_IN_FORCE_IOC ); return ( @@ -47,7 +47,7 @@ export const TimeInForceSelector = ({