fix: typegen (#2046)

* fix: typegen

* fix: interval imports

* fix: more interval imports

* fix: remove unused generated folders

* fix: format

* fix: format again
This commit is contained in:
botond 2022-11-14 12:37:15 +01:00 committed by GitHub
parent 3b3e4b5f4b
commit 1672e157a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 62 additions and 276 deletions

View File

@ -1,17 +0,0 @@
query DepositAssets {
assetsConnection {
edges {
node {
id
name
symbol
decimals
source {
... on ERC20 {
contractAddress
}
}
}
}
}
}

View File

@ -1,75 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { AssetStatus } from "@vegaprotocol/types";
// ====================================================
// GraphQL query operation: DepositAssets
// ====================================================
export interface DepositAssets_assetsConnection_edges_node_source_BuiltinAsset {
__typename: "BuiltinAsset";
}
export interface DepositAssets_assetsConnection_edges_node_source_ERC20 {
__typename: "ERC20";
/**
* The address of the ERC20 contract
*/
contractAddress: string;
}
export type DepositAssets_assetsConnection_edges_node_source = DepositAssets_assetsConnection_edges_node_source_BuiltinAsset | DepositAssets_assetsConnection_edges_node_source_ERC20;
export interface DepositAssets_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 status of the asset in the Vega network
*/
status: AssetStatus;
/**
* The origin source of the asset (e.g: an ERC20 asset)
*/
source: DepositAssets_assetsConnection_edges_node_source;
}
export interface DepositAssets_assetsConnection_edges {
__typename: "AssetEdge";
/**
* The asset information
*/
node: DepositAssets_assetsConnection_edges_node;
}
export interface DepositAssets_assetsConnection {
__typename: "AssetsConnection";
/**
* The assets
*/
edges: (DepositAssets_assetsConnection_edges | null)[] | null;
}
export interface DepositAssets {
/**
* The list of all assets in use in the Vega network or the specified asset if ID is provided
*/
assetsConnection: DepositAssets_assetsConnection | null;
}

View File

@ -1,57 +0,0 @@
import { Schema as Types } from '@vegaprotocol/types';
import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client';
const defaultOptions = {} as const;
export type DepositAssetsQueryVariables = Types.Exact<{ [key: string]: never; }>;
export type DepositAssetsQuery = { __typename?: 'Query', assetsConnection?: { __typename?: 'AssetsConnection', edges?: Array<{ __typename?: 'AssetEdge', node: { __typename?: 'Asset', id: string, name: string, symbol: string, decimals: number, source: { __typename?: 'BuiltinAsset' } | { __typename?: 'ERC20', contractAddress: string } } } | null> | null } | null };
export const DepositAssetsDocument = gql`
query DepositAssets {
assetsConnection {
edges {
node {
id
name
symbol
decimals
source {
... on ERC20 {
contractAddress
}
}
}
}
}
}
`;
/**
* __useDepositAssetsQuery__
*
* To run a query within a React component, call `useDepositAssetsQuery` and pass it any options that fit your needs.
* When your component renders, `useDepositAssetsQuery` 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 } = useDepositAssetsQuery({
* variables: {
* },
* });
*/
export function useDepositAssetsQuery(baseOptions?: Apollo.QueryHookOptions<DepositAssetsQuery, DepositAssetsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useQuery<DepositAssetsQuery, DepositAssetsQueryVariables>(DepositAssetsDocument, options);
}
export function useDepositAssetsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<DepositAssetsQuery, DepositAssetsQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<DepositAssetsQuery, DepositAssetsQueryVariables>(DepositAssetsDocument, options);
}
export type DepositAssetsQueryHookResult = ReturnType<typeof useDepositAssetsQuery>;
export type DepositAssetsLazyQueryHookResult = ReturnType<typeof useDepositAssetsLazyQuery>;
export type DepositAssetsQueryResult = Apollo.QueryResult<DepositAssetsQuery, DepositAssetsQueryVariables>;

View File

