tidy up deal ticket query and market page query

This commit is contained in:
Matthew Russell 2022-03-29 16:19:23 -07:00
parent fdfcc4e5db
commit d3d28947ea
5 changed files with 20 additions and 217 deletions

View File

@ -13,34 +13,6 @@ const MARKET_QUERY = gql`
market(id: $marketId) { market(id: $marketId) {
id id
name name
decimalPlaces
state
tradingMode
tradableInstrument {
instrument {
product {
... on Future {
quoteName
settlementAsset {
id
symbol
name
}
}
}
}
}
trades {
id
price
size
createdAt
}
depth {
lastTrade {
price
}
}
} }
} }
`; `;

View File

@ -3,92 +3,10 @@
// @generated // @generated
// This file was automatically generated and should not be edited. // This file was automatically generated and should not be edited.
import { MarketState, MarketTradingMode } from "./../../../../../libs/types/src/__generated__/globalTypes";
// ==================================================== // ====================================================
// GraphQL query operation: Market // GraphQL query operation: Market
// ==================================================== // ====================================================
export interface Market_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 Market_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: Market_market_tradableInstrument_instrument_product_settlementAsset;
}
export interface Market_market_tradableInstrument_instrument {
__typename: "Instrument";
/**
* A reference to or instance of a fully specified product, including all required product parameters for that product (Product union)
*/
product: Market_market_tradableInstrument_instrument_product;
}
export interface Market_market_tradableInstrument {
__typename: "TradableInstrument";
/**
* An instance of or reference to a fully specified instrument.
*/
instrument: Market_market_tradableInstrument_instrument;
}
export interface Market_market_trades {
__typename: "Trade";
/**
* The hash of the trade data
*/
id: string;
/**
* The price of the trade (probably initially the passive order price, other determination algorithms are possible though) (uint64)
*/
price: string;
/**
* The number of contracts trades, will always be <= the remaining size of both orders immediately before the trade (uint64)
*/
size: string;
/**
* RFC3339Nano time for when the trade occurred
*/
createdAt: string;
}
export interface Market_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 Market_market_depth {
__typename: "MarketDepth";
/**
* Last trade for the given market (if available)
*/
lastTrade: Market_market_depth_lastTrade | null;
}
export interface Market_market { export interface Market_market {
__typename: "Market"; __typename: "Market";
/** /**
@ -99,43 +17,6 @@ export interface Market_market {
* Market full name * Market full name
*/ */
name: string; name: 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;
/**
* 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: Market_market_tradableInstrument;
/**
* Trades on a market
*/
trades: Market_market_trades[] | null;
/**
* Current depth on the order book for this market
*/
depth: Market_market_depth;
} }
export interface Market { export interface Market {

View File

@ -9,32 +9,12 @@ import { MarketState, MarketTradingMode } from "./../../../types/src/__generated
// GraphQL query operation: DealTicketQuery // 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 { export interface DealTicketQuery_market_tradableInstrument_instrument_product {
__typename: "Future"; __typename: "Future";
/** /**
* String representing the quote (e.g. BTCUSD -> USD is quote) * String representing the quote (e.g. BTCUSD -> USD is quote)
*/ */
quoteName: string; quoteName: string;
/**
* The name of the asset (string)
*/
settlementAsset: DealTicketQuery_market_tradableInstrument_instrument_product_settlementAsset;
} }
export interface DealTicketQuery_market_tradableInstrument_instrument { export interface DealTicketQuery_market_tradableInstrument_instrument {
@ -53,26 +33,6 @@ export interface DealTicketQuery_market_tradableInstrument {
instrument: DealTicketQuery_market_tradableInstrument_instrument; instrument: DealTicketQuery_market_tradableInstrument_instrument;
} }
export interface DealTicketQuery_market_trades {
__typename: "Trade";
/**
* The hash of the trade data
*/
id: string;
/**
* The price of the trade (probably initially the passive order price, other determination algorithms are possible though) (uint64)
*/
price: string;
/**
* The number of contracts trades, will always be <= the remaining size of both orders immediately before the trade (uint64)
*/
size: string;
/**
* RFC3339Nano time for when the trade occurred
*/
createdAt: string;
}
export interface DealTicketQuery_market_depth_lastTrade { export interface DealTicketQuery_market_depth_lastTrade {
__typename: "Trade"; __typename: "Trade";
/** /**
@ -95,10 +55,6 @@ export interface DealTicketQuery_market {
* Market ID * Market ID
*/ */
id: string; id: string;
/**
* Market full name
*/
name: string;
/** /**
* decimalPlaces indicates the number of decimal places that an integer must be shifted by in order to get a correct * 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) * number denominated in the currency of the Market. (uint64)
@ -128,10 +84,6 @@ export interface DealTicketQuery_market {
* An instance of or reference to a tradable instrument. * An instance of or reference to a tradable instrument.
*/ */
tradableInstrument: DealTicketQuery_market_tradableInstrument; tradableInstrument: DealTicketQuery_market_tradableInstrument;
/**
* Trades on a market
*/
trades: DealTicketQuery_market_trades[] | null;
/** /**
* Current depth on the order book for this market * Current depth on the order book for this market
*/ */

View File

@ -7,7 +7,6 @@ const DEAL_TICKET_QUERY = gql`
query DealTicketQuery($marketId: ID!) { query DealTicketQuery($marketId: ID!) {
market(id: $marketId) { market(id: $marketId) {
id id
name
decimalPlaces decimalPlaces
state state
tradingMode tradingMode
@ -16,21 +15,10 @@ const DEAL_TICKET_QUERY = gql`
product { product {
... on Future { ... on Future {
quoteName quoteName
settlementAsset {
id
symbol
name
} }
} }
} }
} }
}
trades {
id
price
size
createdAt
}
depth { depth {
lastTrade { lastTrade {
price price

View File

@ -6,8 +6,10 @@ import {
} from '@vegaprotocol/wallet'; } from '@vegaprotocol/wallet';
import { addDecimal } from '@vegaprotocol/react-helpers'; import { addDecimal } from '@vegaprotocol/react-helpers';
import { fireEvent, render, screen } from '@testing-library/react'; import { fireEvent, render, screen } from '@testing-library/react';
import { DealTicket, Market } from './deal-ticket'; import { DealTicket } from './deal-ticket';
import { Order } from './use-order-state'; import { Order } from './use-order-state';
import { DealTicketQuery_market } from './__generated__/DealTicketQuery';
import { MarketState, MarketTradingMode } from '@vegaprotocol/types';
const order: Order = { const order: Order = {
type: OrderType.Market, type: OrderType.Market,
@ -15,34 +17,42 @@ const order: Order = {
timeInForce: OrderTimeInForce.FOK, timeInForce: OrderTimeInForce.FOK,
side: null, side: null,
}; };
const market: Market = { const market: DealTicketQuery_market = {
__typename: 'Market',
id: 'market-id', id: 'market-id',
decimalPlaces: 2, decimalPlaces: 2,
tradingMode: 'Continuous', tradingMode: MarketTradingMode.Continuous,
state: 'Active', state: MarketState.Active,
tradableInstrument: { tradableInstrument: {
__typename: 'TradableInstrument',
instrument: { instrument: {
__typename: 'Instrument',
product: { product: {
__typename: 'Future',
quoteName: 'quote-name', quoteName: 'quote-name',
settlementAsset: {
id: 'asset-id',
symbol: 'asset-symbol',
name: 'asset-name',
},
}, },
}, },
}, },
depth: { depth: {
__typename: 'MarketDepth',
lastTrade: { lastTrade: {
__typename: 'Trade',
price: '100', price: '100',
}, },
}, },
}; };
const submit = jest.fn();
const transactionStatus = 'default';
function generateJsx() { function generateJsx() {
return ( return (
<VegaWalletContext.Provider value={{} as any}> <VegaWalletContext.Provider value={{} as any}>
<DealTicket defaultOrder={order} market={market} /> <DealTicket
defaultOrder={order}
market={market}
submit={submit}
transactionStatus={transactionStatus}
/>
</VegaWalletContext.Provider> </VegaWalletContext.Provider>
); );
} }