diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 900129b02..b9b2dad25 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,3 +42,5 @@ jobs: run: yarn nx affected:test - name: Build affected run: yarn nx affected:build + - name: Build affected spec + run: yarn nx affected --target=build-spec diff --git a/apps/console-lite-e2e/src/support/mocks/generate-accounts.ts b/apps/console-lite-e2e/src/support/mocks/generate-accounts.ts index 5cf9bdf95..fae664258 100644 --- a/apps/console-lite-e2e/src/support/mocks/generate-accounts.ts +++ b/apps/console-lite-e2e/src/support/mocks/generate-accounts.ts @@ -12,7 +12,7 @@ export const generateAccounts = ( id: Cypress.env('VEGA_PUBLIC_KEY'), accounts: [ { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_GENERAL, balance: '100000000', market: null, @@ -22,7 +22,7 @@ export const generateAccounts = ( }, }, { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_GENERAL, balance: '100000000', market: { @@ -35,7 +35,7 @@ export const generateAccounts = ( }, }, { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_MARGIN, balance: '1000', market: { @@ -48,7 +48,7 @@ export const generateAccounts = ( }, }, { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_MARGIN, balance: '1000', market: { @@ -61,7 +61,7 @@ export const generateAccounts = ( }, }, { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_GENERAL, balance: '100000000', market: null, diff --git a/apps/console-lite-e2e/src/support/mocks/generate-assets.ts b/apps/console-lite-e2e/src/support/mocks/generate-assets.ts index 952fe07e4..d771aa3f4 100644 --- a/apps/console-lite-e2e/src/support/mocks/generate-assets.ts +++ b/apps/console-lite-e2e/src/support/mocks/generate-assets.ts @@ -23,27 +23,27 @@ export const generateAssets = (override?: PartialDeep) => { status: Types.AssetStatus.STATUS_ENABLED, infrastructureFeeAccount: { balance: '1', - __typename: 'Account', + __typename: 'AccountBalance', }, globalRewardPoolAccount: { balance: '2', - __typename: 'Account', + __typename: 'AccountBalance', }, takerFeeRewardAccount: { balance: '3', - __typename: 'Account', + __typename: 'AccountBalance', }, makerFeeRewardAccount: { balance: '4', - __typename: 'Account', + __typename: 'AccountBalance', }, lpFeeRewardAccount: { balance: '5', - __typename: 'Account', + __typename: 'AccountBalance', }, marketProposerRewardAccount: { balance: '6', - __typename: 'Account', + __typename: 'AccountBalance', }, __typename: 'Asset', }, @@ -64,27 +64,27 @@ export const generateAssets = (override?: PartialDeep) => { status: Types.AssetStatus.STATUS_ENABLED, infrastructureFeeAccount: { balance: '1', - __typename: 'Account', + __typename: 'AccountBalance', }, globalRewardPoolAccount: { balance: '2', - __typename: 'Account', + __typename: 'AccountBalance', }, takerFeeRewardAccount: { balance: '3', - __typename: 'Account', + __typename: 'AccountBalance', }, makerFeeRewardAccount: { balance: '4', - __typename: 'Account', + __typename: 'AccountBalance', }, lpFeeRewardAccount: { balance: '5', - __typename: 'Account', + __typename: 'AccountBalance', }, marketProposerRewardAccount: { balance: '6', - __typename: 'Account', + __typename: 'AccountBalance', }, __typename: 'Asset', }, @@ -103,7 +103,7 @@ export const generateAssets = (override?: PartialDeep) => { status: Types.AssetStatus.STATUS_ENABLED, infrastructureFeeAccount: { balance: '0', - __typename: 'Account', + __typename: 'AccountBalance', }, globalRewardPoolAccount: null, takerFeeRewardAccount: null, 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 8214b42e5..80d47784c 100644 --- a/apps/console-lite-e2e/src/support/mocks/generate-fills.ts +++ b/apps/console-lite-e2e/src/support/mocks/generate-fills.ts @@ -1,5 +1,5 @@ import type { FillsQuery, FillFieldsFragment } from '@vegaprotocol/fills'; -import { Side } from '@vegaprotocol/types'; +import { Schema } from '@vegaprotocol/types'; import merge from 'lodash/merge'; import type { PartialDeep } from 'type-fest'; @@ -17,7 +17,7 @@ export const generateFills = ( seller: { id: Cypress.env('VEGA_PUBLIC_KEY'), }, - aggressor: Side.SIDE_SELL, + aggressor: Schema.Side.SIDE_SELL, buyerFee: { infrastructureFee: '5000', }, @@ -30,11 +30,11 @@ export const generateFills = ( seller: { id: Cypress.env('VEGA_PUBLIC_KEY'), }, - aggressor: Side.SIDE_BUY, + aggressor: Schema.Side.SIDE_BUY, }), generateFill({ id: '3', - aggressor: Side.SIDE_SELL, + aggressor: Schema.Side.SIDE_SELL, market: { id: 'market-2', }, @@ -80,7 +80,7 @@ export const generateFill = (override?: PartialDeep) => { size: '50000', buyOrder: 'buy-order', sellOrder: 'sell-order', - aggressor: Side.SIDE_BUY, + aggressor: Schema.Side.SIDE_BUY, buyer: { __typename: 'Party', id: 'buyer-id', diff --git a/apps/console-lite-e2e/src/support/mocks/generate-orders.ts b/apps/console-lite-e2e/src/support/mocks/generate-orders.ts index 06d7e185f..5afabe458 100644 --- a/apps/console-lite-e2e/src/support/mocks/generate-orders.ts +++ b/apps/console-lite-e2e/src/support/mocks/generate-orders.ts @@ -1,18 +1,12 @@ import merge from 'lodash/merge'; import type { PartialDeep } from 'type-fest'; -import type { - Orders, - Orders_party_ordersConnection_edges_node, -} from '@vegaprotocol/orders'; -import { - OrderStatus, - OrderTimeInForce, - OrderType, - Side, -} from '@vegaprotocol/types'; +import type { OrdersQuery, OrderFieldsFragment } from '@vegaprotocol/orders'; +import { Schema } from '@vegaprotocol/types'; -export const generateOrders = (override?: PartialDeep): Orders => { - const orders: Orders_party_ordersConnection_edges_node[] = [ +export const generateOrders = ( + override?: PartialDeep +): OrdersQuery => { + const orders: OrderFieldsFragment[] = [ { __typename: 'Order', id: '066468C06549101DAF7BC51099E1412A0067DC08C246B7D8013C9D0CBF1E8EE7', @@ -21,12 +15,12 @@ export const generateOrders = (override?: PartialDeep): Orders => { id: 'market-0', }, size: '10', - type: OrderType.TYPE_LIMIT, - status: OrderStatus.STATUS_FILLED, - side: Side.SIDE_BUY, + type: Schema.OrderType.TYPE_LIMIT, + status: Schema.OrderStatus.STATUS_FILLED, + side: Schema.Side.SIDE_BUY, remaining: '0', price: '20000000', - timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, createdAt: new Date(2020, 1, 30).toISOString(), updatedAt: null, expiresAt: null, @@ -42,12 +36,12 @@ export const generateOrders = (override?: PartialDeep): Orders => { id: 'market-1', }, size: '1', - type: OrderType.TYPE_LIMIT, - status: OrderStatus.STATUS_FILLED, - side: Side.SIDE_BUY, + type: Schema.OrderType.TYPE_LIMIT, + status: Schema.OrderStatus.STATUS_FILLED, + side: Schema.Side.SIDE_BUY, remaining: '0', price: '100', - timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, createdAt: new Date(2020, 1, 29).toISOString(), updatedAt: null, expiresAt: null, @@ -63,12 +57,12 @@ export const generateOrders = (override?: PartialDeep): Orders => { id: 'market-2', }, size: '1', - type: OrderType.TYPE_LIMIT, - status: OrderStatus.STATUS_FILLED, - side: Side.SIDE_BUY, + type: Schema.OrderType.TYPE_LIMIT, + status: Schema.OrderStatus.STATUS_FILLED, + side: Schema.Side.SIDE_BUY, remaining: '0', price: '20000', - timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, createdAt: new Date(2020, 1, 28).toISOString(), updatedAt: null, expiresAt: null, @@ -84,12 +78,12 @@ export const generateOrders = (override?: PartialDeep): Orders => { id: 'market-3', }, size: '1', - type: OrderType.TYPE_LIMIT, - status: OrderStatus.STATUS_ACTIVE, - side: Side.SIDE_BUY, + type: Schema.OrderType.TYPE_LIMIT, + status: Schema.OrderStatus.STATUS_ACTIVE, + side: Schema.Side.SIDE_BUY, remaining: '0', price: '100000', - timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, createdAt: new Date(2020, 1, 27).toISOString(), updatedAt: null, expiresAt: null, @@ -105,12 +99,12 @@ export const generateOrders = (override?: PartialDeep): Orders => { id: 'market-3', }, size: '10', - type: OrderType.TYPE_LIMIT, - status: OrderStatus.STATUS_PARTIALLY_FILLED, - side: Side.SIDE_SELL, + type: Schema.OrderType.TYPE_LIMIT, + status: Schema.OrderStatus.STATUS_PARTIALLY_FILLED, + side: Schema.Side.SIDE_SELL, remaining: '3', price: '100000', - timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, createdAt: new Date(2020, 1, 27).toISOString(), updatedAt: null, expiresAt: null, @@ -120,7 +114,7 @@ export const generateOrders = (override?: PartialDeep): Orders => { }, ]; - const defaultResult: Orders = { + const defaultResult: OrdersQuery = { party: { id: Cypress.env('VEGA_PUBLIC_KEY'), ordersConnection: { diff --git a/apps/console-lite-e2e/src/support/mocks/generate-party-balance.ts b/apps/console-lite-e2e/src/support/mocks/generate-party-balance.ts index 270498376..a9dec83f1 100644 --- a/apps/console-lite-e2e/src/support/mocks/generate-party-balance.ts +++ b/apps/console-lite-e2e/src/support/mocks/generate-party-balance.ts @@ -19,7 +19,7 @@ export const generatePartyBalance = ( decimals: 5, __typename: 'Asset', }, - __typename: 'Account', + __typename: 'AccountBalance', }, { balance: '100000000', @@ -31,7 +31,7 @@ export const generatePartyBalance = ( decimals: 5, __typename: 'Asset', }, - __typename: 'Account', + __typename: 'AccountBalance', }, { balance: '3412867', @@ -43,7 +43,7 @@ export const generatePartyBalance = ( decimals: 5, __typename: 'Asset', }, - __typename: 'Account', + __typename: 'AccountBalance', }, { balance: '70007', @@ -55,7 +55,7 @@ export const generatePartyBalance = ( decimals: 5, __typename: 'Asset', }, - __typename: 'Account', + __typename: 'AccountBalance', }, ], __typename: 'Party', diff --git a/apps/console-lite-e2e/src/support/mocks/generate-party-market-data.ts b/apps/console-lite-e2e/src/support/mocks/generate-party-market-data.ts index f9cbf2f71..1a7bff715 100644 --- a/apps/console-lite-e2e/src/support/mocks/generate-party-market-data.ts +++ b/apps/console-lite-e2e/src/support/mocks/generate-party-market-data.ts @@ -8,7 +8,7 @@ export const generatePartyMarketData = () => { balance: '1200000', asset: { id: 'fBTC', decimals: 5, __typename: 'Asset' }, market: null, - __typename: 'Account', + __typename: 'AccountBalance', }, ], marginsConnection: { edges: null, __typename: 'MarginConnection' }, diff --git a/apps/console-lite/project.json b/apps/console-lite/project.json index 1b4fe5ab1..ca3f8a3b4 100644 --- a/apps/console-lite/project.json +++ b/apps/console-lite/project.json @@ -77,6 +77,13 @@ "nx build console-lite" ] } + }, + "build-spec": { + "executor": "@nrwl/workspace:run-commands", + "outputs": [], + "options": { + "command": "yarn tsc --project ./apps/console-lite/tsconfig.spec.json" + } } }, "tags": [] diff --git a/apps/console-lite/src/app/components/deal-ticket/__generated___/PartyBalance.ts b/apps/console-lite/src/app/components/deal-ticket/__generated___/PartyBalance.ts index 60fd8862f..4b256cfd9 100644 --- a/apps/console-lite/src/app/components/deal-ticket/__generated___/PartyBalance.ts +++ b/apps/console-lite/src/app/components/deal-ticket/__generated___/PartyBalance.ts @@ -8,7 +8,7 @@ export type PartyBalanceQueryQueryVariables = Types.Exact<{ }>; -export type PartyBalanceQueryQuery = { __typename?: 'Query', party?: { __typename?: 'Party', accounts?: Array<{ __typename?: 'Account', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number } }> | null } | null }; +export type PartyBalanceQueryQuery = { __typename?: 'Query', party?: { __typename?: 'Party', accounts?: Array<{ __typename?: 'AccountBalance', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number } }> | null } | null }; export const PartyBalanceQueryDocument = gql` diff --git a/apps/console-lite/src/app/components/deal-ticket/deal-ticket-balance.spec.tsx b/apps/console-lite/src/app/components/deal-ticket/deal-ticket-balance.spec.tsx index b751b2829..5bf94fcb5 100644 --- a/apps/console-lite/src/app/components/deal-ticket/deal-ticket-balance.spec.tsx +++ b/apps/console-lite/src/app/components/deal-ticket/deal-ticket-balance.spec.tsx @@ -1,23 +1,24 @@ import React from 'react'; import { render } from '@testing-library/react'; import type { - PartyBalanceQuery_party_accounts, - PartyBalanceQuery_party_accounts_asset, -} from './__generated__/PartyBalanceQuery'; + AccountFragment, + DealTicketMarketFragment, +} from '@vegaprotocol/deal-ticket'; import { DealTicketBalance } from './deal-ticket-balance'; import { AccountType } from '@vegaprotocol/types'; -const tDAI: PartyBalanceQuery_party_accounts_asset = { - __typename: 'Asset', - id: '1', - symbol: 'tDAI', - name: 'TDAI', - decimals: 2, -}; - -const accounts: PartyBalanceQuery_party_accounts[] = [ +const tDAI: DealTicketMarketFragment['tradableInstrument']['instrument']['product']['settlementAsset'] = { - __typename: 'Account', + __typename: 'Asset', + id: '1', + symbol: 'tDAI', + name: 'TDAI', + decimals: 2, + }; + +const accounts: AccountFragment[] = [ + { + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_GENERAL, balance: '1000000', asset: tDAI, diff --git a/apps/console-lite/src/app/components/deal-ticket/deal-ticket-steps.tsx b/apps/console-lite/src/app/components/deal-ticket/deal-ticket-steps.tsx index cfb55b3cc..e0b874834 100644 --- a/apps/console-lite/src/app/components/deal-ticket/deal-ticket-steps.tsx +++ b/apps/console-lite/src/app/components/deal-ticket/deal-ticket-steps.tsx @@ -38,7 +38,7 @@ import { DealTicketSize } from './deal-ticket-size'; import MarketNameRenderer from '../simple-market-list/simple-market-renderer'; import SideSelector, { SIDE_NAMES } from './side-selector'; import ReviewTrade from './review-trade'; -import { Side, OrderType } from '@vegaprotocol/types'; +import { Schema } from '@vegaprotocol/types'; import { DealTicketSlippage } from './deal-ticket-slippage'; interface DealTicketMarketProps { @@ -118,7 +118,7 @@ export const DealTicketSteps = ({ market }: DealTicketMarketProps) => { const price = useMemo(() => { if (slippage && market?.depth?.lastTrade?.price) { - const isLong = order.side === Side.SIDE_BUY; + const isLong = order.side === Schema.Side.SIDE_BUY; const multiplier = new BigNumber(1)[isLong ? 'plus' : 'minus']( parseFloat(slippage) / 100 ); @@ -182,7 +182,7 @@ export const DealTicketSteps = ({ market }: DealTicketMarketProps) => { (value: number) => { if (market?.depth?.lastTrade?.price) { if (value) { - const isLong = order.side === Side.SIDE_BUY; + const isLong = order.side === Schema.Side.SIDE_BUY; const multiplier = new BigNumber(1)[isLong ? 'plus' : 'minus']( value / 100 ); @@ -193,11 +193,11 @@ export const DealTicketSteps = ({ market }: DealTicketMarketProps) => { setValue('price', bestAskPrice); - if (order.type === OrderType.TYPE_MARKET) { - setValue('type', OrderType.TYPE_LIMIT); + if (order.type === Schema.OrderType.TYPE_MARKET) { + setValue('type', Schema.OrderType.TYPE_LIMIT); } } else { - setValue('type', OrderType.TYPE_MARKET); + setValue('type', Schema.OrderType.TYPE_MARKET); setValue('price', market?.depth?.lastTrade?.price); } } diff --git a/apps/console-lite/src/app/components/deal-ticket/review-trade.tsx b/apps/console-lite/src/app/components/deal-ticket/review-trade.tsx index 3cc485525..6796e49f4 100644 --- a/apps/console-lite/src/app/components/deal-ticket/review-trade.tsx +++ b/apps/console-lite/src/app/components/deal-ticket/review-trade.tsx @@ -14,7 +14,7 @@ import type { MarketTags, MarketTagsVariables, } from './__generated__/MarketTags'; -import { Side } from '@vegaprotocol/types'; +import { Schema } from '@vegaprotocol/types'; import { MarketExpires } from '@vegaprotocol/market-info'; export const MARKET_TAGS_QUERY = gql` @@ -72,9 +72,10 @@ export default ({
void; + value: Schema.Side; + onSelect: (side: Schema.Side) => void; } -export const SIDE_NAMES: Record = { - [Side.SIDE_BUY]: t('Long'), - [Side.SIDE_SELL]: t('Short'), +export const SIDE_NAMES: Record = { + [Schema.Side.SIDE_BUY]: t('Long'), + [Schema.Side.SIDE_SELL]: t('Short'), }; export default ({ value, onSelect }: SideSelectorProps) => { @@ -31,9 +31,9 @@ export default ({ value, onSelect }: SideSelectorProps) => { className={classNames( 'px-8 py-2', 'buyButton hover:buyButton dark:buyButtonDark dark:hover:buyButtonDark', - { selected: value === Side.SIDE_BUY } + { selected: value === Schema.Side.SIDE_BUY } )} - onClick={() => onSelect(Side.SIDE_BUY)} + onClick={() => onSelect(Schema.Side.SIDE_BUY)} > {t('Long')} @@ -43,9 +43,9 @@ export default ({ value, onSelect }: SideSelectorProps) => { className={classNames( 'px-8 py-2', 'sellButton hover:sellButton dark:sellButtonDark dark:hover:sellButtonDark', - { selected: value === Side.SIDE_SELL } + { selected: value === Schema.Side.SIDE_SELL } )} - onClick={() => onSelect(Side.SIDE_SELL)} + onClick={() => onSelect(Schema.Side.SIDE_SELL)} > {t('Short')} diff --git a/apps/console-lite/src/app/components/portfolio/fills/use-column-definitions.tsx b/apps/console-lite/src/app/components/portfolio/fills/use-column-definitions.tsx index 0af2b36d1..f783e09c4 100644 --- a/apps/console-lite/src/app/components/portfolio/fills/use-column-definitions.tsx +++ b/apps/console-lite/src/app/components/portfolio/fills/use-column-definitions.tsx @@ -12,7 +12,7 @@ import { t, } from '@vegaprotocol/react-helpers'; import BigNumber from 'bignumber.js'; -import { Side } from '@vegaprotocol/types'; +import { Schema } from '@vegaprotocol/types'; interface Props { partyId: string; @@ -118,13 +118,13 @@ const useColumnDefinitions = ({ partyId }: Props) => { const taker = t('Taker'); const maker = t('Maker'); if (data?.buyer.id === partyId) { - if (value === Side.SIDE_BUY) { + if (value === Schema.Side.SIDE_BUY) { return taker; } else { return maker; } } else if (data?.seller.id === partyId) { - if (value === Side.SIDE_SELL) { + if (value === Schema.Side.SIDE_SELL) { return taker; } else { return maker; diff --git a/apps/console-lite/src/app/components/portfolio/orders/use-column-definitions.tsx b/apps/console-lite/src/app/components/portfolio/orders/use-column-definitions.tsx index da9841ff7..bc964bd77 100644 --- a/apps/console-lite/src/app/components/portfolio/orders/use-column-definitions.tsx +++ b/apps/console-lite/src/app/components/portfolio/orders/use-column-definitions.tsx @@ -12,19 +12,16 @@ import { t, } from '@vegaprotocol/react-helpers'; import type { - Orders_party_ordersConnection_edges_node, + OrderFieldsFragment, Order, CancelOrderArgs, } from '@vegaprotocol/orders'; import { isOrderActive } from '@vegaprotocol/orders'; import { OrderRejectionReasonMapping, - OrderStatus, - OrderType, OrderStatusMapping, OrderTypeMapping, - Side, - OrderTimeInForce, + Schema, OrderTimeInForceMapping, } from '@vegaprotocol/types'; @@ -60,21 +57,15 @@ const useColumnDefinitions = ({ setEditOrder, orderCancel }: Props) => { cellClass: 'font-mono !flex h-full items-center', width: 80, cellClassRules: { - [positiveClassNames]: ({ - data, - }: { - data: Orders_party_ordersConnection_edges_node; - }) => data?.side === Side.SIDE_BUY, - [negativeClassNames]: ({ - data, - }: { - data: Orders_party_ordersConnection_edges_node; - }) => data?.side === Side.SIDE_SELL, + [positiveClassNames]: ({ data }: { data: OrderFieldsFragment }) => + data?.side === Schema.Side.SIDE_BUY, + [negativeClassNames]: ({ data }: { data: OrderFieldsFragment }) => + data?.side === Schema.Side.SIDE_SELL, }, valueFormatter: ({ value, data }: ValueFormatterParams) => { if (value && data && data.market) { const prefix = data - ? data.side === Side.SIDE_BUY + ? data.side === Schema.Side.SIDE_BUY ? '+' : '-' : ''; @@ -92,8 +83,8 @@ const useColumnDefinitions = ({ setEditOrder, orderCancel }: Props) => { valueFormatter: ({ value, }: ValueFormatterParams & { - value?: Orders_party_ordersConnection_edges_node['type']; - }) => OrderTypeMapping[value as OrderType], + value?: OrderFieldsFragment['type']; + }) => OrderTypeMapping[value as Schema.OrderType], }, { colId: 'status', @@ -106,7 +97,7 @@ const useColumnDefinitions = ({ setEditOrder, orderCancel }: Props) => { value?: StatusKey; }) => { if (value && data && data.market) { - if (value === OrderStatus.STATUS_REJECTED) { + if (value === Schema.OrderStatus.STATUS_REJECTED) { return `${OrderStatusMapping[value as StatusKey]}: ${ data.rejectionReason && OrderRejectionReasonMapping[ @@ -130,7 +121,7 @@ const useColumnDefinitions = ({ setEditOrder, orderCancel }: Props) => { data, value, }: ValueFormatterParams & { - value?: Orders_party_ordersConnection_edges_node['remaining']; + value?: OrderFieldsFragment['remaining']; }) => { if (value && data && data.market) { const dps = data.market.positionDecimalPlaces; @@ -156,13 +147,13 @@ const useColumnDefinitions = ({ setEditOrder, orderCancel }: Props) => { value, data, }: ValueFormatterParams & { - value?: Orders_party_ordersConnection_edges_node['price']; + value?: OrderFieldsFragment['price']; }) => { if ( value === undefined || !data || !data.market || - data.type === OrderType.TYPE_MARKET + data.type === Schema.OrderType.TYPE_MARKET ) { return '-'; } @@ -181,7 +172,7 @@ const useColumnDefinitions = ({ setEditOrder, orderCancel }: Props) => { }) => { if (value && data?.market) { if ( - value === OrderTimeInForce.TIME_IN_FORCE_GTT && + value === Schema.OrderTimeInForce.TIME_IN_FORCE_GTT && data.expiresAt ) { const expiry = getDateTimeFormat().format( @@ -203,7 +194,7 @@ const useColumnDefinitions = ({ setEditOrder, orderCancel }: Props) => { valueFormatter: ({ value, }: ValueFormatterParams & { - value?: Orders_party_ordersConnection_edges_node['createdAt']; + value?: OrderFieldsFragment['createdAt']; }) => { return value ? getDateTimeFormat().format(new Date(value)) : value; }, @@ -215,7 +206,7 @@ const useColumnDefinitions = ({ setEditOrder, orderCancel }: Props) => { valueFormatter: ({ value, }: ValueFormatterParams & { - value?: Orders_party_ordersConnection_edges_node['updatedAt']; + value?: OrderFieldsFragment['updatedAt']; }) => { return value ? getDateTimeFormat().format(new Date(value)) : '-'; }, diff --git a/apps/console-lite/src/app/components/simple-market-list/simple-market-toolbar.spec.tsx b/apps/console-lite/src/app/components/simple-market-list/simple-market-toolbar.spec.tsx index f3a35acf5..2089918be 100644 --- a/apps/console-lite/src/app/components/simple-market-list/simple-market-toolbar.spec.tsx +++ b/apps/console-lite/src/app/components/simple-market-list/simple-market-toolbar.spec.tsx @@ -15,8 +15,8 @@ import { } from '@testing-library/react'; import { MockedProvider } from '@apollo/react-testing'; import { MarketState } from '@vegaprotocol/types'; +import type { Market } from '@vegaprotocol/market-list'; import SimpleMarketToolbar from './simple-market-toolbar'; -import type { SimpleMarkets_markets } from './__generated__/SimpleMarkets'; import { markets as filterData } from './mocks/market-filters.json'; const mockedNavigate = jest.fn(); @@ -35,35 +35,23 @@ describe('SimpleMarketToolbar', () => { const routes = useRoutes([ { path: '/', - element: ( - - ), + element: , }, { path: 'markets', children: [ { path: `:state`, - element: ( - - ), + element: , children: [ { path: `:product`, - element: ( - - ), + element: , children: [ { path: `:asset`, element: ( - + ), }, ], @@ -71,9 +59,7 @@ describe('SimpleMarketToolbar', () => { ], }, ], - element: ( - - ), + element: , }, ]); const location = useLocation(); @@ -166,7 +152,7 @@ describe('SimpleMarketToolbar', () => { })); render( - + , { wrapper: BrowserRouter } ); @@ -187,7 +173,7 @@ describe('SimpleMarketToolbar', () => { (useParams as jest.Mock).mockImplementation(() => ({})); render( - + , { wrapper: BrowserRouter } ); @@ -211,7 +197,7 @@ describe('SimpleMarketToolbar', () => { })); render( - + , { wrapper: BrowserRouter } ); diff --git a/apps/console-lite/tsconfig.spec.json b/apps/console-lite/tsconfig.spec.json index 32b355860..17b59f94d 100644 --- a/apps/console-lite/tsconfig.spec.json +++ b/apps/console-lite/tsconfig.spec.json @@ -3,11 +3,9 @@ "compilerOptions": { "outDir": "../../dist/out-tsc", "module": "commonjs", - "types": ["jest", "node", "@testing-library/jest-dom"], - "jsx": "react", - "allowSyntheticDefaultImports": true, - "esModuleInterop": true + "types": ["jest", "node", "@testing-library/jest-dom"] }, + "files": ["../../node_modules/@nrwl/react/typings/cssmodule.d.ts"], "include": [ "**/*.test.ts", "**/*.spec.ts", diff --git a/apps/explorer/.env b/apps/explorer/.env index 0a312cb52..3533b45b9 100644 --- a/apps/explorer/.env +++ b/apps/explorer/.env @@ -2,7 +2,7 @@ NX_CHAIN_EXPLORER_URL=https://explorer.vega.trading/.netlify/functions/chain-exp NX_TENDERMINT_URL=https://n01.stagnet3.vega.xyz/tm NX_TENDERMINT_WEBSOCKET_URL=wss://n01.stagnet3.vega.xyz/tm/websocket NX_VEGA_CONFIG_URL=https://static.vega.xyz/assets/stagnet3-network.json -NX_VEGA_NETWORKS='{"TESTNET":"https://explorer.fairground.wtf","MAINNET":"https://explorer.vega.xyz"}' +NX_VEGA_NETWORKS={\"MAINNET"\:\"https://explorer.vega.xyz"\,\"TESTNET\":\"https://explorer.fairground.wtf\"} NX_VEGA_ENV=STAGNET3 NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions NX_HOSTED_WALLET_URL=https://wallet.testnet.vega.xyz diff --git a/apps/explorer/.env.capsule b/apps/explorer/.env.capsule index e41cf2045..828306763 100644 --- a/apps/explorer/.env.capsule +++ b/apps/explorer/.env.capsule @@ -3,7 +3,7 @@ NX_CHAIN_EXPLORER_URL=https://explorer.vega.trading/.netlify/functions/chain-exp NX_TENDERMINT_URL=http://localhost:26617 NX_TENDERMINT_WEBSOCKET_URL=wss://localhost:26617/websocket NX_VEGA_URL=http://localhost:3028/query -NX_VEGA_NETWORKS='{"TESTNET":"https://explorer.fairground.wtf","MAINNET":"https://explorer.vega.xyz"}' +NX_VEGA_NETWORKS={\"MAINNET"\:\"https://explorer.vega.xyz"\,\"TESTNET\":\"https://explorer.fairground.wtf\"} NX_VEGA_ENV=CUSTOM NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions diff --git a/apps/explorer/.env.devnet b/apps/explorer/.env.devnet index fb55fa69f..3723d1d6b 100644 --- a/apps/explorer/.env.devnet +++ b/apps/explorer/.env.devnet @@ -4,7 +4,7 @@ NX_TENDERMINT_URL=https://n04.d.vega.xyz/tm NX_TENDERMINT_WEBSOCKET_URL=wss://n04.d.vega.xyz/tm/websocket NX_VEGA_CONFIG_URL=https://static.vega.xyz/assets/devnet-network.json NX_VEGA_URL=https://api.n04.d.vega.xyz/graphql -NX_VEGA_NETWORKS='{"TESTNET":"https://explorer.fairground.wtf","MAINNET":"https://explorer.vega.xyz"}' +NX_VEGA_NETWORKS={\"MAINNET"\:\"https://explorer.vega.xyz"\,\"TESTNET\":\"https://explorer.fairground.wtf\"} NX_VEGA_ENV=DEVNET NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions NX_BLOCK_EXPLORER= diff --git a/apps/explorer/.env.mainnet b/apps/explorer/.env.mainnet index ed6207bc9..a5eac8b75 100644 --- a/apps/explorer/.env.mainnet +++ b/apps/explorer/.env.mainnet @@ -4,7 +4,7 @@ NX_TENDERMINT_URL=https://mainnet-observer-proxy01.ops.vega.xyz/ NX_TENDERMINT_WEBSOCKET_URL=wss://mainnet-observer-proxy01.ops.vega.xyz/websocket NX_VEGA_CONFIG_URL=https://static.vega.xyz/assets/mainnet-network.json NX_VEGA_URL=https://api.vega.xyz/query -NX_VEGA_NETWORKS='{"TESTNET":"https://explorer.fairground.wtf","MAINNET":"https://explorer.vega.xyz"}' +NX_VEGA_NETWORKS={\"MAINNET"\:\"https://explorer.vega.xyz"\,\"TESTNET\":\"https://explorer.fairground.wtf\"} NX_VEGA_ENV=MAINNET NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions NX_BLOCK_EXPLORER= diff --git a/apps/explorer/.env.stagnet1 b/apps/explorer/.env.stagnet1 index 9d5e42cee..f928273e4 100644 --- a/apps/explorer/.env.stagnet1 +++ b/apps/explorer/.env.stagnet1 @@ -4,7 +4,9 @@ NX_HOSTED_WALLET_URL=https://wallet.testnet.vega.xyz NX_VEGA_CONFIG_URL=https://static.vega.xyz/assets/stagnet1-network.json NX_VEGA_ENV=STAGNET1 NX_VEGA_EXPLORER_URL=https://stagnet1.explorer.vega.xyz -NX_VEGA_NETWORKS={\"TESTNET\":\"https://console.fairground.wtf\",\"STAGNET1\":\"https://stagnet1.console.vega.xyz\",\"STAGNET3\":\"https://stagnet3.console.vega.xyz\"} +NX_VEGA_NETWORKS={\"MAINNET"\:\"https://explorer.vega.xyz"\,\"TESTNET\":\"https://explorer.fairground.wtf\"} NX_VEGA_TOKEN_URL=https://stagnet1.token.vega.xyz NX_VEGA_URL=https://api.n00.stagnet1.vega.xyz/graphql -NX_VEGA_WALLET_URL=http://localhost:1789 \ No newline at end of file +NX_VEGA_WALLET_URL=http://localhost:1789 +NX_TENDERMINT_URL=https://tm.n01.stagnet1.vega.xyz +NX_TENDERMINT_WEBSOCKET_URL=wss://tm.n01.stagnet1.vega.xyz/websocket diff --git a/apps/explorer/.env.stagnet3 b/apps/explorer/.env.stagnet3 index 3ef8df81f..35597d904 100644 --- a/apps/explorer/.env.stagnet3 +++ b/apps/explorer/.env.stagnet3 @@ -4,7 +4,7 @@ NX_TENDERMINT_URL=https://n01.stagnet3.vega.xyz/tm NX_TENDERMINT_WEBSOCKET_URL=wss://n01.stagnet3.vega.xyz/tm/websocket NX_VEGA_CONFIG_URL=https://static.vega.xyz/assets/stagnet3-network.json NX_VEGA_URL=https://api.n01.stagnet3.vega.xyz/graphql -NX_VEGA_NETWORKS='{"TESTNET":"https://explorer.fairground.wtf","MAINNET":"https://explorer.vega.xyz"}' +NX_VEGA_NETWORKS={\"MAINNET"\:\"https://explorer.vega.xyz"\,\"TESTNET\":\"https://explorer.fairground.wtf\"} NX_VEGA_ENV=STAGNET3 NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions NX_BLOCK_EXPLORER= diff --git a/apps/explorer/.env.testnet b/apps/explorer/.env.testnet index 9a249d2bd..c56affca9 100644 --- a/apps/explorer/.env.testnet +++ b/apps/explorer/.env.testnet @@ -4,7 +4,7 @@ NX_TENDERMINT_URL=https://tm.n07.testnet.vega.xyz NX_BLOCK_EXPLORER=https://n13.testnet.vega.xyz/rest NX_TENDERMINT_WEBSOCKET_URL=wss://tm.n07.testnet.vega.xyz/websocket NX_VEGA_CONFIG_URL=https://static.vega.xyz/assets/testnet-network.json -NX_VEGA_NETWORKS='{"TESTNET":"https://explorer.fairground.wtf","MAINNET":"https://explorer.vega.xyz"}' +NX_VEGA_NETWORKS={\"MAINNET"\:\"https://explorer.vega.xyz"\,\"TESTNET\":\"https://explorer.fairground.wtf\"} NX_VEGA_ENV=TESTNET NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions NX_VEGA_URL=https://api.n09.testnet.vega.xyz/graphql diff --git a/apps/explorer/project.json b/apps/explorer/project.json index 6d0e239a7..9bd14a156 100644 --- a/apps/explorer/project.json +++ b/apps/explorer/project.json @@ -74,6 +74,13 @@ "nx build explorer" ] } + }, + "build-spec": { + "executor": "@nrwl/workspace:run-commands", + "outputs": [], + "options": { + "command": "yarn tsc --project ./apps/explorer/tsconfig.spec.json" + } } }, "tags": [] diff --git a/apps/explorer/src/app/routes/assets/__generated__/AssetsQuery.ts b/apps/explorer/src/app/routes/assets/__generated__/AssetsQuery.ts index 7ba7b9400..bbb6053b8 100644 --- a/apps/explorer/src/app/routes/assets/__generated__/AssetsQuery.ts +++ b/apps/explorer/src/app/routes/assets/__generated__/AssetsQuery.ts @@ -36,7 +36,7 @@ export interface AssetsQuery_assetsConnection_edges_node_infrastructureFeeAccoun } export interface AssetsQuery_assetsConnection_edges_node_infrastructureFeeAccount { - __typename: "Account"; + __typename: "AccountBalance"; /** * Account type (General, Margin, etc) */ @@ -76,7 +76,7 @@ export interface AssetsQuery_assetsConnection_edges_node { /** * The infrastructure fee account for this asset */ - infrastructureFeeAccount: AssetsQuery_assetsConnection_edges_node_infrastructureFeeAccount; + infrastructureFeeAccount: AssetsQuery_assetsConnection_edges_node_infrastructureFeeAccount | null; } export interface AssetsQuery_assetsConnection_edges { diff --git a/apps/explorer/src/app/routes/assets/__generated___/Assets.ts b/apps/explorer/src/app/routes/assets/__generated___/Assets.ts index b63324434..d38d54341 100644 --- a/apps/explorer/src/app/routes/assets/__generated___/Assets.ts +++ b/apps/explorer/src/app/routes/assets/__generated___/Assets.ts @@ -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 } | 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?: 'AccountBalance', type: Types.AccountType, balance: string, market?: { __typename?: 'Market', id: string } | null } | null } } | null> | null } | null }; export const AssetsQueryDocument = gql` diff --git a/apps/explorer/src/app/routes/markets/__generated__/MarketsQuery.ts b/apps/explorer/src/app/routes/markets/__generated__/MarketsQuery.ts index cb85ac139..764b9e782 100644 --- a/apps/explorer/src/app/routes/markets/__generated__/MarketsQuery.ts +++ b/apps/explorer/src/app/routes/markets/__generated__/MarketsQuery.ts @@ -42,7 +42,7 @@ export interface MarketsQuery_markets_tradableInstrument_instrument_metadata { } export interface MarketsQuery_markets_tradableInstrument_instrument_product_settlementAsset_globalRewardPoolAccount { - __typename: "Account"; + __typename: "AccountBalance"; /** * Balance as string - current account balance (approx. as balances can be updated several times per second) */ @@ -286,7 +286,7 @@ export interface MarketsQuery_markets_accounts_asset { } export interface MarketsQuery_markets_accounts { - __typename: "Account"; + __typename: "AccountBalance"; /** * Asset, the 'currency' */ diff --git a/apps/explorer/src/app/routes/markets/__generated___/Markets.ts b/apps/explorer/src/app/routes/markets/__generated___/Markets.ts index d1718e2b4..4ed804377 100644 --- a/apps/explorer/src/app/routes/markets/__generated___/Markets.ts +++ b/apps/explorer/src/app/routes/markets/__generated___/Markets.ts @@ -6,7 +6,7 @@ const defaultOptions = {} as const; export type MarketsQueryQueryVariables = Types.Exact<{ [key: string]: never; }>; -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 | 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 | null }, product: { __typename?: 'Future', settlementAsset: { __typename?: 'Asset', id: string, name: string, decimals: number, globalRewardPoolAccount?: { __typename?: 'AccountBalance', 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?: 'AccountBalance', 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` diff --git a/apps/explorer/src/app/routes/parties/__generated___/PartyAssets.ts b/apps/explorer/src/app/routes/parties/__generated___/PartyAssets.ts index c3b1c42f0..0a8bba5fa 100644 --- a/apps/explorer/src/app/routes/parties/__generated___/PartyAssets.ts +++ b/apps/explorer/src/app/routes/parties/__generated___/PartyAssets.ts @@ -8,7 +8,7 @@ export type PartyAssetsQueryQueryVariables = Types.Exact<{ }>; -export type PartyAssetsQueryQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, delegations?: Array<{ __typename?: 'Delegation', amount: string, epoch: number, node: { __typename?: 'Node', id: string, name: string } }> | null, stake: { __typename?: 'PartyStake', currentStakeAvailable: string }, accounts?: Array<{ __typename?: 'Account', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', name: string, id: string, decimals: number, symbol: string, source: { __typename: 'BuiltinAsset' } | { __typename: 'ERC20', contractAddress: string } } }> | null } | null }; +export type PartyAssetsQueryQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, delegations?: Array<{ __typename?: 'Delegation', amount: string, epoch: number, node: { __typename?: 'Node', id: string, name: string } }> | null, stake: { __typename?: 'PartyStake', currentStakeAvailable: string }, accounts?: Array<{ __typename?: 'AccountBalance', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', name: string, id: string, decimals: number, symbol: string, source: { __typename: 'BuiltinAsset' } | { __typename: 'ERC20', contractAddress: string } } }> | null } | null }; export const PartyAssetsQueryDocument = gql` diff --git a/apps/explorer/src/app/routes/parties/id/__generated__/PartyAssetsQuery.ts b/apps/explorer/src/app/routes/parties/id/__generated__/PartyAssetsQuery.ts index 8f43167b7..7bd3d76ab 100644 --- a/apps/explorer/src/app/routes/parties/id/__generated__/PartyAssetsQuery.ts +++ b/apps/explorer/src/app/routes/parties/id/__generated__/PartyAssetsQuery.ts @@ -81,7 +81,7 @@ export interface PartyAssetsQuery_party_accounts_asset { } export interface PartyAssetsQuery_party_accounts { - __typename: "Account"; + __typename: "AccountBalance"; /** * Asset, the 'currency' */ diff --git a/apps/liquidity-provision-dashboard/project.json b/apps/liquidity-provision-dashboard/project.json index 44bd96f18..cd00ba0e1 100644 --- a/apps/liquidity-provision-dashboard/project.json +++ b/apps/liquidity-provision-dashboard/project.json @@ -88,6 +88,13 @@ "nx build liquidity-provision-dashboard" ] } + }, + "build-spec": { + "executor": "@nrwl/workspace:run-commands", + "outputs": [], + "options": { + "command": "yarn tsc --project ./apps/liquidity-provision-dashboard/tsconfig.spec.json" + } } }, "tags": [] diff --git a/apps/multisig-signer/project.json b/apps/multisig-signer/project.json index d149d922e..51a93ba88 100644 --- a/apps/multisig-signer/project.json +++ b/apps/multisig-signer/project.json @@ -74,6 +74,13 @@ "nx build multisig-signer" ] } + }, + "build-spec": { + "executor": "@nrwl/workspace:run-commands", + "outputs": [], + "options": { + "command": "yarn tsc --project ./apps/multisig-signer/tsconfig.spec.json" + } } }, "tags": [] diff --git a/apps/static/src/assets/mainnet-tranches.json b/apps/static/src/assets/mainnet-tranches.json index e7a449b98..7285f019a 100644 --- a/apps/static/src/assets/mainnet-tranches.json +++ b/apps/static/src/assets/mainnet-tranches.json @@ -274,7 +274,7 @@ "tranche_end": "2023-12-05T00:00:00.000Z", "total_added": "129999.45", "total_removed": "0", - "locked_amount": "96249.65741714187627252", + "locked_amount": "96016.17448193874966366", "deposits": [ { "amount": "129999.45", @@ -340,7 +340,7 @@ "tranche_end": "2023-09-03T00:00:00.000Z", "total_added": "52600", "total_removed": "0", - "locked_amount": "45067.54189497717188", + "locked_amount": "44925.70570142060104", "deposits": [ { "amount": "2600", @@ -513,7 +513,7 @@ "tranche_end": "2023-09-17T00:00:00.000Z", "total_added": "5000", "total_removed": "0", - "locked_amount": "4475.767694063927", + "locked_amount": "4462.28516615931", "deposits": [ { "amount": "5000", @@ -724,7 +724,7 @@ "tranche_end": "2023-04-05T00:00:00.000Z", "total_added": "97499.58", "total_removed": "0", - "locked_amount": "37634.1494879773269697494", + "locked_amount": "37405.12447846227415707", "deposits": [ { "amount": "97499.58", @@ -757,7 +757,7 @@ "tranche_end": "2023-04-05T00:00:00.000Z", "total_added": "135173.4239508", "total_removed": "0", - "locked_amount": "51439.385085206660947364406288", + "locked_amount": "51126.347436717991246186291608", "deposits": [ { "amount": "135173.4239508", @@ -790,7 +790,7 @@ "tranche_end": "2023-04-05T00:00:00.000Z", "total_added": "32499.86", "total_removed": "0", - "locked_amount": "15832.0367825928700854478", + "locked_amount": "15735.689916140255189314", "deposits": [ { "amount": "32499.86", @@ -823,7 +823,7 @@ "tranche_end": "2023-04-05T00:00:00.000Z", "total_added": "10833.29", "total_removed": "0", - "locked_amount": "5153.1743422855387802305", + "locked_amount": "5121.814372183075076614", "deposits": [ { "amount": "10833.29", @@ -856,7 +856,7 @@ "tranche_end": "2023-04-05T00:00:00.000Z", "total_added": "22749.93", "total_removed": "0", - "locked_amount": "19263.716632166230787346", + "locked_amount": "19146.486059800393774347", "deposits": [ { "amount": "6500", @@ -931,7 +931,7 @@ "tranche_end": "2022-11-01T00:00:00.000Z", "total_added": "30000", "total_removed": "0", - "locked_amount": "1097.4524456521728", + "locked_amount": "936.98105374396269", "deposits": [ { "amount": "7500", @@ -1048,7 +1048,7 @@ "tranche_end": "2023-06-02T00:00:00.000Z", "total_added": "1939928.38", "total_removed": "626880.6921411330574", - "locked_amount": "1167842.42108528531283383", + "locked_amount": "1162611.393382023622567738", "deposits": [ { "amount": "1852091.69", @@ -1345,7 +1345,7 @@ "tranche_end": "2023-02-01T00:00:00.000Z", "total_added": "42500", "total_removed": "0", - "locked_amount": "22804.72429800725075", + "locked_amount": "22577.38982613727525", "deposits": [ { "amount": "12500", @@ -3808,10 +3808,15 @@ "tranche_id": 10, "tranche_start": "2021-07-15T23:37:11.000Z", "tranche_end": "2021-07-15T23:37:11.000Z", - "total_added": "5115969.150000000000000001", - "total_removed": "5113483.280000000000000001", + "total_added": "5565969.150000000000000001", + "total_removed": "5563483.280000000000000001", "locked_amount": "0", "deposits": [ + { + "amount": "450000", + "user": "0xb2d6DEC77558Cf8EdB7c428d23E70Eab0688544f", + "tx": "0xfd3f5320618d015f10fd774838c6be49fd80f0e5afb678684ac7c7361b97da2e" + }, { "amount": "100000", "user": "0xb2d6DEC77558Cf8EdB7c428d23E70Eab0688544f", @@ -4294,6 +4299,11 @@ } ], "withdrawals": [ + { + "amount": "450000", + "user": "0xb2d6DEC77558Cf8EdB7c428d23E70Eab0688544f", + "tx": "0x71a6411439723e3edc24a7acb552c4ff2b6980872798ef8512ecd6a03e397b71" + }, { "amount": "100000", "user": "0xb2d6DEC77558Cf8EdB7c428d23E70Eab0688544f", @@ -4724,6 +4734,12 @@ { "address": "0xb2d6DEC77558Cf8EdB7c428d23E70Eab0688544f", "deposits": [ + { + "amount": "450000", + "user": "0xb2d6DEC77558Cf8EdB7c428d23E70Eab0688544f", + "tranche_id": 10, + "tx": "0xfd3f5320618d015f10fd774838c6be49fd80f0e5afb678684ac7c7361b97da2e" + }, { "amount": "100000", "user": "0xb2d6DEC77558Cf8EdB7c428d23E70Eab0688544f", @@ -4864,6 +4880,12 @@ } ], "withdrawals": [ + { + "amount": "450000", + "user": "0xb2d6DEC77558Cf8EdB7c428d23E70Eab0688544f", + "tranche_id": 10, + "tx": "0x71a6411439723e3edc24a7acb552c4ff2b6980872798ef8512ecd6a03e397b71" + }, { "amount": "100000", "user": "0xb2d6DEC77558Cf8EdB7c428d23E70Eab0688544f", @@ -4997,8 +5019,8 @@ "tx": "0xac16a4ce688d40a482a59914d68c3a676592f8804ee8f0781b66a4ba5ccfbdfc" } ], - "total_tokens": "1956651", - "withdrawn_tokens": "1956651", + "total_tokens": "2406651", + "withdrawn_tokens": "2406651", "remaining_tokens": "0" }, { @@ -6047,10 +6069,30 @@ "tranche_id": 11, "tranche_start": "2021-09-03T00:00:00.000Z", "tranche_end": "2022-09-03T00:00:00.000Z", - "total_added": "40655.000000000000000003", + "total_added": "40684.000000000000000003", "total_removed": "25366.75324099301", "locked_amount": "0", "deposits": [ + { + "amount": "10", + "user": "0xABD95f7D67e76280df18220AA6F5A7358956C58b", + "tx": "0x37d6f89baf838aabecdc5b9a73d1e77e756a3f5c481110b58a10411e92ad0cba" + }, + { + "amount": "12", + "user": "0xABD95f7D67e76280df18220AA6F5A7358956C58b", + "tx": "0x60df930da53b884d43f81a103c7637e3edf27d2a4b52d8692e69d9c089fd98ee" + }, + { + "amount": "2", + "user": "0xABD95f7D67e76280df18220AA6F5A7358956C58b", + "tx": "0xb709a7c454621197a14942e134f78cc03c06dfb16a51a2c9be8319bf934ed812" + }, + { + "amount": "5", + "user": "0xABD95f7D67e76280df18220AA6F5A7358956C58b", + "tx": "0x1ced95c8b8f51848273bf2a048e6ebe9e200e59f959664620e207ce54fdadc00" + }, { "amount": "125", "user": "0x3a380f7CFdEeb723228cA57d2795EA215094000d", @@ -13575,6 +13617,39 @@ } ], "users": [ + { + "address": "0xABD95f7D67e76280df18220AA6F5A7358956C58b", + "deposits": [ + { + "amount": "10", + "user": "0xABD95f7D67e76280df18220AA6F5A7358956C58b", + "tranche_id": 11, + "tx": "0x37d6f89baf838aabecdc5b9a73d1e77e756a3f5c481110b58a10411e92ad0cba" + }, + { + "amount": "12", + "user": "0xABD95f7D67e76280df18220AA6F5A7358956C58b", + "tranche_id": 11, + "tx": "0x60df930da53b884d43f81a103c7637e3edf27d2a4b52d8692e69d9c089fd98ee" + }, + { + "amount": "2", + "user": "0xABD95f7D67e76280df18220AA6F5A7358956C58b", + "tranche_id": 11, + "tx": "0xb709a7c454621197a14942e134f78cc03c06dfb16a51a2c9be8319bf934ed812" + }, + { + "amount": "5", + "user": "0xABD95f7D67e76280df18220AA6F5A7358956C58b", + "tranche_id": 11, + "tx": "0x1ced95c8b8f51848273bf2a048e6ebe9e200e59f959664620e207ce54fdadc00" + } + ], + "withdrawals": [], + "total_tokens": "29", + "withdrawn_tokens": "0", + "remaining_tokens": "29" + }, { "address": "0x3a380f7CFdEeb723228cA57d2795EA215094000d", "deposits": [ @@ -24780,8 +24855,8 @@ "tranche_start": "2022-03-05T00:00:00.000Z", "tranche_end": "2023-06-05T00:00:00.000Z", "total_added": "3732368.4671", - "total_removed": "223275.6398802360697", - "locked_amount": "1819068.43186497551785693485", + "total_removed": "223655.6603333956257", + "locked_amount": "1811030.258062187675158904076", "deposits": [ { "amount": "1998.95815", @@ -24955,6 +25030,11 @@ "user": "0xE6CacAE56Cca8dFdB7910b5A13578719D4E57DA0", "tx": "0xf6708cf8b4b71e4705a99ccfc967456280544ccb064518c4ae06e08b6df3efa7" }, + { + "amount": "380.020453159556", + "user": "0xE6CacAE56Cca8dFdB7910b5A13578719D4E57DA0", + "tx": "0xdc11263bc339be651ab14af63174f2cdb29eaf3300a6a809b2f9a610df94f469" + }, { "amount": "4439.863808001919", "user": "0xE6CacAE56Cca8dFdB7910b5A13578719D4E57DA0", @@ -25160,6 +25240,12 @@ "tranche_id": 1, "tx": "0xf6708cf8b4b71e4705a99ccfc967456280544ccb064518c4ae06e08b6df3efa7" }, + { + "amount": "380.020453159556", + "user": "0xE6CacAE56Cca8dFdB7910b5A13578719D4E57DA0", + "tranche_id": 1, + "tx": "0xdc11263bc339be651ab14af63174f2cdb29eaf3300a6a809b2f9a610df94f469" + }, { "amount": "4439.863808001919", "user": "0xE6CacAE56Cca8dFdB7910b5A13578719D4E57DA0", @@ -25270,8 +25356,8 @@ } ], "total_tokens": "187637.95", - "withdrawn_tokens": "96033.171050169656", - "remaining_tokens": "91604.778949830344" + "withdrawn_tokens": "96413.191503329212", + "remaining_tokens": "91224.758496670788" }, { "address": "0x1A71e3ED1996CAbB91bB043f880CE963D601707e", @@ -25752,8 +25838,8 @@ "tranche_start": "2022-06-05T00:00:00.000Z", "tranche_end": "2023-12-05T00:00:00.000Z", "total_added": "15870102.715470999700000001", - "total_removed": "238273.7820930462773544", - "locked_amount": "11749987.4496775524656951941458329714098404", + "total_removed": "238759.9961824283322294", + "locked_amount": "11721484.6014729559154065406073874423533388", "deposits": [ { "amount": "16249.93", @@ -26282,6 +26368,16 @@ "user": "0xE6CacAE56Cca8dFdB7910b5A13578719D4E57DA0", "tx": "0xccc015d37acd80014d0cd747ec9b6f8fc55ae6c14ceb3c6bc5611382fb2200f5" }, + { + "amount": "465.356889800941875", + "user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b", + "tx": "0xfbc0ac40eb0b82233ff74c0b44e1f933e855c71c84060db7345e32d32fef1d2a" + }, + { + "amount": "20.857199581113", + "user": "0xE6CacAE56Cca8dFdB7910b5A13578719D4E57DA0", + "tx": "0x57be6b70763a67c21c44ec5b16bb2bdcd0201dd456d3be062ad639a500f615de" + }, { "amount": "243.932422174205", "user": "0xE6CacAE56Cca8dFdB7910b5A13578719D4E57DA0", @@ -27128,6 +27224,12 @@ "tranche_id": 2, "tx": "0xc1036c5ebdc4423f7e2241869acd2b218855eb087b7a7301b34c5f30d0c53468" }, + { + "amount": "465.356889800941875", + "user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b", + "tranche_id": 2, + "tx": "0xfbc0ac40eb0b82233ff74c0b44e1f933e855c71c84060db7345e32d32fef1d2a" + }, { "amount": "981.32183505687375", "user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b", @@ -27838,8 +27940,8 @@ } ], "total_tokens": "259998.8875", - "withdrawn_tokens": "67163.2107753242295", - "remaining_tokens": "192835.6767246757705" + "withdrawn_tokens": "67628.567665125171375", + "remaining_tokens": "192370.319834874828625" }, { "address": "0x89051CAb67Bc7F8CC44F7e270c6EDaf1EC57676c", @@ -28757,6 +28859,12 @@ "tranche_id": 2, "tx": "0xccc015d37acd80014d0cd747ec9b6f8fc55ae6c14ceb3c6bc5611382fb2200f5" }, + { + "amount": "20.857199581113", + "user": "0xE6CacAE56Cca8dFdB7910b5A13578719D4E57DA0", + "tranche_id": 2, + "tx": "0x57be6b70763a67c21c44ec5b16bb2bdcd0201dd456d3be062ad639a500f615de" + }, { "amount": "243.932422174205", "user": "0xE6CacAE56Cca8dFdB7910b5A13578719D4E57DA0", @@ -28849,8 +28957,8 @@ } ], "total_tokens": "12362.05", - "withdrawn_tokens": "3200.923492408422", - "remaining_tokens": "9161.126507591578" + "withdrawn_tokens": "3221.780691989535", + "remaining_tokens": "9140.269308010465" }, { "address": "0xb091D456d0dFCB94dcba6f355379056C5bb995fC", @@ -29474,8 +29582,8 @@ "tranche_start": "2021-11-05T00:00:00.000Z", "tranche_end": "2023-05-05T00:00:00.000Z", "total_added": "14597706.0446472999", - "total_removed": "3140755.062704674199099637", - "locked_amount": "5126068.16287379526746716073449839", + "total_removed": "3141399.277884802232022137", + "locked_amount": "5099754.51540371360721163558107384", "deposits": [ { "amount": "129284.449", @@ -29699,6 +29807,11 @@ "user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b", "tx": "0x14c4b4cf77c54981577d361682f156d5fa12b867b286df96746eac2fbcbc1699" }, + { + "amount": "644.2151801280329225", + "user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b", + "tx": "0xc88cbd4f724b63b359afeec4284dc430a581e94c94df08f775476bb6e7641d7f" + }, { "amount": "1360.2331260920135955", "user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b", @@ -32023,6 +32136,12 @@ "tranche_id": 3, "tx": "0x14c4b4cf77c54981577d361682f156d5fa12b867b286df96746eac2fbcbc1699" }, + { + "amount": "644.2151801280329225", + "user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b", + "tranche_id": 3, + "tx": "0xc88cbd4f724b63b359afeec4284dc430a581e94c94df08f775476bb6e7641d7f" + }, { "amount": "1360.2331260920135955", "user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b", @@ -34011,8 +34130,8 @@ } ], "total_tokens": "359123.469575", - "withdrawn_tokens": "232548.516908492756543", - "remaining_tokens": "126574.952666507243457" + "withdrawn_tokens": "233192.7320886207894655", + "remaining_tokens": "125930.7374863792105345" }, { "address": "0xBdd412797c1B78535Afc5F71503b91fAbD0160fB", @@ -35129,8 +35248,8 @@ "tranche_start": "2021-10-05T00:00:00.000Z", "tranche_end": "2023-04-05T00:00:00.000Z", "total_added": "5778205.3912159303", - "total_removed": "1946099.134996047321029132", - "locked_amount": "1708437.129813389772078403182360171", + "total_removed": "2110079.858212660363479132", + "locked_amount": "1698040.44855434566635123479204978", "deposits": [ { "amount": "552496.6455", @@ -35279,6 +35398,11 @@ "user": "0xafa64cCa337eFEE0AD827F6C2684e69275226e90", "tx": "0x5e6e6f25a5e54eaaaec1b558ebbe5ef03a6a5e5ace1d2ebdbe0b785fe7893827" }, + { + "amount": "163980.72321661304245", + "user": "0x83b1a48376E045D26420200345414e6b93066396", + "tx": "0xb2e3a1c7547cc573d47d8902010f5b6f837f1b4580570f0fa34b6041a6ca70a6" + }, { "amount": "14848.19419062596735675", "user": "0x9058e12e2F32cB1cD4D3123359963D77786477FC", @@ -36349,6 +36473,12 @@ } ], "withdrawals": [ + { + "amount": "163980.72321661304245", + "user": "0x83b1a48376E045D26420200345414e6b93066396", + "tranche_id": 4, + "tx": "0xb2e3a1c7547cc573d47d8902010f5b6f837f1b4580570f0fa34b6041a6ca70a6" + }, { "amount": "60299.73667925783", "user": "0x83b1a48376E045D26420200345414e6b93066396", @@ -36387,8 +36517,8 @@ } ], "total_tokens": "1104995.291", - "withdrawn_tokens": "615457.29883212240315", - "remaining_tokens": "489537.99216787759685" + "withdrawn_tokens": "779438.0220487354456", + "remaining_tokens": "325557.2689512645544" }, { "address": "0x5565d64f29Ea17355106DF3bA5903Eb793B3e139", @@ -36738,7 +36868,7 @@ "tranche_end": "2023-06-05T00:00:00.000Z", "total_added": "472355.6199999996", "total_removed": "6182.082957838296", - "locked_amount": "288241.79126746612658824589852868", + "locked_amount": "286968.0966802541023539294469812", "deposits": [ { "amount": "3000", @@ -63705,7 +63835,7 @@ "tranche_start": "2021-12-05T00:00:00.000Z", "tranche_end": "2022-06-05T00:00:00.000Z", "total_added": "171288.42", - "total_removed": "56194.7088304822989", + "total_removed": "56244.8822826097989", "locked_amount": "0", "deposits": [ { @@ -67940,6 +68070,11 @@ "user": "0x4e2b2C4F091f0167770822a706f05C6c51B46E85", "tx": "0x7bc2cab61bc39fd7d196ae964e72332b9917e26168a180474162aeab5d331897" }, + { + "amount": "50.1734521275", + "user": "0x21d4109baaB9aAB379CaCf2D121357ada958570D", + "tx": "0x257f56185f835db9af657e45218e8aa6e29e0fa84fa1e0139ca1564b1ce11520" + }, { "amount": "40", "user": "0x7cE6eB9eCcbe0E2d35Cd4515d58b813d943BF2Ec", @@ -76455,6 +76590,12 @@ } ], "withdrawals": [ + { + "amount": "50.1734521275", + "user": "0x21d4109baaB9aAB379CaCf2D121357ada958570D", + "tranche_id": 6, + "tx": "0x257f56185f835db9af657e45218e8aa6e29e0fa84fa1e0139ca1564b1ce11520" + }, { "amount": "199.8265478725", "user": "0x21d4109baaB9aAB379CaCf2D121357ada958570D", @@ -76463,8 +76604,8 @@ } ], "total_tokens": "250", - "withdrawn_tokens": "199.8265478725", - "remaining_tokens": "50.1734521275" + "withdrawn_tokens": "250", + "remaining_tokens": "0" }, { "address": "0x667B436A05523B8D80483b030f559f034753DD74", diff --git a/apps/stats/project.json b/apps/stats/project.json index b2cd4ef89..a91297962 100644 --- a/apps/stats/project.json +++ b/apps/stats/project.json @@ -64,6 +64,13 @@ "jestConfig": "apps/stats/jest.config.ts", "passWithNoTests": true } + }, + "build-spec": { + "executor": "@nrwl/workspace:run-commands", + "outputs": [], + "options": { + "command": "yarn tsc --project ./apps/stats/tsconfig.spec.json" + } } }, "tags": [] diff --git a/apps/token/client.graphql b/apps/token/client.graphql index 137c4d621..0d1528f28 100644 --- a/apps/token/client.graphql +++ b/apps/token/client.graphql @@ -37,7 +37,7 @@ extend type RewardPerAssetDetail { totalAmountFormatted: String! } -extend type Account { +extend type AccountBalance { "The balance field formatted by the client" balanceFormatted: String! } diff --git a/apps/token/project.json b/apps/token/project.json index 134893657..35013c747 100644 --- a/apps/token/project.json +++ b/apps/token/project.json @@ -74,6 +74,13 @@ "nx build token" ] } + }, + "build-spec": { + "executor": "@nrwl/workspace:run-commands", + "outputs": [], + "options": { + "command": "yarn tsc --project ./apps/token/tsconfig.spec.json" + } } }, "tags": [] diff --git a/apps/token/src/components/vega-wallet/__generated__/Delegations.ts b/apps/token/src/components/vega-wallet/__generated__/Delegations.ts index cf03776e8..858c3470b 100644 --- a/apps/token/src/components/vega-wallet/__generated__/Delegations.ts +++ b/apps/token/src/components/vega-wallet/__generated__/Delegations.ts @@ -97,7 +97,7 @@ export interface Delegations_party_accounts_asset { } export interface Delegations_party_accounts { - __typename: "Account"; + __typename: "AccountBalance"; /** * Asset, the 'currency' */ diff --git a/apps/token/src/components/vega-wallet/__generated___/Delegations.ts b/apps/token/src/components/vega-wallet/__generated___/Delegations.ts index 521d0282f..08c41fcd6 100644 --- a/apps/token/src/components/vega-wallet/__generated___/Delegations.ts +++ b/apps/token/src/components/vega-wallet/__generated___/Delegations.ts @@ -8,7 +8,7 @@ export type DelegationsQueryVariables = Types.Exact<{ }>; -export type DelegationsQuery = { __typename?: 'Query', epoch: { __typename?: 'Epoch', id: string }, party?: { __typename?: 'Party', id: string, delegations?: Array<{ __typename?: 'Delegation', amountFormatted: string, amount: string, epoch: number, node: { __typename?: 'Node', id: string, name: string } }> | null, stake: { __typename?: 'PartyStake', currentStakeAvailable: string, currentStakeAvailableFormatted: string }, accounts?: Array<{ __typename?: 'Account', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', name: string, id: string, decimals: number, symbol: string, source: { __typename: 'BuiltinAsset' } | { __typename: 'ERC20', contractAddress: string } } }> | null } | null }; +export type DelegationsQuery = { __typename?: 'Query', epoch: { __typename?: 'Epoch', id: string }, party?: { __typename?: 'Party', id: string, delegations?: Array<{ __typename?: 'Delegation', amountFormatted: string, amount: string, epoch: number, node: { __typename?: 'Node', id: string, name: string } }> | null, stake: { __typename?: 'PartyStake', currentStakeAvailable: string, currentStakeAvailableFormatted: string }, accounts?: Array<{ __typename?: 'AccountBalance', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', name: string, id: string, decimals: number, symbol: string, source: { __typename: 'BuiltinAsset' } | { __typename: 'ERC20', contractAddress: string } } }> | null } | null }; export const DelegationsDocument = gql` diff --git a/apps/token/src/lib/client.graphql b/apps/token/src/lib/client.graphql index 0cea90165..3e1f3fbfd 100644 --- a/apps/token/src/lib/client.graphql +++ b/apps/token/src/lib/client.graphql @@ -32,6 +32,6 @@ extend type RewardPerAssetDetail { totalAmountFormatted: String! } -extend type Account { +extend type AccountBalance { balanceFormatted: String! } diff --git a/apps/token/src/routes/governance/components/proposal/proposal.spec.tsx b/apps/token/src/routes/governance/components/proposal/proposal.spec.tsx index b8880e72c..38fd59bc6 100644 --- a/apps/token/src/routes/governance/components/proposal/proposal.spec.tsx +++ b/apps/token/src/routes/governance/components/proposal/proposal.spec.tsx @@ -1,6 +1,7 @@ import { render, screen } from '@testing-library/react'; import { generateProposal } from '../../test-helpers/generate-proposals'; import { Proposal } from './proposal'; +import type { Proposal_proposal } from '../../proposal/__generated__/Proposal'; jest.mock('../proposal-detail-header/proposal-header', () => ({ ProposalHeader: () =>
, @@ -20,13 +21,13 @@ jest.mock('../vote-details', () => ({ it('Renders with data-testid', () => { const proposal = generateProposal(); - render(); + render(); expect(screen.getByTestId('proposal')).toBeInTheDocument(); }); it('renders each section', () => { const proposal = generateProposal(); - render(); + render(); expect(screen.getByTestId('proposal-header')).toBeInTheDocument(); expect(screen.getByTestId('proposal-change-table')).toBeInTheDocument(); expect(screen.getByTestId('proposal-terms-json')).toBeInTheDocument(); diff --git a/apps/token/src/routes/governance/components/proposals-list/proposals-list.spec.tsx b/apps/token/src/routes/governance/components/proposals-list/proposals-list.spec.tsx index ab1bd7159..58f47d418 100644 --- a/apps/token/src/routes/governance/components/proposals-list/proposals-list.spec.tsx +++ b/apps/token/src/routes/governance/components/proposals-list/proposals-list.spec.tsx @@ -14,7 +14,7 @@ import { lastMonth, nextMonth, } from '../../test-helpers/mocks'; -import type { ProposalsConnection_proposalsConnection_edges_node as ProposalNode } from '@vegaprotocol/governance'; +import type { ProposalFields } from '../../__generated__/ProposalFields'; const openProposalClosesNextMonth = generateProposal({ id: 'proposal1', @@ -58,7 +58,7 @@ const failedProposalClosedLastMonth = generateProposal({ }, }); -const renderComponent = (proposals: ProposalNode[]) => ( +const renderComponent = (proposals: ProposalFields[]) => ( diff --git a/apps/token/src/routes/governance/components/proposals-list/rejected-proposals-list.spec.tsx b/apps/token/src/routes/governance/components/proposals-list/rejected-proposals-list.spec.tsx index 8c1826926..6804d1e94 100644 --- a/apps/token/src/routes/governance/components/proposals-list/rejected-proposals-list.spec.tsx +++ b/apps/token/src/routes/governance/components/proposals-list/rejected-proposals-list.spec.tsx @@ -12,7 +12,7 @@ import { nextWeek, lastMonth, } from '../../test-helpers/mocks'; -import type { ProposalsConnection_proposalsConnection_edges_node as ProposalNode } from '@vegaprotocol/governance'; +import type { ProposalFields } from '../../__generated__/ProposalFields'; const rejectedProposalClosesNextWeek = generateProposal({ id: 'rejected1', @@ -35,7 +35,7 @@ const rejectedProposalClosedLastMonth = generateProposal({ }, }); -const renderComponent = (proposals: ProposalNode[]) => ( +const renderComponent = (proposals: ProposalFields[]) => ( diff --git a/apps/token/src/routes/governance/components/propose/proposal-form-vote-and-enactment-deadline.spec.tsx b/apps/token/src/routes/governance/components/propose/proposal-form-vote-and-enactment-deadline.spec.tsx index 8652bd64d..2d2824f5f 100644 --- a/apps/token/src/routes/governance/components/propose/proposal-form-vote-and-enactment-deadline.spec.tsx +++ b/apps/token/src/routes/governance/components/propose/proposal-form-vote-and-enactment-deadline.spec.tsx @@ -1,6 +1,13 @@ import { render, screen, fireEvent, act } from '@testing-library/react'; import { ProposalFormVoteAndEnactmentDeadline } from './proposal-form-vote-and-enactment-deadline'; +jest.mock('@vegaprotocol/react-helpers', () => ({ + ...jest.requireActual('@vegaprotocol/react-helpers'), + getDateTimeFormat: jest.fn(() => ({ + format: (date: Date) => date.toISOString(), + })), +})); + beforeEach(() => { jest.useFakeTimers(); jest.setSystemTime(new Date('2022-01-01T00:00:00.000Z')); @@ -19,7 +26,6 @@ const maxEnactDeadline = '4h0m0s'; * Formats date according to locale. * @param expected Use format: YYYY-MM-DDThh:mm:ss.000Z */ -const expectedDate = (expected: string) => new Date(expected).toLocaleString(); const renderComponent = () => { const register = jest.fn(); @@ -142,13 +148,13 @@ describe('Proposal form vote, validation and enactment deadline', () => { // Should be adding 2 mins to the vote deadline as the minimum is set by // default, and we add 2 mins for wallet confirmation expect(screen.getByTestId('voting-date')).toHaveTextContent( - expectedDate('2022-01-01T01:02:00.000Z') + '2022-01-01T01:02:00.000Z' ); expect(screen.getByTestId('validation-date')).toHaveTextContent( - expectedDate('2022-01-01T00:02:00.000Z') + '2022-01-01T00:02:00.000Z' ); expect(screen.getByTestId('enactment-date')).toHaveTextContent( - expectedDate('2022-01-01T02:00:00.000Z') + '2022-01-01T02:00:00.000Z' ); }); @@ -159,13 +165,13 @@ describe('Proposal form vote, validation and enactment deadline', () => { }); expect(screen.getByTestId('voting-date')).toHaveTextContent( - expectedDate('2022-01-01T01:02:30.000Z') + '2022-01-01T01:02:30.000Z' ); expect(screen.getByTestId('validation-date')).toHaveTextContent( - expectedDate('2022-01-01T00:02:30.000Z') + '2022-01-01T00:02:30.000Z' ); expect(screen.getByTestId('enactment-date')).toHaveTextContent( - expectedDate('2022-01-01T02:00:30.000Z') + '2022-01-01T02:00:30.000Z' ); }); @@ -174,10 +180,10 @@ describe('Proposal form vote, validation and enactment deadline', () => { const voteDeadlineInput = screen.getByTestId('proposal-vote-deadline'); fireEvent.change(voteDeadlineInput, { target: { value: 2 } }); expect(screen.getByTestId('voting-date')).toHaveTextContent( - expectedDate('2022-01-01T02:00:00.000Z') + '2022-01-01T02:00:00.000Z' ); expect(screen.getByTestId('enactment-date')).toHaveTextContent( - expectedDate('2022-01-01T03:00:00.000Z') + '2022-01-01T03:00:00.000Z' ); }); @@ -192,12 +198,12 @@ describe('Proposal form vote, validation and enactment deadline', () => { fireEvent.click(voteDeadlineMaxButton); fireEvent.click(validationDeadlineMaxButton); expect(screen.getByTestId('validation-date')).toHaveTextContent( - expectedDate('2022-01-01T05:00:00.000Z') + '2022-01-01T05:00:00.000Z' ); expect(validationDeadlineInput).toHaveValue(5); fireEvent.click(voteDeadlineMinButton); expect(screen.getByTestId('validation-date')).toHaveTextContent( - expectedDate('2022-01-01T01:00:00.000Z') + '2022-01-01T01:00:00.000Z' ); expect(validationDeadlineInput).toHaveValue(1); }); diff --git a/apps/token/src/routes/governance/components/propose/proposal-form-vote-and-enactment-deadline.tsx b/apps/token/src/routes/governance/components/propose/proposal-form-vote-and-enactment-deadline.tsx index ffc2637e1..a1da96410 100644 --- a/apps/token/src/routes/governance/components/propose/proposal-form-vote-and-enactment-deadline.tsx +++ b/apps/token/src/routes/governance/components/propose/proposal-form-vote-and-enactment-deadline.tsx @@ -6,6 +6,7 @@ import { Input, InputError, } from '@vegaprotocol/ui-toolkit'; +import { getDateTimeFormat } from '@vegaprotocol/react-helpers'; import { addHours, addMinutes } from 'date-fns'; import { deadlineToSeconds, @@ -109,7 +110,7 @@ const ValidationForm = ({ {t('ThisWillSetValidationDeadlineTo')} - {deadlineDates.validation.toLocaleString()} + {getDateTimeFormat().format(deadlineDates.validation)} {deadlines.validation === 0 && ( - {deadlineDates.enactment.toLocaleString()} + {getDateTimeFormat().format(deadlineDates.enactment)}

)} @@ -454,7 +455,7 @@ export function ProposalFormVoteAndEnactmentDeadline({ {t('ThisWillSetVotingDeadlineTo')}
- {deadlineDates.vote.toLocaleString()} + {getDateTimeFormat().format(deadlineDates.vote)} {deadlines.vote === minVoteHours && ( { it('Renders proposal details if proposal is found', async () => { const proposal = generateProposal({ id: 'foo' }); - render(renderComponent(proposal, 'foo')); + render(renderComponent(proposal as Proposal_proposal, 'foo')); await waitFor(() => { expect(screen.getByTestId('proposal')).toBeInTheDocument(); }); diff --git a/apps/token/src/routes/governance/proposals/__generated__/ProposalFields.ts b/apps/token/src/routes/governance/proposals/__generated__/ProposalFields.ts index 6254a74ea..7d93e4f54 100644 --- a/apps/token/src/routes/governance/proposals/__generated__/ProposalFields.ts +++ b/apps/token/src/routes/governance/proposals/__generated__/ProposalFields.ts @@ -137,12 +137,13 @@ export interface ProposalFields_terms_change_UpdateAsset_source { __typename: "UpdateERC20"; /** * The lifetime limits deposit per address - * Note: this is a temporary measure for alpha mainnet + * Note: this is a temporary measure that can be changed by governance */ lifetimeLimit: string; /** - * The maximum allowed per withdrawal - * Note: this is a temporary measure for alpha mainnet + * The maximum you can withdraw instantly. All withdrawals over the threshold will be delayed by the withdrawal delay. + * There’s no limit on the size of a withdrawal + * Note: this is a temporary measure that can be changed by governance */ withdrawThreshold: string; } diff --git a/apps/token/src/routes/governance/proposals/__generated__/Proposals.ts b/apps/token/src/routes/governance/proposals/__generated__/Proposals.ts index 012dea01c..6395a02b3 100644 --- a/apps/token/src/routes/governance/proposals/__generated__/Proposals.ts +++ b/apps/token/src/routes/governance/proposals/__generated__/Proposals.ts @@ -137,12 +137,13 @@ export interface Proposals_proposalsConnection_edges_node_terms_change_UpdateAss __typename: "UpdateERC20"; /** * The lifetime limits deposit per address - * Note: this is a temporary measure for alpha mainnet + * Note: this is a temporary measure that can be changed by governance */ lifetimeLimit: string; /** - * The maximum allowed per withdrawal - * Note: this is a temporary measure for alpha mainnet + * The maximum you can withdraw instantly. All withdrawals over the threshold will be delayed by the withdrawal delay. + * There’s no limit on the size of a withdrawal + * Note: this is a temporary measure that can be changed by governance */ withdrawThreshold: string; } diff --git a/apps/token/src/routes/governance/propose/raw/proposal-raw.spec.tsx b/apps/token/src/routes/governance/propose/raw/proposal-raw.spec.tsx index b779c3161..fae5f0e08 100644 --- a/apps/token/src/routes/governance/propose/raw/proposal-raw.spec.tsx +++ b/apps/token/src/routes/governance/propose/raw/proposal-raw.spec.tsx @@ -6,7 +6,7 @@ import { MockedProvider } from '@apollo/client/testing'; import type { VegaWalletContextShape } from '@vegaprotocol/wallet'; import { VegaWalletContext } from '@vegaprotocol/wallet'; import { - BusEventType, + Schema, ProposalRejectionReason, ProposalState, } from '@vegaprotocol/types'; @@ -28,7 +28,7 @@ describe('Raw proposal form', () => { busEvents: [ { __typename: 'BusEvent', - type: BusEventType.Proposal, + type: Schema.BusEventType.Proposal, event: { __typename: 'Proposal', id: '2fca514cebf9f465ae31ecb4c5721e3a6f5f260425ded887ca50ba15b81a5d50', diff --git a/apps/trading-e2e/src/integration/market-summary.cy.ts b/apps/trading-e2e/src/integration/market-summary.cy.ts index bce5267f8..667b037da 100644 --- a/apps/trading-e2e/src/integration/market-summary.cy.ts +++ b/apps/trading-e2e/src/integration/market-summary.cy.ts @@ -118,11 +118,11 @@ describe('Market trading page', () => { const toolTipValue = 'tooltip-value'; const auctionToolTipLabels = [ 'Auction start', - 'Est auction end', + 'Est. auction end', 'Target liquidity', 'Current liquidity', - 'Est uncrossing price', - 'Est uncrossing vol', + 'Est. uncrossing price', + 'Est. uncrossing vol', ]; cy.getByTestId(marketSummaryBlock).within(() => { diff --git a/apps/trading-e2e/src/integration/trading-orders.cy.ts b/apps/trading-e2e/src/integration/trading-orders.cy.ts index 9d2bdc8d2..6dfdc314f 100644 --- a/apps/trading-e2e/src/integration/trading-orders.cy.ts +++ b/apps/trading-e2e/src/integration/trading-orders.cy.ts @@ -1,4 +1,4 @@ -import { OrderRejectionReason, OrderStatus } from '@vegaprotocol/types'; +import { Schema } from '@vegaprotocol/types'; import { connectVegaWallet } from '../support/vega-wallet'; import { updateOrder, @@ -19,7 +19,7 @@ const editOrderBtn = 'edit'; describe('orders list', { tags: '@smoke' }, () => { before(() => { const subscriptionMocks = getSubscriptionMocks(); - cy.spy(subscriptionMocks, 'OrderSub'); + cy.spy(subscriptionMocks, 'OrdersUpdate'); cy.mockTradingPage(); cy.mockGQLSubscription(subscriptionMocks); cy.visit('/markets/market-0'); @@ -27,7 +27,7 @@ describe('orders list', { tags: '@smoke' }, () => { cy.getByTestId('tab-orders').contains('Please connect Vega wallet'); connectVegaWallet(); cy.wait('@Orders').then(() => { - expect(subscriptionMocks.OrderSub).to.be.calledOnce; + expect(subscriptionMocks.OrdersUpdate).to.be.calledOnce; }); }); it('renders orders', () => { @@ -124,7 +124,7 @@ describe('orders list', { tags: '@smoke' }, () => { describe('subscribe orders', { tags: '@smoke' }, () => { before(() => { const subscriptionMocks = getSubscriptionMocks(); - cy.spy(subscriptionMocks, 'OrderSub'); + cy.spy(subscriptionMocks, 'OrdersUpdate'); cy.mockTradingPage(); cy.mockGQLSubscription(subscriptionMocks); cy.visit('/markets/market-0'); @@ -132,7 +132,7 @@ describe('subscribe orders', { tags: '@smoke' }, () => { cy.getByTestId('tab-orders').contains('Please connect Vega wallet'); connectVegaWallet(); cy.wait('@Orders').then(() => { - expect(subscriptionMocks.OrderSub).to.be.calledOnce; + expect(subscriptionMocks.OrdersUpdate).to.be.calledOnce; }); }); const orderId = '1234567890'; @@ -142,7 +142,7 @@ describe('subscribe orders', { tags: '@smoke' }, () => { // 7002-SORD-041 updateOrder({ id: orderId, - status: OrderStatus.STATUS_ACTIVE, + status: Schema.OrderStatus.STATUS_ACTIVE, }); cy.get(`[row-id=${orderId}] [col-id=${orderStatus}]`).should( 'have.text', @@ -154,7 +154,7 @@ describe('subscribe orders', { tags: '@smoke' }, () => { // 7002-SORD-042 updateOrder({ id: orderId, - status: OrderStatus.STATUS_EXPIRED, + status: Schema.OrderStatus.STATUS_EXPIRED, }); cy.get(`[row-id=${orderId}] [col-id=${orderStatus}]`).should( 'have.text', @@ -167,7 +167,7 @@ describe('subscribe orders', { tags: '@smoke' }, () => { // NOT COVERED: see the txn that cancelled it and a link to the block explorer, if cancelled by a user transaction. updateOrder({ id: orderId, - status: OrderStatus.STATUS_CANCELLED, + status: Schema.OrderStatus.STATUS_CANCELLED, }); cy.get(`[row-id=${orderId}] [col-id=${orderStatus}]`).should( 'have.text', @@ -180,7 +180,7 @@ describe('subscribe orders', { tags: '@smoke' }, () => { // NOT COVERED: see an explanation of why stopped updateOrder({ id: orderId, - status: OrderStatus.STATUS_STOPPED, + status: Schema.OrderStatus.STATUS_STOPPED, }); cy.get(`[row-id=${orderId}] [col-id=${orderStatus}]`).should( 'have.text', @@ -192,7 +192,7 @@ describe('subscribe orders', { tags: '@smoke' }, () => { // 7002-SORD-045 updateOrder({ id: orderId, - status: OrderStatus.STATUS_PARTIALLY_FILLED, + status: Schema.OrderStatus.STATUS_PARTIALLY_FILLED, size: '5', remaining: '1', }); @@ -211,7 +211,7 @@ describe('subscribe orders', { tags: '@smoke' }, () => { // NOT COVERED: Must be able to see/link to all trades that were created from this order updateOrder({ id: orderId, - status: OrderStatus.STATUS_FILLED, + status: Schema.OrderStatus.STATUS_FILLED, }); cy.get(`[row-id=${orderId}] [col-id=${orderStatus}]`).should( 'have.text', @@ -223,8 +223,8 @@ describe('subscribe orders', { tags: '@smoke' }, () => { // 7002-SORD-047 updateOrder({ id: orderId, - status: OrderStatus.STATUS_REJECTED, - rejectionReason: OrderRejectionReason.ORDER_ERROR_INTERNAL_ERROR, + status: Schema.OrderStatus.STATUS_REJECTED, + rejectionReason: Schema.OrderRejectionReason.ORDER_ERROR_INTERNAL_ERROR, }); cy.get(`[row-id=${orderId}] [col-id=${orderStatus}]`).should( 'have.text', @@ -237,7 +237,7 @@ describe('subscribe orders', { tags: '@smoke' }, () => { // NOT COVERED: must see an explanation of why parked orders happen updateOrder({ id: orderId, - status: OrderStatus.STATUS_PARKED, + status: Schema.OrderStatus.STATUS_PARKED, }); cy.get(`[row-id=${orderId}] [col-id=${orderStatus}]`).should( 'have.text', diff --git a/apps/trading-e2e/src/support/mocks/generate-accounts.ts b/apps/trading-e2e/src/support/mocks/generate-accounts.ts index a277be603..202aef39a 100644 --- a/apps/trading-e2e/src/support/mocks/generate-accounts.ts +++ b/apps/trading-e2e/src/support/mocks/generate-accounts.ts @@ -12,7 +12,7 @@ export const generateAccounts = ( id: Cypress.env('VEGA_PUBLIC_KEY'), accounts: [ { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_GENERAL, balance: '100000000', market: null, @@ -22,7 +22,7 @@ export const generateAccounts = ( }, }, { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_GENERAL, balance: '100000000', market: { @@ -35,7 +35,7 @@ export const generateAccounts = ( }, }, { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_MARGIN, balance: '1000', market: { @@ -48,7 +48,7 @@ export const generateAccounts = ( }, }, { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_MARGIN, balance: '1000', market: { @@ -61,7 +61,7 @@ export const generateAccounts = ( }, }, { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_GENERAL, balance: '100000000', market: null, @@ -72,7 +72,7 @@ export const generateAccounts = ( }, // account to withdraw Sepolia tBTC { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_GENERAL, balance: '100000000', market: null, diff --git a/apps/trading-e2e/src/support/mocks/generate-assets.ts b/apps/trading-e2e/src/support/mocks/generate-assets.ts index 01ada70eb..b4245028b 100644 --- a/apps/trading-e2e/src/support/mocks/generate-assets.ts +++ b/apps/trading-e2e/src/support/mocks/generate-assets.ts @@ -23,27 +23,27 @@ export const generateAsset = (override?: PartialDeep) => { status: Types.AssetStatus.STATUS_ENABLED, infrastructureFeeAccount: { balance: '1', - __typename: 'Account', + __typename: 'AccountBalance', }, globalRewardPoolAccount: { balance: '2', - __typename: 'Account', + __typename: 'AccountBalance', }, takerFeeRewardAccount: { balance: '3', - __typename: 'Account', + __typename: 'AccountBalance', }, makerFeeRewardAccount: { balance: '4', - __typename: 'Account', + __typename: 'AccountBalance', }, lpFeeRewardAccount: { balance: '5', - __typename: 'Account', + __typename: 'AccountBalance', }, marketProposerRewardAccount: { balance: '6', - __typename: 'Account', + __typename: 'AccountBalance', }, __typename: 'Asset', }, @@ -74,27 +74,27 @@ export const generateAssets = (override?: PartialDeep) => { status: Types.AssetStatus.STATUS_ENABLED, infrastructureFeeAccount: { balance: '1', - __typename: 'Account', + __typename: 'AccountBalance', }, globalRewardPoolAccount: { balance: '2', - __typename: 'Account', + __typename: 'AccountBalance', }, takerFeeRewardAccount: { balance: '3', - __typename: 'Account', + __typename: 'AccountBalance', }, makerFeeRewardAccount: { balance: '4', - __typename: 'Account', + __typename: 'AccountBalance', }, lpFeeRewardAccount: { balance: '5', - __typename: 'Account', + __typename: 'AccountBalance', }, marketProposerRewardAccount: { balance: '6', - __typename: 'Account', + __typename: 'AccountBalance', }, __typename: 'Asset', }, @@ -115,27 +115,27 @@ export const generateAssets = (override?: PartialDeep) => { status: Types.AssetStatus.STATUS_ENABLED, infrastructureFeeAccount: { balance: '1', - __typename: 'Account', + __typename: 'AccountBalance', }, globalRewardPoolAccount: { balance: '2', - __typename: 'Account', + __typename: 'AccountBalance', }, takerFeeRewardAccount: { balance: '3', - __typename: 'Account', + __typename: 'AccountBalance', }, makerFeeRewardAccount: { balance: '4', - __typename: 'Account', + __typename: 'AccountBalance', }, lpFeeRewardAccount: { balance: '5', - __typename: 'Account', + __typename: 'AccountBalance', }, marketProposerRewardAccount: { balance: '6', - __typename: 'Account', + __typename: 'AccountBalance', }, __typename: 'Asset', }, @@ -154,7 +154,7 @@ export const generateAssets = (override?: PartialDeep) => { status: Types.AssetStatus.STATUS_ENABLED, infrastructureFeeAccount: { balance: '0', - __typename: 'Account', + __typename: 'AccountBalance', }, globalRewardPoolAccount: null, takerFeeRewardAccount: null, @@ -183,27 +183,27 @@ export const generateAssets = (override?: PartialDeep) => { quantum: '1', infrastructureFeeAccount: { balance: '1', - __typename: 'Account', + __typename: 'AccountBalance', }, globalRewardPoolAccount: { balance: '2', - __typename: 'Account', + __typename: 'AccountBalance', }, takerFeeRewardAccount: { balance: '3', - __typename: 'Account', + __typename: 'AccountBalance', }, makerFeeRewardAccount: { balance: '4', - __typename: 'Account', + __typename: 'AccountBalance', }, lpFeeRewardAccount: { balance: '5', - __typename: 'Account', + __typename: 'AccountBalance', }, marketProposerRewardAccount: { balance: '6', - __typename: 'Account', + __typename: 'AccountBalance', }, __typename: 'Asset', }, @@ -225,27 +225,27 @@ export const generateAssets = (override?: PartialDeep) => { quantum: '1', infrastructureFeeAccount: { balance: '1', - __typename: 'Account', + __typename: 'AccountBalance', }, globalRewardPoolAccount: { balance: '2', - __typename: 'Account', + __typename: 'AccountBalance', }, takerFeeRewardAccount: { balance: '3', - __typename: 'Account', + __typename: 'AccountBalance', }, makerFeeRewardAccount: { balance: '4', - __typename: 'Account', + __typename: 'AccountBalance', }, lpFeeRewardAccount: { balance: '5', - __typename: 'Account', + __typename: 'AccountBalance', }, marketProposerRewardAccount: { balance: '6', - __typename: 'Account', + __typename: 'AccountBalance', }, __typename: 'Asset', }, diff --git a/apps/trading-e2e/src/support/mocks/generate-fills.ts b/apps/trading-e2e/src/support/mocks/generate-fills.ts index 8214b42e5..80d47784c 100644 --- a/apps/trading-e2e/src/support/mocks/generate-fills.ts +++ b/apps/trading-e2e/src/support/mocks/generate-fills.ts @@ -1,5 +1,5 @@ import type { FillsQuery, FillFieldsFragment } from '@vegaprotocol/fills'; -import { Side } from '@vegaprotocol/types'; +import { Schema } from '@vegaprotocol/types'; import merge from 'lodash/merge'; import type { PartialDeep } from 'type-fest'; @@ -17,7 +17,7 @@ export const generateFills = ( seller: { id: Cypress.env('VEGA_PUBLIC_KEY'), }, - aggressor: Side.SIDE_SELL, + aggressor: Schema.Side.SIDE_SELL, buyerFee: { infrastructureFee: '5000', }, @@ -30,11 +30,11 @@ export const generateFills = ( seller: { id: Cypress.env('VEGA_PUBLIC_KEY'), }, - aggressor: Side.SIDE_BUY, + aggressor: Schema.Side.SIDE_BUY, }), generateFill({ id: '3', - aggressor: Side.SIDE_SELL, + aggressor: Schema.Side.SIDE_SELL, market: { id: 'market-2', }, @@ -80,7 +80,7 @@ export const generateFill = (override?: PartialDeep) => { size: '50000', buyOrder: 'buy-order', sellOrder: 'sell-order', - aggressor: Side.SIDE_BUY, + aggressor: Schema.Side.SIDE_BUY, buyer: { __typename: 'Party', id: 'buyer-id', diff --git a/apps/trading-e2e/src/support/mocks/generate-market-info-query.ts b/apps/trading-e2e/src/support/mocks/generate-market-info-query.ts index 5686eaff5..b93fa78fe 100644 --- a/apps/trading-e2e/src/support/mocks/generate-market-info-query.ts +++ b/apps/trading-e2e/src/support/mocks/generate-market-info-query.ts @@ -36,7 +36,7 @@ export const generateMarketInfoQuery = ( __typename: 'Asset', }, balance: '0', - __typename: 'Account', + __typename: 'AccountBalance', }, { type: AccountType.ACCOUNT_TYPE_FEES_LIQUIDITY, @@ -45,7 +45,7 @@ export const generateMarketInfoQuery = ( __typename: 'Asset', }, balance: '0', - __typename: 'Account', + __typename: 'AccountBalance', }, ], fees: { diff --git a/apps/trading-e2e/src/support/mocks/generate-orders.ts b/apps/trading-e2e/src/support/mocks/generate-orders.ts index ed7424f0a..e9b7a0685 100644 --- a/apps/trading-e2e/src/support/mocks/generate-orders.ts +++ b/apps/trading-e2e/src/support/mocks/generate-orders.ts @@ -1,18 +1,12 @@ import merge from 'lodash/merge'; import type { PartialDeep } from 'type-fest'; -import type { - Orders, - Orders_party_ordersConnection_edges_node, -} from '@vegaprotocol/orders'; -import { - OrderStatus, - OrderTimeInForce, - OrderType, - Side, -} from '@vegaprotocol/types'; +import type { OrdersQuery, OrderFieldsFragment } from '@vegaprotocol/orders'; +import { Schema } from '@vegaprotocol/types'; -export const generateOrders = (override?: PartialDeep): Orders => { - const orders: Orders_party_ordersConnection_edges_node[] = [ +export const generateOrders = ( + override?: PartialDeep +): OrdersQuery => { + const orders: OrderFieldsFragment[] = [ { __typename: 'Order', id: '066468C06549101DAF7BC51099E1412A0067DC08C246B7D8013C9D0CBF1E8EE7', @@ -21,12 +15,12 @@ export const generateOrders = (override?: PartialDeep): Orders => { id: 'market-0', }, size: '10', - type: OrderType.TYPE_LIMIT, - status: OrderStatus.STATUS_FILLED, - side: Side.SIDE_BUY, + type: Schema.OrderType.TYPE_LIMIT, + status: Schema.OrderStatus.STATUS_FILLED, + side: Schema.Side.SIDE_BUY, remaining: '0', price: '20000000', - timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, createdAt: new Date(2020, 1, 30).toISOString(), updatedAt: null, expiresAt: null, @@ -42,12 +36,12 @@ export const generateOrders = (override?: PartialDeep): Orders => { id: 'market-1', }, size: '1', - type: OrderType.TYPE_LIMIT, - status: OrderStatus.STATUS_FILLED, - side: Side.SIDE_BUY, + type: Schema.OrderType.TYPE_LIMIT, + status: Schema.OrderStatus.STATUS_FILLED, + side: Schema.Side.SIDE_BUY, remaining: '0', price: '100', - timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, createdAt: new Date(2020, 1, 29).toISOString(), updatedAt: null, expiresAt: null, @@ -63,12 +57,12 @@ export const generateOrders = (override?: PartialDeep): Orders => { id: 'market-2', }, size: '1', - type: OrderType.TYPE_LIMIT, - status: OrderStatus.STATUS_FILLED, - side: Side.SIDE_BUY, + type: Schema.OrderType.TYPE_LIMIT, + status: Schema.OrderStatus.STATUS_FILLED, + side: Schema.Side.SIDE_BUY, remaining: '0', price: '20000', - timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, createdAt: new Date(2020, 1, 28).toISOString(), updatedAt: null, expiresAt: null, @@ -84,12 +78,12 @@ export const generateOrders = (override?: PartialDeep): Orders => { id: 'market-3', }, size: '1', - type: OrderType.TYPE_LIMIT, - status: OrderStatus.STATUS_ACTIVE, - side: Side.SIDE_BUY, + type: Schema.OrderType.TYPE_LIMIT, + status: Schema.OrderStatus.STATUS_ACTIVE, + side: Schema.Side.SIDE_BUY, remaining: '0', price: '100000', - timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, createdAt: new Date(2020, 1, 27).toISOString(), updatedAt: null, expiresAt: null, @@ -105,12 +99,12 @@ export const generateOrders = (override?: PartialDeep): Orders => { id: 'market-3', }, size: '10', - type: OrderType.TYPE_LIMIT, - status: OrderStatus.STATUS_PARTIALLY_FILLED, - side: Side.SIDE_SELL, + type: Schema.OrderType.TYPE_LIMIT, + status: Schema.OrderStatus.STATUS_PARTIALLY_FILLED, + side: Schema.Side.SIDE_SELL, remaining: '3', price: '100000', - timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, createdAt: new Date(2020, 1, 27).toISOString(), updatedAt: null, expiresAt: null, @@ -120,7 +114,7 @@ export const generateOrders = (override?: PartialDeep): Orders => { }, ]; - const defaultResult: Orders = { + const defaultResult: OrdersQuery = { party: { id: Cypress.env('VEGA_PUBLIC_KEY'), ordersConnection: { diff --git a/apps/trading-e2e/src/support/mocks/generate-ws-order-update.ts b/apps/trading-e2e/src/support/mocks/generate-ws-order-update.ts index 697a83bc5..c9e3255d6 100644 --- a/apps/trading-e2e/src/support/mocks/generate-ws-order-update.ts +++ b/apps/trading-e2e/src/support/mocks/generate-ws-order-update.ts @@ -1,48 +1,50 @@ import merge from 'lodash/merge'; import type { - OrderSub as OrderSubData, - OrderSubVariables, - OrderSub_orders, + OrdersUpdateSubscription, + OrdersUpdateSubscriptionVariables, + OrderUpdateFieldsFragment, } from '@vegaprotocol/orders'; import type { onMessage } from '@vegaprotocol/cypress'; -import { - OrderStatus, - OrderTimeInForce, - OrderType, - Side, -} from '@vegaprotocol/types'; +import { Schema } from '@vegaprotocol/types'; import type { PartialDeep } from 'type-fest'; -let sendOrderUpdate: (data: OrderSubData) => void; -const getOnOrderSub = () => { - const onOrderSub: onMessage = (send) => { +let sendOrderUpdate: (data: OrdersUpdateSubscription) => void; +const getOnOrderUpdate = () => { + const onOrderUpdate: onMessage< + OrdersUpdateSubscription, + OrdersUpdateSubscriptionVariables + > = (send) => { sendOrderUpdate = send; }; - return onOrderSub; + return onOrderUpdate; }; -export const getSubscriptionMocks = () => ({ OrderSub: getOnOrderSub() }); +export const getSubscriptionMocks = () => ({ + OrdersUpdate: getOnOrderUpdate(), +}); -export function updateOrder(override?: PartialDeep): void { - const order: OrderSub_orders = { +export function updateOrder( + override?: PartialDeep +): void { + const order: OrderUpdateFieldsFragment = { __typename: 'OrderUpdate', id: '1234567890', marketId: 'market-0', size: '10', - type: OrderType.TYPE_LIMIT, - status: OrderStatus.STATUS_FILLED, + type: Schema.OrderType.TYPE_LIMIT, + status: Schema.OrderStatus.STATUS_FILLED, rejectionReason: null, - side: Side.SIDE_BUY, + side: Schema.Side.SIDE_BUY, remaining: '0', price: '20000000', - timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, createdAt: new Date(2020, 1, 30).toISOString(), updatedAt: null, expiresAt: null, liquidityProvisionId: null, peggedOrder: null, }; - const update: OrderSubData = { + const update: OrdersUpdateSubscription = { orders: [merge(order, override)], }; if (!sendOrderUpdate) { diff --git a/apps/trading/pages/portfolio/index.page.tsx b/apps/trading/pages/portfolio/index.page.tsx index a9de28a0b..53735d230 100644 --- a/apps/trading/pages/portfolio/index.page.tsx +++ b/apps/trading/pages/portfolio/index.page.tsx @@ -30,12 +30,7 @@ const Portfolio = () => { -
-

{t('Positions')}

-
- -
-
+
diff --git a/apps/trading/project.json b/apps/trading/project.json index 4c32f33a9..d4005c7b4 100644 --- a/apps/trading/project.json +++ b/apps/trading/project.json @@ -60,6 +60,13 @@ "nx build trading" ] } + }, + "build-spec": { + "executor": "@nrwl/workspace:run-commands", + "outputs": [], + "options": { + "command": "yarn tsc --project ./apps/trading/tsconfig.spec.json" + } } }, "tags": [] diff --git a/apps/trading/tsconfig.spec.json b/apps/trading/tsconfig.spec.json index 8c8d4a70d..70edbccf0 100644 --- a/apps/trading/tsconfig.spec.json +++ b/apps/trading/tsconfig.spec.json @@ -1,10 +1,10 @@ { "extends": "./tsconfig.json", "compilerOptions": { + "jsx": "react-jsx", "outDir": "../../dist/out-tsc", "module": "commonjs", - "types": ["jest", "node", "@testing-library/jest-dom"], - "jsx": "react" + "types": ["jest", "node", "@testing-library/jest-dom"] }, "include": [ "**/*.test.ts", diff --git a/libs/accounts/project.json b/libs/accounts/project.json index 67e4fbe40..6c3cb8730 100644 --- a/libs/accounts/project.json +++ b/libs/accounts/project.json @@ -69,6 +69,13 @@ "quiet": true } } + }, + "build-spec": { + "executor": "@nrwl/workspace:run-commands", + "outputs": [], + "options": { + "command": "yarn tsc --project ./libs/accounts/tsconfig.spec.json" + } } } } diff --git a/libs/accounts/src/lib/Accounts.graphql b/libs/accounts/src/lib/Accounts.graphql index 1d91d95d2..226bf6ef2 100644 --- a/libs/accounts/src/lib/Accounts.graphql +++ b/libs/accounts/src/lib/Accounts.graphql @@ -1,4 +1,4 @@ -fragment AccountFields on Account { +fragment AccountFields on AccountBalance { type balance market { diff --git a/libs/accounts/src/lib/__generated___/Accounts.ts b/libs/accounts/src/lib/__generated___/Accounts.ts index 5a80482fd..0c2a90acc 100644 --- a/libs/accounts/src/lib/__generated___/Accounts.ts +++ b/libs/accounts/src/lib/__generated___/Accounts.ts @@ -3,14 +3,14 @@ import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; const defaultOptions = {} as const; -export type AccountFieldsFragment = { __typename?: 'Account', type: Types.AccountType, balance: string, market?: { __typename?: 'Market', id: string } | null, asset: { __typename?: 'Asset', id: string } }; +export type AccountFieldsFragment = { __typename?: 'AccountBalance', type: Types.AccountType, balance: string, market?: { __typename?: 'Market', id: string } | null, asset: { __typename?: 'Asset', id: string } }; export type AccountsQueryVariables = Types.Exact<{ partyId: Types.Scalars['ID']; }>; -export type AccountsQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, accounts?: Array<{ __typename?: 'Account', type: Types.AccountType, balance: string, market?: { __typename?: 'Market', id: string } | null, asset: { __typename?: 'Asset', id: string } }> | null } | null }; +export type AccountsQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, accounts?: Array<{ __typename?: 'AccountBalance', type: Types.AccountType, balance: string, market?: { __typename?: 'Market', id: string } | null, asset: { __typename?: 'Asset', id: string } }> | null } | null }; export type AccountEventsSubscriptionVariables = Types.Exact<{ partyId: Types.Scalars['ID']; @@ -20,7 +20,7 @@ export type AccountEventsSubscriptionVariables = Types.Exact<{ 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 { + fragment AccountFields on AccountBalance { type balance market { diff --git a/libs/accounts/src/lib/accounts-data-provider.spec.ts b/libs/accounts/src/lib/accounts-data-provider.spec.ts index 01dfec14d..417aa64ea 100644 --- a/libs/accounts/src/lib/accounts-data-provider.spec.ts +++ b/libs/accounts/src/lib/accounts-data-provider.spec.ts @@ -46,7 +46,7 @@ describe('getId', () => { const accounts = [ { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_MARGIN, balance: '2781397', market: { @@ -68,7 +68,7 @@ const accounts = [ }, }, { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_MARGIN, balance: '406922', market: { @@ -90,7 +90,7 @@ const accounts = [ }, }, { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_GENERAL, balance: '10001000000', market: null, @@ -102,7 +102,7 @@ const accounts = [ }, }, { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_GENERAL, balance: '1990351587', market: null, @@ -114,7 +114,7 @@ const accounts = [ }, }, { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_GENERAL, balance: '2996218603', market: null, @@ -126,7 +126,7 @@ const accounts = [ }, }, { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_GENERAL, balance: '5000593078', market: null, @@ -138,7 +138,7 @@ const accounts = [ }, }, { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_GENERAL, balance: '4000000000000001006031', market: null, @@ -177,7 +177,7 @@ const accountResult = [ balance: '5000593078', breakdown: [ { - __typename: 'Account', + __typename: 'AccountBalance', asset: { __typename: 'Asset', decimals: 5, @@ -217,7 +217,7 @@ const accountResult = [ balance: '2996218603', breakdown: [ { - __typename: 'Account', + __typename: 'AccountBalance', asset: { __typename: 'Asset', decimals: 5, diff --git a/libs/accounts/src/lib/accounts-data-provider.ts b/libs/accounts/src/lib/accounts-data-provider.ts index e6ff801fa..ab3fbf7f9 100644 --- a/libs/accounts/src/lib/accounts-data-provider.ts +++ b/libs/accounts/src/lib/accounts-data-provider.ts @@ -27,7 +27,7 @@ function isAccount( | IterableElement ): account is AccountFieldsFragment { return ( - (account as AccountFieldsFragment).__typename === 'Account' || + (account as AccountFieldsFragment).__typename === 'AccountBalance' || Boolean((account as AccountFieldsFragment).asset?.id) ); } @@ -58,7 +58,7 @@ const update = ( draft[index].balance = delta.balance; } else { draft.unshift({ - __typename: 'Account', + __typename: 'AccountBalance', type: delta.type, balance: delta.balance, market: delta.marketId ? { id: delta.marketId } : null, diff --git a/libs/accounts/src/lib/accounts-table.spec.tsx b/libs/accounts/src/lib/accounts-table.spec.tsx index e12690bfe..c55070156 100644 --- a/libs/accounts/src/lib/accounts-table.spec.tsx +++ b/libs/accounts/src/lib/accounts-table.spec.tsx @@ -5,7 +5,7 @@ import { getAccountData } from './accounts-data-provider'; import { AccountTable } from './accounts-table'; const singleRow = { - __typename: 'Account', + __typename: 'AccountBalance', type: Types.AccountType.ACCOUNT_TYPE_MARGIN, balance: '125600000', market: { @@ -80,7 +80,7 @@ it('should get correct account data', () => { balance: '0', breakdown: [ { - __typename: 'Account', + __typename: 'AccountBalance', asset: { __typename: 'Asset', decimals: 5, diff --git a/libs/accounts/src/lib/accounts-table.stories.tsx b/libs/accounts/src/lib/accounts-table.stories.tsx index 9c6d1c0ea..6de5dba18 100644 --- a/libs/accounts/src/lib/accounts-table.stories.tsx +++ b/libs/accounts/src/lib/accounts-table.stories.tsx @@ -16,7 +16,7 @@ export const Primary = Template.bind({}); Primary.args = { data: getAccountData([ { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_MARGIN, balance: '2781397', market: { @@ -38,7 +38,7 @@ Primary.args = { }, }, { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_MARGIN, balance: '406922', market: { @@ -60,7 +60,7 @@ Primary.args = { }, }, { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_GENERAL, balance: '10001000000', market: null, @@ -72,7 +72,7 @@ Primary.args = { }, }, { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_GENERAL, balance: '1990351587', market: null, @@ -84,7 +84,7 @@ Primary.args = { }, }, { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_GENERAL, balance: '2996218603', market: null, @@ -96,7 +96,7 @@ Primary.args = { }, }, { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_GENERAL, balance: '5000593078', market: null, @@ -108,7 +108,7 @@ Primary.args = { }, }, { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_GENERAL, balance: '4000000000000001006031', market: null, diff --git a/libs/accounts/src/lib/breakdown-table.spec.tsx b/libs/accounts/src/lib/breakdown-table.spec.tsx index 59d1016f2..169188212 100644 --- a/libs/accounts/src/lib/breakdown-table.spec.tsx +++ b/libs/accounts/src/lib/breakdown-table.spec.tsx @@ -5,7 +5,7 @@ import type { AccountFields } from './accounts-data-provider'; import { getAccountData } from './accounts-data-provider'; const singleRow = { - __typename: 'Account', + __typename: 'AccountBalance', type: Types.AccountType.ACCOUNT_TYPE_MARGIN, balance: '125600000', market: { @@ -74,7 +74,7 @@ describe('BreakdownTable', () => { balance: '0', breakdown: [ { - __typename: 'Account', + __typename: 'AccountBalance', asset: { __typename: 'Asset', decimals: 5, diff --git a/libs/assets/project.json b/libs/assets/project.json index 6d659728b..033bfa958 100644 --- a/libs/assets/project.json +++ b/libs/assets/project.json @@ -38,6 +38,13 @@ "jestConfig": "libs/assets/jest.config.ts", "passWithNoTests": true } + }, + "build-spec": { + "executor": "@nrwl/workspace:run-commands", + "outputs": [], + "options": { + "command": "yarn tsc --project ./libs/assets/tsconfig.spec.json" + } } } } diff --git a/libs/assets/src/lib/__generated___/Asset.ts b/libs/assets/src/lib/__generated___/Asset.ts index f0443317e..4d32929e0 100644 --- a/libs/assets/src/lib/__generated___/Asset.ts +++ b/libs/assets/src/lib/__generated___/Asset.ts @@ -3,14 +3,14 @@ import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; const defaultOptions = {} as const; -export type AssetFieldsFragment = { __typename?: 'Asset', id: string, name: string, symbol: string, decimals: number, quantum: string, status: Types.AssetStatus, source: { __typename: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename: 'ERC20', contractAddress: string, lifetimeLimit: string, withdrawThreshold: string }, infrastructureFeeAccount: { __typename?: 'Account', balance: string }, globalRewardPoolAccount?: { __typename?: 'Account', balance: string } | null, takerFeeRewardAccount?: { __typename?: 'Account', balance: string } | null, makerFeeRewardAccount?: { __typename?: 'Account', balance: string } | null, lpFeeRewardAccount?: { __typename?: 'Account', balance: string } | null, marketProposerRewardAccount?: { __typename?: 'Account', balance: string } | null }; +export type AssetFieldsFragment = { __typename?: 'Asset', id: string, name: string, symbol: string, decimals: number, quantum: string, status: Types.AssetStatus, source: { __typename: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename: 'ERC20', contractAddress: string, lifetimeLimit: string, withdrawThreshold: string }, infrastructureFeeAccount?: { __typename?: 'AccountBalance', balance: string } | null, globalRewardPoolAccount?: { __typename?: 'AccountBalance', balance: string } | null, takerFeeRewardAccount?: { __typename?: 'AccountBalance', balance: string } | null, makerFeeRewardAccount?: { __typename?: 'AccountBalance', balance: string } | null, lpFeeRewardAccount?: { __typename?: 'AccountBalance', balance: string } | null, marketProposerRewardAccount?: { __typename?: 'AccountBalance', balance: string } | null }; export type AssetQueryVariables = Types.Exact<{ assetId: Types.Scalars['ID']; }>; -export type AssetQuery = { __typename?: 'Query', assetsConnection?: { __typename?: 'AssetsConnection', edges?: Array<{ __typename?: 'AssetEdge', node: { __typename?: 'Asset', id: string, name: string, symbol: string, decimals: number, quantum: string, status: Types.AssetStatus, source: { __typename: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename: 'ERC20', contractAddress: string, lifetimeLimit: string, withdrawThreshold: string }, infrastructureFeeAccount: { __typename?: 'Account', balance: string }, globalRewardPoolAccount?: { __typename?: 'Account', balance: string } | null, takerFeeRewardAccount?: { __typename?: 'Account', balance: string } | null, makerFeeRewardAccount?: { __typename?: 'Account', balance: string } | null, lpFeeRewardAccount?: { __typename?: 'Account', balance: string } | null, marketProposerRewardAccount?: { __typename?: 'Account', balance: string } | null } } | null> | null } | null }; +export type AssetQuery = { __typename?: 'Query', assetsConnection?: { __typename?: 'AssetsConnection', edges?: Array<{ __typename?: 'AssetEdge', node: { __typename?: 'Asset', id: string, name: string, symbol: string, decimals: number, quantum: string, status: Types.AssetStatus, source: { __typename: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename: 'ERC20', contractAddress: string, lifetimeLimit: string, withdrawThreshold: string }, infrastructureFeeAccount?: { __typename?: 'AccountBalance', balance: string } | null, globalRewardPoolAccount?: { __typename?: 'AccountBalance', balance: string } | null, takerFeeRewardAccount?: { __typename?: 'AccountBalance', balance: string } | null, makerFeeRewardAccount?: { __typename?: 'AccountBalance', balance: string } | null, lpFeeRewardAccount?: { __typename?: 'AccountBalance', balance: string } | null, marketProposerRewardAccount?: { __typename?: 'AccountBalance', balance: string } | null } } | null> | null } | null }; export const AssetFieldsFragmentDoc = gql` fragment AssetFields on Asset { diff --git a/libs/assets/src/lib/__generated___/Assets.ts b/libs/assets/src/lib/__generated___/Assets.ts index ba9ffb87c..6c9b0afa8 100644 --- a/libs/assets/src/lib/__generated___/Assets.ts +++ b/libs/assets/src/lib/__generated___/Assets.ts @@ -7,7 +7,7 @@ const defaultOptions = {} as const; export type AssetsQueryVariables = Types.Exact<{ [key: string]: never; }>; -export type AssetsQuery = { __typename?: 'Query', assetsConnection?: { __typename?: 'AssetsConnection', edges?: Array<{ __typename?: 'AssetEdge', node: { __typename?: 'Asset', id: string, name: string, symbol: string, decimals: number, quantum: string, status: Types.AssetStatus, source: { __typename: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename: 'ERC20', contractAddress: string, lifetimeLimit: string, withdrawThreshold: string }, infrastructureFeeAccount: { __typename?: 'Account', balance: string }, globalRewardPoolAccount?: { __typename?: 'Account', balance: string } | null, takerFeeRewardAccount?: { __typename?: 'Account', balance: string } | null, makerFeeRewardAccount?: { __typename?: 'Account', balance: string } | null, lpFeeRewardAccount?: { __typename?: 'Account', balance: string } | null, marketProposerRewardAccount?: { __typename?: 'Account', balance: string } | null } } | null> | null } | null }; +export type AssetsQuery = { __typename?: 'Query', assetsConnection?: { __typename?: 'AssetsConnection', edges?: Array<{ __typename?: 'AssetEdge', node: { __typename?: 'Asset', id: string, name: string, symbol: string, decimals: number, quantum: string, status: Types.AssetStatus, source: { __typename: 'BuiltinAsset', maxFaucetAmountMint: string } | { __typename: 'ERC20', contractAddress: string, lifetimeLimit: string, withdrawThreshold: string }, infrastructureFeeAccount?: { __typename?: 'AccountBalance', balance: string } | null, globalRewardPoolAccount?: { __typename?: 'AccountBalance', balance: string } | null, takerFeeRewardAccount?: { __typename?: 'AccountBalance', balance: string } | null, makerFeeRewardAccount?: { __typename?: 'AccountBalance', balance: string } | null, lpFeeRewardAccount?: { __typename?: 'AccountBalance', balance: string } | null, marketProposerRewardAccount?: { __typename?: 'AccountBalance', balance: string } | null } } | null> | null } | null }; export const AssetsDocument = gql` diff --git a/libs/assets/src/lib/asset-details-table.tsx b/libs/assets/src/lib/asset-details-table.tsx index 96382074a..e12fa31a7 100644 --- a/libs/assets/src/lib/asset-details-table.tsx +++ b/libs/assets/src/lib/asset-details-table.tsx @@ -129,7 +129,7 @@ export const rows: Rows = [ key: AssetDetail.INFRASTRUCTURE_FEE_ACCOUNT_BALANCE, label: t('Infrastructure fee account balance'), tooltip: t('The infrastructure fee account in this asset'), - value: (asset) => num(asset, asset.infrastructureFeeAccount.balance), + value: (asset) => num(asset, asset.infrastructureFeeAccount?.balance), }, { key: AssetDetail.GLOBAL_REWARD_POOL_ACCOUNT_BALANCE, diff --git a/libs/assets/src/lib/test-helpers.ts b/libs/assets/src/lib/test-helpers.ts index 7f08b80b4..570611e4f 100644 --- a/libs/assets/src/lib/test-helpers.ts +++ b/libs/assets/src/lib/test-helpers.ts @@ -16,27 +16,27 @@ export const generateERC20Asset = (i: number, status: AssetStatus): Asset => ({ status: status, infrastructureFeeAccount: { balance: '1', - __typename: 'Account', + __typename: 'AccountBalance', }, globalRewardPoolAccount: { balance: '2', - __typename: 'Account', + __typename: 'AccountBalance', }, takerFeeRewardAccount: { balance: '3', - __typename: 'Account', + __typename: 'AccountBalance', }, makerFeeRewardAccount: { balance: '4', - __typename: 'Account', + __typename: 'AccountBalance', }, lpFeeRewardAccount: { balance: '5', - __typename: 'Account', + __typename: 'AccountBalance', }, marketProposerRewardAccount: { balance: '6', - __typename: 'Account', + __typename: 'AccountBalance', }, __typename: 'Asset', }); @@ -57,7 +57,7 @@ export const generateBuiltinAsset = ( status: status, infrastructureFeeAccount: { balance: '0', - __typename: 'Account', + __typename: 'AccountBalance', }, globalRewardPoolAccount: null, takerFeeRewardAccount: null, diff --git a/libs/candles-chart/project.json b/libs/candles-chart/project.json index b8f78f06d..1b35ba53a 100644 --- a/libs/candles-chart/project.json +++ b/libs/candles-chart/project.json @@ -38,6 +38,13 @@ "jestConfig": "libs/candles-chart/jest.config.ts", "passWithNoTests": true } + }, + "build-spec": { + "executor": "@nrwl/workspace:run-commands", + "outputs": [], + "options": { + "command": "yarn tsc --project ./libs/candles-chart/tsconfig.spec.json" + } } } } diff --git a/libs/cypress/project.json b/libs/cypress/project.json index f93119c56..a02c0f5ff 100644 --- a/libs/cypress/project.json +++ b/libs/cypress/project.json @@ -17,6 +17,13 @@ "jestConfig": "libs/cypress/jest.config.ts", "passWithNoTests": true } + }, + "build-spec": { + "executor": "@nrwl/workspace:run-commands", + "outputs": [], + "options": { + "command": "yarn tsc --project ./libs/cypress/tsconfig.spec.json" + } } }, "tags": [] diff --git a/libs/deal-ticket/project.json b/libs/deal-ticket/project.json index 52fb9137f..f9be92714 100644 --- a/libs/deal-ticket/project.json +++ b/libs/deal-ticket/project.json @@ -38,6 +38,13 @@ "jestConfig": "libs/deal-ticket/jest.config.ts", "passWithNoTests": true } + }, + "build-spec": { + "executor": "@nrwl/workspace:run-commands", + "outputs": [], + "options": { + "command": "yarn tsc --project ./libs/deal-ticket/tsconfig.spec.json" + } } } } diff --git a/libs/deal-ticket/src/components/deal-ticket-validation/get-default-order.ts b/libs/deal-ticket/src/components/deal-ticket-validation/get-default-order.ts index df3c15069..57171f149 100644 --- a/libs/deal-ticket/src/components/deal-ticket-validation/get-default-order.ts +++ b/libs/deal-ticket/src/components/deal-ticket-validation/get-default-order.ts @@ -1,24 +1,24 @@ import { toDecimal } from '@vegaprotocol/react-helpers'; import type { OrderSubmissionBody } from '@vegaprotocol/wallet'; -import { OrderTimeInForce, OrderType, Side } from '@vegaprotocol/types'; +import { Schema } from '@vegaprotocol/types'; export const getDefaultOrder = (market: { id: string; positionDecimalPlaces: number; }): OrderSubmissionBody['orderSubmission'] => ({ marketId: market.id, - type: OrderType.TYPE_MARKET, - side: Side.SIDE_BUY, - timeInForce: OrderTimeInForce.TIME_IN_FORCE_IOC, + type: Schema.OrderType.TYPE_MARKET, + side: Schema.Side.SIDE_BUY, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_IOC, size: String(toDecimal(market.positionDecimalPlaces)), }); export interface Order { marketId: string; - type: OrderType; + type: Schema.OrderType; size: string; - side: Side; - timeInForce: OrderTimeInForce; + side: Schema.Side; + timeInForce: Schema.OrderTimeInForce; price?: string; expiresAt?: Date; } diff --git a/libs/deal-ticket/src/components/deal-ticket-validation/use-order-validation.spec.tsx b/libs/deal-ticket/src/components/deal-ticket-validation/use-order-validation.spec.tsx index 775daee7d..e7b5efb08 100644 --- a/libs/deal-ticket/src/components/deal-ticket-validation/use-order-validation.spec.tsx +++ b/libs/deal-ticket/src/components/deal-ticket-validation/use-order-validation.spec.tsx @@ -5,8 +5,7 @@ import { MarketState, MarketStateMapping, MarketTradingMode, - OrderTimeInForce, - OrderType, + Schema, } from '@vegaprotocol/types'; import type { ValidationProps } from './use-order-validation'; import { marketTranslations } from './use-order-validation'; @@ -48,6 +47,15 @@ const market: DealTicketMarketFragment = { price: '100', }, }, + fees: { + __typename: 'Fees', + factors: { + __typename: 'FeeFactors', + makerFee: '1', + infrastructureFee: '2', + liquidityFee: '3', + }, + }, }; const defaultWalletContext = { @@ -63,8 +71,8 @@ const defaultWalletContext = { const defaultOrder = { market, step: 0.1, - orderType: OrderType.TYPE_MARKET, - orderTimeInForce: OrderTimeInForce.TIME_IN_FORCE_FOK, + orderType: Schema.OrderType.TYPE_MARKET, + orderTimeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_FOK, }; const ERROR = { @@ -158,7 +166,7 @@ describe('useOrderValidation', () => { ({ tradingMode, errorMessage }) => { const { result } = setup({ market: { ...defaultOrder.market, tradingMode }, - orderType: OrderType.TYPE_MARKET, + orderType: Schema.OrderType.TYPE_MARKET, }); expect(result.current.isDisabled).toBeTruthy(); expect(result.current.message).toBe(errorMessage); @@ -166,22 +174,22 @@ describe('useOrderValidation', () => { ); it.each` - tradingMode | orderTimeInForce | errorMessage - ${MarketTradingMode.TRADING_MODE_BATCH_AUCTION} | ${OrderTimeInForce.TIME_IN_FORCE_FOK} | ${ERROR.MARKET_CONTINUOUS_TIF} - ${MarketTradingMode.TRADING_MODE_MONITORING_AUCTION} | ${OrderTimeInForce.TIME_IN_FORCE_FOK} | ${ERROR.MARKET_CONTINUOUS_TIF} - ${MarketTradingMode.TRADING_MODE_OPENING_AUCTION} | ${OrderTimeInForce.TIME_IN_FORCE_FOK} | ${ERROR.MARKET_CONTINUOUS_TIF} - ${MarketTradingMode.TRADING_MODE_BATCH_AUCTION} | ${OrderTimeInForce.TIME_IN_FORCE_IOC} | ${ERROR.MARKET_CONTINUOUS_TIF} - ${MarketTradingMode.TRADING_MODE_MONITORING_AUCTION} | ${OrderTimeInForce.TIME_IN_FORCE_IOC} | ${ERROR.MARKET_CONTINUOUS_TIF} - ${MarketTradingMode.TRADING_MODE_OPENING_AUCTION} | ${OrderTimeInForce.TIME_IN_FORCE_IOC} | ${ERROR.MARKET_CONTINUOUS_TIF} - ${MarketTradingMode.TRADING_MODE_BATCH_AUCTION} | ${OrderTimeInForce.TIME_IN_FORCE_GFN} | ${ERROR.MARKET_CONTINUOUS_TIF} - ${MarketTradingMode.TRADING_MODE_MONITORING_AUCTION} | ${OrderTimeInForce.TIME_IN_FORCE_GFN} | ${ERROR.MARKET_CONTINUOUS_TIF} - ${MarketTradingMode.TRADING_MODE_OPENING_AUCTION} | ${OrderTimeInForce.TIME_IN_FORCE_GFN} | ${ERROR.MARKET_CONTINUOUS_TIF} + tradingMode | orderTimeInForce | errorMessage + ${MarketTradingMode.TRADING_MODE_BATCH_AUCTION} | ${Schema.OrderTimeInForce.TIME_IN_FORCE_FOK} | ${ERROR.MARKET_CONTINUOUS_TIF} + ${MarketTradingMode.TRADING_MODE_MONITORING_AUCTION} | ${Schema.OrderTimeInForce.TIME_IN_FORCE_FOK} | ${ERROR.MARKET_CONTINUOUS_TIF} + ${MarketTradingMode.TRADING_MODE_OPENING_AUCTION} | ${Schema.OrderTimeInForce.TIME_IN_FORCE_FOK} | ${ERROR.MARKET_CONTINUOUS_TIF} + ${MarketTradingMode.TRADING_MODE_BATCH_AUCTION} | ${Schema.OrderTimeInForce.TIME_IN_FORCE_IOC} | ${ERROR.MARKET_CONTINUOUS_TIF} + ${MarketTradingMode.TRADING_MODE_MONITORING_AUCTION} | ${Schema.OrderTimeInForce.TIME_IN_FORCE_IOC} | ${ERROR.MARKET_CONTINUOUS_TIF} + ${MarketTradingMode.TRADING_MODE_OPENING_AUCTION} | ${Schema.OrderTimeInForce.TIME_IN_FORCE_IOC} | ${ERROR.MARKET_CONTINUOUS_TIF} + ${MarketTradingMode.TRADING_MODE_BATCH_AUCTION} | ${Schema.OrderTimeInForce.TIME_IN_FORCE_GFN} | ${ERROR.MARKET_CONTINUOUS_TIF} + ${MarketTradingMode.TRADING_MODE_MONITORING_AUCTION} | ${Schema.OrderTimeInForce.TIME_IN_FORCE_GFN} | ${ERROR.MARKET_CONTINUOUS_TIF} + ${MarketTradingMode.TRADING_MODE_OPENING_AUCTION} | ${Schema.OrderTimeInForce.TIME_IN_FORCE_GFN} | ${ERROR.MARKET_CONTINUOUS_TIF} `( `Returns an error message when submitting a limit order with a "$orderTimeInForce" value to a "$tradingMode" market`, ({ tradingMode, orderTimeInForce, errorMessage }) => { const { result } = setup({ market: { ...defaultOrder.market, tradingMode }, - orderType: OrderType.TYPE_LIMIT, + orderType: Schema.OrderType.TYPE_LIMIT, orderTimeInForce, }); expect(result.current).toStrictEqual({ @@ -202,7 +210,7 @@ describe('useOrderValidation', () => { ({ fieldName, errorType, errorMessage }) => { const { result } = setup({ fieldErrors: { [fieldName]: { type: errorType } }, - orderType: OrderType.TYPE_LIMIT, + orderType: Schema.OrderType.TYPE_LIMIT, }); expect(result.current).toStrictEqual({ isDisabled: true, diff --git a/libs/deal-ticket/src/components/deal-ticket-validation/use-order-validation.tsx b/libs/deal-ticket/src/components/deal-ticket-validation/use-order-validation.tsx index 66933303b..a84e2fbec 100644 --- a/libs/deal-ticket/src/components/deal-ticket-validation/use-order-validation.tsx +++ b/libs/deal-ticket/src/components/deal-ticket-validation/use-order-validation.tsx @@ -7,8 +7,7 @@ import { MarketState, MarketStateMapping, MarketTradingMode, - OrderTimeInForce, - OrderType, + Schema, } from '@vegaprotocol/types'; import type { OrderSubmissionBody } from '@vegaprotocol/wallet'; import { Tooltip } from '@vegaprotocol/ui-toolkit'; @@ -28,8 +27,8 @@ export const isMarketInAuction = (market: DealTicketMarketFragment) => { export type ValidationProps = { step?: number; market: DealTicketMarketFragment; - orderType: OrderType; - orderTimeInForce: OrderTimeInForce; + orderType: Schema.OrderType; + orderTimeInForce: Schema.OrderTimeInForce; fieldErrors?: FieldErrors; }; @@ -94,7 +93,7 @@ export const useOrderValidation = ({ } if (isMarketInAuction(market)) { - if (orderType === OrderType.TYPE_MARKET) { + if (orderType === Schema.OrderType.TYPE_MARKET) { if ( market.tradingMode === MarketTradingMode.TRADING_MODE_MONITORING_AUCTION && @@ -149,11 +148,11 @@ export const useOrderValidation = ({ }; } if ( - orderType === OrderType.TYPE_LIMIT && + orderType === Schema.OrderType.TYPE_LIMIT && [ - OrderTimeInForce.TIME_IN_FORCE_FOK, - OrderTimeInForce.TIME_IN_FORCE_IOC, - OrderTimeInForce.TIME_IN_FORCE_GFN, + Schema.OrderTimeInForce.TIME_IN_FORCE_FOK, + Schema.OrderTimeInForce.TIME_IN_FORCE_IOC, + Schema.OrderTimeInForce.TIME_IN_FORCE_GFN, ].includes(orderTimeInForce) ) { if ( @@ -231,7 +230,7 @@ export const useOrderValidation = ({ if ( fieldErrors?.price?.type === 'required' && - orderType !== OrderType.TYPE_MARKET + orderType !== Schema.OrderType.TYPE_MARKET ) { return { isDisabled: true, @@ -241,7 +240,7 @@ export const useOrderValidation = ({ if ( fieldErrors?.price?.type === 'min' && - orderType !== OrderType.TYPE_MARKET + orderType !== Schema.OrderType.TYPE_MARKET ) { return { isDisabled: true, 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 fdcaafc89..66f78a3c8 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 type { DealTicketMarketFragment } from './__generated___/DealTicket'; import { ExpirySelector } from './expiry-selector'; import type { OrderSubmissionBody } from '@vegaprotocol/wallet'; import { useVegaWallet, useVegaWalletDialogStore } from '@vegaprotocol/wallet'; -import { OrderTimeInForce, OrderType } from '@vegaprotocol/types'; +import { Schema } from '@vegaprotocol/types'; import { getDefaultOrder } from '../deal-ticket-validation'; import { isMarketInAuction, @@ -69,7 +69,7 @@ export const DealTicket = ({ order.price && removeDecimal(order.price, market.decimalPlaces), size: removeDecimal(order.size, market.positionDecimalPlaces), expiresAt: - order.timeInForce === OrderTimeInForce.TIME_IN_FORCE_GTT + order.timeInForce === Schema.OrderTimeInForce.TIME_IN_FORCE_GTT ? order.expiresAt : undefined, }); @@ -96,7 +96,7 @@ export const DealTicket = ({ const marketPriceFormatted = marketPrice && addDecimal(marketPrice, market.decimalPlaces); useEffect(() => { - if (marketPriceFormatted && order.type === OrderType.TYPE_MARKET) { + if (marketPriceFormatted && order.type === Schema.OrderType.TYPE_MARKET) { setValue('price', marketPriceFormatted); } }, [marketPriceFormatted, order.type, setValue]); @@ -138,8 +138,8 @@ export const DealTicket = ({ /> )} /> - {order.type === OrderType.TYPE_LIMIT && - order.timeInForce === OrderTimeInForce.TIME_IN_FORCE_GTT && ( + {order.type === Schema.OrderType.TYPE_LIMIT && + order.timeInForce === Schema.OrderTimeInForce.TIME_IN_FORCE_GTT && ( ; -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 type MarketPositionsQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, accounts?: Array<{ __typename?: 'AccountBalance', 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` diff --git a/libs/deal-ticket/src/hooks/__generated__/PartyBalance.ts b/libs/deal-ticket/src/hooks/__generated__/PartyBalance.ts index 177179d13..8e86a504d 100644 --- a/libs/deal-ticket/src/hooks/__generated__/PartyBalance.ts +++ b/libs/deal-ticket/src/hooks/__generated__/PartyBalance.ts @@ -8,12 +8,12 @@ export type PartyBalanceQueryVariables = Types.Exact<{ }>; -export type PartyBalanceQuery = { __typename?: 'Query', party?: { __typename?: 'Party', accounts?: Array<{ __typename?: 'Account', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number } }> | null } | null }; +export type PartyBalanceQuery = { __typename?: 'Query', party?: { __typename?: 'Party', accounts?: Array<{ __typename?: 'AccountBalance', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number } }> | null } | null }; -export type AccountFragment = { __typename?: 'Account', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number } }; +export type AccountFragment = { __typename?: 'AccountBalance', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number } }; export const AccountFragmentDoc = gql` - fragment Account on Account { + fragment Account on AccountBalance { type balance asset { diff --git a/libs/deal-ticket/src/hooks/__generated__/PartyMarketData.ts b/libs/deal-ticket/src/hooks/__generated__/PartyMarketData.ts index f94fe797a..a0bef0671 100644 --- a/libs/deal-ticket/src/hooks/__generated__/PartyMarketData.ts +++ b/libs/deal-ticket/src/hooks/__generated__/PartyMarketData.ts @@ -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 } | null }; +export type PartyMarketDataQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, accounts?: Array<{ __typename?: 'AccountBalance', 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` diff --git a/libs/deal-ticket/src/hooks/use-calculate-slippage.spec.tsx b/libs/deal-ticket/src/hooks/use-calculate-slippage.spec.tsx index 3c453ff9f..6041320a4 100644 --- a/libs/deal-ticket/src/hooks/use-calculate-slippage.spec.tsx +++ b/libs/deal-ticket/src/hooks/use-calculate-slippage.spec.tsx @@ -1,6 +1,6 @@ import { MockedProvider } from '@apollo/client/testing'; import { renderHook } from '@testing-library/react'; -import { Side } from '@vegaprotocol/types'; +import { Schema } from '@vegaprotocol/types'; import type { OrderSubmissionBody } from '@vegaprotocol/wallet'; import { useCalculateSlippage } from './use-calculate-slippage'; @@ -82,7 +82,7 @@ describe('useCalculateSlippage Hook', () => { marketId: 'marketId', order: { size: '10', - side: Side.SIDE_BUY, + side: Schema.Side.SIDE_BUY, } as OrderSubmissionBody['orderSubmission'], }), { @@ -99,7 +99,7 @@ describe('useCalculateSlippage Hook', () => { marketId: 'marketId', order: { size: '10', - side: Side.SIDE_SELL, + side: Schema.Side.SIDE_SELL, } as OrderSubmissionBody['orderSubmission'], }), { @@ -125,7 +125,7 @@ describe('useCalculateSlippage Hook', () => { marketId: 'marketId', order: { size: '10', - side: Side.SIDE_SELL, + side: Schema.Side.SIDE_SELL, } as OrderSubmissionBody['orderSubmission'], }), { diff --git a/libs/deal-ticket/src/hooks/use-calculate-slippage.ts b/libs/deal-ticket/src/hooks/use-calculate-slippage.ts index a53fa5b0b..55d4f4e7c 100644 --- a/libs/deal-ticket/src/hooks/use-calculate-slippage.ts +++ b/libs/deal-ticket/src/hooks/use-calculate-slippage.ts @@ -1,6 +1,6 @@ import { useMemo } from 'react'; -import { Side } from '@vegaprotocol/types'; import { marketDepthProvider } from '@vegaprotocol/market-depth'; +import { Schema } from '@vegaprotocol/types'; import { marketProvider } from '@vegaprotocol/market-list'; import type { SingleMarketFieldsFragment } from '@vegaprotocol/market-list'; import type { OrderSubmissionBody } from '@vegaprotocol/wallet'; @@ -32,7 +32,7 @@ export const useCalculateSlippage = ({ marketId, order }: Props) => { variables, }); const volPriceArr = - data?.depth[order.side === Side.SIDE_BUY ? 'sell' : 'buy'] || []; + data?.depth[order.side === Schema.Side.SIDE_BUY ? 'sell' : 'buy'] || []; if (volPriceArr.length && market) { const decimals = market.decimalPlaces ?? 0; const positionDecimals = market.positionDecimalPlaces ?? 0; diff --git a/libs/deal-ticket/src/hooks/use-fee-deal-ticket-details.tsx b/libs/deal-ticket/src/hooks/use-fee-deal-ticket-details.tsx index e48f9cb5c..71f644451 100644 --- a/libs/deal-ticket/src/hooks/use-fee-deal-ticket-details.tsx +++ b/libs/deal-ticket/src/hooks/use-fee-deal-ticket-details.tsx @@ -1,6 +1,6 @@ import { FeesBreakdown } from '@vegaprotocol/market-info'; import { formatNumber, t } from '@vegaprotocol/react-helpers'; -import { Side } from '@vegaprotocol/types'; +import { Schema } from '@vegaprotocol/types'; import type { OrderSubmissionBody } from '@vegaprotocol/wallet'; import { useVegaWallet } from '@vegaprotocol/wallet'; import BigNumber from 'bignumber.js'; @@ -29,7 +29,7 @@ export const useFeeDealTicketDetails = ( const estPrice = order.price || market.depth.lastTrade?.price; if (estPrice) { if (slippage && parseFloat(slippage) !== 0) { - const isLong = order.side === Side.SIDE_BUY; + const isLong = order.side === Schema.Side.SIDE_BUY; const multiplier = new BigNumber(1)[isLong ? 'plus' : 'minus']( parseFloat(slippage) / 100 ); diff --git a/libs/deal-ticket/src/hooks/use-maximum-position-size.spec.ts b/libs/deal-ticket/src/hooks/use-maximum-position-size.spec.ts index 7570c0e5b..2003ed432 100644 --- a/libs/deal-ticket/src/hooks/use-maximum-position-size.spec.ts +++ b/libs/deal-ticket/src/hooks/use-maximum-position-size.spec.ts @@ -1,10 +1,5 @@ import { renderHook } from '@testing-library/react'; -import { - AccountType, - OrderTimeInForce, - OrderType, - Side, -} from '@vegaprotocol/types'; +import { AccountType, Schema } from '@vegaprotocol/types'; import type { PositionMargin } from './use-market-positions'; import { BigNumber } from 'bignumber.js'; import { useMaximumPositionSize } from './use-maximum-position-size'; @@ -19,7 +14,7 @@ const defaultMockMarketPositions = { let mockMarketPositions: PositionMargin | null = defaultMockMarketPositions; const mockAccount: Account = { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_GENERAL, balance: '200000', asset: { @@ -32,10 +27,10 @@ const mockAccount: Account = { }; const mockOrder: OrderSubmissionBody['orderSubmission'] = { - type: OrderType.TYPE_MARKET, + type: Schema.OrderType.TYPE_MARKET, size: '1', - side: Side.SIDE_BUY, - timeInForce: OrderTimeInForce.TIME_IN_FORCE_IOC, + side: Schema.Side.SIDE_BUY, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_IOC, marketId: 'market-id', }; @@ -92,7 +87,7 @@ describe('useMaximumPositionSize', () => { it('should return correct size when open positions and opposite side', () => { const price = '50'; - mockOrder.side = Side.SIDE_SELL; + mockOrder.side = Schema.Side.SIDE_SELL; mockMarketPositions = defaultMockMarketPositions; const expected = 4001; const { result } = renderHook(() => diff --git a/libs/deal-ticket/src/hooks/use-maximum-position-size.ts b/libs/deal-ticket/src/hooks/use-maximum-position-size.ts index 63cc5280d..52af5c84e 100644 --- a/libs/deal-ticket/src/hooks/use-maximum-position-size.ts +++ b/libs/deal-ticket/src/hooks/use-maximum-position-size.ts @@ -1,7 +1,7 @@ import { useMarketPositions } from './use-market-positions'; import type { OrderSubmissionBody } from '@vegaprotocol/wallet'; import { useSettlementAccount } from './use-settlement-account'; -import { AccountType, Side } from '@vegaprotocol/types'; +import { AccountType, Schema } from '@vegaprotocol/types'; import { BigNumber } from 'bignumber.js'; import type { AccountFragment as Account } from './__generated__/PartyBalance'; @@ -47,8 +47,10 @@ export const useMaximumPositionSize = ({ } const isSameSide = - (marketPositions.openVolume.isPositive() && order.side === Side.SIDE_BUY) || - (marketPositions.openVolume.isNegative() && order.side === Side.SIDE_SELL); + (marketPositions.openVolume.isPositive() && + order.side === Schema.Side.SIDE_BUY) || + (marketPositions.openVolume.isNegative() && + order.side === Schema.Side.SIDE_SELL); const adjustedForVolume = new BigNumber(size)[isSameSide ? 'minus' : 'plus']( marketPositions.openVolume diff --git a/libs/deal-ticket/src/hooks/use-order-closeout.ts b/libs/deal-ticket/src/hooks/use-order-closeout.ts index ceb290dba..33b43bea9 100644 --- a/libs/deal-ticket/src/hooks/use-order-closeout.ts +++ b/libs/deal-ticket/src/hooks/use-order-closeout.ts @@ -5,7 +5,7 @@ import { addDecimal, formatNumber } from '@vegaprotocol/react-helpers'; import { useMarketPositions } from './use-market-positions'; import { useMarketDataMarkPrice } from './use-market-data-mark-price'; import { usePartyMarketDataQuery } from './__generated__/PartyMarketData'; -import { Side } from '@vegaprotocol/types'; +import { Schema } from '@vegaprotocol/types'; import type { DealTicketMarketFragment } from '../components/deal-ticket/__generated___/DealTicket'; import type { PartyBalanceQuery } from './__generated__/PartyBalance'; import { useSettlementAccount } from './use-settlement-account'; @@ -63,7 +63,7 @@ export const useOrderCloseOut = ({ marketPositions?.openVolume.toString() || '0', market.positionDecimalPlaces ) - )[order.side === Side.SIDE_BUY ? 'plus' : 'minus'](order.size); + )[order.side === Schema.Side.SIDE_BUY ? 'plus' : 'minus'](order.size); const markPrice = new BigNumber( addDecimal( markPriceData?.market?.data?.markPrice || 0, diff --git a/libs/deal-ticket/src/hooks/use-order-margin.ts b/libs/deal-ticket/src/hooks/use-order-margin.ts index 248cd13fb..4bf3dc856 100644 --- a/libs/deal-ticket/src/hooks/use-order-margin.ts +++ b/libs/deal-ticket/src/hooks/use-order-margin.ts @@ -1,6 +1,6 @@ import { BigNumber } from 'bignumber.js'; import type { OrderSubmissionBody } from '@vegaprotocol/wallet'; -import { Side } from '@vegaprotocol/types'; +import { Schema } from '@vegaprotocol/types'; import { addDecimal, removeDecimal } from '@vegaprotocol/react-helpers'; import { useMarketPositions } from './use-market-positions'; import { useMarketDataMarkPrice } from './use-market-data-mark-price'; @@ -48,12 +48,15 @@ export const useOrderMargin = ({ BigNumber.maximum( 0, new BigNumber(marketPositions?.openVolume || 0) - [order.side === Side.SIDE_BUY ? 'plus' : 'minus'](order.size) + [order.side === Schema.Side.SIDE_BUY ? 'plus' : 'minus'](order.size) .absoluteValue() ).toString(), market.positionDecimalPlaces ), - side: order.side === Side.SIDE_BUY ? Side.SIDE_BUY : Side.SIDE_SELL, + side: + order.side === Schema.Side.SIDE_BUY + ? Schema.Side.SIDE_BUY + : Schema.Side.SIDE_SELL, timeInForce: order.timeInForce, type: order.type, }, diff --git a/libs/deal-ticket/src/hooks/use-settlement-account.spec.tsx b/libs/deal-ticket/src/hooks/use-settlement-account.spec.tsx index c602a786a..90670d73f 100644 --- a/libs/deal-ticket/src/hooks/use-settlement-account.spec.tsx +++ b/libs/deal-ticket/src/hooks/use-settlement-account.spec.tsx @@ -7,7 +7,7 @@ describe('useSettlementAccount Hook', () => { it('should filter accounts by settlementAssetId', () => { const accounts: Account[] = [ { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_GENERAL, balance: '2000000000000000000000', asset: { @@ -19,7 +19,7 @@ describe('useSettlementAccount Hook', () => { }, }, { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_GENERAL, balance: '1000000000', asset: { @@ -31,7 +31,7 @@ describe('useSettlementAccount Hook', () => { }, }, { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_GENERAL, balance: '5000000000000000000', asset: { @@ -43,7 +43,7 @@ describe('useSettlementAccount Hook', () => { }, }, { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_MARGIN, balance: '5000000000000000000', asset: { diff --git a/libs/deal-ticket/tsconfig.spec.json b/libs/deal-ticket/tsconfig.spec.json index 3da863401..17b59f94d 100644 --- a/libs/deal-ticket/tsconfig.spec.json +++ b/libs/deal-ticket/tsconfig.spec.json @@ -5,6 +5,7 @@ "module": "commonjs", "types": ["jest", "node", "@testing-library/jest-dom"] }, + "files": ["../../node_modules/@nrwl/react/typings/cssmodule.d.ts"], "include": [ "**/*.test.ts", "**/*.spec.ts", diff --git a/libs/deposits/project.json b/libs/deposits/project.json index e7cd58214..e6ee8e7e1 100644 --- a/libs/deposits/project.json +++ b/libs/deposits/project.json @@ -38,6 +38,13 @@ "jestConfig": "libs/deposits/jest.config.ts", "passWithNoTests": true } + }, + "build-spec": { + "executor": "@nrwl/workspace:run-commands", + "outputs": [], + "options": { + "command": "yarn tsc --project ./libs/deposits/tsconfig.spec.json" + } } } } diff --git a/libs/deposits/src/lib/__generated___/Deposit.ts b/libs/deposits/src/lib/__generated___/Deposit.ts index c41cc9773..b0f16377e 100644 --- a/libs/deposits/src/lib/__generated___/Deposit.ts +++ b/libs/deposits/src/lib/__generated___/Deposit.ts @@ -17,7 +17,7 @@ export type DepositEventSubscriptionVariables = Types.Exact<{ }>; -export type DepositEventSubscription = { __typename?: 'Subscription', busEvents?: Array<{ __typename?: 'BusEvent', event: { __typename?: 'Account' } | { __typename?: 'Asset' } | { __typename?: 'AuctionEvent' } | { __typename?: 'Deposit', id: string, status: Types.DepositStatus, amount: string, createdTimestamp: string, creditedTimestamp?: string | null, txHash?: string | null, asset: { __typename?: 'Asset', id: string, symbol: string, decimals: number } } | { __typename?: 'LiquidityProvision' } | { __typename?: 'LossSocialization' } | { __typename?: 'MarginLevels' } | { __typename?: 'Market' } | { __typename?: 'MarketData' } | { __typename?: 'MarketEvent' } | { __typename?: 'MarketTick' } | { __typename?: 'NodeSignature' } | { __typename?: 'OracleSpec' } | { __typename?: 'Order' } | { __typename?: 'Party' } | { __typename?: 'PositionResolution' } | { __typename?: 'Proposal' } | { __typename?: 'RiskFactor' } | { __typename?: 'SettleDistressed' } | { __typename?: 'SettlePosition' } | { __typename?: 'TimeUpdate' } | { __typename?: 'Trade' } | { __typename?: 'TransactionResult' } | { __typename?: 'TransferResponses' } | { __typename?: 'Vote' } | { __typename?: 'Withdrawal' } }> | null }; +export type DepositEventSubscription = { __typename?: 'Subscription', busEvents?: Array<{ __typename?: 'BusEvent', event: { __typename?: 'AccountEvent' } | { __typename?: 'Asset' } | { __typename?: 'AuctionEvent' } | { __typename?: 'Deposit', id: string, status: Types.DepositStatus, amount: string, createdTimestamp: string, creditedTimestamp?: string | null, txHash?: string | null, asset: { __typename?: 'Asset', id: string, symbol: string, decimals: number } } | { __typename?: 'LiquidityProvision' } | { __typename?: 'LossSocialization' } | { __typename?: 'MarginLevels' } | { __typename?: 'Market' } | { __typename?: 'MarketData' } | { __typename?: 'MarketEvent' } | { __typename?: 'MarketTick' } | { __typename?: 'NodeSignature' } | { __typename?: 'OracleSpec' } | { __typename?: 'Order' } | { __typename?: 'Party' } | { __typename?: 'PositionResolution' } | { __typename?: 'Proposal' } | { __typename?: 'RiskFactor' } | { __typename?: 'SettleDistressed' } | { __typename?: 'SettlePosition' } | { __typename?: 'TimeUpdate' } | { __typename?: 'Trade' } | { __typename?: 'TransactionResult' } | { __typename?: 'TransferResponses' } | { __typename?: 'Vote' } | { __typename?: 'Withdrawal' } }> | null }; export const DepositFieldsFragmentDoc = gql` fragment DepositFields on Deposit { diff --git a/libs/deposits/src/lib/deposit-form.spec.tsx b/libs/deposits/src/lib/deposit-form.spec.tsx index 29fa82f8e..8ddede7c3 100644 --- a/libs/deposits/src/lib/deposit-form.spec.tsx +++ b/libs/deposits/src/lib/deposit-form.spec.tsx @@ -2,28 +2,37 @@ import { waitFor, fireEvent, render, screen } from '@testing-library/react'; import BigNumber from 'bignumber.js'; import type { DepositFormProps } from './deposit-form'; import { DepositForm } from './deposit-form'; +import { AssetStatus } from '@vegaprotocol/types'; import { useVegaWallet } from '@vegaprotocol/wallet'; import { useWeb3React } from '@web3-react/core'; -import type { Asset } from '@vegaprotocol/react-helpers'; +import type { AssetFieldsFragment } from '@vegaprotocol/assets'; jest.mock('@vegaprotocol/wallet'); jest.mock('@web3-react/core'); -function generateAsset(): Asset { +function generateAsset(): AssetFieldsFragment { return { __typename: 'Asset', id: 'asset-id', symbol: 'asset-symbol', name: 'asset-name', decimals: 2, + quantum: '', + status: AssetStatus.STATUS_ENABLED, source: { __typename: 'ERC20', contractAddress: 'contract-address', + lifetimeLimit: '', + withdrawThreshold: '', + }, + infrastructureFeeAccount: { + balance: '1', + __typename: 'AccountBalance', }, }; } -let asset: Asset; +let asset: AssetFieldsFragment; let props: DepositFormProps; const MOCK_ETH_ADDRESS = '0x72c22822A19D20DE7e426fB84aa047399Ddd8853'; diff --git a/libs/environment/project.json b/libs/environment/project.json index 7afafdeed..cad579d29 100644 --- a/libs/environment/project.json +++ b/libs/environment/project.json @@ -38,6 +38,13 @@ "jestConfig": "libs/environment/jest.config.ts", "passWithNoTests": true } + }, + "build-spec": { + "executor": "@nrwl/workspace:run-commands", + "outputs": [], + "options": { + "command": "yarn tsc --project ./libs/environment/tsconfig.spec.json" + } } } } diff --git a/libs/environment/src/components/network-switcher/network-switcher.spec.tsx b/libs/environment/src/components/network-switcher/network-switcher.spec.tsx index b3cd01806..306e3f47d 100644 --- a/libs/environment/src/components/network-switcher/network-switcher.spec.tsx +++ b/libs/environment/src/components/network-switcher/network-switcher.spec.tsx @@ -138,6 +138,8 @@ describe('Network switcher', () => { [Networks.TESTNET]: 'https://test.net', [Networks.STAGNET3]: 'https://stag3.net', [Networks.DEVNET]: 'https://dev.net', + [Networks.STAGNET1]: 'https://stag1.net', + [Networks.SANDBOX]: 'https://sandbox.net', }; // @ts-ignore Typescript doesn't know about this module being mocked useEnvironment.mockImplementation(() => ({ @@ -175,6 +177,8 @@ describe('Network switcher', () => { [Networks.TESTNET]: 'https://test.net', [Networks.STAGNET3]: 'https://stag3.net', [Networks.DEVNET]: 'https://dev.net', + [Networks.STAGNET1]: 'https://stag1.net', + [Networks.SANDBOX]: 'https://sandbox.net', }; // @ts-ignore Typescript doesn't know about this module being mocked useEnvironment.mockImplementation(() => ({ @@ -205,6 +209,8 @@ describe('Network switcher', () => { [Networks.TESTNET]: 'https://test.net', [Networks.STAGNET3]: 'https://stag3.net', [Networks.DEVNET]: 'https://dev.net', + [Networks.STAGNET1]: 'https://stag1.net', + [Networks.SANDBOX]: 'https://sandbox.net', }; // @ts-ignore Typescript doesn't know about this module being mocked useEnvironment.mockImplementation(() => ({ diff --git a/libs/fills/project.json b/libs/fills/project.json index c3160d23b..3d629c5cc 100644 --- a/libs/fills/project.json +++ b/libs/fills/project.json @@ -69,6 +69,13 @@ "quiet": true } } + }, + "build-spec": { + "executor": "@nrwl/workspace:run-commands", + "outputs": [], + "options": { + "command": "yarn tsc --project ./libs/fills/tsconfig.spec.json" + } } } } diff --git a/libs/fills/src/lib/fills-table.spec.tsx b/libs/fills/src/lib/fills-table.spec.tsx index b05c4aab5..2c57ded42 100644 --- a/libs/fills/src/lib/fills-table.spec.tsx +++ b/libs/fills/src/lib/fills-table.spec.tsx @@ -1,6 +1,6 @@ import { act, render, screen, waitFor } from '@testing-library/react'; import { getDateTimeFormat } from '@vegaprotocol/react-helpers'; -import { Side } from '@vegaprotocol/types'; +import { Schema } from '@vegaprotocol/types'; import type { PartialDeep } from 'type-fest'; import type { Trade } from './fills-data-provider'; @@ -74,7 +74,7 @@ describe('FillsTable', () => { buyer: { id: partyId, }, - aggressor: Side.SIDE_SELL, + aggressor: Schema.Side.SIDE_SELL, buyerFee: { makerFee: '2', infrastructureFee: '2', @@ -111,7 +111,7 @@ describe('FillsTable', () => { seller: { id: partyId, }, - aggressor: Side.SIDE_SELL, + aggressor: Schema.Side.SIDE_SELL, sellerFee: { makerFee: '1', infrastructureFee: '1', @@ -147,7 +147,7 @@ describe('FillsTable', () => { seller: { id: partyId, }, - aggressor: Side.SIDE_SELL, + aggressor: Schema.Side.SIDE_SELL, }); const { rerender } = render( @@ -166,7 +166,7 @@ describe('FillsTable', () => { seller: { id: partyId, }, - aggressor: Side.SIDE_BUY, + aggressor: Schema.Side.SIDE_BUY, }); rerender(); diff --git a/libs/fills/src/lib/fills-table.tsx b/libs/fills/src/lib/fills-table.tsx index 788103bf6..00dbf2b10 100644 --- a/libs/fills/src/lib/fills-table.tsx +++ b/libs/fills/src/lib/fills-table.tsx @@ -9,7 +9,7 @@ import { t, isNumeric, } from '@vegaprotocol/react-helpers'; -import { Side } from '@vegaprotocol/types'; +import { Schema } from '@vegaprotocol/types'; import { AgGridColumn } from 'ag-grid-react'; import type { VegaValueFormatterParams } from '@vegaprotocol/ui-toolkit'; import { AgGridDynamic as AgGrid } from '@vegaprotocol/ui-toolkit'; @@ -165,13 +165,13 @@ const formatRole = (partyId: string) => { const taker = t('Taker'); const maker = t('Maker'); if (data?.buyer.id === partyId) { - if (value === Side.SIDE_BUY) { + if (value === Schema.Side.SIDE_BUY) { return taker; } else { return maker; } } else if (data?.seller.id === partyId) { - if (value === Side.SIDE_SELL) { + if (value === Schema.Side.SIDE_SELL) { return taker; } else { return maker; diff --git a/libs/fills/src/lib/test-helpers.ts b/libs/fills/src/lib/test-helpers.ts index 376e920b3..31d952b83 100644 --- a/libs/fills/src/lib/test-helpers.ts +++ b/libs/fills/src/lib/test-helpers.ts @@ -1,6 +1,6 @@ import merge from 'lodash/merge'; import type { PartialDeep } from 'type-fest'; -import { MarketState, MarketTradingMode, Side } from '@vegaprotocol/types'; +import { MarketState, MarketTradingMode, Schema } from '@vegaprotocol/types'; import type { Trade } from './fills-data-provider'; export const generateFill = (override?: PartialDeep) => { @@ -12,7 +12,7 @@ export const generateFill = (override?: PartialDeep) => { size: '50000', buyOrder: 'buy-order', sellOrder: 'sell-order', - aggressor: Side.SIDE_BUY, + aggressor: Schema.Side.SIDE_BUY, buyer: { __typename: 'Party', id: 'buyer-id', diff --git a/libs/governance/project.json b/libs/governance/project.json index bd602dfbc..a403bc8d4 100644 --- a/libs/governance/project.json +++ b/libs/governance/project.json @@ -38,6 +38,13 @@ "jestConfig": "libs/governance/jest.config.ts", "passWithNoTests": true } + }, + "build-spec": { + "executor": "@nrwl/workspace:run-commands", + "outputs": [], + "options": { + "command": "yarn tsc --project ./libs/governance/tsconfig.spec.json" + } } } } diff --git a/libs/governance/src/lib/proposals-hooks/__generated__/Proposal.ts b/libs/governance/src/lib/proposals-hooks/__generated__/Proposal.ts index 0c2e42922..d0957bd92 100644 --- a/libs/governance/src/lib/proposals-hooks/__generated__/Proposal.ts +++ b/libs/governance/src/lib/proposals-hooks/__generated__/Proposal.ts @@ -10,7 +10,7 @@ export type ProposalEventSubscriptionVariables = Types.Exact<{ }>; -export type ProposalEventSubscription = { __typename?: 'Subscription', busEvents?: Array<{ __typename?: 'BusEvent', type: Types.BusEventType, event: { __typename?: 'Account' } | { __typename?: 'Asset' } | { __typename?: 'AuctionEvent' } | { __typename?: 'Deposit' } | { __typename?: 'LiquidityProvision' } | { __typename?: 'LossSocialization' } | { __typename?: 'MarginLevels' } | { __typename?: 'Market' } | { __typename?: 'MarketData' } | { __typename?: 'MarketEvent' } | { __typename?: 'MarketTick' } | { __typename?: 'NodeSignature' } | { __typename?: 'OracleSpec' } | { __typename?: 'Order' } | { __typename?: 'Party' } | { __typename?: 'PositionResolution' } | { __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, rejectionReason?: Types.ProposalRejectionReason | null, errorDetails?: string | null } | { __typename?: 'RiskFactor' } | { __typename?: 'SettleDistressed' } | { __typename?: 'SettlePosition' } | { __typename?: 'TimeUpdate' } | { __typename?: 'Trade' } | { __typename?: 'TransactionResult' } | { __typename?: 'TransferResponses' } | { __typename?: 'Vote' } | { __typename?: 'Withdrawal' } }> | null }; +export type ProposalEventSubscription = { __typename?: 'Subscription', busEvents?: Array<{ __typename?: 'BusEvent', type: Types.BusEventType, event: { __typename?: 'AccountEvent' } | { __typename?: 'Asset' } | { __typename?: 'AuctionEvent' } | { __typename?: 'Deposit' } | { __typename?: 'LiquidityProvision' } | { __typename?: 'LossSocialization' } | { __typename?: 'MarginLevels' } | { __typename?: 'Market' } | { __typename?: 'MarketData' } | { __typename?: 'MarketEvent' } | { __typename?: 'MarketTick' } | { __typename?: 'NodeSignature' } | { __typename?: 'OracleSpec' } | { __typename?: 'Order' } | { __typename?: 'Party' } | { __typename?: 'PositionResolution' } | { __typename?: 'Proposal', id?: string | null, reference: string, state: Types.ProposalState, rejectionReason?: Types.ProposalRejectionReason | null, errorDetails?: string | null } | { __typename?: 'RiskFactor' } | { __typename?: 'SettleDistressed' } | { __typename?: 'SettlePosition' } | { __typename?: 'TimeUpdate' } | { __typename?: 'Trade' } | { __typename?: 'TransactionResult' } | { __typename?: 'TransferResponses' } | { __typename?: 'Vote' } | { __typename?: 'Withdrawal' } }> | null }; export const ProposalEventFieldsFragmentDoc = gql` fragment ProposalEventFields on Proposal { diff --git a/libs/liquidity/project.json b/libs/liquidity/project.json index f1b81c3c4..dd2ec595f 100644 --- a/libs/liquidity/project.json +++ b/libs/liquidity/project.json @@ -38,6 +38,13 @@ "jestConfig": "libs/liquidity/jest.config.js", "passWithNoTests": true } + }, + "build-spec": { + "executor": "@nrwl/workspace:run-commands", + "outputs": [], + "options": { + "command": "yarn tsc --project ./libs/liquidity/tsconfig.spec.json" + } } } } diff --git a/libs/liquidity/src/lib/__generated___/MarketLiquidity.ts b/libs/liquidity/src/lib/__generated___/MarketLiquidity.ts index 9c08e0623..8e38b12cc 100644 --- a/libs/liquidity/src/lib/__generated___/MarketLiquidity.ts +++ b/libs/liquidity/src/lib/__generated___/MarketLiquidity.ts @@ -10,14 +10,14 @@ export type MarketLpQueryVariables = Types.Exact<{ export type MarketLpQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', code: string, name: string, product: { __typename?: 'Future', settlementAsset: { __typename?: 'Asset', id: string, symbol: string, decimals: number } } } }, data?: { __typename?: 'MarketData', suppliedStake?: string | null, openInterest: string, targetStake?: string | null, marketValueProxy: string, market: { __typename?: 'Market', id: string } } | null } | null }; -export type LiquidityProvisionFieldsFragment = { __typename?: 'LiquidityProvision', createdAt: string, updatedAt?: string | null, commitmentAmount: string, fee: string, status: Types.LiquidityProvisionStatus, party: { __typename?: 'Party', id: string, accountsConnection?: { __typename?: 'AccountsConnection', edges?: Array<{ __typename?: 'AccountEdge', node: { __typename?: 'Account', type: Types.AccountType, balance: string } } | null> | null } | null } }; +export type LiquidityProvisionFieldsFragment = { __typename?: 'LiquidityProvision', createdAt: string, updatedAt?: string | null, commitmentAmount: string, fee: string, status: Types.LiquidityProvisionStatus, party: { __typename?: 'Party', id: string, accountsConnection?: { __typename?: 'AccountsConnection', edges?: Array<{ __typename?: 'AccountEdge', node: { __typename?: 'AccountBalance', type: Types.AccountType, balance: string } } | null> | null } | null } }; export type LiquidityProvisionsQueryVariables = Types.Exact<{ marketId: Types.Scalars['ID']; }>; -export type LiquidityProvisionsQuery = { __typename?: 'Query', market?: { __typename?: 'Market', liquidityProvisionsConnection?: { __typename?: 'LiquidityProvisionsConnection', edges?: Array<{ __typename?: 'LiquidityProvisionsEdge', node: { __typename?: 'LiquidityProvision', createdAt: string, updatedAt?: string | null, commitmentAmount: string, fee: string, status: Types.LiquidityProvisionStatus, party: { __typename?: 'Party', id: string, accountsConnection?: { __typename?: 'AccountsConnection', edges?: Array<{ __typename?: 'AccountEdge', node: { __typename?: 'Account', type: Types.AccountType, balance: string } } | null> | null } | null } } } | null> | null } | null } | null }; +export type LiquidityProvisionsQuery = { __typename?: 'Query', market?: { __typename?: 'Market', liquidityProvisionsConnection?: { __typename?: 'LiquidityProvisionsConnection', edges?: Array<{ __typename?: 'LiquidityProvisionsEdge', node: { __typename?: 'LiquidityProvision', createdAt: string, updatedAt?: string | null, commitmentAmount: string, fee: string, status: Types.LiquidityProvisionStatus, party: { __typename?: 'Party', id: string, accountsConnection?: { __typename?: 'AccountsConnection', edges?: Array<{ __typename?: 'AccountEdge', node: { __typename?: 'AccountBalance', type: Types.AccountType, balance: string } } | null> | null } | null } } } | null> | null } | null } | null }; export type LiquidityProvisionsUpdateSubscriptionVariables = Types.Exact<{ partyId?: Types.InputMaybe; diff --git a/libs/market-depth/project.json b/libs/market-depth/project.json index adb468ce6..e7aa615ab 100644 --- a/libs/market-depth/project.json +++ b/libs/market-depth/project.json @@ -69,6 +69,13 @@ "quiet": true } } + }, + "build-spec": { + "executor": "@nrwl/workspace:run-commands", + "outputs": [], + "options": { + "command": "yarn tsc --project ./libs/market-depth/tsconfig.spec.json" + } } } } diff --git a/libs/market-depth/src/lib/orderbook.spec.tsx b/libs/market-depth/src/lib/orderbook.spec.tsx index 8f4e45a6a..f047a4ce0 100644 --- a/libs/market-depth/src/lib/orderbook.spec.tsx +++ b/libs/market-depth/src/lib/orderbook.spec.tsx @@ -6,6 +6,7 @@ describe('Orderbook', () => { const params = { numberOfSellRows: 100, numberOfBuyRows: 100, + step: 1, midPrice: 122900, bestStaticBidPrice: 122905, bestStaticOfferPrice: 122895, diff --git a/libs/market-depth/src/lib/orderbook.stories.tsx b/libs/market-depth/src/lib/orderbook.stories.tsx index a7736b0fa..c3340ddb8 100644 --- a/libs/market-depth/src/lib/orderbook.stories.tsx +++ b/libs/market-depth/src/lib/orderbook.stories.tsx @@ -40,7 +40,6 @@ export const Continuous = Template.bind({}); Continuous.args = { numberOfSellRows: 100, numberOfBuyRows: 100, - midPrice: 1000, bestStaticBidPrice: 1000, bestStaticOfferPrice: 1000, decimalPlaces: 3, @@ -51,7 +50,6 @@ export const Auction = Template.bind({}); Auction.args = { numberOfSellRows: 100, numberOfBuyRows: 100, - midPrice: 122900, bestStaticBidPrice: 122905, bestStaticOfferPrice: 122895, decimalPlaces: 3, @@ -64,7 +62,6 @@ export const Empty = Template.bind({}); Empty.args = { numberOfSellRows: 0, numberOfBuyRows: 0, - midPrice: 0, bestStaticBidPrice: 0, bestStaticOfferPrice: 0, decimalPlaces: 3, diff --git a/libs/market-depth/tsconfig.spec.json b/libs/market-depth/tsconfig.spec.json index 3da863401..17b59f94d 100644 --- a/libs/market-depth/tsconfig.spec.json +++ b/libs/market-depth/tsconfig.spec.json @@ -5,6 +5,7 @@ "module": "commonjs", "types": ["jest", "node", "@testing-library/jest-dom"] }, + "files": ["../../node_modules/@nrwl/react/typings/cssmodule.d.ts"], "include": [ "**/*.test.ts", "**/*.spec.ts", diff --git a/libs/market-info/project.json b/libs/market-info/project.json index 8a0195e6f..3da329dc4 100644 --- a/libs/market-info/project.json +++ b/libs/market-info/project.json @@ -38,6 +38,13 @@ "jestConfig": "libs/market-info/jest.config.ts", "passWithNoTests": true } + }, + "build-spec": { + "executor": "@nrwl/workspace:run-commands", + "outputs": [], + "options": { + "command": "yarn tsc --project ./libs/market-info/tsconfig.spec.json" + } } } } diff --git a/libs/market-info/src/components/market-info/__generated___/MarketInfo.ts b/libs/market-info/src/components/market-info/__generated___/MarketInfo.ts index 97def6e71..f7adbe3eb 100644 --- a/libs/market-info/src/components/market-info/__generated___/MarketInfo.ts +++ b/libs/market-info/src/components/market-info/__generated___/MarketInfo.ts @@ -10,7 +10,7 @@ export type MarketInfoQueryVariables = Types.Exact<{ }>; -export type MarketInfoQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, proposal?: { __typename?: 'Proposal', id?: string | null, rationale: { __typename?: 'ProposalRationale', title: string, description: string } } | null, marketTimestamps: { __typename?: 'MarketTimestamps', open?: string | null, close?: string | null }, openingAuction: { __typename?: 'AuctionDuration', durationSecs: number, volume: number }, 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, bestBidVolume: string, bestOfferVolume: string, bestStaticBidVolume: string, bestStaticOfferVolume: string, bestBidPrice: string, bestOfferPrice: string, trigger: Types.AuctionTrigger, openInterest: string, suppliedStake?: string | null, targetStake?: string | null, marketValueProxy: string, 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 } }, candlesConnection?: { __typename?: 'CandleDataConnection', edges?: Array<{ __typename?: 'CandleEdge', node: { __typename?: 'Candle', volume: string } } | null> | 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, decimals: number }, oracleSpecForSettlementData: { __typename?: 'OracleSpec', id: string }, oracleSpecForTradingTermination: { __typename?: 'OracleSpec', id: string }, oracleSpecBinding: { __typename?: 'OracleSpecToFutureBinding', settlementDataProperty: 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 type MarketInfoQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, proposal?: { __typename?: 'Proposal', id?: string | null, rationale: { __typename?: 'ProposalRationale', title: string, description: string } } | null, marketTimestamps: { __typename?: 'MarketTimestamps', open?: string | null, close?: string | null }, openingAuction: { __typename?: 'AuctionDuration', durationSecs: number, volume: number }, accounts?: Array<{ __typename?: 'AccountBalance', 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, bestBidVolume: string, bestOfferVolume: string, bestStaticBidVolume: string, bestStaticOfferVolume: string, bestBidPrice: string, bestOfferPrice: string, trigger: Types.AuctionTrigger, openInterest: string, suppliedStake?: string | null, targetStake?: string | null, marketValueProxy: string, 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 } }, candlesConnection?: { __typename?: 'CandleDataConnection', edges?: Array<{ __typename?: 'CandleEdge', node: { __typename?: 'Candle', volume: string } } | null> | 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, decimals: number }, oracleSpecForSettlementData: { __typename?: 'OracleSpec', id: string }, oracleSpecForTradingTermination: { __typename?: 'OracleSpec', id: string }, oracleSpecBinding: { __typename?: 'OracleSpecToFutureBinding', settlementDataProperty: 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 MarketInfoDocument = gql` diff --git a/libs/market-list/project.json b/libs/market-list/project.json index 1e8233278..101d1bbdb 100644 --- a/libs/market-list/project.json +++ b/libs/market-list/project.json @@ -38,6 +38,13 @@ "jestConfig": "libs/market-list/jest.config.ts", "passWithNoTests": true } + }, + "build-spec": { + "executor": "@nrwl/workspace:run-commands", + "outputs": [], + "options": { + "command": "yarn tsc --project ./libs/market-list/tsconfig.spec.json" + } } } } diff --git a/libs/network-info/project.json b/libs/network-info/project.json index 25304d9b1..fa37e8432 100644 --- a/libs/network-info/project.json +++ b/libs/network-info/project.json @@ -38,6 +38,13 @@ "jestConfig": "libs/network-info/jest.config.ts", "passWithNoTests": true } + }, + "build-spec": { + "executor": "@nrwl/workspace:run-commands", + "outputs": [], + "options": { + "command": "yarn tsc --project ./libs/network-info/tsconfig.spec.json" + } } } } diff --git a/libs/network-stats/project.json b/libs/network-stats/project.json index 17c322c43..98d4ff003 100644 --- a/libs/network-stats/project.json +++ b/libs/network-stats/project.json @@ -38,6 +38,13 @@ "jestConfig": "libs/network-stats/jest.config.ts", "passWithNoTests": true } + }, + "build-spec": { + "executor": "@nrwl/workspace:run-commands", + "outputs": [], + "options": { + "command": "yarn tsc --project ./libs/network-stats/tsconfig.spec.json" + } } } } diff --git a/libs/network-stats/src/config/stats-fields.ts b/libs/network-stats/src/config/stats-fields.ts index c5eff28ce..42c894338 100644 --- a/libs/network-stats/src/config/stats-fields.ts +++ b/libs/network-stats/src/config/stats-fields.ts @@ -1,4 +1,10 @@ -import { addDecimalsFormatNumber, t } from '@vegaprotocol/react-helpers'; +import { + addDecimalsFormatNumber, + getDateTimeFormat, + getTimeFormat, + isValidDate, + t, +} from '@vegaprotocol/react-helpers'; import type { Stats, StatFields } from './types'; // Stats fields config. Keys will correspond to graphql queries when used, and values @@ -120,7 +126,16 @@ export const statsFields: { [key in keyof Stats]: StatFields[] } = { vegaTime: [ { title: t('Time'), - formatter: (time: Date) => new Date(time).toLocaleTimeString(), + formatter: (time: Date) => { + if (!time) { + return; + } + const date = new Date(time); + if (!isValidDate(date)) { + return; + } + return getTimeFormat().format(date); + }, goodThreshold: (time: Date) => { const diff = new Date().getTime() - new Date(time).getTime(); return diff > 0 && diff < 5000; @@ -147,8 +162,11 @@ export const statsFields: { [key in keyof Stats]: StatFields[] } = { if (!t) { return; } - const secSinceStart = - (new Date().getTime() - new Date(t).getTime()) / 1000; + const date = new Date(t); + if (!isValidDate(date)) { + return; + } + const secSinceStart = (new Date().getTime() - date.getTime()) / 1000; const days = Math.floor(secSinceStart / 60 / 60 / 24); const hours = Math.floor((secSinceStart / 60 / 60) % 24); const mins = Math.floor((secSinceStart / 60) % 60); @@ -164,7 +182,11 @@ export const statsFields: { [key in keyof Stats]: StatFields[] } = { if (!t) { return; } - return `${new Date(t).toLocaleString().replace(',', ' ')}`; + const date = new Date(t); + if (!isValidDate(date)) { + return; + } + return getDateTimeFormat().format(date); }, description: t('Genesis'), }, diff --git a/libs/orders/project.json b/libs/orders/project.json index 232d39caf..fd39d313d 100644 --- a/libs/orders/project.json +++ b/libs/orders/project.json @@ -69,6 +69,13 @@ "quiet": true } } + }, + "build-spec": { + "executor": "@nrwl/workspace:run-commands", + "outputs": [], + "options": { + "command": "yarn tsc --project ./libs/orders/tsconfig.spec.json" + } } } } diff --git a/libs/orders/src/lib/components/mocks/generate-orders.ts b/libs/orders/src/lib/components/mocks/generate-orders.ts index 22369f60c..d14c1b8c8 100644 --- a/libs/orders/src/lib/components/mocks/generate-orders.ts +++ b/libs/orders/src/lib/components/mocks/generate-orders.ts @@ -1,12 +1,5 @@ import merge from 'lodash/merge'; -import { - MarketState, - MarketTradingMode, - OrderStatus, - OrderTimeInForce, - OrderType, - Side, -} from '@vegaprotocol/types'; +import { MarketState, MarketTradingMode, Schema } from '@vegaprotocol/types'; import type { Order } from '../'; import type { PartialDeep } from 'type-fest'; @@ -59,12 +52,12 @@ export const generateOrder = (partialOrder?: PartialDeep) => { tradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, }, size: '10', - type: OrderType.TYPE_MARKET, - status: OrderStatus.STATUS_ACTIVE, - side: Side.SIDE_BUY, + type: Schema.OrderType.TYPE_MARKET, + status: Schema.OrderStatus.STATUS_ACTIVE, + side: Schema.Side.SIDE_BUY, remaining: '5', price: '', - timeInForce: OrderTimeInForce.TIME_IN_FORCE_IOC, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_IOC, createdAt: new Date().toISOString(), updatedAt: null, expiresAt: null, @@ -77,17 +70,17 @@ export const generateOrder = (partialOrder?: PartialDeep) => { export const limitOrder = generateOrder({ id: 'limit-order', - type: OrderType.TYPE_LIMIT, - status: OrderStatus.STATUS_ACTIVE, - timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTT, + type: Schema.OrderType.TYPE_LIMIT, + status: Schema.OrderStatus.STATUS_ACTIVE, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTT, createdAt: new Date(2022, 3, 3).toISOString(), expiresAt: new Date(2022, 3, 5).toISOString(), }); export const marketOrder = generateOrder({ id: 'market-order', - type: OrderType.TYPE_MARKET, - status: OrderStatus.STATUS_ACTIVE, + type: Schema.OrderType.TYPE_MARKET, + status: Schema.OrderStatus.STATUS_ACTIVE, }); export const generateMockOrders = (): Order[] => { @@ -99,12 +92,12 @@ export const generateMockOrders = (): Order[] => { id: 'c9f5acd348796011c075077e4d58d9b7f1689b7c1c8e030a5e886b83aa96923d', }, size: '10', - type: OrderType.TYPE_LIMIT, - status: OrderStatus.STATUS_FILLED, - side: Side.SIDE_BUY, + type: Schema.OrderType.TYPE_LIMIT, + status: Schema.OrderStatus.STATUS_FILLED, + side: Schema.Side.SIDE_BUY, remaining: '0', price: '20000000', - timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, createdAt: new Date(2020, 1, 1).toISOString(), }), generateOrder({ @@ -114,12 +107,12 @@ export const generateMockOrders = (): Order[] => { id: '5a4b0b9e9c0629f0315ec56fcb7bd444b0c6e4da5ec7677719d502626658a376', }, size: '1', - type: OrderType.TYPE_LIMIT, - status: OrderStatus.STATUS_FILLED, - side: Side.SIDE_BUY, + type: Schema.OrderType.TYPE_LIMIT, + status: Schema.OrderStatus.STATUS_FILLED, + side: Schema.Side.SIDE_BUY, remaining: '0', price: '100', - timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, createdAt: new Date().toISOString(), }), generateOrder({ @@ -129,12 +122,12 @@ export const generateMockOrders = (): Order[] => { id: 'c6f4337b31ed57a961969c3ba10297b369d01b9e75a4cbb96db4fc62886444e6', }, size: '1', - type: OrderType.TYPE_LIMIT, - status: OrderStatus.STATUS_FILLED, - side: Side.SIDE_BUY, + type: Schema.OrderType.TYPE_LIMIT, + status: Schema.OrderStatus.STATUS_FILLED, + side: Schema.Side.SIDE_BUY, remaining: '0', price: '20000', - timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, createdAt: new Date(2022, 5, 10).toISOString(), }), ]; diff --git a/libs/orders/src/lib/components/order-data-provider/__generated__/OrderSub.ts b/libs/orders/src/lib/components/order-data-provider/__generated__/OrderSub.ts deleted file mode 100644 index 883f3d144..000000000 --- a/libs/orders/src/lib/components/order-data-provider/__generated__/OrderSub.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// @generated -// This file was automatically generated and should not be edited. - -import { OrderType, Side, OrderStatus, OrderRejectionReason, OrderTimeInForce } from "@vegaprotocol/types"; - -// ==================================================== -// GraphQL subscription operation: OrderSub -// ==================================================== - -export interface OrderSub_orders_peggedOrder { - __typename: "PeggedOrder"; -} - -export interface OrderSub_orders { - __typename: "OrderUpdate"; - /** - * Hash of the order data - */ - id: string; - /** - * The market the order is trading on (probably stored internally as a hash of the market details) - */ - marketId: string; - /** - * The order type - */ - type: OrderType | null; - /** - * Whether the order is to buy or sell - */ - side: Side; - /** - * Total number of units that may be bought or sold (immutable) (uint64) - */ - size: string; - /** - * The status of an order, for example 'Active' - */ - status: OrderStatus; - /** - * Why the order was rejected - */ - rejectionReason: OrderRejectionReason | null; - /** - * The worst price the order will trade at (e.g. buy for price or less, sell for price or more) (uint64) - */ - price: string; - /** - * The timeInForce of order (determines how and if it executes, and whether it persists on the book) - */ - timeInForce: OrderTimeInForce; - /** - * Number of units remaining of the total that have not yet been bought or sold (uint64) - */ - remaining: string; - /** - * Expiration time of this order (ISO-8601 RFC3339+Nano formatted date) - */ - expiresAt: string | null; - /** - * RFC3339Nano formatted date and time for when the order was created (timestamp) - */ - createdAt: string; - /** - * RFC3339Nano time the order was altered - */ - updatedAt: string | null; - /** - * The liquidity provision this order was created from - */ - liquidityProvisionId: string | null; - /** - * PeggedOrder contains the details about a pegged order - */ - peggedOrder: OrderSub_orders_peggedOrder | null; -} - -export interface OrderSub { - /** - * Subscribe to orders updates - */ - orders: OrderSub_orders[] | null; -} - -export interface OrderSubVariables { - partyId: string; -} diff --git a/libs/orders/src/lib/components/order-data-provider/__generated__/Orders.ts b/libs/orders/src/lib/components/order-data-provider/__generated__/Orders.ts deleted file mode 100644 index 8bf0405c7..000000000 --- a/libs/orders/src/lib/components/order-data-provider/__generated__/Orders.ts +++ /dev/null @@ -1,158 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// @generated -// This file was automatically generated and should not be edited. - -import { Pagination, OrderType, Side, OrderStatus, OrderRejectionReason, OrderTimeInForce } from "@vegaprotocol/types"; - -// ==================================================== -// GraphQL query operation: Orders -// ==================================================== - -export interface Orders_party_ordersConnection_edges_node_market { - __typename: "Market"; - /** - * Market ID - */ - id: string; -} - -export interface Orders_party_ordersConnection_edges_node_liquidityProvision { - __typename: "LiquidityProvision"; -} - -export interface Orders_party_ordersConnection_edges_node_peggedOrder { - __typename: "PeggedOrder"; -} - -export interface Orders_party_ordersConnection_edges_node { - __typename: "Order"; - /** - * Hash of the order data - */ - id: string; - /** - * The market the order is trading on (probably stored internally as a hash of the market details) - */ - market: Orders_party_ordersConnection_edges_node_market; - /** - * The order type - */ - type: OrderType | null; - /** - * Whether the order is to buy or sell - */ - side: Side; - /** - * Total number of units that may be bought or sold (immutable) (uint64) - */ - size: string; - /** - * The status of an order, for example 'Active' - */ - status: OrderStatus; - /** - * Why the order was rejected - */ - rejectionReason: OrderRejectionReason | null; - /** - * The worst price the order will trade at (e.g. buy for price or less, sell for price or more) (uint64) - */ - price: string; - /** - * The timeInForce of order (determines how and if it executes, and whether it persists on the book) - */ - timeInForce: OrderTimeInForce; - /** - * Number of units remaining of the total that have not yet been bought or sold (uint64) - */ - remaining: string; - /** - * Expiration time of this order (ISO-8601 RFC3339+Nano formatted date) - */ - expiresAt: string | null; - /** - * RFC3339Nano formatted date and time for when the order was created (timestamp) - */ - createdAt: string; - /** - * RFC3339Nano time the order was altered - */ - updatedAt: string | null; - /** - * The liquidity provision this order was created from - */ - liquidityProvision: Orders_party_ordersConnection_edges_node_liquidityProvision | null; - /** - * PeggedOrder contains the details about a pegged order - */ - peggedOrder: Orders_party_ordersConnection_edges_node_peggedOrder | null; -} - -export interface Orders_party_ordersConnection_edges { - __typename: "OrderEdge"; - /** - * The order - */ - node: Orders_party_ordersConnection_edges_node; - /** - * The cursor for this order - */ - cursor: string | null; -} - -export interface Orders_party_ordersConnection_pageInfo { - __typename: "PageInfo"; - /** - * The first cursor in the current page - */ - startCursor: string; - /** - * The last cursor in the current page - */ - endCursor: string; - /** - * The connection has more pages to fetch when traversing forward through the connection - */ - hasNextPage: boolean; - /** - * The connection has more pages to fetch when traversing backward through the connection - */ - hasPreviousPage: boolean; -} - -export interface Orders_party_ordersConnection { - __typename: "OrderConnection"; - /** - * The orders in this connection - */ - edges: Orders_party_ordersConnection_edges[] | null; - /** - * The pagination information - */ - pageInfo: Orders_party_ordersConnection_pageInfo | null; -} - -export interface Orders_party { - __typename: "Party"; - /** - * Party identifier - */ - id: string; - /** - * Orders relating to a party - */ - ordersConnection: Orders_party_ordersConnection | null; -} - -export interface Orders { - /** - * An entity that is trading on the Vega network - */ - party: Orders_party | null; -} - -export interface OrdersVariables { - partyId: string; - pagination?: Pagination | null; -} diff --git a/libs/orders/src/lib/components/order-data-provider/__generated___/orders.ts b/libs/orders/src/lib/components/order-data-provider/__generated___/orders.ts new file mode 100644 index 000000000..c81c9d05c --- /dev/null +++ b/libs/orders/src/lib/components/order-data-provider/__generated___/orders.ts @@ -0,0 +1,150 @@ +import { Schema as Types } from '@vegaprotocol/types'; + +import { gql } from '@apollo/client'; +import * as Apollo from '@apollo/client'; +const defaultOptions = {} as const; +export type OrderFieldsFragment = { __typename?: 'Order', id: string, type?: Types.OrderType | null, side: Types.Side, size: string, status: Types.OrderStatus, rejectionReason?: Types.OrderRejectionReason | null, price: string, timeInForce: Types.OrderTimeInForce, remaining: string, expiresAt?: string | null, createdAt: string, updatedAt?: string | null, market: { __typename?: 'Market', id: string }, liquidityProvision?: { __typename: 'LiquidityProvision' } | null, peggedOrder?: { __typename: 'PeggedOrder' } | null }; + +export type OrdersQueryVariables = Types.Exact<{ + partyId: Types.Scalars['ID']; + pagination?: Types.InputMaybe; +}>; + + +export type OrdersQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, ordersConnection?: { __typename?: 'OrderConnection', edges?: Array<{ __typename?: 'OrderEdge', cursor?: string | null, node: { __typename?: 'Order', id: string, type?: Types.OrderType | null, side: Types.Side, size: string, status: Types.OrderStatus, rejectionReason?: Types.OrderRejectionReason | null, price: string, timeInForce: Types.OrderTimeInForce, remaining: string, expiresAt?: string | null, createdAt: string, updatedAt?: string | null, market: { __typename?: 'Market', id: string }, liquidityProvision?: { __typename: 'LiquidityProvision' } | null, peggedOrder?: { __typename: 'PeggedOrder' } | null } }> | null, pageInfo?: { __typename?: 'PageInfo', startCursor: string, endCursor: string, hasNextPage: boolean, hasPreviousPage: boolean } | null } | null } | null }; + +export type OrderUpdateFieldsFragment = { __typename?: 'OrderUpdate', id: string, marketId: string, type?: Types.OrderType | null, side: Types.Side, size: string, status: Types.OrderStatus, rejectionReason?: Types.OrderRejectionReason | null, price: string, timeInForce: Types.OrderTimeInForce, remaining: string, expiresAt?: string | null, createdAt: string, updatedAt?: string | null, liquidityProvisionId?: string | null, peggedOrder?: { __typename: 'PeggedOrder' } | null }; + +export type OrdersUpdateSubscriptionVariables = Types.Exact<{ + partyId: Types.Scalars['ID']; +}>; + + +export type OrdersUpdateSubscription = { __typename?: 'Subscription', orders?: Array<{ __typename?: 'OrderUpdate', id: string, marketId: string, type?: Types.OrderType | null, side: Types.Side, size: string, status: Types.OrderStatus, rejectionReason?: Types.OrderRejectionReason | null, price: string, timeInForce: Types.OrderTimeInForce, remaining: string, expiresAt?: string | null, createdAt: string, updatedAt?: string | null, liquidityProvisionId?: string | null, peggedOrder?: { __typename: 'PeggedOrder' } | null }> | null }; + +export const OrderFieldsFragmentDoc = gql` + fragment OrderFields on Order { + id + market { + id + } + type + side + size + status + rejectionReason + price + timeInForce + remaining + expiresAt + createdAt + updatedAt + liquidityProvision { + __typename + } + peggedOrder { + __typename + } +} + `; +export const OrderUpdateFieldsFragmentDoc = gql` + fragment OrderUpdateFields on OrderUpdate { + id + marketId + type + side + size + status + rejectionReason + price + timeInForce + remaining + expiresAt + createdAt + updatedAt + liquidityProvisionId + peggedOrder { + __typename + } +} + `; +export const OrdersDocument = gql` + query Orders($partyId: ID!, $pagination: Pagination) { + party(id: $partyId) { + id + ordersConnection(pagination: $pagination) { + edges { + node { + ...OrderFields + } + cursor + } + pageInfo { + startCursor + endCursor + hasNextPage + hasPreviousPage + } + } + } +} + ${OrderFieldsFragmentDoc}`; + +/** + * __useOrdersQuery__ + * + * To run a query within a React component, call `useOrdersQuery` and pass it any options that fit your needs. + * When your component renders, `useOrdersQuery` 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 } = useOrdersQuery({ + * variables: { + * partyId: // value for 'partyId' + * pagination: // value for 'pagination' + * }, + * }); + */ +export function useOrdersQuery(baseOptions: Apollo.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useQuery(OrdersDocument, options); + } +export function useOrdersLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useLazyQuery(OrdersDocument, options); + } +export type OrdersQueryHookResult = ReturnType; +export type OrdersLazyQueryHookResult = ReturnType; +export type OrdersQueryResult = Apollo.QueryResult; +export const OrdersUpdateDocument = gql` + subscription OrdersUpdate($partyId: ID!) { + orders(partyId: $partyId) { + ...OrderUpdateFields + } +} + ${OrderUpdateFieldsFragmentDoc}`; + +/** + * __useOrdersUpdateSubscription__ + * + * To run a query within a React component, call `useOrdersUpdateSubscription` and pass it any options that fit your needs. + * When your component renders, `useOrdersUpdateSubscription` 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 } = useOrdersUpdateSubscription({ + * variables: { + * partyId: // value for 'partyId' + * }, + * }); + */ +export function useOrdersUpdateSubscription(baseOptions: Apollo.SubscriptionHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useSubscription(OrdersUpdateDocument, options); + } +export type OrdersUpdateSubscriptionHookResult = ReturnType; +export type OrdersUpdateSubscriptionResult = Apollo.SubscriptionResult; \ No newline at end of file diff --git a/libs/orders/src/lib/components/order-data-provider/index.ts b/libs/orders/src/lib/components/order-data-provider/index.ts index 3d2555955..3d66ed838 100644 --- a/libs/orders/src/lib/components/order-data-provider/index.ts +++ b/libs/orders/src/lib/components/order-data-provider/index.ts @@ -1,3 +1,2 @@ -export * from './__generated__/OrderSub'; -export * from './__generated__/Orders'; +export * from './__generated___/orders'; export * from './order-data-provider'; diff --git a/libs/orders/src/lib/components/order-data-provider/order-data-provider.spec.ts b/libs/orders/src/lib/components/order-data-provider/order-data-provider.spec.ts index c7cfede80..15f33b6e9 100644 --- a/libs/orders/src/lib/components/order-data-provider/order-data-provider.spec.ts +++ b/libs/orders/src/lib/components/order-data-provider/order-data-provider.spec.ts @@ -1,5 +1,6 @@ import { update } from './order-data-provider'; -import type { OrderSub_orders, Orders_party_ordersConnection_edges } from '../'; +import type { OrderUpdateFieldsFragment, OrderFieldsFragment } from '../'; +import type { Edge } from '@vegaprotocol/react-helpers'; describe('order data provider', () => { it('puts incoming data in proper place', () => { const data = [ @@ -16,7 +17,7 @@ describe('order data provider', () => { createdAt: new Date('2022-01-30').toISOString(), }, }, - ] as Orders_party_ordersConnection_edges[]; + ] as Edge[]; const delta = [ // this one should be dropped because id don't exits and it's older than newest @@ -46,16 +47,20 @@ describe('order data provider', () => { updatedAt: new Date('2022-02-03').toISOString(), createdAt: new Date('2022-01-29').toISOString(), }, - ] as OrderSub_orders[]; + ] as OrderUpdateFieldsFragment[]; const updatedData = update(data, delta); expect( - updatedData.findIndex((edge) => edge.node.id === delta[0].id) + updatedData?.findIndex((edge) => edge.node.id === delta[0].id) ).toEqual(-1); - expect(updatedData[2].node.id).toEqual(delta[2].id); - expect(updatedData[2].node.updatedAt).toEqual(delta[2].updatedAt); - expect(updatedData[0].node.id).toEqual(delta[3].id); - expect(updatedData[1].node.id).toEqual(delta[4].id); - expect(updatedData[1].node.updatedAt).toEqual(delta[4].updatedAt); + expect(updatedData && updatedData[2].node.id).toEqual(delta[2].id); + expect(updatedData && updatedData[2].node.updatedAt).toEqual( + delta[2].updatedAt + ); + expect(updatedData && updatedData[0].node.id).toEqual(delta[3].id); + expect(updatedData && updatedData[1].node.id).toEqual(delta[4].id); + expect(updatedData && updatedData[1].node.updatedAt).toEqual( + delta[4].updatedAt + ); }); }); diff --git a/libs/orders/src/lib/components/order-data-provider/order-data-provider.ts b/libs/orders/src/lib/components/order-data-provider/order-data-provider.ts index be5e8ea75..0eba1fdd6 100644 --- a/libs/orders/src/lib/components/order-data-provider/order-data-provider.ts +++ b/libs/orders/src/lib/components/order-data-provider/order-data-provider.ts @@ -1,5 +1,4 @@ import produce from 'immer'; -import { gql } from '@apollo/client'; import orderBy from 'lodash/orderBy'; import uniqBy from 'lodash/uniqBy'; import { @@ -13,84 +12,33 @@ import type { Market } from '@vegaprotocol/market-list'; import { marketsProvider } from '@vegaprotocol/market-list'; import type { PageInfo, Edge } from '@vegaprotocol/react-helpers'; import type { - Orders, - Orders_party_ordersConnection_edges, - Orders_party_ordersConnection_edges_node, - Orders_party_ordersConnection_edges_node_liquidityProvision, - OrderSub, - OrderSub_orders, -} from '../'; + OrderFieldsFragment, + OrdersQuery, + OrdersUpdateSubscription, +} from './__generated___/orders'; +import { OrdersDocument, OrdersUpdateDocument } from './__generated___/orders'; -export const ORDERS_QUERY = gql` - query Orders($partyId: ID!, $pagination: Pagination) { - party(id: $partyId) { - id - ordersConnection(pagination: $pagination) { - edges { - node { - id - market { - id - } - type - side - size - status - rejectionReason - price - timeInForce - remaining - expiresAt - createdAt - updatedAt - liquidityProvision { - __typename - } - peggedOrder { - __typename - } - } - cursor - } - pageInfo { - startCursor - endCursor - hasNextPage - hasPreviousPage - } - } - } - } -`; +export type Order = Omit & { + market?: Market; +}; +export type OrderEdge = Edge; -export const ORDERS_SUB = gql` - subscription OrderSub($partyId: ID!) { - orders(partyId: $partyId) { - id - marketId - type - side - size - status - rejectionReason - price - timeInForce - remaining - expiresAt - createdAt - updatedAt - liquidityProvisionId - peggedOrder { - __typename - } - } - } -`; +const getData = (responseData: OrdersQuery) => + responseData?.party?.ordersConnection?.edges || null; + +const getDelta = (subscriptionData: OrdersUpdateSubscription) => + subscriptionData.orders || []; + +const getPageInfo = (responseData: OrdersQuery): PageInfo | null => + responseData.party?.ordersConnection?.pageInfo || null; export const update = ( - data: Orders_party_ordersConnection_edges[], - delta: OrderSub_orders[] + data: ReturnType, + delta: ReturnType ) => { + if (!data) { + return data; + } return produce(data, (draft) => { // A single update can contain the same order with multiple updates, so we need to find // the latest version of the order and only update using that @@ -114,12 +62,13 @@ export const update = ( const { marketId, liquidityProvisionId, ...order } = node; // If there is a liquidity provision id add the object to the resulting order - const liquidityProvision: Orders_party_ordersConnection_edges_node_liquidityProvision | null = - liquidityProvisionId - ? { - __typename: 'LiquidityProvision', - } - : null; + const liquidityProvision: + | OrderFieldsFragment['liquidityProvision'] + | null = liquidityProvisionId + ? { + __typename: 'LiquidityProvision', + } + : null; draft.unshift({ node: { @@ -139,24 +88,9 @@ export const update = ( }); }; -export type Order = Omit & { - market?: Market; -}; -export type OrderEdge = Edge; - -const getData = ( - responseData: Orders -): Orders_party_ordersConnection_edges[] | null => - responseData?.party?.ordersConnection?.edges || null; - -const getDelta = (subscriptionData: OrderSub) => subscriptionData.orders || []; - -const getPageInfo = (responseData: Orders): PageInfo | null => - responseData.party?.ordersConnection?.pageInfo || null; - export const ordersProvider = makeDataProvider({ - query: ORDERS_QUERY, - subscriptionQuery: ORDERS_SUB, + query: OrdersDocument, + subscriptionQuery: OrdersUpdateDocument, update, getData, getDelta, @@ -173,7 +107,7 @@ export const ordersWithMarketProvider = makeDerivedDataProvider< >( [ordersProvider, marketsProvider], (partsData): OrderEdge[] => - ((partsData[0] as Parameters['0']) || []).map((edge) => ({ + ((partsData[0] as ReturnType) || []).map((edge) => ({ cursor: edge.cursor, node: { ...edge.node, diff --git a/libs/orders/src/lib/components/order-data-provider/orders.graphql b/libs/orders/src/lib/components/order-data-provider/orders.graphql new file mode 100644 index 000000000..c3b705b2e --- /dev/null +++ b/libs/orders/src/lib/components/order-data-provider/orders.graphql @@ -0,0 +1,69 @@ +fragment OrderFields on Order { + id + market { + id + } + type + side + size + status + rejectionReason + price + timeInForce + remaining + expiresAt + createdAt + updatedAt + liquidityProvision { + __typename + } + peggedOrder { + __typename + } +} + +query Orders($partyId: ID!, $pagination: Pagination) { + party(id: $partyId) { + id + ordersConnection(pagination: $pagination) { + edges { + node { + ...OrderFields + } + cursor + } + pageInfo { + startCursor + endCursor + hasNextPage + hasPreviousPage + } + } + } +} + +fragment OrderUpdateFields on OrderUpdate { + id + marketId + type + side + size + status + rejectionReason + price + timeInForce + remaining + expiresAt + createdAt + updatedAt + liquidityProvisionId + peggedOrder { + __typename + } +} + +subscription OrdersUpdate($partyId: ID!) { + orders(partyId: $partyId) { + ...OrderUpdateFields + } +} diff --git a/libs/orders/src/lib/components/order-feedback/order-feedback.spec.tsx b/libs/orders/src/lib/components/order-feedback/order-feedback.spec.tsx index 422260a67..1a9e3055d 100644 --- a/libs/orders/src/lib/components/order-feedback/order-feedback.spec.tsx +++ b/libs/orders/src/lib/components/order-feedback/order-feedback.spec.tsx @@ -1,14 +1,11 @@ import { render, screen } from '@testing-library/react'; import { - OrderRejectionReason, OrderRejectionReasonMapping, - OrderStatus, OrderStatusMapping, - OrderType, - Side, + Schema, } from '@vegaprotocol/types'; import { VegaTxStatus } from '@vegaprotocol/wallet'; -import type { OrderEvent_busEvents_event_Order } from '../../order-hooks'; +import type { OrderEventFieldsFragment } from '../../order-hooks'; import { generateOrder } from '../mocks/generate-orders'; import type { OrderFeedbackProps } from './order-feedback'; import { OrderFeedback } from './order-feedback'; @@ -42,12 +39,10 @@ describe('OrderFeedback', () => { it('renders error reason', () => { const orderFields = { - status: OrderStatus.STATUS_REJECTED, - rejectionReason: OrderRejectionReason.ORDER_ERROR_AMEND_FAILURE, + status: Schema.OrderStatus.STATUS_REJECTED, + rejectionReason: Schema.OrderRejectionReason.ORDER_ERROR_AMEND_FAILURE, }; - const order = generateOrder( - orderFields - ) as OrderEvent_busEvents_event_Order; + const order = generateOrder(orderFields) as OrderEventFieldsFragment; render(); expect(screen.getByTestId('error-reason')).toHaveTextContent( `${OrderRejectionReasonMapping[orderFields.rejectionReason]}` @@ -56,15 +51,15 @@ describe('OrderFeedback', () => { it('should render order details when order is placed successfully', () => { const order = generateOrder({ - type: OrderType.TYPE_LIMIT, + type: Schema.OrderType.TYPE_LIMIT, price: '100', size: '200', - side: Side.SIDE_BUY, + side: Schema.Side.SIDE_BUY, market: { decimalPlaces: 2, positionDecimalPlaces: 0, }, - }) as OrderEvent_busEvents_event_Order; + }) as OrderEventFieldsFragment; render(); expect(screen.getByTestId('order-confirmed')).toBeInTheDocument(); expect(screen.getByTestId('tx-block-explorer')).toHaveTextContent( diff --git a/libs/orders/src/lib/components/order-feedback/order-feedback.tsx b/libs/orders/src/lib/components/order-feedback/order-feedback.tsx index fc80c6b4d..e63b767f6 100644 --- a/libs/orders/src/lib/components/order-feedback/order-feedback.tsx +++ b/libs/orders/src/lib/components/order-feedback/order-feedback.tsx @@ -1,19 +1,18 @@ import { useEnvironment } from '@vegaprotocol/environment'; -import type { OrderEvent_busEvents_event_Order } from '../../order-hooks/__generated__/OrderEvent'; +import type { OrderEventFieldsFragment } from '../../order-hooks/__generated___/OrderEvent'; import { addDecimalsFormatNumber, Size, t } from '@vegaprotocol/react-helpers'; import { OrderRejectionReasonMapping, - OrderStatus, OrderStatusMapping, OrderTimeInForceMapping, - OrderType, + Schema, } from '@vegaprotocol/types'; import type { VegaTxState } from '@vegaprotocol/wallet'; import { Link } from '@vegaprotocol/ui-toolkit'; export interface OrderFeedbackProps { transaction: VegaTxState; - order: OrderEvent_busEvents_event_Order | null; + order: OrderEventFieldsFragment | null; } export const OrderFeedback = ({ transaction, order }: OrderFeedbackProps) => { @@ -36,7 +35,7 @@ export const OrderFeedback = ({ transaction, order }: OrderFeedbackProps) => {

{t(`Status`)}

{t(`${OrderStatusMapping[order.status]}`)}

- {order.type === OrderType.TYPE_LIMIT && order.market && ( + {order.type === Schema.OrderType.TYPE_LIMIT && order.market && (

{t(`Price`)}

@@ -82,21 +81,18 @@ export const OrderFeedback = ({ transaction, order }: OrderFeedbackProps) => { ); }; -const getRejectionReason = ( - order: OrderEvent_busEvents_event_Order -): string | null => { +const getRejectionReason = (order: OrderEventFieldsFragment): string | null => { switch (order.status) { - case OrderStatus.STATUS_STOPPED: + case Schema.OrderStatus.STATUS_STOPPED: return t( `Your ${ OrderTimeInForceMapping[order.timeInForce] } order was not filled and it has been stopped` ); - case OrderStatus.STATUS_REJECTED: - return ( - order.rejectionReason && - t(OrderRejectionReasonMapping[order.rejectionReason]) - ); + case Schema.OrderStatus.STATUS_REJECTED: + return order.rejectionReason + ? t(OrderRejectionReasonMapping[order.rejectionReason]) + : null; default: return null; } diff --git a/libs/orders/src/lib/components/order-list-manager/order-list-manager.spec.tsx b/libs/orders/src/lib/components/order-list-manager/order-list-manager.spec.tsx index 56d391917..654652343 100644 --- a/libs/orders/src/lib/components/order-list-manager/order-list-manager.spec.tsx +++ b/libs/orders/src/lib/components/order-list-manager/order-list-manager.spec.tsx @@ -1,7 +1,7 @@ import { render, screen } from '@testing-library/react'; import { OrderListManager } from './order-list-manager'; import * as useDataProviderHook from '@vegaprotocol/react-helpers'; -import type { Orders_party_ordersConnection_edges_node } from '../'; +import type { OrderFieldsFragment } from '../'; import * as orderListMock from '../order-list/order-list'; import { forwardRef } from 'react'; @@ -41,7 +41,7 @@ it('Renders the order list if orders provided', async () => { // avoid warnings about padding refs orderListMock.OrderList = forwardRef(() =>

OrderList
); jest.spyOn(useDataProviderHook, 'useDataProvider').mockReturnValue({ - data: [{ id: '1' } as Orders_party_ordersConnection_edges_node], + data: [{ id: '1' } as OrderFieldsFragment], loading: false, error: undefined, flush: jest.fn(), diff --git a/libs/orders/src/lib/components/order-list-manager/use-order-list-data.spec.ts b/libs/orders/src/lib/components/order-list-manager/use-order-list-data.spec.ts index ef4a8898f..06afe0c3f 100644 --- a/libs/orders/src/lib/components/order-list-manager/use-order-list-data.spec.ts +++ b/libs/orders/src/lib/components/order-list-manager/use-order-list-data.spec.ts @@ -2,14 +2,15 @@ import type { AgGridReact } from 'ag-grid-react'; import { MockedProvider } from '@apollo/client/testing'; import { renderHook, waitFor } from '@testing-library/react'; import { useOrderListData } from './use-order-list-data'; -import type { Orders_party_ordersConnection_edges } from '../order-data-provider/__generated__/Orders'; +import type { Edge } from '@vegaprotocol/react-helpers'; +import type { OrderFieldsFragment } from '../order-data-provider/__generated___/orders'; import type { IGetRowsParams } from 'ag-grid-community'; const loadMock = jest.fn(); let mockData = null; let mockDataProviderData = { - data: mockData as (Orders_party_ordersConnection_edges | null)[] | null, + data: mockData as (Edge | null)[] | null, error: undefined, loading: true, load: loadMock, @@ -67,13 +68,13 @@ describe('useOrderListData Hook', () => { id: 'data_id_1', createdAt: 1, }, - } as unknown as Orders_party_ordersConnection_edges, + } as unknown as Edge, { node: { id: 'data_id_2', createdAt: 2, }, - } as unknown as Orders_party_ordersConnection_edges, + } as unknown as Edge, ]; mockDataProviderData = { ...mockDataProviderData, @@ -106,13 +107,13 @@ describe('useOrderListData Hook', () => { id: 'data_id_1', createdAt: 1, }, - } as unknown as Orders_party_ordersConnection_edges, + } as unknown as Edge, { node: { id: 'data_id_2', createdAt: 2, }, - } as unknown as Orders_party_ordersConnection_edges, + } as unknown as Edge, ]; Object.assign(mockDataProviderData, { data: mockData, @@ -124,13 +125,13 @@ describe('useOrderListData Hook', () => { id: 'data_id_3', createdAt: 3, }, - } as unknown as Orders_party_ordersConnection_edges, + } as unknown as Edge, { node: { id: 'data_id_4', createdAt: 4, }, - } as unknown as Orders_party_ordersConnection_edges, + } as unknown as Edge, ]; const mockNextData = [...mockData, ...mockDelta]; const { result } = renderHook( diff --git a/libs/orders/src/lib/components/order-list/order-edit-dialog.tsx b/libs/orders/src/lib/components/order-list/order-edit-dialog.tsx index d476040b1..3b713bfed 100644 --- a/libs/orders/src/lib/components/order-list/order-edit-dialog.tsx +++ b/libs/orders/src/lib/components/order-list/order-edit-dialog.tsx @@ -5,7 +5,7 @@ import { Size, getDateTimeFormat, } from '@vegaprotocol/react-helpers'; -import { OrderType } from '@vegaprotocol/types'; +import { Schema } from '@vegaprotocol/types'; import { FormGroup, Input, @@ -14,7 +14,6 @@ import { Dialog, Icon, } from '@vegaprotocol/ui-toolkit'; -import { OrderTimeInForce } from '@vegaprotocol/types'; import { useForm } from 'react-hook-form'; import type { Order } from '../order-data-provider'; @@ -65,7 +64,7 @@ export const OrderEditDialog = ({

{t(`${order.market.tradableInstrument.instrument.name}`)}

)} - {order.type === OrderType.TYPE_LIMIT && order.market && ( + {order.type === Schema.OrderType.TYPE_LIMIT && order.market && (

{t(`Current price`)}

@@ -86,7 +85,7 @@ export const OrderEditDialog = ({

- {order.timeInForce === OrderTimeInForce.TIME_IN_FORCE_GTT && + {order.timeInForce === Schema.OrderTimeInForce.TIME_IN_FORCE_GTT && order.expiresAt && (

{t(`Expires at`)}

diff --git a/libs/orders/src/lib/components/order-list/order-list.spec.tsx b/libs/orders/src/lib/components/order-list/order-list.spec.tsx index 78daca377..82b90d949 100644 --- a/libs/orders/src/lib/components/order-list/order-list.spec.tsx +++ b/libs/orders/src/lib/components/order-list/order-list.spec.tsx @@ -1,16 +1,12 @@ import { act, render, screen, within } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { getDateTimeFormat } from '@vegaprotocol/react-helpers'; -import { OrderTimeInForce, OrderType } from '@vegaprotocol/types'; import { OrderRejectionReasonMapping, OrderTimeInForceMapping, -} from '@vegaprotocol/types'; -import { - OrderStatus, - OrderRejectionReason, OrderTypeMapping, OrderStatusMapping, + Schema, } from '@vegaprotocol/types'; import type { PartialDeep } from 'type-fest'; import type { VegaWalletContextShape } from '@vegaprotocol/wallet'; @@ -82,7 +78,7 @@ describe('OrderListTable', () => { const expectedValues: string[] = [ marketOrder.market?.tradableInstrument.instrument.code || '', '+0.10', - OrderTypeMapping[marketOrder.type as OrderType] || '', + OrderTypeMapping[marketOrder.type as Schema.OrderType] || '', OrderStatusMapping[marketOrder.status], '5', '-', @@ -105,7 +101,7 @@ describe('OrderListTable', () => { const expectedValues: string[] = [ limitOrder.market?.tradableInstrument.instrument.code || '', '+0.10', - OrderTypeMapping[limitOrder.type || OrderType.TYPE_LIMIT], + OrderTypeMapping[limitOrder.type || Schema.OrderType.TYPE_LIMIT], OrderStatusMapping[limitOrder.status], '5', '-', @@ -124,9 +120,9 @@ describe('OrderListTable', () => { it('should apply correct formatting for a rejected order', async () => { const rejectedOrder = { ...marketOrder, - status: OrderStatus.STATUS_REJECTED, + status: Schema.OrderStatus.STATUS_REJECTED, rejectionReason: - OrderRejectionReason.ORDER_ERROR_INSUFFICIENT_ASSET_BALANCE, + Schema.OrderRejectionReason.ORDER_ERROR_INSUFFICIENT_ASSET_BALANCE, }; await act(async () => { render(generateJsx({ rowData: [rejectedOrder] })); @@ -144,8 +140,8 @@ describe('OrderListTable', () => { const mockEdit = jest.fn(); const mockCancel = jest.fn(); const order = generateOrder({ - type: OrderType.TYPE_LIMIT, - timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC, + type: Schema.OrderType.TYPE_LIMIT, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, liquidityProvision: null, peggedOrder: null, }); @@ -168,8 +164,8 @@ describe('OrderListTable', () => { it('shows if an order is a liquidity provision order and does not show order actions', async () => { const order = generateOrder({ - type: OrderType.TYPE_LIMIT, - timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC, + type: Schema.OrderType.TYPE_LIMIT, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, liquidityProvision: { __typename: 'LiquidityProvision' }, }); @@ -185,8 +181,8 @@ describe('OrderListTable', () => { it('shows if an order is a pegged order and does not show order actions', async () => { const order = generateOrder({ - type: OrderType.TYPE_LIMIT, - timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC, + type: Schema.OrderType.TYPE_LIMIT, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, peggedOrder: { __typename: 'PeggedOrder', }, @@ -202,32 +198,32 @@ describe('OrderListTable', () => { expect(amendCell.queryAllByRole('button')).toHaveLength(0); }); - it.each([OrderStatus.STATUS_ACTIVE, OrderStatus.STATUS_PARKED])( - 'shows buttons for %s orders', - async (status) => { - const order = generateOrder({ - type: OrderType.TYPE_LIMIT, - status, - }); + it.each([ + Schema.OrderStatus.STATUS_ACTIVE, + Schema.OrderStatus.STATUS_PARKED, + ])('shows buttons for %s orders', async (status) => { + const order = generateOrder({ + type: Schema.OrderType.TYPE_LIMIT, + status, + }); - await act(async () => { - render(generateJsx({ rowData: [order] })); - }); + await act(async () => { + render(generateJsx({ rowData: [order] })); + }); - const amendCell = getAmendCell(); - expect(amendCell.getAllByRole('button')).toHaveLength(2); - } - ); + const amendCell = getAmendCell(); + expect(amendCell.getAllByRole('button')).toHaveLength(2); + }); it.each([ - OrderStatus.STATUS_CANCELLED, - OrderStatus.STATUS_EXPIRED, - OrderStatus.STATUS_FILLED, - OrderStatus.STATUS_REJECTED, - OrderStatus.STATUS_STOPPED, + Schema.OrderStatus.STATUS_CANCELLED, + Schema.OrderStatus.STATUS_EXPIRED, + Schema.OrderStatus.STATUS_FILLED, + Schema.OrderStatus.STATUS_REJECTED, + Schema.OrderStatus.STATUS_STOPPED, ])('does not show buttons for %s orders', async (status) => { const order = generateOrder({ - type: OrderType.TYPE_LIMIT, + type: Schema.OrderType.TYPE_LIMIT, status, }); diff --git a/libs/orders/src/lib/components/order-list/order-list.tsx b/libs/orders/src/lib/components/order-list/order-list.tsx index 9f458f3f7..2d15eee42 100644 --- a/libs/orders/src/lib/components/order-list/order-list.tsx +++ b/libs/orders/src/lib/components/order-list/order-list.tsx @@ -8,13 +8,10 @@ import { } from '@vegaprotocol/react-helpers'; import { OrderRejectionReasonMapping, - OrderStatus, OrderStatusMapping, - OrderTimeInForce, OrderTimeInForceMapping, - OrderType, OrderTypeMapping, - Side, + Schema, } from '@vegaprotocol/types'; import { AgGridDynamic as AgGrid, @@ -143,9 +140,9 @@ export const OrderListTable = forwardRef( type="rightAligned" cellClassRules={{ [positiveClassNames]: ({ data }: { data: Order }) => - data?.side === Side.SIDE_BUY, + data?.side === Schema.Side.SIDE_BUY, [negativeClassNames]: ({ data }: { data: Order }) => - data?.side === Side.SIDE_SELL, + data?.side === Schema.Side.SIDE_SELL, }} valueFormatter={({ value, @@ -155,7 +152,7 @@ export const OrderListTable = forwardRef( return '-'; } const prefix = data - ? data.side === Side.SIDE_BUY + ? data.side === Schema.Side.SIDE_BUY ? '+' : '-' : ''; @@ -182,7 +179,7 @@ export const OrderListTable = forwardRef( value, data, }: VegaValueFormatterParams) => { - if (value === OrderStatus.STATUS_REJECTED) { + if (value === Schema.OrderStatus.STATUS_REJECTED) { return `${OrderStatusMapping[value]}: ${ data?.rejectionReason && OrderRejectionReasonMapping[data.rejectionReason] @@ -223,7 +220,7 @@ export const OrderListTable = forwardRef( }: VegaValueFormatterParams) => { if ( !data?.market || - data.type === OrderType.TYPE_MARKET || + data.type === Schema.OrderType.TYPE_MARKET || !isNumeric(value) ) { return '-'; @@ -238,7 +235,7 @@ export const OrderListTable = forwardRef( data, }: VegaValueFormatterParams) => { if ( - value === OrderTimeInForce.TIME_IN_FORCE_GTT && + value === Schema.OrderTimeInForce.TIME_IN_FORCE_GTT && data?.expiresAt ) { const expiry = getDateTimeFormat().format( @@ -303,14 +300,14 @@ export const OrderListTable = forwardRef( /** * Check if an order is active to determine if it can be edited or cancelled */ -export const isOrderActive = (status: OrderStatus) => { +export const isOrderActive = (status: Schema.OrderStatus) => { return ![ - OrderStatus.STATUS_CANCELLED, - OrderStatus.STATUS_REJECTED, - OrderStatus.STATUS_EXPIRED, - OrderStatus.STATUS_FILLED, - OrderStatus.STATUS_STOPPED, - OrderStatus.STATUS_PARTIALLY_FILLED, + Schema.OrderStatus.STATUS_CANCELLED, + Schema.OrderStatus.STATUS_REJECTED, + Schema.OrderStatus.STATUS_EXPIRED, + Schema.OrderStatus.STATUS_FILLED, + Schema.OrderStatus.STATUS_STOPPED, + Schema.OrderStatus.STATUS_PARTIALLY_FILLED, ].includes(status); }; @@ -327,28 +324,28 @@ export const isOrderAmendable = (order: Order | undefined) => { }; export const getEditDialogTitle = ( - status?: OrderStatus + status?: Schema.OrderStatus ): string | undefined => { if (!status) { return; } switch (status) { - case OrderStatus.STATUS_ACTIVE: + case Schema.OrderStatus.STATUS_ACTIVE: return t('Order updated'); - 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_EXPIRED: + case Schema.OrderStatus.STATUS_EXPIRED: return t('Order expired'); - case OrderStatus.STATUS_CANCELLED: + case Schema.OrderStatus.STATUS_CANCELLED: return t('Order cancelled'); - case OrderStatus.STATUS_REJECTED: + case Schema.OrderStatus.STATUS_REJECTED: return t('Order rejected'); default: return t('Order amendment failed'); @@ -356,14 +353,14 @@ export const getEditDialogTitle = ( }; export const getCancelDialogIntent = ( - status?: OrderStatus + status?: Schema.OrderStatus ): Intent | undefined => { if (!status) { return; } switch (status) { - case OrderStatus.STATUS_CANCELLED: + case Schema.OrderStatus.STATUS_CANCELLED: return Intent.Success; default: return Intent.Danger; @@ -371,14 +368,14 @@ export const getCancelDialogIntent = ( }; export const getCancelDialogTitle = ( - status?: OrderStatus + status?: Schema.OrderStatus ): string | undefined => { if (!status) { return; } switch (status) { - case OrderStatus.STATUS_CANCELLED: + case Schema.OrderStatus.STATUS_CANCELLED: return t('Order cancelled'); default: return t('Order cancellation failed'); diff --git a/libs/orders/src/lib/order-hooks/OrderEvent.graphql b/libs/orders/src/lib/order-hooks/OrderEvent.graphql new file mode 100644 index 000000000..f98942e4a --- /dev/null +++ b/libs/orders/src/lib/order-hooks/OrderEvent.graphql @@ -0,0 +1,33 @@ +fragment OrderEventFields on Order { + type + id + status + rejectionReason + createdAt + size + price + timeInForce + expiresAt + side + market { + id + decimalPlaces + positionDecimalPlaces + tradableInstrument { + instrument { + name + } + } + } +} + +subscription OrderEvent($partyId: ID!) { + busEvents(partyId: $partyId, batchSize: 0, types: [Order]) { + type + event { + ... on Order { + ...OrderEventFields + } + } + } +} diff --git a/libs/orders/src/lib/order-hooks/Orders.graphql b/libs/orders/src/lib/order-hooks/Orders.graphql deleted file mode 100644 index af33337c1..000000000 --- a/libs/orders/src/lib/order-hooks/Orders.graphql +++ /dev/null @@ -1,96 +0,0 @@ -fragment OrderFields on Order { - id - market { - id - decimalPlaces - positionDecimalPlaces - tradableInstrument { - instrument { - id - code - } - } - } - type - side - size - status - rejectionReason - price - timeInForce - remaining - expiresAt - createdAt - updatedAt -} - -query Orders($partyId: ID!, $pagination: Pagination) { - party(id: $partyId) { - id - ordersConnection(pagination: $pagination) { - edges { - node { - ...OrderFields - } - cursor - } - pageInfo { - startCursor - endCursor - hasNextPage - hasPreviousPage - } - } - } -} - -subscription OrderSub($partyId: ID!) { - orders(partyId: $partyId) { - id - price - timeInForce - side - marketId - size - remaining - partyId - createdAt - expiresAt - status - reference - type - rejectionReason - version - updatedAt - peggedOrder { - reference - offset - } - liquidityProvisionId - } -} - -subscription OrderEvent($partyId: ID!) { - busEvents(partyId: $partyId, batchSize: 0, types: [Order]) { - type - event { - ... on Order { - type - id - status - rejectionReason - createdAt - size - price - timeInForce - expiresAt - side - market { - id - decimalPlaces - positionDecimalPlaces - } - } - } - } -} diff --git a/libs/orders/src/lib/order-hooks/__generated__/OrderEvent.ts b/libs/orders/src/lib/order-hooks/__generated__/OrderEvent.ts deleted file mode 100644 index 6161620f6..000000000 --- a/libs/orders/src/lib/order-hooks/__generated__/OrderEvent.ts +++ /dev/null @@ -1,139 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// @generated -// This file was automatically generated and should not be edited. - -import { BusEventType, OrderType, OrderStatus, OrderRejectionReason, OrderTimeInForce, Side } from "@vegaprotocol/types"; - -// ==================================================== -// GraphQL subscription operation: OrderEvent -// ==================================================== - -export interface OrderEvent_busEvents_event_TimeUpdate { - __typename: "TimeUpdate" | "MarketEvent" | "TransferResponses" | "PositionResolution" | "Trade" | "Account" | "Party" | "MarginLevels" | "Proposal" | "Vote" | "MarketData" | "NodeSignature" | "LossSocialization" | "SettlePosition" | "Market" | "Asset" | "MarketTick" | "SettleDistressed" | "AuctionEvent" | "RiskFactor" | "Deposit" | "Withdrawal" | "OracleSpec" | "LiquidityProvision" | "TransactionResult"; -} - -export interface OrderEvent_busEvents_event_Order_market_tradableInstrument_instrument { - __typename: "Instrument"; - /** - * Full and fairly descriptive name for the instrument - */ - name: string; -} - -export interface OrderEvent_busEvents_event_Order_market_tradableInstrument { - __typename: "TradableInstrument"; - /** - * An instance of, or reference to, a fully specified instrument. - */ - instrument: OrderEvent_busEvents_event_Order_market_tradableInstrument_instrument; -} - -export interface OrderEvent_busEvents_event_Order_market { - __typename: "Market"; - /** - * Market ID - */ - id: string; - /** - * An instance of, or reference to, a tradable instrument. - */ - tradableInstrument: OrderEvent_busEvents_event_Order_market_tradableInstrument; - /** - * 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; - /** - * 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; -} - -export interface OrderEvent_busEvents_event_Order { - __typename: "Order"; - /** - * The order type - */ - type: OrderType | null; - /** - * Hash of the order data - */ - id: string; - /** - * The status of an order, for example 'Active' - */ - status: OrderStatus; - /** - * Why the order was rejected - */ - rejectionReason: OrderRejectionReason | null; - /** - * RFC3339Nano formatted date and time for when the order was created (timestamp) - */ - createdAt: string; - /** - * Total number of units that may be bought or sold (immutable) (uint64) - */ - size: string; - /** - * The worst price the order will trade at (e.g. buy for price or less, sell for price or more) (uint64) - */ - price: string; - /** - * The timeInForce of order (determines how and if it executes, and whether it persists on the book) - */ - timeInForce: OrderTimeInForce; - /** - * Expiration time of this order (ISO-8601 RFC3339+Nano formatted date) - */ - expiresAt: string | null; - /** - * Whether the order is to buy or sell - */ - side: Side; - /** - * The market the order is trading on (probably stored internally as a hash of the market details) - */ - market: OrderEvent_busEvents_event_Order_market; -} - -export type OrderEvent_busEvents_event = OrderEvent_busEvents_event_TimeUpdate | OrderEvent_busEvents_event_Order; - -export interface OrderEvent_busEvents { - __typename: "BusEvent"; - /** - * The type of event - */ - type: BusEventType; - /** - * The payload - the wrapped event - */ - event: OrderEvent_busEvents_event; -} - -export interface OrderEvent { - /** - * Subscribe to event data from the event bus - */ - busEvents: OrderEvent_busEvents[] | null; -} - -export interface OrderEventVariables { - partyId: string; -} diff --git a/libs/orders/src/lib/order-hooks/__generated___/OrderEvent.ts b/libs/orders/src/lib/order-hooks/__generated___/OrderEvent.ts new file mode 100644 index 000000000..5a8e532f7 --- /dev/null +++ b/libs/orders/src/lib/order-hooks/__generated___/OrderEvent.ts @@ -0,0 +1,73 @@ +import { Schema as Types } from '@vegaprotocol/types'; + +import { gql } from '@apollo/client'; +import * as Apollo from '@apollo/client'; +const defaultOptions = {} as const; +export type OrderEventFieldsFragment = { __typename?: 'Order', type?: Types.OrderType | null, id: string, status: Types.OrderStatus, rejectionReason?: Types.OrderRejectionReason | null, createdAt: string, size: string, price: string, timeInForce: Types.OrderTimeInForce, expiresAt?: string | null, side: Types.Side, market: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string } } } }; + +export type OrderEventSubscriptionVariables = Types.Exact<{ + partyId: Types.Scalars['ID']; +}>; + + +export type OrderEventSubscription = { __typename?: 'Subscription', busEvents?: Array<{ __typename?: 'BusEvent', type: Types.BusEventType, event: { __typename?: 'AccountEvent' } | { __typename?: 'Asset' } | { __typename?: 'AuctionEvent' } | { __typename?: 'Deposit' } | { __typename?: 'LiquidityProvision' } | { __typename?: 'LossSocialization' } | { __typename?: 'MarginLevels' } | { __typename?: 'Market' } | { __typename?: 'MarketData' } | { __typename?: 'MarketEvent' } | { __typename?: 'MarketTick' } | { __typename?: 'NodeSignature' } | { __typename?: 'OracleSpec' } | { __typename?: 'Order', type?: Types.OrderType | null, id: string, status: Types.OrderStatus, rejectionReason?: Types.OrderRejectionReason | null, createdAt: string, size: string, price: string, timeInForce: Types.OrderTimeInForce, expiresAt?: string | null, side: Types.Side, market: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string } } } } | { __typename?: 'Party' } | { __typename?: 'PositionResolution' } | { __typename?: 'Proposal' } | { __typename?: 'RiskFactor' } | { __typename?: 'SettleDistressed' } | { __typename?: 'SettlePosition' } | { __typename?: 'TimeUpdate' } | { __typename?: 'Trade' } | { __typename?: 'TransactionResult' } | { __typename?: 'TransferResponses' } | { __typename?: 'Vote' } | { __typename?: 'Withdrawal' } }> | null }; + +export const OrderEventFieldsFragmentDoc = gql` + fragment OrderEventFields on Order { + type + id + status + rejectionReason + createdAt + size + price + timeInForce + expiresAt + side + market { + id + decimalPlaces + positionDecimalPlaces + tradableInstrument { + instrument { + name + } + } + } +} + `; +export const OrderEventDocument = gql` + subscription OrderEvent($partyId: ID!) { + busEvents(partyId: $partyId, batchSize: 0, types: [Order]) { + type + event { + ... on Order { + ...OrderEventFields + } + } + } +} + ${OrderEventFieldsFragmentDoc}`; + +/** + * __useOrderEventSubscription__ + * + * To run a query within a React component, call `useOrderEventSubscription` and pass it any options that fit your needs. + * When your component renders, `useOrderEventSubscription` 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 } = useOrderEventSubscription({ + * variables: { + * partyId: // value for 'partyId' + * }, + * }); + */ +export function useOrderEventSubscription(baseOptions: Apollo.SubscriptionHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useSubscription(OrderEventDocument, options); + } +export type OrderEventSubscriptionHookResult = ReturnType; +export type OrderEventSubscriptionResult = Apollo.SubscriptionResult; \ No newline at end of file diff --git a/libs/orders/src/lib/order-hooks/__generated___/Orders.ts b/libs/orders/src/lib/order-hooks/__generated___/Orders.ts deleted file mode 100644 index dcdffe07b..000000000 --- a/libs/orders/src/lib/order-hooks/__generated___/Orders.ts +++ /dev/null @@ -1,205 +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 OrderFieldsFragment = { __typename?: 'Order', id: string, type?: Types.OrderType | null, side: Types.Side, size: string, status: Types.OrderStatus, rejectionReason?: Types.OrderRejectionReason | null, price: string, timeInForce: Types.OrderTimeInForce, remaining: string, expiresAt?: string | null, createdAt: string, updatedAt?: string | null, market: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, code: string } } } }; - -export type OrdersQueryVariables = Types.Exact<{ - partyId: Types.Scalars['ID']; - pagination?: Types.InputMaybe; -}>; - - -export type OrdersQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, ordersConnection?: { __typename?: 'OrderConnection', edges?: Array<{ __typename?: 'OrderEdge', cursor?: string | null, node: { __typename?: 'Order', id: string, type?: Types.OrderType | null, side: Types.Side, size: string, status: Types.OrderStatus, rejectionReason?: Types.OrderRejectionReason | null, price: string, timeInForce: Types.OrderTimeInForce, remaining: string, expiresAt?: string | null, createdAt: string, updatedAt?: string | null, market: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, code: string } } } } }> | null, pageInfo?: { __typename?: 'PageInfo', startCursor: string, endCursor: string, hasNextPage: boolean, hasPreviousPage: boolean } | null } | null } | null }; - -export type OrderSubSubscriptionVariables = Types.Exact<{ - partyId: Types.Scalars['ID']; -}>; - - -export type OrderSubSubscription = { __typename?: 'Subscription', orders?: Array<{ __typename?: 'OrderUpdate', id: string, price: string, timeInForce: Types.OrderTimeInForce, side: Types.Side, marketId: string, size: string, remaining: string, partyId: string, createdAt: string, expiresAt?: string | null, status: Types.OrderStatus, reference: string, type?: Types.OrderType | null, rejectionReason?: Types.OrderRejectionReason | null, version: string, updatedAt?: string | null, liquidityProvisionId?: string | null, peggedOrder?: { __typename?: 'PeggedOrder', reference: Types.PeggedReference, offset: string } | null }> | null }; - -export type OrderEventSubscriptionVariables = Types.Exact<{ - partyId: Types.Scalars['ID']; -}>; - - -export type OrderEventSubscription = { __typename?: 'Subscription', busEvents?: Array<{ __typename?: 'BusEvent', type: Types.BusEventType, event: { __typename?: 'Account' } | { __typename?: 'Asset' } | { __typename?: 'AuctionEvent' } | { __typename?: 'Deposit' } | { __typename?: 'LiquidityProvision' } | { __typename?: 'LossSocialization' } | { __typename?: 'MarginLevels' } | { __typename?: 'Market' } | { __typename?: 'MarketData' } | { __typename?: 'MarketEvent' } | { __typename?: 'MarketTick' } | { __typename?: 'NodeSignature' } | { __typename?: 'OracleSpec' } | { __typename?: 'Order', type?: Types.OrderType | null, id: string, status: Types.OrderStatus, rejectionReason?: Types.OrderRejectionReason | null, createdAt: string, size: string, price: string, timeInForce: Types.OrderTimeInForce, expiresAt?: string | null, side: Types.Side, market: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number } } | { __typename?: 'Party' } | { __typename?: 'PositionResolution' } | { __typename?: 'Proposal' } | { __typename?: 'RiskFactor' } | { __typename?: 'SettleDistressed' } | { __typename?: 'SettlePosition' } | { __typename?: 'TimeUpdate' } | { __typename?: 'Trade' } | { __typename?: 'TransactionResult' } | { __typename?: 'TransferResponses' } | { __typename?: 'Vote' } | { __typename?: 'Withdrawal' } }> | null }; - -export const OrderFieldsFragmentDoc = gql` - fragment OrderFields on Order { - id - market { - id - decimalPlaces - positionDecimalPlaces - tradableInstrument { - instrument { - id - code - } - } - } - type - side - size - status - rejectionReason - price - timeInForce - remaining - expiresAt - createdAt - updatedAt -} - `; -export const OrdersDocument = gql` - query Orders($partyId: ID!, $pagination: Pagination) { - party(id: $partyId) { - id - ordersConnection(pagination: $pagination) { - edges { - node { - ...OrderFields - } - cursor - } - pageInfo { - startCursor - endCursor - hasNextPage - hasPreviousPage - } - } - } -} - ${OrderFieldsFragmentDoc}`; - -/** - * __useOrdersQuery__ - * - * To run a query within a React component, call `useOrdersQuery` and pass it any options that fit your needs. - * When your component renders, `useOrdersQuery` 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 } = useOrdersQuery({ - * variables: { - * partyId: // value for 'partyId' - * pagination: // value for 'pagination' - * }, - * }); - */ -export function useOrdersQuery(baseOptions: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(OrdersDocument, options); - } -export function useOrdersLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(OrdersDocument, options); - } -export type OrdersQueryHookResult = ReturnType; -export type OrdersLazyQueryHookResult = ReturnType; -export type OrdersQueryResult = Apollo.QueryResult; -export const OrderSubDocument = gql` - subscription OrderSub($partyId: ID!) { - orders(partyId: $partyId) { - id - price - timeInForce - side - marketId - size - remaining - partyId - createdAt - expiresAt - status - reference - type - rejectionReason - version - updatedAt - peggedOrder { - reference - offset - } - liquidityProvisionId - } -} - `; - -/** - * __useOrderSubSubscription__ - * - * To run a query within a React component, call `useOrderSubSubscription` and pass it any options that fit your needs. - * When your component renders, `useOrderSubSubscription` 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 } = useOrderSubSubscription({ - * variables: { - * partyId: // value for 'partyId' - * }, - * }); - */ -export function useOrderSubSubscription(baseOptions: Apollo.SubscriptionHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useSubscription(OrderSubDocument, options); - } -export type OrderSubSubscriptionHookResult = ReturnType; -export type OrderSubSubscriptionResult = Apollo.SubscriptionResult; -export const OrderEventDocument = gql` - subscription OrderEvent($partyId: ID!) { - busEvents(partyId: $partyId, batchSize: 0, types: [Order]) { - type - event { - ... on Order { - type - id - status - rejectionReason - createdAt - size - price - timeInForce - expiresAt - side - market { - id - decimalPlaces - positionDecimalPlaces - } - } - } - } -} - `; - -/** - * __useOrderEventSubscription__ - * - * To run a query within a React component, call `useOrderEventSubscription` and pass it any options that fit your needs. - * When your component renders, `useOrderEventSubscription` 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 } = useOrderEventSubscription({ - * variables: { - * partyId: // value for 'partyId' - * }, - * }); - */ -export function useOrderEventSubscription(baseOptions: Apollo.SubscriptionHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useSubscription(OrderEventDocument, options); - } -export type OrderEventSubscriptionHookResult = ReturnType; -export type OrderEventSubscriptionResult = Apollo.SubscriptionResult; \ No newline at end of file diff --git a/libs/orders/src/lib/order-hooks/index.ts b/libs/orders/src/lib/order-hooks/index.ts index a0639c824..bde41d256 100644 --- a/libs/orders/src/lib/order-hooks/index.ts +++ b/libs/orders/src/lib/order-hooks/index.ts @@ -1,5 +1,4 @@ -export * from './__generated__/OrderEvent'; -export * from './order-event-query'; +export * from './__generated___/OrderEvent'; export * from './use-order-cancel'; export * from './use-order-submit'; export * from './use-order-edit'; diff --git a/libs/orders/src/lib/order-hooks/order-event-query.ts b/libs/orders/src/lib/order-hooks/order-event-query.ts deleted file mode 100644 index 32b38193e..000000000 --- a/libs/orders/src/lib/order-hooks/order-event-query.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { gql } from '@apollo/client'; - -export const ORDER_EVENT_SUB = gql` - subscription OrderEvent($partyId: ID!) { - busEvents(partyId: $partyId, batchSize: 0, types: [Order]) { - type - event { - ... on Order { - type - id - status - rejectionReason - createdAt - size - price - timeInForce - expiresAt - side - market { - id - tradableInstrument { - instrument { - name - } - } - decimalPlaces - positionDecimalPlaces - } - } - } - } - } -`; diff --git a/libs/orders/src/lib/order-hooks/use-order-cancel.spec.tsx b/libs/orders/src/lib/order-hooks/use-order-cancel.spec.tsx index edcf6ffa6..b07b6efce 100644 --- a/libs/orders/src/lib/order-hooks/use-order-cancel.spec.tsx +++ b/libs/orders/src/lib/order-hooks/use-order-cancel.spec.tsx @@ -5,15 +5,9 @@ import type { ReactNode } from 'react'; import { VegaTxStatus, VegaWalletContext } from '@vegaprotocol/wallet'; import type { VegaWalletContextShape } from '@vegaprotocol/wallet'; import { useOrderCancel } from './use-order-cancel'; -import type { OrderEvent } from './'; -import { ORDER_EVENT_SUB } from './order-event-query'; -import { - BusEventType, - OrderStatus, - OrderTimeInForce, - OrderType, - Side, -} from '@vegaprotocol/types'; +import type { OrderEventSubscription } from './'; +import { OrderEventDocument } from './'; +import { Schema } from '@vegaprotocol/types'; const defaultWalletContext = { pubKey: null, @@ -26,9 +20,9 @@ const defaultWalletContext = { }; function setup(context?: Partial) { - const mocks: MockedResponse = { + const mocks: MockedResponse = { request: { - query: ORDER_EVENT_SUB, + query: OrderEventDocument, variables: { partyId: context?.pubKey || '', }, @@ -37,18 +31,18 @@ function setup(context?: Partial) { data: { busEvents: [ { - type: BusEventType.Order, + type: Schema.BusEventType.Order, event: { - type: OrderType.TYPE_LIMIT, + type: Schema.OrderType.TYPE_LIMIT, id: '9c70716f6c3698ac7bbcddc97176025b985a6bb9a0c4507ec09c9960b3216b62', - status: OrderStatus.STATUS_ACTIVE, + status: Schema.OrderStatus.STATUS_ACTIVE, rejectionReason: null, createdAt: '2022-07-05T14:25:47.815283706Z', expiresAt: '2022-07-05T14:25:47.815283706Z', size: '10', price: '300000', - timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC, - side: Side.SIDE_BUY, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, + side: Schema.Side.SIDE_BUY, market: { id: 'market-id', decimalPlaces: 5, @@ -70,9 +64,9 @@ function setup(context?: Partial) { }, }, }; - const filterMocks: MockedResponse = { + const filterMocks: MockedResponse = { request: { - query: ORDER_EVENT_SUB, + query: OrderEventDocument, variables: { partyId: context?.pubKey || '', }, @@ -81,18 +75,18 @@ function setup(context?: Partial) { data: { busEvents: [ { - type: BusEventType.Order, + type: Schema.BusEventType.Order, event: { - type: OrderType.TYPE_LIMIT, + type: Schema.OrderType.TYPE_LIMIT, id: '9c70716f6c3698ac7bbcddc97176025b985a6bb9a0c4507ec09c9960b3216b62', - status: OrderStatus.STATUS_ACTIVE, + status: Schema.OrderStatus.STATUS_ACTIVE, rejectionReason: null, createdAt: '2022-07-05T14:25:47.815283706Z', expiresAt: '2022-07-05T14:25:47.815283706Z', size: '10', price: '300000', - timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC, - side: Side.SIDE_BUY, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, + side: Schema.Side.SIDE_BUY, market: { id: 'market-id', decimalPlaces: 5, diff --git a/libs/orders/src/lib/order-hooks/use-order-cancel.tsx b/libs/orders/src/lib/order-hooks/use-order-cancel.tsx index e4d7f748f..1cec94cdb 100644 --- a/libs/orders/src/lib/order-hooks/use-order-cancel.tsx +++ b/libs/orders/src/lib/order-hooks/use-order-cancel.tsx @@ -1,6 +1,6 @@ import { useCallback, useState } from 'react'; import { useVegaWallet, useVegaTransaction } from '@vegaprotocol/wallet'; -import type { OrderEvent_busEvents_event_Order } from './'; +import type { OrderEventFieldsFragment } from './'; import * as Sentry from '@sentry/react'; import { useOrderEvent } from './use-order-event'; @@ -13,7 +13,7 @@ export const useOrderCancel = () => { const { pubKey } = useVegaWallet(); const [cancelledOrder, setCancelledOrder] = - useState(null); + useState(null); const { send, diff --git a/libs/orders/src/lib/order-hooks/use-order-edit.spec.tsx b/libs/orders/src/lib/order-hooks/use-order-edit.spec.tsx index 9148fea54..31c048c8e 100644 --- a/libs/orders/src/lib/order-hooks/use-order-edit.spec.tsx +++ b/libs/orders/src/lib/order-hooks/use-order-edit.spec.tsx @@ -3,19 +3,13 @@ import type { VegaWalletContextShape } from '@vegaprotocol/wallet'; import { VegaTxStatus, VegaWalletContext } from '@vegaprotocol/wallet'; import type { ReactNode } from 'react'; import { useOrderEdit } from './use-order-edit'; -import type { OrderEvent } from './'; -import { ORDER_EVENT_SUB } from './order-event-query'; +import type { OrderEventSubscription } from './__generated___/OrderEvent'; +import { OrderEventDocument } from './__generated___/OrderEvent'; import type { MockedResponse } from '@apollo/client/testing'; import { MockedProvider } from '@apollo/client/testing'; -import type { OrderWithMarket } from '../components'; +import type { Order } from '../components'; import { generateOrder } from '../components'; -import { - OrderStatus, - OrderType, - OrderTimeInForce, - Side, - BusEventType, -} from '@vegaprotocol/types'; +import { Schema } from '@vegaprotocol/types'; const defaultWalletContext = { pubKey: null, @@ -27,13 +21,10 @@ const defaultWalletContext = { connector: null, }; -function setup( - order: OrderWithMarket, - context?: Partial -) { - const mocks: MockedResponse = { +function setup(order: Order, context?: Partial) { + const mocks: MockedResponse = { request: { - query: ORDER_EVENT_SUB, + query: OrderEventDocument, variables: { partyId: context?.pubKey || '', }, @@ -42,18 +33,18 @@ function setup( data: { busEvents: [ { - type: BusEventType.Order, + type: Schema.BusEventType.Order, event: { - type: OrderType.TYPE_LIMIT, + type: Schema.OrderType.TYPE_LIMIT, id: '9c70716f6c3698ac7bbcddc97176025b985a6bb9a0c4507ec09c9960b3216b62', - status: OrderStatus.STATUS_ACTIVE, + status: Schema.OrderStatus.STATUS_ACTIVE, rejectionReason: null, createdAt: '2022-07-05T14:25:47.815283706Z', expiresAt: '2022-07-05T14:25:47.815283706Z', size: '10', price: '300000', - timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC, - side: Side.SIDE_BUY, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, + side: Schema.Side.SIDE_BUY, market: { id: 'market-id', decimalPlaces: 5, @@ -75,9 +66,9 @@ function setup( }, }, }; - const filterMocks: MockedResponse = { + const filterMocks: MockedResponse = { request: { - query: ORDER_EVENT_SUB, + query: OrderEventDocument, variables: { partyId: context?.pubKey || '', }, @@ -86,18 +77,18 @@ function setup( data: { busEvents: [ { - type: BusEventType.Order, + type: Schema.BusEventType.Order, event: { - type: OrderType.TYPE_LIMIT, + type: Schema.OrderType.TYPE_LIMIT, id: '9c70716f6c3698ac7bbcddc97176025b985a6bb9a0c4507ec09c9960b3216b62', - status: OrderStatus.STATUS_ACTIVE, + status: Schema.OrderStatus.STATUS_ACTIVE, rejectionReason: null, createdAt: '2022-07-05T14:25:47.815283706Z', expiresAt: '2022-07-05T14:25:47.815283706Z', size: '10', price: '300000', - timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC, - side: Side.SIDE_BUY, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, + side: Schema.Side.SIDE_BUY, market: { id: 'market-id', decimalPlaces: 5, diff --git a/libs/orders/src/lib/order-hooks/use-order-edit.tsx b/libs/orders/src/lib/order-hooks/use-order-edit.tsx index 597984b1e..ea0d4df1f 100644 --- a/libs/orders/src/lib/order-hooks/use-order-edit.tsx +++ b/libs/orders/src/lib/order-hooks/use-order-edit.tsx @@ -1,7 +1,7 @@ import { removeDecimal, toNanoSeconds } from '@vegaprotocol/react-helpers'; import { useState, useCallback } from 'react'; import { useVegaTransaction, useVegaWallet } from '@vegaprotocol/wallet'; -import type { OrderEvent_busEvents_event_Order } from './'; +import type { OrderEventFieldsFragment } from './'; import * as Sentry from '@sentry/react'; import type { Order } from '../components'; import { useOrderEvent } from './use-order-event'; @@ -15,7 +15,7 @@ export const useOrderEdit = (order: Order | null) => { const { pubKey } = useVegaWallet(); const [updatedOrder, setUpdatedOrder] = - useState(null); + useState(null); const { send, diff --git a/libs/orders/src/lib/order-hooks/use-order-event.ts b/libs/orders/src/lib/order-hooks/use-order-event.ts index a929e4dee..b2e6cb700 100644 --- a/libs/orders/src/lib/order-hooks/use-order-event.ts +++ b/libs/orders/src/lib/order-hooks/use-order-event.ts @@ -1,19 +1,19 @@ import { useApolloClient } from '@apollo/client'; import { useCallback, useEffect, useRef } from 'react'; -import { ORDER_EVENT_SUB } from './order-event-query'; +import { OrderEventDocument } from './__generated___/OrderEvent'; import type { - OrderEvent, - OrderEventVariables, - OrderEvent_busEvents_event_Order, -} from './'; + OrderEventSubscription, + OrderEventSubscriptionVariables, + OrderEventFieldsFragment, +} from './__generated___/OrderEvent'; import type { Subscription } from 'zen-observable-ts'; import type { VegaTxState } from '@vegaprotocol/wallet'; -import { BusEventType } from '@vegaprotocol/types'; +import { Schema } from '@vegaprotocol/types'; type WaitFunc = ( orderId: string, partyId: string -) => Promise; +) => Promise; export const useOrderEvent = (transaction: VegaTxState) => { const client = useApolloClient(); @@ -23,8 +23,8 @@ export const useOrderEvent = (transaction: VegaTxState) => { (id: string, partyId: string) => { return new Promise((resolve) => { subRef.current = client - .subscribe({ - query: ORDER_EVENT_SUB, + .subscribe({ + query: OrderEventDocument, variables: { partyId }, }) .subscribe(({ data }) => { @@ -34,7 +34,7 @@ export const useOrderEvent = (transaction: VegaTxState) => { // No types available for the subscription result const matchingOrderEvent = data.busEvents.find((e) => { - if (e.event.__typename !== BusEventType.Order) { + if (e.event.__typename !== Schema.BusEventType.Order) { return false; } @@ -43,7 +43,7 @@ export const useOrderEvent = (transaction: VegaTxState) => { if ( matchingOrderEvent && - matchingOrderEvent.event.__typename === BusEventType.Order + matchingOrderEvent.event.__typename === Schema.BusEventType.Order ) { resolve(matchingOrderEvent.event); subRef.current?.unsubscribe(); diff --git a/libs/orders/src/lib/order-hooks/use-order-submit.spec.tsx b/libs/orders/src/lib/order-hooks/use-order-submit.spec.tsx index ca2d70a75..450324b10 100644 --- a/libs/orders/src/lib/order-hooks/use-order-submit.spec.tsx +++ b/libs/orders/src/lib/order-hooks/use-order-submit.spec.tsx @@ -1,20 +1,12 @@ import { act, renderHook } from '@testing-library/react'; import type { PubKey, VegaWalletContextShape } from '@vegaprotocol/wallet'; import { VegaTxStatus, VegaWalletContext } from '@vegaprotocol/wallet'; -import { - BusEventType, - MarketState, - MarketTradingMode, - OrderStatus, - OrderTimeInForce, - OrderType, - Side, -} from '@vegaprotocol/types'; +import { MarketState, MarketTradingMode, Schema } from '@vegaprotocol/types'; import type { ReactNode } from 'react'; import type { OrderSubmissionBody } from '@vegaprotocol/wallet'; import { useOrderSubmit } from './use-order-submit'; -import type { OrderEvent } from './'; -import { ORDER_EVENT_SUB } from './order-event-query'; +import type { OrderEventSubscription } from './'; +import { OrderEventDocument } from './'; import type { MockedResponse } from '@apollo/client/testing'; import { MockedProvider } from '@apollo/client/testing'; import { toNanoSeconds } from '@vegaprotocol/react-helpers'; @@ -56,9 +48,9 @@ const defaultWalletContext = { }; function setup(context?: Partial) { - const mocks: MockedResponse = { + const mocks: MockedResponse = { request: { - query: ORDER_EVENT_SUB, + query: OrderEventDocument, variables: { partyId: context?.pubKey || '', }, @@ -67,18 +59,18 @@ function setup(context?: Partial) { data: { busEvents: [ { - type: BusEventType.Order, + type: Schema.BusEventType.Order, event: { - type: OrderType.TYPE_LIMIT, + type: Schema.OrderType.TYPE_LIMIT, id: '9c70716f6c3698ac7bbcddc97176025b985a6bb9a0c4507ec09c9960b3216b62', - status: OrderStatus.STATUS_ACTIVE, + status: Schema.OrderStatus.STATUS_ACTIVE, rejectionReason: null, createdAt: '2022-07-05T14:25:47.815283706Z', expiresAt: '2022-07-05T14:25:47.815283706Z', size: '10', price: '300000', - timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC, - side: Side.SIDE_BUY, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, + side: Schema.Side.SIDE_BUY, market: { id: 'market-id', decimalPlaces: 5, @@ -100,9 +92,9 @@ function setup(context?: Partial) { }, }, }; - const filterMocks: MockedResponse = { + const filterMocks: MockedResponse = { request: { - query: ORDER_EVENT_SUB, + query: OrderEventDocument, variables: { partyId: context?.pubKey || '', }, @@ -111,18 +103,18 @@ function setup(context?: Partial) { data: { busEvents: [ { - type: BusEventType.Order, + type: Schema.BusEventType.Order, event: { - type: OrderType.TYPE_LIMIT, + type: Schema.OrderType.TYPE_LIMIT, id: '9c70716f6c3698ac7bbcddc97176025b985a6bb9a0c4507ec09c9960b3216b62', - status: OrderStatus.STATUS_ACTIVE, + status: Schema.OrderStatus.STATUS_ACTIVE, rejectionReason: null, createdAt: '2022-07-05T14:25:47.815283706Z', expiresAt: '2022-07-05T14:25:47.815283706Z', size: '10', price: '300000', - timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC, - side: Side.SIDE_BUY, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, + side: Schema.Side.SIDE_BUY, market: { id: 'market-id', decimalPlaces: 5, @@ -168,10 +160,10 @@ describe('useOrderSubmit', () => { }); const order = { - type: OrderType.TYPE_LIMIT, + type: Schema.OrderType.TYPE_LIMIT, size: '10', - timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTT, - side: Side.SIDE_BUY, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTT, + side: Schema.Side.SIDE_BUY, price: '123456789', expiresAt: new Date('2022-01-01').toISOString(), }; @@ -181,11 +173,11 @@ describe('useOrderSubmit', () => { expect(mockSendTx).toHaveBeenCalledWith(pubKey, { orderSubmission: { - type: OrderType.TYPE_LIMIT, + type: Schema.OrderType.TYPE_LIMIT, marketId: defaultMarket.id, size: '10', - side: Side.SIDE_BUY, - timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTT, + side: Schema.Side.SIDE_BUY, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTT, price: '123456789', expiresAt: toNanoSeconds(order.expiresAt), }, @@ -205,10 +197,10 @@ describe('useOrderSubmit', () => { }); const order = { - type: OrderType.TYPE_LIMIT, + type: Schema.OrderType.TYPE_LIMIT, size: '10', - timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC, - side: Side.SIDE_BUY, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, + side: Schema.Side.SIDE_BUY, price: '123456789', expiresAt: new Date('2022-01-01').toISOString(), }; @@ -218,11 +210,11 @@ describe('useOrderSubmit', () => { expect(mockSendTx).toHaveBeenCalledWith(publicKeyObj.publicKey, { orderSubmission: { - type: OrderType.TYPE_LIMIT, + type: Schema.OrderType.TYPE_LIMIT, marketId: defaultMarket.id, size: '10', - side: Side.SIDE_BUY, - timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC, + side: Schema.Side.SIDE_BUY, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, price: '123456789', expiresAt: undefined, }, diff --git a/libs/orders/src/lib/order-hooks/use-order-submit.tsx b/libs/orders/src/lib/order-hooks/use-order-submit.tsx index 16d001126..6251c4bab 100644 --- a/libs/orders/src/lib/order-hooks/use-order-submit.tsx +++ b/libs/orders/src/lib/order-hooks/use-order-submit.tsx @@ -1,40 +1,39 @@ import { useCallback, useState } from 'react'; import type { ReactNode } from 'react'; -import type { OrderEvent_busEvents_event_Order } from './__generated__/OrderEvent'; +import type { OrderEventFieldsFragment } from './__generated___/OrderEvent'; import { useVegaWallet } from '@vegaprotocol/wallet'; import { toNanoSeconds } from '@vegaprotocol/react-helpers'; import { useVegaTransaction, determineId } from '@vegaprotocol/wallet'; import * as Sentry from '@sentry/react'; import { useOrderEvent } from './use-order-event'; -import { OrderTimeInForce } from '@vegaprotocol/types'; -import { OrderType, OrderStatus } from '@vegaprotocol/types'; +import { Schema } from '@vegaprotocol/types'; import { Icon, Intent } from '@vegaprotocol/ui-toolkit'; import { t } from '@vegaprotocol/react-helpers'; import type { OrderSubmissionBody } from '@vegaprotocol/wallet'; 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'); @@ -42,22 +41,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; @@ -65,19 +64,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; @@ -98,7 +97,7 @@ export const useOrderSubmit = () => { const waitForOrderEvent = useOrderEvent(transaction); const [finalizedOrder, setFinalizedOrder] = - useState(null); + useState(null); const reset = useCallback(() => { resetTransaction(); @@ -118,12 +117,12 @@ export const useOrderSubmit = () => { orderSubmission: { ...order, price: - order.type === OrderType.TYPE_LIMIT && order.price + order.type === Schema.OrderType.TYPE_LIMIT && order.price ? order.price : undefined, expiresAt: order.expiresAt && - order.timeInForce === OrderTimeInForce.TIME_IN_FORCE_GTT + order.timeInForce === Schema.OrderTimeInForce.TIME_IN_FORCE_GTT ? toNanoSeconds(order.expiresAt) // Wallet expects timestamp in nanoseconds : undefined, }, diff --git a/libs/orders/src/lib/utils.ts b/libs/orders/src/lib/utils.ts index 9ec50833c..1ff5109a2 100644 --- a/libs/orders/src/lib/utils.ts +++ b/libs/orders/src/lib/utils.ts @@ -1,20 +1,20 @@ import { t } from '@vegaprotocol/react-helpers'; -import { OrderTimeInForce } from '@vegaprotocol/types'; +import { Schema } from '@vegaprotocol/types'; // 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); diff --git a/libs/positions/project.json b/libs/positions/project.json index f9bb943cb..4c9c6f50e 100644 --- a/libs/positions/project.json +++ b/libs/positions/project.json @@ -69,6 +69,13 @@ "quiet": true } } + }, + "build-spec": { + "executor": "@nrwl/workspace:run-commands", + "outputs": [], + "options": { + "command": "yarn tsc --project ./libs/positions/tsconfig.spec.json" + } } } } diff --git a/libs/positions/src/lib/close-position-dialog/complete.tsx b/libs/positions/src/lib/close-position-dialog/complete.tsx index 4ead9d4e6..f7dbb2da4 100644 --- a/libs/positions/src/lib/close-position-dialog/complete.tsx +++ b/libs/positions/src/lib/close-position-dialog/complete.tsx @@ -1,7 +1,7 @@ import { useEnvironment } from '@vegaprotocol/environment'; -import type { OrderEvent_busEvents_event_Order } from '@vegaprotocol/orders'; +import type { OrderEventFieldsFragment } from '@vegaprotocol/orders'; import { t, truncateByChars } from '@vegaprotocol/react-helpers'; -import { OrderRejectionReasonMapping, OrderStatus } from '@vegaprotocol/types'; +import { OrderRejectionReasonMapping, Schema } from '@vegaprotocol/types'; import { Link } from '@vegaprotocol/ui-toolkit'; import type { TransactionResult, VegaTxState } from '@vegaprotocol/wallet'; import type { ClosingOrder as IClosingOrder } from '../use-close-position'; @@ -13,7 +13,7 @@ interface CompleteProps { transaction: VegaTxState; transactionResult?: TransactionResult; closingOrder?: IClosingOrder; - closingOrderResult?: OrderEvent_busEvents_event_Order; + closingOrderResult?: OrderEventFieldsFragment; } export const Complete = ({ @@ -29,7 +29,7 @@ export const Complete = ({ return ( <> - {closingOrderResult.status === OrderStatus.STATUS_FILLED && + {closingOrderResult.status === Schema.OrderStatus.STATUS_FILLED && transactionResult.status ? ( ) : ( @@ -89,7 +89,7 @@ const Error = ({ closingOrderResult, }: { transactionResult: TransactionResult; - closingOrderResult: OrderEvent_busEvents_event_Order; + closingOrderResult: OrderEventFieldsFragment; }) => { const reason = closingOrderResult.rejectionReason && diff --git a/libs/positions/src/lib/close-position-dialog/requested.spec.tsx b/libs/positions/src/lib/close-position-dialog/requested.spec.tsx index edfc89491..c91c22af5 100644 --- a/libs/positions/src/lib/close-position-dialog/requested.spec.tsx +++ b/libs/positions/src/lib/close-position-dialog/requested.spec.tsx @@ -1,5 +1,5 @@ import { render, screen, within } from '@testing-library/react'; -import { OrderTimeInForce, OrderType, Side } from '@vegaprotocol/types'; +import { Schema } from '@vegaprotocol/types'; import * as dataHook from '../use-request-close-position-data'; import { Requested } from './requested'; @@ -10,15 +10,16 @@ describe('Close position dialog - Request', () => { partyId: 'party-id', order: { marketId: 'market-id', - type: OrderType.TYPE_MARKET as const, - timeInForce: OrderTimeInForce.TIME_IN_FORCE_FOK as const, - side: Side.SIDE_BUY, + type: Schema.OrderType.TYPE_MARKET as const, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_FOK as const, + side: Schema.Side.SIDE_BUY, size: '10', }, }; it('loading state', async () => { jest.spyOn(dataHook, 'useRequestClosePositionData').mockReturnValue({ + loading: false, market: null, marketData: null, orders: [], @@ -32,14 +33,14 @@ describe('Close position dialog - Request', () => { { size: '200', price: '999', - side: Side.SIDE_BUY, - timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC, + side: Schema.Side.SIDE_BUY, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, }, { size: '300', price: '888', - side: Side.SIDE_SELL, - timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC, + side: Schema.Side.SIDE_SELL, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC, }, ]; jest.spyOn(dataHook, 'useRequestClosePositionData').mockReturnValue({ diff --git a/libs/positions/src/lib/positions-data-providers.spec.ts b/libs/positions/src/lib/positions-data-providers.spec.ts index 8981ac92c..be8e3f8b8 100644 --- a/libs/positions/src/lib/positions-data-providers.spec.ts +++ b/libs/positions/src/lib/positions-data-providers.spec.ts @@ -6,7 +6,7 @@ import { getMetrics, rejoinPositionData } from './positions-data-providers'; const accounts = [ { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_GENERAL, asset: { __typename: 'Asset', @@ -18,7 +18,7 @@ const accounts = [ market: null, }, { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_MARGIN, asset: { __typename: 'Asset', @@ -40,7 +40,7 @@ const accounts = [ }, }, { - __typename: 'Account', + __typename: 'AccountBalance', type: AccountType.ACCOUNT_TYPE_MARGIN, asset: { __typename: 'Asset', diff --git a/libs/positions/src/lib/positions-table.stories.tsx b/libs/positions/src/lib/positions-table.stories.tsx index 65a4cce55..8df777804 100644 --- a/libs/positions/src/lib/positions-table.stories.tsx +++ b/libs/positions/src/lib/positions-table.stories.tsx @@ -1,3 +1,4 @@ +import BigNumber from 'bignumber.js'; import type { Story, Meta } from '@storybook/react'; import { PositionsTable } from './positions-table'; import type { Position } from './positions-data-providers'; @@ -28,7 +29,7 @@ const longPosition: Position = { // leverageSearch: '0', liquidationPrice: '1129935', lowMarginLevel: false, - // marginAccountBalance: '0', + marginAccountBalance: new BigNumber('0'), // marginMaintenance: '0', // marginSearch: '0', // marginInitial: '0', @@ -60,7 +61,7 @@ const shortPosition: Position = { // leverageSearch: '0', liquidationPrice: '23734', lowMarginLevel: false, - // marginAccountBalance: '0', + marginAccountBalance: new BigNumber('0'), // marginMaintenance: '0', // marginSearch: '0', // marginInitial: '0', diff --git a/libs/positions/src/lib/use-close-position.spec.tsx b/libs/positions/src/lib/use-close-position.spec.tsx index 98aff9335..43d794ff3 100644 --- a/libs/positions/src/lib/use-close-position.spec.tsx +++ b/libs/positions/src/lib/use-close-position.spec.tsx @@ -2,14 +2,7 @@ import type { ReactNode } from 'react'; import type { MockedResponse } from '@apollo/client/testing'; import { MockedProvider } from '@apollo/client/testing'; import { renderHook, waitFor } from '@testing-library/react'; -import { - BusEventType, - OrderStatus, - OrderTimeInForce, - OrderType, - Schema as Types, - Side, -} from '@vegaprotocol/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { useClosePosition } from './use-close-position'; import { VegaTxStatus, VegaWalletContext } from '@vegaprotocol/wallet'; import type { VegaWalletContextShape } from '@vegaprotocol/wallet'; @@ -17,8 +10,8 @@ import { initialState } from '@vegaprotocol/wallet'; import type { TransactionEventSubscription } from '@vegaprotocol/wallet'; import { TransactionEventDocument } from '@vegaprotocol/wallet'; import { act } from 'react-dom/test-utils'; -import type { OrderEvent } from '@vegaprotocol/orders'; -import { ORDER_EVENT_SUB } from '@vegaprotocol/orders'; +import type { OrderEventSubscription } from '@vegaprotocol/orders'; +import { OrderEventDocument } from '@vegaprotocol/orders'; const pubKey = 'test-pubkey'; const defaultWalletContext = { @@ -58,9 +51,9 @@ function setup(context?: Partial) { }, }, }; - const mockOrderResult: MockedResponse = { + const mockOrderResult: MockedResponse = { request: { - query: ORDER_EVENT_SUB, + query: OrderEventDocument, variables: { partyId: context?.pubKey || '', }, @@ -69,18 +62,18 @@ function setup(context?: Partial) { data: { busEvents: [ { - type: BusEventType.Order, + type: Types.BusEventType.Order, event: { - type: OrderType.TYPE_LIMIT, + type: Types.OrderType.TYPE_LIMIT, id: '2fca514cebf9f465ae31ecb4c5721e3a6f5f260425ded887ca50ba15b81a5d50', - status: OrderStatus.STATUS_ACTIVE, + status: Types.OrderStatus.STATUS_ACTIVE, rejectionReason: null, createdAt: '2022-07-05T14:25:47.815283706Z', expiresAt: '2022-07-05T14:25:47.815283706Z', size: '10', price: '300000', - timeInForce: OrderTimeInForce.TIME_IN_FORCE_GTC, - side: Side.SIDE_BUY, + timeInForce: Types.OrderTimeInForce.TIME_IN_FORCE_GTC, + side: Types.Side.SIDE_BUY, market: { id: 'market-id', decimalPlaces: 5, @@ -164,9 +157,9 @@ describe('useClosePosition', () => { submissions: [ { marketId, - type: OrderType.TYPE_MARKET, - timeInForce: OrderTimeInForce.TIME_IN_FORCE_FOK, - side: Side.SIDE_SELL, + type: Types.OrderType.TYPE_MARKET, + timeInForce: Types.OrderTimeInForce.TIME_IN_FORCE_FOK, + side: Types.Side.SIDE_SELL, size: openVolume, }, ], @@ -208,9 +201,9 @@ describe('useClosePosition', () => { submissions: [ { marketId, - type: OrderType.TYPE_MARKET, - timeInForce: OrderTimeInForce.TIME_IN_FORCE_FOK, - side: Side.SIDE_BUY, + type: Types.OrderType.TYPE_MARKET, + timeInForce: Types.OrderTimeInForce.TIME_IN_FORCE_FOK, + side: Types.Side.SIDE_BUY, size: openVolume.replace('-', ''), }, ], diff --git a/libs/positions/src/lib/use-close-position.ts b/libs/positions/src/lib/use-close-position.ts index 467a9d1f8..ee08834c2 100644 --- a/libs/positions/src/lib/use-close-position.ts +++ b/libs/positions/src/lib/use-close-position.ts @@ -4,15 +4,15 @@ import { determineId } from '@vegaprotocol/wallet'; import { useVegaWallet, useTransactionResult } from '@vegaprotocol/wallet'; import { useVegaTransaction } from '@vegaprotocol/wallet'; import * as Sentry from '@sentry/react'; -import { OrderTimeInForce, OrderType, Side } from '@vegaprotocol/types'; +import { Schema } from '@vegaprotocol/types'; import { useOrderEvent } from '@vegaprotocol/orders'; -import type { OrderEvent_busEvents_event_Order } from '@vegaprotocol/orders'; +import type { OrderEventFieldsFragment } from '@vegaprotocol/orders'; export interface ClosingOrder { marketId: string; - type: OrderType.TYPE_MARKET; - timeInForce: OrderTimeInForce.TIME_IN_FORCE_FOK; - side: Side; + type: Schema.OrderType.TYPE_MARKET; + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_FOK; + side: Schema.Side; size: string; } @@ -21,7 +21,7 @@ export const useClosePosition = () => { const { send, transaction, setComplete, Dialog } = useVegaTransaction(); const [closingOrder, setClosingOrder] = useState(); const [closingOrderResult, setClosingOrderResult] = - useState(); + useState(); const [transactionResult, setTransactionResult] = useState(); const waitForTransactionResult = useTransactionResult(); @@ -45,15 +45,15 @@ export const useClosePosition = () => { try { // figure out if opsition is long or short and make side the opposite const side = openVolume.startsWith('-') - ? Side.SIDE_BUY - : Side.SIDE_SELL; + ? Schema.Side.SIDE_BUY + : Schema.Side.SIDE_SELL; // volume could be prefixed with '-' if position is short, remove it const size = openVolume.replace('-', ''); const closingOrder = { marketId: marketId, - type: OrderType.TYPE_MARKET as const, - timeInForce: OrderTimeInForce.TIME_IN_FORCE_FOK as const, + type: Schema.OrderType.TYPE_MARKET as const, + timeInForce: Schema.OrderTimeInForce.TIME_IN_FORCE_FOK as const, side, size, }; diff --git a/libs/react-helpers/project.json b/libs/react-helpers/project.json index 4c69783a6..d8d9c3d6a 100644 --- a/libs/react-helpers/project.json +++ b/libs/react-helpers/project.json @@ -38,6 +38,13 @@ "jestConfig": "libs/react-helpers/jest.config.ts", "passWithNoTests": true } + }, + "build-spec": { + "executor": "@nrwl/workspace:run-commands", + "outputs": [], + "options": { + "command": "yarn tsc --project ./libs/react-helpers/tsconfig.spec.json" + } } } } diff --git a/libs/react-helpers/src/hooks/use-network-params.spec.tsx b/libs/react-helpers/src/hooks/use-network-params.spec.tsx index 4e2cf31a8..8fce6ebd4 100644 --- a/libs/react-helpers/src/hooks/use-network-params.spec.tsx +++ b/libs/react-helpers/src/hooks/use-network-params.spec.tsx @@ -10,7 +10,7 @@ import { useNetworkParams, } from './use-network-params'; import type { ReactNode } from 'react'; -import type { NetworkParams as NetworkParamsResponse } from './__generated__'; +import type { NetworkParams as NetworkParamsResponse } from './__generated__/NetworkParams'; describe('useNetworkParam', () => { const setup = (arg: NetworkParamsKey) => { diff --git a/libs/react-helpers/src/lib/format/date.ts b/libs/react-helpers/src/lib/format/date.ts index b06a71002..3bc6c39da 100644 --- a/libs/react-helpers/src/lib/format/date.ts +++ b/libs/react-helpers/src/lib/format/date.ts @@ -1,6 +1,9 @@ import once from 'lodash/once'; import { getUserLocale } from './utils'; +export const isValidDate = (date: Date) => + date instanceof Date && !isNaN(date.getTime()); + export const getTimeFormat = once( () => new Intl.DateTimeFormat(getUserLocale(), { diff --git a/libs/react-helpers/src/lib/generic-data-provider.ts b/libs/react-helpers/src/lib/generic-data-provider.ts index f99898bdc..9e51ac356 100644 --- a/libs/react-helpers/src/lib/generic-data-provider.ts +++ b/libs/react-helpers/src/lib/generic-data-provider.ts @@ -7,7 +7,7 @@ import type { } from '@apollo/client'; import type { Subscription } from 'zen-observable-ts'; import isEqual from 'lodash/isEqual'; -import type { Pagination as PaginationWithoutSkip } from '@vegaprotocol/types'; +import type { Schema } from '@vegaprotocol/types'; export interface UpdateDelta { delta?: Delta; @@ -35,7 +35,7 @@ export interface Load { (start?: number, end?: number): Promise; } -type Pagination = PaginationWithoutSkip & { +type Pagination = Schema.Pagination & { skip?: number; }; diff --git a/libs/react-helpers/src/lib/grid/size.tsx b/libs/react-helpers/src/lib/grid/size.tsx index adc16c05a..522740d47 100644 --- a/libs/react-helpers/src/lib/grid/size.tsx +++ b/libs/react-helpers/src/lib/grid/size.tsx @@ -1,4 +1,4 @@ -import { Side } from '@vegaprotocol/types'; +import { Schema } from '@vegaprotocol/types'; import type { ICellRendererParams } from 'ag-grid-community'; import classNames from 'classnames'; import { addDecimalsFormatNumber } from '../format'; @@ -9,18 +9,23 @@ export const Size = ({ positionDecimalPlaces = 0, }: { value: string; - side: Side; + side: Schema.Side; positionDecimalPlaces?: number; }) => { return ( - {side === Side.SIDE_BUY ? '+' : side === Side.SIDE_SELL ? '-' : ''} + {side === Schema.Side.SIDE_BUY + ? '+' + : side === Schema.Side.SIDE_SELL + ? '-' + : ''} {addDecimalsFormatNumber(value, positionDecimalPlaces)} ); diff --git a/libs/react-helpers/tsconfig.spec.json b/libs/react-helpers/tsconfig.spec.json index a85d573fc..3da863401 100644 --- a/libs/react-helpers/tsconfig.spec.json +++ b/libs/react-helpers/tsconfig.spec.json @@ -3,7 +3,7 @@ "compilerOptions": { "outDir": "../../dist/out-tsc", "module": "commonjs", - "types": ["jest", "node"] + "types": ["jest", "node", "@testing-library/jest-dom"] }, "include": [ "**/*.test.ts", diff --git a/libs/smart-contracts/project.json b/libs/smart-contracts/project.json index 9ef0555f2..3481a5610 100644 --- a/libs/smart-contracts/project.json +++ b/libs/smart-contracts/project.json @@ -26,6 +26,13 @@ "jestConfig": "libs/smart-contracts/jest.config.ts", "passWithNoTests": true } + }, + "build-spec": { + "executor": "@nrwl/workspace:run-commands", + "outputs": [], + "options": { + "command": "yarn tsc --project ./libs/smart-contracts/tsconfig.spec.json" + } } }, "tags": [] diff --git a/libs/trades/project.json b/libs/trades/project.json index 4e665116b..4a9e041fd 100644 --- a/libs/trades/project.json +++ b/libs/trades/project.json @@ -38,6 +38,13 @@ "jestConfig": "libs/trades/jest.config.ts", "passWithNoTests": true } + }, + "build-spec": { + "executor": "@nrwl/workspace:run-commands", + "outputs": [], + "options": { + "command": "yarn tsc --project ./libs/trades/tsconfig.spec.json" + } } } } diff --git a/libs/trades/src/lib/trades-table.spec.tsx b/libs/trades/src/lib/trades-table.spec.tsx index f27f20593..849b52608 100644 --- a/libs/trades/src/lib/trades-table.spec.tsx +++ b/libs/trades/src/lib/trades-table.spec.tsx @@ -1,9 +1,9 @@ import { act, render, screen } from '@testing-library/react'; import { getDateTimeFormat } from '@vegaprotocol/react-helpers'; import { DOWN_CLASS, TradesTable, UP_CLASS } from './trades-table'; -import type { TradeFields } from './__generated__/TradeFields'; +import type { Trade } from './trades-data-provider'; -const trade: TradeFields = { +const trade: Trade = { __typename: 'Trade', id: 'trade-id', price: '111122200', @@ -14,7 +14,7 @@ const trade: TradeFields = { id: 'market-id', decimalPlaces: 2, positionDecimalPlaces: 2, - }, + } as Trade['market'], }; it('Correct columns are rendered', async () => { diff --git a/libs/types/src/__generated__/globalTypes.ts b/libs/types/src/__generated__/globalTypes.ts index 5014a1f80..c8eb23eba 100644 --- a/libs/types/src/__generated__/globalTypes.ts +++ b/libs/types/src/__generated__/globalTypes.ts @@ -44,36 +44,6 @@ export enum AuctionTrigger { AUCTION_TRIGGER_UNSPECIFIED = "AUCTION_TRIGGER_UNSPECIFIED", } -export enum BusEventType { - Account = "Account", - Asset = "Asset", - Auction = "Auction", - Deposit = "Deposit", - LiquidityProvision = "LiquidityProvision", - LossSocialization = "LossSocialization", - MarginLevels = "MarginLevels", - Market = "Market", - MarketCreated = "MarketCreated", - MarketData = "MarketData", - MarketTick = "MarketTick", - MarketUpdated = "MarketUpdated", - NodeSignature = "NodeSignature", - OracleSpec = "OracleSpec", - Order = "Order", - Party = "Party", - PositionResolution = "PositionResolution", - Proposal = "Proposal", - RiskFactor = "RiskFactor", - SettleDistressed = "SettleDistressed", - SettlePosition = "SettlePosition", - TimeUpdate = "TimeUpdate", - Trade = "Trade", - TransactionResult = "TransactionResult", - TransferResponses = "TransferResponses", - Vote = "Vote", - Withdrawal = "Withdrawal", -} - /** * Comparator describes the type of comparison. */ @@ -85,18 +55,6 @@ export enum ConditionOperator { OPERATOR_LESS_THAN_OR_EQUAL = "OPERATOR_LESS_THAN_OR_EQUAL", } -/** - * Status of a liquidity provision order - */ -export enum LiquidityProvisionStatus { - STATUS_ACTIVE = "STATUS_ACTIVE", - STATUS_CANCELLED = "STATUS_CANCELLED", - STATUS_PENDING = "STATUS_PENDING", - STATUS_REJECTED = "STATUS_REJECTED", - STATUS_STOPPED = "STATUS_STOPPED", - STATUS_UNDEPLOYED = "STATUS_UNDEPLOYED", -} - /** * The current state of a market */ @@ -139,88 +97,6 @@ export enum OracleSpecStatus { STATUS_DEACTIVATED = "STATUS_DEACTIVATED", } -/** - * Why the order was rejected by the core node - */ -export enum OrderRejectionReason { - ORDER_ERROR_AMEND_FAILURE = "ORDER_ERROR_AMEND_FAILURE", - ORDER_ERROR_BUY_CANNOT_REFERENCE_BEST_ASK_PRICE = "ORDER_ERROR_BUY_CANNOT_REFERENCE_BEST_ASK_PRICE", - ORDER_ERROR_CANNOT_AMEND_FROM_GFA_OR_GFN = "ORDER_ERROR_CANNOT_AMEND_FROM_GFA_OR_GFN", - ORDER_ERROR_CANNOT_AMEND_PEGGED_ORDER_DETAILS_ON_NON_PEGGED_ORDER = "ORDER_ERROR_CANNOT_AMEND_PEGGED_ORDER_DETAILS_ON_NON_PEGGED_ORDER", - ORDER_ERROR_CANNOT_AMEND_TO_FOK_OR_IOC = "ORDER_ERROR_CANNOT_AMEND_TO_FOK_OR_IOC", - ORDER_ERROR_CANNOT_AMEND_TO_GFA_OR_GFN = "ORDER_ERROR_CANNOT_AMEND_TO_GFA_OR_GFN", - ORDER_ERROR_CANNOT_AMEND_TO_GTT_WITHOUT_EXPIRYAT = "ORDER_ERROR_CANNOT_AMEND_TO_GTT_WITHOUT_EXPIRYAT", - ORDER_ERROR_CANNOT_HAVE_GTC_AND_EXPIRYAT = "ORDER_ERROR_CANNOT_HAVE_GTC_AND_EXPIRYAT", - ORDER_ERROR_CANNOT_SEND_FOK_ORDER_DURING_AUCTION = "ORDER_ERROR_CANNOT_SEND_FOK_ORDER_DURING_AUCTION", - ORDER_ERROR_CANNOT_SEND_IOC_ORDER_DURING_AUCTION = "ORDER_ERROR_CANNOT_SEND_IOC_ORDER_DURING_AUCTION", - ORDER_ERROR_EDIT_NOT_ALLOWED = "ORDER_ERROR_EDIT_NOT_ALLOWED", - ORDER_ERROR_EXPIRYAT_BEFORE_CREATEDAT = "ORDER_ERROR_EXPIRYAT_BEFORE_CREATEDAT", - ORDER_ERROR_GFA_ORDER_DURING_CONTINUOUS_TRADING = "ORDER_ERROR_GFA_ORDER_DURING_CONTINUOUS_TRADING", - ORDER_ERROR_GFN_ORDER_DURING_AN_AUCTION = "ORDER_ERROR_GFN_ORDER_DURING_AN_AUCTION", - ORDER_ERROR_INSUFFICIENT_ASSET_BALANCE = "ORDER_ERROR_INSUFFICIENT_ASSET_BALANCE", - ORDER_ERROR_INSUFFICIENT_FUNDS_TO_PAY_FEES = "ORDER_ERROR_INSUFFICIENT_FUNDS_TO_PAY_FEES", - ORDER_ERROR_INTERNAL_ERROR = "ORDER_ERROR_INTERNAL_ERROR", - ORDER_ERROR_INVALID_EXPIRATION_DATETIME = "ORDER_ERROR_INVALID_EXPIRATION_DATETIME", - ORDER_ERROR_INVALID_MARKET_ID = "ORDER_ERROR_INVALID_MARKET_ID", - ORDER_ERROR_INVALID_ORDER_ID = "ORDER_ERROR_INVALID_ORDER_ID", - ORDER_ERROR_INVALID_ORDER_REFERENCE = "ORDER_ERROR_INVALID_ORDER_REFERENCE", - ORDER_ERROR_INVALID_PARTY_ID = "ORDER_ERROR_INVALID_PARTY_ID", - ORDER_ERROR_INVALID_PERSISTENCE = "ORDER_ERROR_INVALID_PERSISTENCE", - ORDER_ERROR_INVALID_REMAINING_SIZE = "ORDER_ERROR_INVALID_REMAINING_SIZE", - ORDER_ERROR_INVALID_SIZE = "ORDER_ERROR_INVALID_SIZE", - ORDER_ERROR_INVALID_TIME_IN_FORCE = "ORDER_ERROR_INVALID_TIME_IN_FORCE", - ORDER_ERROR_INVALID_TYPE = "ORDER_ERROR_INVALID_TYPE", - ORDER_ERROR_MARGIN_CHECK_FAILED = "ORDER_ERROR_MARGIN_CHECK_FAILED", - ORDER_ERROR_MARKET_CLOSED = "ORDER_ERROR_MARKET_CLOSED", - ORDER_ERROR_MISSING_GENERAL_ACCOUNT = "ORDER_ERROR_MISSING_GENERAL_ACCOUNT", - ORDER_ERROR_MUST_BE_GTT_OR_GTC = "ORDER_ERROR_MUST_BE_GTT_OR_GTC", - ORDER_ERROR_MUST_BE_LIMIT_ORDER = "ORDER_ERROR_MUST_BE_LIMIT_ORDER", - ORDER_ERROR_NON_PERSISTENT_ORDER_OUT_OF_PRICE_BOUNDS = "ORDER_ERROR_NON_PERSISTENT_ORDER_OUT_OF_PRICE_BOUNDS", - ORDER_ERROR_NOT_FOUND = "ORDER_ERROR_NOT_FOUND", - ORDER_ERROR_OFFSET_MUST_BE_GREATER_OR_EQUAL_TO_ZERO = "ORDER_ERROR_OFFSET_MUST_BE_GREATER_OR_EQUAL_TO_ZERO", - ORDER_ERROR_OFFSET_MUST_BE_GREATER_THAN_ZERO = "ORDER_ERROR_OFFSET_MUST_BE_GREATER_THAN_ZERO", - ORDER_ERROR_OUT_OF_SEQUENCE = "ORDER_ERROR_OUT_OF_SEQUENCE", - ORDER_ERROR_REMOVAL_FAILURE = "ORDER_ERROR_REMOVAL_FAILURE", - ORDER_ERROR_SELF_TRADING = "ORDER_ERROR_SELF_TRADING", - ORDER_ERROR_SELL_CANNOT_REFERENCE_BEST_BID_PRICE = "ORDER_ERROR_SELL_CANNOT_REFERENCE_BEST_BID_PRICE", - ORDER_ERROR_TIME_FAILURE = "ORDER_ERROR_TIME_FAILURE", - ORDER_ERROR_UNABLE_TO_AMEND_PRICE_ON_PEGGED_ORDER = "ORDER_ERROR_UNABLE_TO_AMEND_PRICE_ON_PEGGED_ORDER", - ORDER_ERROR_UNABLE_TO_REPRICE_PEGGED_ORDER = "ORDER_ERROR_UNABLE_TO_REPRICE_PEGGED_ORDER", - ORDER_ERROR_WITHOUT_REFERENCE_PRICE = "ORDER_ERROR_WITHOUT_REFERENCE_PRICE", -} - -/** - * Valid order statuses, these determine several states for an order that cannot be expressed with other fields in Order. - */ -export enum OrderStatus { - STATUS_ACTIVE = "STATUS_ACTIVE", - STATUS_CANCELLED = "STATUS_CANCELLED", - STATUS_EXPIRED = "STATUS_EXPIRED", - STATUS_FILLED = "STATUS_FILLED", - STATUS_PARKED = "STATUS_PARKED", - STATUS_PARTIALLY_FILLED = "STATUS_PARTIALLY_FILLED", - STATUS_REJECTED = "STATUS_REJECTED", - STATUS_STOPPED = "STATUS_STOPPED", -} - -/** - * Valid order types, these determine what happens when an order is added to the book - */ -export enum OrderTimeInForce { - TIME_IN_FORCE_FOK = "TIME_IN_FORCE_FOK", - TIME_IN_FORCE_GFA = "TIME_IN_FORCE_GFA", - TIME_IN_FORCE_GFN = "TIME_IN_FORCE_GFN", - TIME_IN_FORCE_GTC = "TIME_IN_FORCE_GTC", - TIME_IN_FORCE_GTT = "TIME_IN_FORCE_GTT", - TIME_IN_FORCE_IOC = "TIME_IN_FORCE_IOC", -} - -export enum OrderType { - TYPE_LIMIT = "TYPE_LIMIT", - TYPE_MARKET = "TYPE_MARKET", - TYPE_NETWORK = "TYPE_NETWORK", -} - /** * Type describes the type of properties that are supported by the oracle * engine. @@ -296,14 +172,6 @@ export enum ProposalState { STATE_WAITING_FOR_NODE_VOTE = "STATE_WAITING_FOR_NODE_VOTE", } -/** - * Whether the placer of an order is aiming to buy or sell on the market - */ -export enum Side { - SIDE_BUY = "SIDE_BUY", - SIDE_SELL = "SIDE_SELL", -} - /** * The status of the stake linking */ @@ -333,16 +201,6 @@ export enum WithdrawalStatus { STATUS_REJECTED = "STATUS_REJECTED", } -/** - * Pagination constructs to support cursor based pagination in the API - */ -export interface Pagination { - first?: number | null; - after?: string | null; - last?: number | null; - before?: string | null; -} - //============================================================== // END Enums and Input Objects //============================================================== diff --git a/libs/types/src/__generated__/types.ts b/libs/types/src/__generated__/types.ts index beb228360..5374b1d76 100644 --- a/libs/types/src/__generated__/types.ts +++ b/libs/types/src/__generated__/types.ts @@ -15,8 +15,8 @@ export type Scalars = { }; /** An account record */ -export type Account = { - __typename?: 'Account'; +export type AccountBalance = { + __typename?: 'AccountBalance'; /** Asset, the 'currency' */ asset: Asset; /** Balance as string - current account balance (approx. as balances can be updated several times per second) */ @@ -50,11 +50,25 @@ export type AccountEdge = { /** Cursor identifying the account */ cursor: Scalars['String']; /** The account */ - node: Account; + node: AccountBalance; +}; + +/** An account record */ +export type AccountEvent = { + __typename?: 'AccountEvent'; + /** Asset, the 'currency' */ + asset: Asset; + /** Balance as string - current account balance (approx. as balances can be updated several times per second) */ + balance: Scalars['String']; + /** Market (only relevant to margin accounts) */ + market?: Maybe; + /** Owner of the account */ + party?: Maybe; + /** Account type (General, Margin, etc) */ + type: AccountType; }; export enum AccountField { - AccountId = 'AccountId', AccountType = 'AccountType', AssetId = 'AssetId', MarketId = 'MarketId', @@ -136,8 +150,6 @@ export type AccountsConnection = { export type AggregatedBalance = { __typename?: 'AggregatedBalance'; - /** Account identifier, if query was grouped by account - else null */ - accountId?: Maybe; /** Account type, if query was grouped by account type - else null */ accountType?: Maybe; /** Asset identifier, if query was grouped by asset - else null */ @@ -146,7 +158,7 @@ export type AggregatedBalance = { balance: Scalars['String']; /** Market identifier, if query was grouped by market - else null */ marketId?: Maybe; - /** Party identifier, if query was grouped by party - else null */ + /** Account identifier, if query was grouped by account - else null */ partyId?: Maybe; /** RFC3339Nano time from at which this balance was relevant */ timestamp: Scalars['Timestamp']; @@ -171,7 +183,6 @@ export type AggregatedLedgerEntries = { accountType?: Maybe; /** Asset identifier, if query was grouped by asset - else null */ assetId?: Maybe; - id?: Maybe; /** Market identifier, if query was grouped by market - else null */ marketId?: Maybe; /** Party identifier, if query was grouped by party - else null */ @@ -201,17 +212,17 @@ export type Asset = { /** The precision of the asset. Should match the decimal precision of the asset on its native chain, e.g: for ERC20 assets, it is often 18 */ decimals: Scalars['Int']; /** The global reward pool account for this asset */ - globalRewardPoolAccount?: Maybe; + globalRewardPoolAccount?: Maybe; /** The ID of the asset */ id: Scalars['ID']; /** The infrastructure fee account for this asset */ - infrastructureFeeAccount: Account; + infrastructureFeeAccount?: Maybe; /** The liquidity provision reward account for this asset */ - lpFeeRewardAccount?: Maybe; + lpFeeRewardAccount?: Maybe; /** The maker fee reward account for this asset */ - makerFeeRewardAccount?: Maybe; + makerFeeRewardAccount?: Maybe; /** The market proposer reward account for this asset */ - marketProposerRewardAccount?: Maybe; + marketProposerRewardAccount?: Maybe; /** The full name of the asset (e.g: Great British Pound) */ name: Scalars['String']; /** The minimum economically meaningful amount in the asset */ @@ -223,7 +234,7 @@ export type Asset = { /** The symbol of the asset (e.g: GBP) */ symbol: Scalars['String']; /** The taker fee reward account for this asset */ - takerFeeRewardAccount?: Maybe; + takerFeeRewardAccount?: Maybe; }; /** Edge type containing the asset and cursor information returned by a AssetsConnection */ @@ -586,12 +597,13 @@ export type ERC20 = { contractAddress: Scalars['String']; /** * The lifetime limits deposit per address - * Note: this is a temporary measure for alpha mainnet + * Note: this is a temporary measure that can be changed by governance */ lifetimeLimit: Scalars['String']; /** - * The maximum allowed per withdrawal - * Note: this is a temporary measure for alpha mainnet + * The maximum you can withdraw instantly. All withdrawals over the threshold will be delayed by the withdrawal delay. + * There’s no limit on the size of a withdrawal + * Note: this is a temporary measure that can be changed by governance */ withdrawThreshold: Scalars['String']; }; @@ -841,7 +853,7 @@ export type EthereumKeyRotationsConnection = { }; /** Union type for wrapped events in stream PROPOSAL is mapped to governance data, something to keep in mind */ -export type Event = Account | Asset | AuctionEvent | Deposit | LiquidityProvision | LossSocialization | MarginLevels | Market | MarketData | MarketEvent | MarketTick | NodeSignature | OracleSpec | Order | Party | PositionResolution | Proposal | RiskFactor | SettleDistressed | SettlePosition | TimeUpdate | Trade | TransactionResult | TransferResponses | Vote | Withdrawal; +export type Event = AccountEvent | Asset | AuctionEvent | Deposit | LiquidityProvision | LossSocialization | MarginLevels | Market | MarketData | MarketEvent | MarketTick | NodeSignature | OracleSpec | Order | Party | PositionResolution | Proposal | RiskFactor | SettleDistressed | SettlePosition | TimeUpdate | Trade | TransactionResult | TransferResponses | Vote | Withdrawal; /** The factors applied to calculate the fees */ export type FeeFactors = { @@ -917,6 +929,19 @@ export type GroupOptions = { ByLedgerEntryField?: InputMaybe>>; }; +/** A segment of datanode history */ +export type HistorySegment = { + __typename?: 'HistorySegment'; + /** Chain ID of the history segment */ + chainID: Scalars['String']; + /** From block height of the history segment */ + fromHeight: Scalars['Int']; + /** ID of the history segment */ + historySegmentId: Scalars['String']; + /** To block height of the history segment */ + toHeight: Scalars['Int']; +}; + /** Describes something that can be traded on Vega */ export type Instrument = { __typename?: 'Instrument'; @@ -1016,8 +1041,8 @@ export enum LedgerEntryField { /** Filter for historical entry ledger queries */ export type LedgerEntryFilter = { - AccountFromFilters?: InputMaybe>>; - AccountToFilters?: InputMaybe>>; + AccountFromFilter?: InputMaybe; + AccountToFilter?: InputMaybe; CloseOnAccountFilters?: InputMaybe; TransferTypes?: InputMaybe>>; }; @@ -1262,7 +1287,7 @@ export type Market = { * Get account for a party or market * @deprecated Use the accountsConnection instead */ - accounts?: Maybe>; + accounts?: Maybe>; /** Get account for a party or market */ accountsConnection?: Maybe; /** Candles on a market, for the 'last' n candles, at 'interval' seconds as specified by parameters using cursor based pagination */ @@ -2243,6 +2268,8 @@ export enum OrderRejectionReason { ORDER_ERROR_CANNOT_HAVE_GTC_AND_EXPIRYAT = 'ORDER_ERROR_CANNOT_HAVE_GTC_AND_EXPIRYAT', /** Cannot send FOK orders during an auction */ ORDER_ERROR_CANNOT_SEND_FOK_ORDER_DURING_AUCTION = 'ORDER_ERROR_CANNOT_SEND_FOK_ORDER_DURING_AUCTION', + /** Good for Normal order received during an auction */ + ORDER_ERROR_CANNOT_SEND_GFN_ORDER_DURING_AN_AUCTION = 'ORDER_ERROR_CANNOT_SEND_GFN_ORDER_DURING_AN_AUCTION', /** Cannot send IOC orders during an auction */ ORDER_ERROR_CANNOT_SEND_IOC_ORDER_DURING_AUCTION = 'ORDER_ERROR_CANNOT_SEND_IOC_ORDER_DURING_AUCTION', /** Edit is not allowed */ @@ -2250,9 +2277,7 @@ export enum OrderRejectionReason { /** Attempt to amend expiry time to a value before time order was created */ ORDER_ERROR_EXPIRYAT_BEFORE_CREATEDAT = 'ORDER_ERROR_EXPIRYAT_BEFORE_CREATEDAT', /** Good for Auction order received during continuous trading */ - ORDER_ERROR_GFA_ORDER_DURING_CONTINUOUS_TRADING = 'ORDER_ERROR_GFA_ORDER_DURING_CONTINUOUS_TRADING', - /** Good for Normal order received during an auction */ - ORDER_ERROR_GFN_ORDER_DURING_AN_AUCTION = 'ORDER_ERROR_GFN_ORDER_DURING_AN_AUCTION', + ORDER_ERROR_GFA_CANNOT_SEND_ORDER_DURING_CONTINUOUS_TRADING = 'ORDER_ERROR_GFA_CANNOT_SEND_ORDER_DURING_CONTINUOUS_TRADING', /** Insufficient balance to submit the order (no deposit made) */ ORDER_ERROR_INSUFFICIENT_ASSET_BALANCE = 'ORDER_ERROR_INSUFFICIENT_ASSET_BALANCE', /** Insufficient funds to pay fees */ @@ -2442,7 +2467,7 @@ export type Party = { * Collateral accounts relating to a party * @deprecated Use accountsConnection instead */ - accounts?: Maybe>; + accounts?: Maybe>; /** Collateral accounts relating to a party */ accountsConnection?: Maybe; /** @deprecated Use delegationsConnection instead */ @@ -3198,6 +3223,12 @@ export type ProposalsConnection = { pageInfo: PageInfo; }; +/** Indicator showing whether the data-node is ready for the protocol upgrade to begin. */ +export type ProtocolUpgradeStatus = { + __typename?: 'ProtocolUpgradeStatus'; + ready: Scalars['Boolean']; +}; + /** Queries allow a caller to read data and filter data via GraphQL. */ export type Query = { __typename?: 'Query'; @@ -3210,6 +3241,8 @@ export type Query = { assets?: Maybe>; /** The list of all assets in use in the Vega network or the specified asset if ID is provided */ assetsConnection?: Maybe; + /** Get historical balances for an account within the given date range */ + balanceChanges: AggregatedBalanceConnection; /** Find a deposit using its ID */ deposit?: Maybe; /** Fetch all deposits */ @@ -3237,8 +3270,6 @@ export type Query = { getMarketDataHistoryByID?: Maybe>>; /** Get market data history for a specific market. If no dates are given, the latest snapshot will be returned. If only the start date is provided all history from the given date will be provided, and if only the end date is provided, all history from the start up to and including the end date will be provided. Pagination is provided using a cursor based pagination model */ getMarketDataHistoryConnectionByID?: Maybe; - /** Get historical balances for an account or specific asset within the given date range. */ - historicBalances: AggregatedBalanceConnection; /** * Query for historic key rotations * @deprecated use keyRotationsConnection instead @@ -3259,6 +3290,8 @@ export type Query = { markets?: Maybe>; /** One or more instruments that are trading on the Vega network */ marketsConnection?: Maybe; + /** The most recent history segment */ + mostRecentHistorySegment: HistorySegment; /** Current network limits */ networkLimits?: Maybe; /** Return a single network parameter */ @@ -3360,6 +3393,8 @@ export type Query = { proposals?: Maybe>; /** All governance proposals in the Vega network */ proposalsConnection?: Maybe; + /** Flag indicating whether the data-node is ready to begin the protocol upgrade */ + protocolUpgradeStatus?: Maybe; /** Get statistics about the Vega node */ statistics: Statistics; /** @@ -3394,6 +3429,14 @@ export type QueryassetsConnectionArgs = { }; +/** Queries allow a caller to read data and filter data via GraphQL. */ +export type QuerybalanceChangesArgs = { + dateRange?: InputMaybe; + filter?: InputMaybe; + pagination?: InputMaybe; +}; + + /** Queries allow a caller to read data and filter data via GraphQL. */ export type QuerydepositArgs = { id: Scalars['ID']; @@ -3488,15 +3531,6 @@ export type QuerygetMarketDataHistoryConnectionByIDArgs = { }; -/** Queries allow a caller to read data and filter data via GraphQL. */ -export type QueryhistoricBalancesArgs = { - dateRange?: InputMaybe; - filter?: InputMaybe; - groupBy?: InputMaybe>>; - pagination?: InputMaybe; -}; - - /** Queries allow a caller to read data and filter data via GraphQL. */ export type QuerykeyRotationsArgs = { id?: InputMaybe; @@ -4422,6 +4456,8 @@ export type Transfer = { id: Scalars['ID']; /** The type of transfer being made, i.e. a one-off or recurring transfer */ kind: TransferKind; + /** An optional reason explaining the status of the transfer */ + reason?: Maybe; /** An optional reference */ reference?: Maybe; /** The status of this transfer */ @@ -4543,12 +4579,13 @@ export type UpdateERC20 = { __typename?: 'UpdateERC20'; /** * The lifetime limits deposit per address - * Note: this is a temporary measure for alpha mainnet + * Note: this is a temporary measure that can be changed by governance */ lifetimeLimit: Scalars['String']; /** - * The maximum allowed per withdrawal - * Note: this is a temporary measure for alpha mainnet + * The maximum you can withdraw instantly. All withdrawals over the threshold will be delayed by the withdrawal delay. + * There’s no limit on the size of a withdrawal + * Note: this is a temporary measure that can be changed by governance */ withdrawThreshold: Scalars['String']; }; diff --git a/libs/types/src/global-types-mappings.ts b/libs/types/src/global-types-mappings.ts index 86af068cb..d7808b9b3 100644 --- a/libs/types/src/global-types-mappings.ts +++ b/libs/types/src/global-types-mappings.ts @@ -110,11 +110,11 @@ export enum OrderRejectionReasonMapping { ORDER_ERROR_CANNOT_AMEND_TO_GTT_WITHOUT_EXPIRYAT = 'Cannot amend to GTT without expiry time specified', ORDER_ERROR_CANNOT_HAVE_GTC_AND_EXPIRYAT = 'Cannot have GTC and expiry time specified', ORDER_ERROR_CANNOT_SEND_FOK_ORDER_DURING_AUCTION = 'Cannot send FOK order during auction', + ORDER_ERROR_CANNOT_SEND_GFN_ORDER_DURING_AN_AUCTION = 'Cannot send GFN order during auction', ORDER_ERROR_CANNOT_SEND_IOC_ORDER_DURING_AUCTION = 'Cannot send IOC order during auction', ORDER_ERROR_EDIT_NOT_ALLOWED = 'Edit not allowed', ORDER_ERROR_EXPIRYAT_BEFORE_CREATEDAT = 'Expiry time before creation time', - ORDER_ERROR_GFA_ORDER_DURING_CONTINUOUS_TRADING = 'GFA order during continuous trading', - ORDER_ERROR_GFN_ORDER_DURING_AN_AUCTION = 'GFN order during an auction', + ORDER_ERROR_GFA_CANNOT_SEND_ORDER_DURING_CONTINUOUS_TRADING = 'Cannot send GFA order during continuous trading', ORDER_ERROR_INSUFFICIENT_ASSET_BALANCE = 'Insufficient asset balance', ORDER_ERROR_INSUFFICIENT_FUNDS_TO_PAY_FEES = 'Insufficient funds to pay fees', ORDER_ERROR_INTERNAL_ERROR = 'Internal error', diff --git a/libs/ui-toolkit/project.json b/libs/ui-toolkit/project.json index e1771990d..4928f7987 100644 --- a/libs/ui-toolkit/project.json +++ b/libs/ui-toolkit/project.json @@ -69,6 +69,13 @@ "quiet": true } } + }, + "build-spec": { + "executor": "@nrwl/workspace:run-commands", + "outputs": [], + "options": { + "command": "yarn tsc --project ./libs/ui-toolkit/tsconfig.spec.json" + } } } } diff --git a/libs/ui-toolkit/src/components/theme-switcher/theme-switcher.spec.tsx b/libs/ui-toolkit/src/components/theme-switcher/theme-switcher.spec.tsx index 33c6f28a4..630441d21 100644 --- a/libs/ui-toolkit/src/components/theme-switcher/theme-switcher.spec.tsx +++ b/libs/ui-toolkit/src/components/theme-switcher/theme-switcher.spec.tsx @@ -6,6 +6,7 @@ describe('ThemeSwitcher', () => { it('should render successfully', () => { const { baseElement } = render( { return; }} diff --git a/libs/ui-toolkit/src/components/vega-logo/vega-logo.tsx b/libs/ui-toolkit/src/components/vega-logo/vega-logo.tsx index 672105f54..991788d99 100644 --- a/libs/ui-toolkit/src/components/vega-logo/vega-logo.tsx +++ b/libs/ui-toolkit/src/components/vega-logo/vega-logo.tsx @@ -17,7 +17,7 @@ export const VegaLogo = () => { ); }; -export const VLogo = ({ className }: { className: string }) => { +export const VLogo = ({ className }: { className?: string }) => { return ( ; -export type TransactionEventSubscription = { __typename?: 'Subscription', busEvents?: Array<{ __typename?: 'BusEvent', type: Types.BusEventType, event: { __typename?: 'Account' } | { __typename?: 'Asset' } | { __typename?: 'AuctionEvent' } | { __typename?: 'Deposit' } | { __typename?: 'LiquidityProvision' } | { __typename?: 'LossSocialization' } | { __typename?: 'MarginLevels' } | { __typename?: 'Market' } | { __typename?: 'MarketData' } | { __typename?: 'MarketEvent' } | { __typename?: 'MarketTick' } | { __typename?: 'NodeSignature' } | { __typename?: 'OracleSpec' } | { __typename?: 'Order' } | { __typename?: 'Party' } | { __typename?: 'PositionResolution' } | { __typename?: 'Proposal' } | { __typename?: 'RiskFactor' } | { __typename?: 'SettleDistressed' } | { __typename?: 'SettlePosition' } | { __typename?: 'TimeUpdate' } | { __typename?: 'Trade' } | { __typename?: 'TransactionResult', partyId: string, hash: string, status: boolean, error?: string | null } | { __typename?: 'TransferResponses' } | { __typename?: 'Vote' } | { __typename?: 'Withdrawal' } }> | null }; +export type TransactionEventSubscription = { __typename?: 'Subscription', busEvents?: Array<{ __typename?: 'BusEvent', type: Types.BusEventType, event: { __typename?: 'AccountEvent' } | { __typename?: 'Asset' } | { __typename?: 'AuctionEvent' } | { __typename?: 'Deposit' } | { __typename?: 'LiquidityProvision' } | { __typename?: 'LossSocialization' } | { __typename?: 'MarginLevels' } | { __typename?: 'Market' } | { __typename?: 'MarketData' } | { __typename?: 'MarketEvent' } | { __typename?: 'MarketTick' } | { __typename?: 'NodeSignature' } | { __typename?: 'OracleSpec' } | { __typename?: 'Order' } | { __typename?: 'Party' } | { __typename?: 'PositionResolution' } | { __typename?: 'Proposal' } | { __typename?: 'RiskFactor' } | { __typename?: 'SettleDistressed' } | { __typename?: 'SettlePosition' } | { __typename?: 'TimeUpdate' } | { __typename?: 'Trade' } | { __typename?: 'TransactionResult', partyId: string, hash: string, status: boolean, error?: string | null } | { __typename?: 'TransferResponses' } | { __typename?: 'Vote' } | { __typename?: 'Withdrawal' } }> | null }; export const TransactionEventDocument = gql` diff --git a/libs/wallet/src/connectors/vega-connector.ts b/libs/wallet/src/connectors/vega-connector.ts index 6c2e022ed..1abffc88f 100644 --- a/libs/wallet/src/connectors/vega-connector.ts +++ b/libs/wallet/src/connectors/vega-connector.ts @@ -1,9 +1,4 @@ -import type { - OrderTimeInForce, - OrderType, - Side, - VoteValue, -} from '@vegaprotocol/types'; +import type { Schema, VoteValue } from '@vegaprotocol/types'; export interface DelegateSubmissionBody { delegateSubmission: { @@ -23,9 +18,9 @@ export interface UndelegateSubmissionBody { interface OrderSubmission { marketId: string; reference?: string; - type: OrderType; - side: Side; - timeInForce: OrderTimeInForce; + type: Schema.OrderType; + side: Schema.Side; + timeInForce: Schema.OrderTimeInForce; size: string; price?: string; expiresAt?: string; @@ -40,7 +35,7 @@ interface OrderAmendment { marketId: string; orderId: string; reference?: string; - timeInForce: OrderTimeInForce; + timeInForce: Schema.OrderTimeInForce; sizeDelta?: number; price?: string; expiresAt?: string; diff --git a/libs/wallet/src/use-transaction-result.ts b/libs/wallet/src/use-transaction-result.ts index ddbbd8903..2d0ffd093 100644 --- a/libs/wallet/src/use-transaction-result.ts +++ b/libs/wallet/src/use-transaction-result.ts @@ -1,5 +1,5 @@ import { useApolloClient } from '@apollo/client'; -import { BusEventType } from '@vegaprotocol/types'; +import { Schema } from '@vegaprotocol/types'; import { useCallback, useEffect, useRef } from 'react'; import type { Subscription } from 'zen-observable-ts'; import type { @@ -43,7 +43,9 @@ export const useTransactionResult = () => { } const matchingTransaction = data.busEvents.find((e) => { - if (e.event.__typename !== BusEventType.TransactionResult) { + if ( + e.event.__typename !== Schema.BusEventType.TransactionResult + ) { return false; } @@ -53,7 +55,7 @@ export const useTransactionResult = () => { if ( matchingTransaction && matchingTransaction.event.__typename === - BusEventType.TransactionResult + Schema.BusEventType.TransactionResult ) { resolve(matchingTransaction.event as TransactionResult); subRef.current?.unsubscribe(); diff --git a/libs/web3/project.json b/libs/web3/project.json index 5058d131d..446e4b802 100644 --- a/libs/web3/project.json +++ b/libs/web3/project.json @@ -38,6 +38,13 @@ "jestConfig": "libs/web3/jest.config.ts", "passWithNoTests": true } + }, + "build-spec": { + "executor": "@nrwl/workspace:run-commands", + "outputs": [], + "options": { + "command": "yarn tsc --project ./libs/web3/tsconfig.spec.json" + } } } } diff --git a/libs/withdraws/project.json b/libs/withdraws/project.json index 299eef1b7..cd04a10d8 100644 --- a/libs/withdraws/project.json +++ b/libs/withdraws/project.json @@ -38,6 +38,13 @@ "jestConfig": "libs/withdraws/jest.config.ts", "passWithNoTests": true } + }, + "build-spec": { + "executor": "@nrwl/workspace:run-commands", + "outputs": [], + "options": { + "command": "yarn tsc --project ./libs/withdraws/tsconfig.spec.json" + } } } } diff --git a/libs/withdraws/src/lib/__generated__/WithdrawalEvent.ts b/libs/withdraws/src/lib/__generated__/WithdrawalEvent.ts index 2fafcb4be..fcbe8927d 100644 --- a/libs/withdraws/src/lib/__generated__/WithdrawalEvent.ts +++ b/libs/withdraws/src/lib/__generated__/WithdrawalEvent.ts @@ -10,7 +10,7 @@ import { WithdrawalStatus, AssetStatus } from "@vegaprotocol/types"; // ==================================================== export interface WithdrawalEvent_busEvents_event_TimeUpdate { - __typename: "TimeUpdate" | "MarketEvent" | "TransferResponses" | "PositionResolution" | "Order" | "Trade" | "Account" | "Party" | "MarginLevels" | "Proposal" | "Vote" | "MarketData" | "NodeSignature" | "LossSocialization" | "SettlePosition" | "Market" | "Asset" | "MarketTick" | "SettleDistressed" | "AuctionEvent" | "RiskFactor" | "Deposit" | "OracleSpec" | "LiquidityProvision" | "TransactionResult"; + __typename: "TimeUpdate" | "MarketEvent" | "TransferResponses" | "PositionResolution" | "Order" | "Trade" | "AccountEvent" | "Party" | "MarginLevels" | "Proposal" | "Vote" | "MarketData" | "NodeSignature" | "LossSocialization" | "SettlePosition" | "Market" | "Asset" | "MarketTick" | "SettleDistressed" | "AuctionEvent" | "RiskFactor" | "Deposit" | "OracleSpec" | "LiquidityProvision" | "TransactionResult"; } export interface WithdrawalEvent_busEvents_event_Withdrawal_asset_source_BuiltinAsset { diff --git a/libs/withdraws/src/lib/__generated___/Withdraw.ts b/libs/withdraws/src/lib/__generated___/Withdraw.ts index e27e47c68..31c2972c3 100644 --- a/libs/withdraws/src/lib/__generated___/Withdraw.ts +++ b/libs/withdraws/src/lib/__generated___/Withdraw.ts @@ -8,7 +8,7 @@ export type WithdrawPageQueryQueryVariables = Types.Exact<{ }>; -export type WithdrawPageQueryQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, withdrawals?: Array<{ __typename?: 'Withdrawal', id: string, txHash?: string | null }> | null, accounts?: Array<{ __typename?: 'Account', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', id: string, symbol: string } }> | null } | null, 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 type WithdrawPageQueryQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, withdrawals?: Array<{ __typename?: 'Withdrawal', id: string, txHash?: string | null }> | null, accounts?: Array<{ __typename?: 'AccountBalance', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', id: string, symbol: string } }> | null } | null, 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 WithdrawPageQueryDocument = gql` diff --git a/libs/withdraws/src/lib/__generated___/Withdrawal.ts b/libs/withdraws/src/lib/__generated___/Withdrawal.ts index 1a9e2528e..56e016903 100644 --- a/libs/withdraws/src/lib/__generated___/Withdrawal.ts +++ b/libs/withdraws/src/lib/__generated___/Withdrawal.ts @@ -17,7 +17,7 @@ export type WithdrawalEventSubscriptionVariables = Types.Exact<{ }>; -export type WithdrawalEventSubscription = { __typename?: 'Subscription', busEvents?: Array<{ __typename?: 'BusEvent', event: { __typename?: 'Account' } | { __typename?: 'Asset' } | { __typename?: 'AuctionEvent' } | { __typename?: 'Deposit' } | { __typename?: 'LiquidityProvision' } | { __typename?: 'LossSocialization' } | { __typename?: 'MarginLevels' } | { __typename?: 'Market' } | { __typename?: 'MarketData' } | { __typename?: 'MarketEvent' } | { __typename?: 'MarketTick' } | { __typename?: 'NodeSignature' } | { __typename?: 'OracleSpec' } | { __typename?: 'Order' } | { __typename?: 'Party' } | { __typename?: 'PositionResolution' } | { __typename?: 'Proposal' } | { __typename?: 'RiskFactor' } | { __typename?: 'SettleDistressed' } | { __typename?: 'SettlePosition' } | { __typename?: 'TimeUpdate' } | { __typename?: 'Trade' } | { __typename?: 'TransactionResult' } | { __typename?: 'TransferResponses' } | { __typename?: 'Vote' } | { __typename?: 'Withdrawal', id: string, status: Types.WithdrawalStatus, amount: string, createdTimestamp: string, withdrawnTimestamp?: string | null, txHash?: string | null, pendingOnForeignChain: boolean, asset: { __typename?: 'Asset', id: string, symbol: string, decimals: number }, details?: { __typename?: 'Erc20WithdrawalDetails', receiverAddress: string } | null } }> | null }; +export type WithdrawalEventSubscription = { __typename?: 'Subscription', busEvents?: Array<{ __typename?: 'BusEvent', event: { __typename?: 'AccountEvent' } | { __typename?: 'Asset' } | { __typename?: 'AuctionEvent' } | { __typename?: 'Deposit' } | { __typename?: 'LiquidityProvision' } | { __typename?: 'LossSocialization' } | { __typename?: 'MarginLevels' } | { __typename?: 'Market' } | { __typename?: 'MarketData' } | { __typename?: 'MarketEvent' } | { __typename?: 'MarketTick' } | { __typename?: 'NodeSignature' } | { __typename?: 'OracleSpec' } | { __typename?: 'Order' } | { __typename?: 'Party' } | { __typename?: 'PositionResolution' } | { __typename?: 'Proposal' } | { __typename?: 'RiskFactor' } | { __typename?: 'SettleDistressed' } | { __typename?: 'SettlePosition' } | { __typename?: 'TimeUpdate' } | { __typename?: 'Trade' } | { __typename?: 'TransactionResult' } | { __typename?: 'TransferResponses' } | { __typename?: 'Vote' } | { __typename?: 'Withdrawal', id: string, status: Types.WithdrawalStatus, amount: string, createdTimestamp: string, withdrawnTimestamp?: string | null, txHash?: string | null, pendingOnForeignChain: boolean, asset: { __typename?: 'Asset', id: string, symbol: string, decimals: number }, details?: { __typename?: 'Erc20WithdrawalDetails', receiverAddress: string } | null } }> | null }; export const WithdrawalFieldsFragmentDoc = gql` fragment WithdrawalFields on Withdrawal { diff --git a/libs/withdraws/src/lib/test-helpers.ts b/libs/withdraws/src/lib/test-helpers.ts index 51fe5db5b..f4cfd0db4 100644 --- a/libs/withdraws/src/lib/test-helpers.ts +++ b/libs/withdraws/src/lib/test-helpers.ts @@ -25,27 +25,27 @@ export const generateAsset = (override?: PartialDeep) => { }, infrastructureFeeAccount: { balance: '1', - __typename: 'Account', + __typename: 'AccountBalance', }, globalRewardPoolAccount: { balance: '2', - __typename: 'Account', + __typename: 'AccountBalance', }, takerFeeRewardAccount: { balance: '3', - __typename: 'Account', + __typename: 'AccountBalance', }, makerFeeRewardAccount: { balance: '4', - __typename: 'Account', + __typename: 'AccountBalance', }, lpFeeRewardAccount: { balance: '5', - __typename: 'Account', + __typename: 'AccountBalance', }, marketProposerRewardAccount: { balance: '6', - __typename: 'Account', + __typename: 'AccountBalance', }, __typename: 'Asset', };