@ -14,7 +14,7 @@ import SimpleMarketToolbar from './simple-market-toolbar';
import { IS_MARKET_TRADABLE } from '../../constants';
import { ConsoleLiteGrid } from '../console-lite-grid';
import type { Market } from '@vegaprotocol/market-list';
import { Interval } from '@vegaprotocol/types';
import { Schema } from '@vegaprotocol/types';
import { marketsWithCandlesProvider } from '@vegaprotocol/market-list';
export type MarketWithPercentChange = Market & {
@ -38,7 +38,7 @@ const SimpleMarketList = () => {
const variables = useMemo(() => {
return {
since: new Date(yesterday).toISOString(),
interval: Interval.INTERVAL_I1H,
interval: Schema.Interval.INTERVAL_I1H,
};
}, [yesterday]);
const { data, error, loading } = useDataProvider({

View File

@ -4,7 +4,7 @@ import { InView } from 'react-intersection-observer';
import { useDataProvider, useYesterday } from '@vegaprotocol/react-helpers';
import type { Candle } from '@vegaprotocol/market-list';
import { marketCandlesProvider } from '@vegaprotocol/market-list';
import { Interval } from '@vegaprotocol/types';
import { Schema } from '@vegaprotocol/types';
interface Props {
candles: (Candle | null)[] | null;
@ -73,7 +73,7 @@ const SimpleMarketPercentChange = ({ candles, marketId, setValue }: Props) => {
dataProvider: marketCandlesProvider,
variables: {
marketId,
interval: Interval.INTERVAL_I1D,
interval: Schema.Interval.INTERVAL_I1D,
since: new Date(yesterday).toISOString(),
},
});

View File

@ -5,7 +5,7 @@ import {
useDataProvider,
addDecimalsFormatNumber,
} from '@vegaprotocol/react-helpers';
import { Interval } from '@vegaprotocol/types';
import { Schema } from '@vegaprotocol/types';
import {
calcDayVolume,
getChange,
@ -36,7 +36,7 @@ export const Last24hVolume = ({
const variables = useMemo(
() => ({
marketId: marketId,
interval: Interval.INTERVAL_I1H,
interval: Schema.Interval.INTERVAL_I1H,
since: yTimestamp,
}),
[marketId, yTimestamp]
@ -45,7 +45,7 @@ export const Last24hVolume = ({
const variables24hAgo = useMemo(
() => ({
marketId: marketId,
interval: Interval.INTERVAL_I1D,
interval: Schema.Interval.INTERVAL_I1D,
since: yTimestamp,
}),
[marketId, yTimestamp]

View File

@ -8,7 +8,7 @@ import type {
} from './__generated___/Asset';
import { AssetListBundleDocument } from './__generated___/Asset';
import { ProposalAssetDocument } from './__generated___/Asset';
import { AssetStatus } from '@vegaprotocol/types';
import { Schema } from '@vegaprotocol/types';
import type { useWeb3React } from '@web3-react/core';
import BigNumber from 'bignumber.js';
import type { AppState } from '../../../../contexts/app-state/app-state-context';
@ -86,7 +86,7 @@ const DEFAULT__ASSET: ProposalAssetQuery = {
__typename: 'Query',
asset: {
__typename: 'Asset',
status: AssetStatus.STATUS_PENDING_LISTING,
status: Schema.AssetStatus.STATUS_PENDING_LISTING,
source: {
__typename: 'ERC20',
contractAddress: '0x0',

View File

@ -1,5 +1,5 @@
import type { CollateralBridge } from '@vegaprotocol/smart-contracts';
import { AssetStatus } from '@vegaprotocol/types';
import { Schema } from '@vegaprotocol/types';
import { Button } from '@vegaprotocol/ui-toolkit';
import { useBridgeContract, useEthereumTransaction } from '@vegaprotocol/web3';
import { useTranslation } from 'react-i18next';
@ -80,7 +80,9 @@ export const ListAsset = ({
return null;
}
if (data.asset.source.__typename !== 'ERC20') return null;
if (data.asset.status !== AssetStatus.STATUS_PENDING_LISTING) return null;
if (data.asset.status !== Schema.AssetStatus.STATUS_PENDING_LISTING) {
return null;
}
if (errorAsset || errorBundle) return null;
const { assetSource, signatures, vegaAssetId, nonce } =
assetData.erc20ListAssetBundle;

View File

@ -702,7 +702,7 @@ export interface Proposal_proposal_terms_change_NewAsset_source_ERC20 {
lifetimeLimit: string;
/**
* The maximum you can withdraw instantly. All withdrawals over the threshold will be delayed by the withdrawal delay.
* Theres no limit on the size of a withdrawal
* There is no limit on the size of a withdrawal
* Note: this is a temporary measure that can be changed by governance
*/
withdrawThreshold: string;
@ -760,7 +760,7 @@ export interface Proposal_proposal_terms_change_UpdateAsset_source {
lifetimeLimit: string;
/**
* The maximum you can withdraw instantly. All withdrawals over the threshold will be delayed by the withdrawal delay.
* Theres no limit on the size of a withdrawal
* There is no limit on the size of a withdrawal
* Note: this is a temporary measure that can be changed by governance
*/
withdrawThreshold: string;

View File

@ -142,7 +142,7 @@ export interface ProposalFields_terms_change_UpdateAsset_source {
lifetimeLimit: string;
/**
* The maximum you can withdraw instantly. All withdrawals over the threshold will be delayed by the withdrawal delay.
* Theres no limit on the size of a withdrawal
* There is no limit on the size of a withdrawal
* Note: this is a temporary measure that can be changed by governance
*/
withdrawThreshold: string;

View File

@ -142,7 +142,7 @@ export interface Proposals_proposalsConnection_edges_node_terms_change_UpdateAss
lifetimeLimit: string;
/**
* The maximum you can withdraw instantly. All withdrawals over the threshold will be delayed by the withdrawal delay.
* Theres no limit on the size of a withdrawal
* There is no limit on the size of a withdrawal
* Note: this is a temporary measure that can be changed by governance
*/
withdrawThreshold: string;

View File

@ -2,7 +2,7 @@ import { useCallback, useMemo, useRef, useState } from 'react';
import throttle from 'lodash/throttle';
import { t, useDataProvider, useYesterday } from '@vegaprotocol/react-helpers';
import { PriceCellChange } from '@vegaprotocol/ui-toolkit';
import { Interval } from '@vegaprotocol/types';
import { Schema } from '@vegaprotocol/types';
import type { CandleClose } from '@vegaprotocol/types';
import type {
SingleMarketFieldsFragment,
@ -34,7 +34,7 @@ export const Last24hPriceChange = ({ marketId }: { marketId: string }) => {
const variables = useMemo(
() => ({
marketId: marketId,
interval: Interval.INTERVAL_I1H,
interval: Schema.Interval.INTERVAL_I1H,
since: yTimestamp,
}),
[marketId, yTimestamp]

View File

@ -9,7 +9,7 @@ import {
useDataProvider,
useYesterday,
} from '@vegaprotocol/react-helpers';
import { Interval } from '@vegaprotocol/types';
import { Schema } from '@vegaprotocol/types';
import throttle from 'lodash/throttle';
import { useCallback, useMemo, useRef, useState } from 'react';
@ -39,7 +39,7 @@ export const Last24hVolume = ({ marketId }: { marketId: string }) => {
const variables = useMemo(
() => ({
marketId: marketId,
interval: Interval.INTERVAL_I1H,
interval: Schema.Interval.INTERVAL_I1H,
since: yTimestamp,
}),
[marketId, yTimestamp]

View File

@ -1,52 +0,0 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
import { AssetStatus } from "@vegaprotocol/types";
// ====================================================
// GraphQL fragment: AssetFields
// ====================================================
export interface AssetFields_source_BuiltinAsset {
__typename: "BuiltinAsset";
}
export interface AssetFields_source_ERC20 {
__typename: "ERC20";
/**
* The address of the ERC20 contract
*/
contractAddress: string;
}
export type AssetFields_source = AssetFields_source_BuiltinAsset | AssetFields_source_ERC20;
export interface AssetFields {
__typename: "Asset";
/**
* The ID of the asset
*/
id: string;
/**
* The symbol of the asset (e.g: GBP)
*/
symbol: string;
/**
* The full name of the asset (e.g: Great British Pound)
*/
name: string;
/**
* 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 status of the asset in the Vega network
*/
status: AssetStatus;
/**
* The origin source of the asset (e.g: an ERC20 asset)
*/
source: AssetFields_source;
}

View File

@ -1,6 +1,6 @@
import { MockedProvider } from '@apollo/react-testing';
import { render, screen } from '@testing-library/react';
import { AssetStatus } from '@vegaprotocol/types';
import { Schema } from '@vegaprotocol/types';
import { AssetDetailsDialog } from './asset-details-dialog';
import { AssetDetail, testId } from './asset-details-table';
import { AssetsDocument } from './__generated__/Assets';
@ -11,23 +11,26 @@ const mockedData = {
assetsConnection: {
edges: [
{
node: generateERC20Asset(1, AssetStatus.STATUS_ENABLED),
node: generateERC20Asset(1, Schema.AssetStatus.STATUS_ENABLED),
__typename: 'AssetEdge',
},
{
node: generateBuiltinAsset(1, AssetStatus.STATUS_ENABLED),
node: generateBuiltinAsset(1, Schema.AssetStatus.STATUS_ENABLED),
__typename: 'AssetEdge',
},
{
node: generateBuiltinAsset(2, AssetStatus.STATUS_PENDING_LISTING),
node: generateBuiltinAsset(
2,
Schema.AssetStatus.STATUS_PENDING_LISTING
),
__typename: 'AssetEdge',
},
{
node: generateBuiltinAsset(3, AssetStatus.STATUS_PROPOSED),
node: generateBuiltinAsset(3, Schema.AssetStatus.STATUS_PROPOSED),
__typename: 'AssetEdge',
},
{
node: generateBuiltinAsset(4, AssetStatus.STATUS_REJECTED),
node: generateBuiltinAsset(4, Schema.AssetStatus.STATUS_REJECTED),
__typename: 'AssetEdge',
},
],

View File

@ -1,5 +1,5 @@
import { render, screen } from '@testing-library/react';
import { AssetStatus } from '@vegaprotocol/types';
import { Schema } from '@vegaprotocol/types';
import type { Asset } from './asset-data-provider';
import {
AssetDetail,
@ -13,7 +13,7 @@ describe('AssetDetailsTable', () => {
const cases: [string, Asset, { key: AssetDetail; value: string }[]][] = [
[
'ERC20 asset',
generateERC20Asset(1, AssetStatus.STATUS_ENABLED),
generateERC20Asset(1, Schema.AssetStatus.STATUS_ENABLED),
[
{ key: AssetDetail.ID, value: 'E-01' },
{ key: AssetDetail.TYPE, value: 'ERC20' },
@ -47,7 +47,7 @@ describe('AssetDetailsTable', () => {
],
[
'Builtin asset',
generateBuiltinAsset(1, AssetStatus.STATUS_ENABLED),
generateBuiltinAsset(1, Schema.AssetStatus.STATUS_ENABLED),
[
{ key: AssetDetail.ID, value: 'B-01' },
{ key: AssetDetail.TYPE, value: 'Builtin asset' },

View File

@ -4,7 +4,7 @@ import {
useDataProvider,
} from '@vegaprotocol/react-helpers';
import { AssetsDocument } from './__generated__/Assets';
import { AssetStatus } from '@vegaprotocol/types';
import { Schema } from '@vegaprotocol/types';
import type { AssetsQuery } from './__generated__/Assets';
import type { Asset } from './asset-data-provider';
@ -54,7 +54,7 @@ export const enabledAssetsProvider = makeDerivedDataProvider<
never
>([assetsProvider], ([assets]) =>
(assets as ReturnType<typeof getData>).filter(
(a) => a.status === AssetStatus.STATUS_ENABLED
(a) => a.status === Schema.AssetStatus.STATUS_ENABLED
)
);

View File

@ -1,7 +1,10 @@
import type { AssetStatus } from '@vegaprotocol/types';
import type { Schema } from '@vegaprotocol/types';
import type { Asset } from './asset-data-provider';
export const generateERC20Asset = (i: number, status: AssetStatus): Asset => ({
export const generateERC20Asset = (
i: number,
status: Schema.AssetStatus
): Asset => ({
id: `E-0${i}`,
name: `ERC20 0${i}`,
symbol: `EA0${i}`,
@ -43,7 +46,7 @@ export const generateERC20Asset = (i: number, status: AssetStatus): Asset => ({
export const generateBuiltinAsset = (
i: number,
status: AssetStatus
status: Schema.AssetStatus
): Asset => ({
id: `B-0${i}`,
name: `Builtin 0${i}`,

View File

@ -17,15 +17,15 @@ import type {
CandlesEventsSubscriptionVariables,
} from './__generated__/Candles';
import type { Subscription } from 'zen-observable-ts';
import { Interval } from '@vegaprotocol/types';
import { Schema } from '@vegaprotocol/types';
const INTERVAL_TO_PENNANT_MAP = {
[PennantInterval.I1M]: Interval.INTERVAL_I1M,
[PennantInterval.I5M]: Interval.INTERVAL_I5M,
[PennantInterval.I15M]: Interval.INTERVAL_I15M,
[PennantInterval.I1H]: Interval.INTERVAL_I1H,
[PennantInterval.I6H]: Interval.INTERVAL_I6H,
[PennantInterval.I1D]: Interval.INTERVAL_I1D,
[PennantInterval.I1M]: Schema.Interval.INTERVAL_I1M,
[PennantInterval.I5M]: Schema.Interval.INTERVAL_I5M,
[PennantInterval.I15M]: Schema.Interval.INTERVAL_I15M,
[PennantInterval.I1H]: Schema.Interval.INTERVAL_I1H,
[PennantInterval.I6H]: Schema.Interval.INTERVAL_I6H,
[PennantInterval.I1D]: Schema.Interval.INTERVAL_I1D,
};
const defaultConfig = {

View File

@ -2,7 +2,7 @@ import { waitFor, fireEvent, render, screen } from '@testing-library/react';
import BigNumber from 'bignumber.js';
import type { DepositFormProps } from './deposit-form';
import { DepositForm } from './deposit-form';
import { AssetStatus } from '@vegaprotocol/types';
import { Schema } from '@vegaprotocol/types';
import { useVegaWallet } from '@vegaprotocol/wallet';
import { useWeb3React } from '@web3-react/core';
import type { AssetFieldsFragment } from '@vegaprotocol/assets';
@ -18,7 +18,7 @@ function generateAsset(): AssetFieldsFragment {
name: 'asset-name',
decimals: 2,
quantum: '',
status: AssetStatus.STATUS_ENABLED,
status: Schema.AssetStatus.STATUS_ENABLED,
source: {
__typename: 'ERC20',
contractAddress: 'contract-address',

View File

@ -9,7 +9,7 @@ import {
} from '@vegaprotocol/react-helpers';
import {
AccountType,
Interval,
Schema,
MarketStateMapping,
MarketTradingModeMapping,
} from '@vegaprotocol/types';
@ -62,7 +62,11 @@ export const MarketInfoContainer = ({
return new Date(yesterday).toISOString();
}, [yesterday]);
const variables = useMemo(
() => ({ marketId, since: yTimestamp, interval: Interval.INTERVAL_I1H }),
() => ({
marketId,
since: yTimestamp,
interval: Schema.Interval.INTERVAL_I1H,
}),
[marketId, yTimestamp]
);

View File

@ -13,7 +13,7 @@ import { marketsCandlesProvider } from './markets-candles-provider';
import type { MarketData } from './market-data-provider';
import type { MarketCandles } from './markets-candles-provider';
import { useMemo } from 'react';
import { Interval } from '@vegaprotocol/types';
import { Schema } from '@vegaprotocol/types';
import { filterAndSortMarkets } from './utils';
import { MarketsDocument } from './__generated___/markets';
@ -95,7 +95,7 @@ export const useMarketList = () => {
const variables = useMemo(() => {
return {
since: new Date(yesterday).toISOString(),
interval: Interval.INTERVAL_I1H,
interval: Schema.Interval.INTERVAL_I1H,
};
}, [yesterday]);
const { data, loading, error } = useDataProvider({

View File

@ -13,7 +13,7 @@ module.exports = {
],
excludes: [
'**/generic-data-provider.ts',
'**/__generated__/*',
'**/__generated___/*',
'../../libs/accounts/**',
'../../libs/assets/**',
'../../libs/candles-chart/**',

View File

@ -29,13 +29,6 @@ export enum AccountType {
ACCOUNT_TYPE_SETTLEMENT = "ACCOUNT_TYPE_SETTLEMENT",
}
export enum AssetStatus {
STATUS_ENABLED = "STATUS_ENABLED",
STATUS_PENDING_LISTING = "STATUS_PENDING_LISTING",
STATUS_PROPOSED = "STATUS_PROPOSED",
STATUS_REJECTED = "STATUS_REJECTED",
}
export enum AuctionTrigger {
AUCTION_TRIGGER_BATCH = "AUCTION_TRIGGER_BATCH",
AUCTION_TRIGGER_LIQUIDITY = "AUCTION_TRIGGER_LIQUIDITY",
@ -63,18 +56,6 @@ export enum DataSourceSpecStatus {
STATUS_DEACTIVATED = "STATUS_DEACTIVATED",
}
/**
* The interval for trade candles when subscribing via Vega GraphQL, default is I15M
*/
export enum Interval {
INTERVAL_I15M = "INTERVAL_I15M",
INTERVAL_I1D = "INTERVAL_I1D",
INTERVAL_I1H = "INTERVAL_I1H",
INTERVAL_I1M = "INTERVAL_I1M",
INTERVAL_I5M = "INTERVAL_I5M",
INTERVAL_I6H = "INTERVAL_I6H",
}
/**
* The current state of a market
*/
@ -193,12 +174,6 @@ export enum StakeLinkingStatus {
STATUS_REJECTED = "STATUS_REJECTED",
}
export enum ValidatorStatus {
VALIDATOR_NODE_STATUS_ERSATZ = "VALIDATOR_NODE_STATUS_ERSATZ",
VALIDATOR_NODE_STATUS_PENDING = "VALIDATOR_NODE_STATUS_PENDING",
VALIDATOR_NODE_STATUS_TENDERMINT = "VALIDATOR_NODE_STATUS_TENDERMINT",
}
export enum VoteValue {
VALUE_NO = "VALUE_NO",
VALUE_YES = "VALUE_YES",

View File

@ -534,7 +534,7 @@ export type DataSourceSpec = {
};
/**
* A data spec describes the source data that an instrument wants to get from the
* DataSourceSpecConfiguration describes the source data that an instrument wants to get from the
* sourcing engine.
*/
export type DataSourceSpecConfiguration = {
@ -715,7 +715,7 @@ export type ERC20 = {
lifetimeLimit: Scalars['String'];
/**
* The maximum you can withdraw instantly. All withdrawals over the threshold will be delayed by the withdrawal delay.
* Theres no limit on the size of a withdrawal
* There is no limit on the size of a withdrawal
* Note: this is a temporary measure that can be changed by governance
*/
withdrawThreshold: Scalars['String'];
@ -4693,7 +4693,7 @@ export type UpdateERC20 = {
lifetimeLimit: Scalars['String'];
/**
* The maximum you can withdraw instantly. All withdrawals over the threshold will be delayed by the withdrawal delay.
* Theres no limit on the size of a withdrawal
* There is no limit on the size of a withdrawal
* Note: this is a temporary measure that can be changed by governance
*/
withdrawThreshold: Scalars['String'];