From 72821dd183e7d9297b150e8f13d862162cb3b9f3 Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Sun, 7 May 2023 18:01:07 -0700 Subject: [PATCH] chore(utils,react-helpers,data-provider): remove apollo deps from ui-toolkit (#3626) --- .../components/proposals/proposals-table.tsx | 5 +- .../app/routes/governance/proposals-page.tsx | 2 +- .../src/app/routes/markets/market-page.tsx | 2 +- .../src/app/routes/markets/markets-page.tsx | 2 +- .../network-parameters.spec.tsx | 2 +- .../network-parameters/network-parameters.tsx | 4 +- .../current-proposal-status.spec.tsx | 4 +- .../components/proposal/proposal.spec.tsx | 4 +- .../components/proposal/proposal.tsx | 5 +- .../hooks/use-proposal-network-params.spec.ts | 4 +- .../hooks/use-proposal-network-params.ts | 5 +- .../hooks/use-vote-information.spec.ts | 4 +- .../freeform/propose-freeform.spec.tsx | 4 +- .../propose/freeform/propose-freeform.tsx | 5 +- .../propose-network-parameter.spec.tsx | 4 +- .../propose-network-parameter.tsx | 2 +- .../new-asset/propose-new-asset.spec.tsx | 4 +- .../propose/new-asset/propose-new-asset.tsx | 5 +- .../new-market/propose-new-market.spec.tsx | 4 +- .../propose/new-market/propose-new-market.tsx | 5 +- .../propose/raw/proposal-raw.spec.tsx | 4 +- .../proposals/propose/raw/propose-raw.tsx | 5 +- .../propose-update-asset.spec.tsx | 4 +- .../update-asset/propose-update-asset.tsx | 5 +- .../propose-update-market.spec.tsx | 4 +- .../update-market/propose-update-market.tsx | 5 +- .../routes/proposals/test-helpers/mocks.ts | 4 +- .../src/routes/rewards/home/rewards-page.tsx | 5 +- .../src/routes/staking/node/staking-form.tsx | 5 +- .../src/routes/withdrawals/index.tsx | 2 +- .../src/app/components/detail/detail.tsx | 4 +- .../last-24h-volume/last-24h-volume.tsx | 3 +- apps/trading/client-pages/home/home.tsx | 2 +- .../client-pages/liquidity/liquidity.tsx | 6 +- apps/trading/client-pages/market/market.tsx | 4 +- apps/trading/client-pages/markets/closed.tsx | 2 +- .../portfolio/account-history-container.tsx | 3 +- .../portfolio/deposits-container.tsx | 6 +- .../portfolio/withdrawals-container.tsx | 2 +- .../liquidity-supplied/liquidity-supplied.tsx | 4 +- .../market-mark-price/market-mark-price.tsx | 2 +- .../components/market-state/market-state.tsx | 2 +- .../market-volume/market-volume.tsx | 2 +- .../select-market/select-market.tsx | 2 +- .../welcome-dialog/proposed-markets.tsx | 2 +- .../welcome-dialog/welcome-dialog.tsx | 3 +- apps/trading/pages/_app.page.tsx | 2 +- .../src/lib/accounts-data-provider.ts | 4 +- .../src/lib/accounts-manager.spec.tsx | 6 +- libs/accounts/src/lib/accounts-manager.tsx | 6 +- libs/accounts/src/lib/asset-balance.tsx | 2 +- libs/accounts/src/lib/transfer-container.tsx | 4 +- libs/accounts/src/lib/use-account-balance.tsx | 2 +- .../src/lib/use-market-account-balance.tsx | 2 +- libs/assets/src/lib/asset-data-provider.ts | 3 +- libs/assets/src/lib/assets-data-provider.ts | 7 +- libs/cypress/mock.ts | 4 +- libs/data-provider/.babelrc | 12 +++ libs/data-provider/.eslintrc.json | 18 +++++ libs/data-provider/README.md | 7 ++ libs/data-provider/jest.config.ts | 10 +++ libs/data-provider/package.json | 4 + libs/data-provider/project.json | 43 ++++++++++ .../src}/generic-data-provider.spec.ts | 0 .../src}/generic-data-provider.ts | 2 +- .../src/helpers.ts} | 18 ++--- libs/data-provider/src/index.ts | 4 + .../lib => data-provider/src}/pagination.ts | 3 +- .../src}/use-data-provider.spec.ts | 2 +- .../src}/use-data-provider.ts | 4 +- libs/data-provider/tsconfig.json | 25 ++++++ libs/data-provider/tsconfig.lib.json | 23 ++++++ libs/data-provider/tsconfig.spec.json | 20 +++++ .../deal-ticket/deal-ticket-container.tsx | 2 +- .../components/deal-ticket/deal-ticket.tsx | 2 +- .../deal-ticket/market-selector.tsx | 2 +- .../src/hooks/use-initial-margin.ts | 2 +- libs/deposits/src/lib/deposit-container.tsx | 2 +- libs/deposits/src/lib/deposits-provider.ts | 7 +- libs/fills/src/lib/fills-data-provider.ts | 5 +- libs/fills/src/lib/use-fills-list.spec.ts | 4 +- libs/fills/src/lib/use-fills-list.ts | 5 +- .../src/lib/ledger-entries-data-provider.ts | 7 +- .../src/lib/liquidity-data-provider.ts | 5 +- .../src/lib/markets-liquidity-provider.ts | 8 +- libs/market-depth/src/lib/depth-chart.tsx | 3 +- .../src/lib/market-depth-provider.ts | 4 +- .../src/lib/orderbook-manager.tsx | 2 +- .../last-24h-price-change.tsx | 6 +- .../last-24h-volume/last-24h-volume.tsx | 6 +- .../market-info/market-info-accordion.tsx | 2 +- .../market-info/market-info-data-provider.ts | 5 +- .../market-info/market-info-panels.tsx | 2 +- .../src/hooks/use-market-oracle.spec.ts | 3 +- .../src/hooks/use-market-oracle.ts | 2 +- .../markets-container/markets-container.tsx | 2 +- .../src/lib/market-candles-provider.ts | 2 +- .../src/lib/market-data-provider.ts | 7 +- .../src/lib/markets-candles-provider.ts | 2 +- .../src/lib/markets-data-provider.ts | 6 +- libs/market-list/src/lib/markets-provider.ts | 8 +- libs/network-parameters/.babelrc | 12 +++ libs/network-parameters/.eslintrc.json | 18 +++++ libs/network-parameters/README.md | 7 ++ libs/network-parameters/jest.config.ts | 10 +++ libs/network-parameters/package.json | 4 + libs/network-parameters/project.json | 43 ++++++++++ .../src}/NetworkParams.graphql | 0 .../src}/__generated__/NetworkParams.ts | 0 libs/network-parameters/src/index.ts | 2 + .../src}/network-params.mock.ts | 0 .../src}/use-network-params.spec.tsx | 8 +- .../src}/use-network-params.ts | 0 libs/network-parameters/tsconfig.json | 25 ++++++ libs/network-parameters/tsconfig.lib.json | 23 ++++++ libs/network-parameters/tsconfig.spec.json | 20 +++++ .../lib/__generated__/OracleMarketsSpec.ts | 3 +- .../order-data-provider.spec.ts | 2 +- .../order-data-provider.ts | 4 +- .../order-list-manager.spec.tsx | 2 +- .../order-list-manager/order-list-manager.tsx | 2 +- .../order-hooks/use-has-amendable-order.ts | 2 +- .../positions/src/lib/margin-data-provider.ts | 4 +- .../src/lib/positions-data-providers.ts | 7 +- libs/positions/src/lib/use-market-margin.tsx | 2 +- libs/positions/src/lib/use-open-volume.ts | 2 +- .../src/lib/use-positions-data.spec.tsx | 4 +- libs/positions/src/lib/use-positions-data.tsx | 3 +- .../proposals-data-provider.tsx | 2 +- .../use-update-proposal.spec.ts | 4 +- .../proposals-hooks/use-update-proposal.ts | 2 +- .../lib/proposals-list/proposal-list.spec.tsx | 4 +- .../src/lib/proposals-list/proposals-list.tsx | 2 +- .../lib/proposals-list/use-column-defs.tsx | 5 +- libs/react-helpers/.eslintrc.json | 11 ++- libs/react-helpers/src/hooks/index.ts | 3 - libs/react-helpers/src/lib/index.ts | 1 - libs/trades/src/lib/trades-container.tsx | 4 +- libs/trades/src/lib/trades-data-provider.ts | 4 +- libs/utils/.eslintrc.json | 11 ++- libs/utils/src/index.ts | 3 - libs/utils/tsconfig.lib.json | 2 +- .../src/connect-dialog}/ChainId.graphql | 0 .../connect-dialog}/__generated__/ChainId.ts | 0 .../src/connect-dialog}/chain-id.mock.ts | 0 .../connect-dialog/connect-dialog.spec.tsx | 4 +- .../src/connect-dialog/connect-dialog.tsx | 2 +- libs/web3/src/lib/use-ethereum-config.ts | 2 +- ...hereum-withdraw-approvals-manager.spec.tsx | 4 +- .../src/lib/withdraw-form-container.spec.tsx | 5 +- .../src/lib/withdraw-form-container.tsx | 2 +- .../withdraws/src/lib/withdrawals-provider.ts | 7 +- package.json | 2 + tsconfig.base.json | 4 + workspace.json | 2 + yarn.lock | 80 +++++++++++++++++++ 156 files changed, 688 insertions(+), 211 deletions(-) create mode 100644 libs/data-provider/.babelrc create mode 100644 libs/data-provider/.eslintrc.json create mode 100644 libs/data-provider/README.md create mode 100644 libs/data-provider/jest.config.ts create mode 100644 libs/data-provider/package.json create mode 100644 libs/data-provider/project.json rename libs/{utils/src/lib => data-provider/src}/generic-data-provider.spec.ts (100%) rename libs/{utils/src/lib => data-provider/src}/generic-data-provider.ts (99%) rename libs/{utils/src/lib/apollo-client.ts => data-provider/src/helpers.ts} (100%) create mode 100644 libs/data-provider/src/index.ts rename libs/{utils/src/lib => data-provider/src}/pagination.ts (95%) rename libs/{react-helpers/src/hooks => data-provider/src}/use-data-provider.spec.ts (99%) rename libs/{react-helpers/src/hooks => data-provider/src}/use-data-provider.ts (97%) create mode 100644 libs/data-provider/tsconfig.json create mode 100644 libs/data-provider/tsconfig.lib.json create mode 100644 libs/data-provider/tsconfig.spec.json create mode 100644 libs/network-parameters/.babelrc create mode 100644 libs/network-parameters/.eslintrc.json create mode 100644 libs/network-parameters/README.md create mode 100644 libs/network-parameters/jest.config.ts create mode 100644 libs/network-parameters/package.json create mode 100644 libs/network-parameters/project.json rename libs/{react-helpers/src/hooks => network-parameters/src}/NetworkParams.graphql (100%) rename libs/{react-helpers/src/hooks => network-parameters/src}/__generated__/NetworkParams.ts (100%) create mode 100644 libs/network-parameters/src/index.ts rename libs/{react-helpers/src/hooks => network-parameters/src}/network-params.mock.ts (100%) rename libs/{react-helpers/src/hooks => network-parameters/src}/use-network-params.spec.tsx (94%) rename libs/{react-helpers/src/hooks => network-parameters/src}/use-network-params.ts (100%) create mode 100644 libs/network-parameters/tsconfig.json create mode 100644 libs/network-parameters/tsconfig.lib.json create mode 100644 libs/network-parameters/tsconfig.spec.json rename libs/{react-helpers/src/lib => wallet/src/connect-dialog}/ChainId.graphql (100%) rename libs/{react-helpers/src/lib => wallet/src/connect-dialog}/__generated__/ChainId.ts (100%) rename libs/{react-helpers/src/lib => wallet/src/connect-dialog}/chain-id.mock.ts (100%) diff --git a/apps/explorer/src/app/components/proposals/proposals-table.tsx b/apps/explorer/src/app/components/proposals/proposals-table.tsx index e4e092a42..c5068ba3a 100644 --- a/apps/explorer/src/app/components/proposals/proposals-table.tsx +++ b/apps/explorer/src/app/components/proposals/proposals-table.tsx @@ -12,7 +12,10 @@ import { useLayoutEffect, useMemo, useRef, useState } from 'react'; import type { RowClickedEvent } from 'ag-grid-community'; import { getDateTimeFormat } from '@vegaprotocol/utils'; import { t } from '@vegaprotocol/i18n'; -import { NetworkParams, useNetworkParams } from '@vegaprotocol/react-helpers'; +import { + NetworkParams, + useNetworkParams, +} from '@vegaprotocol/network-parameters'; import { ProposalStateMapping } from '@vegaprotocol/types'; import BigNumber from 'bignumber.js'; import { DApp, TOKEN_PROPOSAL, useLinks } from '@vegaprotocol/environment'; diff --git a/apps/explorer/src/app/routes/governance/proposals-page.tsx b/apps/explorer/src/app/routes/governance/proposals-page.tsx index b9b3271eb..d60a7bac5 100644 --- a/apps/explorer/src/app/routes/governance/proposals-page.tsx +++ b/apps/explorer/src/app/routes/governance/proposals-page.tsx @@ -1,6 +1,6 @@ import { proposalsDataProvider } from '@vegaprotocol/proposals'; import { t } from '@vegaprotocol/i18n'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; import { ProposalsTable } from '../../components/proposals/proposals-table'; import { RouteTitle } from '../../components/route-title'; diff --git a/apps/explorer/src/app/routes/markets/market-page.tsx b/apps/explorer/src/app/routes/markets/market-page.tsx index e13d0205c..7161145af 100644 --- a/apps/explorer/src/app/routes/markets/market-page.tsx +++ b/apps/explorer/src/app/routes/markets/market-page.tsx @@ -1,5 +1,5 @@ import { t } from '@vegaprotocol/i18n'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { AsyncRenderer, Button } from '@vegaprotocol/ui-toolkit'; import { useState } from 'react'; import { useParams } from 'react-router-dom'; diff --git a/apps/explorer/src/app/routes/markets/markets-page.tsx b/apps/explorer/src/app/routes/markets/markets-page.tsx index 01080b3a4..e9398a233 100644 --- a/apps/explorer/src/app/routes/markets/markets-page.tsx +++ b/apps/explorer/src/app/routes/markets/markets-page.tsx @@ -4,7 +4,7 @@ import { marketsProvider } from '@vegaprotocol/market-list'; import { RouteTitle } from '../../components/route-title'; import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; import { t } from '@vegaprotocol/i18n'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { MarketsTable } from '../../components/markets/markets-table'; export const MarketsPage = () => { diff --git a/apps/explorer/src/app/routes/network-parameters/network-parameters.spec.tsx b/apps/explorer/src/app/routes/network-parameters/network-parameters.spec.tsx index 67176d0a4..933f1224d 100644 --- a/apps/explorer/src/app/routes/network-parameters/network-parameters.spec.tsx +++ b/apps/explorer/src/app/routes/network-parameters/network-parameters.spec.tsx @@ -1,5 +1,5 @@ import { render, screen } from '@testing-library/react'; -import type { NetworkParamsQuery } from '@vegaprotocol/react-helpers'; +import type { NetworkParamsQuery } from '@vegaprotocol/network-parameters'; import { NetworkParametersTable } from './network-parameters'; describe('NetworkParametersTable', () => { diff --git a/apps/explorer/src/app/routes/network-parameters/network-parameters.tsx b/apps/explorer/src/app/routes/network-parameters/network-parameters.tsx index 265365d77..84bffe631 100644 --- a/apps/explorer/src/app/routes/network-parameters/network-parameters.tsx +++ b/apps/explorer/src/app/routes/network-parameters/network-parameters.tsx @@ -13,8 +13,8 @@ import { import { t } from '@vegaprotocol/i18n'; import { RouteTitle } from '../../components/route-title'; import orderBy from 'lodash/orderBy'; -import { useNetworkParamsQuery } from '@vegaprotocol/react-helpers'; -import type { NetworkParamsQuery } from '@vegaprotocol/react-helpers'; +import { useNetworkParamsQuery } from '@vegaprotocol/network-parameters'; +import type { NetworkParamsQuery } from '@vegaprotocol/network-parameters'; import { useScrollToLocation } from '../../hooks/scroll-to-location'; import { useDocumentTitle } from '../../hooks/use-document-title'; diff --git a/apps/governance/src/routes/proposals/components/current-proposal-status/current-proposal-status.spec.tsx b/apps/governance/src/routes/proposals/components/current-proposal-status/current-proposal-status.spec.tsx index 3841d760d..719b910ca 100644 --- a/apps/governance/src/routes/proposals/components/current-proposal-status/current-proposal-status.spec.tsx +++ b/apps/governance/src/routes/proposals/components/current-proposal-status/current-proposal-status.spec.tsx @@ -2,8 +2,8 @@ import type { MockedResponse } from '@apollo/client/testing'; import { MockedProvider } from '@apollo/client/testing'; import { render, screen } from '@testing-library/react'; import { ProposalRejectionReason, ProposalState } from '@vegaprotocol/types'; -import type { NetworkParamsQuery } from '@vegaprotocol/react-helpers'; -import { NetworkParamsDocument } from '@vegaprotocol/react-helpers'; +import type { NetworkParamsQuery } from '@vegaprotocol/network-parameters'; +import { NetworkParamsDocument } from '@vegaprotocol/network-parameters'; import { AppStateProvider } from '../../../../contexts/app-state/app-state-provider'; import { generateProposal } from '../../test-helpers/generate-proposals'; import { CurrentProposalStatus } from './current-proposal-status'; diff --git a/apps/governance/src/routes/proposals/components/proposal/proposal.spec.tsx b/apps/governance/src/routes/proposals/components/proposal/proposal.spec.tsx index 70c8da410..95d20400d 100644 --- a/apps/governance/src/routes/proposals/components/proposal/proposal.spec.tsx +++ b/apps/governance/src/routes/proposals/components/proposal/proposal.spec.tsx @@ -3,8 +3,8 @@ import { generateProposal } from '../../test-helpers/generate-proposals'; import { Proposal } from './proposal'; import type { ProposalQuery } from '../../proposal/__generated__/Proposal'; -jest.mock('@vegaprotocol/react-helpers', () => ({ - ...jest.requireActual('@vegaprotocol/react-helpers'), +jest.mock('@vegaprotocol/network-parameters', () => ({ + ...jest.requireActual('@vegaprotocol/network-parameters'), useNetworkParams: jest.fn(() => ({ params: { governance_proposal_asset_minVoterBalance: '1', diff --git a/apps/governance/src/routes/proposals/components/proposal/proposal.tsx b/apps/governance/src/routes/proposals/components/proposal/proposal.tsx index c9518a9de..e0aa51190 100644 --- a/apps/governance/src/routes/proposals/components/proposal/proposal.tsx +++ b/apps/governance/src/routes/proposals/components/proposal/proposal.tsx @@ -1,4 +1,7 @@ -import { NetworkParams, useNetworkParams } from '@vegaprotocol/react-helpers'; +import { + NetworkParams, + useNetworkParams, +} from '@vegaprotocol/network-parameters'; import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; import { ProposalHeader } from '../proposal-detail-header/proposal-header'; import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals'; diff --git a/apps/governance/src/routes/proposals/hooks/use-proposal-network-params.spec.ts b/apps/governance/src/routes/proposals/hooks/use-proposal-network-params.spec.ts index 627a16c92..ff3e1da21 100644 --- a/apps/governance/src/routes/proposals/hooks/use-proposal-network-params.spec.ts +++ b/apps/governance/src/routes/proposals/hooks/use-proposal-network-params.spec.ts @@ -3,8 +3,8 @@ import { BigNumber } from '../../../lib/bignumber'; import { useProposalNetworkParams } from './use-proposal-network-params'; import { generateProposal } from '../test-helpers/generate-proposals'; -jest.mock('@vegaprotocol/react-helpers', () => ({ - ...jest.requireActual('@vegaprotocol/react-helpers'), +jest.mock('@vegaprotocol/network-parameters', () => ({ + ...jest.requireActual('@vegaprotocol/network-parameters'), useNetworkParams: jest.fn(() => ({ params: { governance_proposal_updateMarket_requiredMajority: '0.1', diff --git a/apps/governance/src/routes/proposals/hooks/use-proposal-network-params.ts b/apps/governance/src/routes/proposals/hooks/use-proposal-network-params.ts index cdeb7d78f..1b84b688d 100644 --- a/apps/governance/src/routes/proposals/hooks/use-proposal-network-params.ts +++ b/apps/governance/src/routes/proposals/hooks/use-proposal-network-params.ts @@ -1,4 +1,7 @@ -import { NetworkParams, useNetworkParams } from '@vegaprotocol/react-helpers'; +import { + NetworkParams, + useNetworkParams, +} from '@vegaprotocol/network-parameters'; import { BigNumber } from '../../../lib/bignumber'; import type { ProposalFieldsFragment } from '../proposals/__generated__/Proposals'; import type { ProposalQuery } from '../proposal/__generated__/Proposal'; diff --git a/apps/governance/src/routes/proposals/hooks/use-vote-information.spec.ts b/apps/governance/src/routes/proposals/hooks/use-vote-information.spec.ts index c79bc73fc..95392e14c 100644 --- a/apps/governance/src/routes/proposals/hooks/use-vote-information.spec.ts +++ b/apps/governance/src/routes/proposals/hooks/use-vote-information.spec.ts @@ -28,8 +28,8 @@ jest.mock('../../../contexts/app-state/app-state-context', () => ({ }), })); -jest.mock('@vegaprotocol/react-helpers', () => ({ - ...jest.requireActual('@vegaprotocol/react-helpers'), +jest.mock('@vegaprotocol/network-parameters', () => ({ + ...jest.requireActual('@vegaprotocol/network-parameters'), useNetworkParams: jest.fn(() => ({ params: { governance_proposal_updateMarket_requiredMajority: '0.5', diff --git a/apps/governance/src/routes/proposals/propose/freeform/propose-freeform.spec.tsx b/apps/governance/src/routes/proposals/propose/freeform/propose-freeform.spec.tsx index 530404033..4f206e056 100644 --- a/apps/governance/src/routes/proposals/propose/freeform/propose-freeform.spec.tsx +++ b/apps/governance/src/routes/proposals/propose/freeform/propose-freeform.spec.tsx @@ -5,9 +5,9 @@ import { mockWalletContext } from '../../test-helpers/mocks'; import { AppStateProvider } from '../../../../contexts/app-state/app-state-provider'; import { VegaWalletContext } from '@vegaprotocol/wallet'; import { MemoryRouter as Router } from 'react-router-dom'; -import type { NetworkParamsQuery } from '@vegaprotocol/react-helpers'; +import type { NetworkParamsQuery } from '@vegaprotocol/network-parameters'; import type { MockedResponse } from '@apollo/client/testing'; -import { NetworkParamsDocument } from '@vegaprotocol/react-helpers'; +import { NetworkParamsDocument } from '@vegaprotocol/network-parameters'; jest.mock('@vegaprotocol/environment', () => ({ useEnvironment: () => ({ diff --git a/apps/governance/src/routes/proposals/propose/freeform/propose-freeform.tsx b/apps/governance/src/routes/proposals/propose/freeform/propose-freeform.tsx index 18f837d06..7e4574746 100644 --- a/apps/governance/src/routes/proposals/propose/freeform/propose-freeform.tsx +++ b/apps/governance/src/routes/proposals/propose/freeform/propose-freeform.tsx @@ -19,7 +19,10 @@ import { ProposalMinRequirements } from '../../components/shared'; import { AsyncRenderer, ExternalLink } from '@vegaprotocol/ui-toolkit'; import { Heading } from '../../../../components/heading'; import { createDocsLinks } from '@vegaprotocol/utils'; -import { NetworkParams, useNetworkParams } from '@vegaprotocol/react-helpers'; +import { + NetworkParams, + useNetworkParams, +} from '@vegaprotocol/network-parameters'; import { ProposalUserAction } from '../../components/shared'; import { downloadJson } from '../../../../lib/download-json'; diff --git a/apps/governance/src/routes/proposals/propose/network-parameter/propose-network-parameter.spec.tsx b/apps/governance/src/routes/proposals/propose/network-parameter/propose-network-parameter.spec.tsx index 2afe71cd6..39b0f18a8 100644 --- a/apps/governance/src/routes/proposals/propose/network-parameter/propose-network-parameter.spec.tsx +++ b/apps/governance/src/routes/proposals/propose/network-parameter/propose-network-parameter.spec.tsx @@ -5,8 +5,8 @@ import { mockWalletContext } from '../../test-helpers/mocks'; import { AppStateProvider } from '../../../../contexts/app-state/app-state-provider'; import { VegaWalletContext } from '@vegaprotocol/wallet'; import { MemoryRouter as Router } from 'react-router-dom'; -import type { NetworkParamsQuery } from '@vegaprotocol/react-helpers'; -import { NetworkParamsDocument } from '@vegaprotocol/react-helpers'; +import type { NetworkParamsQuery } from '@vegaprotocol/network-parameters'; +import { NetworkParamsDocument } from '@vegaprotocol/network-parameters'; import type { MockedResponse } from '@apollo/client/testing'; jest.mock('@vegaprotocol/environment', () => ({ diff --git a/apps/governance/src/routes/proposals/propose/network-parameter/propose-network-parameter.tsx b/apps/governance/src/routes/proposals/propose/network-parameter/propose-network-parameter.tsx index eaa57e9ba..b13a47085 100644 --- a/apps/governance/src/routes/proposals/propose/network-parameter/propose-network-parameter.tsx +++ b/apps/governance/src/routes/proposals/propose/network-parameter/propose-network-parameter.tsx @@ -5,7 +5,7 @@ import { createDocsLinks, suitableForSyntaxHighlighter, } from '@vegaprotocol/utils'; -import { useNetworkParams } from '@vegaprotocol/react-helpers'; +import { useNetworkParams } from '@vegaprotocol/network-parameters'; import { getClosingTimestamp, getEnactmentTimestamp, diff --git a/apps/governance/src/routes/proposals/propose/new-asset/propose-new-asset.spec.tsx b/apps/governance/src/routes/proposals/propose/new-asset/propose-new-asset.spec.tsx index d82474862..567891b8c 100644 --- a/apps/governance/src/routes/proposals/propose/new-asset/propose-new-asset.spec.tsx +++ b/apps/governance/src/routes/proposals/propose/new-asset/propose-new-asset.spec.tsx @@ -5,9 +5,9 @@ import { VegaWalletContext } from '@vegaprotocol/wallet'; import { AppStateProvider } from '../../../../contexts/app-state/app-state-provider'; import { mockWalletContext } from '../../test-helpers/mocks'; import { ProposeNewAsset } from './propose-new-asset'; -import type { NetworkParamsQuery } from '@vegaprotocol/react-helpers'; +import type { NetworkParamsQuery } from '@vegaprotocol/network-parameters'; import type { MockedResponse } from '@apollo/client/testing'; -import { NetworkParamsDocument } from '@vegaprotocol/react-helpers'; +import { NetworkParamsDocument } from '@vegaprotocol/network-parameters'; jest.mock('@vegaprotocol/environment', () => ({ useEnvironment: () => ({ diff --git a/apps/governance/src/routes/proposals/propose/new-asset/propose-new-asset.tsx b/apps/governance/src/routes/proposals/propose/new-asset/propose-new-asset.tsx index 77bde4964..cf621bf2d 100644 --- a/apps/governance/src/routes/proposals/propose/new-asset/propose-new-asset.tsx +++ b/apps/governance/src/routes/proposals/propose/new-asset/propose-new-asset.tsx @@ -9,7 +9,10 @@ import { } from '@vegaprotocol/proposals'; import { useEnvironment } from '@vegaprotocol/environment'; import { createDocsLinks, validateJson } from '@vegaprotocol/utils'; -import { NetworkParams, useNetworkParams } from '@vegaprotocol/react-helpers'; +import { + NetworkParams, + useNetworkParams, +} from '@vegaprotocol/network-parameters'; import { ProposalFormDescription, ProposalFormSubheader, diff --git a/apps/governance/src/routes/proposals/propose/new-market/propose-new-market.spec.tsx b/apps/governance/src/routes/proposals/propose/new-market/propose-new-market.spec.tsx index 1c0cd6f03..8210fe010 100644 --- a/apps/governance/src/routes/proposals/propose/new-market/propose-new-market.spec.tsx +++ b/apps/governance/src/routes/proposals/propose/new-market/propose-new-market.spec.tsx @@ -6,8 +6,8 @@ import { AppStateProvider } from '../../../../contexts/app-state/app-state-provi import { VegaWalletContext } from '@vegaprotocol/wallet'; import { BrowserRouter as Router } from 'react-router-dom'; import type { MockedResponse } from '@apollo/client/testing'; -import type { NetworkParamsQuery } from '@vegaprotocol/react-helpers'; -import { NetworkParamsDocument } from '@vegaprotocol/react-helpers'; +import type { NetworkParamsQuery } from '@vegaprotocol/network-parameters'; +import { NetworkParamsDocument } from '@vegaprotocol/network-parameters'; jest.mock('@vegaprotocol/environment', () => ({ useEnvironment: () => ({ diff --git a/apps/governance/src/routes/proposals/propose/new-market/propose-new-market.tsx b/apps/governance/src/routes/proposals/propose/new-market/propose-new-market.tsx index d67f75f36..013c444ca 100644 --- a/apps/governance/src/routes/proposals/propose/new-market/propose-new-market.tsx +++ b/apps/governance/src/routes/proposals/propose/new-market/propose-new-market.tsx @@ -8,7 +8,10 @@ import { } from '@vegaprotocol/proposals'; import { useEnvironment } from '@vegaprotocol/environment'; import { createDocsLinks, validateJson } from '@vegaprotocol/utils'; -import { NetworkParams, useNetworkParams } from '@vegaprotocol/react-helpers'; +import { + NetworkParams, + useNetworkParams, +} from '@vegaprotocol/network-parameters'; import { ProposalFormDescription, ProposalFormSubheader, diff --git a/apps/governance/src/routes/proposals/propose/raw/proposal-raw.spec.tsx b/apps/governance/src/routes/proposals/propose/raw/proposal-raw.spec.tsx index 4e6e7d026..f9b65c8ca 100644 --- a/apps/governance/src/routes/proposals/propose/raw/proposal-raw.spec.tsx +++ b/apps/governance/src/routes/proposals/propose/raw/proposal-raw.spec.tsx @@ -10,8 +10,8 @@ import { ProposeRaw } from './propose-raw'; import { ProposalEventDocument } from '@vegaprotocol/proposals'; import type { ProposalEventSubscription } from '@vegaprotocol/proposals'; -import type { NetworkParamsQuery } from '@vegaprotocol/react-helpers'; -import { NetworkParamsDocument } from '@vegaprotocol/react-helpers'; +import type { NetworkParamsQuery } from '@vegaprotocol/network-parameters'; +import { NetworkParamsDocument } from '@vegaprotocol/network-parameters'; const paramsDelay = 20; diff --git a/apps/governance/src/routes/proposals/propose/raw/propose-raw.tsx b/apps/governance/src/routes/proposals/propose/raw/propose-raw.tsx index 9485ccb84..7b0fd7004 100644 --- a/apps/governance/src/routes/proposals/propose/raw/propose-raw.tsx +++ b/apps/governance/src/routes/proposals/propose/raw/propose-raw.tsx @@ -10,7 +10,10 @@ import { TextArea, } from '@vegaprotocol/ui-toolkit'; import { createDocsLinks, validateJson } from '@vegaprotocol/utils'; -import { NetworkParams, useNetworkParams } from '@vegaprotocol/react-helpers'; +import { + NetworkParams, + useNetworkParams, +} from '@vegaprotocol/network-parameters'; import { useProposalSubmit } from '@vegaprotocol/proposals'; import { ProposalFormSubmit, diff --git a/apps/governance/src/routes/proposals/propose/update-asset/propose-update-asset.spec.tsx b/apps/governance/src/routes/proposals/propose/update-asset/propose-update-asset.spec.tsx index cd86a9994..922847350 100644 --- a/apps/governance/src/routes/proposals/propose/update-asset/propose-update-asset.spec.tsx +++ b/apps/governance/src/routes/proposals/propose/update-asset/propose-update-asset.spec.tsx @@ -5,9 +5,9 @@ import { VegaWalletContext } from '@vegaprotocol/wallet'; import { AppStateProvider } from '../../../../contexts/app-state/app-state-provider'; import { mockWalletContext } from '../../test-helpers/mocks'; import { ProposeUpdateAsset } from './propose-update-asset'; -import type { NetworkParamsQuery } from '@vegaprotocol/react-helpers'; +import type { NetworkParamsQuery } from '@vegaprotocol/network-parameters'; import type { MockedResponse } from '@apollo/client/testing'; -import { NetworkParamsDocument } from '@vegaprotocol/react-helpers'; +import { NetworkParamsDocument } from '@vegaprotocol/network-parameters'; jest.mock('@vegaprotocol/environment', () => ({ useEnvironment: () => ({ diff --git a/apps/governance/src/routes/proposals/propose/update-asset/propose-update-asset.tsx b/apps/governance/src/routes/proposals/propose/update-asset/propose-update-asset.tsx index e6a825e45..0bbed4234 100644 --- a/apps/governance/src/routes/proposals/propose/update-asset/propose-update-asset.tsx +++ b/apps/governance/src/routes/proposals/propose/update-asset/propose-update-asset.tsx @@ -8,7 +8,10 @@ import { } from '@vegaprotocol/proposals'; import { useEnvironment } from '@vegaprotocol/environment'; import { createDocsLinks, validateJson } from '@vegaprotocol/utils'; -import { NetworkParams, useNetworkParams } from '@vegaprotocol/react-helpers'; +import { + NetworkParams, + useNetworkParams, +} from '@vegaprotocol/network-parameters'; import { ProposalFormDescription, ProposalFormSubheader, diff --git a/apps/governance/src/routes/proposals/propose/update-market/propose-update-market.spec.tsx b/apps/governance/src/routes/proposals/propose/update-market/propose-update-market.spec.tsx index 23506cc0f..2749544b5 100644 --- a/apps/governance/src/routes/proposals/propose/update-market/propose-update-market.spec.tsx +++ b/apps/governance/src/routes/proposals/propose/update-market/propose-update-market.spec.tsx @@ -6,8 +6,8 @@ import { VegaWalletContext } from '@vegaprotocol/wallet'; import { AppStateProvider } from '../../../../contexts/app-state/app-state-provider'; import { mockWalletContext } from '../../test-helpers/mocks'; import { ProposeUpdateMarket } from './propose-update-market'; -import type { NetworkParamsQuery } from '@vegaprotocol/react-helpers'; -import { NetworkParamsDocument } from '@vegaprotocol/react-helpers'; +import type { NetworkParamsQuery } from '@vegaprotocol/network-parameters'; +import { NetworkParamsDocument } from '@vegaprotocol/network-parameters'; import type { ProposalMarketsQueryQuery } from './__generated__/UpdateMarket'; import { ProposalMarketsQueryDocument } from './__generated__/UpdateMarket'; import { ProposalState } from '@vegaprotocol/types'; diff --git a/apps/governance/src/routes/proposals/propose/update-market/propose-update-market.tsx b/apps/governance/src/routes/proposals/propose/update-market/propose-update-market.tsx index 08732f8fb..4d1bbd1b8 100644 --- a/apps/governance/src/routes/proposals/propose/update-market/propose-update-market.tsx +++ b/apps/governance/src/routes/proposals/propose/update-market/propose-update-market.tsx @@ -9,7 +9,10 @@ import { } from '@vegaprotocol/proposals'; import { useEnvironment } from '@vegaprotocol/environment'; import { createDocsLinks, validateJson } from '@vegaprotocol/utils'; -import { NetworkParams, useNetworkParams } from '@vegaprotocol/react-helpers'; +import { + NetworkParams, + useNetworkParams, +} from '@vegaprotocol/network-parameters'; import { ProposalFormDescription, ProposalFormDownloadJson, diff --git a/apps/governance/src/routes/proposals/test-helpers/mocks.ts b/apps/governance/src/routes/proposals/test-helpers/mocks.ts index abb233013..bead8e64d 100644 --- a/apps/governance/src/routes/proposals/test-helpers/mocks.ts +++ b/apps/governance/src/routes/proposals/test-helpers/mocks.ts @@ -1,6 +1,6 @@ -import { NetworkParamsDocument } from '@vegaprotocol/react-helpers'; +import { NetworkParamsDocument } from '@vegaprotocol/network-parameters'; import type { MockedResponse } from '@apollo/client/testing'; -import type { NetworkParamsQuery } from '@vegaprotocol/react-helpers'; +import type { NetworkParamsQuery } from '@vegaprotocol/network-parameters'; import type { PubKey } from '@vegaprotocol/wallet'; export const mockPubkey: PubKey = { diff --git a/apps/governance/src/routes/rewards/home/rewards-page.tsx b/apps/governance/src/routes/rewards/home/rewards-page.tsx index d0e92bdc5..79ac560d9 100644 --- a/apps/governance/src/routes/rewards/home/rewards-page.tsx +++ b/apps/governance/src/routes/rewards/home/rewards-page.tsx @@ -12,7 +12,10 @@ import { } from '@vegaprotocol/ui-toolkit'; import { useVegaWallet } from '@vegaprotocol/wallet'; import { createDocsLinks } from '@vegaprotocol/utils'; -import { useNetworkParams, NetworkParams } from '@vegaprotocol/react-helpers'; +import { + useNetworkParams, + NetworkParams, +} from '@vegaprotocol/network-parameters'; import { useEpochQuery } from './__generated__/Rewards'; import { EpochCountdown } from '../../../components/epoch-countdown'; import { Heading, SubHeading } from '../../../components/heading'; diff --git a/apps/governance/src/routes/staking/node/staking-form.tsx b/apps/governance/src/routes/staking/node/staking-form.tsx index 012fcaaa0..518a9fbf6 100644 --- a/apps/governance/src/routes/staking/node/staking-form.tsx +++ b/apps/governance/src/routes/staking/node/staking-form.tsx @@ -23,7 +23,10 @@ import { addDecimal, removePaginationWrapper, } from '@vegaprotocol/utils'; -import { useNetworkParam, NetworkParams } from '@vegaprotocol/react-helpers'; +import { + useNetworkParam, + NetworkParams, +} from '@vegaprotocol/network-parameters'; import { useBalances } from '../../../lib/balances/balances-store'; import { useVegaWallet } from '@vegaprotocol/wallet'; import { SubHeading } from '../../../components/heading'; diff --git a/apps/governance/src/routes/withdrawals/index.tsx b/apps/governance/src/routes/withdrawals/index.tsx index f4548961c..4cbb068f9 100644 --- a/apps/governance/src/routes/withdrawals/index.tsx +++ b/apps/governance/src/routes/withdrawals/index.tsx @@ -10,7 +10,7 @@ import { WithdrawalsTable, } from '@vegaprotocol/withdraws'; import { useVegaWallet } from '@vegaprotocol/wallet'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { useDocumentTitle } from '../../hooks/use-document-title'; import type { RouteChildProps } from '../index'; diff --git a/apps/liquidity-provision-dashboard/src/app/components/detail/detail.tsx b/apps/liquidity-provision-dashboard/src/app/components/detail/detail.tsx index cff644a3f..7a198d38e 100644 --- a/apps/liquidity-provision-dashboard/src/app/components/detail/detail.tsx +++ b/apps/liquidity-provision-dashboard/src/app/components/detail/detail.tsx @@ -1,7 +1,7 @@ import { useParams } from 'react-router-dom'; -import { makeDerivedDataProvider } from '@vegaprotocol/utils'; +import { makeDerivedDataProvider } from '@vegaprotocol/data-provider'; import { t } from '@vegaprotocol/i18n'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; import { diff --git a/apps/liquidity-provision-dashboard/src/app/components/detail/last-24h-volume/last-24h-volume.tsx b/apps/liquidity-provision-dashboard/src/app/components/detail/last-24h-volume/last-24h-volume.tsx index 3056b50fa..1e9ddb059 100644 --- a/apps/liquidity-provision-dashboard/src/app/components/detail/last-24h-volume/last-24h-volume.tsx +++ b/apps/liquidity-provision-dashboard/src/app/components/detail/last-24h-volume/last-24h-volume.tsx @@ -1,7 +1,8 @@ import { useState, useMemo, useRef, useCallback } from 'react'; import throttle from 'lodash/throttle'; import { addDecimalsFormatNumber } from '@vegaprotocol/utils'; -import { useYesterday, useDataProvider } from '@vegaprotocol/react-helpers'; +import { useYesterday } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import * as Schema from '@vegaprotocol/types'; import { calcDayVolume, diff --git a/apps/trading/client-pages/home/home.tsx b/apps/trading/client-pages/home/home.tsx index fdaed68a5..035d92e2b 100644 --- a/apps/trading/client-pages/home/home.tsx +++ b/apps/trading/client-pages/home/home.tsx @@ -1,7 +1,7 @@ import { useEffect } from 'react'; import { useNavigate } from 'react-router-dom'; import { marketsWithDataProvider } from '@vegaprotocol/market-list'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; import { Links, Routes } from '../../pages/client-router'; import { useGlobalStore } from '../../stores'; diff --git a/apps/trading/client-pages/liquidity/liquidity.tsx b/apps/trading/client-pages/liquidity/liquidity.tsx index bd49dc81d..20dfc86e2 100644 --- a/apps/trading/client-pages/liquidity/liquidity.tsx +++ b/apps/trading/client-pages/liquidity/liquidity.tsx @@ -12,12 +12,12 @@ import { formatNumberPercentage, } from '@vegaprotocol/utils'; import { t } from '@vegaprotocol/i18n'; +import { updateGridData } from '@vegaprotocol/react-helpers'; import { NetworkParams, - useDataProvider, useNetworkParams, - updateGridData, -} from '@vegaprotocol/react-helpers'; +} from '@vegaprotocol/network-parameters'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { AsyncRenderer, Tab, diff --git a/apps/trading/client-pages/market/market.tsx b/apps/trading/client-pages/market/market.tsx index fb7f4f30d..501892022 100644 --- a/apps/trading/client-pages/market/market.tsx +++ b/apps/trading/client-pages/market/market.tsx @@ -1,11 +1,11 @@ import React, { useEffect, useMemo } from 'react'; import { addDecimalsFormatNumber, titlefy } from '@vegaprotocol/utils'; import { t } from '@vegaprotocol/i18n'; +import { useScreenDimensions } from '@vegaprotocol/react-helpers'; import { useDataProvider, - useScreenDimensions, useThrottledDataProvider, -} from '@vegaprotocol/react-helpers'; +} from '@vegaprotocol/data-provider'; import { AsyncRenderer, ExternalLink, Splash } from '@vegaprotocol/ui-toolkit'; import { marketProvider, marketDataProvider } from '@vegaprotocol/market-list'; import { useGlobalStore, usePageTitleStore } from '../../stores'; diff --git a/apps/trading/client-pages/markets/closed.tsx b/apps/trading/client-pages/markets/closed.tsx index 6c81e10c4..de704f8f5 100644 --- a/apps/trading/client-pages/markets/closed.tsx +++ b/apps/trading/client-pages/markets/closed.tsx @@ -20,7 +20,7 @@ import { useAssetDetailsDialogStore } from '@vegaprotocol/assets'; import type { ColDef } from 'ag-grid-community'; import { SettlementDateCell } from './settlement-date-cell'; import { SettlementPriceCell } from './settlement-price-cell'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; type SettlementAsset = diff --git a/apps/trading/client-pages/portfolio/account-history-container.tsx b/apps/trading/client-pages/portfolio/account-history-container.tsx index baa1e7bc4..715d02d3e 100644 --- a/apps/trading/client-pages/portfolio/account-history-container.tsx +++ b/apps/trading/client-pages/portfolio/account-history-container.tsx @@ -24,7 +24,8 @@ import { PriceChart } from 'pennant'; import 'pennant/dist/style.css'; import type { Account } from '@vegaprotocol/accounts'; import { accountsDataProvider } from '@vegaprotocol/accounts'; -import { useDataProvider, useThemeSwitcher } from '@vegaprotocol/react-helpers'; +import { useThemeSwitcher } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import type { Market } from '@vegaprotocol/market-list'; const DateRange = { diff --git a/apps/trading/client-pages/portfolio/deposits-container.tsx b/apps/trading/client-pages/portfolio/deposits-container.tsx index b73bb9d5c..37679dcb7 100644 --- a/apps/trading/client-pages/portfolio/deposits-container.tsx +++ b/apps/trading/client-pages/portfolio/deposits-container.tsx @@ -2,10 +2,8 @@ import { AsyncRenderer, Button } from '@vegaprotocol/ui-toolkit'; import { useDepositDialog, DepositsTable } from '@vegaprotocol/deposits'; import { depositsProvider } from '@vegaprotocol/deposits'; import { t } from '@vegaprotocol/i18n'; -import { - useDataProvider, - useBottomPlaceholder, -} from '@vegaprotocol/react-helpers'; +import { useBottomPlaceholder } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { useVegaWallet } from '@vegaprotocol/wallet'; import { useRef } from 'react'; import type { AgGridReact } from 'ag-grid-react'; diff --git a/apps/trading/client-pages/portfolio/withdrawals-container.tsx b/apps/trading/client-pages/portfolio/withdrawals-container.tsx index 4168ac6a4..8edfc0da1 100644 --- a/apps/trading/client-pages/portfolio/withdrawals-container.tsx +++ b/apps/trading/client-pages/portfolio/withdrawals-container.tsx @@ -6,7 +6,7 @@ import { } from '@vegaprotocol/withdraws'; import { useVegaWallet } from '@vegaprotocol/wallet'; import { t } from '@vegaprotocol/i18n'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { VegaWalletContainer } from '../../components/vega-wallet-container'; export const WithdrawalsContainer = () => { diff --git a/apps/trading/components/liquidity-supplied/liquidity-supplied.tsx b/apps/trading/components/liquidity-supplied/liquidity-supplied.tsx index b33d25521..0771cbdc9 100644 --- a/apps/trading/components/liquidity-supplied/liquidity-supplied.tsx +++ b/apps/trading/components/liquidity-supplied/liquidity-supplied.tsx @@ -1,9 +1,9 @@ import { useCallback, useMemo, useState } from 'react'; import { NetworkParams, - useDataProvider, useNetworkParams, -} from '@vegaprotocol/react-helpers'; +} from '@vegaprotocol/network-parameters'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import type { MarketData } from '@vegaprotocol/market-list'; import { marketDataProvider, marketProvider } from '@vegaprotocol/market-list'; import { HeaderStat } from '../header'; diff --git a/apps/trading/components/market-mark-price/market-mark-price.tsx b/apps/trading/components/market-mark-price/market-mark-price.tsx index 5f65eb2f9..249c8c5af 100644 --- a/apps/trading/components/market-mark-price/market-mark-price.tsx +++ b/apps/trading/components/market-mark-price/market-mark-price.tsx @@ -1,7 +1,7 @@ import type { RefObject } from 'react'; import { useInView } from 'react-intersection-observer'; import { addDecimalsFormatNumber, isNumeric } from '@vegaprotocol/utils'; -import { useThrottledDataProvider } from '@vegaprotocol/react-helpers'; +import { useThrottledDataProvider } from '@vegaprotocol/data-provider'; import { PriceCell } from '@vegaprotocol/datagrid'; import { marketDataProvider } from '@vegaprotocol/market-list'; import { THROTTLE_UPDATE_TIME } from '../constants'; diff --git a/apps/trading/components/market-state/market-state.tsx b/apps/trading/components/market-state/market-state.tsx index 184856e1d..2c4a5900d 100644 --- a/apps/trading/components/market-state/market-state.tsx +++ b/apps/trading/components/market-state/market-state.tsx @@ -2,7 +2,7 @@ import throttle from 'lodash/throttle'; import type { MarketData, Market } from '@vegaprotocol/market-list'; import { marketDataProvider } from '@vegaprotocol/market-list'; import { t } from '@vegaprotocol/i18n'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import * as Schema from '@vegaprotocol/types'; import { HeaderStat } from '../header'; import { useCallback, useRef, useState } from 'react'; diff --git a/apps/trading/components/market-volume/market-volume.tsx b/apps/trading/components/market-volume/market-volume.tsx index 603dfeaa9..73f5e9bc1 100644 --- a/apps/trading/components/market-volume/market-volume.tsx +++ b/apps/trading/components/market-volume/market-volume.tsx @@ -2,7 +2,7 @@ import { useCallback, useRef, useState } from 'react'; import throttle from 'lodash/throttle'; import { addDecimalsFormatNumber } from '@vegaprotocol/utils'; import { t } from '@vegaprotocol/i18n'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import type { MarketData } from '@vegaprotocol/market-list'; import { marketDataProvider, marketProvider } from '@vegaprotocol/market-list'; import { HeaderStat } from '../header'; diff --git a/apps/trading/components/select-market/select-market.tsx b/apps/trading/components/select-market/select-market.tsx index 2a0ede834..e5bd07b30 100644 --- a/apps/trading/components/select-market/select-market.tsx +++ b/apps/trading/components/select-market/select-market.tsx @@ -3,7 +3,7 @@ import type { RefObject } from 'react'; import { useMarketList } from '@vegaprotocol/market-list'; import { positionsDataProvider } from '@vegaprotocol/positions'; import { t } from '@vegaprotocol/i18n'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { ExternalLink, Icon, Loader, Popover } from '@vegaprotocol/ui-toolkit'; import { useVegaWallet } from '@vegaprotocol/wallet'; import { diff --git a/apps/trading/components/welcome-dialog/proposed-markets.tsx b/apps/trading/components/welcome-dialog/proposed-markets.tsx index fbeacfe09..407e51e0d 100644 --- a/apps/trading/components/welcome-dialog/proposed-markets.tsx +++ b/apps/trading/components/welcome-dialog/proposed-markets.tsx @@ -1,6 +1,6 @@ import { useMemo } from 'react'; import { t } from '@vegaprotocol/i18n'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { proposalsDataProvider } from '@vegaprotocol/proposals'; import take from 'lodash/take'; import * as Types from '@vegaprotocol/types'; diff --git a/apps/trading/components/welcome-dialog/welcome-dialog.tsx b/apps/trading/components/welcome-dialog/welcome-dialog.tsx index dd48ed2eb..9fe62cdb9 100644 --- a/apps/trading/components/welcome-dialog/welcome-dialog.tsx +++ b/apps/trading/components/welcome-dialog/welcome-dialog.tsx @@ -2,7 +2,8 @@ import React, { useCallback } from 'react'; import { useLocation } from 'react-router-dom'; import { Dialog } from '@vegaprotocol/ui-toolkit'; import { t } from '@vegaprotocol/i18n'; -import { useDataProvider, useLocalStorage } from '@vegaprotocol/react-helpers'; +import { useLocalStorage } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { activeMarketsProvider } from '@vegaprotocol/market-list'; import * as constants from '../constants'; import { RiskNoticeDialog } from './risk-notice-dialog'; diff --git a/apps/trading/pages/_app.page.tsx b/apps/trading/pages/_app.page.tsx index de6a6c211..05c86867e 100644 --- a/apps/trading/pages/_app.page.tsx +++ b/apps/trading/pages/_app.page.tsx @@ -34,7 +34,7 @@ import { AnnouncementBanner } from '../components/banner'; import { AppLoader, DynamicLoader } from '../components/app-loader'; import { Navbar } from '../components/navbar'; import { ENV } from '../lib/config'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { activeOrdersProvider, allOrdersProvider } from '@vegaprotocol/orders'; import { useTelemetryApproval } from '../lib/hooks/use-telemetry-approval'; import { diff --git a/libs/accounts/src/lib/accounts-data-provider.ts b/libs/accounts/src/lib/accounts-data-provider.ts index f8734e9eb..81ccf2dee 100644 --- a/libs/accounts/src/lib/accounts-data-provider.ts +++ b/libs/accounts/src/lib/accounts-data-provider.ts @@ -1,10 +1,10 @@ import { assetsProvider } from '@vegaprotocol/assets'; import { marketsProvider } from '@vegaprotocol/market-list'; +import { removePaginationWrapper } from '@vegaprotocol/utils'; import { makeDataProvider, makeDerivedDataProvider, - removePaginationWrapper, -} from '@vegaprotocol/utils'; +} from '@vegaprotocol/data-provider'; import * as Schema from '@vegaprotocol/types'; import produce from 'immer'; diff --git a/libs/accounts/src/lib/accounts-manager.spec.tsx b/libs/accounts/src/lib/accounts-manager.spec.tsx index 7f3fce85f..bfbc02308 100644 --- a/libs/accounts/src/lib/accounts-manager.spec.tsx +++ b/libs/accounts/src/lib/accounts-manager.spec.tsx @@ -5,12 +5,12 @@ import { screen, waitFor, } from '@testing-library/react'; -import * as helpers from '@vegaprotocol/react-helpers'; +import * as helpers from '@vegaprotocol/data-provider'; import { AccountManager } from './accounts-manager'; const mockedUseDataProvider = jest.fn(); -jest.mock('@vegaprotocol/react-helpers', () => ({ - ...jest.requireActual('@vegaprotocol/react-helpers'), +jest.mock('@vegaprotocol/data-provider', () => ({ + ...jest.requireActual('@vegaprotocol/data-provider'), useDataProvider: jest.fn(() => mockedUseDataProvider()), })); diff --git a/libs/accounts/src/lib/accounts-manager.tsx b/libs/accounts/src/lib/accounts-manager.tsx index f8fadbee4..06ee40e31 100644 --- a/libs/accounts/src/lib/accounts-manager.tsx +++ b/libs/accounts/src/lib/accounts-manager.tsx @@ -1,9 +1,7 @@ import { useRef, useMemo, memo, useCallback } from 'react'; import { t } from '@vegaprotocol/i18n'; -import { - useDataProvider, - useBottomPlaceholder, -} from '@vegaprotocol/react-helpers'; +import { useBottomPlaceholder } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; import type { AgGridReact } from 'ag-grid-react'; import type { AccountFields } from './accounts-data-provider'; diff --git a/libs/accounts/src/lib/asset-balance.tsx b/libs/accounts/src/lib/asset-balance.tsx index b6db46cf5..56c39709b 100644 --- a/libs/accounts/src/lib/asset-balance.tsx +++ b/libs/accounts/src/lib/asset-balance.tsx @@ -1,7 +1,7 @@ import { useMemo } from 'react'; import { addDecimalsFormatNumber } from '@vegaprotocol/utils'; import { accountsDataProvider } from './accounts-data-provider'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; interface AssetBalanceProps { partyId: string; diff --git a/libs/accounts/src/lib/transfer-container.tsx b/libs/accounts/src/lib/transfer-container.tsx index 116618af8..e95d3e6a4 100644 --- a/libs/accounts/src/lib/transfer-container.tsx +++ b/libs/accounts/src/lib/transfer-container.tsx @@ -3,9 +3,9 @@ import { addDecimal, truncateByChars } from '@vegaprotocol/utils'; import { t } from '@vegaprotocol/i18n'; import { NetworkParams, - useDataProvider, useNetworkParam, -} from '@vegaprotocol/react-helpers'; +} from '@vegaprotocol/network-parameters'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import type { Transfer } from '@vegaprotocol/wallet'; import { useVegaTransactionStore, useVegaWallet } from '@vegaprotocol/wallet'; import { useCallback, useMemo } from 'react'; diff --git a/libs/accounts/src/lib/use-account-balance.tsx b/libs/accounts/src/lib/use-account-balance.tsx index d824652c6..0807f8b39 100644 --- a/libs/accounts/src/lib/use-account-balance.tsx +++ b/libs/accounts/src/lib/use-account-balance.tsx @@ -1,6 +1,6 @@ import { useCallback, useMemo, useState } from 'react'; import { useVegaWallet } from '@vegaprotocol/wallet'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { accountsDataProvider } from './accounts-data-provider'; import type { Account } from './accounts-data-provider'; import { getSettlementAccount } from './get-settlement-account'; diff --git a/libs/accounts/src/lib/use-market-account-balance.tsx b/libs/accounts/src/lib/use-market-account-balance.tsx index 97fef2a3d..1d6317da4 100644 --- a/libs/accounts/src/lib/use-market-account-balance.tsx +++ b/libs/accounts/src/lib/use-market-account-balance.tsx @@ -1,6 +1,6 @@ import { useCallback, useMemo, useState } from 'react'; import { useVegaWallet } from '@vegaprotocol/wallet'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { accountsDataProvider } from './accounts-data-provider'; import type { Account } from './accounts-data-provider'; import { getMarketAccount } from './get-market-account'; diff --git a/libs/assets/src/lib/asset-data-provider.ts b/libs/assets/src/lib/asset-data-provider.ts index 091652589..e117bb30f 100644 --- a/libs/assets/src/lib/asset-data-provider.ts +++ b/libs/assets/src/lib/asset-data-provider.ts @@ -1,5 +1,4 @@ -import { makeDataProvider } from '@vegaprotocol/utils'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { makeDataProvider, useDataProvider } from '@vegaprotocol/data-provider'; import type { AssetQuery, diff --git a/libs/assets/src/lib/assets-data-provider.ts b/libs/assets/src/lib/assets-data-provider.ts index 08ddd72cb..760b5b567 100644 --- a/libs/assets/src/lib/assets-data-provider.ts +++ b/libs/assets/src/lib/assets-data-provider.ts @@ -1,5 +1,8 @@ -import { makeDataProvider, makeDerivedDataProvider } from '@vegaprotocol/utils'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { + makeDataProvider, + makeDerivedDataProvider, +} from '@vegaprotocol/data-provider'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { AssetsDocument } from './__generated__/Assets'; import * as Schema from '@vegaprotocol/types'; import type { AssetsQuery } from './__generated__/Assets'; diff --git a/libs/cypress/mock.ts b/libs/cypress/mock.ts index 085659195..3c90c5cda 100644 --- a/libs/cypress/mock.ts +++ b/libs/cypress/mock.ts @@ -20,7 +20,7 @@ export * from '../market-list/src/lib/markets.mock'; export * from '../oracles/src/lib/oracle-spec-data-connection.mock'; export * from '../orders/src/lib/components/order-data-provider/orders.mock'; export * from '../positions/src/lib/positions.mock'; -export * from '../react-helpers/src/hooks/network-params.mock'; -export * from '../react-helpers/src/lib/chain-id.mock'; +export * from '../network-parameters/src/network-params.mock'; +export * from '../wallet/src/connect-dialog/chain-id.mock'; export * from '../trades/src/lib/trades.mock'; export * from '../withdraws/src/lib/withdrawal.mock'; diff --git a/libs/data-provider/.babelrc b/libs/data-provider/.babelrc new file mode 100644 index 000000000..ccae900be --- /dev/null +++ b/libs/data-provider/.babelrc @@ -0,0 +1,12 @@ +{ + "presets": [ + [ + "@nrwl/react/babel", + { + "runtime": "automatic", + "useBuiltIns": "usage" + } + ] + ], + "plugins": [] +} diff --git a/libs/data-provider/.eslintrc.json b/libs/data-provider/.eslintrc.json new file mode 100644 index 000000000..734ddacee --- /dev/null +++ b/libs/data-provider/.eslintrc.json @@ -0,0 +1,18 @@ +{ + "extends": ["plugin:@nrwl/nx/react", "../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.ts", "*.tsx"], + "rules": {} + }, + { + "files": ["*.js", "*.jsx"], + "rules": {} + } + ] +} diff --git a/libs/data-provider/README.md b/libs/data-provider/README.md new file mode 100644 index 000000000..f7284d157 --- /dev/null +++ b/libs/data-provider/README.md @@ -0,0 +1,7 @@ +# data-provider + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test data-provider` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/libs/data-provider/jest.config.ts b/libs/data-provider/jest.config.ts new file mode 100644 index 000000000..2b810ca6a --- /dev/null +++ b/libs/data-provider/jest.config.ts @@ -0,0 +1,10 @@ +/* eslint-disable */ +export default { + displayName: 'data-provider', + preset: '../../jest.preset.js', + transform: { + '^.+\\.[tj]sx?$': 'babel-jest', + }, + moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], + coverageDirectory: '../../coverage/libs/data-provider', +}; diff --git a/libs/data-provider/package.json b/libs/data-provider/package.json new file mode 100644 index 000000000..eabeb57fc --- /dev/null +++ b/libs/data-provider/package.json @@ -0,0 +1,4 @@ +{ + "name": "@vegaprotocol/data-provider", + "version": "0.0.1" +} diff --git a/libs/data-provider/project.json b/libs/data-provider/project.json new file mode 100644 index 000000000..ff4c77a22 --- /dev/null +++ b/libs/data-provider/project.json @@ -0,0 +1,43 @@ +{ + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/data-provider/src", + "projectType": "library", + "tags": [], + "targets": { + "build": { + "executor": "@nrwl/web:rollup", + "outputs": ["{options.outputPath}"], + "options": { + "outputPath": "dist/libs/data-provider", + "tsConfig": "libs/data-provider/tsconfig.lib.json", + "project": "libs/data-provider/package.json", + "entryFile": "libs/data-provider/src/index.ts", + "external": ["react/jsx-runtime"], + "rollupConfig": "@nrwl/react/plugins/bundle-rollup", + "compiler": "babel", + "assets": [ + { + "glob": "libs/data-provider/README.md", + "input": ".", + "output": "." + } + ] + } + }, + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["libs/data-provider/**/*.{ts,tsx,js,jsx}"] + } + }, + "test": { + "executor": "@nrwl/jest:jest", + "outputs": ["coverage/libs/data-provider"], + "options": { + "jestConfig": "libs/data-provider/jest.config.ts", + "passWithNoTests": true + } + } + } +} diff --git a/libs/utils/src/lib/generic-data-provider.spec.ts b/libs/data-provider/src/generic-data-provider.spec.ts similarity index 100% rename from libs/utils/src/lib/generic-data-provider.spec.ts rename to libs/data-provider/src/generic-data-provider.spec.ts diff --git a/libs/utils/src/lib/generic-data-provider.ts b/libs/data-provider/src/generic-data-provider.ts similarity index 99% rename from libs/utils/src/lib/generic-data-provider.ts rename to libs/data-provider/src/generic-data-provider.ts index 2d2b94ceb..f7419d4a9 100644 --- a/libs/utils/src/lib/generic-data-provider.ts +++ b/libs/data-provider/src/generic-data-provider.ts @@ -11,7 +11,7 @@ import type { import type { GraphQLErrors } from '@apollo/client/errors'; import type { Subscription } from 'zen-observable-ts'; import isEqualWith from 'lodash/isEqualWith'; -import { isNotFoundGraphQLError } from './apollo-client'; +import { isNotFoundGraphQLError } from './helpers'; import type * as Schema from '@vegaprotocol/types'; interface UpdateData { delta?: Delta; diff --git a/libs/utils/src/lib/apollo-client.ts b/libs/data-provider/src/helpers.ts similarity index 100% rename from libs/utils/src/lib/apollo-client.ts rename to libs/data-provider/src/helpers.ts index 832dca15c..382ae75b8 100644 --- a/libs/utils/src/lib/apollo-client.ts +++ b/libs/data-provider/src/helpers.ts @@ -9,15 +9,6 @@ const isApolloGraphQLError = ( return !!error && !!(error as ApolloError).graphQLErrors; }; -const hasNotFoundGraphQLErrors = (errors: GraphQLErrors, path?: string[]) => { - return errors.some( - (e) => - e.extensions && - e.extensions['type'] === NOT_FOUND && - (!path || path.every((item, i) => item === e?.path?.[i])) - ); -}; - export const isNotFoundGraphQLError = ( error: Error | ApolloError | undefined, path?: string[] @@ -28,5 +19,14 @@ export const isNotFoundGraphQLError = ( ); }; +const hasNotFoundGraphQLErrors = (errors: GraphQLErrors, path?: string[]) => { + return errors.some( + (e) => + e.extensions && + e.extensions['type'] === NOT_FOUND && + (!path || path.every((item, i) => item === e?.path?.[i])) + ); +}; + export const marketDataErrorPolicyGuard = (errors: GraphQLErrors) => errors.every((e) => e.message.match(/no market data for market:/i)); diff --git a/libs/data-provider/src/index.ts b/libs/data-provider/src/index.ts new file mode 100644 index 000000000..4d6639aea --- /dev/null +++ b/libs/data-provider/src/index.ts @@ -0,0 +1,4 @@ +export * from './use-data-provider'; +export * from './generic-data-provider'; +export * from './pagination'; +export * from './helpers'; diff --git a/libs/utils/src/lib/pagination.ts b/libs/data-provider/src/pagination.ts similarity index 95% rename from libs/utils/src/lib/pagination.ts rename to libs/data-provider/src/pagination.ts index 23a016b4e..be9686b11 100644 --- a/libs/utils/src/lib/pagination.ts +++ b/libs/data-provider/src/pagination.ts @@ -1,6 +1,5 @@ import type { IGetRowsParams } from 'ag-grid-community'; -import type { Load, DerivedPart } from './generic-data-provider'; -import type { Node, Edge } from './generic-data-provider'; +import type { Load, DerivedPart, Node, Edge } from './generic-data-provider'; import type { MutableRefObject } from 'react'; const getLastRow = ( diff --git a/libs/react-helpers/src/hooks/use-data-provider.spec.ts b/libs/data-provider/src/use-data-provider.spec.ts similarity index 99% rename from libs/react-helpers/src/hooks/use-data-provider.spec.ts rename to libs/data-provider/src/use-data-provider.spec.ts index a6f8e3c0b..b999f89da 100644 --- a/libs/react-helpers/src/hooks/use-data-provider.spec.ts +++ b/libs/data-provider/src/use-data-provider.spec.ts @@ -1,7 +1,7 @@ import { renderHook, act } from '@testing-library/react'; import { useDataProvider, useThrottledDataProvider } from './use-data-provider'; import type { useDataProviderParams } from './use-data-provider'; -import type { Subscribe, UpdateCallback } from '@vegaprotocol/utils'; +import type { Subscribe, UpdateCallback } from './generic-data-provider'; import { MockedProvider } from '@apollo/client/testing'; type Data = number; diff --git a/libs/react-helpers/src/hooks/use-data-provider.ts b/libs/data-provider/src/use-data-provider.ts similarity index 97% rename from libs/react-helpers/src/hooks/use-data-provider.ts rename to libs/data-provider/src/use-data-provider.ts index 372b250e1..9df93a169 100644 --- a/libs/react-helpers/src/hooks/use-data-provider.ts +++ b/libs/data-provider/src/use-data-provider.ts @@ -3,8 +3,8 @@ import throttle from 'lodash/throttle'; import isEqualWith from 'lodash/isEqualWith'; import { useApolloClient } from '@apollo/client'; import type { OperationVariables } from '@apollo/client'; -import type { Subscribe, Load, UpdateCallback } from '@vegaprotocol/utils'; -import { variablesIsEqualCustomizer } from '@vegaprotocol/utils'; +import type { Subscribe, Load, UpdateCallback } from './generic-data-provider'; +import { variablesIsEqualCustomizer } from './generic-data-provider'; export interface useDataProviderParams< Data, diff --git a/libs/data-provider/tsconfig.json b/libs/data-provider/tsconfig.json new file mode 100644 index 000000000..4c089585e --- /dev/null +++ b/libs/data-provider/tsconfig.json @@ -0,0 +1,25 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "jsx": "react-jsx", + "allowJs": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ] +} diff --git a/libs/data-provider/tsconfig.lib.json b/libs/data-provider/tsconfig.lib.json new file mode 100644 index 000000000..af84f21cf --- /dev/null +++ b/libs/data-provider/tsconfig.lib.json @@ -0,0 +1,23 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "types": ["node"] + }, + "files": [ + "../../node_modules/@nrwl/react/typings/cssmodule.d.ts", + "../../node_modules/@nrwl/react/typings/image.d.ts" + ], + "exclude": [ + "jest.config.ts", + "**/*.spec.ts", + "**/*.test.ts", + "**/*.spec.tsx", + "**/*.test.tsx", + "**/*.spec.js", + "**/*.test.js", + "**/*.spec.jsx", + "**/*.test.jsx" + ], + "include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"] +} diff --git a/libs/data-provider/tsconfig.spec.json b/libs/data-provider/tsconfig.spec.json new file mode 100644 index 000000000..ff08addd6 --- /dev/null +++ b/libs/data-provider/tsconfig.spec.json @@ -0,0 +1,20 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "module": "commonjs", + "types": ["jest", "node"] + }, + "include": [ + "jest.config.ts", + "**/*.test.ts", + "**/*.spec.ts", + "**/*.test.tsx", + "**/*.spec.tsx", + "**/*.test.js", + "**/*.spec.js", + "**/*.test.jsx", + "**/*.spec.jsx", + "**/*.d.ts" + ] +} diff --git a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-container.tsx b/libs/deal-ticket/src/components/deal-ticket/deal-ticket-container.tsx index 117c2d743..8bb682245 100644 --- a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-container.tsx +++ b/libs/deal-ticket/src/components/deal-ticket/deal-ticket-container.tsx @@ -1,6 +1,6 @@ import { AsyncRenderer, Splash } from '@vegaprotocol/ui-toolkit'; import { t } from '@vegaprotocol/i18n'; -import { useThrottledDataProvider } from '@vegaprotocol/react-helpers'; +import { useThrottledDataProvider } from '@vegaprotocol/data-provider'; import { useVegaTransactionStore } from '@vegaprotocol/wallet'; import { useMarket, marketDataProvider } from '@vegaprotocol/market-list'; import { DealTicket } from './deal-ticket'; diff --git a/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx b/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx index 84bb027e5..2cba96fd7 100644 --- a/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx +++ b/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx @@ -44,7 +44,7 @@ import { import { OrderTimeInForce, OrderType } from '@vegaprotocol/types'; import { useOrderForm } from '../../hooks/use-order-form'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { marketMarginDataProvider } from '@vegaprotocol/positions'; diff --git a/libs/deal-ticket/src/components/deal-ticket/market-selector.tsx b/libs/deal-ticket/src/components/deal-ticket/market-selector.tsx index ca309293c..04e4851ac 100644 --- a/libs/deal-ticket/src/components/deal-ticket/market-selector.tsx +++ b/libs/deal-ticket/src/components/deal-ticket/market-selector.tsx @@ -18,8 +18,8 @@ import { import { useScreenDimensions, useOutsideClick, - useDataProvider, } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { t } from '@vegaprotocol/i18n'; import { IconNames } from '@blueprintjs/icons'; import * as Schema from '@vegaprotocol/types'; diff --git a/libs/deal-ticket/src/hooks/use-initial-margin.ts b/libs/deal-ticket/src/hooks/use-initial-margin.ts index b431123a2..3b0806332 100644 --- a/libs/deal-ticket/src/hooks/use-initial-margin.ts +++ b/libs/deal-ticket/src/hooks/use-initial-margin.ts @@ -1,5 +1,5 @@ import { useMemo } from 'react'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { useVegaWallet } from '@vegaprotocol/wallet'; import { marketDataProvider } from '@vegaprotocol/market-list'; import { diff --git a/libs/deposits/src/lib/deposit-container.tsx b/libs/deposits/src/lib/deposit-container.tsx index c1cf1c555..ce3fb3dc4 100644 --- a/libs/deposits/src/lib/deposit-container.tsx +++ b/libs/deposits/src/lib/deposit-container.tsx @@ -2,7 +2,7 @@ import { Networks, useEnvironment } from '@vegaprotocol/environment'; import { AsyncRenderer, Splash } from '@vegaprotocol/ui-toolkit'; import { DepositManager } from './deposit-manager'; import { t } from '@vegaprotocol/i18n'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { enabledAssetsProvider } from '@vegaprotocol/assets'; /** diff --git a/libs/deposits/src/lib/deposits-provider.ts b/libs/deposits/src/lib/deposits-provider.ts index 216ac4aed..2a08ad503 100644 --- a/libs/deposits/src/lib/deposits-provider.ts +++ b/libs/deposits/src/lib/deposits-provider.ts @@ -1,10 +1,7 @@ import uniqBy from 'lodash/uniqBy'; import orderBy from 'lodash/orderBy'; -import { - getEvents, - makeDataProvider, - removePaginationWrapper, -} from '@vegaprotocol/utils'; +import { getEvents, removePaginationWrapper } from '@vegaprotocol/utils'; +import { makeDataProvider } from '@vegaprotocol/data-provider'; import * as Schema from '@vegaprotocol/types'; import { DepositsDocument, diff --git a/libs/fills/src/lib/fills-data-provider.ts b/libs/fills/src/lib/fills-data-provider.ts index 762148b99..9f069edf3 100644 --- a/libs/fills/src/lib/fills-data-provider.ts +++ b/libs/fills/src/lib/fills-data-provider.ts @@ -1,15 +1,16 @@ import produce from 'immer'; import orderBy from 'lodash/orderBy'; +import {} from '@vegaprotocol/utils'; +import type { PageInfo, Edge } from '@vegaprotocol/data-provider'; import { makeDataProvider, makeDerivedDataProvider, defaultAppend as append, paginatedCombineDelta as combineDelta, paginatedCombineInsertionData as combineInsertionData, -} from '@vegaprotocol/utils'; +} from '@vegaprotocol/data-provider'; import type { Market } from '@vegaprotocol/market-list'; import { marketsProvider } from '@vegaprotocol/market-list'; -import type { PageInfo, Edge } from '@vegaprotocol/utils'; import { FillsDocument, FillsEventDocument } from './__generated__/Fills'; import type { FillsQuery, diff --git a/libs/fills/src/lib/use-fills-list.spec.ts b/libs/fills/src/lib/use-fills-list.spec.ts index 9d539a385..dfd0935de 100644 --- a/libs/fills/src/lib/use-fills-list.spec.ts +++ b/libs/fills/src/lib/use-fills-list.spec.ts @@ -16,8 +16,8 @@ const mockDataProvider = jest.fn((args) => { updateMock = args.update; return mockDataProviderData; }); -jest.mock('@vegaprotocol/react-helpers', () => ({ - ...jest.requireActual('@vegaprotocol/react-helpers'), +jest.mock('@vegaprotocol/data-provider', () => ({ + ...jest.requireActual('@vegaprotocol/data-provider'), useDataProvider: jest.fn((args) => mockDataProvider(args)), })); diff --git a/libs/fills/src/lib/use-fills-list.ts b/libs/fills/src/lib/use-fills-list.ts index 2827545d9..cc66bcacd 100644 --- a/libs/fills/src/lib/use-fills-list.ts +++ b/libs/fills/src/lib/use-fills-list.ts @@ -1,8 +1,9 @@ import type { RefObject } from 'react'; import type { AgGridReact } from 'ag-grid-react'; import { useCallback, useRef } from 'react'; -import { makeInfiniteScrollGetRows } from '@vegaprotocol/utils'; -import { useDataProvider, updateGridData } from '@vegaprotocol/react-helpers'; +import { makeInfiniteScrollGetRows } from '@vegaprotocol/data-provider'; +import { updateGridData } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import type { Trade, TradeEdge } from './fills-data-provider'; import { fillsWithMarketProvider } from './fills-data-provider'; diff --git a/libs/ledger/src/lib/ledger-entries-data-provider.ts b/libs/ledger/src/lib/ledger-entries-data-provider.ts index 893214335..98250c1ab 100644 --- a/libs/ledger/src/lib/ledger-entries-data-provider.ts +++ b/libs/ledger/src/lib/ledger-entries-data-provider.ts @@ -2,12 +2,13 @@ import type { Asset } from '@vegaprotocol/assets'; import { assetsProvider } from '@vegaprotocol/assets'; import type { Market } from '@vegaprotocol/market-list'; import { marketsProvider } from '@vegaprotocol/market-list'; +import { makeInfiniteScrollGetRows } from '@vegaprotocol/data-provider'; +import { updateGridData } from '@vegaprotocol/react-helpers'; import { makeDataProvider, makeDerivedDataProvider, - makeInfiniteScrollGetRows, -} from '@vegaprotocol/utils'; -import { useDataProvider, updateGridData } from '@vegaprotocol/react-helpers'; + useDataProvider, +} from '@vegaprotocol/data-provider'; import type * as Schema from '@vegaprotocol/types'; import type { AgGridReact } from 'ag-grid-react'; import produce from 'immer'; diff --git a/libs/liquidity/src/lib/liquidity-data-provider.ts b/libs/liquidity/src/lib/liquidity-data-provider.ts index 821567c42..8bf15c0f3 100644 --- a/libs/liquidity/src/lib/liquidity-data-provider.ts +++ b/libs/liquidity/src/lib/liquidity-data-provider.ts @@ -1,5 +1,8 @@ import compact from 'lodash/compact'; -import { makeDataProvider, makeDerivedDataProvider } from '@vegaprotocol/utils'; +import { + makeDataProvider, + makeDerivedDataProvider, +} from '@vegaprotocol/data-provider'; import * as Schema from '@vegaprotocol/types'; import BigNumber from 'bignumber.js'; import produce from 'immer'; diff --git a/libs/liquidity/src/lib/markets-liquidity-provider.ts b/libs/liquidity/src/lib/markets-liquidity-provider.ts index f190e10da..540c10f22 100644 --- a/libs/liquidity/src/lib/markets-liquidity-provider.ts +++ b/libs/liquidity/src/lib/markets-liquidity-provider.ts @@ -1,7 +1,11 @@ import { useMemo } from 'react'; import * as Schema from '@vegaprotocol/types'; -import { makeDataProvider, makeDerivedDataProvider } from '@vegaprotocol/utils'; -import { useDataProvider, useYesterday } from '@vegaprotocol/react-helpers'; +import { + makeDataProvider, + makeDerivedDataProvider, + useDataProvider, +} from '@vegaprotocol/data-provider'; +import { useYesterday } from '@vegaprotocol/react-helpers'; import type { MarketCandles, MarketMaybeWithDataAndCandles, diff --git a/libs/market-depth/src/lib/depth-chart.tsx b/libs/market-depth/src/lib/depth-chart.tsx index be7d74119..fb3cd1ae1 100644 --- a/libs/market-depth/src/lib/depth-chart.tsx +++ b/libs/market-depth/src/lib/depth-chart.tsx @@ -3,7 +3,8 @@ import throttle from 'lodash/throttle'; import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; import { addDecimal, getNumberFormat } from '@vegaprotocol/utils'; import { t } from '@vegaprotocol/i18n'; -import { useDataProvider, useThemeSwitcher } from '@vegaprotocol/react-helpers'; +import { useThemeSwitcher } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { marketDepthProvider } from './market-depth-provider'; import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { marketDataProvider, marketProvider } from '@vegaprotocol/market-list'; diff --git a/libs/market-depth/src/lib/market-depth-provider.ts b/libs/market-depth/src/lib/market-depth-provider.ts index d462aea17..8393928d3 100644 --- a/libs/market-depth/src/lib/market-depth-provider.ts +++ b/libs/market-depth/src/lib/market-depth-provider.ts @@ -1,6 +1,6 @@ -import { makeDataProvider } from '@vegaprotocol/utils'; +import type { Update } from '@vegaprotocol/data-provider'; +import { makeDataProvider } from '@vegaprotocol/data-provider'; import { updateLevels } from './orderbook-data'; -import type { Update } from '@vegaprotocol/utils'; import { captureException } from '@sentry/react'; import { diff --git a/libs/market-depth/src/lib/orderbook-manager.tsx b/libs/market-depth/src/lib/orderbook-manager.tsx index 8201936f4..5766becfe 100644 --- a/libs/market-depth/src/lib/orderbook-manager.tsx +++ b/libs/market-depth/src/lib/orderbook-manager.tsx @@ -1,7 +1,7 @@ import throttle from 'lodash/throttle'; import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; import { Orderbook } from './orderbook'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { marketDepthProvider } from './market-depth-provider'; import { marketDataProvider, marketProvider } from '@vegaprotocol/market-list'; import type { MarketData } from '@vegaprotocol/market-list'; diff --git a/libs/market-info/src/components/last-24h-price-change/last-24h-price-change.tsx b/libs/market-info/src/components/last-24h-price-change/last-24h-price-change.tsx index aae0e87e2..4a2f1d3b5 100644 --- a/libs/market-info/src/components/last-24h-price-change/last-24h-price-change.tsx +++ b/libs/market-info/src/components/last-24h-price-change/last-24h-price-change.tsx @@ -1,10 +1,8 @@ import type { RefObject } from 'react'; import { useInView } from 'react-intersection-observer'; import { isNumeric } from '@vegaprotocol/utils'; -import { - useThrottledDataProvider, - useYesterday, -} from '@vegaprotocol/react-helpers'; +import { useYesterday } from '@vegaprotocol/react-helpers'; +import { useThrottledDataProvider } from '@vegaprotocol/data-provider'; import { PriceChangeCell } from '@vegaprotocol/datagrid'; import * as Schema from '@vegaprotocol/types'; import type { CandleClose } from '@vegaprotocol/types'; diff --git a/libs/market-info/src/components/last-24h-volume/last-24h-volume.tsx b/libs/market-info/src/components/last-24h-volume/last-24h-volume.tsx index b0b759366..e759485b0 100644 --- a/libs/market-info/src/components/last-24h-volume/last-24h-volume.tsx +++ b/libs/market-info/src/components/last-24h-volume/last-24h-volume.tsx @@ -5,10 +5,8 @@ import { marketCandlesProvider, } from '@vegaprotocol/market-list'; import { addDecimalsFormatNumber, isNumeric } from '@vegaprotocol/utils'; -import { - useThrottledDataProvider, - useYesterday, -} from '@vegaprotocol/react-helpers'; +import { useYesterday } from '@vegaprotocol/react-helpers'; +import { useThrottledDataProvider } from '@vegaprotocol/data-provider'; import * as Schema from '@vegaprotocol/types'; interface Props { diff --git a/libs/market-info/src/components/market-info/market-info-accordion.tsx b/libs/market-info/src/components/market-info/market-info-accordion.tsx index 19960ea8f..750bfbbb8 100644 --- a/libs/market-info/src/components/market-info/market-info-accordion.tsx +++ b/libs/market-info/src/components/market-info/market-info-accordion.tsx @@ -1,7 +1,7 @@ import { useEnvironment } from '@vegaprotocol/environment'; import { removePaginationWrapper, TokenLinks } from '@vegaprotocol/utils'; import { t } from '@vegaprotocol/i18n'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import * as Schema from '@vegaprotocol/types'; import { Accordion, diff --git a/libs/market-info/src/components/market-info/market-info-data-provider.ts b/libs/market-info/src/components/market-info/market-info-data-provider.ts index 366953241..8f4818d50 100644 --- a/libs/market-info/src/components/market-info/market-info-data-provider.ts +++ b/libs/market-info/src/components/market-info/market-info-data-provider.ts @@ -1,4 +1,7 @@ -import { makeDataProvider, makeDerivedDataProvider } from '@vegaprotocol/utils'; +import { + makeDataProvider, + makeDerivedDataProvider, +} from '@vegaprotocol/data-provider'; import type { MarketInfoQuery, MarketInfoQueryVariables, diff --git a/libs/market-info/src/components/market-info/market-info-panels.tsx b/libs/market-info/src/components/market-info/market-info-panels.tsx index 513dc7723..6a89c98b2 100644 --- a/libs/market-info/src/components/market-info/market-info-panels.tsx +++ b/libs/market-info/src/components/market-info/market-info-panels.tsx @@ -33,7 +33,7 @@ import { useOracleProofs, useOracleMarkets, } from '@vegaprotocol/oracles'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; type PanelProps = Pick< ComponentProps, diff --git a/libs/market-info/src/hooks/use-market-oracle.spec.ts b/libs/market-info/src/hooks/use-market-oracle.spec.ts index 1adfec798..a94cd21a5 100644 --- a/libs/market-info/src/hooks/use-market-oracle.spec.ts +++ b/libs/market-info/src/hooks/use-market-oracle.spec.ts @@ -52,7 +52,8 @@ jest.mock('@vegaprotocol/environment', () => ({ useEnvironment: jest.fn((args) => mockEnvironment()), })); -jest.mock('@vegaprotocol/react-helpers', () => ({ +jest.mock('@vegaprotocol/data-provider', () => ({ + ...jest.requireActual('@vegaprotocol/data-provider'), useDataProvider: jest.fn((args) => mockDataProvider()), })); diff --git a/libs/market-info/src/hooks/use-market-oracle.ts b/libs/market-info/src/hooks/use-market-oracle.ts index 5ccbd5254..430d3f56b 100644 --- a/libs/market-info/src/hooks/use-market-oracle.ts +++ b/libs/market-info/src/hooks/use-market-oracle.ts @@ -1,6 +1,6 @@ import { useEnvironment } from '@vegaprotocol/environment'; import { useOracleProofs } from '@vegaprotocol/oracles'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { marketInfoProvider } from '../components/market-info/market-info-data-provider'; import { useMemo } from 'react'; diff --git a/libs/market-list/src/lib/components/markets-container/markets-container.tsx b/libs/market-list/src/lib/components/markets-container/markets-container.tsx index a83cf4e08..d2fc0159e 100644 --- a/libs/market-list/src/lib/components/markets-container/markets-container.tsx +++ b/libs/market-list/src/lib/components/markets-container/markets-container.tsx @@ -4,7 +4,7 @@ import type { AgGridReact } from 'ag-grid-react'; import { t } from '@vegaprotocol/i18n'; import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; import { MarketListTable } from './market-list-table'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import type { CellClickedEvent } from 'ag-grid-community'; import { marketsWithDataProvider as dataProvider } from '../../markets-provider'; import type { MarketMaybeWithData } from '../../markets-provider'; diff --git a/libs/market-list/src/lib/market-candles-provider.ts b/libs/market-list/src/lib/market-candles-provider.ts index 7fd9a423b..eb7090ed8 100644 --- a/libs/market-list/src/lib/market-candles-provider.ts +++ b/libs/market-list/src/lib/market-candles-provider.ts @@ -1,4 +1,4 @@ -import { makeDataProvider } from '@vegaprotocol/utils'; +import { makeDataProvider } from '@vegaprotocol/data-provider'; import type { MarketCandlesQuery, MarketCandlesQueryVariables, diff --git a/libs/market-list/src/lib/market-data-provider.ts b/libs/market-list/src/lib/market-data-provider.ts index ef995e99c..2ce13a43a 100644 --- a/libs/market-list/src/lib/market-data-provider.ts +++ b/libs/market-list/src/lib/market-data-provider.ts @@ -1,6 +1,9 @@ import produce from 'immer'; -import { makeDataProvider, makeDerivedDataProvider } from '@vegaprotocol/utils'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { + makeDataProvider, + makeDerivedDataProvider, +} from '@vegaprotocol/data-provider'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { MarketDataDocument, MarketDataUpdateDocument, diff --git a/libs/market-list/src/lib/markets-candles-provider.ts b/libs/market-list/src/lib/markets-candles-provider.ts index bc3a195a3..45d7ffb34 100644 --- a/libs/market-list/src/lib/markets-candles-provider.ts +++ b/libs/market-list/src/lib/markets-candles-provider.ts @@ -1,4 +1,4 @@ -import { makeDataProvider } from '@vegaprotocol/utils'; +import { makeDataProvider } from '@vegaprotocol/data-provider'; import { MarketsCandlesDocument } from './__generated__/markets-candles'; import type { MarketsCandlesQuery, diff --git a/libs/market-list/src/lib/markets-data-provider.ts b/libs/market-list/src/lib/markets-data-provider.ts index 4304bd87e..3d284da8d 100644 --- a/libs/market-list/src/lib/markets-data-provider.ts +++ b/libs/market-list/src/lib/markets-data-provider.ts @@ -1,7 +1,5 @@ -import { - makeDataProvider, - marketDataErrorPolicyGuard, -} from '@vegaprotocol/utils'; +import { marketDataErrorPolicyGuard } from '@vegaprotocol/data-provider'; +import { makeDataProvider } from '@vegaprotocol/data-provider'; import type { MarketsDataQuery } from './__generated__/markets-data'; import { MarketsDataDocument } from './__generated__/markets-data'; import type { MarketData } from './market-data-provider'; diff --git a/libs/market-list/src/lib/markets-provider.ts b/libs/market-list/src/lib/markets-provider.ts index ebe2845a4..2181ccf67 100644 --- a/libs/market-list/src/lib/markets-provider.ts +++ b/libs/market-list/src/lib/markets-provider.ts @@ -1,5 +1,9 @@ -import { makeDataProvider, makeDerivedDataProvider } from '@vegaprotocol/utils'; -import { useDataProvider, useYesterday } from '@vegaprotocol/react-helpers'; +import { useYesterday } from '@vegaprotocol/react-helpers'; +import { + makeDataProvider, + makeDerivedDataProvider, + useDataProvider, +} from '@vegaprotocol/data-provider'; import type { MarketsQuery, MarketFieldsFragment, diff --git a/libs/network-parameters/.babelrc b/libs/network-parameters/.babelrc new file mode 100644 index 000000000..ccae900be --- /dev/null +++ b/libs/network-parameters/.babelrc @@ -0,0 +1,12 @@ +{ + "presets": [ + [ + "@nrwl/react/babel", + { + "runtime": "automatic", + "useBuiltIns": "usage" + } + ] + ], + "plugins": [] +} diff --git a/libs/network-parameters/.eslintrc.json b/libs/network-parameters/.eslintrc.json new file mode 100644 index 000000000..db820c5d0 --- /dev/null +++ b/libs/network-parameters/.eslintrc.json @@ -0,0 +1,18 @@ +{ + "extends": ["plugin:@nrwl/nx/react", "../../.eslintrc.json"], + "ignorePatterns": ["!**/*", "__generated__"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.ts", "*.tsx"], + "rules": {} + }, + { + "files": ["*.js", "*.jsx"], + "rules": {} + } + ] +} diff --git a/libs/network-parameters/README.md b/libs/network-parameters/README.md new file mode 100644 index 000000000..a59d49e2e --- /dev/null +++ b/libs/network-parameters/README.md @@ -0,0 +1,7 @@ +# network-parameters + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test network-parameters` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/libs/network-parameters/jest.config.ts b/libs/network-parameters/jest.config.ts new file mode 100644 index 000000000..245d8a070 --- /dev/null +++ b/libs/network-parameters/jest.config.ts @@ -0,0 +1,10 @@ +/* eslint-disable */ +export default { + displayName: 'network-parameters', + preset: '../../jest.preset.js', + transform: { + '^.+\\.[tj]sx?$': 'babel-jest', + }, + moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], + coverageDirectory: '../../coverage/libs/network-parameters', +}; diff --git a/libs/network-parameters/package.json b/libs/network-parameters/package.json new file mode 100644 index 000000000..a1e690122 --- /dev/null +++ b/libs/network-parameters/package.json @@ -0,0 +1,4 @@ +{ + "name": "@vegaprotocol/network-parameters", + "version": "0.0.1" +} diff --git a/libs/network-parameters/project.json b/libs/network-parameters/project.json new file mode 100644 index 000000000..b7d5cc0a4 --- /dev/null +++ b/libs/network-parameters/project.json @@ -0,0 +1,43 @@ +{ + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/network-parameters/src", + "projectType": "library", + "tags": [], + "targets": { + "build": { + "executor": "@nrwl/web:rollup", + "outputs": ["{options.outputPath}"], + "options": { + "outputPath": "dist/libs/network-parameters", + "tsConfig": "libs/network-parameters/tsconfig.lib.json", + "project": "libs/network-parameters/package.json", + "entryFile": "libs/network-parameters/src/index.ts", + "external": ["react/jsx-runtime"], + "rollupConfig": "@nrwl/react/plugins/bundle-rollup", + "compiler": "babel", + "assets": [ + { + "glob": "libs/network-parameters/README.md", + "input": ".", + "output": "." + } + ] + } + }, + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["libs/network-parameters/**/*.{ts,tsx,js,jsx}"] + } + }, + "test": { + "executor": "@nrwl/jest:jest", + "outputs": ["coverage/libs/network-parameters"], + "options": { + "jestConfig": "libs/network-parameters/jest.config.ts", + "passWithNoTests": true + } + } + } +} diff --git a/libs/react-helpers/src/hooks/NetworkParams.graphql b/libs/network-parameters/src/NetworkParams.graphql similarity index 100% rename from libs/react-helpers/src/hooks/NetworkParams.graphql rename to libs/network-parameters/src/NetworkParams.graphql diff --git a/libs/react-helpers/src/hooks/__generated__/NetworkParams.ts b/libs/network-parameters/src/__generated__/NetworkParams.ts similarity index 100% rename from libs/react-helpers/src/hooks/__generated__/NetworkParams.ts rename to libs/network-parameters/src/__generated__/NetworkParams.ts diff --git a/libs/network-parameters/src/index.ts b/libs/network-parameters/src/index.ts new file mode 100644 index 000000000..10457e6b4 --- /dev/null +++ b/libs/network-parameters/src/index.ts @@ -0,0 +1,2 @@ +export * from './use-network-params'; +export * from './__generated__/NetworkParams'; diff --git a/libs/react-helpers/src/hooks/network-params.mock.ts b/libs/network-parameters/src/network-params.mock.ts similarity index 100% rename from libs/react-helpers/src/hooks/network-params.mock.ts rename to libs/network-parameters/src/network-params.mock.ts diff --git a/libs/react-helpers/src/hooks/use-network-params.spec.tsx b/libs/network-parameters/src/use-network-params.spec.tsx similarity index 94% rename from libs/react-helpers/src/hooks/use-network-params.spec.tsx rename to libs/network-parameters/src/use-network-params.spec.tsx index a70320ff3..6a6f7c473 100644 --- a/libs/react-helpers/src/hooks/use-network-params.spec.tsx +++ b/libs/network-parameters/src/use-network-params.spec.tsx @@ -2,16 +2,18 @@ import { renderHook, waitFor } from '@testing-library/react'; import type { MockedResponse } from '@apollo/client/testing'; import { MockedProvider } from '@apollo/client/testing'; import type { NetworkParamsKey } from './use-network-params'; -import { toRealKey } from './use-network-params'; import { + toRealKey, NetworkParams, useNetworkParam, useNetworkParams, } from './use-network-params'; import type { ReactNode } from 'react'; import type { NetworkParamsQuery } from './__generated__/NetworkParams'; -import { NetworkParamDocument } from './__generated__/NetworkParams'; -import { NetworkParamsDocument } from './__generated__/NetworkParams'; +import { + NetworkParamDocument, + NetworkParamsDocument, +} from './__generated__/NetworkParams'; describe('useNetworkParam', () => { const setup = (arg: NetworkParamsKey) => { diff --git a/libs/react-helpers/src/hooks/use-network-params.ts b/libs/network-parameters/src/use-network-params.ts similarity index 100% rename from libs/react-helpers/src/hooks/use-network-params.ts rename to libs/network-parameters/src/use-network-params.ts diff --git a/libs/network-parameters/tsconfig.json b/libs/network-parameters/tsconfig.json new file mode 100644 index 000000000..4c089585e --- /dev/null +++ b/libs/network-parameters/tsconfig.json @@ -0,0 +1,25 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "jsx": "react-jsx", + "allowJs": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ] +} diff --git a/libs/network-parameters/tsconfig.lib.json b/libs/network-parameters/tsconfig.lib.json new file mode 100644 index 000000000..af84f21cf --- /dev/null +++ b/libs/network-parameters/tsconfig.lib.json @@ -0,0 +1,23 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "types": ["node"] + }, + "files": [ + "../../node_modules/@nrwl/react/typings/cssmodule.d.ts", + "../../node_modules/@nrwl/react/typings/image.d.ts" + ], + "exclude": [ + "jest.config.ts", + "**/*.spec.ts", + "**/*.test.ts", + "**/*.spec.tsx", + "**/*.test.tsx", + "**/*.spec.js", + "**/*.test.js", + "**/*.spec.jsx", + "**/*.test.jsx" + ], + "include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"] +} diff --git a/libs/network-parameters/tsconfig.spec.json b/libs/network-parameters/tsconfig.spec.json new file mode 100644 index 000000000..ff08addd6 --- /dev/null +++ b/libs/network-parameters/tsconfig.spec.json @@ -0,0 +1,20 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "module": "commonjs", + "types": ["jest", "node"] + }, + "include": [ + "jest.config.ts", + "**/*.test.ts", + "**/*.spec.ts", + "**/*.test.tsx", + "**/*.spec.tsx", + "**/*.test.js", + "**/*.spec.js", + "**/*.test.jsx", + "**/*.spec.jsx", + "**/*.d.ts" + ] +} diff --git a/libs/oracles/src/lib/__generated__/OracleMarketsSpec.ts b/libs/oracles/src/lib/__generated__/OracleMarketsSpec.ts index f45568150..583b378dd 100644 --- a/libs/oracles/src/lib/__generated__/OracleMarketsSpec.ts +++ b/libs/oracles/src/lib/__generated__/OracleMarketsSpec.ts @@ -3,7 +3,6 @@ import * as Types from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; const defaultOptions = {} as const; - export type OracleMarketSpecFieldsFragment = { __typename?: 'Market', id: string, state: Types.MarketState, tradingMode: Types.MarketTradingMode, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, product: { __typename?: 'Future', dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null } } | { __typename?: 'DataSourceDefinitionInternal' } } }, dataSourceSpecForTradingTermination: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null } } | { __typename?: 'DataSourceDefinitionInternal' } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecToFutureBinding', settlementDataProperty: string, tradingTerminationProperty: string } } } } }; export type DataSourceSpecFragment = { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null } } | { __typename?: 'DataSourceDefinitionInternal' } }; @@ -106,4 +105,4 @@ export function useOracleMarketsSpecLazyQuery(baseOptions?: Apollo.LazyQueryHook } export type OracleMarketsSpecQueryHookResult = ReturnType; export type OracleMarketsSpecLazyQueryHookResult = ReturnType; -export type OracleMarketsSpecQueryResult = Apollo.QueryResult; +export type OracleMarketsSpecQueryResult = Apollo.QueryResult; \ No newline at end of file diff --git a/libs/orders/src/lib/components/order-data-provider/order-data-provider.spec.ts b/libs/orders/src/lib/components/order-data-provider/order-data-provider.spec.ts index 8f736ba03..dd10b1d3f 100644 --- a/libs/orders/src/lib/components/order-data-provider/order-data-provider.spec.ts +++ b/libs/orders/src/lib/components/order-data-provider/order-data-provider.spec.ts @@ -1,6 +1,6 @@ import { update } from './order-data-provider'; import type { OrderUpdateFieldsFragment, OrderFieldsFragment } from '../'; -import type { Edge } from '@vegaprotocol/utils'; +import type { Edge } from '@vegaprotocol/data-provider'; describe('order data provider', () => { it('puts incoming data in proper place', () => { diff --git a/libs/orders/src/lib/components/order-data-provider/order-data-provider.ts b/libs/orders/src/lib/components/order-data-provider/order-data-provider.ts index ca52734ef..180dff166 100644 --- a/libs/orders/src/lib/components/order-data-provider/order-data-provider.ts +++ b/libs/orders/src/lib/components/order-data-provider/order-data-provider.ts @@ -5,10 +5,10 @@ import { makeDataProvider, makeDerivedDataProvider, defaultAppend as append, -} from '@vegaprotocol/utils'; +} from '@vegaprotocol/data-provider'; +import type { PageInfo, Edge } from '@vegaprotocol/data-provider'; import type { Market } from '@vegaprotocol/market-list'; import { marketsProvider } from '@vegaprotocol/market-list'; -import type { PageInfo, Edge } from '@vegaprotocol/utils'; import { OrderStatus } from '@vegaprotocol/types'; import type { OrderFieldsFragment, diff --git a/libs/orders/src/lib/components/order-list-manager/order-list-manager.spec.tsx b/libs/orders/src/lib/components/order-list-manager/order-list-manager.spec.tsx index e3bb64b12..88e151a59 100644 --- a/libs/orders/src/lib/components/order-list-manager/order-list-manager.spec.tsx +++ b/libs/orders/src/lib/components/order-list-manager/order-list-manager.spec.tsx @@ -1,6 +1,6 @@ import { render, screen, act } from '@testing-library/react'; import { OrderListManager } from './order-list-manager'; -import * as useDataProviderHook from '@vegaprotocol/react-helpers'; +import * as useDataProviderHook from '@vegaprotocol/data-provider'; import type { OrderFieldsFragment } from '../'; import * as orderListMock from '../order-list/order-list'; import { forwardRef } from 'react'; diff --git a/libs/orders/src/lib/components/order-list-manager/order-list-manager.tsx b/libs/orders/src/lib/components/order-list-manager/order-list-manager.tsx index 97822089b..93e7db191 100644 --- a/libs/orders/src/lib/components/order-list-manager/order-list-manager.tsx +++ b/libs/orders/src/lib/components/order-list-manager/order-list-manager.tsx @@ -8,7 +8,7 @@ import type { GridReadyEvent, FilterChangedEvent } from 'ag-grid-community'; import { OrderListTable } from '../order-list/order-list'; import { useHasAmendableOrder } from '../../order-hooks/use-has-amendable-order'; import { useBottomPlaceholder } from '@vegaprotocol/react-helpers'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { ordersWithMarketProvider } from '../order-data-provider/order-data-provider'; import { normalizeOrderAmendment, diff --git a/libs/orders/src/lib/order-hooks/use-has-amendable-order.ts b/libs/orders/src/lib/order-hooks/use-has-amendable-order.ts index 4b6d6dcff..abc9359f5 100644 --- a/libs/orders/src/lib/order-hooks/use-has-amendable-order.ts +++ b/libs/orders/src/lib/order-hooks/use-has-amendable-order.ts @@ -1,7 +1,7 @@ import { useCallback, useState } from 'react'; import { hasAmendableOrderProvider } from '../components/order-data-provider'; import { useVegaWallet } from '@vegaprotocol/wallet'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; export const useHasAmendableOrder = (marketId?: string) => { const { pubKey } = useVegaWallet(); diff --git a/libs/positions/src/lib/margin-data-provider.ts b/libs/positions/src/lib/margin-data-provider.ts index aab08ea1c..e18ba0180 100644 --- a/libs/positions/src/lib/margin-data-provider.ts +++ b/libs/positions/src/lib/margin-data-provider.ts @@ -1,9 +1,9 @@ import produce from 'immer'; +import { removePaginationWrapper } from '@vegaprotocol/utils'; import { makeDataProvider, makeDerivedDataProvider, - removePaginationWrapper, -} from '@vegaprotocol/utils'; +} from '@vegaprotocol/data-provider'; import { MarginsSubscriptionDocument, MarginsDocument, diff --git a/libs/positions/src/lib/positions-data-providers.ts b/libs/positions/src/lib/positions-data-providers.ts index df1edd869..c01976a49 100644 --- a/libs/positions/src/lib/positions-data-providers.ts +++ b/libs/positions/src/lib/positions-data-providers.ts @@ -4,12 +4,12 @@ import BigNumber from 'bignumber.js'; import sortBy from 'lodash/sortBy'; import type { Account } from '@vegaprotocol/accounts'; import { accountsDataProvider } from '@vegaprotocol/accounts'; +import { toBigNum, removePaginationWrapper } from '@vegaprotocol/utils'; +import type { Edge } from '@vegaprotocol/data-provider'; import { - toBigNum, makeDataProvider, makeDerivedDataProvider, - removePaginationWrapper, -} from '@vegaprotocol/utils'; +} from '@vegaprotocol/data-provider'; import * as Schema from '@vegaprotocol/types'; import type { MarketMaybeWithData, @@ -29,7 +29,6 @@ import { } from './__generated__/Positions'; import { marginsDataProvider } from './margin-data-provider'; import { calculateMargins } from './margin-calculator'; -import type { Edge } from '@vegaprotocol/utils'; import { Side } from '@vegaprotocol/types'; import { marketInfoProvider } from '@vegaprotocol/market-info'; import type { MarketInfoQuery } from '@vegaprotocol/market-info'; diff --git a/libs/positions/src/lib/use-market-margin.tsx b/libs/positions/src/lib/use-market-margin.tsx index 5fa1d951c..89ff18634 100644 --- a/libs/positions/src/lib/use-market-margin.tsx +++ b/libs/positions/src/lib/use-market-margin.tsx @@ -1,6 +1,6 @@ import { useCallback, useState } from 'react'; import { useVegaWallet } from '@vegaprotocol/wallet'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { marginsDataProvider } from './margin-data-provider'; import type { MarginFieldsFragment } from './__generated__/Positions'; diff --git a/libs/positions/src/lib/use-open-volume.ts b/libs/positions/src/lib/use-open-volume.ts index 7e460c426..696e522fe 100644 --- a/libs/positions/src/lib/use-open-volume.ts +++ b/libs/positions/src/lib/use-open-volume.ts @@ -1,6 +1,6 @@ import { useState, useCallback } from 'react'; import { openVolumeDataProvider } from './positions-data-providers'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; export const useOpenVolume = ( partyId: string | null | undefined, diff --git a/libs/positions/src/lib/use-positions-data.spec.tsx b/libs/positions/src/lib/use-positions-data.spec.tsx index 8de6dcbb2..f044f22b6 100644 --- a/libs/positions/src/lib/use-positions-data.spec.tsx +++ b/libs/positions/src/lib/use-positions-data.spec.tsx @@ -44,8 +44,8 @@ const mockDataProvider = jest.fn((args) => { updateMock = args.update; return mockDataProviderData; }); -jest.mock('@vegaprotocol/react-helpers', () => ({ - ...jest.requireActual('@vegaprotocol/react-helpers'), +jest.mock('@vegaprotocol/data-provider', () => ({ + ...jest.requireActual('@vegaprotocol/data-provider'), useDataProvider: jest.fn((args) => mockDataProvider(args)), })); diff --git a/libs/positions/src/lib/use-positions-data.tsx b/libs/positions/src/lib/use-positions-data.tsx index 6759639ef..aca8aa16c 100644 --- a/libs/positions/src/lib/use-positions-data.tsx +++ b/libs/positions/src/lib/use-positions-data.tsx @@ -4,7 +4,8 @@ import type { AgGridReact } from 'ag-grid-react'; import type { Position } from './positions-data-providers'; import { positionsMetricsProvider } from './positions-data-providers'; import type { PositionsQueryVariables } from './__generated__/Positions'; -import { useDataProvider, updateGridData } from '@vegaprotocol/react-helpers'; +import { updateGridData } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import type { GetRowsParams } from '@vegaprotocol/datagrid'; import isEqual from 'lodash/isEqual'; diff --git a/libs/proposals/src/lib/proposals-data-provider/proposals-data-provider.tsx b/libs/proposals/src/lib/proposals-data-provider/proposals-data-provider.tsx index 07b27604b..acdbd808a 100644 --- a/libs/proposals/src/lib/proposals-data-provider/proposals-data-provider.tsx +++ b/libs/proposals/src/lib/proposals-data-provider/proposals-data-provider.tsx @@ -1,4 +1,4 @@ -import { makeDataProvider } from '@vegaprotocol/utils'; +import { makeDataProvider } from '@vegaprotocol/data-provider'; import type { ProposalsListQuery, ProposalsListQueryVariables, diff --git a/libs/proposals/src/lib/proposals-hooks/use-update-proposal.spec.ts b/libs/proposals/src/lib/proposals-hooks/use-update-proposal.spec.ts index d75211fd8..9f2cd8d9d 100644 --- a/libs/proposals/src/lib/proposals-hooks/use-update-proposal.spec.ts +++ b/libs/proposals/src/lib/proposals-hooks/use-update-proposal.spec.ts @@ -203,8 +203,8 @@ const mockDataProviderData: { const mockDataProvider = jest.fn(() => { return mockDataProviderData; }); -jest.mock('@vegaprotocol/react-helpers', () => ({ - ...jest.requireActual('@vegaprotocol/react-helpers'), +jest.mock('@vegaprotocol/data-provider', () => ({ + ...jest.requireActual('@vegaprotocol/data-provider'), useDataProvider: jest.fn((args) => mockDataProvider()), })); diff --git a/libs/proposals/src/lib/proposals-hooks/use-update-proposal.ts b/libs/proposals/src/lib/proposals-hooks/use-update-proposal.ts index 0989e750d..57f484f69 100644 --- a/libs/proposals/src/lib/proposals-hooks/use-update-proposal.ts +++ b/libs/proposals/src/lib/proposals-hooks/use-update-proposal.ts @@ -1,6 +1,6 @@ import { proposalsDataProvider } from '..'; import * as Schema from '@vegaprotocol/types'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { useMemo } from 'react'; import first from 'lodash/first'; import type { ProposalListFieldsFragment } from '..'; diff --git a/libs/proposals/src/lib/proposals-list/proposal-list.spec.tsx b/libs/proposals/src/lib/proposals-list/proposal-list.spec.tsx index 5fd6cdc61..a4465bd8e 100644 --- a/libs/proposals/src/lib/proposals-list/proposal-list.spec.tsx +++ b/libs/proposals/src/lib/proposals-list/proposal-list.spec.tsx @@ -43,8 +43,8 @@ const useDataProvider = () => { error: false, }; }; -jest.mock('@vegaprotocol/react-helpers', () => ({ - ...jest.requireActual('@vegaprotocol/react-helpers'), +jest.mock('@vegaprotocol/data-provider', () => ({ + ...jest.requireActual('@vegaprotocol/data-provider'), useDataProvider: jest.fn(() => useDataProvider()), })); diff --git a/libs/proposals/src/lib/proposals-list/proposals-list.tsx b/libs/proposals/src/lib/proposals-list/proposals-list.tsx index 1e421679a..f2ae575cf 100644 --- a/libs/proposals/src/lib/proposals-list/proposals-list.tsx +++ b/libs/proposals/src/lib/proposals-list/proposals-list.tsx @@ -1,7 +1,7 @@ import { useCallback, useEffect, useRef, useState } from 'react'; import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; import { AgGridLazy as AgGrid } from '@vegaprotocol/datagrid'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { t } from '@vegaprotocol/i18n'; import * as Types from '@vegaprotocol/types'; import { proposalsDataProvider } from '../proposals-data-provider'; diff --git a/libs/proposals/src/lib/proposals-list/use-column-defs.tsx b/libs/proposals/src/lib/proposals-list/use-column-defs.tsx index be65fbdc6..e0e571ab0 100644 --- a/libs/proposals/src/lib/proposals-list/use-column-defs.tsx +++ b/libs/proposals/src/lib/proposals-list/use-column-defs.tsx @@ -5,7 +5,10 @@ import { DateRangeFilter, SetFilter } from '@vegaprotocol/datagrid'; import { useEnvironment } from '@vegaprotocol/environment'; import { getDateTimeFormat } from '@vegaprotocol/utils'; import { t } from '@vegaprotocol/i18n'; -import { NetworkParams, useNetworkParams } from '@vegaprotocol/react-helpers'; +import { + NetworkParams, + useNetworkParams, +} from '@vegaprotocol/network-parameters'; import type { VegaICellRendererParams, VegaValueFormatterParams, diff --git a/libs/react-helpers/.eslintrc.json b/libs/react-helpers/.eslintrc.json index de2a9b877..95a79ce34 100644 --- a/libs/react-helpers/.eslintrc.json +++ b/libs/react-helpers/.eslintrc.json @@ -4,7 +4,16 @@ "overrides": [ { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "rules": {} + "rules": { + "no-restricted-imports": [ + "error", + "@apollo/client", + "@vegaprotocol/data-provider", + "graphql", + "graphql-tag", + "graphql-ws" + ] + } }, { "files": ["*.ts", "*.tsx"], diff --git a/libs/react-helpers/src/hooks/index.ts b/libs/react-helpers/src/hooks/index.ts index 92d319aa5..724ae9f81 100644 --- a/libs/react-helpers/src/hooks/index.ts +++ b/libs/react-helpers/src/hooks/index.ts @@ -1,10 +1,7 @@ -export * from './__generated__/NetworkParams'; export * from './use-apply-grid-transaction'; -export * from './use-data-provider'; export * from './use-fetch'; export * from './use-local-storage'; export * from './use-mutation-observer'; -export * from './use-network-params'; export * from './use-navigator-online'; export * from './use-number-parts'; export * from './use-outside-click'; diff --git a/libs/react-helpers/src/lib/index.ts b/libs/react-helpers/src/lib/index.ts index 93ab45d31..37a3d05e8 100644 --- a/libs/react-helpers/src/lib/index.ts +++ b/libs/react-helpers/src/lib/index.ts @@ -1,4 +1,3 @@ -export * from './__generated__/ChainId'; export * from './ag-grid-update'; export * from './format'; export * from './grid'; diff --git a/libs/trades/src/lib/trades-container.tsx b/libs/trades/src/lib/trades-container.tsx index 0af7cb4b9..1779426e0 100644 --- a/libs/trades/src/lib/trades-container.tsx +++ b/libs/trades/src/lib/trades-container.tsx @@ -1,5 +1,5 @@ -import { makeInfiniteScrollGetRows } from '@vegaprotocol/utils'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { makeInfiniteScrollGetRows } from '@vegaprotocol/data-provider'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; import type { AgGridReact } from 'ag-grid-react'; import { useCallback, useRef } from 'react'; diff --git a/libs/trades/src/lib/trades-data-provider.ts b/libs/trades/src/lib/trades-data-provider.ts index 22440929f..18f17074d 100644 --- a/libs/trades/src/lib/trades-data-provider.ts +++ b/libs/trades/src/lib/trades-data-provider.ts @@ -4,8 +4,8 @@ import { defaultAppend as append, paginatedCombineDelta as combineDelta, paginatedCombineInsertionData as combineInsertionData, -} from '@vegaprotocol/utils'; -import type { PageInfo, Edge } from '@vegaprotocol/utils'; +} from '@vegaprotocol/data-provider'; +import type { PageInfo, Edge } from '@vegaprotocol/data-provider'; import type { Market } from '@vegaprotocol/market-list'; import { marketsProvider } from '@vegaprotocol/market-list'; import type { diff --git a/libs/utils/.eslintrc.json b/libs/utils/.eslintrc.json index 9d9c0db55..340d6c422 100644 --- a/libs/utils/.eslintrc.json +++ b/libs/utils/.eslintrc.json @@ -4,7 +4,16 @@ "overrides": [ { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "rules": {} + "rules": { + "no-restricted-imports": [ + "error", + "@apollo/client", + "@vegaprotocol/data-provider", + "graphql", + "graphql-tag", + "graphql-ws" + ] + } }, { "files": ["*.ts", "*.tsx"], diff --git a/libs/utils/src/index.ts b/libs/utils/src/index.ts index 15f600113..21ca3cd2b 100644 --- a/libs/utils/src/index.ts +++ b/libs/utils/src/index.ts @@ -1,7 +1,5 @@ -export * from './lib/apollo-client'; export * from './lib/flag-emoji'; export * from './lib/format'; -export * from './lib/generic-data-provider'; export * from './lib/get-events'; export * from './lib/get-nodes'; export * from './lib/get-user-locale'; @@ -12,7 +10,6 @@ export * from './lib/links'; export * from './lib/local-logger'; export * from './lib/local-storage'; export * from './lib/markets'; -export * from './lib/pagination'; export * from './lib/remove-0x'; export * from './lib/remove-pagination-wrapper'; export * from './lib/time'; diff --git a/libs/utils/tsconfig.lib.json b/libs/utils/tsconfig.lib.json index bcdddcf3e..e85ef50f6 100644 --- a/libs/utils/tsconfig.lib.json +++ b/libs/utils/tsconfig.lib.json @@ -5,6 +5,6 @@ "declaration": true, "types": [] }, - "include": ["**/*.ts", "../ui-toolkit/src/utils/cell-class-rules.ts"], + "include": ["**/*.ts"], "exclude": ["jest.config.ts", "**/*.spec.ts", "**/*.test.ts"] } diff --git a/libs/react-helpers/src/lib/ChainId.graphql b/libs/wallet/src/connect-dialog/ChainId.graphql similarity index 100% rename from libs/react-helpers/src/lib/ChainId.graphql rename to libs/wallet/src/connect-dialog/ChainId.graphql diff --git a/libs/react-helpers/src/lib/__generated__/ChainId.ts b/libs/wallet/src/connect-dialog/__generated__/ChainId.ts similarity index 100% rename from libs/react-helpers/src/lib/__generated__/ChainId.ts rename to libs/wallet/src/connect-dialog/__generated__/ChainId.ts diff --git a/libs/react-helpers/src/lib/chain-id.mock.ts b/libs/wallet/src/connect-dialog/chain-id.mock.ts similarity index 100% rename from libs/react-helpers/src/lib/chain-id.mock.ts rename to libs/wallet/src/connect-dialog/chain-id.mock.ts diff --git a/libs/wallet/src/connect-dialog/connect-dialog.spec.tsx b/libs/wallet/src/connect-dialog/connect-dialog.spec.tsx index 60aed606c..5f981c86e 100644 --- a/libs/wallet/src/connect-dialog/connect-dialog.spec.tsx +++ b/libs/wallet/src/connect-dialog/connect-dialog.spec.tsx @@ -22,8 +22,8 @@ import { WalletError, } from '../connectors'; import { useEnvironment } from '@vegaprotocol/environment'; -import type { ChainIdQuery } from '@vegaprotocol/react-helpers'; -import { ChainIdDocument } from '@vegaprotocol/react-helpers'; +import type { ChainIdQuery } from './__generated__/ChainId'; +import { ChainIdDocument } from './__generated__/ChainId'; const mockUpdateDialogOpen = jest.fn(); const mockCloseVegaDialog = jest.fn(); diff --git a/libs/wallet/src/connect-dialog/connect-dialog.tsx b/libs/wallet/src/connect-dialog/connect-dialog.tsx index 8c30bdc15..5c085bf52 100644 --- a/libs/wallet/src/connect-dialog/connect-dialog.tsx +++ b/libs/wallet/src/connect-dialog/connect-dialog.tsx @@ -12,7 +12,6 @@ import { useCallback, useState } from 'react'; import type { WalletClientError } from '@vegaprotocol/wallet-client'; import { ExternalLinks } from '@vegaprotocol/utils'; import { t } from '@vegaprotocol/i18n'; -import { useChainIdQuery } from '@vegaprotocol/react-helpers'; import type { VegaConnector } from '../connectors'; import { ViewConnector } from '../connectors'; import { JsonRpcConnector, RestConnector } from '../connectors'; @@ -27,6 +26,7 @@ import { import type { Status } from '../use-json-rpc-connect'; import { useJsonRpcConnect } from '../use-json-rpc-connect'; import { ViewConnectorForm } from './view-connector-form'; +import { useChainIdQuery } from './__generated__/ChainId'; export const CLOSE_DELAY = 1700; type Connectors = { [key: string]: VegaConnector }; diff --git a/libs/web3/src/lib/use-ethereum-config.ts b/libs/web3/src/lib/use-ethereum-config.ts index c38e5f0b1..9dcb45ea8 100644 --- a/libs/web3/src/lib/use-ethereum-config.ts +++ b/libs/web3/src/lib/use-ethereum-config.ts @@ -1,4 +1,4 @@ -import { useNetworkParamsQuery } from '@vegaprotocol/react-helpers'; +import { useNetworkParamsQuery } from '@vegaprotocol/network-parameters'; import { removePaginationWrapper } from '@vegaprotocol/utils'; import { useMemo } from 'react'; diff --git a/libs/web3/src/lib/use-ethereum-withdraw-approvals-manager.spec.tsx b/libs/web3/src/lib/use-ethereum-withdraw-approvals-manager.spec.tsx index 960c77b37..f9321ea35 100644 --- a/libs/web3/src/lib/use-ethereum-withdraw-approvals-manager.spec.tsx +++ b/libs/web3/src/lib/use-ethereum-withdraw-approvals-manager.spec.tsx @@ -16,8 +16,8 @@ import type { EthTransactionStore } from './use-ethereum-transaction-store'; import { WithdrawalApprovalDocument } from '@vegaprotocol/wallet'; import type { WithdrawalApprovalQuery } from '@vegaprotocol/wallet'; -import { NetworkParamsDocument } from '@vegaprotocol/react-helpers'; -import type { NetworkParamsQuery } from '@vegaprotocol/react-helpers'; +import { NetworkParamsDocument } from '@vegaprotocol/network-parameters'; +import type { NetworkParamsQuery } from '@vegaprotocol/network-parameters'; const mockWeb3Provider = jest.fn(); diff --git a/libs/withdraws/src/lib/withdraw-form-container.spec.tsx b/libs/withdraws/src/lib/withdraw-form-container.spec.tsx index a16393b9e..ad6683f7d 100644 --- a/libs/withdraws/src/lib/withdraw-form-container.spec.tsx +++ b/libs/withdraws/src/lib/withdraw-form-container.spec.tsx @@ -6,8 +6,9 @@ import { WithdrawFormContainer } from './withdraw-form-container'; import * as Types from '@vegaprotocol/types'; import { useWeb3React } from '@web3-react/core'; let mockData: Account[] | null = null; -jest.mock('@vegaprotocol/react-helpers', () => ({ - ...jest.requireActual('@vegaprotocol/react-helpers'), + +jest.mock('@vegaprotocol/data-provider', () => ({ + ...jest.requireActual('@vegaprotocol/data-provider'), useDataProvider: () => ({ data: mockData, }), diff --git a/libs/withdraws/src/lib/withdraw-form-container.tsx b/libs/withdraws/src/lib/withdraw-form-container.tsx index 036f6c1ff..b6e92e806 100644 --- a/libs/withdraws/src/lib/withdraw-form-container.tsx +++ b/libs/withdraws/src/lib/withdraw-form-container.tsx @@ -1,7 +1,7 @@ import { useMemo } from 'react'; import { toBigNum } from '@vegaprotocol/utils'; import { t } from '@vegaprotocol/i18n'; -import { useDataProvider } from '@vegaprotocol/react-helpers'; +import { useDataProvider } from '@vegaprotocol/data-provider'; import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; import { accountsDataProvider } from '@vegaprotocol/accounts'; import type { WithdrawalArgs } from './use-create-withdraw'; diff --git a/libs/withdraws/src/lib/withdrawals-provider.ts b/libs/withdraws/src/lib/withdrawals-provider.ts index 1c056d1ae..d52cea6d5 100644 --- a/libs/withdraws/src/lib/withdrawals-provider.ts +++ b/libs/withdraws/src/lib/withdrawals-provider.ts @@ -1,9 +1,6 @@ import uniqBy from 'lodash/uniqBy'; -import { - makeDataProvider, - removePaginationWrapper, - getEvents, -} from '@vegaprotocol/utils'; +import { removePaginationWrapper, getEvents } from '@vegaprotocol/utils'; +import { makeDataProvider } from '@vegaprotocol/data-provider'; import * as Schema from '@vegaprotocol/types'; import { WithdrawalsDocument, diff --git a/package.json b/package.json index 721c29aed..386aa68c1 100644 --- a/package.json +++ b/package.json @@ -132,6 +132,8 @@ "@storybook/manager-webpack5": "6.5.10", "@storybook/react": "6.5.10", "@svgr/webpack": "^5.4.0", + "@swc/core": "^1.2.173", + "@swc/jest": "0.2.20", "@testing-library/jest-dom": "^5.16.2", "@testing-library/react": "13.3.0", "@testing-library/user-event": "^14.4.1", diff --git a/tsconfig.base.json b/tsconfig.base.json index c0e01c8ce..db2ec726c 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -22,6 +22,7 @@ "@vegaprotocol/assets": ["libs/assets/src/index.ts"], "@vegaprotocol/candles-chart": ["libs/candles-chart/src/index.ts"], "@vegaprotocol/cypress": ["libs/cypress/src/index.ts"], + "@vegaprotocol/data-provider": ["libs/data-provider/src/index.ts"], "@vegaprotocol/datagrid": ["libs/datagrid/src/index.ts"], "@vegaprotocol/deal-ticket": ["libs/deal-ticket/src/index.ts"], "@vegaprotocol/deposits": ["libs/deposits/src/index.ts"], @@ -35,6 +36,9 @@ "@vegaprotocol/market-list": ["libs/market-list/src/index.ts"], "@vegaprotocol/mock": ["libs/cypress/mock.ts"], "@vegaprotocol/network-info": ["libs/network-info/src/index.ts"], + "@vegaprotocol/network-parameters": [ + "libs/network-parameters/src/index.ts" + ], "@vegaprotocol/network-stats": ["libs/network-stats/src/index.ts"], "@vegaprotocol/oracles": ["libs/oracles/src/index.ts"], "@vegaprotocol/orders": ["libs/orders/src/index.ts"], diff --git a/workspace.json b/workspace.json index 987074145..0315f095d 100644 --- a/workspace.json +++ b/workspace.json @@ -7,6 +7,7 @@ "assets": "libs/assets", "candles-chart": "libs/candles-chart", "cypress": "libs/cypress", + "data-provider": "libs/data-provider", "datagrid": "libs/datagrid", "deal-ticket": "libs/deal-ticket", "deposits": "libs/deposits", @@ -25,6 +26,7 @@ "market-list": "libs/market-list", "multisig-signer": "apps/multisig-signer", "network-info": "libs/network-info", + "network-parameters": "libs/network-parameters", "network-stats": "libs/network-stats", "oracles": "libs/oracles", "orders": "libs/orders", diff --git a/yarn.lock b/yarn.lock index e7e9b910f..2452b44b9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3189,6 +3189,13 @@ slash "^3.0.0" strip-ansi "^6.0.0" +"@jest/create-cache-key-function@^27.4.2": + version "27.5.1" + resolved "https://registry.yarnpkg.com/@jest/create-cache-key-function/-/create-cache-key-function-27.5.1.tgz#7448fae15602ea95c828f5eceed35c202a820b31" + integrity sha512-dmH1yW+makpTSURTy8VzdUwFnfQh1G8R+DxO2Ho2FFmBbKFEVm+3jWdvFhE2VqB/LATCTokkP0dotjyQyw5/AQ== + dependencies: + "@jest/types" "^27.5.1" + "@jest/environment@^27.5.1": version "27.5.1" resolved "https://registry.yarnpkg.com/@jest/environment/-/environment-27.5.1.tgz#d7425820511fe7158abbecc010140c3fd3be9c74" @@ -6741,6 +6748,72 @@ "@svgr/plugin-jsx" "^6.4.0" "@svgr/plugin-svgo" "^6.3.1" +"@swc/core-darwin-arm64@1.3.56": + version "1.3.56" + resolved "https://registry.yarnpkg.com/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.56.tgz#a846f7fdbc274aa7d299568031dde025d44a3b4c" + integrity sha512-DZcu7BzDaLEdWHabz9DRTP0yEBLqkrWmskFcD5BX0lGAvoIvE4duMnAqi5F2B3X7630QioHRCYFoRw2WkeE3Cw== + +"@swc/core-darwin-x64@1.3.56": + version "1.3.56" + resolved "https://registry.yarnpkg.com/@swc/core-darwin-x64/-/core-darwin-x64-1.3.56.tgz#793865f14f07f5eff6a6e6764aa6c766983fa007" + integrity sha512-VH5saqYFasdRXJy6RAT+MXm0+IjkMZvOkohJwUei+oA65cKJofQwrJ1jZro8yOJFYvUSI3jgNRGsdBkmo/4hMw== + +"@swc/core-linux-arm-gnueabihf@1.3.56": + version "1.3.56" + resolved "https://registry.yarnpkg.com/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.56.tgz#6942e9a4f6086da66d995c46c2ab2b0f7fa86a1d" + integrity sha512-LWwPo6NnJkH01+ukqvkoNIOpMdw+Zundm4vBeicwyVrkP+mC3kwVfi03TUFpQUz3kRKdw/QEnxGTj+MouCPbtw== + +"@swc/core-linux-arm64-gnu@1.3.56": + version "1.3.56" + resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.56.tgz#21c3f8083c2d0a8028a07bf42cdd2a345e5108e9" + integrity sha512-GzsUy/4egJ4cMlxbM+Ub7AMi5CKAc+pxBxrh8MUPQbyStW8jGgnQsJouTnGy0LHawtdEnsCOl6PcO6OgvktXuQ== + +"@swc/core-linux-arm64-musl@1.3.56": + version "1.3.56" + resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.56.tgz#87c9781f0814bca65074f357e5cfdcdd7fb09845" + integrity sha512-9gxL09BIiAv8zY0DjfnFf19bo8+P4T9tdhzPwcm+1yPJcY5yr1+YFWLNFzz01agtOj6VlZ2/wUJTaOfdjjtc+A== + +"@swc/core-linux-x64-gnu@1.3.56": + version "1.3.56" + resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.56.tgz#55edae77d1c6a2b6230abbc79bccd175cb7c2208" + integrity sha512-n0ORNknl50vMRkll3BDO1E4WOqY6iISlPV1ZQCRLWQ6YQ2q8/WAryBxc2OAybcGHBUFkxyACpJukeU1QZ/9tNw== + +"@swc/core-linux-x64-musl@1.3.56": + version "1.3.56" + resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.56.tgz#45bf5a6611350bcbe3bdd1eac6f5fcfe69502137" + integrity sha512-r+D34WLAOAlJtfw1gaVWpHRwCncU9nzW9i7w9kSw4HpWYnHJOz54jLGSEmNsrhdTCz1VK2ar+V2ktFUsrlGlDA== + +"@swc/core-win32-arm64-msvc@1.3.56": + version "1.3.56" + resolved "https://registry.yarnpkg.com/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.56.tgz#28853170b9e4f57a793d617aab75ef4b9c4b8a7f" + integrity sha512-29Yt75Is6X24z3x8h/xZC1HnDPkPpyLH9mDQiM6Cuc0I9mVr1XSriPEUB2N/awf5IE4SA8c+3IVq1DtKWbkJIw== + +"@swc/core-win32-ia32-msvc@1.3.56": + version "1.3.56" + resolved "https://registry.yarnpkg.com/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.56.tgz#dfa120fece0741c6ccc24885d4c155c9593a956e" + integrity sha512-mplp0zbYDrcHtfvkniXlXdB04e2qIjz2Gq/XHKr4Rnc6xVORJjjXF91IemXKpavx2oZYJws+LNJL7UFQ8jyCdQ== + +"@swc/core-win32-x64-msvc@1.3.56": + version "1.3.56" + resolved "https://registry.yarnpkg.com/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.56.tgz#23b601b9afcdc435e2e4d66767ac5fa6bb50d640" + integrity sha512-zp8MBnrw/bjdLenO/ifYzHrImSjKunqL0C2IF4LXYNRfcbYFh2NwobsVQMZ20IT0474lKRdlP8Oxdt+bHuXrzA== + +"@swc/core@^1.2.173": + version "1.3.56" + resolved "https://registry.yarnpkg.com/@swc/core/-/core-1.3.56.tgz#b12e98bc9ef39dc6092e71ea922f8073f7bec50f" + integrity sha512-yz/EeXT+PMZucUNrYceRUaTfuNS4IIu5EDZSOlvCEvm4jAmZi7CYH1B/kvzEzoAOzr7zkQiDPNJftcQXLkjbjA== + optionalDependencies: + "@swc/core-darwin-arm64" "1.3.56" + "@swc/core-darwin-x64" "1.3.56" + "@swc/core-linux-arm-gnueabihf" "1.3.56" + "@swc/core-linux-arm64-gnu" "1.3.56" + "@swc/core-linux-arm64-musl" "1.3.56" + "@swc/core-linux-x64-gnu" "1.3.56" + "@swc/core-linux-x64-musl" "1.3.56" + "@swc/core-win32-arm64-msvc" "1.3.56" + "@swc/core-win32-ia32-msvc" "1.3.56" + "@swc/core-win32-x64-msvc" "1.3.56" + "@swc/helpers@0.4.3": version "0.4.3" resolved "https://registry.yarnpkg.com/@swc/helpers/-/helpers-0.4.3.tgz#16593dfc248c53b699d4b5026040f88ddb497012" @@ -6748,6 +6821,13 @@ dependencies: tslib "^2.4.0" +"@swc/jest@0.2.20": + version "0.2.20" + resolved "https://registry.yarnpkg.com/@swc/jest/-/jest-0.2.20.tgz#2bddb4348fb730296b86cdcd96748be131b11395" + integrity sha512-5qSUBYY1wyIMn7p0Vl9qqV4hMI69oJwZCIPUpBsTFWN2wlwn6RDugzdgCn+bLXVYh+Cxi8bJcZ1uumDgsoL+FA== + dependencies: + "@jest/create-cache-key-function" "^27.4.2" + "@szmarczak/http-timer@^1.1.2": version "1.1.2" resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-1.1.2.tgz#b1665e2c461a2cd92f4c1bbf50d5454de0d4b421"