From 3f62c79f8decce272edf6a26357af53d8f5a9e6c Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Tue, 29 Mar 2022 15:52:51 -0700 Subject: [PATCH 01/10] colocate querys with libs --- apps/explorer/.eslintrc.json | 2 +- .../assets}/__generated__/AssetsQuery.ts | 2 +- apps/explorer/src/app/routes/assets/index.tsx | 2 +- .../__generated__/ProposalsQuery.ts | 2 +- .../src/app/routes/governance/index.tsx | 2 +- .../markets}/__generated__/MarketsQuery.ts | 2 +- .../explorer/src/app/routes/markets/index.tsx | 2 +- .../__generated__/NetworkParametersQuery.ts | 0 .../app/routes/network-parameters/index.tsx | 2 +- .../id}/__generated__/PartyAssetsQuery.ts | 2 +- .../src/app/routes/parties/id/index.tsx | 2 +- .../validators}/__generated__/NodesQuery.ts | 2 +- .../src/app/routes/validators/index.tsx | 2 +- apps/trading/.eslintrc.json | 2 +- .../components/deal-ticket-container/index.ts | 1 - .../components/order-list-container/index.ts | 1 - .../components/page-query-container/index.tsx | 2 +- .../trading/pages/markets/[marketId].page.tsx | 2 +- .../pages/markets}/__generated__/Market.ts | 2 +- apps/trading/pages/markets/index.page.tsx | 67 +------- apps/trading/pages/markets/trade-grid.tsx | 26 +-- libs/deal-ticket/.eslintrc.json | 2 +- .../src/__generated__/DealTicketQuery.ts | 150 ++++++++++++++++++ .../src/__generated__/OrderEvent.ts | 2 +- .../deal-ticket/src/deal-ticket-container.tsx | 66 ++++++++ libs/deal-ticket/src/deal-ticket-limit.tsx | 4 +- .../deal-ticket/src/deal-ticket-manager.tsx | 17 +- libs/deal-ticket/src/deal-ticket-market.tsx | 4 +- libs/deal-ticket/src/deal-ticket.tsx | 6 +- libs/deal-ticket/src/index.ts | 1 + .../deal-ticket/src}/order-dialog.tsx | 7 +- libs/deal-ticket/src/submit-button.tsx | 4 +- .../src}/use-order-submit.spec.tsx | 4 +- .../deal-ticket/src}/use-order-submit.ts | 8 +- libs/graphql/project.json | 2 +- libs/graphql/src/__generated__/Guess.ts | 39 ----- libs/graphql/src/data-providers/index.ts | 3 - libs/graphql/src/index.ts | 20 --- libs/market-list/.eslintrc.json | 2 +- libs/market-list/src/index.ts | 1 + .../lib}/__generated__/MarketDataFields.ts | 2 +- .../src/lib}/__generated__/MarketDataSub.ts | 2 +- .../src/lib}/__generated__/Markets.ts | 2 +- .../market-list/src/lib/market-list-table.tsx | 2 +- .../market-list/src/lib/markets-container.tsx | 64 ++++++++ .../src/lib}/markets-data-provider.ts | 6 +- libs/order-list/.eslintrc.json | 2 +- .../src/__generated__/OrderFields.ts | 2 +- .../src/__generated__/OrderSub.ts | 2 +- .../src/__generated__/Orders.ts | 2 +- libs/order-list/src/index.ts | 1 + .../src}/order-list-container.spec.tsx | 12 +- .../order-list/src}/order-list-container.tsx | 8 +- libs/order-list/src/order-list.spec.tsx | 2 +- libs/order-list/src/order-list.tsx | 8 +- .../order-list/src}/use-orders.spec.tsx | 10 +- .../order-list/src}/use-orders.ts | 12 +- libs/positions/.eslintrc.json | 2 +- libs/positions/src/index.ts | 2 + .../src/lib}/__generated__/PositionDetails.ts | 2 +- .../lib}/__generated__/PositionSubscribe.ts | 2 +- .../src/lib}/__generated__/Positions.ts | 2 +- .../positions/src/lib/positions-container.tsx | 14 +- .../src/lib}/positions-data-provider.ts | 6 +- .../src/lib/positions-table.spec.tsx | 6 +- libs/positions/src/lib/positions-table.tsx | 6 +- .../src/hooks/use-data-provider.ts | 2 +- libs/react-helpers/src/index.ts | 1 + .../src/lib}/generic-data-provider.ts | 0 .../async-renderer/async-renderer.tsx | 2 +- .../src}/components/async-renderer/index.ts | 0 libs/ui-toolkit/src/index.ts | 1 + libs/wallet/src/index.ts | 1 + .../wallet/src}/use-vega-transaction.spec.tsx | 7 +- .../wallet/src}/use-vega-transaction.ts | 4 +- 75 files changed, 401 insertions(+), 267 deletions(-) rename {libs/graphql/src => apps/explorer/src/app/routes/assets}/__generated__/AssetsQuery.ts (95%) rename {libs/graphql/src => apps/explorer/src/app/routes/governance}/__generated__/ProposalsQuery.ts (99%) rename {libs/graphql/src => apps/explorer/src/app/routes/markets}/__generated__/MarketsQuery.ts (99%) rename {libs/graphql/src => apps/explorer/src/app/routes/network-parameters}/__generated__/NetworkParametersQuery.ts (100%) rename {libs/graphql/src => apps/explorer/src/app/routes/parties/id}/__generated__/PartyAssetsQuery.ts (96%) rename {libs/graphql/src => apps/explorer/src/app/routes/validators}/__generated__/NodesQuery.ts (94%) delete mode 100644 apps/trading/components/deal-ticket-container/index.ts delete mode 100644 apps/trading/components/order-list-container/index.ts rename {libs/graphql/src => apps/trading/pages/markets}/__generated__/Market.ts (97%) create mode 100644 libs/deal-ticket/src/__generated__/DealTicketQuery.ts rename libs/{graphql => deal-ticket}/src/__generated__/OrderEvent.ts (98%) create mode 100644 libs/deal-ticket/src/deal-ticket-container.tsx rename apps/trading/components/deal-ticket-container/deal-ticket-container.tsx => libs/deal-ticket/src/deal-ticket-manager.tsx (80%) rename {apps/trading/components/deal-ticket-container => libs/deal-ticket/src}/order-dialog.tsx (94%) rename {apps/trading/hooks => libs/deal-ticket/src}/use-order-submit.spec.tsx (97%) rename {apps/trading/hooks => libs/deal-ticket/src}/use-order-submit.ts (96%) delete mode 100644 libs/graphql/src/__generated__/Guess.ts delete mode 100644 libs/graphql/src/data-providers/index.ts rename libs/{graphql/src => market-list/src/lib}/__generated__/MarketDataFields.ts (90%) rename libs/{graphql/src => market-list/src/lib}/__generated__/MarketDataSub.ts (91%) rename libs/{graphql/src => market-list/src/lib}/__generated__/Markets.ts (97%) create mode 100644 libs/market-list/src/lib/markets-container.tsx rename libs/{graphql/src/data-providers => market-list/src/lib}/markets-data-provider.ts (89%) rename libs/{graphql => order-list}/src/__generated__/OrderFields.ts (97%) rename libs/{graphql => order-list}/src/__generated__/OrderSub.ts (98%) rename libs/{graphql => order-list}/src/__generated__/Orders.ts (98%) rename {apps/trading/components/order-list-container => libs/order-list/src}/order-list-container.spec.tsx (77%) rename {apps/trading/components/order-list-container => libs/order-list/src}/order-list-container.tsx (55%) rename {apps/trading/hooks => libs/order-list/src}/use-orders.spec.tsx (96%) rename {apps/trading/hooks => libs/order-list/src}/use-orders.ts (94%) rename libs/{graphql/src => positions/src/lib}/__generated__/PositionDetails.ts (98%) rename libs/{graphql/src => positions/src/lib}/__generated__/PositionSubscribe.ts (98%) rename libs/{graphql/src => positions/src/lib}/__generated__/Positions.ts (98%) rename apps/trading/pages/markets/positions.tsx => libs/positions/src/lib/positions-container.tsx (83%) rename libs/{graphql/src/data-providers => positions/src/lib}/positions-data-provider.ts (93%) rename libs/{graphql/src/data-providers => react-helpers/src/lib}/generic-data-provider.ts (100%) rename {apps/trading => libs/ui-toolkit/src}/components/async-renderer/async-renderer.tsx (91%) rename {apps/trading => libs/ui-toolkit/src}/components/async-renderer/index.ts (100%) rename {apps/trading/hooks => libs/wallet/src}/use-vega-transaction.spec.tsx (96%) rename {apps/trading/hooks => libs/wallet/src}/use-vega-transaction.ts (94%) diff --git a/apps/explorer/.eslintrc.json b/apps/explorer/.eslintrc.json index 734ddacee..db820c5d0 100644 --- a/apps/explorer/.eslintrc.json +++ b/apps/explorer/.eslintrc.json @@ -1,6 +1,6 @@ { "extends": ["plugin:@nrwl/nx/react", "../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], + "ignorePatterns": ["!**/*", "__generated__"], "overrides": [ { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], diff --git a/libs/graphql/src/__generated__/AssetsQuery.ts b/apps/explorer/src/app/routes/assets/__generated__/AssetsQuery.ts similarity index 95% rename from libs/graphql/src/__generated__/AssetsQuery.ts rename to apps/explorer/src/app/routes/assets/__generated__/AssetsQuery.ts index ea9b6f249..554ee5c3f 100644 --- a/libs/graphql/src/__generated__/AssetsQuery.ts +++ b/apps/explorer/src/app/routes/assets/__generated__/AssetsQuery.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { AccountType } from "./globalTypes"; +import { AccountType } from "./../../../../../../../libs/graphql/src/__generated__/globalTypes"; // ==================================================== // GraphQL query operation: AssetsQuery diff --git a/apps/explorer/src/app/routes/assets/index.tsx b/apps/explorer/src/app/routes/assets/index.tsx index 859d90171..caa2ae40d 100644 --- a/apps/explorer/src/app/routes/assets/index.tsx +++ b/apps/explorer/src/app/routes/assets/index.tsx @@ -3,7 +3,7 @@ import React from 'react'; import { RouteTitle } from '../../components/route-title'; import { SubHeading } from '../../components/sub-heading'; import { SyntaxHighlighter } from '../../components/syntax-highlighter'; -import { AssetsQuery } from '@vegaprotocol/graphql'; +import { AssetsQuery } from './__generated__/AssetsQuery'; export const ASSETS_QUERY = gql` query AssetsQuery { diff --git a/libs/graphql/src/__generated__/ProposalsQuery.ts b/apps/explorer/src/app/routes/governance/__generated__/ProposalsQuery.ts similarity index 99% rename from libs/graphql/src/__generated__/ProposalsQuery.ts rename to apps/explorer/src/app/routes/governance/__generated__/ProposalsQuery.ts index f47bef14f..95c1869fb 100644 --- a/libs/graphql/src/__generated__/ProposalsQuery.ts +++ b/apps/explorer/src/app/routes/governance/__generated__/ProposalsQuery.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { ProposalState, ProposalRejectionReason, VoteValue } from "./globalTypes"; +import { ProposalState, ProposalRejectionReason, VoteValue } from "./../../../../../../../libs/graphql/src/__generated__/globalTypes"; // ==================================================== // GraphQL query operation: ProposalsQuery diff --git a/apps/explorer/src/app/routes/governance/index.tsx b/apps/explorer/src/app/routes/governance/index.tsx index 1d81a9e80..e55c99337 100644 --- a/apps/explorer/src/app/routes/governance/index.tsx +++ b/apps/explorer/src/app/routes/governance/index.tsx @@ -6,7 +6,7 @@ import { SyntaxHighlighter } from '../../components/syntax-highlighter'; import { ProposalsQuery, ProposalsQuery_proposals_terms_change, -} from '@vegaprotocol/graphql'; +} from './__generated__/ProposalsQuery'; export function getProposalName(change: ProposalsQuery_proposals_terms_change) { if (change.__typename === 'NewAsset') { diff --git a/libs/graphql/src/__generated__/MarketsQuery.ts b/apps/explorer/src/app/routes/markets/__generated__/MarketsQuery.ts similarity index 99% rename from libs/graphql/src/__generated__/MarketsQuery.ts rename to apps/explorer/src/app/routes/markets/__generated__/MarketsQuery.ts index 18707af7a..d2d476668 100644 --- a/libs/graphql/src/__generated__/MarketsQuery.ts +++ b/apps/explorer/src/app/routes/markets/__generated__/MarketsQuery.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { MarketTradingMode, MarketState, AccountType, AuctionTrigger } from "./globalTypes"; +import { MarketTradingMode, MarketState, AccountType, AuctionTrigger } from "./../../../../../../../libs/graphql/src/__generated__/globalTypes"; // ==================================================== // GraphQL query operation: MarketsQuery diff --git a/apps/explorer/src/app/routes/markets/index.tsx b/apps/explorer/src/app/routes/markets/index.tsx index 45568c903..075f8619d 100644 --- a/apps/explorer/src/app/routes/markets/index.tsx +++ b/apps/explorer/src/app/routes/markets/index.tsx @@ -1,5 +1,5 @@ import { gql, useQuery } from '@apollo/client'; -import { MarketsQuery } from '@vegaprotocol/graphql'; +import { MarketsQuery } from './__generated__/MarketsQuery'; import React from 'react'; import { SyntaxHighlighter } from '../../components/syntax-highlighter'; diff --git a/libs/graphql/src/__generated__/NetworkParametersQuery.ts b/apps/explorer/src/app/routes/network-parameters/__generated__/NetworkParametersQuery.ts similarity index 100% rename from libs/graphql/src/__generated__/NetworkParametersQuery.ts rename to apps/explorer/src/app/routes/network-parameters/__generated__/NetworkParametersQuery.ts diff --git a/apps/explorer/src/app/routes/network-parameters/index.tsx b/apps/explorer/src/app/routes/network-parameters/index.tsx index 8a8ed8bd9..28822cd80 100644 --- a/apps/explorer/src/app/routes/network-parameters/index.tsx +++ b/apps/explorer/src/app/routes/network-parameters/index.tsx @@ -1,6 +1,6 @@ import { gql, useQuery } from '@apollo/client'; import { RouteTitle } from '../../components/route-title'; -import { NetworkParametersQuery } from '@vegaprotocol/graphql'; +import { NetworkParametersQuery } from './__generated__/NetworkParametersQuery'; import { SyntaxHighlighter } from '../../components/syntax-highlighter'; export const NETWORK_PARAMETERS_QUERY = gql` diff --git a/libs/graphql/src/__generated__/PartyAssetsQuery.ts b/apps/explorer/src/app/routes/parties/id/__generated__/PartyAssetsQuery.ts similarity index 96% rename from libs/graphql/src/__generated__/PartyAssetsQuery.ts rename to apps/explorer/src/app/routes/parties/id/__generated__/PartyAssetsQuery.ts index 1fe3f42fa..fd88252b9 100644 --- a/libs/graphql/src/__generated__/PartyAssetsQuery.ts +++ b/apps/explorer/src/app/routes/parties/id/__generated__/PartyAssetsQuery.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { AccountType } from "./globalTypes"; +import { AccountType } from "./../../../../../../../../libs/graphql/src/__generated__/globalTypes"; // ==================================================== // GraphQL query operation: PartyAssetsQuery diff --git a/apps/explorer/src/app/routes/parties/id/index.tsx b/apps/explorer/src/app/routes/parties/id/index.tsx index 2412ab1f3..d9aed4dad 100644 --- a/apps/explorer/src/app/routes/parties/id/index.tsx +++ b/apps/explorer/src/app/routes/parties/id/index.tsx @@ -11,7 +11,7 @@ import { TendermintSearchTransactionResponse } from '../tendermint-transaction-r import { PartyAssetsQuery, PartyAssetsQueryVariables, -} from '@vegaprotocol/graphql'; +} from './__generated__/PartyAssetsQuery'; const PARTY_ASSETS_QUERY = gql` query PartyAssetsQuery($partyId: ID!) { diff --git a/libs/graphql/src/__generated__/NodesQuery.ts b/apps/explorer/src/app/routes/validators/__generated__/NodesQuery.ts similarity index 94% rename from libs/graphql/src/__generated__/NodesQuery.ts rename to apps/explorer/src/app/routes/validators/__generated__/NodesQuery.ts index 0b8079143..478c6f528 100644 --- a/libs/graphql/src/__generated__/NodesQuery.ts +++ b/apps/explorer/src/app/routes/validators/__generated__/NodesQuery.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { NodeStatus } from "./globalTypes"; +import { NodeStatus } from "./../../../../../../../libs/graphql/src/__generated__/globalTypes"; // ==================================================== // GraphQL query operation: NodesQuery diff --git a/apps/explorer/src/app/routes/validators/index.tsx b/apps/explorer/src/app/routes/validators/index.tsx index 68ff1bb49..ffb93d1fa 100644 --- a/apps/explorer/src/app/routes/validators/index.tsx +++ b/apps/explorer/src/app/routes/validators/index.tsx @@ -6,7 +6,7 @@ import { SyntaxHighlighter } from '../../components/syntax-highlighter'; import { DATA_SOURCES } from '../../config'; import useFetch from '../../hooks/use-fetch'; import { TendermintValidatorsResponse } from './tendermint-validator-response'; -import { NodesQuery } from '@vegaprotocol/graphql'; +import { NodesQuery } from './__generated__/NodesQuery'; const NODES_QUERY = gql` query NodesQuery { diff --git a/apps/trading/.eslintrc.json b/apps/trading/.eslintrc.json index 2548ff963..bc7243829 100644 --- a/apps/trading/.eslintrc.json +++ b/apps/trading/.eslintrc.json @@ -5,7 +5,7 @@ "next", "next/core-web-vitals" ], - "ignorePatterns": ["!**/*"], + "ignorePatterns": ["!**/*", "__generated__"], "overrides": [ { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], diff --git a/apps/trading/components/deal-ticket-container/index.ts b/apps/trading/components/deal-ticket-container/index.ts deleted file mode 100644 index 6d3e9ada5..000000000 --- a/apps/trading/components/deal-ticket-container/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './deal-ticket-container'; diff --git a/apps/trading/components/order-list-container/index.ts b/apps/trading/components/order-list-container/index.ts deleted file mode 100644 index ac2975314..000000000 --- a/apps/trading/components/order-list-container/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './order-list-container'; diff --git a/apps/trading/components/page-query-container/index.tsx b/apps/trading/components/page-query-container/index.tsx index 78e6f98f9..360262604 100644 --- a/apps/trading/components/page-query-container/index.tsx +++ b/apps/trading/components/page-query-container/index.tsx @@ -1,7 +1,7 @@ import { OperationVariables, QueryHookOptions, useQuery } from '@apollo/client'; import { DocumentNode } from 'graphql'; import { ReactNode } from 'react'; -import { AsyncRenderer } from '../async-renderer'; +import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; interface PageQueryContainerProps { query: DocumentNode; diff --git a/apps/trading/pages/markets/[marketId].page.tsx b/apps/trading/pages/markets/[marketId].page.tsx index 868e9c6b9..3355f3fc2 100644 --- a/apps/trading/pages/markets/[marketId].page.tsx +++ b/apps/trading/pages/markets/[marketId].page.tsx @@ -1,5 +1,5 @@ import { gql } from '@apollo/client'; -import { Market, MarketVariables } from '@vegaprotocol/graphql'; +import { Market, MarketVariables } from './__generated__/Market'; import { Splash } from '@vegaprotocol/ui-toolkit'; import { useRouter } from 'next/router'; import React, { useEffect, useState } from 'react'; diff --git a/libs/graphql/src/__generated__/Market.ts b/apps/trading/pages/markets/__generated__/Market.ts similarity index 97% rename from libs/graphql/src/__generated__/Market.ts rename to apps/trading/pages/markets/__generated__/Market.ts index 61cf341ce..a862a3ce3 100644 --- a/libs/graphql/src/__generated__/Market.ts +++ b/apps/trading/pages/markets/__generated__/Market.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { MarketState, MarketTradingMode } from "./globalTypes"; +import { MarketState, MarketTradingMode } from "./../../../../../libs/graphql/src/__generated__/globalTypes"; // ==================================================== // GraphQL query operation: Market diff --git a/apps/trading/pages/markets/index.page.tsx b/apps/trading/pages/markets/index.page.tsx index eafb7451c..9f6a97c93 100644 --- a/apps/trading/pages/markets/index.page.tsx +++ b/apps/trading/pages/markets/index.page.tsx @@ -1,70 +1,7 @@ -import { useRef, useCallback } from 'react'; -import { produce } from 'immer'; -import merge from 'lodash/merge'; -import { useRouter } from 'next/router'; -import { AsyncRenderer } from '../../components/async-renderer'; -import { MarketListTable, getRowNodeId } from '@vegaprotocol/market-list'; -import { - Markets_markets, - Markets_markets_data, - marketsDataProvider, -} from '@vegaprotocol/graphql'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; - -import type { AgGridReact } from 'ag-grid-react'; +import { MarketsContainer } from '@vegaprotocol/market-list'; const Markets = () => { - const { pathname, push } = useRouter(); - const gridRef = useRef(null); - const update = useCallback( - (delta: Markets_markets_data) => { - const update: Markets_markets[] = []; - const add: Markets_markets[] = []; - if (!gridRef.current) { - return false; - } - const rowNode = gridRef.current.api.getRowNode( - getRowNodeId(delta.market) - ); - if (rowNode) { - const updatedData = produce( - rowNode.data.data, - (draft: Markets_markets_data) => merge(draft, delta) - ); - if (updatedData !== rowNode.data.data) { - update.push({ ...rowNode.data, data: updatedData }); - } - } - // @TODO - else add new market - if (update.length || add.length) { - gridRef.current.api.applyTransactionAsync({ - update, - add, - addIndex: 0, - }); - } - return true; - }, - [gridRef] - ); - const { data, error, loading } = useDataProvider< - Markets_markets, - Markets_markets_data - >(marketsDataProvider, update); - - return ( - - {(data) => ( - - push(`${pathname}/${id}?portfolio=orders&trade=orderbook`) - } - /> - )} - - ); + return ; }; export default Markets; diff --git a/apps/trading/pages/markets/trade-grid.tsx b/apps/trading/pages/markets/trade-grid.tsx index 95de8f5aa..a42059118 100644 --- a/apps/trading/pages/markets/trade-grid.tsx +++ b/apps/trading/pages/markets/trade-grid.tsx @@ -1,12 +1,12 @@ -import { Market_market } from '@vegaprotocol/graphql'; import classNames from 'classnames'; import AutoSizer from 'react-virtualized-auto-sizer'; -import { useState, ReactNode, ComponentType } from 'react'; +import { useState, ReactNode } from 'react'; import { GridTab, GridTabs } from './grid-tabs'; -import { DealTicketContainer } from '../../components/deal-ticket-container'; -import { OrderListContainer } from '../..//components/order-list-container'; +import { DealTicketContainer } from '@vegaprotocol/deal-ticket'; +import { OrderListContainer } from '@vegaprotocol/order-list'; import { Splash } from '@vegaprotocol/ui-toolkit'; -import { Positions } from './positions'; +import { PositionsContainer } from '@vegaprotocol/positions'; +import { Market_market } from './__generated__/Market'; const Chart = () => ( @@ -29,22 +29,12 @@ const Trades = () => ( ); -// enum TradingView { -// Chart = 'Chart', -// Ticket = 'Ticket', -// Orderbook = 'Orderbook', -// Orders = 'Orders', -// Positions = 'Positions', -// Collateral = 'Collateral', -// Trades = 'Trades', -// } - const TradingViews = { Chart: Chart, Ticket: DealTicketContainer, Orderbook: Orderbook, Orders: OrderListContainer, - Positions: Positions, + Positions: PositionsContainer, Collateral: Collateral, Trades: Trades, }; @@ -71,7 +61,7 @@ export const TradeGrid = ({ market }: TradeGridProps) => { - + @@ -134,7 +124,7 @@ export const TradePanels = ({ market }: TradePanelsProps) => { throw new Error(`No component for view: ${view}`); } - return ; + return ; }; return ( diff --git a/libs/deal-ticket/.eslintrc.json b/libs/deal-ticket/.eslintrc.json index 734ddacee..db820c5d0 100644 --- a/libs/deal-ticket/.eslintrc.json +++ b/libs/deal-ticket/.eslintrc.json @@ -1,6 +1,6 @@ { "extends": ["plugin:@nrwl/nx/react", "../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], + "ignorePatterns": ["!**/*", "__generated__"], "overrides": [ { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], diff --git a/libs/deal-ticket/src/__generated__/DealTicketQuery.ts b/libs/deal-ticket/src/__generated__/DealTicketQuery.ts new file mode 100644 index 000000000..804923d09 --- /dev/null +++ b/libs/deal-ticket/src/__generated__/DealTicketQuery.ts @@ -0,0 +1,150 @@ +/* tslint:disable */ +/* eslint-disable */ +// @generated +// This file was automatically generated and should not be edited. + +import { MarketState, MarketTradingMode } from "./../../../graphql/src/__generated__/globalTypes"; + +// ==================================================== +// GraphQL query operation: DealTicketQuery +// ==================================================== + +export interface DealTicketQuery_market_tradableInstrument_instrument_product_settlementAsset { + __typename: "Asset"; + /** + * The id of the asset + */ + id: string; + /** + * The symbol of the asset (e.g: GBP) + */ + symbol: string; + /** + * The full name of the asset (e.g: Great British Pound) + */ + name: string; +} + +export interface DealTicketQuery_market_tradableInstrument_instrument_product { + __typename: "Future"; + /** + * String representing the quote (e.g. BTCUSD -> USD is quote) + */ + quoteName: string; + /** + * The name of the asset (string) + */ + settlementAsset: DealTicketQuery_market_tradableInstrument_instrument_product_settlementAsset; +} + +export interface DealTicketQuery_market_tradableInstrument_instrument { + __typename: "Instrument"; + /** + * A reference to or instance of a fully specified product, including all required product parameters for that product (Product union) + */ + product: DealTicketQuery_market_tradableInstrument_instrument_product; +} + +export interface DealTicketQuery_market_tradableInstrument { + __typename: "TradableInstrument"; + /** + * An instance of or reference to a fully specified instrument. + */ + instrument: DealTicketQuery_market_tradableInstrument_instrument; +} + +export interface DealTicketQuery_market_trades { + __typename: "Trade"; + /** + * The hash of the trade data + */ + id: string; + /** + * The price of the trade (probably initially the passive order price, other determination algorithms are possible though) (uint64) + */ + price: string; + /** + * The number of contracts trades, will always be <= the remaining size of both orders immediately before the trade (uint64) + */ + size: string; + /** + * RFC3339Nano time for when the trade occurred + */ + createdAt: string; +} + +export interface DealTicketQuery_market_depth_lastTrade { + __typename: "Trade"; + /** + * The price of the trade (probably initially the passive order price, other determination algorithms are possible though) (uint64) + */ + price: string; +} + +export interface DealTicketQuery_market_depth { + __typename: "MarketDepth"; + /** + * Last trade for the given market (if available) + */ + lastTrade: DealTicketQuery_market_depth_lastTrade | null; +} + +export interface DealTicketQuery_market { + __typename: "Market"; + /** + * Market ID + */ + id: string; + /** + * Market full name + */ + name: string; + /** + * decimalPlaces indicates the number of decimal places that an integer must be shifted by in order to get a correct + * number denominated in the currency of the Market. (uint64) + * + * Examples: + * Currency Balance decimalPlaces Real Balance + * GBP 100 0 GBP 100 + * GBP 100 2 GBP 1.00 + * GBP 100 4 GBP 0.01 + * GBP 1 4 GBP 0.0001 ( 0.01p ) + * + * GBX (pence) 100 0 GBP 1.00 (100p ) + * GBX (pence) 100 2 GBP 0.01 ( 1p ) + * GBX (pence) 100 4 GBP 0.0001 ( 0.01p ) + * GBX (pence) 1 4 GBP 0.000001 ( 0.0001p) + */ + decimalPlaces: number; + /** + * Current state of the market + */ + state: MarketState; + /** + * Current mode of execution of the market + */ + tradingMode: MarketTradingMode; + /** + * An instance of or reference to a tradable instrument. + */ + tradableInstrument: DealTicketQuery_market_tradableInstrument; + /** + * Trades on a market + */ + trades: DealTicketQuery_market_trades[] | null; + /** + * Current depth on the order book for this market + */ + depth: DealTicketQuery_market_depth; +} + +export interface DealTicketQuery { + /** + * An instrument that is trading on the VEGA network + */ + market: DealTicketQuery_market | null; +} + +export interface DealTicketQueryVariables { + marketId: string; +} diff --git a/libs/graphql/src/__generated__/OrderEvent.ts b/libs/deal-ticket/src/__generated__/OrderEvent.ts similarity index 98% rename from libs/graphql/src/__generated__/OrderEvent.ts rename to libs/deal-ticket/src/__generated__/OrderEvent.ts index b5ff01623..1ac9d2455 100644 --- a/libs/graphql/src/__generated__/OrderEvent.ts +++ b/libs/deal-ticket/src/__generated__/OrderEvent.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { BusEventType, OrderType, OrderStatus, OrderRejectionReason } from "./globalTypes"; +import { BusEventType, OrderType, OrderStatus, OrderRejectionReason } from "./../../../graphql/src/__generated__/globalTypes"; // ==================================================== // GraphQL subscription operation: OrderEvent diff --git a/libs/deal-ticket/src/deal-ticket-container.tsx b/libs/deal-ticket/src/deal-ticket-container.tsx new file mode 100644 index 000000000..64603e13f --- /dev/null +++ b/libs/deal-ticket/src/deal-ticket-container.tsx @@ -0,0 +1,66 @@ +import { AsyncRenderer, Splash } from '@vegaprotocol/ui-toolkit'; +import { gql, useQuery } from '@apollo/client'; +import { DealTicketManager } from './deal-ticket-manager'; +import { DealTicketQuery } from './__generated__/DealTicketQuery'; + +const DEAL_TICKET_QUERY = gql` + query DealTicketQuery($marketId: ID!) { + market(id: $marketId) { + id + name + decimalPlaces + state + tradingMode + tradableInstrument { + instrument { + product { + ... on Future { + quoteName + settlementAsset { + id + symbol + name + } + } + } + } + } + trades { + id + price + size + createdAt + } + depth { + lastTrade { + price + } + } + } + } +`; + +interface DealTicketContainerProps { + marketId: string; +} + +export const DealTicketContainer = ({ marketId }: DealTicketContainerProps) => { + const { data, loading, error } = useQuery(DEAL_TICKET_QUERY, { + variables: { marketId }, + }); + + return ( + data={data} loading={loading} error={error}> + {(data) => { + if (!data.market) { + return ( + +

Could not load market

+
+ ); + } + return ; + }} + + ); +}; diff --git a/libs/deal-ticket/src/deal-ticket-limit.tsx b/libs/deal-ticket/src/deal-ticket-limit.tsx index b327ccacd..92df74775 100644 --- a/libs/deal-ticket/src/deal-ticket-limit.tsx +++ b/libs/deal-ticket/src/deal-ticket-limit.tsx @@ -1,19 +1,19 @@ import { FormGroup, Input } from '@vegaprotocol/ui-toolkit'; import { OrderTimeInForce } from '@vegaprotocol/wallet'; import { TransactionStatus } from './deal-ticket'; -import { Market_market } from '@vegaprotocol/graphql'; import { ExpirySelector } from './expiry-selector'; import { SideSelector } from './side-selector'; import { SubmitButton } from './submit-button'; import { TimeInForceSelector } from './time-in-force-selector'; import { TypeSelector } from './type-selector'; import { Order } from './use-order-state'; +import { DealTicketQuery_market } from './__generated__/DealTicketQuery'; interface DealTicketLimitProps { order: Order; updateOrder: (order: Partial) => void; transactionStatus: TransactionStatus; - market: Market_market; + market: DealTicketQuery_market; } export const DealTicketLimit = ({ diff --git a/apps/trading/components/deal-ticket-container/deal-ticket-container.tsx b/libs/deal-ticket/src/deal-ticket-manager.tsx similarity index 80% rename from apps/trading/components/deal-ticket-container/deal-ticket-container.tsx rename to libs/deal-ticket/src/deal-ticket-manager.tsx index cecf6ea34..0e2a0c86b 100644 --- a/apps/trading/components/deal-ticket-container/deal-ticket-container.tsx +++ b/libs/deal-ticket/src/deal-ticket-manager.tsx @@ -1,16 +1,17 @@ -import { Dialog, Intent } from '@vegaprotocol/ui-toolkit'; -import { DealTicket } from '@vegaprotocol/deal-ticket'; -import { Market_market, OrderStatus } from '@vegaprotocol/graphql'; -import { useOrderSubmit } from '../../hooks/use-order-submit'; import { useEffect, useState } from 'react'; -import { VegaTxStatus } from '../../hooks/use-vega-transaction'; +import { Dialog, Intent } from '@vegaprotocol/ui-toolkit'; +import { OrderStatus } from '@vegaprotocol/graphql'; +import { VegaTxStatus } from '@vegaprotocol/wallet'; +import { DealTicket } from './deal-ticket'; +import { useOrderSubmit } from './use-order-submit'; import { OrderDialog } from './order-dialog'; +import { DealTicketQuery_market } from './__generated__/DealTicketQuery'; -interface DealTicketContainerProps { - market: Market_market; +interface DealTicketManagerProps { + market: DealTicketQuery_market; } -export const DealTicketContainer = ({ market }: DealTicketContainerProps) => { +export const DealTicketManager = ({ market }: DealTicketManagerProps) => { const [orderDialogOpen, setOrderDialogOpen] = useState(false); const { submit, transaction, finalizedOrder, reset } = useOrderSubmit(market); diff --git a/libs/deal-ticket/src/deal-ticket-market.tsx b/libs/deal-ticket/src/deal-ticket-market.tsx index 3d46e4770..3c1d11584 100644 --- a/libs/deal-ticket/src/deal-ticket-market.tsx +++ b/libs/deal-ticket/src/deal-ticket-market.tsx @@ -1,18 +1,18 @@ import { addDecimal } from '@vegaprotocol/react-helpers'; import { FormGroup, Input } from '@vegaprotocol/ui-toolkit'; -import { Market_market } from '@vegaprotocol/graphql'; import { TransactionStatus } from './deal-ticket'; import { SideSelector } from './side-selector'; import { SubmitButton } from './submit-button'; import { TimeInForceSelector } from './time-in-force-selector'; import { TypeSelector } from './type-selector'; import { Order } from './use-order-state'; +import { DealTicketQuery_market } from './__generated__/DealTicketQuery'; interface DealTicketMarketProps { order: Order; updateOrder: (order: Partial) => void; transactionStatus: TransactionStatus; - market: Market_market; + market: DealTicketQuery_market; } export const DealTicketMarket = ({ diff --git a/libs/deal-ticket/src/deal-ticket.tsx b/libs/deal-ticket/src/deal-ticket.tsx index a7235d957..ceeb28ca2 100644 --- a/libs/deal-ticket/src/deal-ticket.tsx +++ b/libs/deal-ticket/src/deal-ticket.tsx @@ -1,9 +1,9 @@ -import { OrderSide, OrderTimeInForce, OrderType } from '@vegaprotocol/wallet'; -import { Market_market } from '@vegaprotocol/graphql'; import { FormEvent } from 'react'; +import { OrderSide, OrderTimeInForce, OrderType } from '@vegaprotocol/wallet'; import { Order, useOrderState } from './use-order-state'; import { DealTicketMarket } from './deal-ticket-market'; import { DealTicketLimit } from './deal-ticket-limit'; +import { DealTicketQuery_market } from './__generated__/DealTicketQuery'; const DEFAULT_ORDER: Order = { type: OrderType.Market, @@ -15,7 +15,7 @@ const DEFAULT_ORDER: Order = { export type TransactionStatus = 'default' | 'pending'; export interface DealTicketProps { - market: Market_market; + market: DealTicketQuery_market; submit: (order: Order) => void; transactionStatus: TransactionStatus; defaultOrder?: Order; diff --git a/libs/deal-ticket/src/index.ts b/libs/deal-ticket/src/index.ts index 22bedf9bd..1a51576f3 100644 --- a/libs/deal-ticket/src/index.ts +++ b/libs/deal-ticket/src/index.ts @@ -1,2 +1,3 @@ export * from './deal-ticket'; export * from './use-order-state'; +export * from './deal-ticket-container'; diff --git a/apps/trading/components/deal-ticket-container/order-dialog.tsx b/libs/deal-ticket/src/order-dialog.tsx similarity index 94% rename from apps/trading/components/deal-ticket-container/order-dialog.tsx rename to libs/deal-ticket/src/order-dialog.tsx index 8db306ace..950ec4162 100644 --- a/apps/trading/components/deal-ticket-container/order-dialog.tsx +++ b/libs/deal-ticket/src/order-dialog.tsx @@ -1,11 +1,8 @@ import { Icon, Loader } from '@vegaprotocol/ui-toolkit'; import { ReactNode } from 'react'; -import { - TransactionState, - VegaTxStatus, -} from '../../hooks/use-vega-transaction'; -import { OrderEvent_busEvents_event_Order } from '@vegaprotocol/graphql'; +import { OrderEvent_busEvents_event_Order } from './__generated__/OrderEvent'; import { formatNumber } from '@vegaprotocol/react-helpers'; +import { TransactionState, VegaTxStatus } from '@vegaprotocol/wallet'; interface OrderDialogProps { transaction: TransactionState; diff --git a/libs/deal-ticket/src/submit-button.tsx b/libs/deal-ticket/src/submit-button.tsx index 610c78633..901e639e5 100644 --- a/libs/deal-ticket/src/submit-button.tsx +++ b/libs/deal-ticket/src/submit-button.tsx @@ -1,14 +1,14 @@ import { Button, InputError } from '@vegaprotocol/ui-toolkit'; import { OrderTimeInForce, OrderType } from '@vegaprotocol/wallet'; -import { Market_market } from '@vegaprotocol/graphql'; import { useMemo } from 'react'; import { Order } from './use-order-state'; import { useVegaWallet } from '@vegaprotocol/wallet'; import { TransactionStatus } from './deal-ticket'; +import { DealTicketQuery_market } from './__generated__/DealTicketQuery'; interface SubmitButtonProps { transactionStatus: TransactionStatus; - market: Market_market; + market: DealTicketQuery_market; order: Order; } diff --git a/apps/trading/hooks/use-order-submit.spec.tsx b/libs/deal-ticket/src/use-order-submit.spec.tsx similarity index 97% rename from apps/trading/hooks/use-order-submit.spec.tsx rename to libs/deal-ticket/src/use-order-submit.spec.tsx index 2bc3e5979..e89d78607 100644 --- a/apps/trading/hooks/use-order-submit.spec.tsx +++ b/libs/deal-ticket/src/use-order-submit.spec.tsx @@ -1,15 +1,15 @@ import { MockedProvider } from '@apollo/client/testing'; import { act, renderHook } from '@testing-library/react-hooks'; -import { Order } from '@vegaprotocol/deal-ticket'; +import { Order } from './use-order-state'; import { VegaKeyExtended, + VegaTxStatus, VegaWalletContext, VegaWalletContextShape, } from '@vegaprotocol/wallet'; import { OrderSide, OrderTimeInForce, OrderType } from '@vegaprotocol/wallet'; import { ReactNode } from 'react'; import { useOrderSubmit } from './use-order-submit'; -import { VegaTxStatus } from './use-vega-transaction'; const defaultWalletContext = { keypair: null, diff --git a/apps/trading/hooks/use-order-submit.ts b/libs/deal-ticket/src/use-order-submit.ts similarity index 96% rename from apps/trading/hooks/use-order-submit.ts rename to libs/deal-ticket/src/use-order-submit.ts index d9089243a..4392ab024 100644 --- a/apps/trading/hooks/use-order-submit.ts +++ b/libs/deal-ticket/src/use-order-submit.ts @@ -2,15 +2,15 @@ import { useCallback, useEffect, useState } from 'react'; import { gql, useSubscription } from '@apollo/client'; import { ethers } from 'ethers'; import { SHA3 } from 'sha3'; -import { Order } from '@vegaprotocol/deal-ticket'; +import { Order } from './use-order-state'; import { OrderType, useVegaWallet } from '@vegaprotocol/wallet'; -import { useVegaTransaction } from './use-vega-transaction'; +import { removeDecimal } from '@vegaprotocol/react-helpers'; +import { useVegaTransaction } from '@vegaprotocol/wallet'; import { OrderEvent, OrderEventVariables, OrderEvent_busEvents_event_Order, -} from '@vegaprotocol/graphql'; -import { removeDecimal } from '@vegaprotocol/react-helpers'; +} from './__generated__/OrderEvent'; const ORDER_EVENT_SUB = gql` subscription OrderEvent($partyId: ID!) { diff --git a/libs/graphql/project.json b/libs/graphql/project.json index 071816ba2..25358bd14 100644 --- a/libs/graphql/project.json +++ b/libs/graphql/project.json @@ -44,7 +44,7 @@ "options": { "commands": [ { - "command": "npx apollo client:codegen libs/graphql/src/__generated__ --config=libs/graphql/apollo.config.js --target=typescript --globalTypesFile=libs/graphql/src/__generated__/globalTypes.ts --outputFlat" + "command": "npx apollo client:codegen --config=libs/graphql/apollo.config.js --target=typescript --globalTypesFile=libs/graphql/src/__generated__/globalTypes.ts" } ] } diff --git a/libs/graphql/src/__generated__/Guess.ts b/libs/graphql/src/__generated__/Guess.ts deleted file mode 100644 index 7e096adf3..000000000 --- a/libs/graphql/src/__generated__/Guess.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// @generated -// This file was automatically generated and should not be edited. - -// ==================================================== -// GraphQL query operation: Guess -// ==================================================== - -export interface Guess_party { - __typename: "Party"; - /** - * Party identifier - */ - id: string; -} - -export interface Guess_market { - __typename: "Market"; - /** - * Market ID - */ - id: string; -} - -export interface Guess { - /** - * An entity that is trading on the VEGA network - */ - party: Guess_party | null; - /** - * An instrument that is trading on the VEGA network - */ - market: Guess_market | null; -} - -export interface GuessVariables { - guess: string; -} diff --git a/libs/graphql/src/data-providers/index.ts b/libs/graphql/src/data-providers/index.ts deleted file mode 100644 index 2d8321fb2..000000000 --- a/libs/graphql/src/data-providers/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './markets-data-provider'; -export * from './positions-data-provider'; -export type { Subscribe } from './generic-data-provider'; diff --git a/libs/graphql/src/index.ts b/libs/graphql/src/index.ts index 575a2c27a..f2426ad97 100644 --- a/libs/graphql/src/index.ts +++ b/libs/graphql/src/index.ts @@ -1,21 +1 @@ -export * from './__generated__/AssetsQuery'; export * from './__generated__/globalTypes'; -export * from './__generated__/Guess'; -export * from './__generated__/Market'; -export * from './__generated__/MarketDataFields'; -export * from './__generated__/MarketDataSub'; -export * from './__generated__/Markets'; -export * from './__generated__/MarketsQuery'; -export * from './__generated__/NetworkParametersQuery'; -export * from './__generated__/NodesQuery'; -export * from './__generated__/OrderEvent'; -export * from './__generated__/OrderFields'; -export * from './__generated__/Orders'; -export * from './__generated__/OrderSub'; -export * from './__generated__/PartyAssetsQuery'; -export * from './__generated__/PositionDetails'; -export * from './__generated__/Positions'; -export * from './__generated__/PositionSubscribe'; -export * from './__generated__/ProposalsQuery'; - -export * from './data-providers'; diff --git a/libs/market-list/.eslintrc.json b/libs/market-list/.eslintrc.json index 734ddacee..db820c5d0 100644 --- a/libs/market-list/.eslintrc.json +++ b/libs/market-list/.eslintrc.json @@ -1,6 +1,6 @@ { "extends": ["plugin:@nrwl/nx/react", "../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], + "ignorePatterns": ["!**/*", "__generated__"], "overrides": [ { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], diff --git a/libs/market-list/src/index.ts b/libs/market-list/src/index.ts index a681b7d24..d6791d111 100644 --- a/libs/market-list/src/index.ts +++ b/libs/market-list/src/index.ts @@ -1 +1,2 @@ export * from './lib/market-list-table'; +export * from './lib/markets-container'; diff --git a/libs/graphql/src/__generated__/MarketDataFields.ts b/libs/market-list/src/lib/__generated__/MarketDataFields.ts similarity index 90% rename from libs/graphql/src/__generated__/MarketDataFields.ts rename to libs/market-list/src/lib/__generated__/MarketDataFields.ts index eb9675cbe..df9204e68 100644 --- a/libs/graphql/src/__generated__/MarketDataFields.ts +++ b/libs/market-list/src/lib/__generated__/MarketDataFields.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { MarketState, MarketTradingMode } from "./globalTypes"; +import { MarketState, MarketTradingMode } from "./../../../../graphql/src/__generated__/globalTypes"; // ==================================================== // GraphQL fragment: MarketDataFields diff --git a/libs/graphql/src/__generated__/MarketDataSub.ts b/libs/market-list/src/lib/__generated__/MarketDataSub.ts similarity index 91% rename from libs/graphql/src/__generated__/MarketDataSub.ts rename to libs/market-list/src/lib/__generated__/MarketDataSub.ts index 9e88d087f..80d1783e6 100644 --- a/libs/graphql/src/__generated__/MarketDataSub.ts +++ b/libs/market-list/src/lib/__generated__/MarketDataSub.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { MarketState, MarketTradingMode } from "./globalTypes"; +import { MarketState, MarketTradingMode } from "./../../../../graphql/src/__generated__/globalTypes"; // ==================================================== // GraphQL subscription operation: MarketDataSub diff --git a/libs/graphql/src/__generated__/Markets.ts b/libs/market-list/src/lib/__generated__/Markets.ts similarity index 97% rename from libs/graphql/src/__generated__/Markets.ts rename to libs/market-list/src/lib/__generated__/Markets.ts index e7b0cd958..71751d9ee 100644 --- a/libs/graphql/src/__generated__/Markets.ts +++ b/libs/market-list/src/lib/__generated__/Markets.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { MarketState, MarketTradingMode } from "./globalTypes"; +import { MarketState, MarketTradingMode } from "./../../../../graphql/src/__generated__/globalTypes"; // ==================================================== // GraphQL query operation: Markets diff --git a/libs/market-list/src/lib/market-list-table.tsx b/libs/market-list/src/lib/market-list-table.tsx index 816844e02..8b58d21eb 100644 --- a/libs/market-list/src/lib/market-list-table.tsx +++ b/libs/market-list/src/lib/market-list-table.tsx @@ -2,7 +2,7 @@ import { forwardRef } from 'react'; import type { ValueFormatterParams } from 'ag-grid-community'; import { PriceCell, formatNumber } from '@vegaprotocol/react-helpers'; import { AgGridDynamic as AgGrid } from '@vegaprotocol/ui-toolkit'; -import { Markets_markets } from '@vegaprotocol/graphql'; +import { Markets_markets } from './__generated__/Markets'; import { AgGridColumn } from 'ag-grid-react'; import type { AgGridReact } from 'ag-grid-react'; diff --git a/libs/market-list/src/lib/markets-container.tsx b/libs/market-list/src/lib/markets-container.tsx new file mode 100644 index 000000000..b4813ccce --- /dev/null +++ b/libs/market-list/src/lib/markets-container.tsx @@ -0,0 +1,64 @@ +import { useRef, useCallback } from 'react'; +import { produce } from 'immer'; +import merge from 'lodash/merge'; +import { useRouter } from 'next/router'; +import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; +import { MarketListTable, getRowNodeId } from './market-list-table'; +import { useDataProvider } from '@vegaprotocol/react-helpers'; +import type { AgGridReact } from 'ag-grid-react'; +import { Markets_markets, Markets_markets_data } from './__generated__/Markets'; +import { marketsDataProvider } from './markets-data-provider'; + +export const MarketsContainer = () => { + const { pathname, push } = useRouter(); + const gridRef = useRef(null); + const update = useCallback( + (delta: Markets_markets_data) => { + const update: Markets_markets[] = []; + const add: Markets_markets[] = []; + if (!gridRef.current) { + return false; + } + const rowNode = gridRef.current.api.getRowNode( + getRowNodeId(delta.market) + ); + if (rowNode) { + const updatedData = produce( + rowNode.data.data, + (draft: Markets_markets_data) => merge(draft, delta) + ); + if (updatedData !== rowNode.data.data) { + update.push({ ...rowNode.data, data: updatedData }); + } + } + // @TODO - else add new market + if (update.length || add.length) { + gridRef.current.api.applyTransactionAsync({ + update, + add, + addIndex: 0, + }); + } + return true; + }, + [gridRef] + ); + const { data, error, loading } = useDataProvider< + Markets_markets, + Markets_markets_data + >(marketsDataProvider, update); + + return ( + + {(data) => ( + + push(`${pathname}/${id}?portfolio=orders&trade=orderbook`) + } + /> + )} + + ); +}; diff --git a/libs/graphql/src/data-providers/markets-data-provider.ts b/libs/market-list/src/lib/markets-data-provider.ts similarity index 89% rename from libs/graphql/src/data-providers/markets-data-provider.ts rename to libs/market-list/src/lib/markets-data-provider.ts index b163a1029..67f6fffc6 100644 --- a/libs/graphql/src/data-providers/markets-data-provider.ts +++ b/libs/market-list/src/lib/markets-data-provider.ts @@ -1,11 +1,11 @@ import { gql } from '@apollo/client'; -import { Markets, Markets_markets } from '../__generated__/Markets'; -import { makeDataProvider } from './generic-data-provider'; +import { Markets, Markets_markets } from './__generated__/Markets'; +import { makeDataProvider } from '@vegaprotocol/react-helpers'; import { MarketDataSub, MarketDataSub_marketData, -} from '../__generated__/MarketDataSub'; +} from './__generated__/MarketDataSub'; const MARKET_DATA_FRAGMENT = gql` fragment MarketDataFields on MarketData { diff --git a/libs/order-list/.eslintrc.json b/libs/order-list/.eslintrc.json index 734ddacee..db820c5d0 100644 --- a/libs/order-list/.eslintrc.json +++ b/libs/order-list/.eslintrc.json @@ -1,6 +1,6 @@ { "extends": ["plugin:@nrwl/nx/react", "../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], + "ignorePatterns": ["!**/*", "__generated__"], "overrides": [ { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], diff --git a/libs/graphql/src/__generated__/OrderFields.ts b/libs/order-list/src/__generated__/OrderFields.ts similarity index 97% rename from libs/graphql/src/__generated__/OrderFields.ts rename to libs/order-list/src/__generated__/OrderFields.ts index 1fa9bff65..194e5f380 100644 --- a/libs/graphql/src/__generated__/OrderFields.ts +++ b/libs/order-list/src/__generated__/OrderFields.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { OrderType, Side, OrderStatus, OrderRejectionReason, OrderTimeInForce } from "./globalTypes"; +import { OrderType, Side, OrderStatus, OrderRejectionReason, OrderTimeInForce } from "./../../../graphql/src/__generated__/globalTypes"; // ==================================================== // GraphQL fragment: OrderFields diff --git a/libs/graphql/src/__generated__/OrderSub.ts b/libs/order-list/src/__generated__/OrderSub.ts similarity index 98% rename from libs/graphql/src/__generated__/OrderSub.ts rename to libs/order-list/src/__generated__/OrderSub.ts index 8c8e05efc..127d3f57a 100644 --- a/libs/graphql/src/__generated__/OrderSub.ts +++ b/libs/order-list/src/__generated__/OrderSub.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { OrderType, Side, OrderStatus, OrderRejectionReason, OrderTimeInForce } from "./globalTypes"; +import { OrderType, Side, OrderStatus, OrderRejectionReason, OrderTimeInForce } from "./../../../graphql/src/__generated__/globalTypes"; // ==================================================== // GraphQL subscription operation: OrderSub diff --git a/libs/graphql/src/__generated__/Orders.ts b/libs/order-list/src/__generated__/Orders.ts similarity index 98% rename from libs/graphql/src/__generated__/Orders.ts rename to libs/order-list/src/__generated__/Orders.ts index 37f376e44..d08bdde03 100644 --- a/libs/graphql/src/__generated__/Orders.ts +++ b/libs/order-list/src/__generated__/Orders.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { OrderType, Side, OrderStatus, OrderRejectionReason, OrderTimeInForce } from "./globalTypes"; +import { OrderType, Side, OrderStatus, OrderRejectionReason, OrderTimeInForce } from "./../../../graphql/src/__generated__/globalTypes"; // ==================================================== // GraphQL query operation: Orders diff --git a/libs/order-list/src/index.ts b/libs/order-list/src/index.ts index d432bcbe8..3d3fcc27c 100644 --- a/libs/order-list/src/index.ts +++ b/libs/order-list/src/index.ts @@ -1 +1,2 @@ export * from './order-list'; +export * from './order-list-container'; diff --git a/apps/trading/components/order-list-container/order-list-container.spec.tsx b/libs/order-list/src/order-list-container.spec.tsx similarity index 77% rename from apps/trading/components/order-list-container/order-list-container.spec.tsx rename to libs/order-list/src/order-list-container.spec.tsx index 77a64470d..08ff862ae 100644 --- a/apps/trading/components/order-list-container/order-list-container.spec.tsx +++ b/libs/order-list/src/order-list-container.spec.tsx @@ -1,9 +1,9 @@ -import { OrderListContainer } from './order-list-container'; -import * as useOrdersHook from '../../hooks/use-orders'; import { render, screen } from '@testing-library/react'; -import { Orders_party_orders } from '@vegaprotocol/graphql'; +import { OrderListContainer } from './order-list-container'; +import * as useOrdersHook from './use-orders'; +import { Orders_party_orders } from './__generated__/Orders'; -jest.mock('@vegaprotocol/order-list', () => ({ +jest.mock('./order-list', () => ({ OrderList: () =>
OrderList
, })); @@ -30,12 +30,12 @@ test('Renders an error state', () => { ).toBeInTheDocument(); }); -test('Renders the order list if orders provided', () => { +test('Renders the order list if orders provided', async () => { jest.spyOn(useOrdersHook, 'useOrders').mockReturnValue({ orders: [{ id: '1' } as Orders_party_orders], loading: false, error: null, }); render(); - expect(screen.getByText('OrderList')).toBeInTheDocument(); + expect(await screen.findByText('OrderList')).toBeInTheDocument(); }); diff --git a/apps/trading/components/order-list-container/order-list-container.tsx b/libs/order-list/src/order-list-container.tsx similarity index 55% rename from apps/trading/components/order-list-container/order-list-container.tsx rename to libs/order-list/src/order-list-container.tsx index 246891559..676008b2e 100644 --- a/apps/trading/components/order-list-container/order-list-container.tsx +++ b/libs/order-list/src/order-list-container.tsx @@ -1,7 +1,7 @@ -import { useOrders } from '../../hooks/use-orders'; -import { OrderList } from '@vegaprotocol/order-list'; -import { AsyncRenderer } from '../async-renderer'; -import { OrderFields } from '@vegaprotocol/graphql'; +import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; +import { useOrders } from './use-orders'; +import { OrderList } from './order-list'; +import { OrderFields } from './__generated__/OrderFields'; export const OrderListContainer = () => { const { orders, loading, error } = useOrders(); diff --git a/libs/order-list/src/order-list.spec.tsx b/libs/order-list/src/order-list.spec.tsx index cec0664de..51d0622b0 100644 --- a/libs/order-list/src/order-list.spec.tsx +++ b/libs/order-list/src/order-list.spec.tsx @@ -1,6 +1,6 @@ import { act, render, screen } from '@testing-library/react'; import { formatNumber, getDateTimeFormat } from '@vegaprotocol/react-helpers'; -import { Orders_party_orders } from '@vegaprotocol/graphql'; +import { Orders_party_orders } from './__generated__/Orders'; import { OrderStatus, OrderTimeInForce, diff --git a/libs/order-list/src/order-list.tsx b/libs/order-list/src/order-list.tsx index 49f60c7f9..d007aab6a 100644 --- a/libs/order-list/src/order-list.tsx +++ b/libs/order-list/src/order-list.tsx @@ -1,9 +1,5 @@ -import { - Orders_party_orders, - OrderTimeInForce, - OrderStatus, - Side, -} from '@vegaprotocol/graphql'; +import { OrderTimeInForce, OrderStatus, Side } from '@vegaprotocol/graphql'; +import { Orders_party_orders } from './__generated__/Orders'; import { formatNumber, getDateTimeFormat, diff --git a/apps/trading/hooks/use-orders.spec.tsx b/libs/order-list/src/use-orders.spec.tsx similarity index 96% rename from apps/trading/hooks/use-orders.spec.tsx rename to libs/order-list/src/use-orders.spec.tsx index ae3fbdf14..e8f08a2cc 100644 --- a/apps/trading/hooks/use-orders.spec.tsx +++ b/libs/order-list/src/use-orders.spec.tsx @@ -1,13 +1,13 @@ import { MockedProvider, MockedResponse } from '@apollo/client/testing'; import { renderHook } from '@testing-library/react-hooks'; +import { OrderFields } from './__generated__/OrderFields'; +import { Orders } from './__generated__/Orders'; +import { OrderSub } from './__generated__/OrderSub'; import { - OrderFields, - Orders, OrderStatus, - OrderSub, - OrderTimeInForce, - OrderType, Side, + OrderType, + OrderTimeInForce, } from '@vegaprotocol/graphql'; import { VegaKeyExtended, diff --git a/apps/trading/hooks/use-orders.ts b/libs/order-list/src/use-orders.ts similarity index 94% rename from apps/trading/hooks/use-orders.ts rename to libs/order-list/src/use-orders.ts index 53d99d61d..4190e3395 100644 --- a/apps/trading/hooks/use-orders.ts +++ b/libs/order-list/src/use-orders.ts @@ -1,15 +1,11 @@ -import { gql, useApolloClient } from '@apollo/client'; import { useCallback, useEffect, useState } from 'react'; -import { - OrderSub, - OrderSubVariables, - Orders, - OrdersVariables, - OrderFields, -} from '@vegaprotocol/graphql'; +import { gql, useApolloClient } from '@apollo/client'; import uniqBy from 'lodash/uniqBy'; import orderBy from 'lodash/orderBy'; import { useVegaWallet } from '@vegaprotocol/wallet'; +import { Orders, OrdersVariables } from './__generated__/Orders'; +import { OrderSub, OrderSubVariables } from './__generated__/OrderSub'; +import { OrderFields } from './__generated__/OrderFields'; const ORDER_FRAGMENT = gql` fragment OrderFields on Order { diff --git a/libs/positions/.eslintrc.json b/libs/positions/.eslintrc.json index 734ddacee..db820c5d0 100644 --- a/libs/positions/.eslintrc.json +++ b/libs/positions/.eslintrc.json @@ -1,6 +1,6 @@ { "extends": ["plugin:@nrwl/nx/react", "../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], + "ignorePatterns": ["!**/*", "__generated__"], "overrides": [ { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], diff --git a/libs/positions/src/index.ts b/libs/positions/src/index.ts index 2b3811e35..8c1c401eb 100644 --- a/libs/positions/src/index.ts +++ b/libs/positions/src/index.ts @@ -1 +1,3 @@ export * from './lib/positions-table'; +export * from './lib/positions-container'; +export * from './lib/positions-data-provider'; diff --git a/libs/graphql/src/__generated__/PositionDetails.ts b/libs/positions/src/lib/__generated__/PositionDetails.ts similarity index 98% rename from libs/graphql/src/__generated__/PositionDetails.ts rename to libs/positions/src/lib/__generated__/PositionDetails.ts index 2667543dc..d0acbf457 100644 --- a/libs/graphql/src/__generated__/PositionDetails.ts +++ b/libs/positions/src/lib/__generated__/PositionDetails.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { MarketTradingMode } from "./globalTypes"; +import { MarketTradingMode } from "./../../../../graphql/src/__generated__/globalTypes"; // ==================================================== // GraphQL fragment: PositionDetails diff --git a/libs/graphql/src/__generated__/PositionSubscribe.ts b/libs/positions/src/lib/__generated__/PositionSubscribe.ts similarity index 98% rename from libs/graphql/src/__generated__/PositionSubscribe.ts rename to libs/positions/src/lib/__generated__/PositionSubscribe.ts index d4d470bd2..7a4b454dd 100644 --- a/libs/graphql/src/__generated__/PositionSubscribe.ts +++ b/libs/positions/src/lib/__generated__/PositionSubscribe.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { MarketTradingMode } from "./globalTypes"; +import { MarketTradingMode } from "./../../../../graphql/src/__generated__/globalTypes"; // ==================================================== // GraphQL subscription operation: PositionSubscribe diff --git a/libs/graphql/src/__generated__/Positions.ts b/libs/positions/src/lib/__generated__/Positions.ts similarity index 98% rename from libs/graphql/src/__generated__/Positions.ts rename to libs/positions/src/lib/__generated__/Positions.ts index 14c90f956..89bb420ff 100644 --- a/libs/graphql/src/__generated__/Positions.ts +++ b/libs/positions/src/lib/__generated__/Positions.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { MarketTradingMode } from "./globalTypes"; +import { MarketTradingMode } from "./../../../../graphql/src/__generated__/globalTypes"; // ==================================================== // GraphQL query operation: Positions diff --git a/apps/trading/pages/markets/positions.tsx b/libs/positions/src/lib/positions-container.tsx similarity index 83% rename from apps/trading/pages/markets/positions.tsx rename to libs/positions/src/lib/positions-container.tsx index a35006add..73ce63e7b 100644 --- a/apps/trading/pages/markets/positions.tsx +++ b/libs/positions/src/lib/positions-container.tsx @@ -2,19 +2,17 @@ import { useRef, useCallback, useMemo } from 'react'; import { produce } from 'immer'; import merge from 'lodash/merge'; import { useRouter } from 'next/router'; -import { AsyncRenderer } from '../../components/async-renderer'; -import { PositionsTable, getRowNodeId } from '@vegaprotocol/positions'; +import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; import { useDataProvider } from '@vegaprotocol/react-helpers'; -import { - Positions_party_positions, - PositionSubscribe_positions, - positionsDataProvider, -} from '@vegaprotocol/graphql'; import { useVegaWallet } from '@vegaprotocol/wallet'; +import { PositionSubscribe_positions } from './__generated__/PositionSubscribe'; +import { Positions_party_positions } from './__generated__/Positions'; import type { AgGridReact } from 'ag-grid-react'; +import PositionsTable, { getRowNodeId } from './positions-table'; +import { positionsDataProvider } from './positions-data-provider'; -export const Positions = () => { +export const PositionsContainer = () => { const { pathname, push } = useRouter(); const gridRef = useRef(null); const { keypair } = useVegaWallet(); diff --git a/libs/graphql/src/data-providers/positions-data-provider.ts b/libs/positions/src/lib/positions-data-provider.ts similarity index 93% rename from libs/graphql/src/data-providers/positions-data-provider.ts rename to libs/positions/src/lib/positions-data-provider.ts index cd661f03e..74281dc4e 100644 --- a/libs/graphql/src/data-providers/positions-data-provider.ts +++ b/libs/positions/src/lib/positions-data-provider.ts @@ -2,13 +2,13 @@ import { gql } from '@apollo/client'; import { Positions, Positions_party_positions, -} from '../__generated__/Positions'; -import { makeDataProvider } from './generic-data-provider'; +} from './__generated__/Positions'; +import { makeDataProvider } from '@vegaprotocol/react-helpers'; import { PositionSubscribe, PositionSubscribe_positions, -} from '../__generated__/PositionSubscribe'; +} from './__generated__/PositionSubscribe'; const POSITIONS_FRAGMENT = gql` fragment PositionDetails on Position { diff --git a/libs/positions/src/lib/positions-table.spec.tsx b/libs/positions/src/lib/positions-table.spec.tsx index 5265fd17a..198dbe028 100644 --- a/libs/positions/src/lib/positions-table.spec.tsx +++ b/libs/positions/src/lib/positions-table.spec.tsx @@ -1,9 +1,7 @@ import { act, render, screen } from '@testing-library/react'; import PositionsTable from './positions-table'; -import { - Positions_party_positions, - MarketTradingMode, -} from '@vegaprotocol/graphql'; +import { Positions_party_positions } from './__generated__/Positions'; +import { MarketTradingMode } from '@vegaprotocol/graphql'; const singleRow: Positions_party_positions = { realisedPNL: '5', diff --git a/libs/positions/src/lib/positions-table.tsx b/libs/positions/src/lib/positions-table.tsx index 61e094490..843a6be24 100644 --- a/libs/positions/src/lib/positions-table.tsx +++ b/libs/positions/src/lib/positions-table.tsx @@ -10,10 +10,8 @@ import { AgGridDynamic as AgGrid } from '@vegaprotocol/ui-toolkit'; import { AgGridColumn } from 'ag-grid-react'; import type { AgGridReact } from 'ag-grid-react'; import compact from 'lodash/compact'; -import { - Positions_party_positions, - MarketTradingMode, -} from '@vegaprotocol/graphql'; +import { Positions_party_positions } from './__generated__/Positions'; +import { MarketTradingMode } from '@vegaprotocol/graphql'; interface PositionsTableProps { data: Positions_party_positions[] | null; diff --git a/libs/react-helpers/src/hooks/use-data-provider.ts b/libs/react-helpers/src/hooks/use-data-provider.ts index 9cf3a99d3..dec3596a6 100644 --- a/libs/react-helpers/src/hooks/use-data-provider.ts +++ b/libs/react-helpers/src/hooks/use-data-provider.ts @@ -1,7 +1,7 @@ import { useState, useEffect, useRef, useCallback } from 'react'; import { useApolloClient } from '@apollo/client'; import type { OperationVariables } from '@apollo/client'; -import type { Subscribe } from '@vegaprotocol/graphql'; +import type { Subscribe } from '../lib/generic-data-provider'; export function useDataProvider( dataProvider: Subscribe, diff --git a/libs/react-helpers/src/index.ts b/libs/react-helpers/src/index.ts index efc2cfa4e..3ae1eb02c 100644 --- a/libs/react-helpers/src/index.ts +++ b/libs/react-helpers/src/index.ts @@ -4,5 +4,6 @@ export * from './lib/decimals'; export * from './lib/format'; export * from './lib/grid-cells'; export * from './lib/storage'; +export * from './lib/generic-data-provider'; export * from './hooks'; diff --git a/libs/graphql/src/data-providers/generic-data-provider.ts b/libs/react-helpers/src/lib/generic-data-provider.ts similarity index 100% rename from libs/graphql/src/data-providers/generic-data-provider.ts rename to libs/react-helpers/src/lib/generic-data-provider.ts diff --git a/apps/trading/components/async-renderer/async-renderer.tsx b/libs/ui-toolkit/src/components/async-renderer/async-renderer.tsx similarity index 91% rename from apps/trading/components/async-renderer/async-renderer.tsx rename to libs/ui-toolkit/src/components/async-renderer/async-renderer.tsx index f886ac740..a918ca23e 100644 --- a/apps/trading/components/async-renderer/async-renderer.tsx +++ b/libs/ui-toolkit/src/components/async-renderer/async-renderer.tsx @@ -1,4 +1,4 @@ -import { Splash } from '@vegaprotocol/ui-toolkit'; +import { Splash } from '../splash'; import { ReactNode } from 'react'; interface AsyncRendererProps { diff --git a/apps/trading/components/async-renderer/index.ts b/libs/ui-toolkit/src/components/async-renderer/index.ts similarity index 100% rename from apps/trading/components/async-renderer/index.ts rename to libs/ui-toolkit/src/components/async-renderer/index.ts diff --git a/libs/ui-toolkit/src/index.ts b/libs/ui-toolkit/src/index.ts index 27bb0a3a1..e9633036c 100644 --- a/libs/ui-toolkit/src/index.ts +++ b/libs/ui-toolkit/src/index.ts @@ -2,6 +2,7 @@ import * as EthereumUtils from './utils/web3'; // Components export { AgGridLazy, AgGridDynamic } from './components/ag-grid'; +export { AsyncRenderer } from './components/async-renderer'; export { Button, AnchorButton } from './components/button'; export { Callout } from './components/callout'; export { EthereumUtils }; diff --git a/libs/wallet/src/index.ts b/libs/wallet/src/index.ts index 0e4c016fa..b4b4d9ae2 100644 --- a/libs/wallet/src/index.ts +++ b/libs/wallet/src/index.ts @@ -5,3 +5,4 @@ export * from './connect-dialog'; export * from './connectors'; export * from './storage-keys'; export * from './types'; +export * from './use-vega-transaction'; diff --git a/apps/trading/hooks/use-vega-transaction.spec.tsx b/libs/wallet/src/use-vega-transaction.spec.tsx similarity index 96% rename from apps/trading/hooks/use-vega-transaction.spec.tsx rename to libs/wallet/src/use-vega-transaction.spec.tsx index 5b7be1f4d..e563cd42c 100644 --- a/apps/trading/hooks/use-vega-transaction.spec.tsx +++ b/libs/wallet/src/use-vega-transaction.spec.tsx @@ -1,11 +1,8 @@ import { act, renderHook } from '@testing-library/react-hooks'; -import { - OrderSubmission, - VegaWalletContext, - VegaWalletContextShape, -} from '@vegaprotocol/wallet'; +import { VegaWalletContext, VegaWalletContextShape } from './context'; import { ReactNode } from 'react'; import { useVegaTransaction, VegaTxStatus } from './use-vega-transaction'; +import { OrderSubmission } from './types'; const defaultWalletContext = { keypair: null, diff --git a/apps/trading/hooks/use-vega-transaction.ts b/libs/wallet/src/use-vega-transaction.ts similarity index 94% rename from apps/trading/hooks/use-vega-transaction.ts rename to libs/wallet/src/use-vega-transaction.ts index 00fe9c5e7..b30b188ac 100644 --- a/apps/trading/hooks/use-vega-transaction.ts +++ b/libs/wallet/src/use-vega-transaction.ts @@ -1,5 +1,7 @@ import { useCallback, useState } from 'react'; -import { useVegaWallet, SendTxError, Transaction } from '@vegaprotocol/wallet'; +import { Transaction } from './types'; +import { useVegaWallet } from './hooks'; +import { SendTxError } from './context'; export enum VegaTxStatus { Default = 'Default', From edce1c7869928dafb2a99be9a37f72bc52cf9234 Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Tue, 29 Mar 2022 16:03:27 -0700 Subject: [PATCH 02/10] rename graphql dir to types --- .../assets/__generated__/AssetsQuery.ts | 2 +- .../__generated__/ProposalsQuery.ts | 2 +- .../markets/__generated__/MarketsQuery.ts | 2 +- .../id/__generated__/PartyAssetsQuery.ts | 2 +- .../validators/__generated__/NodesQuery.ts | 2 +- .../pages/markets/__generated__/Market.ts | 2 +- .../src/__generated__/DealTicketQuery.ts | 2 +- .../src/__generated__/OrderEvent.ts | 2 +- libs/deal-ticket/src/deal-ticket-manager.tsx | 2 +- libs/graphql/README.md | 7 ------ libs/graphql/package.json | 4 ---- .../src/lib/__generated__/MarketDataFields.ts | 2 +- .../src/lib/__generated__/MarketDataSub.ts | 2 +- .../src/lib/__generated__/Markets.ts | 2 +- .../src/__generated__/OrderFields.ts | 2 +- libs/order-list/src/__generated__/OrderSub.ts | 2 +- libs/order-list/src/__generated__/Orders.ts | 2 +- libs/order-list/src/order-list.spec.tsx | 2 +- libs/order-list/src/order-list.tsx | 2 +- libs/order-list/src/use-orders.spec.tsx | 2 +- .../src/lib/__generated__/PositionDetails.ts | 2 +- .../lib/__generated__/PositionSubscribe.ts | 2 +- .../src/lib/__generated__/Positions.ts | 2 +- .../src/lib/positions-table.spec.tsx | 2 +- libs/positions/src/lib/positions-table.tsx | 2 +- libs/{graphql => types}/.babelrc | 0 libs/{graphql => types}/.eslintrc.json | 0 libs/types/README.md | 7 ++++++ libs/{graphql => types}/apollo.config.js | 0 libs/{graphql => types}/jest.config.js | 4 ++-- libs/types/package.json | 4 ++++ libs/{graphql => types}/project.json | 22 +++++++++---------- .../src/__generated__/globalTypes.ts | 0 libs/{graphql => types}/src/index.ts | 0 libs/{graphql => types}/tsconfig.json | 0 libs/{graphql => types}/tsconfig.lib.json | 0 libs/{graphql => types}/tsconfig.spec.json | 0 tsconfig.base.json | 2 +- workspace.json | 2 +- 39 files changed, 49 insertions(+), 49 deletions(-) delete mode 100644 libs/graphql/README.md delete mode 100644 libs/graphql/package.json rename libs/{graphql => types}/.babelrc (100%) rename libs/{graphql => types}/.eslintrc.json (100%) create mode 100644 libs/types/README.md rename libs/{graphql => types}/apollo.config.js (100%) rename libs/{graphql => types}/jest.config.js (67%) create mode 100644 libs/types/package.json rename libs/{graphql => types}/project.json (61%) rename libs/{graphql => types}/src/__generated__/globalTypes.ts (100%) rename libs/{graphql => types}/src/index.ts (100%) rename libs/{graphql => types}/tsconfig.json (100%) rename libs/{graphql => types}/tsconfig.lib.json (100%) rename libs/{graphql => types}/tsconfig.spec.json (100%) diff --git a/apps/explorer/src/app/routes/assets/__generated__/AssetsQuery.ts b/apps/explorer/src/app/routes/assets/__generated__/AssetsQuery.ts index 554ee5c3f..1a610de95 100644 --- a/apps/explorer/src/app/routes/assets/__generated__/AssetsQuery.ts +++ b/apps/explorer/src/app/routes/assets/__generated__/AssetsQuery.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { AccountType } from "./../../../../../../../libs/graphql/src/__generated__/globalTypes"; +import { AccountType } from "./../../../../../../../libs/types/src/__generated__/globalTypes"; // ==================================================== // GraphQL query operation: AssetsQuery diff --git a/apps/explorer/src/app/routes/governance/__generated__/ProposalsQuery.ts b/apps/explorer/src/app/routes/governance/__generated__/ProposalsQuery.ts index 95c1869fb..01beb9781 100644 --- a/apps/explorer/src/app/routes/governance/__generated__/ProposalsQuery.ts +++ b/apps/explorer/src/app/routes/governance/__generated__/ProposalsQuery.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { ProposalState, ProposalRejectionReason, VoteValue } from "./../../../../../../../libs/graphql/src/__generated__/globalTypes"; +import { ProposalState, ProposalRejectionReason, VoteValue } from "./../../../../../../../libs/types/src/__generated__/globalTypes"; // ==================================================== // GraphQL query operation: ProposalsQuery diff --git a/apps/explorer/src/app/routes/markets/__generated__/MarketsQuery.ts b/apps/explorer/src/app/routes/markets/__generated__/MarketsQuery.ts index d2d476668..a845cf55e 100644 --- a/apps/explorer/src/app/routes/markets/__generated__/MarketsQuery.ts +++ b/apps/explorer/src/app/routes/markets/__generated__/MarketsQuery.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { MarketTradingMode, MarketState, AccountType, AuctionTrigger } from "./../../../../../../../libs/graphql/src/__generated__/globalTypes"; +import { MarketTradingMode, MarketState, AccountType, AuctionTrigger } from "./../../../../../../../libs/types/src/__generated__/globalTypes"; // ==================================================== // GraphQL query operation: MarketsQuery 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 fd88252b9..623bd276c 100644 --- a/apps/explorer/src/app/routes/parties/id/__generated__/PartyAssetsQuery.ts +++ b/apps/explorer/src/app/routes/parties/id/__generated__/PartyAssetsQuery.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { AccountType } from "./../../../../../../../../libs/graphql/src/__generated__/globalTypes"; +import { AccountType } from "./../../../../../../../../libs/types/src/__generated__/globalTypes"; // ==================================================== // GraphQL query operation: PartyAssetsQuery diff --git a/apps/explorer/src/app/routes/validators/__generated__/NodesQuery.ts b/apps/explorer/src/app/routes/validators/__generated__/NodesQuery.ts index 478c6f528..0df9fe0e1 100644 --- a/apps/explorer/src/app/routes/validators/__generated__/NodesQuery.ts +++ b/apps/explorer/src/app/routes/validators/__generated__/NodesQuery.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { NodeStatus } from "./../../../../../../../libs/graphql/src/__generated__/globalTypes"; +import { NodeStatus } from "./../../../../../../../libs/types/src/__generated__/globalTypes"; // ==================================================== // GraphQL query operation: NodesQuery diff --git a/apps/trading/pages/markets/__generated__/Market.ts b/apps/trading/pages/markets/__generated__/Market.ts index a862a3ce3..24f68b822 100644 --- a/apps/trading/pages/markets/__generated__/Market.ts +++ b/apps/trading/pages/markets/__generated__/Market.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { MarketState, MarketTradingMode } from "./../../../../../libs/graphql/src/__generated__/globalTypes"; +import { MarketState, MarketTradingMode } from "./../../../../../libs/types/src/__generated__/globalTypes"; // ==================================================== // GraphQL query operation: Market diff --git a/libs/deal-ticket/src/__generated__/DealTicketQuery.ts b/libs/deal-ticket/src/__generated__/DealTicketQuery.ts index 804923d09..8a18b4c53 100644 --- a/libs/deal-ticket/src/__generated__/DealTicketQuery.ts +++ b/libs/deal-ticket/src/__generated__/DealTicketQuery.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { MarketState, MarketTradingMode } from "./../../../graphql/src/__generated__/globalTypes"; +import { MarketState, MarketTradingMode } from "./../../../types/src/__generated__/globalTypes"; // ==================================================== // GraphQL query operation: DealTicketQuery diff --git a/libs/deal-ticket/src/__generated__/OrderEvent.ts b/libs/deal-ticket/src/__generated__/OrderEvent.ts index 1ac9d2455..4922d70ab 100644 --- a/libs/deal-ticket/src/__generated__/OrderEvent.ts +++ b/libs/deal-ticket/src/__generated__/OrderEvent.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { BusEventType, OrderType, OrderStatus, OrderRejectionReason } from "./../../../graphql/src/__generated__/globalTypes"; +import { BusEventType, OrderType, OrderStatus, OrderRejectionReason } from "./../../../types/src/__generated__/globalTypes"; // ==================================================== // GraphQL subscription operation: OrderEvent diff --git a/libs/deal-ticket/src/deal-ticket-manager.tsx b/libs/deal-ticket/src/deal-ticket-manager.tsx index 0e2a0c86b..837cb15ce 100644 --- a/libs/deal-ticket/src/deal-ticket-manager.tsx +++ b/libs/deal-ticket/src/deal-ticket-manager.tsx @@ -1,6 +1,6 @@ import { useEffect, useState } from 'react'; import { Dialog, Intent } from '@vegaprotocol/ui-toolkit'; -import { OrderStatus } from '@vegaprotocol/graphql'; +import { OrderStatus } from '@vegaprotocol/types'; import { VegaTxStatus } from '@vegaprotocol/wallet'; import { DealTicket } from './deal-ticket'; import { useOrderSubmit } from './use-order-submit'; diff --git a/libs/graphql/README.md b/libs/graphql/README.md deleted file mode 100644 index 6342967d9..000000000 --- a/libs/graphql/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# graphql - -This library was generated with [Nx](https://nx.dev). - -## Running unit tests - -Run `nx test graphql` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/libs/graphql/package.json b/libs/graphql/package.json deleted file mode 100644 index d2fdb2ce1..000000000 --- a/libs/graphql/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "@vegaprotocol/graphql", - "version": "0.0.1" -} diff --git a/libs/market-list/src/lib/__generated__/MarketDataFields.ts b/libs/market-list/src/lib/__generated__/MarketDataFields.ts index df9204e68..9a4a3d1e9 100644 --- a/libs/market-list/src/lib/__generated__/MarketDataFields.ts +++ b/libs/market-list/src/lib/__generated__/MarketDataFields.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { MarketState, MarketTradingMode } from "./../../../../graphql/src/__generated__/globalTypes"; +import { MarketState, MarketTradingMode } from "./../../../../types/src/__generated__/globalTypes"; // ==================================================== // GraphQL fragment: MarketDataFields diff --git a/libs/market-list/src/lib/__generated__/MarketDataSub.ts b/libs/market-list/src/lib/__generated__/MarketDataSub.ts index 80d1783e6..91b6972b8 100644 --- a/libs/market-list/src/lib/__generated__/MarketDataSub.ts +++ b/libs/market-list/src/lib/__generated__/MarketDataSub.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { MarketState, MarketTradingMode } from "./../../../../graphql/src/__generated__/globalTypes"; +import { MarketState, MarketTradingMode } from "./../../../../types/src/__generated__/globalTypes"; // ==================================================== // GraphQL subscription operation: MarketDataSub diff --git a/libs/market-list/src/lib/__generated__/Markets.ts b/libs/market-list/src/lib/__generated__/Markets.ts index 71751d9ee..6f59a34a9 100644 --- a/libs/market-list/src/lib/__generated__/Markets.ts +++ b/libs/market-list/src/lib/__generated__/Markets.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { MarketState, MarketTradingMode } from "./../../../../graphql/src/__generated__/globalTypes"; +import { MarketState, MarketTradingMode } from "./../../../../types/src/__generated__/globalTypes"; // ==================================================== // GraphQL query operation: Markets diff --git a/libs/order-list/src/__generated__/OrderFields.ts b/libs/order-list/src/__generated__/OrderFields.ts index 194e5f380..2ea07eae8 100644 --- a/libs/order-list/src/__generated__/OrderFields.ts +++ b/libs/order-list/src/__generated__/OrderFields.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { OrderType, Side, OrderStatus, OrderRejectionReason, OrderTimeInForce } from "./../../../graphql/src/__generated__/globalTypes"; +import { OrderType, Side, OrderStatus, OrderRejectionReason, OrderTimeInForce } from "./../../../types/src/__generated__/globalTypes"; // ==================================================== // GraphQL fragment: OrderFields diff --git a/libs/order-list/src/__generated__/OrderSub.ts b/libs/order-list/src/__generated__/OrderSub.ts index 127d3f57a..c6cc6a03c 100644 --- a/libs/order-list/src/__generated__/OrderSub.ts +++ b/libs/order-list/src/__generated__/OrderSub.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { OrderType, Side, OrderStatus, OrderRejectionReason, OrderTimeInForce } from "./../../../graphql/src/__generated__/globalTypes"; +import { OrderType, Side, OrderStatus, OrderRejectionReason, OrderTimeInForce } from "./../../../types/src/__generated__/globalTypes"; // ==================================================== // GraphQL subscription operation: OrderSub diff --git a/libs/order-list/src/__generated__/Orders.ts b/libs/order-list/src/__generated__/Orders.ts index d08bdde03..e75bc76f5 100644 --- a/libs/order-list/src/__generated__/Orders.ts +++ b/libs/order-list/src/__generated__/Orders.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { OrderType, Side, OrderStatus, OrderRejectionReason, OrderTimeInForce } from "./../../../graphql/src/__generated__/globalTypes"; +import { OrderType, Side, OrderStatus, OrderRejectionReason, OrderTimeInForce } from "./../../../types/src/__generated__/globalTypes"; // ==================================================== // GraphQL query operation: Orders diff --git a/libs/order-list/src/order-list.spec.tsx b/libs/order-list/src/order-list.spec.tsx index 51d0622b0..8dc9e57dc 100644 --- a/libs/order-list/src/order-list.spec.tsx +++ b/libs/order-list/src/order-list.spec.tsx @@ -7,7 +7,7 @@ import { OrderType, Side, OrderRejectionReason, -} from '@vegaprotocol/graphql'; +} from '@vegaprotocol/types'; import { OrderList } from './order-list'; test('No orders message shown', async () => { diff --git a/libs/order-list/src/order-list.tsx b/libs/order-list/src/order-list.tsx index d007aab6a..6ea026ca9 100644 --- a/libs/order-list/src/order-list.tsx +++ b/libs/order-list/src/order-list.tsx @@ -1,4 +1,4 @@ -import { OrderTimeInForce, OrderStatus, Side } from '@vegaprotocol/graphql'; +import { OrderTimeInForce, OrderStatus, Side } from '@vegaprotocol/types'; import { Orders_party_orders } from './__generated__/Orders'; import { formatNumber, diff --git a/libs/order-list/src/use-orders.spec.tsx b/libs/order-list/src/use-orders.spec.tsx index e8f08a2cc..bb7659ae8 100644 --- a/libs/order-list/src/use-orders.spec.tsx +++ b/libs/order-list/src/use-orders.spec.tsx @@ -8,7 +8,7 @@ import { Side, OrderType, OrderTimeInForce, -} from '@vegaprotocol/graphql'; +} from '@vegaprotocol/types'; import { VegaKeyExtended, VegaWalletContext, diff --git a/libs/positions/src/lib/__generated__/PositionDetails.ts b/libs/positions/src/lib/__generated__/PositionDetails.ts index d0acbf457..c2db215e2 100644 --- a/libs/positions/src/lib/__generated__/PositionDetails.ts +++ b/libs/positions/src/lib/__generated__/PositionDetails.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { MarketTradingMode } from "./../../../../graphql/src/__generated__/globalTypes"; +import { MarketTradingMode } from "./../../../../types/src/__generated__/globalTypes"; // ==================================================== // GraphQL fragment: PositionDetails diff --git a/libs/positions/src/lib/__generated__/PositionSubscribe.ts b/libs/positions/src/lib/__generated__/PositionSubscribe.ts index 7a4b454dd..ef93c2449 100644 --- a/libs/positions/src/lib/__generated__/PositionSubscribe.ts +++ b/libs/positions/src/lib/__generated__/PositionSubscribe.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { MarketTradingMode } from "./../../../../graphql/src/__generated__/globalTypes"; +import { MarketTradingMode } from "./../../../../types/src/__generated__/globalTypes"; // ==================================================== // GraphQL subscription operation: PositionSubscribe diff --git a/libs/positions/src/lib/__generated__/Positions.ts b/libs/positions/src/lib/__generated__/Positions.ts index 89bb420ff..c1c1e32c0 100644 --- a/libs/positions/src/lib/__generated__/Positions.ts +++ b/libs/positions/src/lib/__generated__/Positions.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { MarketTradingMode } from "./../../../../graphql/src/__generated__/globalTypes"; +import { MarketTradingMode } from "./../../../../types/src/__generated__/globalTypes"; // ==================================================== // GraphQL query operation: Positions diff --git a/libs/positions/src/lib/positions-table.spec.tsx b/libs/positions/src/lib/positions-table.spec.tsx index 198dbe028..022895e29 100644 --- a/libs/positions/src/lib/positions-table.spec.tsx +++ b/libs/positions/src/lib/positions-table.spec.tsx @@ -1,7 +1,7 @@ import { act, render, screen } from '@testing-library/react'; import PositionsTable from './positions-table'; import { Positions_party_positions } from './__generated__/Positions'; -import { MarketTradingMode } from '@vegaprotocol/graphql'; +import { MarketTradingMode } from '@vegaprotocol/types'; const singleRow: Positions_party_positions = { realisedPNL: '5', diff --git a/libs/positions/src/lib/positions-table.tsx b/libs/positions/src/lib/positions-table.tsx index 843a6be24..d1dc1ce67 100644 --- a/libs/positions/src/lib/positions-table.tsx +++ b/libs/positions/src/lib/positions-table.tsx @@ -11,7 +11,7 @@ import { AgGridColumn } from 'ag-grid-react'; import type { AgGridReact } from 'ag-grid-react'; import compact from 'lodash/compact'; import { Positions_party_positions } from './__generated__/Positions'; -import { MarketTradingMode } from '@vegaprotocol/graphql'; +import { MarketTradingMode } from '@vegaprotocol/types'; interface PositionsTableProps { data: Positions_party_positions[] | null; diff --git a/libs/graphql/.babelrc b/libs/types/.babelrc similarity index 100% rename from libs/graphql/.babelrc rename to libs/types/.babelrc diff --git a/libs/graphql/.eslintrc.json b/libs/types/.eslintrc.json similarity index 100% rename from libs/graphql/.eslintrc.json rename to libs/types/.eslintrc.json diff --git a/libs/types/README.md b/libs/types/README.md new file mode 100644 index 000000000..5e6821bec --- /dev/null +++ b/libs/types/README.md @@ -0,0 +1,7 @@ +# types + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test types` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/libs/graphql/apollo.config.js b/libs/types/apollo.config.js similarity index 100% rename from libs/graphql/apollo.config.js rename to libs/types/apollo.config.js diff --git a/libs/graphql/jest.config.js b/libs/types/jest.config.js similarity index 67% rename from libs/graphql/jest.config.js rename to libs/types/jest.config.js index 51bb43cdc..1ce0ebb45 100644 --- a/libs/graphql/jest.config.js +++ b/libs/types/jest.config.js @@ -1,9 +1,9 @@ module.exports = { - displayName: 'graphql', + displayName: 'types', preset: '../../jest.preset.js', transform: { '^.+\\.[tj]sx?$': 'babel-jest', }, moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], - coverageDirectory: '../../coverage/libs/graphql', + coverageDirectory: '../../coverage/libs/types', }; diff --git a/libs/types/package.json b/libs/types/package.json new file mode 100644 index 000000000..c42b23b71 --- /dev/null +++ b/libs/types/package.json @@ -0,0 +1,4 @@ +{ + "name": "@vegaprotocol/types", + "version": "0.0.1" +} diff --git a/libs/graphql/project.json b/libs/types/project.json similarity index 61% rename from libs/graphql/project.json rename to libs/types/project.json index 25358bd14..cd4583b3d 100644 --- a/libs/graphql/project.json +++ b/libs/types/project.json @@ -1,6 +1,6 @@ { - "root": "libs/graphql", - "sourceRoot": "libs/graphql/src", + "root": "libs/types", + "sourceRoot": "libs/types/src", "projectType": "library", "tags": [], "targets": { @@ -8,16 +8,16 @@ "executor": "@nrwl/web:rollup", "outputs": ["{options.outputPath}"], "options": { - "outputPath": "dist/libs/graphql", - "tsConfig": "libs/graphql/tsconfig.lib.json", - "project": "libs/graphql/package.json", - "entryFile": "libs/graphql/src/index.ts", + "outputPath": "dist/libs/types", + "tsConfig": "libs/types/tsconfig.lib.json", + "project": "libs/types/package.json", + "entryFile": "libs/types/src/index.ts", "external": ["react/jsx-runtime"], "rollupConfig": "@nrwl/react/plugins/bundle-rollup", "compiler": "babel", "assets": [ { - "glob": "libs/graphql/README.md", + "glob": "libs/types/README.md", "input": ".", "output": "." } @@ -28,14 +28,14 @@ "executor": "@nrwl/linter:eslint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["libs/graphql/**/*.{ts,tsx,js,jsx}"] + "lintFilePatterns": ["libs/types/**/*.{ts,tsx,js,jsx}"] } }, "test": { "executor": "@nrwl/jest:jest", - "outputs": ["coverage/libs/graphql"], + "outputs": ["coverage/libs/types"], "options": { - "jestConfig": "libs/graphql/jest.config.js", + "jestConfig": "libs/types/jest.config.js", "passWithNoTests": true } }, @@ -44,7 +44,7 @@ "options": { "commands": [ { - "command": "npx apollo client:codegen --config=libs/graphql/apollo.config.js --target=typescript --globalTypesFile=libs/graphql/src/__generated__/globalTypes.ts" + "command": "npx apollo client:codegen --config=libs/types/apollo.config.js --target=typescript --globalTypesFile=libs/types/src/__generated__/globalTypes.ts" } ] } diff --git a/libs/graphql/src/__generated__/globalTypes.ts b/libs/types/src/__generated__/globalTypes.ts similarity index 100% rename from libs/graphql/src/__generated__/globalTypes.ts rename to libs/types/src/__generated__/globalTypes.ts diff --git a/libs/graphql/src/index.ts b/libs/types/src/index.ts similarity index 100% rename from libs/graphql/src/index.ts rename to libs/types/src/index.ts diff --git a/libs/graphql/tsconfig.json b/libs/types/tsconfig.json similarity index 100% rename from libs/graphql/tsconfig.json rename to libs/types/tsconfig.json diff --git a/libs/graphql/tsconfig.lib.json b/libs/types/tsconfig.lib.json similarity index 100% rename from libs/graphql/tsconfig.lib.json rename to libs/types/tsconfig.lib.json diff --git a/libs/graphql/tsconfig.spec.json b/libs/types/tsconfig.spec.json similarity index 100% rename from libs/graphql/tsconfig.spec.json rename to libs/types/tsconfig.spec.json diff --git a/tsconfig.base.json b/tsconfig.base.json index 90f9d8d30..cef48f937 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -16,7 +16,6 @@ "baseUrl": ".", "paths": { "@vegaprotocol/deal-ticket": ["libs/deal-ticket/src/index.ts"], - "@vegaprotocol/graphql": ["libs/graphql/src/index.ts"], "@vegaprotocol/market-list": ["libs/market-list/src/index.ts"], "@vegaprotocol/network-stats": ["libs/network-stats/src/index.ts"], "@vegaprotocol/order-list": ["libs/order-list/src/index.ts"], @@ -25,6 +24,7 @@ "@vegaprotocol/tailwindcss-config": [ "libs/tailwindcss-config/src/index.js" ], + "@vegaprotocol/types": ["libs/types/src/index.ts"], "@vegaprotocol/ui-toolkit": ["libs/ui-toolkit/src/index.ts"], "@vegaprotocol/wallet": ["libs/wallet/src/index.ts"], "@vegaprotocol/web3": ["libs/web3/src/index.ts"] diff --git a/workspace.json b/workspace.json index 3410110b8..4579869a4 100644 --- a/workspace.json +++ b/workspace.json @@ -4,7 +4,6 @@ "deal-ticket": "libs/deal-ticket", "explorer": "apps/explorer", "explorer-e2e": "apps/explorer-e2e", - "graphql": "libs/graphql", "market-list": "libs/market-list", "network-stats": "libs/network-stats", "order-list": "libs/order-list", @@ -15,6 +14,7 @@ "tailwindcss-config": "libs/tailwindcss-config", "trading": "apps/trading", "trading-e2e": "apps/trading-e2e", + "types": "libs/types", "ui-toolkit": "libs/ui-toolkit", "wallet": "libs/wallet", "web3": "libs/web3" From fdfcc4e5db4a337668d3780fd8ea219b4637097e Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Tue, 29 Mar 2022 16:10:38 -0700 Subject: [PATCH 03/10] delete global types from explorer app --- .../explorer/src/__generated__/globalTypes.ts | 126 ------------------ 1 file changed, 126 deletions(-) delete mode 100644 apps/explorer/src/__generated__/globalTypes.ts diff --git a/apps/explorer/src/__generated__/globalTypes.ts b/apps/explorer/src/__generated__/globalTypes.ts deleted file mode 100644 index 74aa66291..000000000 --- a/apps/explorer/src/__generated__/globalTypes.ts +++ /dev/null @@ -1,126 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// @generated -// This file was automatically generated and should not be edited. - -//============================================================== -// START Enums and Input Objects -//============================================================== - -/** - * The various account types we have (used by collateral) - */ -export enum AccountType { - Bond = "Bond", - FeeInfrastructure = "FeeInfrastructure", - FeeLiquidity = "FeeLiquidity", - General = "General", - GlobalInsurance = "GlobalInsurance", - Insurance = "Insurance", - LockWithdraw = "LockWithdraw", - Margin = "Margin", - Settlement = "Settlement", -} - -export enum AuctionTrigger { - Batch = "Batch", - Liquidity = "Liquidity", - Opening = "Opening", - Price = "Price", - Unspecified = "Unspecified", -} - -/** - * The current state of a market - */ -export enum MarketState { - Active = "Active", - Cancelled = "Cancelled", - Closed = "Closed", - Pending = "Pending", - Proposed = "Proposed", - Rejected = "Rejected", - Settled = "Settled", - Suspended = "Suspended", - TradingTerminated = "TradingTerminated", -} - -/** - * What market trading mode are we in - */ -export enum MarketTradingMode { - BatchAuction = "BatchAuction", - Continuous = "Continuous", - MonitoringAuction = "MonitoringAuction", - OpeningAuction = "OpeningAuction", -} - -export enum NodeStatus { - NonValidator = "NonValidator", - Validator = "Validator", -} - -/** - * Reason for the proposal being rejected by the core node - */ -export enum ProposalRejectionReason { - CloseTimeTooLate = "CloseTimeTooLate", - CloseTimeTooSoon = "CloseTimeTooSoon", - CouldNotInstantiateMarket = "CouldNotInstantiateMarket", - EnactTimeTooLate = "EnactTimeTooLate", - EnactTimeTooSoon = "EnactTimeTooSoon", - IncompatibleTimestamps = "IncompatibleTimestamps", - InsufficientTokens = "InsufficientTokens", - InvalidAsset = "InvalidAsset", - InvalidAssetDetails = "InvalidAssetDetails", - InvalidFeeAmount = "InvalidFeeAmount", - InvalidFutureMaturityTimestamp = "InvalidFutureMaturityTimestamp", - InvalidFutureProduct = "InvalidFutureProduct", - InvalidInstrumentSecurity = "InvalidInstrumentSecurity", - InvalidRiskParameter = "InvalidRiskParameter", - InvalidShape = "InvalidShape", - MajorityThresholdNotReached = "MajorityThresholdNotReached", - MarketMissingLiquidityCommitment = "MarketMissingLiquidityCommitment", - MissingBuiltinAssetField = "MissingBuiltinAssetField", - MissingCommitmentAmount = "MissingCommitmentAmount", - MissingERC20ContractAddress = "MissingERC20ContractAddress", - NetworkParameterInvalidKey = "NetworkParameterInvalidKey", - NetworkParameterInvalidValue = "NetworkParameterInvalidValue", - NetworkParameterValidationFailed = "NetworkParameterValidationFailed", - NoProduct = "NoProduct", - NoRiskParameters = "NoRiskParameters", - NoTradingMode = "NoTradingMode", - NodeValidationFailed = "NodeValidationFailed", - OpeningAuctionDurationTooLarge = "OpeningAuctionDurationTooLarge", - OpeningAuctionDurationTooSmall = "OpeningAuctionDurationTooSmall", - ParticipationThresholdNotReached = "ParticipationThresholdNotReached", - ProductMaturityIsPassed = "ProductMaturityIsPassed", - UnsupportedProduct = "UnsupportedProduct", - UnsupportedTradingMode = "UnsupportedTradingMode", -} - -/** - * Various states a proposal can transition through: - * Open -> - * - Passed -> Enacted. - * - Rejected. - * Proposal can enter Failed state from any other state. - */ -export enum ProposalState { - Declined = "Declined", - Enacted = "Enacted", - Failed = "Failed", - Open = "Open", - Passed = "Passed", - Rejected = "Rejected", - WaitingForNodeVote = "WaitingForNodeVote", -} - -export enum VoteValue { - No = "No", - Yes = "Yes", -} - -//============================================================== -// END Enums and Input Objects -//============================================================== From d3d28947ea2bc3d1043d491366d194e4d0d168d7 Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Tue, 29 Mar 2022 16:19:23 -0700 Subject: [PATCH 04/10] tidy up deal ticket query and market page query --- .../trading/pages/markets/[marketId].page.tsx | 28 ----- .../pages/markets/__generated__/Market.ts | 119 ------------------ .../src/__generated__/DealTicketQuery.ts | 48 ------- .../deal-ticket/src/deal-ticket-container.tsx | 12 -- libs/deal-ticket/src/deal-ticket.spec.tsx | 30 +++-- 5 files changed, 20 insertions(+), 217 deletions(-) diff --git a/apps/trading/pages/markets/[marketId].page.tsx b/apps/trading/pages/markets/[marketId].page.tsx index 3355f3fc2..3fc398def 100644 --- a/apps/trading/pages/markets/[marketId].page.tsx +++ b/apps/trading/pages/markets/[marketId].page.tsx @@ -13,34 +13,6 @@ const MARKET_QUERY = gql` market(id: $marketId) { id name - decimalPlaces - state - tradingMode - tradableInstrument { - instrument { - product { - ... on Future { - quoteName - settlementAsset { - id - symbol - name - } - } - } - } - } - trades { - id - price - size - createdAt - } - depth { - lastTrade { - price - } - } } } `; diff --git a/apps/trading/pages/markets/__generated__/Market.ts b/apps/trading/pages/markets/__generated__/Market.ts index 24f68b822..cc812fc8c 100644 --- a/apps/trading/pages/markets/__generated__/Market.ts +++ b/apps/trading/pages/markets/__generated__/Market.ts @@ -3,92 +3,10 @@ // @generated // This file was automatically generated and should not be edited. -import { MarketState, MarketTradingMode } from "./../../../../../libs/types/src/__generated__/globalTypes"; - // ==================================================== // GraphQL query operation: Market // ==================================================== -export interface Market_market_tradableInstrument_instrument_product_settlementAsset { - __typename: "Asset"; - /** - * The id of the asset - */ - id: string; - /** - * The symbol of the asset (e.g: GBP) - */ - symbol: string; - /** - * The full name of the asset (e.g: Great British Pound) - */ - name: string; -} - -export interface Market_market_tradableInstrument_instrument_product { - __typename: "Future"; - /** - * String representing the quote (e.g. BTCUSD -> USD is quote) - */ - quoteName: string; - /** - * The name of the asset (string) - */ - settlementAsset: Market_market_tradableInstrument_instrument_product_settlementAsset; -} - -export interface Market_market_tradableInstrument_instrument { - __typename: "Instrument"; - /** - * A reference to or instance of a fully specified product, including all required product parameters for that product (Product union) - */ - product: Market_market_tradableInstrument_instrument_product; -} - -export interface Market_market_tradableInstrument { - __typename: "TradableInstrument"; - /** - * An instance of or reference to a fully specified instrument. - */ - instrument: Market_market_tradableInstrument_instrument; -} - -export interface Market_market_trades { - __typename: "Trade"; - /** - * The hash of the trade data - */ - id: string; - /** - * The price of the trade (probably initially the passive order price, other determination algorithms are possible though) (uint64) - */ - price: string; - /** - * The number of contracts trades, will always be <= the remaining size of both orders immediately before the trade (uint64) - */ - size: string; - /** - * RFC3339Nano time for when the trade occurred - */ - createdAt: string; -} - -export interface Market_market_depth_lastTrade { - __typename: "Trade"; - /** - * The price of the trade (probably initially the passive order price, other determination algorithms are possible though) (uint64) - */ - price: string; -} - -export interface Market_market_depth { - __typename: "MarketDepth"; - /** - * Last trade for the given market (if available) - */ - lastTrade: Market_market_depth_lastTrade | null; -} - export interface Market_market { __typename: "Market"; /** @@ -99,43 +17,6 @@ export interface Market_market { * Market full name */ name: string; - /** - * decimalPlaces indicates the number of decimal places that an integer must be shifted by in order to get a correct - * number denominated in the currency of the Market. (uint64) - * - * Examples: - * Currency Balance decimalPlaces Real Balance - * GBP 100 0 GBP 100 - * GBP 100 2 GBP 1.00 - * GBP 100 4 GBP 0.01 - * GBP 1 4 GBP 0.0001 ( 0.01p ) - * - * GBX (pence) 100 0 GBP 1.00 (100p ) - * GBX (pence) 100 2 GBP 0.01 ( 1p ) - * GBX (pence) 100 4 GBP 0.0001 ( 0.01p ) - * GBX (pence) 1 4 GBP 0.000001 ( 0.0001p) - */ - decimalPlaces: number; - /** - * Current state of the market - */ - state: MarketState; - /** - * Current mode of execution of the market - */ - tradingMode: MarketTradingMode; - /** - * An instance of or reference to a tradable instrument. - */ - tradableInstrument: Market_market_tradableInstrument; - /** - * Trades on a market - */ - trades: Market_market_trades[] | null; - /** - * Current depth on the order book for this market - */ - depth: Market_market_depth; } export interface Market { diff --git a/libs/deal-ticket/src/__generated__/DealTicketQuery.ts b/libs/deal-ticket/src/__generated__/DealTicketQuery.ts index 8a18b4c53..b36f98611 100644 --- a/libs/deal-ticket/src/__generated__/DealTicketQuery.ts +++ b/libs/deal-ticket/src/__generated__/DealTicketQuery.ts @@ -9,32 +9,12 @@ import { MarketState, MarketTradingMode } from "./../../../types/src/__generated // GraphQL query operation: DealTicketQuery // ==================================================== -export interface DealTicketQuery_market_tradableInstrument_instrument_product_settlementAsset { - __typename: "Asset"; - /** - * The id of the asset - */ - id: string; - /** - * The symbol of the asset (e.g: GBP) - */ - symbol: string; - /** - * The full name of the asset (e.g: Great British Pound) - */ - name: string; -} - export interface DealTicketQuery_market_tradableInstrument_instrument_product { __typename: "Future"; /** * String representing the quote (e.g. BTCUSD -> USD is quote) */ quoteName: string; - /** - * The name of the asset (string) - */ - settlementAsset: DealTicketQuery_market_tradableInstrument_instrument_product_settlementAsset; } export interface DealTicketQuery_market_tradableInstrument_instrument { @@ -53,26 +33,6 @@ export interface DealTicketQuery_market_tradableInstrument { instrument: DealTicketQuery_market_tradableInstrument_instrument; } -export interface DealTicketQuery_market_trades { - __typename: "Trade"; - /** - * The hash of the trade data - */ - id: string; - /** - * The price of the trade (probably initially the passive order price, other determination algorithms are possible though) (uint64) - */ - price: string; - /** - * The number of contracts trades, will always be <= the remaining size of both orders immediately before the trade (uint64) - */ - size: string; - /** - * RFC3339Nano time for when the trade occurred - */ - createdAt: string; -} - export interface DealTicketQuery_market_depth_lastTrade { __typename: "Trade"; /** @@ -95,10 +55,6 @@ export interface DealTicketQuery_market { * Market ID */ id: string; - /** - * Market full name - */ - name: string; /** * decimalPlaces indicates the number of decimal places that an integer must be shifted by in order to get a correct * number denominated in the currency of the Market. (uint64) @@ -128,10 +84,6 @@ export interface DealTicketQuery_market { * An instance of or reference to a tradable instrument. */ tradableInstrument: DealTicketQuery_market_tradableInstrument; - /** - * Trades on a market - */ - trades: DealTicketQuery_market_trades[] | null; /** * Current depth on the order book for this market */ diff --git a/libs/deal-ticket/src/deal-ticket-container.tsx b/libs/deal-ticket/src/deal-ticket-container.tsx index 64603e13f..8715f5406 100644 --- a/libs/deal-ticket/src/deal-ticket-container.tsx +++ b/libs/deal-ticket/src/deal-ticket-container.tsx @@ -7,7 +7,6 @@ const DEAL_TICKET_QUERY = gql` query DealTicketQuery($marketId: ID!) { market(id: $marketId) { id - name decimalPlaces state tradingMode @@ -16,21 +15,10 @@ const DEAL_TICKET_QUERY = gql` product { ... on Future { quoteName - settlementAsset { - id - symbol - name - } } } } } - trades { - id - price - size - createdAt - } depth { lastTrade { price diff --git a/libs/deal-ticket/src/deal-ticket.spec.tsx b/libs/deal-ticket/src/deal-ticket.spec.tsx index d259afe5b..9bd9c76c3 100644 --- a/libs/deal-ticket/src/deal-ticket.spec.tsx +++ b/libs/deal-ticket/src/deal-ticket.spec.tsx @@ -6,8 +6,10 @@ import { } from '@vegaprotocol/wallet'; import { addDecimal } from '@vegaprotocol/react-helpers'; import { fireEvent, render, screen } from '@testing-library/react'; -import { DealTicket, Market } from './deal-ticket'; +import { DealTicket } from './deal-ticket'; import { Order } from './use-order-state'; +import { DealTicketQuery_market } from './__generated__/DealTicketQuery'; +import { MarketState, MarketTradingMode } from '@vegaprotocol/types'; const order: Order = { type: OrderType.Market, @@ -15,34 +17,42 @@ const order: Order = { timeInForce: OrderTimeInForce.FOK, side: null, }; -const market: Market = { +const market: DealTicketQuery_market = { + __typename: 'Market', id: 'market-id', decimalPlaces: 2, - tradingMode: 'Continuous', - state: 'Active', + tradingMode: MarketTradingMode.Continuous, + state: MarketState.Active, tradableInstrument: { + __typename: 'TradableInstrument', instrument: { + __typename: 'Instrument', product: { + __typename: 'Future', quoteName: 'quote-name', - settlementAsset: { - id: 'asset-id', - symbol: 'asset-symbol', - name: 'asset-name', - }, }, }, }, depth: { + __typename: 'MarketDepth', lastTrade: { + __typename: 'Trade', price: '100', }, }, }; +const submit = jest.fn(); +const transactionStatus = 'default'; function generateJsx() { return ( - + ); } From 3394050f761983ded83fe21aac907315829146b7 Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Tue, 29 Mar 2022 16:21:57 -0700 Subject: [PATCH 05/10] update types in submit button to use global types --- libs/deal-ticket/src/submit-button.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libs/deal-ticket/src/submit-button.tsx b/libs/deal-ticket/src/submit-button.tsx index 901e639e5..6359a9f48 100644 --- a/libs/deal-ticket/src/submit-button.tsx +++ b/libs/deal-ticket/src/submit-button.tsx @@ -5,6 +5,7 @@ import { Order } from './use-order-state'; import { useVegaWallet } from '@vegaprotocol/wallet'; import { TransactionStatus } from './deal-ticket'; import { DealTicketQuery_market } from './__generated__/DealTicketQuery'; +import { MarketState, MarketTradingMode } from '@vegaprotocol/types'; interface SubmitButtonProps { transactionStatus: TransactionStatus; @@ -28,20 +29,22 @@ export const SubmitButton = ({ return 'Selected public key has been tainted'; } - // TODO: Change these to use enums from @vegaprotocol/graphql - if (market.state !== 'Active') { - if (market.state === 'Suspended') { + if (market.state !== MarketState.Active) { + if (market.state === MarketState.Suspended) { return 'Market is currently suspended'; } - if (market.state === 'Proposed' || market.state === 'Pending') { + if ( + market.state === MarketState.Proposed || + market.state === MarketState.Pending + ) { return 'Market is not active yet'; } return 'Market is no longer active'; } - if (market.tradingMode !== 'Continuous') { + if (market.tradingMode !== MarketTradingMode.Continuous) { if (order.type === OrderType.Market) { return 'Only limit orders are permitted when market is in auction'; } From 858bd372d23002be411247f92416aa154fc0af2f Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Tue, 29 Mar 2022 17:01:34 -0700 Subject: [PATCH 06/10] prevent positions table if not party id provided, handle no data in async renderer --- .../positions/src/lib/positions-container.tsx | 76 +++---------------- libs/positions/src/lib/positions-manager.tsx | 61 +++++++++++++++ .../src/lib/positions-table.spec.tsx | 9 +-- libs/positions/src/lib/positions-table.tsx | 6 +- .../async-renderer/async-renderer.tsx | 6 +- 5 files changed, 82 insertions(+), 76 deletions(-) create mode 100644 libs/positions/src/lib/positions-manager.tsx diff --git a/libs/positions/src/lib/positions-container.tsx b/libs/positions/src/lib/positions-container.tsx index 73ce63e7b..6322f6929 100644 --- a/libs/positions/src/lib/positions-container.tsx +++ b/libs/positions/src/lib/positions-container.tsx @@ -1,69 +1,17 @@ -import { useRef, useCallback, useMemo } from 'react'; -import { produce } from 'immer'; -import merge from 'lodash/merge'; -import { useRouter } from 'next/router'; -import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { Splash } from '@vegaprotocol/ui-toolkit'; import { useVegaWallet } from '@vegaprotocol/wallet'; -import { PositionSubscribe_positions } from './__generated__/PositionSubscribe'; -import { Positions_party_positions } from './__generated__/Positions'; - -import type { AgGridReact } from 'ag-grid-react'; -import PositionsTable, { getRowNodeId } from './positions-table'; -import { positionsDataProvider } from './positions-data-provider'; +import { PositionsManager } from './positions-manager'; export const PositionsContainer = () => { - const { pathname, push } = useRouter(); - const gridRef = useRef(null); const { keypair } = useVegaWallet(); - const variables = useMemo(() => ({ partyId: keypair?.pub }), [keypair]); - const update = useCallback( - (delta: PositionSubscribe_positions) => { - const update: Positions_party_positions[] = []; - const add: Positions_party_positions[] = []; - if (!gridRef.current) { - return false; - } - const rowNode = gridRef.current.api.getRowNode(getRowNodeId(delta)); - if (rowNode) { - const updatedData = produce( - rowNode.data, - (draft: Positions_party_positions) => { - merge(draft, delta); - } - ); - if (updatedData !== rowNode.data) { - update.push(updatedData); - } - } else { - add.push(delta); - } - if (update.length || add.length) { - gridRef.current.api.applyTransactionAsync({ - update, - add, - addIndex: 0, - }); - } - return true; - }, - [gridRef] - ); - const { data, error, loading } = useDataProvider< - Positions_party_positions, - PositionSubscribe_positions - >(positionsDataProvider, update, variables); - return ( - - {(data) => ( - - push(`${pathname}/${id}?portfolio=orders&trade=orderbook`) - } - /> - )} - - ); + + if (!keypair) { + return ( + +

Please connect Vega wallet

+
+ ); + } + + return ; }; diff --git a/libs/positions/src/lib/positions-manager.tsx b/libs/positions/src/lib/positions-manager.tsx new file mode 100644 index 000000000..28b790a1f --- /dev/null +++ b/libs/positions/src/lib/positions-manager.tsx @@ -0,0 +1,61 @@ +import { useRef, useCallback, useMemo } from 'react'; +import { produce } from 'immer'; +import merge from 'lodash/merge'; +import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; +import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { PositionSubscribe_positions } from './__generated__/PositionSubscribe'; +import { Positions_party_positions } from './__generated__/Positions'; + +import type { AgGridReact } from 'ag-grid-react'; +import PositionsTable, { getRowNodeId } from './positions-table'; +import { positionsDataProvider } from './positions-data-provider'; + +interface PositionsManagerProps { + partyId: string; +} + +export const PositionsManager = ({ partyId }: PositionsManagerProps) => { + const gridRef = useRef(null); + const variables = useMemo(() => ({ partyId }), [partyId]); + const update = useCallback( + (delta: PositionSubscribe_positions) => { + const update: Positions_party_positions[] = []; + const add: Positions_party_positions[] = []; + if (!gridRef.current) { + return false; + } + const rowNode = gridRef.current.api.getRowNode(getRowNodeId(delta)); + if (rowNode) { + const updatedData = produce( + rowNode.data, + (draft: Positions_party_positions) => { + merge(draft, delta); + } + ); + if (updatedData !== rowNode.data) { + update.push(updatedData); + } + } else { + add.push(delta); + } + if (update.length || add.length) { + gridRef.current.api.applyTransactionAsync({ + update, + add, + addIndex: 0, + }); + } + return true; + }, + [gridRef] + ); + const { data, error, loading } = useDataProvider< + Positions_party_positions, + PositionSubscribe_positions + >(positionsDataProvider, update, variables); + return ( + + {(data) => } + + ); +}; diff --git a/libs/positions/src/lib/positions-table.spec.tsx b/libs/positions/src/lib/positions-table.spec.tsx index 022895e29..e6a4c426e 100644 --- a/libs/positions/src/lib/positions-table.spec.tsx +++ b/libs/positions/src/lib/positions-table.spec.tsx @@ -54,19 +54,16 @@ const singleRow: Positions_party_positions = { __typename: 'Position', }; const singleRowData = [singleRow]; -const onRowClicked = jest.fn; test('should render successfully', async () => { await act(async () => { - const { baseElement } = render( - - ); + const { baseElement } = render(); expect(baseElement).toBeTruthy(); }); }); test('Render correct columns', async () => { await act(async () => { - render(); + render(); }); const headers = screen.getAllByRole('columnheader'); @@ -82,7 +79,7 @@ test('Render correct columns', async () => { test('Correct formatting applied', async () => { await act(async () => { - render(); + render(); }); const cells = screen.getAllByRole('gridcell'); const expectedValues = [ diff --git a/libs/positions/src/lib/positions-table.tsx b/libs/positions/src/lib/positions-table.tsx index d1dc1ce67..ebe695648 100644 --- a/libs/positions/src/lib/positions-table.tsx +++ b/libs/positions/src/lib/positions-table.tsx @@ -15,7 +15,6 @@ import { MarketTradingMode } from '@vegaprotocol/types'; interface PositionsTableProps { data: Positions_party_positions[] | null; - onRowClicked: (marketId: string) => void; } export const getRowNodeId = (data: { market: { id: string } }) => @@ -47,7 +46,7 @@ interface PositionsTableValueFormatterParams extends ValueFormatterParams { } export const PositionsTable = forwardRef( - ({ data, onRowClicked }, ref) => { + ({ data }, ref) => { const sortedData = useMemo(() => { return compact(data).sort(sortByName); }, [data]); @@ -62,9 +61,6 @@ export const PositionsTable = forwardRef( flex: 1, resizable: true, }} - onRowClicked={({ data }: { data: Positions_party_positions }) => - onRowClicked(getRowNodeId(data)) - } components={{ PriceCell }} > ({ return Something went wrong: {error.message}; } - if (loading || !data) { + if (loading) { return Loading...; } + if (!data) { + return No data; + } + return <>{children(data)}; } From 4f1585110348d76a1e652b699cbcc1430ff95901 Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Tue, 29 Mar 2022 17:19:41 -0700 Subject: [PATCH 07/10] update order-list lib so it behaves the same as positions and requires a partyId --- libs/order-list/src/order-list-container.tsx | 19 +++--- ...r.spec.tsx => order-list-manager.spec.tsx} | 8 +-- libs/order-list/src/order-list-manager.tsx | 18 ++++++ libs/order-list/src/use-orders.spec.tsx | 59 +++++-------------- libs/order-list/src/use-orders.ts | 16 +++-- 5 files changed, 54 insertions(+), 66 deletions(-) rename libs/order-list/src/{order-list-container.spec.tsx => order-list-manager.spec.tsx} (84%) create mode 100644 libs/order-list/src/order-list-manager.tsx diff --git a/libs/order-list/src/order-list-container.tsx b/libs/order-list/src/order-list-container.tsx index 676008b2e..f4c608530 100644 --- a/libs/order-list/src/order-list-container.tsx +++ b/libs/order-list/src/order-list-container.tsx @@ -1,14 +1,13 @@ -import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; -import { useOrders } from './use-orders'; -import { OrderList } from './order-list'; -import { OrderFields } from './__generated__/OrderFields'; +import { Splash } from '@vegaprotocol/ui-toolkit'; +import { useVegaWallet } from '@vegaprotocol/wallet'; +import { OrderListManager } from './order-list-manager'; export const OrderListContainer = () => { - const { orders, loading, error } = useOrders(); + const { keypair } = useVegaWallet(); - return ( - loading={loading} error={error} data={orders}> - {(data) => } - - ); + if (!keypair) { + return Please connect Vega wallet; + } + + return ; }; diff --git a/libs/order-list/src/order-list-container.spec.tsx b/libs/order-list/src/order-list-manager.spec.tsx similarity index 84% rename from libs/order-list/src/order-list-container.spec.tsx rename to libs/order-list/src/order-list-manager.spec.tsx index 08ff862ae..2be69170e 100644 --- a/libs/order-list/src/order-list-container.spec.tsx +++ b/libs/order-list/src/order-list-manager.spec.tsx @@ -1,5 +1,5 @@ import { render, screen } from '@testing-library/react'; -import { OrderListContainer } from './order-list-container'; +import { OrderListManager } from './order-list-manager'; import * as useOrdersHook from './use-orders'; import { Orders_party_orders } from './__generated__/Orders'; @@ -13,7 +13,7 @@ test('Renders a loading state while awaiting orders', () => { loading: true, error: null, }); - render(); + render(); expect(screen.getByText('Loading...')).toBeInTheDocument(); }); @@ -24,7 +24,7 @@ test('Renders an error state', () => { loading: false, error: new Error(errorMsg), }); - render(); + render(); expect( screen.getByText(`Something went wrong: ${errorMsg}`) ).toBeInTheDocument(); @@ -36,6 +36,6 @@ test('Renders the order list if orders provided', async () => { loading: false, error: null, }); - render(); + render(); expect(await screen.findByText('OrderList')).toBeInTheDocument(); }); diff --git a/libs/order-list/src/order-list-manager.tsx b/libs/order-list/src/order-list-manager.tsx new file mode 100644 index 000000000..ceb262614 --- /dev/null +++ b/libs/order-list/src/order-list-manager.tsx @@ -0,0 +1,18 @@ +import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; +import { useOrders } from './use-orders'; +import { OrderList } from './order-list'; +import { OrderFields } from './__generated__/OrderFields'; + +interface OrderListManagerProps { + partyId: string; +} + +export const OrderListManager = ({ partyId }: OrderListManagerProps) => { + const { orders, loading, error } = useOrders(partyId); + + return ( + loading={loading} error={error} data={orders}> + {(data) => } + + ); +}; diff --git a/libs/order-list/src/use-orders.spec.tsx b/libs/order-list/src/use-orders.spec.tsx index bb7659ae8..50b9cccbe 100644 --- a/libs/order-list/src/use-orders.spec.tsx +++ b/libs/order-list/src/use-orders.spec.tsx @@ -9,24 +9,11 @@ import { OrderType, OrderTimeInForce, } from '@vegaprotocol/types'; -import { - VegaKeyExtended, - VegaWalletContext, - VegaWalletContextShape, -} from '@vegaprotocol/wallet'; +import {} from '@vegaprotocol/wallet'; import { ReactNode } from 'react'; import { ORDERS_QUERY, ORDERS_SUB, useOrders } from './use-orders'; -const keypair = { pub: '0x123' } as VegaKeyExtended; -const defaultWalletContext = { - keypair, - keypairs: [keypair], - sendTx: jest.fn().mockReturnValue(Promise.resolve(null)), - connect: jest.fn(), - disconnect: jest.fn(), - selectPublicKey: jest.fn(), - connector: null, -}; +const partyId = '0x123'; function generateOrder(order?: Partial): OrderFields { return { @@ -60,20 +47,11 @@ function generateOrder(order?: Partial): OrderFields { }; } -function setup( - context?: Partial, - mocks: MockedResponse[] = [] -) { +function setup(mocks: MockedResponse[] = [], id: string | null) { const wrapper = ({ children }: { children: ReactNode }) => ( - - - {children} - - + {children} ); - return renderHook(() => useOrders(), { wrapper }); + return renderHook(() => useOrders(id as string), { wrapper }); } test('Fetches and subscribes to orders and merges appropriately', async () => { @@ -81,13 +59,13 @@ test('Fetches and subscribes to orders and merges appropriately', async () => { const mockOrderQuery: MockedResponse = { request: { query: ORDERS_QUERY, - variables: { partyId: keypair.pub }, + variables: { partyId }, }, result: { data: { party: { __typename: 'Party', - id: keypair.pub, + id: partyId, orders: [order], }, }, @@ -106,7 +84,7 @@ test('Fetches and subscribes to orders and merges appropriately', async () => { const mockOrderSub: MockedResponse = { request: { query: ORDERS_SUB, - variables: { partyId: keypair.pub }, + variables: { partyId }, }, result: { data: { @@ -115,10 +93,10 @@ test('Fetches and subscribes to orders and merges appropriately', async () => { }, delay: 100, }; - const { result, waitForNextUpdate } = setup(defaultWalletContext, [ - mockOrderQuery, - mockOrderSub, - ]); + const { result, waitForNextUpdate } = setup( + [mockOrderQuery, mockOrderSub], + partyId + ); expect(result.current.loading).toBe(true); expect(result.current.error).toBe(null); await waitForNextUpdate(); @@ -133,13 +111,11 @@ test('Returns an error if fetch fails', async () => { const mockFailedOrderQuery: MockedResponse = { request: { query: ORDERS_QUERY, - variables: { partyId: keypair.pub }, + variables: { partyId }, }, error, }; - const { result, waitForNextUpdate } = setup(defaultWalletContext, [ - mockFailedOrderQuery, - ]); + const { result, waitForNextUpdate } = setup([mockFailedOrderQuery], partyId); expect(result.current.loading).toBe(true); expect(result.current.error).toBe(null); await waitForNextUpdate(); @@ -151,14 +127,11 @@ test('No queries are made if no pubkey provided', () => { const mockQuery: MockedResponse = { request: { query: ORDERS_QUERY, - variables: { partyId: keypair.pub }, + variables: { partyId }, }, newData: jest.fn(), }; - const { result } = setup( - { ...defaultWalletContext, keypair: null, keypairs: [] }, - [mockQuery] - ); + const { result } = setup([mockQuery], null); expect(mockQuery.newData).not.toBeCalled(); expect(result.current.loading).toBe(false); expect(result.current.error).toBe(null); diff --git a/libs/order-list/src/use-orders.ts b/libs/order-list/src/use-orders.ts index 4190e3395..8954b02d4 100644 --- a/libs/order-list/src/use-orders.ts +++ b/libs/order-list/src/use-orders.ts @@ -2,7 +2,6 @@ import { useCallback, useEffect, useState } from 'react'; import { gql, useApolloClient } from '@apollo/client'; import uniqBy from 'lodash/uniqBy'; import orderBy from 'lodash/orderBy'; -import { useVegaWallet } from '@vegaprotocol/wallet'; import { Orders, OrdersVariables } from './__generated__/Orders'; import { OrderSub, OrderSubVariables } from './__generated__/OrderSub'; import { OrderFields } from './__generated__/OrderFields'; @@ -61,9 +60,8 @@ interface UseOrders { loading: boolean; } -export const useOrders = (): UseOrders => { +export const useOrders = (partyId: string): UseOrders => { const client = useApolloClient(); - const { keypair } = useVegaWallet(); const [orders, setOrders] = useState([]); const [error, setError] = useState(null); const [loading, setLoading] = useState(false); @@ -89,14 +87,14 @@ export const useOrders = (): UseOrders => { // Make initial fetch useEffect(() => { const fetchOrders = async () => { - if (!keypair?.pub) return; + if (!partyId) return; setLoading(true); try { const res = await client.query({ query: ORDERS_QUERY, - variables: { partyId: keypair.pub }, + variables: { partyId }, }); if (!res.data.party?.orders?.length) return; @@ -112,16 +110,16 @@ export const useOrders = (): UseOrders => { }; fetchOrders(); - }, [mergeOrders, keypair, client]); + }, [mergeOrders, partyId, client]); // Start subscription useEffect(() => { - if (!keypair?.pub) return; + if (!partyId) return; const sub = client .subscribe({ query: ORDERS_SUB, - variables: { partyId: keypair.pub }, + variables: { partyId }, }) .subscribe(({ data }) => { if (!data?.orders) { @@ -135,7 +133,7 @@ export const useOrders = (): UseOrders => { sub.unsubscribe(); } }; - }, [client, keypair, mergeOrders]); + }, [client, partyId, mergeOrders]); return { orders, error, loading }; }; From 7af0efa8d8d262384694846ce0dd9ef119436279 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20G=C5=82ownia?= Date: Wed, 30 Mar 2022 11:49:48 +0200 Subject: [PATCH 08/10] Enable @typescript-eslint/consistent-type-imports eslint rule --- .eslintrc.json | 7 +++++++ .github/workflows/test.yml | 16 ++++++++-------- .../src/app/components/blocks/block-data.tsx | 2 +- .../src/app/components/blocks/blocks-data.tsx | 2 +- .../src/app/components/jump-to/index.tsx | 2 +- .../src/app/components/route-title/index.tsx | 3 ++- .../src/app/components/sub-heading/index.tsx | 2 +- apps/explorer/src/app/components/table/index.tsx | 3 ++- .../src/app/components/txs/block-txs-data.tsx | 2 +- apps/explorer/src/app/components/txs/tx-list.tsx | 2 +- .../src/app/components/txs/txs-per-block.tsx | 2 +- .../websocket/tendermint-websocket-context.ts | 2 +- apps/explorer/src/app/routes/assets/index.tsx | 2 +- .../src/app/routes/blocks/home/index.tsx | 2 +- apps/explorer/src/app/routes/blocks/id/block.tsx | 2 +- .../app/routes/blocks/tendermint-new-block.d.ts | 3 ++- apps/explorer/src/app/routes/genesis/index.tsx | 2 +- .../genesis/tendermint-genesis-response.d.ts | 1 + .../explorer/src/app/routes/governance/index.tsx | 2 +- apps/explorer/src/app/routes/markets/index.tsx | 2 +- .../src/app/routes/network-parameters/index.tsx | 2 +- .../explorer/src/app/routes/parties/id/index.tsx | 4 ++-- apps/explorer/src/app/routes/pending/index.tsx | 2 +- apps/explorer/src/app/routes/txs/home/index.tsx | 2 +- apps/explorer/src/app/routes/txs/id/index.tsx | 4 ++-- .../src/app/routes/txs/id/tx-content.tsx | 2 +- .../src/app/routes/txs/id/tx-details.tsx | 2 +- .../explorer/src/app/routes/validators/index.tsx | 4 ++-- apps/stats/src/report-web-vitals.ts | 2 +- apps/trading/components/app-loader/index.tsx | 2 +- .../components/page-query-container/index.tsx | 7 ++++--- .../components/web3-container/web3-container.tsx | 3 ++- apps/trading/pages/_app.page.tsx | 2 +- apps/trading/pages/markets/[marketId].page.tsx | 2 +- apps/trading/pages/markets/grid-tabs.tsx | 10 ++-------- apps/trading/pages/markets/trade-grid.tsx | 5 +++-- libs/deal-ticket/src/deal-ticket-container.tsx | 2 +- libs/deal-ticket/src/deal-ticket-limit.tsx | 6 +++--- libs/deal-ticket/src/deal-ticket-manager.tsx | 2 +- libs/deal-ticket/src/deal-ticket-market.tsx | 6 +++--- libs/deal-ticket/src/deal-ticket.spec.tsx | 4 ++-- libs/deal-ticket/src/deal-ticket.tsx | 7 ++++--- libs/deal-ticket/src/expiry-selector.tsx | 2 +- libs/deal-ticket/src/order-dialog.tsx | 7 ++++--- libs/deal-ticket/src/side-selector.tsx | 2 +- libs/deal-ticket/src/submit-button.tsx | 6 +++--- libs/deal-ticket/src/time-in-force-selector.tsx | 2 +- libs/deal-ticket/src/type-selector.tsx | 2 +- libs/deal-ticket/src/use-order-state.ts | 3 ++- libs/deal-ticket/src/use-order-submit.spec.tsx | 9 ++++----- libs/deal-ticket/src/use-order-submit.ts | 4 ++-- libs/market-list/src/lib/market-list-table.tsx | 2 +- libs/market-list/src/lib/markets-container.tsx | 5 ++++- .../market-list/src/lib/markets-data-provider.ts | 4 ++-- .../good-threshold-indicator.tsx | 2 +- .../promoted-stats-item/promoted-stats-item.tsx | 2 +- .../components/stats-manager/stats-manager.tsx | 2 +- .../src/components/table-row/table-row.tsx | 2 +- libs/network-stats/src/config/stats-fields.ts | 2 +- libs/order-list/src/order-list-manager.spec.tsx | 2 +- libs/order-list/src/order-list-manager.tsx | 2 +- libs/order-list/src/order-list.spec.tsx | 2 +- libs/order-list/src/order-list.tsx | 4 ++-- libs/order-list/src/use-orders.spec.tsx | 11 ++++++----- libs/order-list/src/use-orders.ts | 6 +++--- .../positions/src/lib/positions-data-provider.ts | 4 ++-- libs/positions/src/lib/positions-manager.tsx | 4 ++-- libs/positions/src/lib/positions-table.spec.tsx | 2 +- libs/positions/src/lib/positions-table.tsx | 2 +- .../src/hooks/use-apply-grid-transaction.ts | 2 +- .../src/lib/grid-cells/flash-cell.stories.tsx | 2 +- .../src/components/ag-grid/ag-grid-dark.tsx | 2 +- .../src/components/ag-grid/ag-grid-light.tsx | 2 +- .../components/async-renderer/async-renderer.tsx | 2 +- .../src/components/button/button.stories.tsx | 2 +- libs/ui-toolkit/src/components/button/button.tsx | 6 ++++-- .../src/components/callout/callout.stories.tsx | 2 +- .../src/components/callout/callout.tsx | 3 ++- .../src/components/dialog/dialog.stories.tsx | 2 +- libs/ui-toolkit/src/components/dialog/dialog.tsx | 5 +++-- .../etherscan-link/etherscan-link.stories.tsx | 2 +- .../components/etherscan-link/etherscan-link.tsx | 2 +- .../src/components/form-group/form-group.tsx | 2 +- .../components/form-group/from-group.stories.tsx | 2 +- .../src/components/icon/icon.stories.tsx | 2 +- libs/ui-toolkit/src/components/icon/icon.tsx | 3 ++- .../input-error/input-error.stories.tsx | 2 +- .../src/components/input-error/input-error.tsx | 2 +- .../src/components/input/input.stories.tsx | 2 +- libs/ui-toolkit/src/components/input/input.tsx | 6 ++++-- .../src/components/lozenge/lozenge.stories.tsx | 2 +- .../src/components/lozenge/lozenge.tsx | 2 +- .../src/components/select/select.stories.tsx | 2 +- libs/ui-toolkit/src/components/select/select.tsx | 3 ++- .../src/components/splash/splash.stories.tsx | 5 +++-- libs/ui-toolkit/src/components/splash/splash.tsx | 2 +- .../components/text-area/text-area.stories.tsx | 2 +- .../src/components/text-area/text-area.tsx | 3 ++- .../theme-switcher/theme-switcher.stories.tsx | 2 +- .../src/components/vega-logo/lozenge.stories.tsx | 2 +- libs/ui-toolkit/src/utils/contrast.stories.tsx | 2 +- libs/wallet/src/connect-dialog.test.tsx | 5 +++-- libs/wallet/src/connect-dialog.tsx | 2 +- libs/wallet/src/connectors/index.ts | 2 +- libs/wallet/src/connectors/injected-connector.ts | 2 +- libs/wallet/src/connectors/rest-connector.ts | 10 ++++++---- libs/wallet/src/context.ts | 6 +++--- libs/wallet/src/provider.test.tsx | 2 +- libs/wallet/src/provider.tsx | 16 +++++----------- libs/wallet/src/rest-connector-form.tsx | 2 +- libs/wallet/src/use-vega-transaction.spec.tsx | 7 ++++--- libs/wallet/src/use-vega-transaction.ts | 4 ++-- libs/web3/src/lib/types.ts | 6 +++--- libs/web3/src/lib/web3-connect-dialog.tsx | 2 +- libs/web3/src/lib/web3-provider.tsx | 2 +- 115 files changed, 206 insertions(+), 184 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 6a841772d..dd2d9f7ed 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -48,6 +48,13 @@ "ts-check": false, "minimumDescriptionLength": 10 } + ], + "@typescript-eslint/consistent-type-imports": [ + "error", + { + "prefer": "type-imports", + "disallowTypeAnnotations": true + } ] } }, diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f3dbad68b..4060da6d0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,11 +31,11 @@ jobs: run: yarn install - name: Check formatting run: yarn nx format:check - - name: Check formatting - run: yarn eslint - - name: Check formatting + - name: Lint affected + run: yarn nx affected:lint + - name: Test affected run: yarn nx affected:test - - name: Check formatting + - name: Build affected run: yarn nx affected:build pr: name: Test and lint - PR @@ -59,9 +59,9 @@ jobs: run: yarn install - name: Check formatting run: yarn nx format:check - - name: Check formatting - run: yarn eslint - - name: Check formatting + - name: Lint affected + run: yarn nx affected:lint + - name: Test affected run: yarn nx affected:test - - name: Check formatting + - name: Build affected run: yarn nx affected:build diff --git a/apps/explorer/src/app/components/blocks/block-data.tsx b/apps/explorer/src/app/components/blocks/block-data.tsx index f155679b6..2fedb94ca 100644 --- a/apps/explorer/src/app/components/blocks/block-data.tsx +++ b/apps/explorer/src/app/components/blocks/block-data.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { BlockMeta } from '../../routes/blocks/tendermint-blockchain-response'; +import type { BlockMeta } from '../../routes/blocks/tendermint-blockchain-response'; import { Routes } from '../../routes/router-config'; import { Link } from 'react-router-dom'; import { SecondsAgo } from '../seconds-ago'; diff --git a/apps/explorer/src/app/components/blocks/blocks-data.tsx b/apps/explorer/src/app/components/blocks/blocks-data.tsx index 66d1301e1..512da0dbe 100644 --- a/apps/explorer/src/app/components/blocks/blocks-data.tsx +++ b/apps/explorer/src/app/components/blocks/blocks-data.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { TendermintBlockchainResponse } from '../../routes/blocks/tendermint-blockchain-response'; +import type { TendermintBlockchainResponse } from '../../routes/blocks/tendermint-blockchain-response'; import { BlockData } from './block-data'; interface BlocksProps { diff --git a/apps/explorer/src/app/components/jump-to/index.tsx b/apps/explorer/src/app/components/jump-to/index.tsx index 075efa5c6..1e723f3f9 100644 --- a/apps/explorer/src/app/components/jump-to/index.tsx +++ b/apps/explorer/src/app/components/jump-to/index.tsx @@ -1,4 +1,4 @@ -import { HTMLInputTypeAttribute, SyntheticEvent } from 'react'; +import type { HTMLInputTypeAttribute, SyntheticEvent } from 'react'; import { Input, Button } from '@vegaprotocol/ui-toolkit'; interface JumpToProps { diff --git a/apps/explorer/src/app/components/route-title/index.tsx b/apps/explorer/src/app/components/route-title/index.tsx index 393844f0c..99a0a5f79 100644 --- a/apps/explorer/src/app/components/route-title/index.tsx +++ b/apps/explorer/src/app/components/route-title/index.tsx @@ -1,5 +1,6 @@ import classnames from 'classnames'; -import React, { HTMLAttributes } from 'react'; +import type { HTMLAttributes } from 'react'; +import React from 'react'; interface RouteTitleProps extends HTMLAttributes { children: React.ReactNode; diff --git a/apps/explorer/src/app/components/sub-heading/index.tsx b/apps/explorer/src/app/components/sub-heading/index.tsx index 094ef2faf..839176ca7 100644 --- a/apps/explorer/src/app/components/sub-heading/index.tsx +++ b/apps/explorer/src/app/components/sub-heading/index.tsx @@ -1,5 +1,5 @@ import classnames from 'classnames'; -import { HTMLAttributes } from 'react'; +import type { HTMLAttributes } from 'react'; interface SubHeadingProps extends HTMLAttributes { children: React.ReactNode; diff --git a/apps/explorer/src/app/components/table/index.tsx b/apps/explorer/src/app/components/table/index.tsx index 186306c45..c23ef343e 100644 --- a/apps/explorer/src/app/components/table/index.tsx +++ b/apps/explorer/src/app/components/table/index.tsx @@ -1,4 +1,5 @@ -import React, { ThHTMLAttributes } from 'react'; +import type { ThHTMLAttributes } from 'react'; +import React from 'react'; import classnames from 'classnames'; interface TableProps extends ThHTMLAttributes { diff --git a/apps/explorer/src/app/components/txs/block-txs-data.tsx b/apps/explorer/src/app/components/txs/block-txs-data.tsx index bde3f6187..7ef9c1410 100644 --- a/apps/explorer/src/app/components/txs/block-txs-data.tsx +++ b/apps/explorer/src/app/components/txs/block-txs-data.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { TendermintBlockchainResponse } from '../../routes/blocks/tendermint-blockchain-response'; +import type { TendermintBlockchainResponse } from '../../routes/blocks/tendermint-blockchain-response'; import { BlockData } from '../blocks'; import { TxsPerBlock } from './txs-per-block'; diff --git a/apps/explorer/src/app/components/txs/tx-list.tsx b/apps/explorer/src/app/components/txs/tx-list.tsx index 1a9198fbc..98f3500ca 100644 --- a/apps/explorer/src/app/components/txs/tx-list.tsx +++ b/apps/explorer/src/app/components/txs/tx-list.tsx @@ -1,4 +1,4 @@ -import { TendermintUnconfirmedTransactionsResponse } from '../../routes/txs/tendermint-unconfirmed-transactions-response.d'; +import type { TendermintUnconfirmedTransactionsResponse } from '../../routes/txs/tendermint-unconfirmed-transactions-response.d'; interface TxsProps { data: TendermintUnconfirmedTransactionsResponse | undefined; diff --git a/apps/explorer/src/app/components/txs/txs-per-block.tsx b/apps/explorer/src/app/components/txs/txs-per-block.tsx index 67613281e..808d3adf4 100644 --- a/apps/explorer/src/app/components/txs/txs-per-block.tsx +++ b/apps/explorer/src/app/components/txs/txs-per-block.tsx @@ -1,5 +1,5 @@ import useFetch from '../../hooks/use-fetch'; -import { ChainExplorerTxResponse } from '../../routes/types/chain-explorer-response'; +import type { ChainExplorerTxResponse } from '../../routes/types/chain-explorer-response'; import { Routes } from '../../routes/router-config'; import { DATA_SOURCES } from '../../config'; import { Link } from 'react-router-dom'; diff --git a/apps/explorer/src/app/contexts/websocket/tendermint-websocket-context.ts b/apps/explorer/src/app/contexts/websocket/tendermint-websocket-context.ts index 8ee2f6400..089b52d70 100644 --- a/apps/explorer/src/app/contexts/websocket/tendermint-websocket-context.ts +++ b/apps/explorer/src/app/contexts/websocket/tendermint-websocket-context.ts @@ -1,5 +1,5 @@ import React from 'react'; -import { WebSocketHook } from 'react-use-websocket/dist/lib/types'; +import type { WebSocketHook } from 'react-use-websocket/dist/lib/types'; export type WebsocketContextShape = WebSocketHook; diff --git a/apps/explorer/src/app/routes/assets/index.tsx b/apps/explorer/src/app/routes/assets/index.tsx index caa2ae40d..3fdf7f19e 100644 --- a/apps/explorer/src/app/routes/assets/index.tsx +++ b/apps/explorer/src/app/routes/assets/index.tsx @@ -3,7 +3,7 @@ import React from 'react'; import { RouteTitle } from '../../components/route-title'; import { SubHeading } from '../../components/sub-heading'; import { SyntaxHighlighter } from '../../components/syntax-highlighter'; -import { AssetsQuery } from './__generated__/AssetsQuery'; +import type { AssetsQuery } from './__generated__/AssetsQuery'; export const ASSETS_QUERY = gql` query AssetsQuery { diff --git a/apps/explorer/src/app/routes/blocks/home/index.tsx b/apps/explorer/src/app/routes/blocks/home/index.tsx index 15a6c8425..b6fa12635 100644 --- a/apps/explorer/src/app/routes/blocks/home/index.tsx +++ b/apps/explorer/src/app/routes/blocks/home/index.tsx @@ -1,6 +1,6 @@ import { DATA_SOURCES } from '../../../config'; import useFetch from '../../../hooks/use-fetch'; -import { TendermintBlockchainResponse } from '../tendermint-blockchain-response'; +import type { TendermintBlockchainResponse } from '../tendermint-blockchain-response'; import { RouteTitle } from '../../../components/route-title'; import { RenderFetched } from '../../../components/render-fetched'; import { BlocksData, BlocksRefetch } from '../../../components/blocks'; diff --git a/apps/explorer/src/app/routes/blocks/id/block.tsx b/apps/explorer/src/app/routes/blocks/id/block.tsx index 0cddc8a28..a506c20d4 100644 --- a/apps/explorer/src/app/routes/blocks/id/block.tsx +++ b/apps/explorer/src/app/routes/blocks/id/block.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { Link, useParams } from 'react-router-dom'; import { DATA_SOURCES } from '../../../config'; import useFetch from '../../../hooks/use-fetch'; -import { TendermintBlocksResponse } from '../tendermint-blocks-response'; +import type { TendermintBlocksResponse } from '../tendermint-blocks-response'; import { RouteTitle } from '../../../components/route-title'; import { SecondsAgo } from '../../../components/seconds-ago'; import { diff --git a/apps/explorer/src/app/routes/blocks/tendermint-new-block.d.ts b/apps/explorer/src/app/routes/blocks/tendermint-new-block.d.ts index 63e134689..4111b34ec 100644 --- a/apps/explorer/src/app/routes/blocks/tendermint-new-block.d.ts +++ b/apps/explorer/src/app/routes/blocks/tendermint-new-block.d.ts @@ -63,6 +63,7 @@ export interface Block { last_commit: LastCommit; } +// eslint-disable-next-line @typescript-eslint/no-empty-interface export interface ResultBeginBlock {} export interface ResultEndBlock { @@ -81,7 +82,7 @@ export interface Data { } export interface Events { - "tm.event": string[]; + 'tm.event': string[]; } export interface Result { diff --git a/apps/explorer/src/app/routes/genesis/index.tsx b/apps/explorer/src/app/routes/genesis/index.tsx index 2b88c265c..960087c32 100644 --- a/apps/explorer/src/app/routes/genesis/index.tsx +++ b/apps/explorer/src/app/routes/genesis/index.tsx @@ -2,7 +2,7 @@ import { RouteTitle } from '../../components/route-title'; import { SyntaxHighlighter } from '../../components/syntax-highlighter'; import { DATA_SOURCES } from '../../config'; import useFetch from '../../hooks/use-fetch'; -import { TendermintGenesisResponse } from './tendermint-genesis-response'; +import type { TendermintGenesisResponse } from './tendermint-genesis-response'; const Genesis = () => { const { diff --git a/apps/explorer/src/app/routes/genesis/tendermint-genesis-response.d.ts b/apps/explorer/src/app/routes/genesis/tendermint-genesis-response.d.ts index c0105af37..afa61555a 100644 --- a/apps/explorer/src/app/routes/genesis/tendermint-genesis-response.d.ts +++ b/apps/explorer/src/app/routes/genesis/tendermint-genesis-response.d.ts @@ -13,6 +13,7 @@ export interface ValidatorAddresses { pub_key_types: string[]; } +// eslint-disable-next-line @typescript-eslint/no-empty-interface export interface Version {} export interface ConsensusParams { diff --git a/apps/explorer/src/app/routes/governance/index.tsx b/apps/explorer/src/app/routes/governance/index.tsx index e55c99337..30af1c727 100644 --- a/apps/explorer/src/app/routes/governance/index.tsx +++ b/apps/explorer/src/app/routes/governance/index.tsx @@ -3,7 +3,7 @@ import React from 'react'; import { RouteTitle } from '../../components/route-title'; import { SubHeading } from '../../components/sub-heading'; import { SyntaxHighlighter } from '../../components/syntax-highlighter'; -import { +import type { ProposalsQuery, ProposalsQuery_proposals_terms_change, } from './__generated__/ProposalsQuery'; diff --git a/apps/explorer/src/app/routes/markets/index.tsx b/apps/explorer/src/app/routes/markets/index.tsx index 075f8619d..dfe1adc78 100644 --- a/apps/explorer/src/app/routes/markets/index.tsx +++ b/apps/explorer/src/app/routes/markets/index.tsx @@ -1,5 +1,5 @@ import { gql, useQuery } from '@apollo/client'; -import { MarketsQuery } from './__generated__/MarketsQuery'; +import type { MarketsQuery } from './__generated__/MarketsQuery'; import React from 'react'; import { SyntaxHighlighter } from '../../components/syntax-highlighter'; diff --git a/apps/explorer/src/app/routes/network-parameters/index.tsx b/apps/explorer/src/app/routes/network-parameters/index.tsx index 28822cd80..cf0569618 100644 --- a/apps/explorer/src/app/routes/network-parameters/index.tsx +++ b/apps/explorer/src/app/routes/network-parameters/index.tsx @@ -1,6 +1,6 @@ import { gql, useQuery } from '@apollo/client'; import { RouteTitle } from '../../components/route-title'; -import { NetworkParametersQuery } from './__generated__/NetworkParametersQuery'; +import type { NetworkParametersQuery } from './__generated__/NetworkParametersQuery'; import { SyntaxHighlighter } from '../../components/syntax-highlighter'; export const NETWORK_PARAMETERS_QUERY = gql` diff --git a/apps/explorer/src/app/routes/parties/id/index.tsx b/apps/explorer/src/app/routes/parties/id/index.tsx index d9aed4dad..809af5bc3 100644 --- a/apps/explorer/src/app/routes/parties/id/index.tsx +++ b/apps/explorer/src/app/routes/parties/id/index.tsx @@ -7,8 +7,8 @@ import { SubHeading } from '../../../components/sub-heading'; import { SyntaxHighlighter } from '../../../components/syntax-highlighter'; import { DATA_SOURCES } from '../../../config'; import useFetch from '../../../hooks/use-fetch'; -import { TendermintSearchTransactionResponse } from '../tendermint-transaction-response'; -import { +import type { TendermintSearchTransactionResponse } from '../tendermint-transaction-response'; +import type { PartyAssetsQuery, PartyAssetsQueryVariables, } from './__generated__/PartyAssetsQuery'; diff --git a/apps/explorer/src/app/routes/pending/index.tsx b/apps/explorer/src/app/routes/pending/index.tsx index 1955f0aeb..97bb5ab93 100644 --- a/apps/explorer/src/app/routes/pending/index.tsx +++ b/apps/explorer/src/app/routes/pending/index.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { DATA_SOURCES } from '../../config'; import useFetch from '../../hooks/use-fetch'; -import { TendermintUnconfirmedTransactionsResponse } from '../txs/tendermint-unconfirmed-transactions-response.d'; +import type { TendermintUnconfirmedTransactionsResponse } from '../txs/tendermint-unconfirmed-transactions-response.d'; import { TxList } from '../../components/txs'; import { RouteTitle } from '../../components/route-title'; diff --git a/apps/explorer/src/app/routes/txs/home/index.tsx b/apps/explorer/src/app/routes/txs/home/index.tsx index fc382840d..558fc1d34 100644 --- a/apps/explorer/src/app/routes/txs/home/index.tsx +++ b/apps/explorer/src/app/routes/txs/home/index.tsx @@ -1,5 +1,5 @@ import useFetch from '../../../hooks/use-fetch'; -import { TendermintBlockchainResponse } from '../../blocks/tendermint-blockchain-response'; +import type { TendermintBlockchainResponse } from '../../blocks/tendermint-blockchain-response'; import { DATA_SOURCES } from '../../../config'; import { RouteTitle } from '../../../components/route-title'; import { BlocksRefetch } from '../../../components/blocks'; diff --git a/apps/explorer/src/app/routes/txs/id/index.tsx b/apps/explorer/src/app/routes/txs/id/index.tsx index bb78aed50..93a27887d 100644 --- a/apps/explorer/src/app/routes/txs/id/index.tsx +++ b/apps/explorer/src/app/routes/txs/id/index.tsx @@ -1,8 +1,8 @@ import React from 'react'; import { useParams } from 'react-router-dom'; import useFetch from '../../../hooks/use-fetch'; -import { TendermintTransactionResponse } from '../tendermint-transaction-response.d'; -import { ChainExplorerTxResponse } from '../../types/chain-explorer-response'; +import type { TendermintTransactionResponse } from '../tendermint-transaction-response.d'; +import type { ChainExplorerTxResponse } from '../../types/chain-explorer-response'; import { DATA_SOURCES } from '../../../config'; import { RouteTitle } from '../../../components/route-title'; import { RenderFetched } from '../../../components/render-fetched'; diff --git a/apps/explorer/src/app/routes/txs/id/tx-content.tsx b/apps/explorer/src/app/routes/txs/id/tx-content.tsx index 8d334080c..a5a194740 100644 --- a/apps/explorer/src/app/routes/txs/id/tx-content.tsx +++ b/apps/explorer/src/app/routes/txs/id/tx-content.tsx @@ -7,7 +7,7 @@ import { TableRow, } from '../../../components/table'; import { TxOrderType } from '../../../components/txs'; -import { ChainExplorerTxResponse } from '../../../routes/types/chain-explorer-response'; +import type { ChainExplorerTxResponse } from '../../../routes/types/chain-explorer-response'; interface TxContentProps { data: ChainExplorerTxResponse | undefined; diff --git a/apps/explorer/src/app/routes/txs/id/tx-details.tsx b/apps/explorer/src/app/routes/txs/id/tx-details.tsx index 6e3f8e6b8..497d4efa1 100644 --- a/apps/explorer/src/app/routes/txs/id/tx-details.tsx +++ b/apps/explorer/src/app/routes/txs/id/tx-details.tsx @@ -7,7 +7,7 @@ import { } from '../../../components/table'; import { TruncateInline } from '../../../components/truncate/truncate'; import { Routes } from '../../../routes/router-config'; -import { Result } from '../../../routes/txs/tendermint-transaction-response.d'; +import type { Result } from '../../../routes/txs/tendermint-transaction-response.d'; interface TxDetailsProps { txData: Result | undefined; diff --git a/apps/explorer/src/app/routes/validators/index.tsx b/apps/explorer/src/app/routes/validators/index.tsx index ffb93d1fa..521b83bbc 100644 --- a/apps/explorer/src/app/routes/validators/index.tsx +++ b/apps/explorer/src/app/routes/validators/index.tsx @@ -5,8 +5,8 @@ import { SubHeading } from '../../components/sub-heading'; import { SyntaxHighlighter } from '../../components/syntax-highlighter'; import { DATA_SOURCES } from '../../config'; import useFetch from '../../hooks/use-fetch'; -import { TendermintValidatorsResponse } from './tendermint-validator-response'; -import { NodesQuery } from './__generated__/NodesQuery'; +import type { TendermintValidatorsResponse } from './tendermint-validator-response'; +import type { NodesQuery } from './__generated__/NodesQuery'; const NODES_QUERY = gql` query NodesQuery { diff --git a/apps/stats/src/report-web-vitals.ts b/apps/stats/src/report-web-vitals.ts index 49a2a16e0..6071e230d 100644 --- a/apps/stats/src/report-web-vitals.ts +++ b/apps/stats/src/report-web-vitals.ts @@ -1,4 +1,4 @@ -import { ReportHandler } from 'web-vitals'; +import type { ReportHandler } from 'web-vitals'; const reportWebVitals = (onPerfEntry?: ReportHandler) => { if (onPerfEntry && onPerfEntry instanceof Function) { diff --git a/apps/trading/components/app-loader/index.tsx b/apps/trading/components/app-loader/index.tsx index cb6f2d013..daf3ca871 100644 --- a/apps/trading/components/app-loader/index.tsx +++ b/apps/trading/components/app-loader/index.tsx @@ -1,5 +1,5 @@ import { useEagerConnect } from '../../hooks/use-vega-wallet-eager-connect'; -import { ReactNode } from 'react'; +import type { ReactNode } from 'react'; interface AppLoaderProps { children: ReactNode; diff --git a/apps/trading/components/page-query-container/index.tsx b/apps/trading/components/page-query-container/index.tsx index 360262604..44c3a3ed7 100644 --- a/apps/trading/components/page-query-container/index.tsx +++ b/apps/trading/components/page-query-container/index.tsx @@ -1,6 +1,7 @@ -import { OperationVariables, QueryHookOptions, useQuery } from '@apollo/client'; -import { DocumentNode } from 'graphql'; -import { ReactNode } from 'react'; +import type { OperationVariables, QueryHookOptions } from '@apollo/client'; +import { useQuery } from '@apollo/client'; +import type { DocumentNode } from 'graphql'; +import type { ReactNode } from 'react'; import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; interface PageQueryContainerProps { diff --git a/apps/trading/components/web3-container/web3-container.tsx b/apps/trading/components/web3-container/web3-container.tsx index 2241bc953..e2a48380d 100644 --- a/apps/trading/components/web3-container/web3-container.tsx +++ b/apps/trading/components/web3-container/web3-container.tsx @@ -1,7 +1,8 @@ import { Button, Splash } from '@vegaprotocol/ui-toolkit'; import { Web3Provider, Web3ConnectDialog } from '@vegaprotocol/web3'; import { useWeb3React } from '@web3-react/core'; -import { ReactNode, useEffect, useState } from 'react'; +import type { ReactNode } from 'react'; +import { useEffect, useState } from 'react'; import { Connectors } from '../../lib/web3-connectors'; interface Web3ContainerProps { diff --git a/apps/trading/pages/_app.page.tsx b/apps/trading/pages/_app.page.tsx index d5b1a8668..ae37cdfef 100644 --- a/apps/trading/pages/_app.page.tsx +++ b/apps/trading/pages/_app.page.tsx @@ -1,4 +1,4 @@ -import { AppProps } from 'next/app'; +import type { AppProps } from 'next/app'; import Head from 'next/head'; import { Navbar } from '../components/navbar'; import { ThemeContext } from '@vegaprotocol/react-helpers'; diff --git a/apps/trading/pages/markets/[marketId].page.tsx b/apps/trading/pages/markets/[marketId].page.tsx index 3fc398def..dfd37f869 100644 --- a/apps/trading/pages/markets/[marketId].page.tsx +++ b/apps/trading/pages/markets/[marketId].page.tsx @@ -1,5 +1,5 @@ import { gql } from '@apollo/client'; -import { Market, MarketVariables } from './__generated__/Market'; +import type { Market, MarketVariables } from './__generated__/Market'; import { Splash } from '@vegaprotocol/ui-toolkit'; import { useRouter } from 'next/router'; import React, { useEffect, useState } from 'react'; diff --git a/apps/trading/pages/markets/grid-tabs.tsx b/apps/trading/pages/markets/grid-tabs.tsx index ecab02260..5d7a248fc 100644 --- a/apps/trading/pages/markets/grid-tabs.tsx +++ b/apps/trading/pages/markets/grid-tabs.tsx @@ -1,14 +1,8 @@ import * as Tabs from '@radix-ui/react-tabs'; import classNames from 'classnames'; import { useRouter } from 'next/router'; -import { - Children, - isValidElement, - ReactElement, - ReactNode, - useEffect, - useState, -} from 'react'; +import type { ReactElement, ReactNode } from 'react'; +import { Children, isValidElement, useEffect, useState } from 'react'; interface GridTabsProps { children: ReactElement[]; diff --git a/apps/trading/pages/markets/trade-grid.tsx b/apps/trading/pages/markets/trade-grid.tsx index a42059118..ce600e8b6 100644 --- a/apps/trading/pages/markets/trade-grid.tsx +++ b/apps/trading/pages/markets/trade-grid.tsx @@ -1,12 +1,13 @@ import classNames from 'classnames'; import AutoSizer from 'react-virtualized-auto-sizer'; -import { useState, ReactNode } from 'react'; +import type { ReactNode } from 'react'; +import { useState } from 'react'; import { GridTab, GridTabs } from './grid-tabs'; import { DealTicketContainer } from '@vegaprotocol/deal-ticket'; import { OrderListContainer } from '@vegaprotocol/order-list'; import { Splash } from '@vegaprotocol/ui-toolkit'; import { PositionsContainer } from '@vegaprotocol/positions'; -import { Market_market } from './__generated__/Market'; +import type { Market_market } from './__generated__/Market'; const Chart = () => ( diff --git a/libs/deal-ticket/src/deal-ticket-container.tsx b/libs/deal-ticket/src/deal-ticket-container.tsx index 8715f5406..359f99da5 100644 --- a/libs/deal-ticket/src/deal-ticket-container.tsx +++ b/libs/deal-ticket/src/deal-ticket-container.tsx @@ -1,7 +1,7 @@ import { AsyncRenderer, Splash } from '@vegaprotocol/ui-toolkit'; import { gql, useQuery } from '@apollo/client'; import { DealTicketManager } from './deal-ticket-manager'; -import { DealTicketQuery } from './__generated__/DealTicketQuery'; +import type { DealTicketQuery } from './__generated__/DealTicketQuery'; const DEAL_TICKET_QUERY = gql` query DealTicketQuery($marketId: ID!) { diff --git a/libs/deal-ticket/src/deal-ticket-limit.tsx b/libs/deal-ticket/src/deal-ticket-limit.tsx index 92df74775..a8fa08443 100644 --- a/libs/deal-ticket/src/deal-ticket-limit.tsx +++ b/libs/deal-ticket/src/deal-ticket-limit.tsx @@ -1,13 +1,13 @@ import { FormGroup, Input } from '@vegaprotocol/ui-toolkit'; import { OrderTimeInForce } from '@vegaprotocol/wallet'; -import { TransactionStatus } from './deal-ticket'; +import type { TransactionStatus } from './deal-ticket'; import { ExpirySelector } from './expiry-selector'; import { SideSelector } from './side-selector'; import { SubmitButton } from './submit-button'; import { TimeInForceSelector } from './time-in-force-selector'; import { TypeSelector } from './type-selector'; -import { Order } from './use-order-state'; -import { DealTicketQuery_market } from './__generated__/DealTicketQuery'; +import type { Order } from './use-order-state'; +import type { DealTicketQuery_market } from './__generated__/DealTicketQuery'; interface DealTicketLimitProps { order: Order; diff --git a/libs/deal-ticket/src/deal-ticket-manager.tsx b/libs/deal-ticket/src/deal-ticket-manager.tsx index 837cb15ce..c7cc976f6 100644 --- a/libs/deal-ticket/src/deal-ticket-manager.tsx +++ b/libs/deal-ticket/src/deal-ticket-manager.tsx @@ -5,7 +5,7 @@ import { VegaTxStatus } from '@vegaprotocol/wallet'; import { DealTicket } from './deal-ticket'; import { useOrderSubmit } from './use-order-submit'; import { OrderDialog } from './order-dialog'; -import { DealTicketQuery_market } from './__generated__/DealTicketQuery'; +import type { DealTicketQuery_market } from './__generated__/DealTicketQuery'; interface DealTicketManagerProps { market: DealTicketQuery_market; diff --git a/libs/deal-ticket/src/deal-ticket-market.tsx b/libs/deal-ticket/src/deal-ticket-market.tsx index 3c1d11584..2caac612e 100644 --- a/libs/deal-ticket/src/deal-ticket-market.tsx +++ b/libs/deal-ticket/src/deal-ticket-market.tsx @@ -1,12 +1,12 @@ import { addDecimal } from '@vegaprotocol/react-helpers'; import { FormGroup, Input } from '@vegaprotocol/ui-toolkit'; -import { TransactionStatus } from './deal-ticket'; +import type { TransactionStatus } from './deal-ticket'; import { SideSelector } from './side-selector'; import { SubmitButton } from './submit-button'; import { TimeInForceSelector } from './time-in-force-selector'; import { TypeSelector } from './type-selector'; -import { Order } from './use-order-state'; -import { DealTicketQuery_market } from './__generated__/DealTicketQuery'; +import type { Order } from './use-order-state'; +import type { DealTicketQuery_market } from './__generated__/DealTicketQuery'; interface DealTicketMarketProps { order: Order; diff --git a/libs/deal-ticket/src/deal-ticket.spec.tsx b/libs/deal-ticket/src/deal-ticket.spec.tsx index 9bd9c76c3..902e9e80e 100644 --- a/libs/deal-ticket/src/deal-ticket.spec.tsx +++ b/libs/deal-ticket/src/deal-ticket.spec.tsx @@ -7,8 +7,8 @@ import { import { addDecimal } from '@vegaprotocol/react-helpers'; import { fireEvent, render, screen } from '@testing-library/react'; import { DealTicket } from './deal-ticket'; -import { Order } from './use-order-state'; -import { DealTicketQuery_market } from './__generated__/DealTicketQuery'; +import type { Order } from './use-order-state'; +import type { DealTicketQuery_market } from './__generated__/DealTicketQuery'; import { MarketState, MarketTradingMode } from '@vegaprotocol/types'; const order: Order = { diff --git a/libs/deal-ticket/src/deal-ticket.tsx b/libs/deal-ticket/src/deal-ticket.tsx index ceeb28ca2..52e32fd0a 100644 --- a/libs/deal-ticket/src/deal-ticket.tsx +++ b/libs/deal-ticket/src/deal-ticket.tsx @@ -1,9 +1,10 @@ -import { FormEvent } from 'react'; +import type { FormEvent } from 'react'; import { OrderSide, OrderTimeInForce, OrderType } from '@vegaprotocol/wallet'; -import { Order, useOrderState } from './use-order-state'; +import type { Order } from './use-order-state'; +import { useOrderState } from './use-order-state'; import { DealTicketMarket } from './deal-ticket-market'; import { DealTicketLimit } from './deal-ticket-limit'; -import { DealTicketQuery_market } from './__generated__/DealTicketQuery'; +import type { DealTicketQuery_market } from './__generated__/DealTicketQuery'; const DEFAULT_ORDER: Order = { type: OrderType.Market, diff --git a/libs/deal-ticket/src/expiry-selector.tsx b/libs/deal-ticket/src/expiry-selector.tsx index 01f01243d..cdb745a63 100644 --- a/libs/deal-ticket/src/expiry-selector.tsx +++ b/libs/deal-ticket/src/expiry-selector.tsx @@ -1,5 +1,5 @@ import { FormGroup, Input } from '@vegaprotocol/ui-toolkit'; -import { Order } from './use-order-state'; +import type { Order } from './use-order-state'; import { formatForInput } from '@vegaprotocol/react-helpers'; interface ExpirySelectorProps { diff --git a/libs/deal-ticket/src/order-dialog.tsx b/libs/deal-ticket/src/order-dialog.tsx index 950ec4162..aaa9e75a6 100644 --- a/libs/deal-ticket/src/order-dialog.tsx +++ b/libs/deal-ticket/src/order-dialog.tsx @@ -1,8 +1,9 @@ import { Icon, Loader } from '@vegaprotocol/ui-toolkit'; -import { ReactNode } from 'react'; -import { OrderEvent_busEvents_event_Order } from './__generated__/OrderEvent'; +import type { ReactNode } from 'react'; +import type { OrderEvent_busEvents_event_Order } from './__generated__/OrderEvent'; import { formatNumber } from '@vegaprotocol/react-helpers'; -import { TransactionState, VegaTxStatus } from '@vegaprotocol/wallet'; +import type { TransactionState } from '@vegaprotocol/wallet'; +import { VegaTxStatus } from '@vegaprotocol/wallet'; interface OrderDialogProps { transaction: TransactionState; diff --git a/libs/deal-ticket/src/side-selector.tsx b/libs/deal-ticket/src/side-selector.tsx index 029ea318a..ef891cd3c 100644 --- a/libs/deal-ticket/src/side-selector.tsx +++ b/libs/deal-ticket/src/side-selector.tsx @@ -1,7 +1,7 @@ import { FormGroup } from '@vegaprotocol/ui-toolkit'; import { OrderSide } from '@vegaprotocol/wallet'; import { ButtonRadio } from './button-radio'; -import { Order } from './use-order-state'; +import type { Order } from './use-order-state'; interface SideSelectorProps { order: Order; diff --git a/libs/deal-ticket/src/submit-button.tsx b/libs/deal-ticket/src/submit-button.tsx index 6359a9f48..83bfb90f6 100644 --- a/libs/deal-ticket/src/submit-button.tsx +++ b/libs/deal-ticket/src/submit-button.tsx @@ -1,10 +1,10 @@ import { Button, InputError } from '@vegaprotocol/ui-toolkit'; import { OrderTimeInForce, OrderType } from '@vegaprotocol/wallet'; import { useMemo } from 'react'; -import { Order } from './use-order-state'; +import type { Order } from './use-order-state'; import { useVegaWallet } from '@vegaprotocol/wallet'; -import { TransactionStatus } from './deal-ticket'; -import { DealTicketQuery_market } from './__generated__/DealTicketQuery'; +import type { TransactionStatus } from './deal-ticket'; +import type { DealTicketQuery_market } from './__generated__/DealTicketQuery'; import { MarketState, MarketTradingMode } from '@vegaprotocol/types'; interface SubmitButtonProps { diff --git a/libs/deal-ticket/src/time-in-force-selector.tsx b/libs/deal-ticket/src/time-in-force-selector.tsx index 6c793ea46..abea9a766 100644 --- a/libs/deal-ticket/src/time-in-force-selector.tsx +++ b/libs/deal-ticket/src/time-in-force-selector.tsx @@ -1,6 +1,6 @@ import { FormGroup, Select } from '@vegaprotocol/ui-toolkit'; import { OrderTimeInForce, OrderType } from '@vegaprotocol/wallet'; -import { Order } from './use-order-state'; +import type { Order } from './use-order-state'; interface TimeInForceSelectorProps { order: Order; diff --git a/libs/deal-ticket/src/type-selector.tsx b/libs/deal-ticket/src/type-selector.tsx index b3621843a..a39ee2c57 100644 --- a/libs/deal-ticket/src/type-selector.tsx +++ b/libs/deal-ticket/src/type-selector.tsx @@ -1,7 +1,7 @@ import { FormGroup } from '@vegaprotocol/ui-toolkit'; import { OrderType } from '@vegaprotocol/wallet'; import { ButtonRadio } from './button-radio'; -import { Order } from './use-order-state'; +import type { Order } from './use-order-state'; interface TypeSelectorProps { order: Order; diff --git a/libs/deal-ticket/src/use-order-state.ts b/libs/deal-ticket/src/use-order-state.ts index 42545ce01..787725ade 100644 --- a/libs/deal-ticket/src/use-order-state.ts +++ b/libs/deal-ticket/src/use-order-state.ts @@ -1,4 +1,5 @@ -import { OrderSide, OrderTimeInForce, OrderType } from '@vegaprotocol/wallet'; +import type { OrderSide } from '@vegaprotocol/wallet'; +import { OrderTimeInForce, OrderType } from '@vegaprotocol/wallet'; import { useState, useCallback } from 'react'; export interface Order { diff --git a/libs/deal-ticket/src/use-order-submit.spec.tsx b/libs/deal-ticket/src/use-order-submit.spec.tsx index e89d78607..2f50a0a30 100644 --- a/libs/deal-ticket/src/use-order-submit.spec.tsx +++ b/libs/deal-ticket/src/use-order-submit.spec.tsx @@ -1,14 +1,13 @@ import { MockedProvider } from '@apollo/client/testing'; import { act, renderHook } from '@testing-library/react-hooks'; -import { Order } from './use-order-state'; -import { +import type { Order } from './use-order-state'; +import type { VegaKeyExtended, - VegaTxStatus, - VegaWalletContext, VegaWalletContextShape, } from '@vegaprotocol/wallet'; +import { VegaTxStatus, VegaWalletContext } from '@vegaprotocol/wallet'; import { OrderSide, OrderTimeInForce, OrderType } from '@vegaprotocol/wallet'; -import { ReactNode } from 'react'; +import type { ReactNode } from 'react'; import { useOrderSubmit } from './use-order-submit'; const defaultWalletContext = { diff --git a/libs/deal-ticket/src/use-order-submit.ts b/libs/deal-ticket/src/use-order-submit.ts index 4392ab024..fae8e81d2 100644 --- a/libs/deal-ticket/src/use-order-submit.ts +++ b/libs/deal-ticket/src/use-order-submit.ts @@ -2,11 +2,11 @@ import { useCallback, useEffect, useState } from 'react'; import { gql, useSubscription } from '@apollo/client'; import { ethers } from 'ethers'; import { SHA3 } from 'sha3'; -import { Order } from './use-order-state'; +import type { Order } from './use-order-state'; import { OrderType, useVegaWallet } from '@vegaprotocol/wallet'; import { removeDecimal } from '@vegaprotocol/react-helpers'; import { useVegaTransaction } from '@vegaprotocol/wallet'; -import { +import type { OrderEvent, OrderEventVariables, OrderEvent_busEvents_event_Order, diff --git a/libs/market-list/src/lib/market-list-table.tsx b/libs/market-list/src/lib/market-list-table.tsx index 8b58d21eb..1c537d0d6 100644 --- a/libs/market-list/src/lib/market-list-table.tsx +++ b/libs/market-list/src/lib/market-list-table.tsx @@ -2,7 +2,7 @@ import { forwardRef } from 'react'; import type { ValueFormatterParams } from 'ag-grid-community'; import { PriceCell, formatNumber } from '@vegaprotocol/react-helpers'; import { AgGridDynamic as AgGrid } from '@vegaprotocol/ui-toolkit'; -import { Markets_markets } from './__generated__/Markets'; +import type { Markets_markets } from './__generated__/Markets'; import { AgGridColumn } from 'ag-grid-react'; import type { AgGridReact } from 'ag-grid-react'; diff --git a/libs/market-list/src/lib/markets-container.tsx b/libs/market-list/src/lib/markets-container.tsx index b4813ccce..ee5cd20e5 100644 --- a/libs/market-list/src/lib/markets-container.tsx +++ b/libs/market-list/src/lib/markets-container.tsx @@ -6,7 +6,10 @@ import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; import { MarketListTable, getRowNodeId } from './market-list-table'; import { useDataProvider } from '@vegaprotocol/react-helpers'; import type { AgGridReact } from 'ag-grid-react'; -import { Markets_markets, Markets_markets_data } from './__generated__/Markets'; +import type { + Markets_markets, + Markets_markets_data, +} from './__generated__/Markets'; import { marketsDataProvider } from './markets-data-provider'; export const MarketsContainer = () => { diff --git a/libs/market-list/src/lib/markets-data-provider.ts b/libs/market-list/src/lib/markets-data-provider.ts index 67f6fffc6..6ee73e94f 100644 --- a/libs/market-list/src/lib/markets-data-provider.ts +++ b/libs/market-list/src/lib/markets-data-provider.ts @@ -1,8 +1,8 @@ import { gql } from '@apollo/client'; -import { Markets, Markets_markets } from './__generated__/Markets'; +import type { Markets, Markets_markets } from './__generated__/Markets'; import { makeDataProvider } from '@vegaprotocol/react-helpers'; -import { +import type { MarketDataSub, MarketDataSub_marketData, } from './__generated__/MarketDataSub'; diff --git a/libs/network-stats/src/components/good-threshold-indicator/good-threshold-indicator.tsx b/libs/network-stats/src/components/good-threshold-indicator/good-threshold-indicator.tsx index 4844e7955..0e7d517c2 100644 --- a/libs/network-stats/src/components/good-threshold-indicator/good-threshold-indicator.tsx +++ b/libs/network-stats/src/components/good-threshold-indicator/good-threshold-indicator.tsx @@ -1,4 +1,4 @@ -import { value, goodThreshold } from '../../config/types'; +import type { value, goodThreshold } from '../../config/types'; interface GoodThresholdIndicatorProps { goodThreshold: goodThreshold | undefined; diff --git a/libs/network-stats/src/components/promoted-stats-item/promoted-stats-item.tsx b/libs/network-stats/src/components/promoted-stats-item/promoted-stats-item.tsx index 0b6f9e4f5..ec47ac010 100644 --- a/libs/network-stats/src/components/promoted-stats-item/promoted-stats-item.tsx +++ b/libs/network-stats/src/components/promoted-stats-item/promoted-stats-item.tsx @@ -1,5 +1,5 @@ import { Tooltip } from '../tooltip'; -import { StatFields } from '../../config/types'; +import type { StatFields } from '../../config/types'; import { defaultFieldFormatter } from '../table-row'; import { GoodThresholdIndicator } from '../good-threshold-indicator'; diff --git a/libs/network-stats/src/components/stats-manager/stats-manager.tsx b/libs/network-stats/src/components/stats-manager/stats-manager.tsx index c7b3a1e40..302503e98 100644 --- a/libs/network-stats/src/components/stats-manager/stats-manager.tsx +++ b/libs/network-stats/src/components/stats-manager/stats-manager.tsx @@ -1,7 +1,7 @@ import { useEffect, useState } from 'react'; import classnames from 'classnames'; import { statsFields } from '../../config/stats-fields'; -import { +import type { Stats as IStats, StructuredStats as IStructuredStats, } from '../../config/types'; diff --git a/libs/network-stats/src/components/table-row/table-row.tsx b/libs/network-stats/src/components/table-row/table-row.tsx index 4a6403ab5..b43296596 100644 --- a/libs/network-stats/src/components/table-row/table-row.tsx +++ b/libs/network-stats/src/components/table-row/table-row.tsx @@ -1,5 +1,5 @@ import { Tooltip } from '../tooltip'; -import { StatFields } from '../../config/types'; +import type { StatFields } from '../../config/types'; import { GoodThresholdIndicator } from '../good-threshold-indicator'; export const defaultFieldFormatter = (field: unknown) => diff --git a/libs/network-stats/src/config/stats-fields.ts b/libs/network-stats/src/config/stats-fields.ts index c779c1c39..8a10a5430 100644 --- a/libs/network-stats/src/config/stats-fields.ts +++ b/libs/network-stats/src/config/stats-fields.ts @@ -1,4 +1,4 @@ -import { Stats as IStats, StatFields as IStatFields } from './types'; +import type { Stats as IStats, StatFields as IStatFields } from './types'; // Stats fields config. Keys will correspond to graphql queries when used, and values // contain the associated data and methods we need to render. A single query diff --git a/libs/order-list/src/order-list-manager.spec.tsx b/libs/order-list/src/order-list-manager.spec.tsx index 2be69170e..70bd19a7b 100644 --- a/libs/order-list/src/order-list-manager.spec.tsx +++ b/libs/order-list/src/order-list-manager.spec.tsx @@ -1,7 +1,7 @@ import { render, screen } from '@testing-library/react'; import { OrderListManager } from './order-list-manager'; import * as useOrdersHook from './use-orders'; -import { Orders_party_orders } from './__generated__/Orders'; +import type { Orders_party_orders } from './__generated__/Orders'; jest.mock('./order-list', () => ({ OrderList: () =>
OrderList
, diff --git a/libs/order-list/src/order-list-manager.tsx b/libs/order-list/src/order-list-manager.tsx index ceb262614..7a2b13915 100644 --- a/libs/order-list/src/order-list-manager.tsx +++ b/libs/order-list/src/order-list-manager.tsx @@ -1,7 +1,7 @@ import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; import { useOrders } from './use-orders'; import { OrderList } from './order-list'; -import { OrderFields } from './__generated__/OrderFields'; +import type { OrderFields } from './__generated__/OrderFields'; interface OrderListManagerProps { partyId: string; diff --git a/libs/order-list/src/order-list.spec.tsx b/libs/order-list/src/order-list.spec.tsx index 8dc9e57dc..40b3e23f6 100644 --- a/libs/order-list/src/order-list.spec.tsx +++ b/libs/order-list/src/order-list.spec.tsx @@ -1,6 +1,6 @@ import { act, render, screen } from '@testing-library/react'; import { formatNumber, getDateTimeFormat } from '@vegaprotocol/react-helpers'; -import { Orders_party_orders } from './__generated__/Orders'; +import type { Orders_party_orders } from './__generated__/Orders'; import { OrderStatus, OrderTimeInForce, diff --git a/libs/order-list/src/order-list.tsx b/libs/order-list/src/order-list.tsx index 6ea026ca9..b1b0ada31 100644 --- a/libs/order-list/src/order-list.tsx +++ b/libs/order-list/src/order-list.tsx @@ -1,12 +1,12 @@ import { OrderTimeInForce, OrderStatus, Side } from '@vegaprotocol/types'; -import { Orders_party_orders } from './__generated__/Orders'; +import type { Orders_party_orders } from './__generated__/Orders'; import { formatNumber, getDateTimeFormat, useApplyGridTransaction, } from '@vegaprotocol/react-helpers'; import { AgGridDynamic as AgGrid } from '@vegaprotocol/ui-toolkit'; -import { GridApi, ValueFormatterParams } from 'ag-grid-community'; +import type { GridApi, ValueFormatterParams } from 'ag-grid-community'; import { AgGridColumn } from 'ag-grid-react'; import { useRef, useState } from 'react'; diff --git a/libs/order-list/src/use-orders.spec.tsx b/libs/order-list/src/use-orders.spec.tsx index 50b9cccbe..1e7b9dfef 100644 --- a/libs/order-list/src/use-orders.spec.tsx +++ b/libs/order-list/src/use-orders.spec.tsx @@ -1,8 +1,9 @@ -import { MockedProvider, MockedResponse } from '@apollo/client/testing'; +import type { MockedResponse } from '@apollo/client/testing'; +import { MockedProvider } from '@apollo/client/testing'; import { renderHook } from '@testing-library/react-hooks'; -import { OrderFields } from './__generated__/OrderFields'; -import { Orders } from './__generated__/Orders'; -import { OrderSub } from './__generated__/OrderSub'; +import type { OrderFields } from './__generated__/OrderFields'; +import type { Orders } from './__generated__/Orders'; +import type { OrderSub } from './__generated__/OrderSub'; import { OrderStatus, Side, @@ -10,7 +11,7 @@ import { OrderTimeInForce, } from '@vegaprotocol/types'; import {} from '@vegaprotocol/wallet'; -import { ReactNode } from 'react'; +import type { ReactNode } from 'react'; import { ORDERS_QUERY, ORDERS_SUB, useOrders } from './use-orders'; const partyId = '0x123'; diff --git a/libs/order-list/src/use-orders.ts b/libs/order-list/src/use-orders.ts index 8954b02d4..d9c40f953 100644 --- a/libs/order-list/src/use-orders.ts +++ b/libs/order-list/src/use-orders.ts @@ -2,9 +2,9 @@ import { useCallback, useEffect, useState } from 'react'; import { gql, useApolloClient } from '@apollo/client'; import uniqBy from 'lodash/uniqBy'; import orderBy from 'lodash/orderBy'; -import { Orders, OrdersVariables } from './__generated__/Orders'; -import { OrderSub, OrderSubVariables } from './__generated__/OrderSub'; -import { OrderFields } from './__generated__/OrderFields'; +import type { Orders, OrdersVariables } from './__generated__/Orders'; +import type { OrderSub, OrderSubVariables } from './__generated__/OrderSub'; +import type { OrderFields } from './__generated__/OrderFields'; const ORDER_FRAGMENT = gql` fragment OrderFields on Order { diff --git a/libs/positions/src/lib/positions-data-provider.ts b/libs/positions/src/lib/positions-data-provider.ts index 74281dc4e..d1d26a602 100644 --- a/libs/positions/src/lib/positions-data-provider.ts +++ b/libs/positions/src/lib/positions-data-provider.ts @@ -1,11 +1,11 @@ import { gql } from '@apollo/client'; -import { +import type { Positions, Positions_party_positions, } from './__generated__/Positions'; import { makeDataProvider } from '@vegaprotocol/react-helpers'; -import { +import type { PositionSubscribe, PositionSubscribe_positions, } from './__generated__/PositionSubscribe'; diff --git a/libs/positions/src/lib/positions-manager.tsx b/libs/positions/src/lib/positions-manager.tsx index 28b790a1f..5f299d981 100644 --- a/libs/positions/src/lib/positions-manager.tsx +++ b/libs/positions/src/lib/positions-manager.tsx @@ -3,8 +3,8 @@ import { produce } from 'immer'; import merge from 'lodash/merge'; import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; import { useDataProvider } from '@vegaprotocol/react-helpers'; -import { PositionSubscribe_positions } from './__generated__/PositionSubscribe'; -import { Positions_party_positions } from './__generated__/Positions'; +import type { PositionSubscribe_positions } from './__generated__/PositionSubscribe'; +import type { Positions_party_positions } from './__generated__/Positions'; import type { AgGridReact } from 'ag-grid-react'; import PositionsTable, { getRowNodeId } from './positions-table'; diff --git a/libs/positions/src/lib/positions-table.spec.tsx b/libs/positions/src/lib/positions-table.spec.tsx index e6a4c426e..8efdf8f24 100644 --- a/libs/positions/src/lib/positions-table.spec.tsx +++ b/libs/positions/src/lib/positions-table.spec.tsx @@ -1,6 +1,6 @@ import { act, render, screen } from '@testing-library/react'; import PositionsTable from './positions-table'; -import { Positions_party_positions } from './__generated__/Positions'; +import type { Positions_party_positions } from './__generated__/Positions'; import { MarketTradingMode } from '@vegaprotocol/types'; const singleRow: Positions_party_positions = { diff --git a/libs/positions/src/lib/positions-table.tsx b/libs/positions/src/lib/positions-table.tsx index ebe695648..01e2cad8a 100644 --- a/libs/positions/src/lib/positions-table.tsx +++ b/libs/positions/src/lib/positions-table.tsx @@ -10,7 +10,7 @@ import { AgGridDynamic as AgGrid } from '@vegaprotocol/ui-toolkit'; import { AgGridColumn } from 'ag-grid-react'; import type { AgGridReact } from 'ag-grid-react'; import compact from 'lodash/compact'; -import { Positions_party_positions } from './__generated__/Positions'; +import type { Positions_party_positions } from './__generated__/Positions'; import { MarketTradingMode } from '@vegaprotocol/types'; interface PositionsTableProps { diff --git a/libs/react-helpers/src/hooks/use-apply-grid-transaction.ts b/libs/react-helpers/src/hooks/use-apply-grid-transaction.ts index 007f891a7..7a41813d2 100644 --- a/libs/react-helpers/src/hooks/use-apply-grid-transaction.ts +++ b/libs/react-helpers/src/hooks/use-apply-grid-transaction.ts @@ -1,4 +1,4 @@ -import { GridApi } from 'ag-grid-community'; +import type { GridApi } from 'ag-grid-community'; import { useEffect } from 'react'; import isEqual from 'lodash/isEqual'; diff --git a/libs/react-helpers/src/lib/grid-cells/flash-cell.stories.tsx b/libs/react-helpers/src/lib/grid-cells/flash-cell.stories.tsx index 6530aae60..c0fc5dedb 100644 --- a/libs/react-helpers/src/lib/grid-cells/flash-cell.stories.tsx +++ b/libs/react-helpers/src/lib/grid-cells/flash-cell.stories.tsx @@ -1,5 +1,5 @@ import { FlashCell } from './flash-cell'; -import { Meta, Story } from '@storybook/react'; +import type { Meta, Story } from '@storybook/react'; import * as React from 'react'; export default { diff --git a/libs/ui-toolkit/src/components/ag-grid/ag-grid-dark.tsx b/libs/ui-toolkit/src/components/ag-grid/ag-grid-dark.tsx index a0c0c9022..ebc0aeaf1 100644 --- a/libs/ui-toolkit/src/components/ag-grid/ag-grid-dark.tsx +++ b/libs/ui-toolkit/src/components/ag-grid/ag-grid-dark.tsx @@ -1,4 +1,4 @@ -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; import { theme } from '@vegaprotocol/tailwindcss-config'; import 'ag-grid-community/dist/styles/ag-theme-balham-dark.css'; diff --git a/libs/ui-toolkit/src/components/ag-grid/ag-grid-light.tsx b/libs/ui-toolkit/src/components/ag-grid/ag-grid-light.tsx index 90ed42eef..868d8fdb5 100644 --- a/libs/ui-toolkit/src/components/ag-grid/ag-grid-light.tsx +++ b/libs/ui-toolkit/src/components/ag-grid/ag-grid-light.tsx @@ -1,4 +1,4 @@ -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; import { theme } from '@vegaprotocol/tailwindcss-config'; import 'ag-grid-community/dist/styles/ag-theme-balham.css'; diff --git a/libs/ui-toolkit/src/components/async-renderer/async-renderer.tsx b/libs/ui-toolkit/src/components/async-renderer/async-renderer.tsx index 99dd1ec19..451b25354 100644 --- a/libs/ui-toolkit/src/components/async-renderer/async-renderer.tsx +++ b/libs/ui-toolkit/src/components/async-renderer/async-renderer.tsx @@ -1,5 +1,5 @@ import { Splash } from '../splash'; -import { ReactNode } from 'react'; +import type { ReactNode } from 'react'; interface AsyncRendererProps { loading: boolean; diff --git a/libs/ui-toolkit/src/components/button/button.stories.tsx b/libs/ui-toolkit/src/components/button/button.stories.tsx index f2161ca90..f2abf4dda 100644 --- a/libs/ui-toolkit/src/components/button/button.stories.tsx +++ b/libs/ui-toolkit/src/components/button/button.stories.tsx @@ -1,4 +1,4 @@ -import { Story, Meta } from '@storybook/react'; +import type { Story, Meta } from '@storybook/react'; import { Button } from './button'; export default { diff --git a/libs/ui-toolkit/src/components/button/button.tsx b/libs/ui-toolkit/src/components/button/button.tsx index 075f09aee..e071f20d2 100644 --- a/libs/ui-toolkit/src/components/button/button.tsx +++ b/libs/ui-toolkit/src/components/button/button.tsx @@ -1,6 +1,8 @@ -import { AnchorHTMLAttributes, ButtonHTMLAttributes, forwardRef } from 'react'; +import type { AnchorHTMLAttributes, ButtonHTMLAttributes } from 'react'; +import { forwardRef } from 'react'; import classNames from 'classnames'; -import { Icon, IconName } from '../icon'; +import type { IconName } from '../icon'; +import { Icon } from '../icon'; import { includesLeftPadding, includesRightPadding, diff --git a/libs/ui-toolkit/src/components/callout/callout.stories.tsx b/libs/ui-toolkit/src/components/callout/callout.stories.tsx index ad910f35e..94dacb3bb 100644 --- a/libs/ui-toolkit/src/components/callout/callout.stories.tsx +++ b/libs/ui-toolkit/src/components/callout/callout.stories.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { ComponentStory, ComponentMeta } from '@storybook/react'; +import type { ComponentStory, ComponentMeta } from '@storybook/react'; import { Callout } from './callout'; import { Button } from '../button'; diff --git a/libs/ui-toolkit/src/components/callout/callout.tsx b/libs/ui-toolkit/src/components/callout/callout.tsx index ef25176a0..999f0143b 100644 --- a/libs/ui-toolkit/src/components/callout/callout.tsx +++ b/libs/ui-toolkit/src/components/callout/callout.tsx @@ -1,6 +1,7 @@ import classNames from 'classnames'; import { getIntentShadow, Intent } from '../../utils/intent'; -import { Icon, IconName } from '../icon'; +import type { IconName } from '../icon'; +import { Icon } from '../icon'; export interface CalloutProps { children?: React.ReactNode; diff --git a/libs/ui-toolkit/src/components/dialog/dialog.stories.tsx b/libs/ui-toolkit/src/components/dialog/dialog.stories.tsx index 97ec9cc31..4d3752813 100644 --- a/libs/ui-toolkit/src/components/dialog/dialog.stories.tsx +++ b/libs/ui-toolkit/src/components/dialog/dialog.stories.tsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import { ComponentStory, ComponentMeta } from '@storybook/react'; +import type { ComponentStory, ComponentMeta } from '@storybook/react'; import { Dialog } from './dialog'; import { Button } from '../button'; diff --git a/libs/ui-toolkit/src/components/dialog/dialog.tsx b/libs/ui-toolkit/src/components/dialog/dialog.tsx index 79727c523..a6c81d936 100644 --- a/libs/ui-toolkit/src/components/dialog/dialog.tsx +++ b/libs/ui-toolkit/src/components/dialog/dialog.tsx @@ -1,7 +1,8 @@ import * as DialogPrimitives from '@radix-ui/react-dialog'; import classNames from 'classnames'; -import { ReactNode } from 'react'; -import { getIntentShadow, Intent } from '../../utils/intent'; +import type { ReactNode } from 'react'; +import type { Intent } from '../../utils/intent'; +import { getIntentShadow } from '../../utils/intent'; import { Icon } from '../icon'; interface DialogProps { diff --git a/libs/ui-toolkit/src/components/etherscan-link/etherscan-link.stories.tsx b/libs/ui-toolkit/src/components/etherscan-link/etherscan-link.stories.tsx index 0ab295604..6579117f6 100644 --- a/libs/ui-toolkit/src/components/etherscan-link/etherscan-link.stories.tsx +++ b/libs/ui-toolkit/src/components/etherscan-link/etherscan-link.stories.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { ComponentStory, ComponentMeta } from '@storybook/react'; +import type { ComponentStory, ComponentMeta } from '@storybook/react'; import { EtherscanLink } from '.'; import { EthereumChainIds, EthereumChainNames } from '../../utils/web3'; diff --git a/libs/ui-toolkit/src/components/etherscan-link/etherscan-link.tsx b/libs/ui-toolkit/src/components/etherscan-link/etherscan-link.tsx index da08a8a8e..bd81014de 100644 --- a/libs/ui-toolkit/src/components/etherscan-link/etherscan-link.tsx +++ b/libs/ui-toolkit/src/components/etherscan-link/etherscan-link.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { EthereumChainId } from '../../utils/web3'; +import type { EthereumChainId } from '../../utils/web3'; const etherscanUrls: Record = { '0x1': 'https://etherscan.io', diff --git a/libs/ui-toolkit/src/components/form-group/form-group.tsx b/libs/ui-toolkit/src/components/form-group/form-group.tsx index bd5724943..1adb35330 100644 --- a/libs/ui-toolkit/src/components/form-group/form-group.tsx +++ b/libs/ui-toolkit/src/components/form-group/form-group.tsx @@ -1,5 +1,5 @@ import classNames from 'classnames'; -import { ReactNode } from 'react'; +import type { ReactNode } from 'react'; interface FormGroupProps { children: ReactNode; diff --git a/libs/ui-toolkit/src/components/form-group/from-group.stories.tsx b/libs/ui-toolkit/src/components/form-group/from-group.stories.tsx index da5b18ad5..6348f9372 100644 --- a/libs/ui-toolkit/src/components/form-group/from-group.stories.tsx +++ b/libs/ui-toolkit/src/components/form-group/from-group.stories.tsx @@ -1,4 +1,4 @@ -import { Story, Meta } from '@storybook/react'; +import type { Story, Meta } from '@storybook/react'; import { Input } from '../input'; import { FormGroup } from './form-group'; export default { diff --git a/libs/ui-toolkit/src/components/icon/icon.stories.tsx b/libs/ui-toolkit/src/components/icon/icon.stories.tsx index 5fe951f90..8ab3ec65e 100644 --- a/libs/ui-toolkit/src/components/icon/icon.stories.tsx +++ b/libs/ui-toolkit/src/components/icon/icon.stories.tsx @@ -1,4 +1,4 @@ -import { Story, Meta } from '@storybook/react'; +import type { Story, Meta } from '@storybook/react'; import { Icon } from './icon'; export default { diff --git a/libs/ui-toolkit/src/components/icon/icon.tsx b/libs/ui-toolkit/src/components/icon/icon.tsx index 8ea0b4251..595e8f2c2 100644 --- a/libs/ui-toolkit/src/components/icon/icon.tsx +++ b/libs/ui-toolkit/src/components/icon/icon.tsx @@ -1,4 +1,5 @@ -import { IconSvgPaths20, IconSvgPaths16, IconName } from '@blueprintjs/icons'; +import type { IconName } from '@blueprintjs/icons'; +import { IconSvgPaths20, IconSvgPaths16 } from '@blueprintjs/icons'; import classNames from 'classnames'; export type { IconName } from '@blueprintjs/icons'; diff --git a/libs/ui-toolkit/src/components/input-error/input-error.stories.tsx b/libs/ui-toolkit/src/components/input-error/input-error.stories.tsx index b227a0c6c..2f46aa9b0 100644 --- a/libs/ui-toolkit/src/components/input-error/input-error.stories.tsx +++ b/libs/ui-toolkit/src/components/input-error/input-error.stories.tsx @@ -1,4 +1,4 @@ -import { Story, Meta } from '@storybook/react'; +import type { Story, Meta } from '@storybook/react'; import { InputError } from './input-error'; export default { diff --git a/libs/ui-toolkit/src/components/input-error/input-error.tsx b/libs/ui-toolkit/src/components/input-error/input-error.tsx index 69e835b09..6f7837ae8 100644 --- a/libs/ui-toolkit/src/components/input-error/input-error.tsx +++ b/libs/ui-toolkit/src/components/input-error/input-error.tsx @@ -1,5 +1,5 @@ import classNames from 'classnames'; -import { HTMLAttributes } from 'react'; +import type { HTMLAttributes } from 'react'; import { Icon } from '../icon'; interface InputErrorProps extends HTMLAttributes { diff --git a/libs/ui-toolkit/src/components/input/input.stories.tsx b/libs/ui-toolkit/src/components/input/input.stories.tsx index 97ff3587d..85fd255e8 100644 --- a/libs/ui-toolkit/src/components/input/input.stories.tsx +++ b/libs/ui-toolkit/src/components/input/input.stories.tsx @@ -1,4 +1,4 @@ -import { Story, Meta } from '@storybook/react'; +import type { Story, Meta } from '@storybook/react'; import { Input } from './input'; export default { component: Input, diff --git a/libs/ui-toolkit/src/components/input/input.tsx b/libs/ui-toolkit/src/components/input/input.tsx index e58411858..905a12b43 100644 --- a/libs/ui-toolkit/src/components/input/input.tsx +++ b/libs/ui-toolkit/src/components/input/input.tsx @@ -1,6 +1,8 @@ -import { InputHTMLAttributes, forwardRef } from 'react'; +import type { InputHTMLAttributes } from 'react'; +import { forwardRef } from 'react'; import classNames from 'classnames'; -import { Icon, IconName } from '../icon'; +import type { IconName } from '../icon'; +import { Icon } from '../icon'; import { includesLeftPadding, includesRightPadding, diff --git a/libs/ui-toolkit/src/components/lozenge/lozenge.stories.tsx b/libs/ui-toolkit/src/components/lozenge/lozenge.stories.tsx index 6ceefccf6..cb065db53 100644 --- a/libs/ui-toolkit/src/components/lozenge/lozenge.stories.tsx +++ b/libs/ui-toolkit/src/components/lozenge/lozenge.stories.tsx @@ -1,4 +1,4 @@ -import { Story, Meta } from '@storybook/react'; +import type { Story, Meta } from '@storybook/react'; import { Lozenge } from './lozenge'; export default { diff --git a/libs/ui-toolkit/src/components/lozenge/lozenge.tsx b/libs/ui-toolkit/src/components/lozenge/lozenge.tsx index 19c44454e..54c3d25fa 100644 --- a/libs/ui-toolkit/src/components/lozenge/lozenge.tsx +++ b/libs/ui-toolkit/src/components/lozenge/lozenge.tsx @@ -1,4 +1,4 @@ -import { ReactNode } from 'react'; +import type { ReactNode } from 'react'; import classNames from 'classnames'; interface LozengeProps { diff --git a/libs/ui-toolkit/src/components/select/select.stories.tsx b/libs/ui-toolkit/src/components/select/select.stories.tsx index f223cb9d3..713ab4043 100644 --- a/libs/ui-toolkit/src/components/select/select.stories.tsx +++ b/libs/ui-toolkit/src/components/select/select.stories.tsx @@ -1,4 +1,4 @@ -import { Story, Meta } from '@storybook/react'; +import type { Story, Meta } from '@storybook/react'; import { Select } from './select'; export default { diff --git a/libs/ui-toolkit/src/components/select/select.tsx b/libs/ui-toolkit/src/components/select/select.tsx index 189b2e9c7..3f7b74b79 100644 --- a/libs/ui-toolkit/src/components/select/select.tsx +++ b/libs/ui-toolkit/src/components/select/select.tsx @@ -1,4 +1,5 @@ -import { SelectHTMLAttributes, forwardRef } from 'react'; +import type { SelectHTMLAttributes } from 'react'; +import { forwardRef } from 'react'; import classNames from 'classnames'; import { inputClassNames } from '../input/input'; diff --git a/libs/ui-toolkit/src/components/splash/splash.stories.tsx b/libs/ui-toolkit/src/components/splash/splash.stories.tsx index a1e9ec77c..6a956389c 100644 --- a/libs/ui-toolkit/src/components/splash/splash.stories.tsx +++ b/libs/ui-toolkit/src/components/splash/splash.stories.tsx @@ -1,5 +1,6 @@ -import { Story, ComponentMeta } from '@storybook/react'; -import { Splash, SplashProps } from './splash'; +import type { Story, ComponentMeta } from '@storybook/react'; +import type { SplashProps } from './splash'; +import { Splash } from './splash'; export default { component: Splash, diff --git a/libs/ui-toolkit/src/components/splash/splash.tsx b/libs/ui-toolkit/src/components/splash/splash.tsx index 671405d70..f86751d43 100644 --- a/libs/ui-toolkit/src/components/splash/splash.tsx +++ b/libs/ui-toolkit/src/components/splash/splash.tsx @@ -1,5 +1,5 @@ import classNames from 'classnames'; -import { ReactNode } from 'react'; +import type { ReactNode } from 'react'; export interface SplashProps { children: ReactNode; diff --git a/libs/ui-toolkit/src/components/text-area/text-area.stories.tsx b/libs/ui-toolkit/src/components/text-area/text-area.stories.tsx index 4793f108a..b54922ddf 100644 --- a/libs/ui-toolkit/src/components/text-area/text-area.stories.tsx +++ b/libs/ui-toolkit/src/components/text-area/text-area.stories.tsx @@ -1,4 +1,4 @@ -import { Story, Meta } from '@storybook/react'; +import type { Story, Meta } from '@storybook/react'; import { TextArea } from './text-area'; export default { diff --git a/libs/ui-toolkit/src/components/text-area/text-area.tsx b/libs/ui-toolkit/src/components/text-area/text-area.tsx index 5653941ee..df4484df7 100644 --- a/libs/ui-toolkit/src/components/text-area/text-area.tsx +++ b/libs/ui-toolkit/src/components/text-area/text-area.tsx @@ -1,4 +1,5 @@ -import { TextareaHTMLAttributes, forwardRef } from 'react'; +import type { TextareaHTMLAttributes } from 'react'; +import { forwardRef } from 'react'; import { inputClassNames } from '../input/input'; export interface TextAreaProps diff --git a/libs/ui-toolkit/src/components/theme-switcher/theme-switcher.stories.tsx b/libs/ui-toolkit/src/components/theme-switcher/theme-switcher.stories.tsx index a3af971e5..09341844b 100644 --- a/libs/ui-toolkit/src/components/theme-switcher/theme-switcher.stories.tsx +++ b/libs/ui-toolkit/src/components/theme-switcher/theme-switcher.stories.tsx @@ -1,4 +1,4 @@ -import { Story, Meta } from '@storybook/react'; +import type { Story, Meta } from '@storybook/react'; import { ThemeSwitcher } from './theme-switcher'; export default { diff --git a/libs/ui-toolkit/src/components/vega-logo/lozenge.stories.tsx b/libs/ui-toolkit/src/components/vega-logo/lozenge.stories.tsx index 4e03ab8ca..3e9490025 100644 --- a/libs/ui-toolkit/src/components/vega-logo/lozenge.stories.tsx +++ b/libs/ui-toolkit/src/components/vega-logo/lozenge.stories.tsx @@ -1,4 +1,4 @@ -import { Story, Meta } from '@storybook/react'; +import type { Story, Meta } from '@storybook/react'; import { VegaLogo } from './vega-logo'; export default { diff --git a/libs/ui-toolkit/src/utils/contrast.stories.tsx b/libs/ui-toolkit/src/utils/contrast.stories.tsx index 4be7d682f..d8112c549 100644 --- a/libs/ui-toolkit/src/utils/contrast.stories.tsx +++ b/libs/ui-toolkit/src/utils/contrast.stories.tsx @@ -1,4 +1,4 @@ -import { Story, Meta } from '@storybook/react'; +import type { Story, Meta } from '@storybook/react'; interface ContrastCheckerProps { backgrounds: string[]; diff --git a/libs/wallet/src/connect-dialog.test.tsx b/libs/wallet/src/connect-dialog.test.tsx index 668726f17..7c5d977ce 100644 --- a/libs/wallet/src/connect-dialog.test.tsx +++ b/libs/wallet/src/connect-dialog.test.tsx @@ -6,9 +6,10 @@ import { screen, waitFor, } from '@testing-library/react'; -import { VegaWalletContext, VegaWalletContextShape } from './context'; +import type { VegaWalletContextShape } from './context'; +import { VegaWalletContext } from './context'; import { VegaConnectDialog } from './connect-dialog'; -import { VegaConnectDialogProps } from '.'; +import type { VegaConnectDialogProps } from '.'; import { RestConnector } from './connectors'; let defaultProps: VegaConnectDialogProps; diff --git a/libs/wallet/src/connect-dialog.tsx b/libs/wallet/src/connect-dialog.tsx index f75a39057..57ad8fc63 100644 --- a/libs/wallet/src/connect-dialog.tsx +++ b/libs/wallet/src/connect-dialog.tsx @@ -1,6 +1,6 @@ import { useCallback, useState } from 'react'; import { Dialog } from '@vegaprotocol/ui-toolkit'; -import { VegaConnector } from './connectors'; +import type { VegaConnector } from './connectors'; import { RestConnectorForm } from './rest-connector-form'; import { useEffect } from 'react'; import { RestConnector } from './connectors/rest-connector'; diff --git a/libs/wallet/src/connectors/index.ts b/libs/wallet/src/connectors/index.ts index aa738f25a..4d075d52d 100644 --- a/libs/wallet/src/connectors/index.ts +++ b/libs/wallet/src/connectors/index.ts @@ -1,4 +1,4 @@ -import { +import type { VegaKey, TransactionResponse, OrderSubmissionBody, diff --git a/libs/wallet/src/connectors/injected-connector.ts b/libs/wallet/src/connectors/injected-connector.ts index 75601b9d5..48fc4ab48 100644 --- a/libs/wallet/src/connectors/injected-connector.ts +++ b/libs/wallet/src/connectors/injected-connector.ts @@ -1,4 +1,4 @@ -import { VegaConnector } from '.'; +import type { VegaConnector } from '.'; /** * Dummy injected connector that we may use when browser wallet is implemented diff --git a/libs/wallet/src/connectors/rest-connector.ts b/libs/wallet/src/connectors/rest-connector.ts index 686d28535..42fb0c465 100644 --- a/libs/wallet/src/connectors/rest-connector.ts +++ b/libs/wallet/src/connectors/rest-connector.ts @@ -1,12 +1,14 @@ -import { - DefaultApi, - createConfiguration, +import type { Configuration, OrderSubmissionBody, } from '@vegaprotocol/vegawallet-service-api-client'; +import { + DefaultApi, + createConfiguration, +} from '@vegaprotocol/vegawallet-service-api-client'; import { LocalStorage } from '@vegaprotocol/react-helpers'; import { WALLET_CONFIG } from '../storage-keys'; -import { VegaConnector } from '.'; +import type { VegaConnector } from '.'; // Perhaps there should be a default ConnectorConfig that others can extend off. Do all connectors // need to use local storage, I don't think so... diff --git a/libs/wallet/src/context.ts b/libs/wallet/src/context.ts index 3f66df95f..8859b1e32 100644 --- a/libs/wallet/src/context.ts +++ b/libs/wallet/src/context.ts @@ -1,10 +1,10 @@ -import { +import type { VegaKey, TransactionResponse, } from '@vegaprotocol/vegawallet-service-api-client'; import { createContext } from 'react'; -import { VegaConnector } from './connectors'; -import { Transaction } from './types'; +import type { VegaConnector } from './connectors'; +import type { Transaction } from './types'; export type SendTxError = | { diff --git a/libs/wallet/src/provider.test.tsx b/libs/wallet/src/provider.test.tsx index 227ead99b..bb8de8806 100644 --- a/libs/wallet/src/provider.test.tsx +++ b/libs/wallet/src/provider.test.tsx @@ -1,6 +1,6 @@ import '@testing-library/jest-dom'; import { act, fireEvent, render, screen } from '@testing-library/react'; -import { VegaKey } from '@vegaprotocol/vegawallet-service-api-client'; +import type { VegaKey } from '@vegaprotocol/vegawallet-service-api-client'; import { RestConnector } from './connectors'; import { useVegaWallet } from './hooks'; import { VegaWalletProvider } from './provider'; diff --git a/libs/wallet/src/provider.tsx b/libs/wallet/src/provider.tsx index 9b8305e62..0fe2b2840 100644 --- a/libs/wallet/src/provider.tsx +++ b/libs/wallet/src/provider.tsx @@ -1,17 +1,11 @@ import { LocalStorage } from '@vegaprotocol/react-helpers'; -import { - ReactNode, - useCallback, - useEffect, - useMemo, - useRef, - useState, -} from 'react'; -import { VegaKeyExtended, VegaWalletContextShape } from '.'; -import { VegaConnector } from './connectors'; +import type { ReactNode } from 'react'; +import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; +import type { VegaKeyExtended, VegaWalletContextShape } from '.'; +import type { VegaConnector } from './connectors'; import { VegaWalletContext } from './context'; import { WALLET_KEY } from './storage-keys'; -import { OrderSubmissionBody } from '@vegaprotocol/vegawallet-service-api-client'; +import type { OrderSubmissionBody } from '@vegaprotocol/vegawallet-service-api-client'; interface VegaWalletProviderProps { children: ReactNode; diff --git a/libs/wallet/src/rest-connector-form.tsx b/libs/wallet/src/rest-connector-form.tsx index f459e89e7..e0d220860 100644 --- a/libs/wallet/src/rest-connector-form.tsx +++ b/libs/wallet/src/rest-connector-form.tsx @@ -1,7 +1,7 @@ import { Button, FormGroup, Input, InputError } from '@vegaprotocol/ui-toolkit'; import { useState } from 'react'; import { useForm } from 'react-hook-form'; -import { RestConnector } from '.'; +import type { RestConnector } from '.'; interface FormFields { wallet: string; diff --git a/libs/wallet/src/use-vega-transaction.spec.tsx b/libs/wallet/src/use-vega-transaction.spec.tsx index e563cd42c..8d798f991 100644 --- a/libs/wallet/src/use-vega-transaction.spec.tsx +++ b/libs/wallet/src/use-vega-transaction.spec.tsx @@ -1,8 +1,9 @@ import { act, renderHook } from '@testing-library/react-hooks'; -import { VegaWalletContext, VegaWalletContextShape } from './context'; -import { ReactNode } from 'react'; +import type { VegaWalletContextShape } from './context'; +import { VegaWalletContext } from './context'; +import type { ReactNode } from 'react'; import { useVegaTransaction, VegaTxStatus } from './use-vega-transaction'; -import { OrderSubmission } from './types'; +import type { OrderSubmission } from './types'; const defaultWalletContext = { keypair: null, diff --git a/libs/wallet/src/use-vega-transaction.ts b/libs/wallet/src/use-vega-transaction.ts index b30b188ac..131b50b17 100644 --- a/libs/wallet/src/use-vega-transaction.ts +++ b/libs/wallet/src/use-vega-transaction.ts @@ -1,7 +1,7 @@ import { useCallback, useState } from 'react'; -import { Transaction } from './types'; +import type { Transaction } from './types'; import { useVegaWallet } from './hooks'; -import { SendTxError } from './context'; +import type { SendTxError } from './context'; export enum VegaTxStatus { Default = 'Default', diff --git a/libs/web3/src/lib/types.ts b/libs/web3/src/lib/types.ts index f0a54f765..5dd624e6c 100644 --- a/libs/web3/src/lib/types.ts +++ b/libs/web3/src/lib/types.ts @@ -1,6 +1,6 @@ -import { Web3ReactHooks } from '@web3-react/core'; -import { MetaMask } from '@web3-react/metamask'; -import { WalletConnect } from '@web3-react/walletconnect'; +import type { Web3ReactHooks } from '@web3-react/core'; +import type { MetaMask } from '@web3-react/metamask'; +import type { WalletConnect } from '@web3-react/walletconnect'; export type Connectors = { [name: string]: [Connector, Web3ReactHooks, object]; diff --git a/libs/web3/src/lib/web3-connect-dialog.tsx b/libs/web3/src/lib/web3-connect-dialog.tsx index de11df2d1..878d5c370 100644 --- a/libs/web3/src/lib/web3-connect-dialog.tsx +++ b/libs/web3/src/lib/web3-connect-dialog.tsx @@ -1,5 +1,5 @@ import { Dialog, Intent } from '@vegaprotocol/ui-toolkit'; -import { Connectors } from './types'; +import type { Connectors } from './types'; interface Web3ConnectDialogProps { dialogOpen: boolean; diff --git a/libs/web3/src/lib/web3-provider.tsx b/libs/web3/src/lib/web3-provider.tsx index e7c429f93..c4314fbd7 100644 --- a/libs/web3/src/lib/web3-provider.tsx +++ b/libs/web3/src/lib/web3-provider.tsx @@ -1,5 +1,5 @@ import { Web3ReactProvider } from '@web3-react/core'; -import { Connectors } from './types'; +import type { Connectors } from './types'; interface Web3ProviderProps { children: JSX.Element | JSX.Element[]; From 83104cf1d6645d6f0664a40e4a00bf31ede4437b Mon Sep 17 00:00:00 2001 From: Dexter Edwards Date: Thu, 31 Mar 2022 01:55:36 +0100 Subject: [PATCH 09/10] Task/Remove env.local from block explorer(#169) --- apps/explorer/.env.local | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 apps/explorer/.env.local diff --git a/apps/explorer/.env.local b/apps/explorer/.env.local deleted file mode 100644 index 95e4b1e16..000000000 --- a/apps/explorer/.env.local +++ /dev/null @@ -1,16 +0,0 @@ -# App configuration variables -NX_CHAIN_EXPLORER_URL = "https://explorer.vega.trading/.netlify/functions/chain-explorer-api" -NX_TENDERMINT_URL = "https://lb.testnet.vega.xyz/tm" -NX_TENDERMINT_WEBSOCKET_URL = "wss://lb.testnet.vega.xyz/tm/websocket" -NX_VEGA_URL = "https://lb.testnet.vega.xyz/query" -NX_VEGA_ENV = 'Testnet' -NX_VEGA_REST = 'https://lb.testnet.vega.xyz/datanode/rest' - -# App flags -NX_EXPLORER_ASSETS = 1 -NX_EXPLORER_GENESIS = 1 -NX_EXPLORER_GOVERNANCE = 1 -NX_EXPLORER_MARKETS = 1 -NX_EXPLORER_NETWORK_PARAMETERS = 1 -NX_EXPLORER_PARTIES = 1 -NX_EXPLORER_VALIDATORS = 1 From 4899d1bce8e89ce08c2b0c5cd842772703689f27 Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Wed, 30 Mar 2022 18:08:25 -0700 Subject: [PATCH 10/10] Task/Mark translations (#174) * add dummy i18n translate function to market text that will need translation in future * add i18n function to aria-labels --- .../src/app/components/blocks/block-data.tsx | 13 +-- .../src/app/components/blocks/blocks-data.tsx | 7 +- .../app/components/blocks/blocks-refetch.tsx | 3 +- .../src/app/components/header/header.tsx | 3 +- .../app/components/jump-to-block/index.tsx | 5 +- .../src/app/components/jump-to/index.tsx | 3 +- .../app/components/render-fetched/index.tsx | 9 +- .../router-error-boundary/index.tsx | 3 +- .../src/app/components/search/search.tsx | 13 +-- .../src/app/components/seconds-ago/index.tsx | 10 ++- .../src/app/components/txs/block-txs-data.tsx | 7 +- .../src/app/components/txs/tx-list.tsx | 3 +- .../src/app/components/txs/txs-per-block.tsx | 9 +- apps/explorer/src/app/routes/assets/index.tsx | 3 +- .../src/app/routes/blocks/home/index.tsx | 3 +- .../src/app/routes/blocks/id/block.tsx | 5 +- .../explorer/src/app/routes/genesis/index.tsx | 3 +- .../src/app/routes/governance/index.tsx | 13 +-- .../explorer/src/app/routes/markets/index.tsx | 3 +- .../app/routes/network-parameters/index.tsx | 3 +- .../src/app/routes/parties/home/index.tsx | 7 +- .../src/app/routes/parties/id/index.tsx | 7 +- .../explorer/src/app/routes/pending/index.tsx | 5 +- .../explorer/src/app/routes/router-config.tsx | 21 ++--- .../src/app/routes/txs/home/index.tsx | 3 +- apps/explorer/src/app/routes/txs/id/index.tsx | 5 +- .../src/app/routes/txs/id/tx-content.tsx | 9 +- .../src/app/routes/txs/id/tx-details.tsx | 11 +-- .../src/app/routes/validators/index.tsx | 7 +- apps/trading/components/navbar/navbar.tsx | 5 +- .../vega-wallet-connect-button/index.tsx | 3 +- .../web3-container/web3-container.tsx | 19 +++-- apps/trading/pages/_app.page.tsx | 4 +- apps/trading/pages/index.page.tsx | 18 +--- .../trading/pages/markets/[marketId].page.tsx | 5 +- apps/trading/pages/markets/grid-tabs.tsx | 9 +- apps/trading/pages/markets/trade-grid.tsx | 27 +++--- apps/trading/pages/portfolio/index.page.tsx | 11 +-- .../deal-ticket/src/deal-ticket-container.tsx | 3 +- libs/deal-ticket/src/order-dialog.tsx | 25 +++--- libs/deal-ticket/src/submit-button.tsx | 19 +++-- .../market-list/src/lib/market-list-table.tsx | 18 ++-- libs/network-stats/src/config/stats-fields.ts | 82 ++++++++++--------- libs/order-list/src/order-list-container.tsx | 3 +- libs/order-list/src/order-list.spec.tsx | 2 +- libs/order-list/src/order-list.tsx | 6 +- .../positions/src/lib/positions-container.tsx | 3 +- libs/positions/src/lib/positions-table.tsx | 11 +-- libs/react-helpers/src/index.ts | 1 + libs/react-helpers/src/lib/i18n.ts | 1 + .../src/components/vega-logo/vega-logo.tsx | 4 +- libs/wallet/src/connect-dialog.tsx | 3 +- libs/wallet/src/provider.tsx | 4 +- libs/wallet/src/rest-connector-form.tsx | 17 ++-- libs/web3/src/lib/web3-connect-dialog.tsx | 3 +- 55 files changed, 281 insertions(+), 221 deletions(-) create mode 100644 libs/react-helpers/src/lib/i18n.ts diff --git a/apps/explorer/src/app/components/blocks/block-data.tsx b/apps/explorer/src/app/components/blocks/block-data.tsx index 2fedb94ca..0c91931c5 100644 --- a/apps/explorer/src/app/components/blocks/block-data.tsx +++ b/apps/explorer/src/app/components/blocks/block-data.tsx @@ -4,6 +4,7 @@ import { Routes } from '../../routes/router-config'; import { Link } from 'react-router-dom'; import { SecondsAgo } from '../seconds-ago'; import { Table, TableRow, TableCell } from '../table'; +import { t } from '@vegaprotocol/react-helpers'; interface BlockProps { block: BlockMeta; @@ -20,7 +21,7 @@ export const BlockData = ({ block, className }: BlockProps) => { { {block.num_txs === '1' - ? '1 transaction' - : `${block.num_txs} transactions`} + ? t('1 transaction') + : t(`${block.num_txs} transactions`)} {block.header.proposer_address} @@ -50,7 +51,7 @@ export const BlockData = ({ block, className }: BlockProps) => { diff --git a/apps/explorer/src/app/components/blocks/blocks-data.tsx b/apps/explorer/src/app/components/blocks/blocks-data.tsx index 512da0dbe..708f16f75 100644 --- a/apps/explorer/src/app/components/blocks/blocks-data.tsx +++ b/apps/explorer/src/app/components/blocks/blocks-data.tsx @@ -1,3 +1,4 @@ +import { t } from '@vegaprotocol/react-helpers'; import React from 'react'; import type { TendermintBlockchainResponse } from '../../routes/blocks/tendermint-blockchain-response'; import { BlockData } from './block-data'; @@ -9,12 +10,14 @@ interface BlocksProps { export const BlocksData = ({ data, className }: BlocksProps) => { if (!data?.result) { - return
Awaiting block data
; + return
{t('Awaiting block data')}
; } return (
    {data.result?.block_metas?.map((block, index) => { diff --git a/apps/explorer/src/app/components/blocks/blocks-refetch.tsx b/apps/explorer/src/app/components/blocks/blocks-refetch.tsx index fe5ce7b7d..18e6f5177 100644 --- a/apps/explorer/src/app/components/blocks/blocks-refetch.tsx +++ b/apps/explorer/src/app/components/blocks/blocks-refetch.tsx @@ -1,3 +1,4 @@ +import { t } from '@vegaprotocol/react-helpers'; import { Button } from '@vegaprotocol/ui-toolkit'; interface BlocksRefetchProps { @@ -12,7 +13,7 @@ export const BlocksRefetch = ({ refetch }: BlocksRefetchProps) => { className="mb-28" data-testid="refresh" > - Refresh to see latest blocks + {t('Refresh to see latest blocks')} ); }; diff --git a/apps/explorer/src/app/components/header/header.tsx b/apps/explorer/src/app/components/header/header.tsx index ee7f2b050..c1cd30351 100644 --- a/apps/explorer/src/app/components/header/header.tsx +++ b/apps/explorer/src/app/components/header/header.tsx @@ -1,10 +1,11 @@ +import { t } from '@vegaprotocol/react-helpers'; import { Search } from '../search'; export const Header = () => { return (

    - Vega Explorer + {t('Vega Explorer')}

    diff --git a/apps/explorer/src/app/components/jump-to-block/index.tsx b/apps/explorer/src/app/components/jump-to-block/index.tsx index 9d2f434b0..11230ff14 100644 --- a/apps/explorer/src/app/components/jump-to-block/index.tsx +++ b/apps/explorer/src/app/components/jump-to-block/index.tsx @@ -1,3 +1,4 @@ +import { t } from '@vegaprotocol/react-helpers'; import React from 'react'; import { useNavigate } from 'react-router-dom'; import { Routes } from '../../routes/router-config'; @@ -22,8 +23,8 @@ export const JumpToBlock = () => { return ( diff --git a/apps/explorer/src/app/components/render-fetched/index.tsx b/apps/explorer/src/app/components/render-fetched/index.tsx index 233bc0996..cfd8a0317 100644 --- a/apps/explorer/src/app/components/render-fetched/index.tsx +++ b/apps/explorer/src/app/components/render-fetched/index.tsx @@ -1,3 +1,4 @@ +import { t } from '@vegaprotocol/react-helpers'; import React from 'react'; import { StatusMessage } from '../status-message'; @@ -15,12 +16,16 @@ export const RenderFetched = ({ className, }: RenderFetchedProps) => { if (loading) { - return Loading...; + return ( + {t('Loading...')} + ); } if (error) { return ( - Error retrieving data + + {t('Error retrieving data')} + ); } diff --git a/apps/explorer/src/app/components/router-error-boundary/index.tsx b/apps/explorer/src/app/components/router-error-boundary/index.tsx index 9453c8178..0d4445114 100644 --- a/apps/explorer/src/app/components/router-error-boundary/index.tsx +++ b/apps/explorer/src/app/components/router-error-boundary/index.tsx @@ -1,3 +1,4 @@ +import { t } from '@vegaprotocol/react-helpers'; import React from 'react'; interface RouteErrorBoundaryProps { @@ -23,7 +24,7 @@ export class RouteErrorBoundary extends React.Component< override render() { if (this.state.hasError) { - return

    Something went wrong

    ; + return

    {t('Something went wrong')}

    ; } return this.props.children; diff --git a/apps/explorer/src/app/components/search/search.tsx b/apps/explorer/src/app/components/search/search.tsx index adf4d9db7..f1cd3d2b7 100644 --- a/apps/explorer/src/app/components/search/search.tsx +++ b/apps/explorer/src/app/components/search/search.tsx @@ -1,3 +1,4 @@ +import { t } from '@vegaprotocol/react-helpers'; import { FormGroup, Input, InputError, Button } from '@vegaprotocol/ui-toolkit'; import React from 'react'; import { useForm } from 'react-hook-form'; @@ -28,23 +29,23 @@ export const Search = () => { const search = fields.search; if (!search) { - setError(new Error('Search required')); + setError(new Error(t('Search required'))); } else if (isPrependedTransaction(search)) { if (Number.isNaN(Number(search))) { - setError(new Error('Transaction is not hexadecimal')); + setError(new Error(t('Transaction is not hexadecimal'))); } else { navigate(`${Routes.TX}/${search}`); } } else if (isTransaction(search)) { if (Number.isNaN(Number(`0x${search}`))) { - setError(new Error('Transaction is not hexadecimal')); + setError(new Error(t('Transaction is not hexadecimal'))); } else { navigate(`${Routes.TX}/0x${search}`); } } else if (isBlock(search)) { navigate(`${Routes.BLOCKS}/${Number(search)}`); } else { - setError(new Error("Something doesn't look right")); + setError(new Error(t("Something doesn't look right"))); } }, [navigate] @@ -62,7 +63,7 @@ export const Search = () => { hasError={Boolean(error?.message)} type="text" autoFocus={true} - placeholder="Enter block number or transaction hash" + placeholder={t('Enter block number or transaction hash')} /> {error?.message ? ( { )} ); diff --git a/apps/explorer/src/app/components/seconds-ago/index.tsx b/apps/explorer/src/app/components/seconds-ago/index.tsx index 965fd6024..4a1d4e732 100644 --- a/apps/explorer/src/app/components/seconds-ago/index.tsx +++ b/apps/explorer/src/app/components/seconds-ago/index.tsx @@ -1,3 +1,4 @@ +import { t } from '@vegaprotocol/react-helpers'; import { useEffect, useState } from 'react'; interface SecondsAgoProps { @@ -15,15 +16,18 @@ export const SecondsAgo = ({ date, ...props }: SecondsAgoProps) => { }, [setNow]); if (!date) { - return <>Date unknown; + return <>{t('Date unknown')}; } - const timeAgoInSeconds = Math.floor((now - new Date(date).getTime()) / 1000); return (
    - {timeAgoInSeconds === 1 ? '1 second' : `${timeAgoInSeconds} seconds`} ago + {t( + `${ + timeAgoInSeconds === 1 ? '1 second' : `${timeAgoInSeconds} seconds` + } ago` + )}
    ); }; diff --git a/apps/explorer/src/app/components/txs/block-txs-data.tsx b/apps/explorer/src/app/components/txs/block-txs-data.tsx index 7ef9c1410..ebba9c589 100644 --- a/apps/explorer/src/app/components/txs/block-txs-data.tsx +++ b/apps/explorer/src/app/components/txs/block-txs-data.tsx @@ -1,3 +1,4 @@ +import { t } from '@vegaprotocol/react-helpers'; import React from 'react'; import type { TendermintBlockchainResponse } from '../../routes/blocks/tendermint-blockchain-response'; import { BlockData } from '../blocks'; @@ -13,12 +14,14 @@ export const BlockTxsData = ({ data, className }: TxsProps) => { // Data for the block has already been fetched at this point, so no errors // or loading to deal with. This is specifically the case // where the data object is not undefined, but lacks a result. - return
    No data
    ; + return
    {t('No data')}
    ; } return (
      {data.result?.block_metas?.map((block, index) => { diff --git a/apps/explorer/src/app/components/txs/tx-list.tsx b/apps/explorer/src/app/components/txs/tx-list.tsx index 98f3500ca..cd55be663 100644 --- a/apps/explorer/src/app/components/txs/tx-list.tsx +++ b/apps/explorer/src/app/components/txs/tx-list.tsx @@ -1,3 +1,4 @@ +import { t } from '@vegaprotocol/react-helpers'; import type { TendermintUnconfirmedTransactionsResponse } from '../../routes/txs/tendermint-unconfirmed-transactions-response.d'; interface TxsProps { @@ -6,7 +7,7 @@ interface TxsProps { export const TxList = ({ data }: TxsProps) => { if (!data) { - return
      Awaiting transactions
      ; + return
      {t('Awaiting transactions')}
      ; } return
      {JSON.stringify(data, null, ' ')}
      ; diff --git a/apps/explorer/src/app/components/txs/txs-per-block.tsx b/apps/explorer/src/app/components/txs/txs-per-block.tsx index 808d3adf4..4d04c06e3 100644 --- a/apps/explorer/src/app/components/txs/txs-per-block.tsx +++ b/apps/explorer/src/app/components/txs/txs-per-block.tsx @@ -6,6 +6,7 @@ import { Link } from 'react-router-dom'; import { RenderFetched } from '../render-fetched'; import { TruncateInline } from '../truncate/truncate'; import { TxOrderType } from './tx-order-type'; +import { t } from '@vegaprotocol/react-helpers'; interface TxsPerBlockProps { blockHeight: string | undefined; @@ -36,9 +37,9 @@ export const TxsPerBlock = ({ blockHeight }: TxsPerBlockProps) => { - - - + + + @@ -76,7 +77,7 @@ export const TxsPerBlock = ({ blockHeight }: TxsPerBlockProps) => { ) : (
      - No transactions in block {blockHeight} + {t(`No transactions in block ${blockHeight}`)}
      )} diff --git a/apps/explorer/src/app/routes/assets/index.tsx b/apps/explorer/src/app/routes/assets/index.tsx index 3fdf7f19e..8baba3d16 100644 --- a/apps/explorer/src/app/routes/assets/index.tsx +++ b/apps/explorer/src/app/routes/assets/index.tsx @@ -1,4 +1,5 @@ import { gql, useQuery } from '@apollo/client'; +import { t } from '@vegaprotocol/react-helpers'; import React from 'react'; import { RouteTitle } from '../../components/route-title'; import { SubHeading } from '../../components/sub-heading'; @@ -37,7 +38,7 @@ const Assets = () => { if (!data || !data.assets) return null; return (
      - Assets + {t('Assets')} {data?.assets.map((a) => ( diff --git a/apps/explorer/src/app/routes/blocks/home/index.tsx b/apps/explorer/src/app/routes/blocks/home/index.tsx index b6fa12635..99ec64fcc 100644 --- a/apps/explorer/src/app/routes/blocks/home/index.tsx +++ b/apps/explorer/src/app/routes/blocks/home/index.tsx @@ -5,6 +5,7 @@ import { RouteTitle } from '../../../components/route-title'; import { RenderFetched } from '../../../components/render-fetched'; import { BlocksData, BlocksRefetch } from '../../../components/blocks'; import { JumpToBlock } from '../../../components/jump-to-block'; +import { t } from '@vegaprotocol/react-helpers'; const Blocks = () => { const { @@ -16,7 +17,7 @@ const Blocks = () => { return (
      - Blocks + {t('Blocks')} <> diff --git a/apps/explorer/src/app/routes/blocks/id/block.tsx b/apps/explorer/src/app/routes/blocks/id/block.tsx index a506c20d4..cebd90612 100644 --- a/apps/explorer/src/app/routes/blocks/id/block.tsx +++ b/apps/explorer/src/app/routes/blocks/id/block.tsx @@ -15,6 +15,7 @@ import { TxsPerBlock } from '../../../components/txs/txs-per-block'; import { Button } from '@vegaprotocol/ui-toolkit'; import { Routes } from '../../router-config'; import { RenderFetched } from '../../../components/render-fetched'; +import { t } from '@vegaprotocol/react-helpers'; const Block = () => { const { block } = useParams<{ block: string }>(); @@ -26,12 +27,12 @@ const Block = () => { const header = blockData?.result.block.header; if (!header) { - return

      Could not get block data

      ; + return

      {t('Could not get block data')}

      ; } return (
      - BLOCK {block} + {t(`BLOCK ${block}`)} <>
      diff --git a/apps/explorer/src/app/routes/genesis/index.tsx b/apps/explorer/src/app/routes/genesis/index.tsx index 960087c32..1d0a46007 100644 --- a/apps/explorer/src/app/routes/genesis/index.tsx +++ b/apps/explorer/src/app/routes/genesis/index.tsx @@ -1,3 +1,4 @@ +import { t } from '@vegaprotocol/react-helpers'; import { RouteTitle } from '../../components/route-title'; import { SyntaxHighlighter } from '../../components/syntax-highlighter'; import { DATA_SOURCES } from '../../config'; @@ -13,7 +14,7 @@ const Genesis = () => { if (!genesis?.result.genesis) return null; return (
      - Genesis + {t('Genesis')}
      ); diff --git a/apps/explorer/src/app/routes/governance/index.tsx b/apps/explorer/src/app/routes/governance/index.tsx index 30af1c727..cd224bb1b 100644 --- a/apps/explorer/src/app/routes/governance/index.tsx +++ b/apps/explorer/src/app/routes/governance/index.tsx @@ -1,4 +1,5 @@ import { gql, useQuery } from '@apollo/client'; +import { t } from '@vegaprotocol/react-helpers'; import React from 'react'; import { RouteTitle } from '../../components/route-title'; import { SubHeading } from '../../components/sub-heading'; @@ -10,16 +11,16 @@ import type { export function getProposalName(change: ProposalsQuery_proposals_terms_change) { if (change.__typename === 'NewAsset') { - return `New asset: ${change.symbol}`; + return t(`New asset: ${change.symbol}`); } else if (change.__typename === 'NewMarket') { - return `New market: ${change.instrument.name}`; + return t(`New market: ${change.instrument.name}`); } else if (change.__typename === 'UpdateMarket') { - return `Update market: ${change.marketId}`; + return t(`Update market: ${change.marketId}`); } else if (change.__typename === 'UpdateNetworkParameter') { - return `Update network: ${change.networkParameter.key}`; + return t(`Update network: ${change.networkParameter.key}`); } - return 'Unknown proposal'; + return t('Unknown proposal'); } const PROPOSAL_QUERY = gql` @@ -105,7 +106,7 @@ const Governance = () => { if (!data) return null; return (
      - Governance + {t('Governance')} {data.proposals?.map((p) => ( {getProposalName(p.terms.change)} diff --git a/apps/explorer/src/app/routes/markets/index.tsx b/apps/explorer/src/app/routes/markets/index.tsx index dfe1adc78..f184d4c65 100644 --- a/apps/explorer/src/app/routes/markets/index.tsx +++ b/apps/explorer/src/app/routes/markets/index.tsx @@ -5,6 +5,7 @@ import React from 'react'; import { SyntaxHighlighter } from '../../components/syntax-highlighter'; import { RouteTitle } from '../../components/route-title'; import { SubHeading } from '../../components/sub-heading'; +import { t } from '@vegaprotocol/react-helpers'; const MARKETS_QUERY = gql` query MarketsQuery { @@ -151,7 +152,7 @@ const Markets = () => { if (!data || !data.markets) return null; return (
      - Markets + {t('Markets')} {data ? data.markets.map((m) => ( diff --git a/apps/explorer/src/app/routes/network-parameters/index.tsx b/apps/explorer/src/app/routes/network-parameters/index.tsx index cf0569618..07f0cee83 100644 --- a/apps/explorer/src/app/routes/network-parameters/index.tsx +++ b/apps/explorer/src/app/routes/network-parameters/index.tsx @@ -2,6 +2,7 @@ import { gql, useQuery } from '@apollo/client'; import { RouteTitle } from '../../components/route-title'; import type { NetworkParametersQuery } from './__generated__/NetworkParametersQuery'; import { SyntaxHighlighter } from '../../components/syntax-highlighter'; +import { t } from '@vegaprotocol/react-helpers'; export const NETWORK_PARAMETERS_QUERY = gql` query NetworkParametersQuery { @@ -17,7 +18,7 @@ const NetworkParameters = () => { return (
      - Network Parameters + {t('Network Parameters')} {data ? : null}
      diff --git a/apps/explorer/src/app/routes/parties/home/index.tsx b/apps/explorer/src/app/routes/parties/home/index.tsx index 712a74aa7..74c415272 100644 --- a/apps/explorer/src/app/routes/parties/home/index.tsx +++ b/apps/explorer/src/app/routes/parties/home/index.tsx @@ -4,6 +4,7 @@ import { JumpTo } from '../../../components/jump-to'; import { useNavigate } from 'react-router-dom'; import { Routes } from '../../router-config'; +import { t } from '@vegaprotocol/react-helpers'; export const JumpToParty = () => { const navigate = useNavigate(); @@ -23,8 +24,8 @@ export const JumpToParty = () => { }; return ( { const Parties = () => { return (
      - Parties + {t('Parties')}
      ); diff --git a/apps/explorer/src/app/routes/parties/id/index.tsx b/apps/explorer/src/app/routes/parties/id/index.tsx index 809af5bc3..c0ca31e8d 100644 --- a/apps/explorer/src/app/routes/parties/id/index.tsx +++ b/apps/explorer/src/app/routes/parties/id/index.tsx @@ -1,5 +1,6 @@ import { useQuery } from '@apollo/client'; import { gql } from '@apollo/client'; +import { t } from '@vegaprotocol/react-helpers'; import React from 'react'; import { useParams } from 'react-router-dom'; import { RouteTitle } from '../../../components/route-title'; @@ -71,17 +72,17 @@ const Party = () => { return (
      - Party + {t('Party')} {data ? ( <> - Asset data + {t('Asset data')} ) : null} {partyData ? ( <> - Tendermint Data + {t('Tendermint Data')} ) : null} diff --git a/apps/explorer/src/app/routes/pending/index.tsx b/apps/explorer/src/app/routes/pending/index.tsx index 97bb5ab93..d5fd38a9e 100644 --- a/apps/explorer/src/app/routes/pending/index.tsx +++ b/apps/explorer/src/app/routes/pending/index.tsx @@ -4,6 +4,7 @@ import useFetch from '../../hooks/use-fetch'; import type { TendermintUnconfirmedTransactionsResponse } from '../txs/tendermint-unconfirmed-transactions-response.d'; import { TxList } from '../../components/txs'; import { RouteTitle } from '../../components/route-title'; +import { t } from '@vegaprotocol/react-helpers'; const PendingTxs = () => { const { @@ -15,11 +16,11 @@ const PendingTxs = () => { return (
      - Unconfirmed transactions + {t('Unconfirmed transactions')} https://lb.testnet.vega.xyz/tm/unconfirmed_txs
      -
      Number: {unconfirmedTransactions?.result?.n_txs || 0}
      +
      {t(`Number: ${unconfirmedTransactions?.result?.n_txs || 0}`)}


      diff --git a/apps/explorer/src/app/routes/router-config.tsx b/apps/explorer/src/app/routes/router-config.tsx index a67587755..cecf1a2b7 100644 --- a/apps/explorer/src/app/routes/router-config.tsx +++ b/apps/explorer/src/app/routes/router-config.tsx @@ -16,6 +16,7 @@ import { Tx } from './txs/id'; import { Txs as TxHome } from './txs/home'; import { PendingTxs } from './pending'; import flags from '../lib/flags'; +import { t } from '@vegaprotocol/react-helpers'; export const Routes = { HOME: '/', TX: 'txs', @@ -34,7 +35,7 @@ const partiesRoutes = flags.parties { path: Routes.PARTIES, name: 'Parties', - text: 'Parties', + text: t('Parties'), element: , children: [ { @@ -54,7 +55,7 @@ const assetsRoutes = flags.assets ? [ { path: Routes.ASSETS, - text: 'Assets', + text: t('Assets'), name: 'Assets', element: , }, @@ -66,7 +67,7 @@ const genesisRoutes = flags.genesis { path: Routes.GENESIS, name: 'Genesis', - text: 'Genesis Parameters', + text: t('Genesis Parameters'), element: , }, ] @@ -77,7 +78,7 @@ const governanceRoutes = flags.governance { path: Routes.GOVERNANCE, name: 'Governance', - text: 'Proposals', + text: t('Proposals'), element: , }, ] @@ -88,7 +89,7 @@ const marketsRoutes = flags.markets { path: Routes.MARKETS, name: 'Markets', - text: 'Markets', + text: t('Markets'), element: , }, ] @@ -99,7 +100,7 @@ const networkParametersRoutes = flags.networkParameters { path: Routes.NETWORK_PARAMETERS, name: 'NetworkParameters', - text: 'Network Parameters', + text: t('Network Parameters'), element: , }, ] @@ -109,7 +110,7 @@ const validators = flags.validators { path: Routes.VALIDATORS, name: 'Validators', - text: 'Validators', + text: t('Validators'), element: , }, ] @@ -119,14 +120,14 @@ const routerConfig = [ { path: Routes.HOME, name: 'Home', - text: 'Home', + text: t('Home'), element: , index: true, }, { path: Routes.TX, name: 'Txs', - text: 'Transactions', + text: t('Transactions'), element: , children: [ { @@ -146,7 +147,7 @@ const routerConfig = [ { path: Routes.BLOCKS, name: 'Blocks', - text: 'Blocks', + text: t('Blocks'), element: , children: [ { diff --git a/apps/explorer/src/app/routes/txs/home/index.tsx b/apps/explorer/src/app/routes/txs/home/index.tsx index 558fc1d34..bd83ab739 100644 --- a/apps/explorer/src/app/routes/txs/home/index.tsx +++ b/apps/explorer/src/app/routes/txs/home/index.tsx @@ -6,6 +6,7 @@ import { BlocksRefetch } from '../../../components/blocks'; import { RenderFetched } from '../../../components/render-fetched'; import { BlockTxsData } from '../../../components/txs'; import { JumpToBlock } from '../../../components/jump-to-block'; +import { t } from '@vegaprotocol/react-helpers'; const Txs = () => { const { @@ -17,7 +18,7 @@ const Txs = () => { return (
      - Transactions + {t('Transactions')} <> diff --git a/apps/explorer/src/app/routes/txs/id/index.tsx b/apps/explorer/src/app/routes/txs/id/index.tsx index 93a27887d..22798d56c 100644 --- a/apps/explorer/src/app/routes/txs/id/index.tsx +++ b/apps/explorer/src/app/routes/txs/id/index.tsx @@ -8,6 +8,7 @@ import { RouteTitle } from '../../../components/route-title'; import { RenderFetched } from '../../../components/render-fetched'; import { TxContent } from './tx-content'; import { TxDetails } from './tx-details'; +import { t } from '@vegaprotocol/react-helpers'; const Tx = () => { const { txHash } = useParams<{ txHash: string }>(); @@ -30,7 +31,7 @@ const Tx = () => { return (
      - Transaction details + {t('Transaction details')} { /> -

      Transaction content

      +

      {t('Transaction content')}

      diff --git a/apps/explorer/src/app/routes/txs/id/tx-content.tsx b/apps/explorer/src/app/routes/txs/id/tx-content.tsx index a5a194740..fdd135318 100644 --- a/apps/explorer/src/app/routes/txs/id/tx-content.tsx +++ b/apps/explorer/src/app/routes/txs/id/tx-content.tsx @@ -1,3 +1,4 @@ +import { t } from '@vegaprotocol/react-helpers'; import { StatusMessage } from '../../../components/status-message'; import { SyntaxHighlighter } from '../../../components/syntax-highlighter'; import { @@ -16,7 +17,9 @@ interface TxContentProps { export const TxContent = ({ data }: TxContentProps) => { if (!data?.Command) { return ( - Could not retrieve transaction content + + {t('Could not retrieve transaction content')} + ); } @@ -25,7 +28,7 @@ export const TxContent = ({ data }: TxContentProps) => {
      TransactionFromType{t('Transaction')}{t('From')}{t('Type')}
      - Type + {t('Type')} @@ -33,7 +36,7 @@ export const TxContent = ({ data }: TxContentProps) => {
      -

      Decoded transaction content

      +

      {t('Decoded transaction content')}

      ); diff --git a/apps/explorer/src/app/routes/txs/id/tx-details.tsx b/apps/explorer/src/app/routes/txs/id/tx-details.tsx index 497d4efa1..c4008b65a 100644 --- a/apps/explorer/src/app/routes/txs/id/tx-details.tsx +++ b/apps/explorer/src/app/routes/txs/id/tx-details.tsx @@ -1,3 +1,4 @@ +import { t } from '@vegaprotocol/react-helpers'; import { Link } from 'react-router-dom'; import { Table, @@ -19,20 +20,20 @@ const truncateLength = 30; export const TxDetails = ({ txData, pubKey, className }: TxDetailsProps) => { if (!txData) { - return <>Awaiting Tendermint transaction details; + return <>{t('Awaiting Tendermint transaction details')}; } return ( - Hash + {t('Hash')} {txData.hash} - Submitted by + {t('Submitted by')} { - Block + {t('Block')} { - Encoded txn + {t('Encoded txn')} { return (
      - Validators + {t('Validators')} {data ? ( <> - Vega data + {t('Vega data')} ) : null} {validators ? ( <> - Tendermint data + {t('Tendermint data')} diff --git a/apps/trading/components/navbar/navbar.tsx b/apps/trading/components/navbar/navbar.tsx index b4c87d2c1..51df59f8d 100644 --- a/apps/trading/components/navbar/navbar.tsx +++ b/apps/trading/components/navbar/navbar.tsx @@ -2,6 +2,7 @@ import { useRouter } from 'next/router'; import { Vega } from '../icons/vega'; import Link from 'next/link'; import { AnchorButton } from '@vegaprotocol/ui-toolkit'; +import { t } from '@vegaprotocol/react-helpers'; export const Navbar = () => { return ( @@ -12,8 +13,8 @@ export const Navbar = () => { {[ - { name: 'Trading', path: '/markets' }, - { name: 'Portfolio', path: '/portfolio' }, + { name: t('Trading'), path: '/markets' }, + { name: t('Portfolio'), path: '/portfolio' }, ].map((route) => ( ))} diff --git a/apps/trading/components/vega-wallet-connect-button/index.tsx b/apps/trading/components/vega-wallet-connect-button/index.tsx index 2a72e9289..1556b5441 100644 --- a/apps/trading/components/vega-wallet-connect-button/index.tsx +++ b/apps/trading/components/vega-wallet-connect-button/index.tsx @@ -1,3 +1,4 @@ +import { t } from '@vegaprotocol/react-helpers'; import { useVegaWallet } from '@vegaprotocol/wallet'; interface VegaWalletButtonProps { @@ -23,7 +24,7 @@ export const VegaWalletButton = ({ onClick={handleClick} className="ml-auto inline-block text-ui sm:text-body-large" > - {isConnected ? 'Disconnect Vega wallet' : 'Connect Vega wallet'} + {isConnected ? t('Disconnect Vega wallet') : t('Connect Vega wallet')} ); }; diff --git a/apps/trading/components/web3-container/web3-container.tsx b/apps/trading/components/web3-container/web3-container.tsx index e2a48380d..a427345d8 100644 --- a/apps/trading/components/web3-container/web3-container.tsx +++ b/apps/trading/components/web3-container/web3-container.tsx @@ -1,3 +1,4 @@ +import { t } from '@vegaprotocol/react-helpers'; import { Button, Splash } from '@vegaprotocol/ui-toolkit'; import { Web3Provider, Web3ConnectDialog } from '@vegaprotocol/web3'; import { useWeb3React } from '@web3-react/core'; @@ -42,8 +43,10 @@ export const Web3Content = ({ children, setDialogOpen }: Web3ContentProps) => { if (error) { return ( -

      Something went wrong: {error.message}

      - +

      {t(`Something went wrong: ${error.message}`)}

      +
      ); } @@ -51,8 +54,8 @@ export const Web3Content = ({ children, setDialogOpen }: Web3ContentProps) => { if (!isActive) { return ( -

      Connect your Ethereum wallet

      - +

      {t('Connect your Ethereum wallet')}

      +
      ); } @@ -60,8 +63,12 @@ export const Web3Content = ({ children, setDialogOpen }: Web3ContentProps) => { if (chainId !== appChainId) { return ( -

      This app only works on chain ID: {appChainId}

      - +

      + {t(`This app only works on chain ID: ${appChainId}`)} +

      +
      ); } diff --git a/apps/trading/pages/_app.page.tsx b/apps/trading/pages/_app.page.tsx index ae37cdfef..4179742ff 100644 --- a/apps/trading/pages/_app.page.tsx +++ b/apps/trading/pages/_app.page.tsx @@ -1,7 +1,7 @@ import type { AppProps } from 'next/app'; import Head from 'next/head'; import { Navbar } from '../components/navbar'; -import { ThemeContext } from '@vegaprotocol/react-helpers'; +import { t, ThemeContext } from '@vegaprotocol/react-helpers'; import { VegaConnectDialog, VegaWalletProvider } from '@vegaprotocol/wallet'; import { Connectors } from '../lib/vega-connectors'; import { useCallback, useMemo, useState } from 'react'; @@ -32,7 +32,7 @@ function VegaTradingApp({ Component, pageProps }: AppProps) { - Welcome to trading! + {t('Welcome to Vega trading!')}
      @@ -29,11 +18,6 @@ export function Index() {
      - - - - - ); } diff --git a/apps/trading/pages/markets/[marketId].page.tsx b/apps/trading/pages/markets/[marketId].page.tsx index dfd37f869..ade159a69 100644 --- a/apps/trading/pages/markets/[marketId].page.tsx +++ b/apps/trading/pages/markets/[marketId].page.tsx @@ -6,6 +6,7 @@ import React, { useEffect, useState } from 'react'; import debounce from 'lodash/debounce'; import { PageQueryContainer } from '../../components/page-query-container'; import { TradeGrid, TradePanels } from './trade-grid'; +import { t } from '@vegaprotocol/react-helpers'; // Top level page query const MARKET_QUERY = gql` @@ -29,7 +30,7 @@ const MarketPage = () => { if (!marketId) { return ( -

      Not found

      +

      {t('Not found')}

      ); } @@ -46,7 +47,7 @@ const MarketPage = () => { > {({ market }) => { if (!market) { - return Market not found; + return {t('Market not found')}; } return w > 960 ? ( diff --git a/apps/trading/pages/markets/grid-tabs.tsx b/apps/trading/pages/markets/grid-tabs.tsx index 5d7a248fc..6e554959d 100644 --- a/apps/trading/pages/markets/grid-tabs.tsx +++ b/apps/trading/pages/markets/grid-tabs.tsx @@ -19,7 +19,7 @@ export const GridTabs = ({ children, group }: GridTabsProps) => { } // Default to first tab - return children[0].props.name; + return children[0].props.id; }); // Update the query string in the url when the active tab changes @@ -45,7 +45,7 @@ export const GridTabs = ({ children, group }: GridTabsProps) => { > {Children.map(children, (child) => { if (!isValidElement(child)) return null; - const isActive = child.props.name === activeTab; + const isActive = child.props.id === activeTab; const triggerClass = classNames('py-4', 'px-12', 'capitalize', { 'text-black dark:text-vega-yellow': isActive, 'bg-white dark:bg-black': isActive, @@ -53,7 +53,7 @@ export const GridTabs = ({ children, group }: GridTabsProps) => { 'bg-black-10 dark:bg-white-10': !isActive, }); return ( - + {child.props.name} ); @@ -64,7 +64,7 @@ export const GridTabs = ({ children, group }: GridTabsProps) => { {Children.map(children, (child) => { if (!isValidElement(child)) return null; return ( - + {child.props.children} ); @@ -76,6 +76,7 @@ export const GridTabs = ({ children, group }: GridTabsProps) => { interface GridTabProps { children: ReactNode; + id: string; name: string; } diff --git a/apps/trading/pages/markets/trade-grid.tsx b/apps/trading/pages/markets/trade-grid.tsx index ce600e8b6..7f78f7c9c 100644 --- a/apps/trading/pages/markets/trade-grid.tsx +++ b/apps/trading/pages/markets/trade-grid.tsx @@ -8,25 +8,26 @@ import { OrderListContainer } from '@vegaprotocol/order-list'; import { Splash } from '@vegaprotocol/ui-toolkit'; import { PositionsContainer } from '@vegaprotocol/positions'; import type { Market_market } from './__generated__/Market'; +import { t } from '@vegaprotocol/react-helpers'; const Chart = () => ( -

      Chart

      +

      {t('Chart')}

      ); const Orderbook = () => ( -

      Orderbook

      +

      {t('Orderbook')}

      ); const Collateral = () => ( -

      Collateral

      +

      {t('Collateral')}

      ); const Trades = () => ( -

      Trades

      +

      {t('Trades')}

      ); @@ -56,7 +57,9 @@ export const TradeGrid = ({ market }: TradeGridProps) => { return (
      -

      Market: {market.name}

      +

      + {t('Market')}: {market.name} +

      @@ -66,23 +69,23 @@ export const TradeGrid = ({ market }: TradeGridProps) => { - + - + - + - + - + @@ -131,7 +134,9 @@ export const TradePanels = ({ market }: TradePanelsProps) => { return (
      -

      Market: {market.name}

      +

      + {t('Market')}: {market.name} +

      diff --git a/apps/trading/pages/portfolio/index.page.tsx b/apps/trading/pages/portfolio/index.page.tsx index 5cf191e63..eb477ed74 100644 --- a/apps/trading/pages/portfolio/index.page.tsx +++ b/apps/trading/pages/portfolio/index.page.tsx @@ -1,3 +1,4 @@ +import { t } from '@vegaprotocol/react-helpers'; import { AnchorButton } from '@vegaprotocol/ui-toolkit'; import { useVegaWallet } from '@vegaprotocol/wallet'; @@ -5,14 +6,10 @@ const Portfolio = () => { const { keypair } = useVegaWallet(); return (
      -

      Portfolio

      - {keypair && ( -

      - Keypair: {keypair.name} {keypair.pub} -

      - )} +

      {t('Portfolio')}

      + {keypair &&

      {t(`Keypair: ${keypair.name} ${keypair.pub}`)}

      }
      - Deposit + {t('Deposit')}
      ); diff --git a/libs/deal-ticket/src/deal-ticket-container.tsx b/libs/deal-ticket/src/deal-ticket-container.tsx index 359f99da5..608850c24 100644 --- a/libs/deal-ticket/src/deal-ticket-container.tsx +++ b/libs/deal-ticket/src/deal-ticket-container.tsx @@ -2,6 +2,7 @@ import { AsyncRenderer, Splash } from '@vegaprotocol/ui-toolkit'; import { gql, useQuery } from '@apollo/client'; import { DealTicketManager } from './deal-ticket-manager'; import type { DealTicketQuery } from './__generated__/DealTicketQuery'; +import { t } from '@vegaprotocol/react-helpers'; const DEAL_TICKET_QUERY = gql` query DealTicketQuery($marketId: ID!) { @@ -43,7 +44,7 @@ export const DealTicketContainer = ({ marketId }: DealTicketContainerProps) => { if (!data.market) { return ( -

      Could not load market

      +

      {t('Could not load market')}

      ); } diff --git a/libs/deal-ticket/src/order-dialog.tsx b/libs/deal-ticket/src/order-dialog.tsx index aaa9e75a6..d32379be4 100644 --- a/libs/deal-ticket/src/order-dialog.tsx +++ b/libs/deal-ticket/src/order-dialog.tsx @@ -1,7 +1,7 @@ import { Icon, Loader } from '@vegaprotocol/ui-toolkit'; import type { ReactNode } from 'react'; import type { OrderEvent_busEvents_event_Order } from './__generated__/OrderEvent'; -import { formatNumber } from '@vegaprotocol/react-helpers'; +import { formatNumber, t } from '@vegaprotocol/react-helpers'; import type { TransactionState } from '@vegaprotocol/wallet'; import { VegaTxStatus } from '@vegaprotocol/wallet'; @@ -40,7 +40,7 @@ export const OrderDialog = ({ icon={} > {transaction.hash && ( -

      Tx hash: {transaction.hash}

      +

      {t(`Tx hash: ${transaction.hash}`)}

      )} ); @@ -53,7 +53,7 @@ export const OrderDialog = ({ title="Order failed" icon={} > -

      Reason: {finalizedOrder.rejectionReason}

      +

      {t(`Reason: ${finalizedOrder.rejectionReason}`)}

      ); } @@ -63,16 +63,19 @@ export const OrderDialog = ({ title="Order placed" icon={} > -

      Status: {finalizedOrder.status}

      - {finalizedOrder.market &&

      Market: {finalizedOrder.market.name}

      } -

      Type: {finalizedOrder.type}

      -

      Amount: {finalizedOrder.size}

      +

      {t(`Status: ${finalizedOrder.status}`)}

      + {finalizedOrder.market && ( +

      {t(`Market: {finalizedOrder.market.name}`)}

      + )} +

      {t(`Type: ${finalizedOrder.type}`)}

      +

      {t(`Amount: ${finalizedOrder.size}`)}

      {finalizedOrder.type === 'Limit' && finalizedOrder.market && (

      - Price:{' '} - {formatNumber( - finalizedOrder.price, - finalizedOrder.market.decimalPlaces + {t( + `Price: ${formatNumber( + finalizedOrder.price, + finalizedOrder.market.decimalPlaces + )}` )}

      )} diff --git a/libs/deal-ticket/src/submit-button.tsx b/libs/deal-ticket/src/submit-button.tsx index 83bfb90f6..88df187d0 100644 --- a/libs/deal-ticket/src/submit-button.tsx +++ b/libs/deal-ticket/src/submit-button.tsx @@ -6,6 +6,7 @@ import { useVegaWallet } from '@vegaprotocol/wallet'; import type { TransactionStatus } from './deal-ticket'; import type { DealTicketQuery_market } from './__generated__/DealTicketQuery'; import { MarketState, MarketTradingMode } from '@vegaprotocol/types'; +import { t } from '@vegaprotocol/react-helpers'; interface SubmitButtonProps { transactionStatus: TransactionStatus; @@ -22,31 +23,31 @@ export const SubmitButton = ({ const invalidText = useMemo(() => { if (!keypair) { - return 'No public key selected'; + return t('No public key selected'); } if (keypair.tainted) { - return 'Selected public key has been tainted'; + return t('Selected public key has been tainted'); } if (market.state !== MarketState.Active) { if (market.state === MarketState.Suspended) { - return 'Market is currently suspended'; + return t('Market is currently suspended'); } if ( market.state === MarketState.Proposed || market.state === MarketState.Pending ) { - return 'Market is not active yet'; + return t('Market is not active yet'); } - return 'Market is no longer active'; + return t('Market is no longer active'); } if (market.tradingMode !== MarketTradingMode.Continuous) { if (order.type === OrderType.Market) { - return 'Only limit orders are permitted when market is in auction'; + return t('Only limit orders are permitted when market is in auction'); } if ( @@ -56,7 +57,9 @@ export const SubmitButton = ({ OrderTimeInForce.GFN, ].includes(order.timeInForce) ) { - return 'Only GTT, GTC and GFA are permitted when market is in auction'; + return t( + 'Only GTT, GTC and GFA are permitted when market is in auction' + ); } } @@ -73,7 +76,7 @@ export const SubmitButton = ({ type="submit" disabled={disabled} > - {transactionStatus === 'pending' ? 'Pending...' : 'Place order'} + {transactionStatus === 'pending' ? t('Pending...') : t('Place order')} {invalidText && {invalidText}} diff --git a/libs/market-list/src/lib/market-list-table.tsx b/libs/market-list/src/lib/market-list-table.tsx index 1c537d0d6..944543cb3 100644 --- a/libs/market-list/src/lib/market-list-table.tsx +++ b/libs/market-list/src/lib/market-list-table.tsx @@ -1,6 +1,6 @@ import { forwardRef } from 'react'; import type { ValueFormatterParams } from 'ag-grid-community'; -import { PriceCell, formatNumber } from '@vegaprotocol/react-helpers'; +import { PriceCell, formatNumber, t } from '@vegaprotocol/react-helpers'; import { AgGridDynamic as AgGrid } from '@vegaprotocol/ui-toolkit'; import type { Markets_markets } from './__generated__/Markets'; import { AgGridColumn } from 'ag-grid-react'; @@ -18,7 +18,7 @@ export const MarketListTable = forwardRef( return ( ( components={{ PriceCell }} > `${value.market.state} (${value.market.tradingMode})` } /> ( } /> @@ -65,7 +65,7 @@ export const MarketListTable = forwardRef( cellRenderer="PriceCell" /> ( formatNumber(value, data.decimalPlaces) } /> - + ); } diff --git a/libs/network-stats/src/config/stats-fields.ts b/libs/network-stats/src/config/stats-fields.ts index 8a10a5430..ada886fcf 100644 --- a/libs/network-stats/src/config/stats-fields.ts +++ b/libs/network-stats/src/config/stats-fields.ts @@ -1,3 +1,4 @@ +import { t } from '@vegaprotocol/react-helpers'; import type { Stats as IStats, StatFields as IStatFields } from './types'; // Stats fields config. Keys will correspond to graphql queries when used, and values @@ -6,7 +7,7 @@ import type { Stats as IStats, StatFields as IStatFields } from './types'; export const statsFields: { [key in keyof IStats]: IStatFields[] } = { status: [ { - title: 'Status', + title: t('Status'), formatter: (status: string) => { if (!status) { return; @@ -22,123 +23,126 @@ export const statsFields: { [key in keyof IStats]: IStatFields[] } = { goodThreshold: (status: string) => status === 'CONNECTED' || status === 'CHAIN_STATUS_CONNECTED', promoted: true, - description: - 'Status is either connected, replaying, unspecified or disconnected', + description: t( + 'Status is either connected, replaying, unspecified or disconnected' + ), }, ], blockHeight: [ { - title: 'Height', + title: t('Height'), goodThreshold: (height: number) => height >= 60, promoted: true, - description: 'Block height', + description: t('Block height'), }, ], totalNodes: [ { - title: 'Total nodes', - description: 'The total number of nodes registered on the network', + title: t('Total nodes'), + description: t('The total number of nodes registered on the network'), }, ], validatingNodes: [ { - title: 'Validating nodes', + title: t('Validating nodes'), promoted: true, - description: 'Nodes participating in consensus', + description: t('Nodes participating in consensus'), }, ], inactiveNodes: [ { - title: 'Inactive nodes', + title: t('Inactive nodes'), goodThreshold: (totalInactive: number) => totalInactive < 1, - description: 'Nodes that are registered but not validating', + description: t('Nodes that are registered but not validating'), }, ], stakedTotal: [ { - title: 'Total staked', + title: t('Total staked'), formatter: (total: string) => total.length > 18 && parseInt(total.substring(0, total.length - 18)).toLocaleString('en-US'), - description: 'Sum of VEGA associated with a Vega key', + description: t('Sum of VEGA associated with a Vega key'), }, ], backlogLength: [ { - title: 'Backlog', + title: t('Backlog'), goodThreshold: (length: number, blockDuration: number) => { return ( length < 1000 || (length >= 1000 && blockDuration / 1000000000 <= 1) ); }, - description: 'Number of transactions waiting to be processed', + description: t('Number of transactions waiting to be processed'), }, ], tradesPerSecond: [ { - title: 'Trades / second', + title: t('Trades / second'), goodThreshold: (trades: number) => trades >= 2, - description: 'Number of trades processed in the last second', + description: t('Number of trades processed in the last second'), }, ], averageOrdersPerBlock: [ { - title: 'Orders / block', + title: t('Orders / block'), goodThreshold: (orders: number) => orders >= 2, - description: - 'Number of new orders processed in the last block. All pegged orders and liquidity provisions count as a single order', + description: t( + 'Number of new orders processed in the last block. All pegged orders and liquidity provisions count as a single order' + ), }, ], ordersPerSecond: [ { - title: 'Orders / second', + title: t('Orders / second'), goodThreshold: (orders: number) => orders >= 2, - description: - 'Number of orders processed in the last second. All pegged orders and liquidity provisions count as a single order', + description: t( + 'Number of orders processed in the last second. All pegged orders and liquidity provisions count as a single order' + ), }, ], txPerBlock: [ { - title: 'Transactions / block', + title: t('Transactions / block'), goodThreshold: (tx: number) => tx > 2, - description: 'Number of transactions processed in the last block', + description: t('Number of transactions processed in the last block'), }, ], blockDuration: [ { - title: 'Block time', + title: t('Block time'), formatter: (duration: number) => (duration / 1000000000).toFixed(3), goodThreshold: (blockDuration: number) => blockDuration > 0 && blockDuration <= 2000000000, - description: 'Seconds between the two most recent blocks', + description: t('Seconds between the two most recent blocks'), }, ], vegaTime: [ { - title: 'Time', + title: t('Time'), formatter: (time: Date) => new Date(time).toLocaleTimeString(), goodThreshold: (time: Date) => { const diff = new Date().getTime() - new Date(time).getTime(); return diff > 0 && diff < 5000; }, - description: 'The time on the blockchain', + description: t('The time on the blockchain'), }, ], appVersion: [ { - title: 'App', - description: 'Vega node software version on this node', + title: t('App'), + description: t('Vega node software version on this node'), }, ], chainVersion: [ { - title: 'Tendermint', - description: 'Tendermint software version on this node', + title: t('Tendermint'), + description: t('Tendermint software version on this node'), }, ], uptime: [ { - title: 'Uptime', + title: t('Uptime'), formatter: (t: string) => { if (!t) { return; @@ -152,23 +156,23 @@ export const statsFields: { [key in keyof IStats]: IStatFields[] } = { return `${days}d ${hours}h ${mins}m ${secs}s`; }, promoted: true, - description: 'Time since genesis', + description: t('Time since genesis'), }, { - title: 'Up since', + title: t('Up since'), formatter: (t: string) => { if (!t) { return; } return `${new Date(t).toLocaleString().replace(',', ' ')}`; }, - description: 'Genesis', + description: t('Genesis'), }, ], chainId: [ { - title: 'Chain ID', - description: 'Identifier', + title: t('Chain ID'), + description: t('Identifier'), }, ], }; diff --git a/libs/order-list/src/order-list-container.tsx b/libs/order-list/src/order-list-container.tsx index f4c608530..32b0aafba 100644 --- a/libs/order-list/src/order-list-container.tsx +++ b/libs/order-list/src/order-list-container.tsx @@ -1,3 +1,4 @@ +import { t } from '@vegaprotocol/react-helpers'; import { Splash } from '@vegaprotocol/ui-toolkit'; import { useVegaWallet } from '@vegaprotocol/wallet'; import { OrderListManager } from './order-list-manager'; @@ -6,7 +7,7 @@ export const OrderListContainer = () => { const { keypair } = useVegaWallet(); if (!keypair) { - return Please connect Vega wallet; + return {t('Please connect Vega wallet')}; } return ; diff --git a/libs/order-list/src/order-list.spec.tsx b/libs/order-list/src/order-list.spec.tsx index 40b3e23f6..eb9b5bb4a 100644 --- a/libs/order-list/src/order-list.spec.tsx +++ b/libs/order-list/src/order-list.spec.tsx @@ -87,7 +87,7 @@ test('Correct columns are rendered', async () => { 'Amount', 'Type', 'Status', - 'Filled', + 'Remaining', 'Price', 'Time In Force', 'Created At', diff --git a/libs/order-list/src/order-list.tsx b/libs/order-list/src/order-list.tsx index b1b0ada31..c48f10cd8 100644 --- a/libs/order-list/src/order-list.tsx +++ b/libs/order-list/src/order-list.tsx @@ -3,6 +3,7 @@ import type { Orders_party_orders } from './__generated__/Orders'; import { formatNumber, getDateTimeFormat, + t, useApplyGridTransaction, } from '@vegaprotocol/react-helpers'; import { AgGridDynamic as AgGrid } from '@vegaprotocol/ui-toolkit'; @@ -33,11 +34,11 @@ export const OrderList = ({ orders }: OrderListProps) => { getRowNodeId={(data) => data.id} > { @@ -57,7 +58,6 @@ export const OrderList = ({ orders }: OrderListProps) => { }} /> { diff --git a/libs/positions/src/lib/positions-container.tsx b/libs/positions/src/lib/positions-container.tsx index 6322f6929..7eec41287 100644 --- a/libs/positions/src/lib/positions-container.tsx +++ b/libs/positions/src/lib/positions-container.tsx @@ -1,3 +1,4 @@ +import { t } from '@vegaprotocol/react-helpers'; import { Splash } from '@vegaprotocol/ui-toolkit'; import { useVegaWallet } from '@vegaprotocol/wallet'; import { PositionsManager } from './positions-manager'; @@ -8,7 +9,7 @@ export const PositionsContainer = () => { if (!keypair) { return ( -

      Please connect Vega wallet

      +

      {t('Please connect Vega wallet')}

      ); } diff --git a/libs/positions/src/lib/positions-table.tsx b/libs/positions/src/lib/positions-table.tsx index 01e2cad8a..304826de9 100644 --- a/libs/positions/src/lib/positions-table.tsx +++ b/libs/positions/src/lib/positions-table.tsx @@ -5,6 +5,7 @@ import { formatNumber, volumePrefix, addDecimal, + t, } from '@vegaprotocol/react-helpers'; import { AgGridDynamic as AgGrid } from '@vegaprotocol/ui-toolkit'; import { AgGridColumn } from 'ag-grid-react'; @@ -64,18 +65,18 @@ export const PositionsTable = forwardRef( components={{ PriceCell }} > volumePrefix(value) } /> ( } /> ( }} /> str; 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 4545b46b8..7476cd470 100644 --- a/libs/ui-toolkit/src/components/vega-logo/vega-logo.tsx +++ b/libs/ui-toolkit/src/components/vega-logo/vega-logo.tsx @@ -1,7 +1,9 @@ +import { t } from '@vegaprotocol/react-helpers'; + export const VegaLogo = () => { return ( setSelectedConnector(connector)} className="capitalize hover:text-vega-pink dark:hover:text-vega-yellow underline" > - {key} provider + {t(`${key} provider`)}

      {connector.description}

      diff --git a/libs/wallet/src/provider.tsx b/libs/wallet/src/provider.tsx index 0fe2b2840..ad281014a 100644 --- a/libs/wallet/src/provider.tsx +++ b/libs/wallet/src/provider.tsx @@ -1,4 +1,4 @@ -import { LocalStorage } from '@vegaprotocol/react-helpers'; +import { LocalStorage, t } from '@vegaprotocol/react-helpers'; import type { ReactNode } from 'react'; import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import type { VegaKeyExtended, VegaWalletContextShape } from '.'; @@ -38,7 +38,7 @@ export const VegaWalletProvider = ({ children }: VegaWalletProviderProps) => { const nameMeta = pk.meta?.find((m) => m.key === 'name'); return { ...pk, - name: nameMeta?.value ? nameMeta.value : 'None', + name: nameMeta?.value ? nameMeta.value : t('None'), }; }); diff --git a/libs/wallet/src/rest-connector-form.tsx b/libs/wallet/src/rest-connector-form.tsx index e0d220860..6173a55a5 100644 --- a/libs/wallet/src/rest-connector-form.tsx +++ b/libs/wallet/src/rest-connector-form.tsx @@ -1,3 +1,4 @@ +import { t } from '@vegaprotocol/react-helpers'; import { Button, FormGroup, Input, InputError } from '@vegaprotocol/ui-toolkit'; import { useState } from 'react'; import { useForm } from 'react-hook-form'; @@ -40,20 +41,20 @@ export function RestConnectorForm({ } } catch (err) { if (err instanceof TypeError) { - setError('Wallet not running at http://localhost:1789'); + setError(t('Wallet not running at http://localhost:1789')); } else if (err instanceof Error) { - setError('Authentication failed'); + setError(t('Authentication failed')); } else { - setError('Something went wrong'); + setError(t('Something went wrong')); } } } return (
      - + )} - + @@ -82,7 +83,7 @@ export function RestConnectorForm({

      )} ); diff --git a/libs/web3/src/lib/web3-connect-dialog.tsx b/libs/web3/src/lib/web3-connect-dialog.tsx index 878d5c370..039deb4c6 100644 --- a/libs/web3/src/lib/web3-connect-dialog.tsx +++ b/libs/web3/src/lib/web3-connect-dialog.tsx @@ -1,3 +1,4 @@ +import { t } from '@vegaprotocol/react-helpers'; import { Dialog, Intent } from '@vegaprotocol/ui-toolkit'; import type { Connectors } from './types'; @@ -19,7 +20,7 @@ export const Web3ConnectDialog = ({ open={dialogOpen} onChange={setDialogOpen} intent={Intent.Prompt} - title="Connect to your Ethereum wallet" + title={t('Connect to your Ethereum wallet')} >
        {Object.entries(connectors).map(([connectorName, [connector]]) => {