diff --git a/apps/console-lite/src/app/components/deal-ticket/use-order-validation.spec.tsx b/apps/console-lite/src/app/components/deal-ticket/use-order-validation.spec.tsx index 93810b4c2..5de1d0cd9 100644 --- a/apps/console-lite/src/app/components/deal-ticket/use-order-validation.spec.tsx +++ b/apps/console-lite/src/app/components/deal-ticket/use-order-validation.spec.tsx @@ -198,7 +198,11 @@ describe('useOrderValidation', () => { `( 'Returns an error message for market state when not accepting orders', ({ state }) => { - const { result } = setup({ market: { ...defaultOrder.market, state } }); + const market = { + ...defaultOrder.market, + data: { ...defaultOrder.market.data, marketState: state }, + }; + const { result } = setup({ market }); expect(result.current).toStrictEqual({ isDisabled: true, message: `This market is ${marketTranslations( @@ -220,14 +224,19 @@ describe('useOrderValidation', () => { balance: '0', margin: '100', balanceError: false, - // asset, }); - const { result } = setup({ - market: { - ...defaultOrder.market, - state, - tradingMode: Schema.MarketTradingMode.TRADING_MODE_BATCH_AUCTION, + + const market = { + ...defaultOrder.market, + data: { + ...defaultOrder.market.data, + marketState: state, + marketTradingMode: + Schema.MarketTradingMode.TRADING_MODE_BATCH_AUCTION, }, + }; + const { result } = setup({ + market, order: { ...order, type: Schema.OrderType.TYPE_LIMIT, @@ -252,8 +261,12 @@ describe('useOrderValidation', () => { `( `Returns an error message when trying to submit a non-limit order for a "$tradingMode" market`, ({ tradingMode, errorMessage }) => { + const market = { + ...defaultOrder.market, + data: { ...defaultOrder.market.data, marketTradingMode: tradingMode }, + }; const { result } = setup({ - market: { ...defaultOrder.market, tradingMode }, + market, order: { ...order, type: Schema.OrderType.TYPE_MARKET, @@ -278,8 +291,12 @@ describe('useOrderValidation', () => { `( `Returns an error message when submitting a limit order with a "$orderTimeInForce" value to a "$tradingMode" market`, ({ tradingMode, orderTimeInForce, errorMessage }) => { + const market = { + ...defaultOrder.market, + data: { ...defaultOrder.market.data, marketTradingMode: tradingMode }, + }; const { result } = setup({ - market: { ...defaultOrder.market, tradingMode }, + market, order: { ...order, type: Schema.OrderType.TYPE_LIMIT, @@ -382,14 +399,15 @@ describe('useOrderValidation', () => { `( 'Returns error when market state is pending and size is wrong', ({ state }) => { + const market = { + ...defaultOrder.market, + data: { ...defaultOrder.market.data, marketState: state }, + }; const { result } = setup({ fieldErrors: { size: { type: `validate`, message: DealTicket.ERROR_SIZE_DECIMAL }, }, - market: { - ...market, - state, - }, + market, }); expect(result.current).toStrictEqual({ isDisabled: true, diff --git a/apps/console-lite/src/app/components/deal-ticket/use-order-validation.tsx b/apps/console-lite/src/app/components/deal-ticket/use-order-validation.tsx index 31f559161..45bf064a4 100644 --- a/apps/console-lite/src/app/components/deal-ticket/use-order-validation.tsx +++ b/apps/console-lite/src/app/components/deal-ticket/use-order-validation.tsx @@ -169,13 +169,13 @@ export const useOrderValidation = ({ Schema.MarketState.STATE_TRADING_TERMINATED, Schema.MarketState.STATE_CANCELLED, Schema.MarketState.STATE_CLOSED, - ].includes(market.state) + ].includes(market.data.marketState) ) { return { isDisabled: true, message: t( `This market is ${marketTranslations( - market.state + market.data.marketState )} and not accepting orders` ), section: DEAL_TICKET_SECTION.SUMMARY, @@ -186,7 +186,7 @@ export const useOrderValidation = ({ [ Schema.MarketState.STATE_PROPOSED, Schema.MarketState.STATE_PENDING, - ].includes(market.state) + ].includes(market.data.marketState) ) { if (fieldErrorChecking) { return fieldErrorChecking; @@ -195,7 +195,7 @@ export const useOrderValidation = ({ isDisabled: false, message: t( `This market is ${marketTranslations( - market.state + market.data.marketState )} and only accepting liquidity commitment orders` ), section: DEAL_TICKET_SECTION.SUMMARY, @@ -205,9 +205,9 @@ export const useOrderValidation = ({ if (isMarketInAuction(market)) { if (order.type === Schema.OrderType.TYPE_MARKET) { if ( - market.tradingMode === + market.data.marketTradingMode === Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION && - market.data?.trigger === + market.data.trigger === Schema.AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY ) { return { @@ -230,9 +230,9 @@ export const useOrderValidation = ({ }; } if ( - market.tradingMode === + market.data.marketTradingMode === Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION && - market.data?.trigger === Schema.AuctionTrigger.AUCTION_TRIGGER_PRICE + market.data.trigger === Schema.AuctionTrigger.AUCTION_TRIGGER_PRICE ) { return { isDisabled: true, @@ -270,9 +270,9 @@ export const useOrderValidation = ({ ].includes(order.timeInForce) ) { if ( - market.tradingMode === + market.data.marketTradingMode === Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION && - market.data?.trigger === + market.data.trigger === Schema.AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY ) { return { @@ -297,9 +297,9 @@ export const useOrderValidation = ({ }; } if ( - market.tradingMode === + market.data.marketTradingMode === Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION && - market.data?.trigger === Schema.AuctionTrigger.AUCTION_TRIGGER_PRICE + market.data.trigger === Schema.AuctionTrigger.AUCTION_TRIGGER_PRICE ) { return { isDisabled: true, @@ -355,7 +355,7 @@ export const useOrderValidation = ({ Schema.MarketTradingMode.TRADING_MODE_BATCH_AUCTION, Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION, Schema.MarketTradingMode.TRADING_MODE_OPENING_AUCTION, - ].includes(market.tradingMode) + ].includes(market.data.marketTradingMode) ) { return { isDisabled: false, diff --git a/apps/trading-e2e/src/support/trading.ts b/apps/trading-e2e/src/support/trading.ts index 435a26d51..2866a3740 100644 --- a/apps/trading-e2e/src/support/trading.ts +++ b/apps/trading-e2e/src/support/trading.ts @@ -59,6 +59,7 @@ const mockTradingPage = ( generateMarketData({ trigger: trigger, marketTradingMode: tradingMode, + marketState: state, }) ); aliasQuery(req, 'MarketsData', generateMarketsData()); 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 22d7a2415..98051c73e 100644 --- a/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx +++ b/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx @@ -75,7 +75,7 @@ export const DealTicket = ({ return; } - const marketStateError = validateMarketState(market.state); + const marketStateError = validateMarketState(market.data.marketState); if (marketStateError !== true) { setError('summary', { message: marketStateError }); return; @@ -87,7 +87,7 @@ export const DealTicket = ({ } const marketTradingModeError = validateMarketTradingMode( - market.tradingMode + market.data.marketTradingMode ); if (marketTradingModeError !== true) { setError('summary', { message: marketTradingModeError }); @@ -110,8 +110,8 @@ export const DealTicket = ({ hasNoBalance, market.positionDecimalPlaces, market.decimalPlaces, - market.state, - market.tradingMode, + market.data.marketState, + market.data.marketTradingMode, setError, ] ); @@ -242,7 +242,7 @@ const SummaryMessage = memo( Schema.MarketTradingMode.TRADING_MODE_BATCH_AUCTION, Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION, Schema.MarketTradingMode.TRADING_MODE_OPENING_AUCTION, - ].includes(market.tradingMode) + ].includes(market.data.marketTradingMode) ) { return (