From 7613a9fa9f29313384beccaf662a767dff796986 Mon Sep 17 00:00:00 2001 From: botond <105208209+notbot00@users.noreply.github.com> Date: Fri, 9 Sep 2022 16:14:48 +0100 Subject: [PATCH] Feat/migrate libs (#1266) * feat: add new generator with config * feat: split off gql queries to separate files for the new generator * fix: delete dummy schema * feat: add generated queries with new codegen * fix: regenerate from scratch and remove duplicates * fix: libs and app gen folders * fix: remove more duplicate queries * fix: add generated files to be ignored by the formatter * fix: format * feat: migrate assets to use new code generator * fix: generated imports * fix: lint * fix: accounts export * fix: more imports * fix: add type alias for new type system and regenerate * fix: format * fix: export * fix: format * fix: delete leftover file from merge * chore: migrate candles-chart lib * fix: remove redundant asset files * chore: migrate accounts * chore: update glob * chore: add cleanup to fix-imports to support type migrations for now * fix: imports * fix: update market types * fix: type import paths * fix: format * fix: import * fix: types in e2e tests * fix: format * fix: lint --- .../deal-ticket/__generated___/MarketTags.ts | 2 +- .../__generated___/PartyBalance.ts | 2 +- .../deposits/__generated___/Deposits.ts | 2 +- .../__generated___/Candles.ts | 2 +- .../__generated___/SimpleMarkets.ts | 2 +- .../app/hooks/__generated___/EstimateOrder.ts | 2 +- .../hooks/__generated___/MarketMarkPrice.ts | 2 +- .../hooks/__generated___/MarketPositions.ts | 2 +- .../hooks/__generated___/PartyMarketData.ts | 2 +- .../routes/assets/__generated___/Assets.ts | 2 +- .../governance/__generated___/Proposals.ts | 2 +- .../routes/markets/__generated___/Markets.ts | 2 +- .../__generated___/NetworkParameters.ts | 2 +- .../oracles/__generated___/OracleSpecs.ts | 2 +- .../parties/__generated___/PartyAssets.ts | 2 +- .../routes/validators/__generated___/Nodes.ts | 2 +- .../vega-wallet/__generated___/Delegations.ts | 2 +- .../src/hooks/__generated___/NetworkParams.ts | 2 +- .../governance/__generated___/Proposal.ts | 2 +- .../vote-details/__generated___/Stake.ts | 2 +- .../routes/home/__generated___/NodeData.ts | 2 +- .../rewards/home/__generated___/Rewards.ts | 2 +- .../routes/staking/__generated___/Nodes.ts | 2 +- .../__generated___/PartyDelegations.ts | 2 +- .../routes/staking/__generated___/Staking.ts | 2 +- .../__generated___/PartyStakeLinkings.ts | 2 +- .../src/support/mocks/generate-accounts.ts | 8 +- .../src/support/mocks/generate-candles.ts | 10 +- .../src/support/mocks/generate-chart.ts | 18 +- .../pages/markets/__generated___/Market.ts | 2 +- .../deposit/__generated___/Deposit.ts | 2 +- libs/accounts/src/lib/Accounts.graphql | 20 +- .../src/lib/__generated__/AccountFields.ts | 74 ------- .../src/lib/__generated__/AccountSubscribe.ts | 85 -------- .../src/lib/__generated__/Accounts.ts | 189 ++++++++-------- .../src/lib/__generated___/Accounts.ts | 110 ---------- .../src/lib/accounts-data-provider.ts | 89 +++----- libs/accounts/src/lib/accounts-manager.tsx | 17 +- libs/accounts/src/lib/accounts-table.spec.tsx | 4 +- libs/accounts/src/lib/accounts-table.tsx | 16 +- libs/accounts/src/lib/asset-balance.tsx | 7 +- libs/accounts/src/lib/index.ts | 2 - .../Assets.ts | 2 +- .../src/lib/__generated__/AssetsConnection.ts | 80 ------- .../src/lib/asset-details-dialog.spec.tsx | 8 +- libs/assets/src/lib/asset-details-dialog.tsx | 47 +--- libs/assets/src/lib/index.ts | 2 +- libs/candles-chart/src/lib/Candles.graphql | 2 +- .../src/lib/__generated__/CandleFields.ts | 36 --- .../src/lib/__generated__/Candles.ts | 205 +++++++++--------- .../src/lib/__generated__/CandlesSub.ts | 50 ----- .../src/lib/__generated__/Chart.ts | 115 +++++----- .../src/lib/__generated___/Candles.ts | 113 ---------- .../src/lib/__generated___/Chart.ts | 55 ----- libs/candles-chart/src/lib/data-source.ts | 111 +++------- libs/candles-chart/src/lib/index.ts | 2 - .../components/__generated___/DealTicket.ts | 2 +- .../components/__generated___/MarketInfo.ts | 2 +- .../components/__generated___/MarketNames.ts | 2 +- .../__generated__/MarketInfoQuery.ts | 4 +- .../src/lib/__generated___/Deposit.ts | 2 +- libs/fills/src/lib/__generated___/Fills.ts | 2 +- .../__generated___/Proposal.ts | 2 +- .../src/lib/__generated___/MarketDepth.ts | 2 +- .../src/lib/__generated___/MarketData.ts | 2 +- .../stats-manager/__generated___/Stats.ts | 2 +- .../lib/order-hooks/__generated___/Orders.ts | 2 +- .../src/lib/__generated___/Positions.ts | 2 +- .../src/lib/positions-data-providers.spec.ts | 4 +- .../src/lib/positions-data-providers.ts | 6 +- libs/trades/src/lib/__generated___/Trades.ts | 2 +- libs/types/apollo.config.js | 8 +- libs/types/codegen.yml | 8 +- libs/types/fix-imports.js | 68 +++++- .../src/lib/__generated___/NetworkParams.ts | 2 +- .../src/lib/__generated___/Erc20Approval.ts | 2 +- .../src/lib/__generated___/Withdraw.ts | 2 +- .../src/lib/__generated___/Withdrawal.ts | 2 +- .../src/lib/use-create-withdraw.spec.tsx | 4 +- package.json | 2 +- tsconfig.base.json | 1 - yarn.lock | 2 +- 82 files changed, 511 insertions(+), 1161 deletions(-) delete mode 100644 libs/accounts/src/lib/__generated__/AccountFields.ts delete mode 100644 libs/accounts/src/lib/__generated__/AccountSubscribe.ts delete mode 100644 libs/accounts/src/lib/__generated___/Accounts.ts rename libs/assets/src/lib/{__generated___ => __generated__}/Assets.ts (97%) delete mode 100644 libs/assets/src/lib/__generated__/AssetsConnection.ts delete mode 100644 libs/candles-chart/src/lib/__generated__/CandleFields.ts delete mode 100644 libs/candles-chart/src/lib/__generated__/CandlesSub.ts delete mode 100644 libs/candles-chart/src/lib/__generated___/Candles.ts delete mode 100644 libs/candles-chart/src/lib/__generated___/Chart.ts diff --git a/apps/console-lite/src/app/components/deal-ticket/__generated___/MarketTags.ts b/apps/console-lite/src/app/components/deal-ticket/__generated___/MarketTags.ts index 99e0ebbc4..d6b879f57 100644 --- a/apps/console-lite/src/app/components/deal-ticket/__generated___/MarketTags.ts +++ b/apps/console-lite/src/app/components/deal-ticket/__generated___/MarketTags.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/apps/console-lite/src/app/components/deal-ticket/__generated___/PartyBalance.ts b/apps/console-lite/src/app/components/deal-ticket/__generated___/PartyBalance.ts index 37892e30e..60fd8862f 100644 --- a/apps/console-lite/src/app/components/deal-ticket/__generated___/PartyBalance.ts +++ b/apps/console-lite/src/app/components/deal-ticket/__generated___/PartyBalance.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/apps/console-lite/src/app/components/deposits/__generated___/Deposits.ts b/apps/console-lite/src/app/components/deposits/__generated___/Deposits.ts index 8e8972412..11720a480 100644 --- a/apps/console-lite/src/app/components/deposits/__generated___/Deposits.ts +++ b/apps/console-lite/src/app/components/deposits/__generated___/Deposits.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/apps/console-lite/src/app/components/simple-market-list/__generated___/Candles.ts b/apps/console-lite/src/app/components/simple-market-list/__generated___/Candles.ts index 10852a97c..a69c128f3 100644 --- a/apps/console-lite/src/app/components/simple-market-list/__generated___/Candles.ts +++ b/apps/console-lite/src/app/components/simple-market-list/__generated___/Candles.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/apps/console-lite/src/app/components/simple-market-list/__generated___/SimpleMarkets.ts b/apps/console-lite/src/app/components/simple-market-list/__generated___/SimpleMarkets.ts index ee1e0743e..fa5e240ac 100644 --- a/apps/console-lite/src/app/components/simple-market-list/__generated___/SimpleMarkets.ts +++ b/apps/console-lite/src/app/components/simple-market-list/__generated___/SimpleMarkets.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/apps/console-lite/src/app/hooks/__generated___/EstimateOrder.ts b/apps/console-lite/src/app/hooks/__generated___/EstimateOrder.ts index a9584623d..8a51585dc 100644 --- a/apps/console-lite/src/app/hooks/__generated___/EstimateOrder.ts +++ b/apps/console-lite/src/app/hooks/__generated___/EstimateOrder.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/apps/console-lite/src/app/hooks/__generated___/MarketMarkPrice.ts b/apps/console-lite/src/app/hooks/__generated___/MarketMarkPrice.ts index c229f45ac..666870091 100644 --- a/apps/console-lite/src/app/hooks/__generated___/MarketMarkPrice.ts +++ b/apps/console-lite/src/app/hooks/__generated___/MarketMarkPrice.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/apps/console-lite/src/app/hooks/__generated___/MarketPositions.ts b/apps/console-lite/src/app/hooks/__generated___/MarketPositions.ts index 090290948..e6dc12487 100644 --- a/apps/console-lite/src/app/hooks/__generated___/MarketPositions.ts +++ b/apps/console-lite/src/app/hooks/__generated___/MarketPositions.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/apps/console-lite/src/app/hooks/__generated___/PartyMarketData.ts b/apps/console-lite/src/app/hooks/__generated___/PartyMarketData.ts index b4e7f2c8c..516fc6126 100644 --- a/apps/console-lite/src/app/hooks/__generated___/PartyMarketData.ts +++ b/apps/console-lite/src/app/hooks/__generated___/PartyMarketData.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/apps/explorer/src/app/routes/assets/__generated___/Assets.ts b/apps/explorer/src/app/routes/assets/__generated___/Assets.ts index 2d89adea5..a7507a109 100644 --- a/apps/explorer/src/app/routes/assets/__generated___/Assets.ts +++ b/apps/explorer/src/app/routes/assets/__generated___/Assets.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/apps/explorer/src/app/routes/governance/__generated___/Proposals.ts b/apps/explorer/src/app/routes/governance/__generated___/Proposals.ts index b807b5e9d..7a9394f8f 100644 --- a/apps/explorer/src/app/routes/governance/__generated___/Proposals.ts +++ b/apps/explorer/src/app/routes/governance/__generated___/Proposals.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/apps/explorer/src/app/routes/markets/__generated___/Markets.ts b/apps/explorer/src/app/routes/markets/__generated___/Markets.ts index deb1d2bdd..e5e1c1a43 100644 --- a/apps/explorer/src/app/routes/markets/__generated___/Markets.ts +++ b/apps/explorer/src/app/routes/markets/__generated___/Markets.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/apps/explorer/src/app/routes/network-parameters/__generated___/NetworkParameters.ts b/apps/explorer/src/app/routes/network-parameters/__generated___/NetworkParameters.ts index d40f46c02..dd1045c07 100644 --- a/apps/explorer/src/app/routes/network-parameters/__generated___/NetworkParameters.ts +++ b/apps/explorer/src/app/routes/network-parameters/__generated___/NetworkParameters.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/apps/explorer/src/app/routes/oracles/__generated___/OracleSpecs.ts b/apps/explorer/src/app/routes/oracles/__generated___/OracleSpecs.ts index 9f53d037c..f146c789a 100644 --- a/apps/explorer/src/app/routes/oracles/__generated___/OracleSpecs.ts +++ b/apps/explorer/src/app/routes/oracles/__generated___/OracleSpecs.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/apps/explorer/src/app/routes/parties/__generated___/PartyAssets.ts b/apps/explorer/src/app/routes/parties/__generated___/PartyAssets.ts index 9c10bbff9..c3b1c42f0 100644 --- a/apps/explorer/src/app/routes/parties/__generated___/PartyAssets.ts +++ b/apps/explorer/src/app/routes/parties/__generated___/PartyAssets.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/apps/explorer/src/app/routes/validators/__generated___/Nodes.ts b/apps/explorer/src/app/routes/validators/__generated___/Nodes.ts index bf86e7858..ddcb8e34f 100644 --- a/apps/explorer/src/app/routes/validators/__generated___/Nodes.ts +++ b/apps/explorer/src/app/routes/validators/__generated___/Nodes.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/apps/token/src/components/vega-wallet/__generated___/Delegations.ts b/apps/token/src/components/vega-wallet/__generated___/Delegations.ts index 5d6610ba9..521d0282f 100644 --- a/apps/token/src/components/vega-wallet/__generated___/Delegations.ts +++ b/apps/token/src/components/vega-wallet/__generated___/Delegations.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/apps/token/src/hooks/__generated___/NetworkParams.ts b/apps/token/src/hooks/__generated___/NetworkParams.ts index 1208760a1..d63723105 100644 --- a/apps/token/src/hooks/__generated___/NetworkParams.ts +++ b/apps/token/src/hooks/__generated___/NetworkParams.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/apps/token/src/routes/governance/__generated___/Proposal.ts b/apps/token/src/routes/governance/__generated___/Proposal.ts index 29e37bd12..9bffdd389 100644 --- a/apps/token/src/routes/governance/__generated___/Proposal.ts +++ b/apps/token/src/routes/governance/__generated___/Proposal.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/apps/token/src/routes/governance/components/vote-details/__generated___/Stake.ts b/apps/token/src/routes/governance/components/vote-details/__generated___/Stake.ts index aa930de95..0c3473d7b 100644 --- a/apps/token/src/routes/governance/components/vote-details/__generated___/Stake.ts +++ b/apps/token/src/routes/governance/components/vote-details/__generated___/Stake.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/apps/token/src/routes/home/__generated___/NodeData.ts b/apps/token/src/routes/home/__generated___/NodeData.ts index b2bc06f54..3713ca816 100644 --- a/apps/token/src/routes/home/__generated___/NodeData.ts +++ b/apps/token/src/routes/home/__generated___/NodeData.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/apps/token/src/routes/rewards/home/__generated___/Rewards.ts b/apps/token/src/routes/rewards/home/__generated___/Rewards.ts index c39358064..49ca05f70 100644 --- a/apps/token/src/routes/rewards/home/__generated___/Rewards.ts +++ b/apps/token/src/routes/rewards/home/__generated___/Rewards.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/apps/token/src/routes/staking/__generated___/Nodes.ts b/apps/token/src/routes/staking/__generated___/Nodes.ts index c51582125..94f58eb5a 100644 --- a/apps/token/src/routes/staking/__generated___/Nodes.ts +++ b/apps/token/src/routes/staking/__generated___/Nodes.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/apps/token/src/routes/staking/__generated___/PartyDelegations.ts b/apps/token/src/routes/staking/__generated___/PartyDelegations.ts index 71ee9e4f9..0914c78b1 100644 --- a/apps/token/src/routes/staking/__generated___/PartyDelegations.ts +++ b/apps/token/src/routes/staking/__generated___/PartyDelegations.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/apps/token/src/routes/staking/__generated___/Staking.ts b/apps/token/src/routes/staking/__generated___/Staking.ts index af5b483fc..864f2ab32 100644 --- a/apps/token/src/routes/staking/__generated___/Staking.ts +++ b/apps/token/src/routes/staking/__generated___/Staking.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/apps/token/src/routes/staking/associate/__generated___/PartyStakeLinkings.ts b/apps/token/src/routes/staking/associate/__generated___/PartyStakeLinkings.ts index 48dd96edc..53e018802 100644 --- a/apps/token/src/routes/staking/associate/__generated___/PartyStakeLinkings.ts +++ b/apps/token/src/routes/staking/associate/__generated___/PartyStakeLinkings.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/apps/trading-e2e/src/support/mocks/generate-accounts.ts b/apps/trading-e2e/src/support/mocks/generate-accounts.ts index 91b40d0cd..f0e322bb5 100644 --- a/apps/trading-e2e/src/support/mocks/generate-accounts.ts +++ b/apps/trading-e2e/src/support/mocks/generate-accounts.ts @@ -1,12 +1,12 @@ import merge from 'lodash/merge'; -import type { Accounts } from '@vegaprotocol/accounts'; +import type { AccountsQuery } from '@vegaprotocol/accounts'; import { AccountType } from '@vegaprotocol/types'; import type { PartialDeep } from 'type-fest'; export const generateAccounts = ( - override?: PartialDeep -): Accounts => { - const defaultAccounts: Accounts = { + override?: PartialDeep +): AccountsQuery => { + const defaultAccounts: AccountsQuery = { party: { __typename: 'Party', id: Cypress.env('VEGA_PUBLIC_KEY'), diff --git a/apps/trading-e2e/src/support/mocks/generate-candles.ts b/apps/trading-e2e/src/support/mocks/generate-candles.ts index 2ce58d860..3ac1912f3 100644 --- a/apps/trading-e2e/src/support/mocks/generate-candles.ts +++ b/apps/trading-e2e/src/support/mocks/generate-candles.ts @@ -1,12 +1,14 @@ import merge from 'lodash/merge'; import type { PartialDeep } from 'type-fest'; import type { - Candles, - Candles_market_candles, + CandlesQuery, + CandleFieldsFragment, } from '@vegaprotocol/candles-chart'; -export const generateCandles = (override?: PartialDeep): Candles => { - const candles: Candles_market_candles[] = [ +export const generateCandles = ( + override?: PartialDeep +): CandlesQuery => { + const candles: CandleFieldsFragment[] = [ { datetime: '2022-04-06T09:15:00Z', high: '17481092', diff --git a/apps/trading-e2e/src/support/mocks/generate-chart.ts b/apps/trading-e2e/src/support/mocks/generate-chart.ts index f80db6353..91819aedd 100644 --- a/apps/trading-e2e/src/support/mocks/generate-chart.ts +++ b/apps/trading-e2e/src/support/mocks/generate-chart.ts @@ -1,15 +1,21 @@ import merge from 'lodash/merge'; import type { PartialDeep } from 'type-fest'; -import type { - Chart, - Chart_market_data_priceMonitoringBounds, -} from '@vegaprotocol/candles-chart'; +import type { ChartQuery } from '@vegaprotocol/candles-chart'; +import type { Schema } from '@vegaprotocol/types'; -export const generateChart = (override?: PartialDeep): Chart => { - const priceMonitoringBound: Chart_market_data_priceMonitoringBounds = { +export const generateChart = ( + override?: PartialDeep +): ChartQuery => { + const priceMonitoringBound: Schema.PriceMonitoringBounds = { minValidPrice: '16256291', maxValidPrice: '18296869', referencePrice: '17247489', + trigger: { + __typename: 'PriceMonitoringTrigger', + auctionExtensionSecs: 1, + horizonSecs: 0, + probability: 0, + }, __typename: 'PriceMonitoringBounds', }; const defaultResult = { diff --git a/apps/trading/pages/markets/__generated___/Market.ts b/apps/trading/pages/markets/__generated___/Market.ts index dc98077fa..879fc9520 100644 --- a/apps/trading/pages/markets/__generated___/Market.ts +++ b/apps/trading/pages/markets/__generated___/Market.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/apps/trading/pages/portfolio/deposit/__generated___/Deposit.ts b/apps/trading/pages/portfolio/deposit/__generated___/Deposit.ts index 7157ef251..18b76fd9b 100644 --- a/apps/trading/pages/portfolio/deposit/__generated___/Deposit.ts +++ b/apps/trading/pages/portfolio/deposit/__generated___/Deposit.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/libs/accounts/src/lib/Accounts.graphql b/libs/accounts/src/lib/Accounts.graphql index c2b7da82c..b4029a499 100644 --- a/libs/accounts/src/lib/Accounts.graphql +++ b/libs/accounts/src/lib/Accounts.graphql @@ -3,7 +3,11 @@ fragment AccountFields on Account { balance market { id - name + tradableInstrument { + instrument { + name + } + } } asset { id @@ -15,20 +19,14 @@ fragment AccountFields on Account { query Accounts($partyId: ID!) { party(id: $partyId) { id - accountsConnection { - edges { - node { - type - balance - } - } + accounts { + ...AccountFields } } } -subscription AccountSubscribe($partyId: ID!) { +subscription AccountEvents($partyId: ID!) { accounts(partyId: $partyId) { - type - balance + ...AccountFields } } diff --git a/libs/accounts/src/lib/__generated__/AccountFields.ts b/libs/accounts/src/lib/__generated__/AccountFields.ts deleted file mode 100644 index b2286b2b1..000000000 --- a/libs/accounts/src/lib/__generated__/AccountFields.ts +++ /dev/null @@ -1,74 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// @generated -// This file was automatically generated and should not be edited. - -import { AccountType } from "@vegaprotocol/types"; - -// ==================================================== -// GraphQL fragment: AccountFields -// ==================================================== - -export interface AccountFields_market_tradableInstrument_instrument { - __typename: "Instrument"; - /** - * Full and fairly descriptive name for the instrument - */ - name: string; -} - -export interface AccountFields_market_tradableInstrument { - __typename: "TradableInstrument"; - /** - * An instance of, or reference to, a fully specified instrument. - */ - instrument: AccountFields_market_tradableInstrument_instrument; -} - -export interface AccountFields_market { - __typename: "Market"; - /** - * Market ID - */ - id: string; - /** - * An instance of, or reference to, a tradable instrument. - */ - tradableInstrument: AccountFields_market_tradableInstrument; -} - -export interface AccountFields_asset { - __typename: "Asset"; - /** - * The ID of the asset - */ - id: string; - /** - * The symbol of the asset (e.g: GBP) - */ - symbol: string; - /** - * The precision of the asset. Should match the decimal precision of the asset on its native chain, e.g: for ERC20 assets, it is often 18 - */ - decimals: number; -} - -export interface AccountFields { - __typename: "Account"; - /** - * Account type (General, Margin, etc) - */ - type: AccountType; - /** - * Balance as string - current account balance (approx. as balances can be updated several times per second) - */ - balance: string; - /** - * Market (only relevant to margin accounts) - */ - market: AccountFields_market | null; - /** - * Asset, the 'currency' - */ - asset: AccountFields_asset; -} diff --git a/libs/accounts/src/lib/__generated__/AccountSubscribe.ts b/libs/accounts/src/lib/__generated__/AccountSubscribe.ts deleted file mode 100644 index 94a5e17bf..000000000 --- a/libs/accounts/src/lib/__generated__/AccountSubscribe.ts +++ /dev/null @@ -1,85 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// @generated -// This file was automatically generated and should not be edited. - -import { AccountType } from "@vegaprotocol/types"; - -// ==================================================== -// GraphQL subscription operation: AccountSubscribe -// ==================================================== - -export interface AccountSubscribe_accounts_market_tradableInstrument_instrument { - __typename: "Instrument"; - /** - * Full and fairly descriptive name for the instrument - */ - name: string; -} - -export interface AccountSubscribe_accounts_market_tradableInstrument { - __typename: "TradableInstrument"; - /** - * An instance of, or reference to, a fully specified instrument. - */ - instrument: AccountSubscribe_accounts_market_tradableInstrument_instrument; -} - -export interface AccountSubscribe_accounts_market { - __typename: "Market"; - /** - * Market ID - */ - id: string; - /** - * An instance of, or reference to, a tradable instrument. - */ - tradableInstrument: AccountSubscribe_accounts_market_tradableInstrument; -} - -export interface AccountSubscribe_accounts_asset { - __typename: "Asset"; - /** - * The ID of the asset - */ - id: string; - /** - * The symbol of the asset (e.g: GBP) - */ - symbol: string; - /** - * The precision of the asset. Should match the decimal precision of the asset on its native chain, e.g: for ERC20 assets, it is often 18 - */ - decimals: number; -} - -export interface AccountSubscribe_accounts { - __typename: "Account"; - /** - * Account type (General, Margin, etc) - */ - type: AccountType; - /** - * Balance as string - current account balance (approx. as balances can be updated several times per second) - */ - balance: string; - /** - * Market (only relevant to margin accounts) - */ - market: AccountSubscribe_accounts_market | null; - /** - * Asset, the 'currency' - */ - asset: AccountSubscribe_accounts_asset; -} - -export interface AccountSubscribe { - /** - * Subscribe to the accounts updates - */ - accounts: AccountSubscribe_accounts; -} - -export interface AccountSubscribeVariables { - partyId: string; -} diff --git a/libs/accounts/src/lib/__generated__/Accounts.ts b/libs/accounts/src/lib/__generated__/Accounts.ts index 42ff085ed..9ed0ec048 100644 --- a/libs/accounts/src/lib/__generated__/Accounts.ts +++ b/libs/accounts/src/lib/__generated__/Accounts.ts @@ -1,97 +1,108 @@ -/* tslint:disable */ -/* eslint-disable */ -// @generated -// This file was automatically generated and should not be edited. +import { Schema as Types } from '@vegaprotocol/types'; -import { AccountType } from "@vegaprotocol/types"; +import { gql } from '@apollo/client'; +import * as Apollo from '@apollo/client'; +const defaultOptions = {} as const; +export type AccountFieldsFragment = { __typename?: 'Account', type: Types.AccountType, balance: string, market?: { __typename?: 'Market', id: string, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string } } } | null, asset: { __typename?: 'Asset', id: string, symbol: string, decimals: number } }; -// ==================================================== -// GraphQL query operation: Accounts -// ==================================================== +export type AccountsQueryVariables = Types.Exact<{ + partyId: Types.Scalars['ID']; +}>; -export interface Accounts_party_accounts_market_tradableInstrument_instrument { - __typename: "Instrument"; - /** - * Full and fairly descriptive name for the instrument - */ - name: string; + +export type AccountsQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, accounts?: Array<{ __typename?: 'Account', type: Types.AccountType, balance: string, market?: { __typename?: 'Market', id: string, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string } } } | null, asset: { __typename?: 'Asset', id: string, symbol: string, decimals: number } }> | null } | null }; + +export type AccountEventsSubscriptionVariables = Types.Exact<{ + partyId: Types.Scalars['ID']; +}>; + + +export type AccountEventsSubscription = { __typename?: 'Subscription', accounts: { __typename?: 'Account', type: Types.AccountType, balance: string, market?: { __typename?: 'Market', id: string, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string } } } | null, asset: { __typename?: 'Asset', id: string, symbol: string, decimals: number } } }; + +export const AccountFieldsFragmentDoc = gql` + fragment AccountFields on Account { + type + balance + market { + id + tradableInstrument { + instrument { + name + } + } + } + asset { + id + symbol + decimals + } } - -export interface Accounts_party_accounts_market_tradableInstrument { - __typename: "TradableInstrument"; - /** - * An instance of, or reference to, a fully specified instrument. - */ - instrument: Accounts_party_accounts_market_tradableInstrument_instrument; + `; +export const AccountsDocument = gql` + query Accounts($partyId: ID!) { + party(id: $partyId) { + id + accounts { + ...AccountFields + } + } } + ${AccountFieldsFragmentDoc}`; -export interface Accounts_party_accounts_market { - __typename: "Market"; - /** - * Market ID - */ - id: string; - /** - * An instance of, or reference to, a tradable instrument. - */ - tradableInstrument: Accounts_party_accounts_market_tradableInstrument; +/** + * __useAccountsQuery__ + * + * To run a query within a React component, call `useAccountsQuery` and pass it any options that fit your needs. + * When your component renders, `useAccountsQuery` returns an object from Apollo Client that contains loading, error, and data properties + * you can use to render your UI. + * + * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; + * + * @example + * const { data, loading, error } = useAccountsQuery({ + * variables: { + * partyId: // value for 'partyId' + * }, + * }); + */ +export function useAccountsQuery(baseOptions: Apollo.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useQuery(AccountsDocument, options); + } +export function useAccountsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useLazyQuery(AccountsDocument, options); + } +export type AccountsQueryHookResult = ReturnType; +export type AccountsLazyQueryHookResult = ReturnType; +export type AccountsQueryResult = Apollo.QueryResult; +export const AccountEventsDocument = gql` + subscription AccountEvents($partyId: ID!) { + accounts(partyId: $partyId) { + ...AccountFields + } } + ${AccountFieldsFragmentDoc}`; -export interface Accounts_party_accounts_asset { - __typename: "Asset"; - /** - * The ID of the asset - */ - id: string; - /** - * The symbol of the asset (e.g: GBP) - */ - symbol: string; - /** - * The precision of the asset. Should match the decimal precision of the asset on its native chain, e.g: for ERC20 assets, it is often 18 - */ - decimals: number; -} - -export interface Accounts_party_accounts { - __typename: "Account"; - /** - * Account type (General, Margin, etc) - */ - type: AccountType; - /** - * Balance as string - current account balance (approx. as balances can be updated several times per second) - */ - balance: string; - /** - * Market (only relevant to margin accounts) - */ - market: Accounts_party_accounts_market | null; - /** - * Asset, the 'currency' - */ - asset: Accounts_party_accounts_asset; -} - -export interface Accounts_party { - __typename: "Party"; - /** - * Party identifier - */ - id: string; - /** - * Collateral accounts relating to a party - */ - accounts: Accounts_party_accounts[] | null; -} - -export interface Accounts { - /** - * An entity that is trading on the Vega network - */ - party: Accounts_party | null; -} - -export interface AccountsVariables { - partyId: string; -} +/** + * __useAccountEventsSubscription__ + * + * To run a query within a React component, call `useAccountEventsSubscription` and pass it any options that fit your needs. + * When your component renders, `useAccountEventsSubscription` returns an object from Apollo Client that contains loading, error, and data properties + * you can use to render your UI. + * + * @param baseOptions options that will be passed into the subscription, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; + * + * @example + * const { data, loading, error } = useAccountEventsSubscription({ + * variables: { + * partyId: // value for 'partyId' + * }, + * }); + */ +export function useAccountEventsSubscription(baseOptions: Apollo.SubscriptionHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useSubscription(AccountEventsDocument, options); + } +export type AccountEventsSubscriptionHookResult = ReturnType; +export type AccountEventsSubscriptionResult = Apollo.SubscriptionResult; \ No newline at end of file diff --git a/libs/accounts/src/lib/__generated___/Accounts.ts b/libs/accounts/src/lib/__generated___/Accounts.ts deleted file mode 100644 index 92e6e678f..000000000 --- a/libs/accounts/src/lib/__generated___/Accounts.ts +++ /dev/null @@ -1,110 +0,0 @@ -import * as Types from '@vegaprotocol/types/types'; - -import { gql } from '@apollo/client'; -import * as Apollo from '@apollo/client'; -const defaultOptions = {} as const; -export type AccountFieldsFragment = { __typename?: 'Account', type: Types.AccountType, balance: string, market?: { __typename?: 'Market', id: string, name: string } | null, asset: { __typename?: 'Asset', id: string, symbol: string, decimals: number } }; - -export type AccountsQueryVariables = Types.Exact<{ - partyId: Types.Scalars['ID']; -}>; - - -export type AccountsQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, accountsConnection: { __typename?: 'AccountsConnection', edges?: Array<{ __typename?: 'AccountEdge', node: { __typename?: 'Account', type: Types.AccountType, balance: string } } | null> | null } } | null }; - -export type AccountSubscribeSubscriptionVariables = Types.Exact<{ - partyId: Types.Scalars['ID']; -}>; - - -export type AccountSubscribeSubscription = { __typename?: 'Subscription', accounts: { __typename?: 'Account', type: Types.AccountType, balance: string } }; - -export const AccountFieldsFragmentDoc = gql` - fragment AccountFields on Account { - type - balance - market { - id - name - } - asset { - id - symbol - decimals - } -} - `; -export const AccountsDocument = gql` - query Accounts($partyId: ID!) { - party(id: $partyId) { - id - accountsConnection { - edges { - node { - type - balance - } - } - } - } -} - `; - -/** - * __useAccountsQuery__ - * - * To run a query within a React component, call `useAccountsQuery` and pass it any options that fit your needs. - * When your component renders, `useAccountsQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useAccountsQuery({ - * variables: { - * partyId: // value for 'partyId' - * }, - * }); - */ -export function useAccountsQuery(baseOptions: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(AccountsDocument, options); - } -export function useAccountsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(AccountsDocument, options); - } -export type AccountsQueryHookResult = ReturnType; -export type AccountsLazyQueryHookResult = ReturnType; -export type AccountsQueryResult = Apollo.QueryResult; -export const AccountSubscribeDocument = gql` - subscription AccountSubscribe($partyId: ID!) { - accounts(partyId: $partyId) { - type - balance - } -} - `; - -/** - * __useAccountSubscribeSubscription__ - * - * To run a query within a React component, call `useAccountSubscribeSubscription` and pass it any options that fit your needs. - * When your component renders, `useAccountSubscribeSubscription` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the subscription, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useAccountSubscribeSubscription({ - * variables: { - * partyId: // value for 'partyId' - * }, - * }); - */ -export function useAccountSubscribeSubscription(baseOptions: Apollo.SubscriptionHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useSubscription(AccountSubscribeDocument, options); - } -export type AccountSubscribeSubscriptionHookResult = ReturnType; -export type AccountSubscribeSubscriptionResult = Apollo.SubscriptionResult; \ No newline at end of file diff --git a/libs/accounts/src/lib/accounts-data-provider.ts b/libs/accounts/src/lib/accounts-data-provider.ts index 6882ec5b7..47f685168 100644 --- a/libs/accounts/src/lib/accounts-data-provider.ts +++ b/libs/accounts/src/lib/accounts-data-provider.ts @@ -1,64 +1,21 @@ import produce from 'immer'; -import { gql } from '@apollo/client'; +import { + AccountsDocument, + AccountEventsDocument, +} from './__generated__/Accounts'; import type { - Accounts, - Accounts_party_accounts, + AccountFieldsFragment, + AccountsQuery, + AccountEventsSubscription, } from './__generated__/Accounts'; import { makeDataProvider } from '@vegaprotocol/react-helpers'; -import type { - AccountSubscribe, - AccountSubscribe_accounts, -} from './__generated__/AccountSubscribe'; - -const ACCOUNTS_FRAGMENT = gql` - fragment AccountFields on Account { - type - balance - market { - id - tradableInstrument { - instrument { - name - } - } - } - asset { - id - symbol - decimals - } - } -`; - -const ACCOUNTS_QUERY = gql` - ${ACCOUNTS_FRAGMENT} - query Accounts($partyId: ID!) { - party(id: $partyId) { - id - accounts { - ...AccountFields - } - } - } -`; - -export const ACCOUNTS_SUB = gql` - ${ACCOUNTS_FRAGMENT} - subscription AccountSubscribe($partyId: ID!) { - accounts(partyId: $partyId) { - ...AccountFields - } - } -`; - -export const getId = ( - data: Accounts_party_accounts | AccountSubscribe_accounts -) => `${data.type}-${data.asset.symbol}-${data.market?.id ?? 'null'}`; +export const getId = (data: AccountFieldsFragment) => + `${data.type}-${data.asset.symbol}-${data.market?.id ?? 'null'}`; const update = ( - data: Accounts_party_accounts[], - delta: AccountSubscribe_accounts + data: AccountFieldsFragment[], + delta: AccountFieldsFragment ) => { return produce(data, (draft) => { const id = getId(delta); @@ -71,20 +28,24 @@ const update = ( }); }; -const getData = (responseData: Accounts): Accounts_party_accounts[] | null => - responseData.party ? responseData.party.accounts : null; +const getData = ( + responseData: AccountsQuery +): AccountFieldsFragment[] | null => { + return responseData.party?.accounts ?? null; +}; + const getDelta = ( - subscriptionData: AccountSubscribe -): AccountSubscribe_accounts => subscriptionData.accounts; + subscriptionData: AccountEventsSubscription +): AccountFieldsFragment => subscriptionData.accounts; export const accountsDataProvider = makeDataProvider< - Accounts, - Accounts_party_accounts[], - AccountSubscribe, - AccountSubscribe_accounts + AccountsQuery, + AccountFieldsFragment[], + AccountEventsSubscription, + AccountFieldsFragment >({ - query: ACCOUNTS_QUERY, - subscriptionQuery: ACCOUNTS_SUB, + query: AccountsDocument, + subscriptionQuery: AccountEventsDocument, update, getData, getDelta, diff --git a/libs/accounts/src/lib/accounts-manager.tsx b/libs/accounts/src/lib/accounts-manager.tsx index 2e06b2daa..bc1d4955a 100644 --- a/libs/accounts/src/lib/accounts-manager.tsx +++ b/libs/accounts/src/lib/accounts-manager.tsx @@ -3,8 +3,7 @@ import { produce } from 'immer'; import merge from 'lodash/merge'; import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; import { useDataProvider, addSummaryRows } from '@vegaprotocol/react-helpers'; -import type { AccountSubscribe_accounts } from './__generated__/AccountSubscribe'; -import type { Accounts_party_accounts } from './__generated__/Accounts'; +import type { AccountFieldsFragment } from './__generated__/Accounts'; import type { AgGridReact } from 'ag-grid-react'; import { @@ -22,17 +21,17 @@ export const AccountsManager = ({ partyId }: AccountsManagerProps) => { const gridRef = useRef(null); const variables = useMemo(() => ({ partyId }), [partyId]); const update = useCallback( - ({ delta }: { delta: AccountSubscribe_accounts }) => { - const update: Accounts_party_accounts[] = []; - const add: Accounts_party_accounts[] = []; + ({ delta }: { delta: AccountFieldsFragment }) => { + const update: AccountFieldsFragment[] = []; + const add: AccountFieldsFragment[] = []; if (!gridRef.current?.api) { return false; } const rowNode = gridRef.current.api.getRowNode(getId(delta)); if (rowNode) { - const updatedData = produce( + const updatedData = produce( rowNode.data, - (draft: Accounts_party_accounts) => { + (draft: AccountFieldsFragment) => { merge(draft, delta); } ); @@ -62,8 +61,8 @@ export const AccountsManager = ({ partyId }: AccountsManagerProps) => { [gridRef] ); const { data, error, loading } = useDataProvider< - Accounts_party_accounts[], - AccountSubscribe_accounts + AccountFieldsFragment[], + AccountFieldsFragment >({ dataProvider: accountsDataProvider, update, variables }); return ( diff --git a/libs/accounts/src/lib/accounts-table.spec.tsx b/libs/accounts/src/lib/accounts-table.spec.tsx index 6e10b163f..9db752249 100644 --- a/libs/accounts/src/lib/accounts-table.spec.tsx +++ b/libs/accounts/src/lib/accounts-table.spec.tsx @@ -1,9 +1,9 @@ import AccountsTable from './accounts-table'; import { act, render, screen, waitFor } from '@testing-library/react'; -import type { Accounts_party_accounts } from './__generated__/Accounts'; +import type { AccountFieldsFragment } from './__generated__/Accounts'; import { AccountType } from '@vegaprotocol/types'; -const singleRow: Accounts_party_accounts = { +const singleRow: AccountFieldsFragment = { __typename: 'Account', type: AccountType.ACCOUNT_TYPE_MARGIN, balance: '125600000', diff --git a/libs/accounts/src/lib/accounts-table.tsx b/libs/accounts/src/lib/accounts-table.tsx index 552f9bfde..451b8ec4d 100644 --- a/libs/accounts/src/lib/accounts-table.tsx +++ b/libs/accounts/src/lib/accounts-table.tsx @@ -14,22 +14,22 @@ import type { SummaryRow } from '@vegaprotocol/react-helpers'; import { AgGridDynamic as AgGrid } from '@vegaprotocol/ui-toolkit'; import { AgGridColumn } from 'ag-grid-react'; import type { AgGridReact } from 'ag-grid-react'; -import type { Accounts_party_accounts } from './__generated__/Accounts'; +import type { AccountFieldsFragment } from './__generated__/Accounts'; import { getId } from './accounts-data-provider'; import { useAssetDetailsDialogStore } from '@vegaprotocol/assets'; import type { AccountType } from '@vegaprotocol/types'; import { AccountTypeMapping } from '@vegaprotocol/types'; interface AccountsTableProps { - data: Accounts_party_accounts[] | null; + data: AccountFieldsFragment[] | null; } interface AccountsTableValueFormatterParams extends ValueFormatterParams { - data: Accounts_party_accounts; + data: AccountFieldsFragment; } export const getGroupId = ( - data: Accounts_party_accounts & SummaryRow, + data: AccountFieldsFragment & SummaryRow, columnApi: ColumnApi ) => { if (data.__summaryRow) { @@ -44,9 +44,9 @@ export const getGroupId = ( }; export const getGroupSummaryRow = ( - data: Accounts_party_accounts[], + data: AccountFieldsFragment[], columnApi: ColumnApi -): Partial | null => { +): Partial | null => { if (!data.length) { return null; } @@ -67,8 +67,8 @@ export const getGroupSummaryRow = ( const comparator = ( valueA: string, valueB: string, - nodeA: { data: Accounts_party_accounts & SummaryRow }, - nodeB: { data: Accounts_party_accounts & SummaryRow }, + nodeA: { data: AccountFieldsFragment & SummaryRow }, + nodeB: { data: AccountFieldsFragment & SummaryRow }, isInverted: boolean ) => { if (valueA < valueB) { diff --git a/libs/accounts/src/lib/asset-balance.tsx b/libs/accounts/src/lib/asset-balance.tsx index 9b3c9b53d..6e3ad4e50 100644 --- a/libs/accounts/src/lib/asset-balance.tsx +++ b/libs/accounts/src/lib/asset-balance.tsx @@ -3,8 +3,7 @@ import { addDecimalsFormatNumber, useDataProvider, } from '@vegaprotocol/react-helpers'; -import type { AccountSubscribe_accounts } from './__generated__/AccountSubscribe'; -import type { Accounts_party_accounts } from './__generated__/Accounts'; +import type { AccountFieldsFragment } from './__generated__/Accounts'; import { accountsDataProvider } from './accounts-data-provider'; @@ -16,8 +15,8 @@ interface AssetBalanceProps { export const AssetBalance = ({ partyId, assetSymbol }: AssetBalanceProps) => { const variables = useMemo(() => ({ partyId }), [partyId]); const { data } = useDataProvider< - Accounts_party_accounts[], - AccountSubscribe_accounts + AccountFieldsFragment[], + AccountFieldsFragment >({ dataProvider: accountsDataProvider, variables, diff --git a/libs/accounts/src/lib/index.ts b/libs/accounts/src/lib/index.ts index 867400896..0ace69825 100644 --- a/libs/accounts/src/lib/index.ts +++ b/libs/accounts/src/lib/index.ts @@ -1,6 +1,4 @@ export * from './__generated__/Accounts'; -export * from './__generated__/AccountFields'; -export * from './__generated__/AccountSubscribe'; export * from './accounts-container'; export * from './accounts-data-provider'; export * from './accounts-manager'; diff --git a/libs/assets/src/lib/__generated___/Assets.ts b/libs/assets/src/lib/__generated__/Assets.ts similarity index 97% rename from libs/assets/src/lib/__generated___/Assets.ts rename to libs/assets/src/lib/__generated__/Assets.ts index a59ce11a4..caf19cc76 100644 --- a/libs/assets/src/lib/__generated___/Assets.ts +++ b/libs/assets/src/lib/__generated__/Assets.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/libs/assets/src/lib/__generated__/AssetsConnection.ts b/libs/assets/src/lib/__generated__/AssetsConnection.ts deleted file mode 100644 index 47a34d4c6..000000000 --- a/libs/assets/src/lib/__generated__/AssetsConnection.ts +++ /dev/null @@ -1,80 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// @generated -// This file was automatically generated and should not be edited. - -// ==================================================== -// GraphQL query operation: AssetsConnection -// ==================================================== - -export interface AssetsConnection_assetsConnection_edges_node_source_BuiltinAsset { - __typename: "BuiltinAsset"; -} - -export interface AssetsConnection_assetsConnection_edges_node_source_ERC20 { - __typename: "ERC20"; - /** - * The address of the ERC20 contract - */ - contractAddress: string; - /** - * The lifetime limits deposit per address - * Note: this is a temporary measure for alpha mainnet - */ - lifetimeLimit: string; - /** - * The maximum allowed per withdrawal - * Note: this is a temporary measure for alpha mainnet - */ - withdrawThreshold: string; -} - -export type AssetsConnection_assetsConnection_edges_node_source = AssetsConnection_assetsConnection_edges_node_source_BuiltinAsset | AssetsConnection_assetsConnection_edges_node_source_ERC20; - -export interface AssetsConnection_assetsConnection_edges_node { - __typename: "Asset"; - /** - * The ID of the asset - */ - id: string; - /** - * The full name of the asset (e.g: Great British Pound) - */ - name: string; - /** - * The symbol of the asset (e.g: GBP) - */ - symbol: string; - /** - * The precision of the asset. Should match the decimal precision of the asset on its native chain, e.g: for ERC20 assets, it is often 18 - */ - decimals: number; - /** - * The minimum economically meaningful amount in the asset - */ - quantum: string; - /** - * The origin source of the asset (e.g: an ERC20 asset) - */ - source: AssetsConnection_assetsConnection_edges_node_source; -} - -export interface AssetsConnection_assetsConnection_edges { - __typename: "AssetEdge"; - node: AssetsConnection_assetsConnection_edges_node; -} - -export interface AssetsConnection_assetsConnection { - __typename: "AssetsConnection"; - /** - * The assets - */ - edges: (AssetsConnection_assetsConnection_edges | null)[] | null; -} - -export interface AssetsConnection { - /** - * The list of all assets in use in the Vega network or the specified asset if ID is provided - */ - assetsConnection: AssetsConnection_assetsConnection; -} diff --git a/libs/assets/src/lib/asset-details-dialog.spec.tsx b/libs/assets/src/lib/asset-details-dialog.spec.tsx index 574e65ccd..a060d9fa6 100644 --- a/libs/assets/src/lib/asset-details-dialog.spec.tsx +++ b/libs/assets/src/lib/asset-details-dialog.spec.tsx @@ -1,9 +1,7 @@ import { MockedProvider } from '@apollo/react-testing'; import { render, screen } from '@testing-library/react'; -import { - AssetDetailsDialog, - ASSETS_CONNECTION_QUERY, -} from './asset-details-dialog'; +import { AssetDetailsDialog } from './asset-details-dialog'; +import { AssetsConnectionDocument } from './__generated__/Assets'; const mockedData = { data: { @@ -275,7 +273,7 @@ const mockedData = { const mocks = [ { request: { - query: ASSETS_CONNECTION_QUERY, + query: AssetsConnectionDocument, variables: {}, }, result: mockedData, diff --git a/libs/assets/src/lib/asset-details-dialog.tsx b/libs/assets/src/lib/asset-details-dialog.tsx index 3650fd0ab..1bb4143b9 100644 --- a/libs/assets/src/lib/asset-details-dialog.tsx +++ b/libs/assets/src/lib/asset-details-dialog.tsx @@ -1,4 +1,3 @@ -import { gql, useQuery } from '@apollo/client'; import { t } from '@vegaprotocol/react-helpers'; import type { Asset } from '@vegaprotocol/react-helpers'; import { @@ -10,10 +9,8 @@ import { Splash, Tooltip, } from '@vegaprotocol/ui-toolkit'; -import type { - AssetsConnection, - AssetsConnection_assetsConnection_edges_node_source_ERC20, -} from './__generated__/AssetsConnection'; +import { useAssetsConnectionQuery } from './__generated__/Assets'; +import type { Schema } from '@vegaprotocol/types'; import create from 'zustand'; export type AssetDetailsDialogStore = { @@ -43,29 +40,6 @@ type AssetDetails = { tooltip: string; }[]; -export const ASSETS_CONNECTION_QUERY = gql` - query AssetsConnection { - assetsConnection { - edges { - node { - id - name - symbol - decimals - quantum - source { - ... on ERC20 { - contractAddress - lifetimeLimit - withdrawThreshold - } - } - } - } - } - } -`; - export interface AssetDetailsDialogProps { assetSymbol: string | Asset; open: boolean; @@ -77,7 +51,7 @@ export const AssetDetailsDialog = ({ open, onChange, }: AssetDetailsDialogProps) => { - const { data } = useQuery(ASSETS_CONNECTION_QUERY); + const { data } = useAssetsConnectionQuery(); const symbol = typeof assetSymbol === 'string' ? assetSymbol : assetSymbol.symbol; const asset = data?.assetsConnection.edges?.find( @@ -114,10 +88,7 @@ export const AssetDetailsDialog = ({ { key: 'contractaddress', label: t('Contract address'), - value: ( - asset.node - .source as AssetsConnection_assetsConnection_edges_node_source_ERC20 - ).contractAddress, + value: (asset.node.source as Schema.ERC20).contractAddress, tooltip: t( 'The address of the contract for the token, on the ethereum network' ), @@ -125,10 +96,7 @@ export const AssetDetailsDialog = ({ { key: 'withdrawalthreshold', label: t('Withdrawal threshold'), - value: ( - asset.node - .source as AssetsConnection_assetsConnection_edges_node_source_ERC20 - ).withdrawThreshold, + value: (asset.node.source as Schema.ERC20).withdrawThreshold, tooltip: t( 'The maximum allowed per withdraw note: this is a temporary measure for restricted mainnet' ), @@ -136,10 +104,7 @@ export const AssetDetailsDialog = ({ { key: 'lifetimelimit', label: t('Lifetime limit'), - value: ( - asset.node - .source as AssetsConnection_assetsConnection_edges_node_source_ERC20 - ).lifetimeLimit, + value: (asset.node.source as Schema.ERC20).lifetimeLimit, tooltip: t( 'The lifetime limits deposit per address note: this is a temporary measure for restricted mainnet' ), diff --git a/libs/assets/src/lib/index.ts b/libs/assets/src/lib/index.ts index 513d2726b..e2f715fbc 100644 --- a/libs/assets/src/lib/index.ts +++ b/libs/assets/src/lib/index.ts @@ -1,2 +1,2 @@ -export * from './__generated__/AssetsConnection'; +export * from './__generated__/Assets'; export * from './asset-details-dialog'; diff --git a/libs/candles-chart/src/lib/Candles.graphql b/libs/candles-chart/src/lib/Candles.graphql index 931453460..a53432b74 100644 --- a/libs/candles-chart/src/lib/Candles.graphql +++ b/libs/candles-chart/src/lib/Candles.graphql @@ -24,7 +24,7 @@ query Candles($marketId: ID!, $interval: Interval!, $since: String!) { } } -subscription CandlesSub($marketId: ID!, $interval: Interval!) { +subscription CandlesEvents($marketId: ID!, $interval: Interval!) { candles(marketId: $marketId, interval: $interval) { ...CandleFields } diff --git a/libs/candles-chart/src/lib/__generated__/CandleFields.ts b/libs/candles-chart/src/lib/__generated__/CandleFields.ts deleted file mode 100644 index 9e22fdcdc..000000000 --- a/libs/candles-chart/src/lib/__generated__/CandleFields.ts +++ /dev/null @@ -1,36 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// @generated -// This file was automatically generated and should not be edited. - -// ==================================================== -// GraphQL fragment: CandleFields -// ==================================================== - -export interface CandleFields { - __typename: "Candle"; - /** - * RFC3339Nano formatted date and time for the candle - */ - datetime: string; - /** - * High price (uint64) - */ - high: string; - /** - * Low price (uint64) - */ - low: string; - /** - * Open price (uint64) - */ - open: string; - /** - * Close price (uint64) - */ - close: string; - /** - * Volume price (uint64) - */ - volume: string; -} diff --git a/libs/candles-chart/src/lib/__generated__/Candles.ts b/libs/candles-chart/src/lib/__generated__/Candles.ts index 21f13dcbc..6762edcd5 100644 --- a/libs/candles-chart/src/lib/__generated__/Candles.ts +++ b/libs/candles-chart/src/lib/__generated__/Candles.ts @@ -1,108 +1,113 @@ -/* tslint:disable */ -/* eslint-disable */ -// @generated -// This file was automatically generated and should not be edited. +import { Schema as Types } from '@vegaprotocol/types'; -import { Interval } from "@vegaprotocol/types"; +import { gql } from '@apollo/client'; +import * as Apollo from '@apollo/client'; +const defaultOptions = {} as const; +export type CandleFieldsFragment = { __typename?: 'Candle', datetime: string, high: string, low: string, open: string, close: string, volume: string }; -// ==================================================== -// GraphQL query operation: Candles -// ==================================================== +export type CandlesQueryVariables = Types.Exact<{ + marketId: Types.Scalars['ID']; + interval: Types.Interval; + since: Types.Scalars['String']; +}>; -export interface Candles_market_tradableInstrument_instrument { - __typename: "Instrument"; - /** - * Uniquely identify an instrument across all instruments available on Vega (string) - */ - id: string; - /** - * Full and fairly descriptive name for the instrument - */ - name: string; - /** - * A short non necessarily unique code used to easily describe the instrument (e.g: FX:BTCUSD/DEC18) (string) - */ - code: string; + +export type CandlesQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, decimalPlaces: number, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string } }, candles?: Array<{ __typename?: 'Candle', datetime: string, high: string, low: string, open: string, close: string, volume: string } | null> | null } | null }; + +export type CandlesEventsSubscriptionVariables = Types.Exact<{ + marketId: Types.Scalars['ID']; + interval: Types.Interval; +}>; + + +export type CandlesEventsSubscription = { __typename?: 'Subscription', candles: { __typename?: 'Candle', datetime: string, high: string, low: string, open: string, close: string, volume: string } }; + +export const CandleFieldsFragmentDoc = gql` + fragment CandleFields on Candle { + datetime + high + low + open + close + volume } - -export interface Candles_market_tradableInstrument { - __typename: "TradableInstrument"; - /** - * An instance of, or reference to, a fully specified instrument. - */ - instrument: Candles_market_tradableInstrument_instrument; + `; +export const CandlesDocument = gql` + query Candles($marketId: ID!, $interval: Interval!, $since: String!) { + market(id: $marketId) { + id + decimalPlaces + tradableInstrument { + instrument { + id + name + code + } + } + candles(interval: $interval, since: $since) { + ...CandleFields + } + } } + ${CandleFieldsFragmentDoc}`; -export interface Candles_market_candles { - __typename: "Candle"; - /** - * RFC3339Nano formatted date and time for the candle - */ - datetime: string; - /** - * High price (uint64) - */ - high: string; - /** - * Low price (uint64) - */ - low: string; - /** - * Open price (uint64) - */ - open: string; - /** - * Close price (uint64) - */ - close: string; - /** - * Volume price (uint64) - */ - volume: string; +/** + * __useCandlesQuery__ + * + * To run a query within a React component, call `useCandlesQuery` and pass it any options that fit your needs. + * When your component renders, `useCandlesQuery` returns an object from Apollo Client that contains loading, error, and data properties + * you can use to render your UI. + * + * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; + * + * @example + * const { data, loading, error } = useCandlesQuery({ + * variables: { + * marketId: // value for 'marketId' + * interval: // value for 'interval' + * since: // value for 'since' + * }, + * }); + */ +export function useCandlesQuery(baseOptions: Apollo.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useQuery(CandlesDocument, options); + } +export function useCandlesLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useLazyQuery(CandlesDocument, options); + } +export type CandlesQueryHookResult = ReturnType; +export type CandlesLazyQueryHookResult = ReturnType; +export type CandlesQueryResult = Apollo.QueryResult; +export const CandlesEventsDocument = gql` + subscription CandlesEvents($marketId: ID!, $interval: Interval!) { + candles(marketId: $marketId, interval: $interval) { + ...CandleFields + } } + ${CandleFieldsFragmentDoc}`; -export interface Candles_market { - __typename: "Market"; - /** - * Market ID - */ - id: string; - /** - * decimalPlaces indicates the number of decimal places that an integer must be shifted by in order to get a correct - * number denominated in the currency of the market. (uint64) - * - * Examples: - * Currency Balance decimalPlaces Real Balance - * GBP 100 0 GBP 100 - * GBP 100 2 GBP 1.00 - * GBP 100 4 GBP 0.01 - * GBP 1 4 GBP 0.0001 ( 0.01p ) - * - * GBX (pence) 100 0 GBP 1.00 (100p ) - * GBX (pence) 100 2 GBP 0.01 ( 1p ) - * GBX (pence) 100 4 GBP 0.0001 ( 0.01p ) - * GBX (pence) 1 4 GBP 0.000001 ( 0.0001p) - */ - decimalPlaces: number; - /** - * An instance of, or reference to, a tradable instrument. - */ - tradableInstrument: Candles_market_tradableInstrument; - /** - * Candles on a market, for the 'last' n candles, at 'interval' seconds as specified by parameters - */ - candles: (Candles_market_candles | null)[] | null; -} - -export interface Candles { - /** - * An instrument that is trading on the Vega network - */ - market: Candles_market | null; -} - -export interface CandlesVariables { - marketId: string; - interval: Interval; - since: string; -} +/** + * __useCandlesEventsSubscription__ + * + * To run a query within a React component, call `useCandlesEventsSubscription` and pass it any options that fit your needs. + * When your component renders, `useCandlesEventsSubscription` returns an object from Apollo Client that contains loading, error, and data properties + * you can use to render your UI. + * + * @param baseOptions options that will be passed into the subscription, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; + * + * @example + * const { data, loading, error } = useCandlesEventsSubscription({ + * variables: { + * marketId: // value for 'marketId' + * interval: // value for 'interval' + * }, + * }); + */ +export function useCandlesEventsSubscription(baseOptions: Apollo.SubscriptionHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useSubscription(CandlesEventsDocument, options); + } +export type CandlesEventsSubscriptionHookResult = ReturnType; +export type CandlesEventsSubscriptionResult = Apollo.SubscriptionResult; \ No newline at end of file diff --git a/libs/candles-chart/src/lib/__generated__/CandlesSub.ts b/libs/candles-chart/src/lib/__generated__/CandlesSub.ts deleted file mode 100644 index e81470f4c..000000000 --- a/libs/candles-chart/src/lib/__generated__/CandlesSub.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -// @generated -// This file was automatically generated and should not be edited. - -import { Interval } from "@vegaprotocol/types"; - -// ==================================================== -// GraphQL subscription operation: CandlesSub -// ==================================================== - -export interface CandlesSub_candles { - __typename: "Candle"; - /** - * RFC3339Nano formatted date and time for the candle - */ - datetime: string; - /** - * High price (uint64) - */ - high: string; - /** - * Low price (uint64) - */ - low: string; - /** - * Open price (uint64) - */ - open: string; - /** - * Close price (uint64) - */ - close: string; - /** - * Volume price (uint64) - */ - volume: string; -} - -export interface CandlesSub { - /** - * Subscribe to the candles updates - */ - candles: CandlesSub_candles; -} - -export interface CandlesSubVariables { - marketId: string; - interval: Interval; -} diff --git a/libs/candles-chart/src/lib/__generated__/Chart.ts b/libs/candles-chart/src/lib/__generated__/Chart.ts index e7dbd0c80..fec36dd6f 100644 --- a/libs/candles-chart/src/lib/__generated__/Chart.ts +++ b/libs/candles-chart/src/lib/__generated__/Chart.ts @@ -1,68 +1,55 @@ -/* tslint:disable */ -/* eslint-disable */ -// @generated -// This file was automatically generated and should not be edited. +import { Schema as Types } from '@vegaprotocol/types'; -// ==================================================== -// GraphQL query operation: Chart -// ==================================================== +import { gql } from '@apollo/client'; +import * as Apollo from '@apollo/client'; +const defaultOptions = {} as const; +export type ChartQueryVariables = Types.Exact<{ + marketId: Types.Scalars['ID']; +}>; -export interface Chart_market_data_priceMonitoringBounds { - __typename: "PriceMonitoringBounds"; - /** - * Minimum price that isn't currently breaching the specified price monitoring trigger - */ - minValidPrice: string; - /** - * Maximum price that isn't currently breaching the specified price monitoring trigger - */ - maxValidPrice: string; - /** - * Reference price used to calculate the valid price range - */ - referencePrice: string; + +export type ChartQuery = { __typename?: 'Query', market?: { __typename?: 'Market', decimalPlaces: number, data?: { __typename?: 'MarketData', priceMonitoringBounds?: Array<{ __typename?: 'PriceMonitoringBounds', minValidPrice: string, maxValidPrice: string, referencePrice: string }> | null } | null } | null }; + + +export const ChartDocument = gql` + query Chart($marketId: ID!) { + market(id: $marketId) { + decimalPlaces + data { + priceMonitoringBounds { + minValidPrice + maxValidPrice + referencePrice + } + } + } } + `; -export interface Chart_market_data { - __typename: "MarketData"; - /** - * a list of valid price ranges per associated trigger - */ - priceMonitoringBounds: Chart_market_data_priceMonitoringBounds[] | null; -} - -export interface Chart_market { - __typename: "Market"; - /** - * decimalPlaces indicates the number of decimal places that an integer must be shifted by in order to get a correct - * number denominated in the currency of the market. (uint64) - * - * Examples: - * Currency Balance decimalPlaces Real Balance - * GBP 100 0 GBP 100 - * GBP 100 2 GBP 1.00 - * GBP 100 4 GBP 0.01 - * GBP 1 4 GBP 0.0001 ( 0.01p ) - * - * GBX (pence) 100 0 GBP 1.00 (100p ) - * GBX (pence) 100 2 GBP 0.01 ( 1p ) - * GBX (pence) 100 4 GBP 0.0001 ( 0.01p ) - * GBX (pence) 1 4 GBP 0.000001 ( 0.0001p) - */ - decimalPlaces: number; - /** - * marketData for the given market - */ - data: Chart_market_data | null; -} - -export interface Chart { - /** - * An instrument that is trading on the Vega network - */ - market: Chart_market | null; -} - -export interface ChartVariables { - marketId: string; -} +/** + * __useChartQuery__ + * + * To run a query within a React component, call `useChartQuery` and pass it any options that fit your needs. + * When your component renders, `useChartQuery` returns an object from Apollo Client that contains loading, error, and data properties + * you can use to render your UI. + * + * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; + * + * @example + * const { data, loading, error } = useChartQuery({ + * variables: { + * marketId: // value for 'marketId' + * }, + * }); + */ +export function useChartQuery(baseOptions: Apollo.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useQuery(ChartDocument, options); + } +export function useChartLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useLazyQuery(ChartDocument, options); + } +export type ChartQueryHookResult = ReturnType; +export type ChartLazyQueryHookResult = ReturnType; +export type ChartQueryResult = Apollo.QueryResult; \ No newline at end of file diff --git a/libs/candles-chart/src/lib/__generated___/Candles.ts b/libs/candles-chart/src/lib/__generated___/Candles.ts deleted file mode 100644 index bceb3114d..000000000 --- a/libs/candles-chart/src/lib/__generated___/Candles.ts +++ /dev/null @@ -1,113 +0,0 @@ -import * as Types from '@vegaprotocol/types/types'; - -import { gql } from '@apollo/client'; -import * as Apollo from '@apollo/client'; -const defaultOptions = {} as const; -export type CandleFieldsFragment = { __typename?: 'Candle', datetime: string, high: string, low: string, open: string, close: string, volume: string }; - -export type CandlesQueryVariables = Types.Exact<{ - marketId: Types.Scalars['ID']; - interval: Types.Interval; - since: Types.Scalars['String']; -}>; - - -export type CandlesQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, decimalPlaces: number, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string } }, candles?: Array<{ __typename?: 'Candle', datetime: string, high: string, low: string, open: string, close: string, volume: string } | null> | null } | null }; - -export type CandlesSubSubscriptionVariables = Types.Exact<{ - marketId: Types.Scalars['ID']; - interval: Types.Interval; -}>; - - -export type CandlesSubSubscription = { __typename?: 'Subscription', candles: { __typename?: 'Candle', datetime: string, high: string, low: string, open: string, close: string, volume: string } }; - -export const CandleFieldsFragmentDoc = gql` - fragment CandleFields on Candle { - datetime - high - low - open - close - volume -} - `; -export const CandlesDocument = gql` - query Candles($marketId: ID!, $interval: Interval!, $since: String!) { - market(id: $marketId) { - id - decimalPlaces - tradableInstrument { - instrument { - id - name - code - } - } - candles(interval: $interval, since: $since) { - ...CandleFields - } - } -} - ${CandleFieldsFragmentDoc}`; - -/** - * __useCandlesQuery__ - * - * To run a query within a React component, call `useCandlesQuery` and pass it any options that fit your needs. - * When your component renders, `useCandlesQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useCandlesQuery({ - * variables: { - * marketId: // value for 'marketId' - * interval: // value for 'interval' - * since: // value for 'since' - * }, - * }); - */ -export function useCandlesQuery(baseOptions: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(CandlesDocument, options); - } -export function useCandlesLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(CandlesDocument, options); - } -export type CandlesQueryHookResult = ReturnType; -export type CandlesLazyQueryHookResult = ReturnType; -export type CandlesQueryResult = Apollo.QueryResult; -export const CandlesSubDocument = gql` - subscription CandlesSub($marketId: ID!, $interval: Interval!) { - candles(marketId: $marketId, interval: $interval) { - ...CandleFields - } -} - ${CandleFieldsFragmentDoc}`; - -/** - * __useCandlesSubSubscription__ - * - * To run a query within a React component, call `useCandlesSubSubscription` and pass it any options that fit your needs. - * When your component renders, `useCandlesSubSubscription` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the subscription, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useCandlesSubSubscription({ - * variables: { - * marketId: // value for 'marketId' - * interval: // value for 'interval' - * }, - * }); - */ -export function useCandlesSubSubscription(baseOptions: Apollo.SubscriptionHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useSubscription(CandlesSubDocument, options); - } -export type CandlesSubSubscriptionHookResult = ReturnType; -export type CandlesSubSubscriptionResult = Apollo.SubscriptionResult; \ No newline at end of file diff --git a/libs/candles-chart/src/lib/__generated___/Chart.ts b/libs/candles-chart/src/lib/__generated___/Chart.ts deleted file mode 100644 index 4e1b09874..000000000 --- a/libs/candles-chart/src/lib/__generated___/Chart.ts +++ /dev/null @@ -1,55 +0,0 @@ -import * as Types from '@vegaprotocol/types/types'; - -import { gql } from '@apollo/client'; -import * as Apollo from '@apollo/client'; -const defaultOptions = {} as const; -export type ChartQueryVariables = Types.Exact<{ - marketId: Types.Scalars['ID']; -}>; - - -export type ChartQuery = { __typename?: 'Query', market?: { __typename?: 'Market', decimalPlaces: number, data?: { __typename?: 'MarketData', priceMonitoringBounds?: Array<{ __typename?: 'PriceMonitoringBounds', minValidPrice: string, maxValidPrice: string, referencePrice: string }> | null } | null } | null }; - - -export const ChartDocument = gql` - query Chart($marketId: ID!) { - market(id: $marketId) { - decimalPlaces - data { - priceMonitoringBounds { - minValidPrice - maxValidPrice - referencePrice - } - } - } -} - `; - -/** - * __useChartQuery__ - * - * To run a query within a React component, call `useChartQuery` and pass it any options that fit your needs. - * When your component renders, `useChartQuery` returns an object from Apollo Client that contains loading, error, and data properties - * you can use to render your UI. - * - * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; - * - * @example - * const { data, loading, error } = useChartQuery({ - * variables: { - * marketId: // value for 'marketId' - * }, - * }); - */ -export function useChartQuery(baseOptions: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ChartDocument, options); - } -export function useChartLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ChartDocument, options); - } -export type ChartQueryHookResult = ReturnType; -export type ChartLazyQueryHookResult = ReturnType; -export type ChartQueryResult = Apollo.QueryResult; \ No newline at end of file diff --git a/libs/candles-chart/src/lib/data-source.ts b/libs/candles-chart/src/lib/data-source.ts index 84095bd56..df3d7bec6 100644 --- a/libs/candles-chart/src/lib/data-source.ts +++ b/libs/candles-chart/src/lib/data-source.ts @@ -1,16 +1,21 @@ import type { ApolloClient } from '@apollo/client'; -import { gql } from '@apollo/client'; import type { Candle, DataSource } from 'pennant'; import { Interval as PennantInterval } from 'pennant'; import { addDecimal } from '@vegaprotocol/react-helpers'; -import type { Chart, ChartVariables } from './__generated__/Chart'; -import type { Candles, CandlesVariables } from './__generated__/Candles'; -import type { CandleFields } from './__generated__/CandleFields'; +import { ChartDocument } from './__generated__/Chart'; +import type { ChartQuery, ChartQueryVariables } from './__generated__/Chart'; +import { + CandlesDocument, + CandlesEventsDocument, +} from './__generated__/Candles'; import type { - CandlesSub, - CandlesSubVariables, -} from './__generated__/CandlesSub'; + CandlesQuery, + CandlesQueryVariables, + CandleFieldsFragment, + CandlesEventsSubscription, + CandlesEventsSubscriptionVariables, +} from './__generated__/Candles'; import type { Subscription } from 'zen-observable-ts'; import { Interval } from '@vegaprotocol/types'; @@ -23,61 +28,6 @@ const INTERVAL_TO_PENNANT_MAP = { [PennantInterval.I1D]: Interval.INTERVAL_I1D, }; -export const CANDLE_FRAGMENT = gql` - fragment CandleFields on Candle { - datetime - high - low - open - close - volume - } -`; - -export const CANDLES_QUERY = gql` - ${CANDLE_FRAGMENT} - query Candles($marketId: ID!, $interval: Interval!, $since: String!) { - market(id: $marketId) { - id - decimalPlaces - tradableInstrument { - instrument { - id - name - code - } - } - candles(interval: $interval, since: $since) { - ...CandleFields - } - } - } -`; - -export const CANDLES_SUB = gql` - ${CANDLE_FRAGMENT} - subscription CandlesSub($marketId: ID!, $interval: Interval!) { - candles(marketId: $marketId, interval: $interval) { - ...CandleFields - } - } -`; - -const CHART_QUERY = gql` - query Chart($marketId: ID!) { - market(id: $marketId) { - decimalPlaces - data { - priceMonitoringBounds { - minValidPrice - maxValidPrice - referencePrice - } - } - } - } -`; - const defaultConfig = { decimalPlaces: 5, supportedIntervals: [ @@ -131,13 +81,15 @@ export class VegaDataSource implements DataSource { */ async onReady() { try { - const { data } = await this.client.query({ - query: CHART_QUERY, - variables: { - marketId: this.marketId, - }, - fetchPolicy: 'no-cache', - }); + const { data } = await this.client.query( + { + query: ChartDocument, + variables: { + marketId: this.marketId, + }, + fetchPolicy: 'no-cache', + } + ); if (data && data.market && data.market.data) { this._decimalPlaces = data.market.decimalPlaces; @@ -178,8 +130,11 @@ export class VegaDataSource implements DataSource { */ async query(interval: PennantInterval, from: string) { try { - const { data } = await this.client.query({ - query: CANDLES_QUERY, + const { data } = await this.client.query< + CandlesQuery, + CandlesQueryVariables + >({ + query: CandlesDocument, variables: { marketId: this.marketId, interval: INTERVAL_TO_PENNANT_MAP[interval], @@ -192,7 +147,7 @@ export class VegaDataSource implements DataSource { const decimalPlaces = data.market.decimalPlaces; const candles = data.market.candles - .filter((d): d is CandleFields => d !== null) + .filter((d): d is CandleFieldsFragment => d !== null) .map((d) => parseCandle(d, decimalPlaces)); return candles; @@ -211,8 +166,11 @@ export class VegaDataSource implements DataSource { interval: PennantInterval, onSubscriptionData: (data: Candle) => void ) { - const res = this.client.subscribe({ - query: CANDLES_SUB, + const res = this.client.subscribe< + CandlesEventsSubscription, + CandlesEventsSubscriptionVariables + >({ + query: CandlesEventsDocument, variables: { marketId: this.marketId, interval: INTERVAL_TO_PENNANT_MAP[interval], @@ -236,7 +194,10 @@ export class VegaDataSource implements DataSource { } } -function parseCandle(candle: CandleFields, decimalPlaces: number): Candle { +function parseCandle( + candle: CandleFieldsFragment, + decimalPlaces: number +): Candle { return { date: new Date(candle.datetime), high: Number(addDecimal(candle.high, decimalPlaces)), diff --git a/libs/candles-chart/src/lib/index.ts b/libs/candles-chart/src/lib/index.ts index 97c2a33d3..fec9df1f3 100644 --- a/libs/candles-chart/src/lib/index.ts +++ b/libs/candles-chart/src/lib/index.ts @@ -1,6 +1,4 @@ -export * from './__generated__/CandleFields'; export * from './__generated__/Candles'; -export * from './__generated__/CandlesSub'; export * from './__generated__/Chart'; export * from './candles-chart'; export * from './data-source'; diff --git a/libs/deal-ticket/src/components/__generated___/DealTicket.ts b/libs/deal-ticket/src/components/__generated___/DealTicket.ts index 72baee372..42c386716 100644 --- a/libs/deal-ticket/src/components/__generated___/DealTicket.ts +++ b/libs/deal-ticket/src/components/__generated___/DealTicket.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/libs/deal-ticket/src/components/__generated___/MarketInfo.ts b/libs/deal-ticket/src/components/__generated___/MarketInfo.ts index db4847f58..03a931d63 100644 --- a/libs/deal-ticket/src/components/__generated___/MarketInfo.ts +++ b/libs/deal-ticket/src/components/__generated___/MarketInfo.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/libs/deal-ticket/src/components/__generated___/MarketNames.ts b/libs/deal-ticket/src/components/__generated___/MarketNames.ts index edd97bfea..99a191096 100644 --- a/libs/deal-ticket/src/components/__generated___/MarketNames.ts +++ b/libs/deal-ticket/src/components/__generated___/MarketNames.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/libs/deal-ticket/src/components/market-info/__generated__/MarketInfoQuery.ts b/libs/deal-ticket/src/components/market-info/__generated__/MarketInfoQuery.ts index b564c331d..ad7030fd3 100644 --- a/libs/deal-ticket/src/components/market-info/__generated__/MarketInfoQuery.ts +++ b/libs/deal-ticket/src/components/market-info/__generated__/MarketInfoQuery.ts @@ -462,14 +462,14 @@ export interface MarketInfoQuery_market { /** * decimalPlaces indicates the number of decimal places that an integer must be shifted by in order to get a correct * number denominated in the currency of the market. (uint64) - * + * * Examples: * Currency Balance decimalPlaces Real Balance * GBP 100 0 GBP 100 * GBP 100 2 GBP 1.00 * GBP 100 4 GBP 0.01 * GBP 1 4 GBP 0.0001 ( 0.01p ) - * + * * GBX (pence) 100 0 GBP 1.00 (100p ) * GBX (pence) 100 2 GBP 0.01 ( 1p ) * GBX (pence) 100 4 GBP 0.0001 ( 0.01p ) diff --git a/libs/deposits/src/lib/__generated___/Deposit.ts b/libs/deposits/src/lib/__generated___/Deposit.ts index ab1a3f633..dce3d6cb8 100644 --- a/libs/deposits/src/lib/__generated___/Deposit.ts +++ b/libs/deposits/src/lib/__generated___/Deposit.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/libs/fills/src/lib/__generated___/Fills.ts b/libs/fills/src/lib/__generated___/Fills.ts index abceb245c..b0011f312 100644 --- a/libs/fills/src/lib/__generated___/Fills.ts +++ b/libs/fills/src/lib/__generated___/Fills.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/libs/governance/src/lib/proposals-hooks/__generated___/Proposal.ts b/libs/governance/src/lib/proposals-hooks/__generated___/Proposal.ts index b13a16f80..c44106b99 100644 --- a/libs/governance/src/lib/proposals-hooks/__generated___/Proposal.ts +++ b/libs/governance/src/lib/proposals-hooks/__generated___/Proposal.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/libs/market-depth/src/lib/__generated___/MarketDepth.ts b/libs/market-depth/src/lib/__generated___/MarketDepth.ts index 48a8e2f14..3882a9523 100644 --- a/libs/market-depth/src/lib/__generated___/MarketDepth.ts +++ b/libs/market-depth/src/lib/__generated___/MarketDepth.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/libs/market-list/src/lib/__generated___/MarketData.ts b/libs/market-list/src/lib/__generated___/MarketData.ts index 21a5964ac..6a5677a0a 100644 --- a/libs/market-list/src/lib/__generated___/MarketData.ts +++ b/libs/market-list/src/lib/__generated___/MarketData.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/libs/network-stats/src/components/stats-manager/__generated___/Stats.ts b/libs/network-stats/src/components/stats-manager/__generated___/Stats.ts index a629ad1c3..2d8764e28 100644 --- a/libs/network-stats/src/components/stats-manager/__generated___/Stats.ts +++ b/libs/network-stats/src/components/stats-manager/__generated___/Stats.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/libs/orders/src/lib/order-hooks/__generated___/Orders.ts b/libs/orders/src/lib/order-hooks/__generated___/Orders.ts index 37417d7a9..a332890b3 100644 --- a/libs/orders/src/lib/order-hooks/__generated___/Orders.ts +++ b/libs/orders/src/lib/order-hooks/__generated___/Orders.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/libs/positions/src/lib/__generated___/Positions.ts b/libs/positions/src/lib/__generated___/Positions.ts index 402816484..c950d3307 100644 --- a/libs/positions/src/lib/__generated___/Positions.ts +++ b/libs/positions/src/lib/__generated___/Positions.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/libs/positions/src/lib/positions-data-providers.spec.ts b/libs/positions/src/lib/positions-data-providers.spec.ts index 67efe22d3..79f40919e 100644 --- a/libs/positions/src/lib/positions-data-providers.spec.ts +++ b/libs/positions/src/lib/positions-data-providers.spec.ts @@ -1,9 +1,9 @@ import { AccountType, MarketTradingMode } from '@vegaprotocol/types'; -import type { Accounts } from '@vegaprotocol/accounts'; +import type { AccountsQuery } from '@vegaprotocol/accounts'; import type { Positions } from './__generated__/Positions'; import { getMetrics } from './positions-data-providers'; -const accounts: Accounts = { +const accounts: AccountsQuery = { party: { __typename: 'Party', id: '02eceaba4df2bef76ea10caf728d8a099a2aa846cced25737cccaa9812342f65', diff --git a/libs/positions/src/lib/positions-data-providers.ts b/libs/positions/src/lib/positions-data-providers.ts index 513423482..8a93880cd 100644 --- a/libs/positions/src/lib/positions-data-providers.ts +++ b/libs/positions/src/lib/positions-data-providers.ts @@ -2,7 +2,7 @@ import { gql } from '@apollo/client'; import produce from 'immer'; import BigNumber from 'bignumber.js'; import sortBy from 'lodash/sortBy'; -import type { Accounts_party_accounts } from '@vegaprotocol/accounts'; +import type { AccountFieldsFragment } from '@vegaprotocol/accounts'; import { accountsDataProvider } from '@vegaprotocol/accounts'; import { toBigNum } from '@vegaprotocol/react-helpers'; import type { Positions, Positions_party } from './__generated__/Positions'; @@ -117,7 +117,7 @@ export const POSITIONS_SUBSCRIPTION = gql` export const getMetrics = ( data: Positions_party | null, - accounts: Accounts_party_accounts[] | null + accounts: AccountFieldsFragment[] | null ): Position[] => { if (!data || !data?.positionsConnection.edges) { return []; @@ -272,7 +272,7 @@ export const positionsMetricsDataProvider = makeDerivedDataProvider( return sortBy( getMetrics( positions as Positions_party | null, - accounts as Accounts_party_accounts[] | null + accounts as AccountFieldsFragment[] | null ), 'updatedAt' ).reverse(); diff --git a/libs/trades/src/lib/__generated___/Trades.ts b/libs/trades/src/lib/__generated___/Trades.ts index 9bc466259..c6fcca571 100644 --- a/libs/trades/src/lib/__generated___/Trades.ts +++ b/libs/trades/src/lib/__generated___/Trades.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/libs/types/apollo.config.js b/libs/types/apollo.config.js index 7f306cb72..92fa4866a 100644 --- a/libs/types/apollo.config.js +++ b/libs/types/apollo.config.js @@ -11,6 +11,12 @@ module.exports = { '../../apps/token/client.graphql', '../../apps/trading/client.graphql', ], - excludes: ['**/generic-data-provider.ts', '**/__generated___/*'], + excludes: [ + '**/generic-data-provider.ts', + '**/__generated___/*', + '../../libs/accounts/**', + '../../libs/assets/**', + '../../libs/candles-chart/**', + ], }, }; diff --git a/libs/types/codegen.yml b/libs/types/codegen.yml index 527db3252..851a6b7db 100644 --- a/libs/types/codegen.yml +++ b/libs/types/codegen.yml @@ -9,21 +9,21 @@ config: generates: libs/types/src/__generated__/types.ts: - typescript - libs/**/__generated__: + libs/**: preset: near-operation-file presetConfig: folder: __generated___ extension: .ts - baseTypesPath: ~@vegaprotocol/types/types + baseTypesPath: ~@vegaprotocol/types plugins: - typescript-operations - typescript-react-apollo - apps/**/__generated__: + apps/**: preset: near-operation-file presetConfig: folder: __generated___ extension: .ts - baseTypesPath: ~@vegaprotocol/types/types + baseTypesPath: ~@vegaprotocol/types plugins: - typescript-operations - typescript-react-apollo diff --git a/libs/types/fix-imports.js b/libs/types/fix-imports.js index fa62b5517..1daea5b2e 100644 --- a/libs/types/fix-imports.js +++ b/libs/types/fix-imports.js @@ -1,6 +1,66 @@ +const fs = require('fs'); +const path = require('path'); +const glob = require('glob'); const replace = require('replace-in-file'); -replace({ - files: '{apps,libs}/**/__generated__/*.ts', - from: /"[^"]*\/types\/src\/__generated__\/globalTypes"/g, - to: '"@vegaprotocol/types"', +const apolloConfig = require('./apollo.config'); + +Promise.all([ + replace({ + files: '{apps,libs}/**/__generated__/*.ts', + from: /"[^"]*\/types\/src\/__generated__\/globalTypes"/g, + to: '"@vegaprotocol/types"', + }), + replace({ + files: '{apps,libs}/**/__generated___/*.ts', + from: 'import * as Types', + to: 'import { Schema as Types }', + }), + replace({ + files: '{apps,libs}/**/__generated__/*.ts', + from: 'import * as Types', + to: 'import { Schema as Types }', + }), +]).then(() => { + // @TODO: remove this temporary cleanup ugliness below once all libs and apps are migrated from the old apollo codegen + const MIGRATED_TO_NEW_CODEGEN = apolloConfig.client.excludes.reduce( + (acc, ignoredPath) => { + if ( + ignoredPath.startsWith('../../libs/') || + ignoredPath.startsWith('../../apps/') + ) { + acc.push(path.join(__dirname, ignoredPath.replace('/**', ''))); + } + return acc; + }, + [] + ); + + // @TODO: remove also + MIGRATED_TO_NEW_CODEGEN.forEach((packagePath) => { + glob(path.join(packagePath, '**', '__generated___'), (err, matches) => { + matches.forEach((match) => { + console.log(`Handling ${match}...`); + const oldTypesFolder = match.replace('__generated___', '__generated__'); + if (fs.existsSync(oldTypesFolder)) { + console.log(`Found ${oldTypesFolder}...`); + try { + fs.rmSync(oldTypesFolder, { + force: true, + recursive: true, + }); + console.log(`Removed ${oldTypesFolder}...`); + } catch (err) { + console.error(`Error removing ${oldTypesFolder}.`); + } + + try { + fs.renameSync(match, oldTypesFolder); + console.log(`Renamed ${match} to ${oldTypesFolder}...`); + } catch (err) { + console.error(`Error renaming ${match} to ${oldTypesFolder}.`); + } + } + }); + }); + }); }); diff --git a/libs/web3/src/lib/__generated___/NetworkParams.ts b/libs/web3/src/lib/__generated___/NetworkParams.ts index 1f15fb4cc..bf9bbd4dd 100644 --- a/libs/web3/src/lib/__generated___/NetworkParams.ts +++ b/libs/web3/src/lib/__generated___/NetworkParams.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/libs/withdraws/src/lib/__generated___/Erc20Approval.ts b/libs/withdraws/src/lib/__generated___/Erc20Approval.ts index 9cd9eb0c0..f919d989a 100644 --- a/libs/withdraws/src/lib/__generated___/Erc20Approval.ts +++ b/libs/withdraws/src/lib/__generated___/Erc20Approval.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/libs/withdraws/src/lib/__generated___/Withdraw.ts b/libs/withdraws/src/lib/__generated___/Withdraw.ts index 73ff97211..8d9c1be3a 100644 --- a/libs/withdraws/src/lib/__generated___/Withdraw.ts +++ b/libs/withdraws/src/lib/__generated___/Withdraw.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/libs/withdraws/src/lib/__generated___/Withdrawal.ts b/libs/withdraws/src/lib/__generated___/Withdrawal.ts index 60c8c3b48..584b15205 100644 --- a/libs/withdraws/src/lib/__generated___/Withdrawal.ts +++ b/libs/withdraws/src/lib/__generated___/Withdrawal.ts @@ -1,4 +1,4 @@ -import * as Types from '@vegaprotocol/types/types'; +import { Schema as Types } from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; diff --git a/libs/withdraws/src/lib/use-create-withdraw.spec.tsx b/libs/withdraws/src/lib/use-create-withdraw.spec.tsx index 94f1c5101..cb2db36e1 100644 --- a/libs/withdraws/src/lib/use-create-withdraw.spec.tsx +++ b/libs/withdraws/src/lib/use-create-withdraw.spec.tsx @@ -20,7 +20,7 @@ import type { } from './__generated__/WithdrawalEvent'; import { WITHDRAWAL_BUS_EVENT_SUB } from './use-withdrawals'; import { WithdrawalStatus } from '@vegaprotocol/types'; -import { AssetStatus } from '@vegaprotocol/types/types'; +import { Schema } from '@vegaprotocol/types'; function setup( vegaWalletContext: Partial, @@ -74,7 +74,7 @@ beforeEach(() => { name: 'asset-name', symbol: 'asset-symbol', decimals: 2, - status: AssetStatus.STATUS_ENABLED, + status: Schema.AssetStatus.STATUS_ENABLED, source: { __typename: 'ERC20', contractAddress: '0x123', diff --git a/package.json b/package.json index f80fc1a1e..30e2bc36e 100644 --- a/package.json +++ b/package.json @@ -153,7 +153,7 @@ "eslint-plugin-react-hooks": "4.6.0", "eslint-plugin-unicorn": "^41.0.0", "faker": "^5.5.3", - "glob": "^8.0.1", + "glob": "^8.0.3", "husky": "^7.0.4", "jest": "27.5.1", "jest-canvas-mock": "^2.3.1", diff --git a/tsconfig.base.json b/tsconfig.base.json index 860b2e449..395b4e40f 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -39,7 +39,6 @@ ], "@vegaprotocol/trades": ["libs/trades/src/index.ts"], "@vegaprotocol/types": ["libs/types/src/index.ts"], - "@vegaprotocol/types/types": ["libs/types/src/__generated__/types.ts"], "@vegaprotocol/ui-toolkit": ["libs/ui-toolkit/src/index.ts"], "@vegaprotocol/wallet": ["libs/wallet/src/index.ts"], "@vegaprotocol/web3": ["libs/web3/src/index.ts"], diff --git a/yarn.lock b/yarn.lock index 166fe235d..4660c6250 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13280,7 +13280,7 @@ glob@^7.0.0, glob@^7.1.0, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4, gl once "^1.3.0" path-is-absolute "^1.0.0" -glob@^8.0.0, glob@^8.0.1: +glob@^8.0.0, glob@^8.0.3: version "8.0.3" resolved "https://registry.yarnpkg.com/glob/-/glob-8.0.3.tgz#415c6eb2deed9e502c68fa44a272e6da6eeca42e" integrity sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ==