Chore/migrate to new types (#1439)
* fix: candle type paths * chore: migrate deal-ticket * chore: migrate deposits * fix: format * chore: migrate environment * fix: format * chore: migrate fills * fix: format * chore: fix build errors * fix: format * fix: lint * fix: env tests * fix: add missing query variable * fix: format * fix: change vega_url because n11 is down * fix: deal ticket query name * chore: extend event type * fix: incorrect e2e test
This commit is contained in:
parent
d9e3b9de99
commit
87f7efd960
@ -23,7 +23,7 @@ describe('market selector', { tags: '@smoke' }, () => {
|
||||
aliasQuery(req, 'Markets', generateSimpleMarkets());
|
||||
aliasQuery(req, 'MarketsCandlesQuery', generateMarketsCandles());
|
||||
aliasQuery(req, 'MarketsDataQuery', generateMarketsData());
|
||||
aliasQuery(req, 'DealTicketQuery', generateDealTicket());
|
||||
aliasQuery(req, 'DealTicket', generateDealTicket());
|
||||
aliasQuery(req, 'MarketTags', generateMarketTags());
|
||||
aliasQuery(req, 'MarketPositions', generateMarketPositions());
|
||||
aliasQuery(req, 'EstimateOrder', generateEstimateOrder());
|
||||
|
@ -23,7 +23,7 @@ describe('Market trade', { tags: '@smoke' }, () => {
|
||||
aliasQuery(req, 'MarketsCandlesQuery', generateMarketsCandles());
|
||||
aliasQuery(req, 'MarketsDataQuery', generateMarketsData());
|
||||
aliasQuery(req, 'SimpleMarkets', generateSimpleMarkets());
|
||||
aliasQuery(req, 'DealTicketQuery', generateDealTicket());
|
||||
aliasQuery(req, 'DealTicket', generateDealTicket());
|
||||
aliasQuery(req, 'MarketTags', generateMarketTags());
|
||||
aliasQuery(req, 'MarketPositions', generateMarketPositions());
|
||||
aliasQuery(req, 'EstimateOrder', generateEstimateOrder());
|
||||
|
@ -1,13 +1,12 @@
|
||||
import type {
|
||||
Fills,
|
||||
Fills_party_tradesConnection_edges_node,
|
||||
} from '@vegaprotocol/fills';
|
||||
import type { FillsQuery, FillFieldsFragment } from '@vegaprotocol/fills';
|
||||
import { Side } from '@vegaprotocol/types';
|
||||
import merge from 'lodash/merge';
|
||||
import type { PartialDeep } from 'type-fest';
|
||||
|
||||
export const generateFills = (override?: PartialDeep<Fills>): Fills => {
|
||||
const fills: Fills_party_tradesConnection_edges_node[] = [
|
||||
export const generateFills = (
|
||||
override?: PartialDeep<FillsQuery>
|
||||
): FillsQuery => {
|
||||
const fills: FillFieldsFragment[] = [
|
||||
generateFill({
|
||||
buyer: {
|
||||
id: Cypress.env('VEGA_PUBLIC_KEY'),
|
||||
@ -45,7 +44,7 @@ export const generateFills = (override?: PartialDeep<Fills>): Fills => {
|
||||
}),
|
||||
];
|
||||
|
||||
const defaultResult: Fills = {
|
||||
const defaultResult: FillsQuery = {
|
||||
party: {
|
||||
id: 'buyer-id',
|
||||
tradesConnection: {
|
||||
@ -72,10 +71,8 @@ export const generateFills = (override?: PartialDeep<Fills>): Fills => {
|
||||
return merge(defaultResult, override);
|
||||
};
|
||||
|
||||
export const generateFill = (
|
||||
override?: PartialDeep<Fills_party_tradesConnection_edges_node>
|
||||
) => {
|
||||
const defaultFill: Fills_party_tradesConnection_edges_node = {
|
||||
export const generateFill = (override?: PartialDeep<FillFieldsFragment>) => {
|
||||
const defaultFill: FillFieldsFragment = {
|
||||
__typename: 'Trade',
|
||||
id: '0',
|
||||
createdAt: new Date().toISOString(),
|
||||
|
@ -1,6 +1,6 @@
|
||||
# App configuration variables
|
||||
NX_VEGA_CONFIG_URL=https://static.vega.xyz/assets/testnet-network.json
|
||||
NX_VEGA_URL=https://api.n11.testnet.vega.xyz/graphql
|
||||
NX_VEGA_URL=https://api.n12.testnet.vega.xyz/graphql
|
||||
NX_VEGA_ENV=TESTNET
|
||||
NX_VEGA_NETWORKS='{\"MAINNET\":\"https://alpha.console.vega.xyz\"}'
|
||||
NX_ETHEREUM_PROVIDER_URL=https://ropsten.infura.io/v3/4f846e79e13f44d1b51bbd7ed9edefb8
|
||||
|
@ -1,13 +1,13 @@
|
||||
import * as React from 'react';
|
||||
import classNames from 'classnames';
|
||||
import type { DealTicketQuery_market_tradableInstrument_instrument_product_settlementAsset } from '@vegaprotocol/deal-ticket';
|
||||
import type { DealTicketMarketFragment } from '@vegaprotocol/deal-ticket';
|
||||
import type { PartyBalanceQuery_party_accounts } from './__generated__/PartyBalanceQuery';
|
||||
import { useSettlementAccount } from '../../hooks/use-settlement-account';
|
||||
import { addDecimalsFormatNumber, t } from '@vegaprotocol/react-helpers';
|
||||
import { AccountType } from '@vegaprotocol/types';
|
||||
|
||||
interface DealTicketBalanceProps {
|
||||
settlementAsset: DealTicketQuery_market_tradableInstrument_instrument_product_settlementAsset;
|
||||
settlementAsset: DealTicketMarketFragment['tradableInstrument']['instrument']['product']['settlementAsset'];
|
||||
accounts: PartyBalanceQuery_party_accounts[];
|
||||
isWalletConnected: boolean;
|
||||
className?: string;
|
||||
|
@ -52,6 +52,10 @@ export const DealTicketContainer = () => {
|
||||
const container = marketId ? (
|
||||
<Container marketId={marketId}>
|
||||
{(data) => {
|
||||
if (!data.market) {
|
||||
return null as unknown as JSX.Element;
|
||||
}
|
||||
|
||||
const balance = (
|
||||
<DealTicketBalance
|
||||
className="mb-4"
|
||||
|
@ -2,7 +2,7 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useForm, Controller } from 'react-hook-form';
|
||||
import { Stepper } from '../stepper';
|
||||
import type { DealTicketQuery_market } from '@vegaprotocol/deal-ticket';
|
||||
import type { DealTicketMarketFragment } from '@vegaprotocol/deal-ticket';
|
||||
import { InputError } from '@vegaprotocol/ui-toolkit';
|
||||
import { BigNumber } from 'bignumber.js';
|
||||
import { MarketSelector } from '@vegaprotocol/deal-ticket';
|
||||
@ -37,7 +37,7 @@ import { Side, OrderType } from '@vegaprotocol/types';
|
||||
import { DealTicketSlippage } from './deal-ticket-slippage';
|
||||
|
||||
interface DealTicketMarketProps {
|
||||
market: DealTicketQuery_market;
|
||||
market: DealTicketMarketFragment;
|
||||
partyData?: PartyBalanceQuery;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ import {
|
||||
} from '@vegaprotocol/ui-toolkit';
|
||||
import * as React from 'react';
|
||||
import classNames from 'classnames';
|
||||
import type { DealTicketQuery_market } from '@vegaprotocol/deal-ticket';
|
||||
import type { DealTicketMarketFragment } from '@vegaprotocol/deal-ticket';
|
||||
import type { Order } from '@vegaprotocol/orders';
|
||||
import { SIDE_NAMES } from './side-selector';
|
||||
import SimpleMarketExpires from '../simple-market-list/simple-market-expires';
|
||||
@ -33,7 +33,7 @@ export const MARKET_TAGS_QUERY = gql`
|
||||
`;
|
||||
|
||||
interface Props {
|
||||
market: DealTicketQuery_market;
|
||||
market: DealTicketMarketFragment;
|
||||
isDisabled: boolean;
|
||||
transactionStatus?: string;
|
||||
order: Order;
|
||||
|
@ -1,4 +1,4 @@
|
||||
query Deposits {
|
||||
query DepositAssets {
|
||||
assetsConnection {
|
||||
edges {
|
||||
node {
|
||||
|
@ -6,14 +6,14 @@
|
||||
import { AssetStatus } from "@vegaprotocol/types";
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: Deposits
|
||||
// GraphQL query operation: DepositAssets
|
||||
// ====================================================
|
||||
|
||||
export interface Deposits_assetsConnection_edges_node_source_BuiltinAsset {
|
||||
export interface DepositAssets_assetsConnection_edges_node_source_BuiltinAsset {
|
||||
__typename: "BuiltinAsset";
|
||||
}
|
||||
|
||||
export interface Deposits_assetsConnection_edges_node_source_ERC20 {
|
||||
export interface DepositAssets_assetsConnection_edges_node_source_ERC20 {
|
||||
__typename: "ERC20";
|
||||
/**
|
||||
* The address of the ERC20 contract
|
||||
@ -21,9 +21,9 @@ export interface Deposits_assetsConnection_edges_node_source_ERC20 {
|
||||
contractAddress: string;
|
||||
}
|
||||
|
||||
export type Deposits_assetsConnection_edges_node_source = Deposits_assetsConnection_edges_node_source_BuiltinAsset | Deposits_assetsConnection_edges_node_source_ERC20;
|
||||
export type DepositAssets_assetsConnection_edges_node_source = DepositAssets_assetsConnection_edges_node_source_BuiltinAsset | DepositAssets_assetsConnection_edges_node_source_ERC20;
|
||||
|
||||
export interface Deposits_assetsConnection_edges_node {
|
||||
export interface DepositAssets_assetsConnection_edges_node {
|
||||
__typename: "Asset";
|
||||
/**
|
||||
* The ID of the asset
|
||||
@ -48,25 +48,25 @@ export interface Deposits_assetsConnection_edges_node {
|
||||
/**
|
||||
* The origin source of the asset (e.g: an ERC20 asset)
|
||||
*/
|
||||
source: Deposits_assetsConnection_edges_node_source;
|
||||
source: DepositAssets_assetsConnection_edges_node_source;
|
||||
}
|
||||
|
||||
export interface Deposits_assetsConnection_edges {
|
||||
export interface DepositAssets_assetsConnection_edges {
|
||||
__typename: "AssetEdge";
|
||||
node: Deposits_assetsConnection_edges_node;
|
||||
node: DepositAssets_assetsConnection_edges_node;
|
||||
}
|
||||
|
||||
export interface Deposits_assetsConnection {
|
||||
export interface DepositAssets_assetsConnection {
|
||||
__typename: "AssetsConnection";
|
||||
/**
|
||||
* The assets
|
||||
*/
|
||||
edges: (Deposits_assetsConnection_edges | null)[] | null;
|
||||
edges: (DepositAssets_assetsConnection_edges | null)[] | null;
|
||||
}
|
||||
|
||||
export interface Deposits {
|
||||
export interface DepositAssets {
|
||||
/**
|
||||
* The list of all assets in use in the Vega network or the specified asset if ID is provided
|
||||
*/
|
||||
assetsConnection: Deposits_assetsConnection | null;
|
||||
assetsConnection: DepositAssets_assetsConnection | null;
|
||||
}
|
@ -3,14 +3,14 @@ import { Schema as Types } from '@vegaprotocol/types';
|
||||
import { gql } from '@apollo/client';
|
||||
import * as Apollo from '@apollo/client';
|
||||
const defaultOptions = {} as const;
|
||||
export type DepositsQueryVariables = Types.Exact<{ [key: string]: never; }>;
|
||||
export type DepositAssetsQueryVariables = Types.Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
export type DepositsQuery = { __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 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 DepositsDocument = gql`
|
||||
query Deposits {
|
||||
export const DepositAssetsDocument = gql`
|
||||
query DepositAssets {
|
||||
assetsConnection {
|
||||
edges {
|
||||
node {
|
||||
@ -30,28 +30,28 @@ export const DepositsDocument = gql`
|
||||
`;
|
||||
|
||||
/**
|
||||
* __useDepositsQuery__
|
||||
* __useDepositAssetsQuery__
|
||||
*
|
||||
* To run a query within a React component, call `useDepositsQuery` and pass it any options that fit your needs.
|
||||
* When your component renders, `useDepositsQuery` returns an object from Apollo Client that contains loading, error, and data properties
|
||||
* 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 } = useDepositsQuery({
|
||||
* const { data, loading, error } = useDepositAssetsQuery({
|
||||
* variables: {
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useDepositsQuery(baseOptions?: Apollo.QueryHookOptions<DepositsQuery, DepositsQueryVariables>) {
|
||||
export function useDepositAssetsQuery(baseOptions?: Apollo.QueryHookOptions<DepositAssetsQuery, DepositAssetsQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useQuery<DepositsQuery, DepositsQueryVariables>(DepositsDocument, options);
|
||||
return Apollo.useQuery<DepositAssetsQuery, DepositAssetsQueryVariables>(DepositAssetsDocument, options);
|
||||
}
|
||||
export function useDepositsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<DepositsQuery, DepositsQueryVariables>) {
|
||||
export function useDepositAssetsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<DepositAssetsQuery, DepositAssetsQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useLazyQuery<DepositsQuery, DepositsQueryVariables>(DepositsDocument, options);
|
||||
return Apollo.useLazyQuery<DepositAssetsQuery, DepositAssetsQueryVariables>(DepositAssetsDocument, options);
|
||||
}
|
||||
export type DepositsQueryHookResult = ReturnType<typeof useDepositsQuery>;
|
||||
export type DepositsLazyQueryHookResult = ReturnType<typeof useDepositsLazyQuery>;
|
||||
export type DepositsQueryResult = Apollo.QueryResult<DepositsQuery, DepositsQueryVariables>;
|
||||
export type DepositAssetsQueryHookResult = ReturnType<typeof useDepositAssetsQuery>;
|
||||
export type DepositAssetsLazyQueryHookResult = ReturnType<typeof useDepositAssetsLazyQuery>;
|
||||
export type DepositAssetsQueryResult = Apollo.QueryResult<DepositAssetsQuery, DepositAssetsQueryVariables>;
|
@ -5,10 +5,10 @@ import { Networks, useEnvironment } from '@vegaprotocol/environment';
|
||||
import { AsyncRenderer, Splash } from '@vegaprotocol/ui-toolkit';
|
||||
import { useVegaWallet } from '@vegaprotocol/wallet';
|
||||
import { Web3Container } from '@vegaprotocol/web3';
|
||||
import type { Deposits } from './__generated__/Deposits';
|
||||
import type { DepositAssets } from './__generated__/DepositAssets';
|
||||
|
||||
const DEPOSITS_QUERY = gql`
|
||||
query Deposits {
|
||||
query DepositAssets {
|
||||
assetsConnection {
|
||||
edges {
|
||||
node {
|
||||
@ -35,7 +35,7 @@ export const DepositContainer = () => {
|
||||
const { VEGA_ENV } = useEnvironment();
|
||||
const { keypair } = useVegaWallet();
|
||||
|
||||
const { data, loading, error } = useQuery<Deposits>(DEPOSITS_QUERY, {
|
||||
const { data, loading, error } = useQuery<DepositAssets>(DEPOSITS_QUERY, {
|
||||
variables: { partyId: keypair?.pub },
|
||||
skip: !keypair?.pub,
|
||||
});
|
||||
@ -43,7 +43,7 @@ export const DepositContainer = () => {
|
||||
const assets = getEnabledAssets(data);
|
||||
|
||||
return (
|
||||
<AsyncRenderer<Deposits> data={data} loading={loading} error={error}>
|
||||
<AsyncRenderer<DepositAssets> data={data} loading={loading} error={error}>
|
||||
{assets.length ? (
|
||||
<Web3Container>
|
||||
<DepositManager
|
||||
|
@ -68,9 +68,14 @@ const SimpleMarketPercentChangeWrapper = (props: Props) => {
|
||||
};
|
||||
|
||||
const SimpleMarketPercentChange = ({ candles, marketId, setValue }: Props) => {
|
||||
const yesterday = Math.round(new Date().getTime() / 1000) - 24 * 3600;
|
||||
const { data } = useDataProvider({
|
||||
dataProvider: marketCandlesProvider,
|
||||
variables: { marketId, interval: Interval.INTERVAL_I1D },
|
||||
variables: {
|
||||
marketId,
|
||||
interval: Interval.INTERVAL_I1D,
|
||||
since: new Date(yesterday * 1000).toISOString(),
|
||||
},
|
||||
});
|
||||
|
||||
const close = data?.map((m) => m.close);
|
||||
|
@ -3,7 +3,7 @@ import { renderHook } from '@testing-library/react';
|
||||
import { MockedProvider } from '@apollo/client/testing';
|
||||
import useOrderCloseOut from './use-order-closeout';
|
||||
import type { Order } from '@vegaprotocol/orders';
|
||||
import type { DealTicketQuery_market } from '@vegaprotocol/deal-ticket';
|
||||
import type { DealTicketMarketFragment } from '@vegaprotocol/deal-ticket';
|
||||
import type { PartyBalanceQuery } from '../components/deal-ticket/__generated__/PartyBalanceQuery';
|
||||
|
||||
jest.mock('@vegaprotocol/wallet', () => ({
|
||||
@ -49,7 +49,7 @@ describe('useOrderCloseOut Hook', () => {
|
||||
() =>
|
||||
useOrderCloseOut({
|
||||
order: order as Order,
|
||||
market: market as DealTicketQuery_market,
|
||||
market: market as DealTicketMarketFragment,
|
||||
partyData: partyData as PartyBalanceQuery,
|
||||
}),
|
||||
{
|
||||
@ -66,7 +66,7 @@ describe('useOrderCloseOut Hook', () => {
|
||||
() =>
|
||||
useOrderCloseOut({
|
||||
order: { ...order, side: 'SIDE_SELL' } as Order,
|
||||
market: market as DealTicketQuery_market,
|
||||
market: market as DealTicketMarketFragment,
|
||||
partyData: partyData as PartyBalanceQuery,
|
||||
}),
|
||||
{
|
||||
@ -83,7 +83,7 @@ describe('useOrderCloseOut Hook', () => {
|
||||
() =>
|
||||
useOrderCloseOut({
|
||||
order: { ...order, side: 'SIDE_SELL' } as Order,
|
||||
market: market as DealTicketQuery_market,
|
||||
market: market as DealTicketMarketFragment,
|
||||
}),
|
||||
{
|
||||
wrapper: ({ children }: { children: React.ReactNode }) => (
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { BigNumber } from 'bignumber.js';
|
||||
import type { Order } from '@vegaprotocol/orders';
|
||||
import type { DealTicketQuery_market } from '@vegaprotocol/deal-ticket';
|
||||
import type { DealTicketMarketFragment } from '@vegaprotocol/deal-ticket';
|
||||
import type { PartyBalanceQuery } from '../components/deal-ticket/__generated__/PartyBalanceQuery';
|
||||
import { useSettlementAccount } from './use-settlement-account';
|
||||
import { useVegaWallet } from '@vegaprotocol/wallet';
|
||||
@ -47,7 +47,7 @@ const CLOSEOUT_PRICE_QUERY = gql`
|
||||
|
||||
interface Props {
|
||||
order: Order;
|
||||
market: DealTicketQuery_market;
|
||||
market: DealTicketMarketFragment;
|
||||
partyData?: PartyBalanceQuery;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ import { renderHook } from '@testing-library/react';
|
||||
import { useQuery } from '@apollo/client';
|
||||
import { BigNumber } from 'bignumber.js';
|
||||
import type { Order } from '@vegaprotocol/orders';
|
||||
import type { DealTicketQuery_market } from '@vegaprotocol/deal-ticket';
|
||||
import type { DealTicketMarketFragment } from '@vegaprotocol/deal-ticket';
|
||||
import type { PositionMargin } from './use-market-positions';
|
||||
import useOrderMargin from './use-order-margin';
|
||||
|
||||
@ -54,7 +54,7 @@ describe('useOrderMargin Hook', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useOrderMargin({
|
||||
order: order as Order,
|
||||
market: market as DealTicketQuery_market,
|
||||
market: market as DealTicketMarketFragment,
|
||||
partyId,
|
||||
})
|
||||
);
|
||||
@ -72,7 +72,7 @@ describe('useOrderMargin Hook', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useOrderMargin({
|
||||
order: order as Order,
|
||||
market: market as DealTicketQuery_market,
|
||||
market: market as DealTicketMarketFragment,
|
||||
partyId,
|
||||
})
|
||||
);
|
||||
@ -84,7 +84,7 @@ describe('useOrderMargin Hook', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useOrderMargin({
|
||||
order: order as Order,
|
||||
market: market as DealTicketQuery_market,
|
||||
market: market as DealTicketMarketFragment,
|
||||
partyId,
|
||||
})
|
||||
);
|
||||
@ -111,7 +111,7 @@ describe('useOrderMargin Hook', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useOrderMargin({
|
||||
order: order as Order,
|
||||
market: market as DealTicketQuery_market,
|
||||
market: market as DealTicketMarketFragment,
|
||||
partyId,
|
||||
})
|
||||
);
|
||||
|
@ -6,7 +6,7 @@ import type {
|
||||
EstimateOrderVariables,
|
||||
EstimateOrder_estimateOrder_fee,
|
||||
} from './__generated__/estimateOrder';
|
||||
import type { DealTicketQuery_market } from '@vegaprotocol/deal-ticket';
|
||||
import type { DealTicketMarketFragment } from '@vegaprotocol/deal-ticket';
|
||||
import { Side } from '@vegaprotocol/types';
|
||||
import { addDecimal, removeDecimal } from '@vegaprotocol/react-helpers';
|
||||
import useMarketPositions from './use-market-positions';
|
||||
@ -47,7 +47,7 @@ export const ESTIMATE_ORDER_QUERY = gql`
|
||||
|
||||
interface Props {
|
||||
order: Order;
|
||||
market: DealTicketQuery_market;
|
||||
market: DealTicketMarketFragment;
|
||||
partyId: string;
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ describe('vega wallet', { tags: '@smoke' }, () => {
|
||||
cy.getByTestId('manage-vega-wallet').click();
|
||||
cy.getByTestId('keypair-list').should('exist');
|
||||
cy.getByTestId(`key-${key2}`).click();
|
||||
cy.getByTestId('manage-vega-wallet').contains(truncatedKey2);
|
||||
cy.getByTestId('keypair-list').contains(truncatedKey2);
|
||||
cy.getByTestId('disconnect').click();
|
||||
cy.getByTestId('connect-vega-wallet').should('exist');
|
||||
cy.getByTestId('manage-vega-wallet').should('not.exist');
|
||||
|
@ -1,13 +1,12 @@
|
||||
import type {
|
||||
Fills,
|
||||
Fills_party_tradesConnection_edges_node,
|
||||
} from '@vegaprotocol/fills';
|
||||
import type { FillsQuery, FillFieldsFragment } from '@vegaprotocol/fills';
|
||||
import { Side } from '@vegaprotocol/types';
|
||||
import merge from 'lodash/merge';
|
||||
import type { PartialDeep } from 'type-fest';
|
||||
|
||||
export const generateFills = (override?: PartialDeep<Fills>): Fills => {
|
||||
const fills: Fills_party_tradesConnection_edges_node[] = [
|
||||
export const generateFills = (
|
||||
override?: PartialDeep<FillsQuery>
|
||||
): FillsQuery => {
|
||||
const fills: FillFieldsFragment[] = [
|
||||
generateFill({
|
||||
buyer: {
|
||||
id: Cypress.env('VEGA_PUBLIC_KEY'),
|
||||
@ -45,7 +44,7 @@ export const generateFills = (override?: PartialDeep<Fills>): Fills => {
|
||||
}),
|
||||
];
|
||||
|
||||
const defaultResult: Fills = {
|
||||
const defaultResult: FillsQuery = {
|
||||
party: {
|
||||
id: 'buyer-id',
|
||||
tradesConnection: {
|
||||
@ -72,10 +71,8 @@ export const generateFills = (override?: PartialDeep<Fills>): Fills => {
|
||||
return merge(defaultResult, override);
|
||||
};
|
||||
|
||||
export const generateFill = (
|
||||
override?: PartialDeep<Fills_party_tradesConnection_edges_node>
|
||||
) => {
|
||||
const defaultFill: Fills_party_tradesConnection_edges_node = {
|
||||
export const generateFill = (override?: PartialDeep<FillFieldsFragment>) => {
|
||||
const defaultFill: FillFieldsFragment = {
|
||||
__typename: 'Trade',
|
||||
id: '0',
|
||||
createdAt: new Date().toISOString(),
|
||||
|
@ -1,60 +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 AssetsConnectionQueryVariables = Types.Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
export type AssetsConnectionQuery = { __typename?: 'Query', assetsConnection?: { __typename?: 'AssetsConnection', edges?: Array<{ __typename?: 'AssetEdge', node: { __typename?: 'Asset', id: string, name: string, symbol: string, decimals: number, quantum: string, source: { __typename?: 'BuiltinAsset' } | { __typename?: 'ERC20', contractAddress: string, lifetimeLimit: string, withdrawThreshold: string } } } | null> | null } | null };
|
||||
|
||||
|
||||
export const AssetsConnectionDocument = gql`
|
||||
query AssetsConnection {
|
||||
assetsConnection {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
name
|
||||
symbol
|
||||
decimals
|
||||
quantum
|
||||
source {
|
||||
... on ERC20 {
|
||||
contractAddress
|
||||
lifetimeLimit
|
||||
withdrawThreshold
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
/**
|
||||
* __useAssetsConnectionQuery__
|
||||
*
|
||||
* To run a query within a React component, call `useAssetsConnectionQuery` and pass it any options that fit your needs.
|
||||
* When your component renders, `useAssetsConnectionQuery` 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 } = useAssetsConnectionQuery({
|
||||
* variables: {
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useAssetsConnectionQuery(baseOptions?: Apollo.QueryHookOptions<AssetsConnectionQuery, AssetsConnectionQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useQuery<AssetsConnectionQuery, AssetsConnectionQueryVariables>(AssetsConnectionDocument, options);
|
||||
}
|
||||
export function useAssetsConnectionLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<AssetsConnectionQuery, AssetsConnectionQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useLazyQuery<AssetsConnectionQuery, AssetsConnectionQueryVariables>(AssetsConnectionDocument, options);
|
||||
}
|
||||
export type AssetsConnectionQueryHookResult = ReturnType<typeof useAssetsConnectionQuery>;
|
||||
export type AssetsConnectionLazyQueryHookResult = ReturnType<typeof useAssetsConnectionLazyQuery>;
|
||||
export type AssetsConnectionQueryResult = Apollo.QueryResult<AssetsConnectionQuery, AssetsConnectionQueryVariables>;
|
@ -3,19 +3,19 @@ import type { Candle, DataSource } from 'pennant';
|
||||
import { Interval as PennantInterval } from 'pennant';
|
||||
|
||||
import { addDecimal } from '@vegaprotocol/react-helpers';
|
||||
import { ChartDocument } from './__generated___/Chart';
|
||||
import type { ChartQuery, ChartQueryVariables } from './__generated___/Chart';
|
||||
import { ChartDocument } from './__generated__/Chart';
|
||||
import type { ChartQuery, ChartQueryVariables } from './__generated__/Chart';
|
||||
import {
|
||||
CandlesDocument,
|
||||
CandlesEventsDocument,
|
||||
} from './__generated___/Candles';
|
||||
} from './__generated__/Candles';
|
||||
import type {
|
||||
CandlesQuery,
|
||||
CandlesQueryVariables,
|
||||
CandleFieldsFragment,
|
||||
CandlesEventsSubscription,
|
||||
CandlesEventsSubscriptionVariables,
|
||||
} from './__generated___/Candles';
|
||||
} from './__generated__/Candles';
|
||||
import type { Subscription } from 'zen-observable-ts';
|
||||
import { Interval } from '@vegaprotocol/types';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
export * from './__generated___/Candles';
|
||||
export * from './__generated___/Chart';
|
||||
export * from './__generated__/Candles';
|
||||
export * from './__generated__/Chart';
|
||||
export * from './candles-chart';
|
||||
export * from './data-source';
|
||||
|
@ -1,30 +0,0 @@
|
||||
query DealTicketQuery($marketId: ID!) {
|
||||
market(id: $marketId) {
|
||||
id
|
||||
decimalPlaces
|
||||
positionDecimalPlaces
|
||||
state
|
||||
tradingMode
|
||||
tradableInstrument {
|
||||
instrument {
|
||||
id
|
||||
name
|
||||
product {
|
||||
... on Future {
|
||||
quoteName
|
||||
settlementAsset {
|
||||
id
|
||||
symbol
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
depth {
|
||||
lastTrade {
|
||||
price
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
query MarketNames {
|
||||
markets {
|
||||
id
|
||||
state
|
||||
tradableInstrument {
|
||||
instrument {
|
||||
code
|
||||
name
|
||||
metadata {
|
||||
tags
|
||||
}
|
||||
product {
|
||||
... on Future {
|
||||
quoteName
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,73 +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 DealTicketQueryQueryVariables = Types.Exact<{
|
||||
marketId: Types.Scalars['ID'];
|
||||
}>;
|
||||
|
||||
|
||||
export type DealTicketQueryQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string } } } }, depth: { __typename?: 'MarketDepth', lastTrade?: { __typename?: 'Trade', price: string } | null } } | null };
|
||||
|
||||
|
||||
export const DealTicketQueryDocument = gql`
|
||||
query DealTicketQuery($marketId: ID!) {
|
||||
market(id: $marketId) {
|
||||
id
|
||||
decimalPlaces
|
||||
positionDecimalPlaces
|
||||
state
|
||||
tradingMode
|
||||
tradableInstrument {
|
||||
instrument {
|
||||
id
|
||||
name
|
||||
product {
|
||||
... on Future {
|
||||
quoteName
|
||||
settlementAsset {
|
||||
id
|
||||
symbol
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
depth {
|
||||
lastTrade {
|
||||
price
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
/**
|
||||
* __useDealTicketQueryQuery__
|
||||
*
|
||||
* To run a query within a React component, call `useDealTicketQueryQuery` and pass it any options that fit your needs.
|
||||
* When your component renders, `useDealTicketQueryQuery` 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 } = useDealTicketQueryQuery({
|
||||
* variables: {
|
||||
* marketId: // value for 'marketId'
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useDealTicketQueryQuery(baseOptions: Apollo.QueryHookOptions<DealTicketQueryQuery, DealTicketQueryQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useQuery<DealTicketQueryQuery, DealTicketQueryQueryVariables>(DealTicketQueryDocument, options);
|
||||
}
|
||||
export function useDealTicketQueryLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<DealTicketQueryQuery, DealTicketQueryQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useLazyQuery<DealTicketQueryQuery, DealTicketQueryQueryVariables>(DealTicketQueryDocument, options);
|
||||
}
|
||||
export type DealTicketQueryQueryHookResult = ReturnType<typeof useDealTicketQueryQuery>;
|
||||
export type DealTicketQueryLazyQueryHookResult = ReturnType<typeof useDealTicketQueryLazyQuery>;
|
||||
export type DealTicketQueryQueryResult = Apollo.QueryResult<DealTicketQueryQuery, DealTicketQueryQueryVariables>;
|
@ -1,185 +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 MarketInfoQueryQueryVariables = Types.Exact<{
|
||||
marketId: Types.Scalars['ID'];
|
||||
interval: Types.Interval;
|
||||
since: Types.Scalars['String'];
|
||||
}>;
|
||||
|
||||
|
||||
export type MarketInfoQueryQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, accounts?: Array<{ __typename?: 'Account', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', id: string } }> | null, fees: { __typename?: 'Fees', factors: { __typename?: 'FeeFactors', makerFee: string, infrastructureFee: string, liquidityFee: string } }, priceMonitoringSettings: { __typename?: 'PriceMonitoringSettings', parameters?: { __typename?: 'PriceMonitoringParameters', triggers?: Array<{ __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number }> | null } | null }, riskFactors?: { __typename?: 'RiskFactor', market: string, short: string, long: string } | null, data?: { __typename?: 'MarketData', markPrice: string, indicativeVolume: string, bestBidVolume: string, bestOfferVolume: string, bestStaticBidVolume: string, bestStaticOfferVolume: string, openInterest: string, bestBidPrice: string, bestOfferPrice: string, trigger: Types.AuctionTrigger, market: { __typename?: 'Market', id: string }, priceMonitoringBounds?: Array<{ __typename?: 'PriceMonitoringBounds', minValidPrice: string, maxValidPrice: string, referencePrice: string, trigger: { __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number } }> | null } | null, liquidityMonitoringParameters: { __typename?: 'LiquidityMonitoringParameters', triggeringRatio: number, targetStakeParameters: { __typename?: 'TargetStakeParameters', timeWindow: number, scalingFactor: number } }, candles?: Array<{ __typename?: 'Candle', volume: string } | null> | null, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null }, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string }, oracleSpecForSettlementPrice: { __typename?: 'OracleSpec', id: string }, oracleSpecForTradingTermination: { __typename?: 'OracleSpec', id: string }, oracleSpecBinding: { __typename?: 'OracleSpecToFutureBinding', settlementPriceProperty: string, tradingTerminationProperty: string } } }, riskModel: { __typename?: 'LogNormalRiskModel', tau: number, riskAversionParameter: number, params: { __typename?: 'LogNormalModelParams', r: number, sigma: number, mu: number } } | { __typename?: 'SimpleRiskModel', params: { __typename?: 'SimpleRiskModelParams', factorLong: number, factorShort: number } } }, depth: { __typename?: 'MarketDepth', lastTrade?: { __typename?: 'Trade', price: string } | null } } | null };
|
||||
|
||||
|
||||
export const MarketInfoQueryDocument = gql`
|
||||
query MarketInfoQuery($marketId: ID!, $interval: Interval!, $since: String!) {
|
||||
market(id: $marketId) {
|
||||
id
|
||||
decimalPlaces
|
||||
positionDecimalPlaces
|
||||
state
|
||||
accounts {
|
||||
type
|
||||
asset {
|
||||
id
|
||||
}
|
||||
balance
|
||||
}
|
||||
tradingMode
|
||||
accounts {
|
||||
type
|
||||
asset {
|
||||
id
|
||||
}
|
||||
balance
|
||||
}
|
||||
fees {
|
||||
factors {
|
||||
makerFee
|
||||
infrastructureFee
|
||||
liquidityFee
|
||||
}
|
||||
}
|
||||
priceMonitoringSettings {
|
||||
parameters {
|
||||
triggers {
|
||||
horizonSecs
|
||||
probability
|
||||
auctionExtensionSecs
|
||||
}
|
||||
}
|
||||
}
|
||||
riskFactors {
|
||||
market
|
||||
short
|
||||
long
|
||||
}
|
||||
accounts {
|
||||
type
|
||||
asset {
|
||||
id
|
||||
}
|
||||
balance
|
||||
}
|
||||
data {
|
||||
market {
|
||||
id
|
||||
}
|
||||
markPrice
|
||||
indicativeVolume
|
||||
bestBidVolume
|
||||
bestOfferVolume
|
||||
bestStaticBidVolume
|
||||
bestStaticOfferVolume
|
||||
openInterest
|
||||
bestBidPrice
|
||||
bestOfferPrice
|
||||
trigger
|
||||
priceMonitoringBounds {
|
||||
minValidPrice
|
||||
maxValidPrice
|
||||
trigger {
|
||||
horizonSecs
|
||||
probability
|
||||
auctionExtensionSecs
|
||||
}
|
||||
referencePrice
|
||||
}
|
||||
}
|
||||
liquidityMonitoringParameters {
|
||||
triggeringRatio
|
||||
targetStakeParameters {
|
||||
timeWindow
|
||||
scalingFactor
|
||||
}
|
||||
}
|
||||
candles(interval: $interval, since: $since) {
|
||||
volume
|
||||
}
|
||||
tradableInstrument {
|
||||
instrument {
|
||||
id
|
||||
name
|
||||
code
|
||||
metadata {
|
||||
tags
|
||||
}
|
||||
product {
|
||||
... on Future {
|
||||
quoteName
|
||||
settlementAsset {
|
||||
id
|
||||
symbol
|
||||
name
|
||||
}
|
||||
oracleSpecForSettlementPrice {
|
||||
id
|
||||
}
|
||||
oracleSpecForTradingTermination {
|
||||
id
|
||||
}
|
||||
oracleSpecBinding {
|
||||
settlementPriceProperty
|
||||
tradingTerminationProperty
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
riskModel {
|
||||
... on LogNormalRiskModel {
|
||||
tau
|
||||
riskAversionParameter
|
||||
params {
|
||||
r
|
||||
sigma
|
||||
mu
|
||||
}
|
||||
}
|
||||
... on SimpleRiskModel {
|
||||
params {
|
||||
factorLong
|
||||
factorShort
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
depth {
|
||||
lastTrade {
|
||||
price
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
/**
|
||||
* __useMarketInfoQueryQuery__
|
||||
*
|
||||
* To run a query within a React component, call `useMarketInfoQueryQuery` and pass it any options that fit your needs.
|
||||
* When your component renders, `useMarketInfoQueryQuery` 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 } = useMarketInfoQueryQuery({
|
||||
* variables: {
|
||||
* marketId: // value for 'marketId'
|
||||
* interval: // value for 'interval'
|
||||
* since: // value for 'since'
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useMarketInfoQueryQuery(baseOptions: Apollo.QueryHookOptions<MarketInfoQueryQuery, MarketInfoQueryQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useQuery<MarketInfoQueryQuery, MarketInfoQueryQueryVariables>(MarketInfoQueryDocument, options);
|
||||
}
|
||||
export function useMarketInfoQueryLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<MarketInfoQueryQuery, MarketInfoQueryQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useLazyQuery<MarketInfoQueryQuery, MarketInfoQueryQueryVariables>(MarketInfoQueryDocument, options);
|
||||
}
|
||||
export type MarketInfoQueryQueryHookResult = ReturnType<typeof useMarketInfoQueryQuery>;
|
||||
export type MarketInfoQueryLazyQueryHookResult = ReturnType<typeof useMarketInfoQueryLazyQuery>;
|
||||
export type MarketInfoQueryQueryResult = Apollo.QueryResult<MarketInfoQueryQuery, MarketInfoQueryQueryVariables>;
|
@ -1,60 +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 MarketNamesQueryVariables = Types.Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
export type MarketNamesQuery = { __typename?: 'Query', markets?: Array<{ __typename?: 'Market', id: string, state: Types.MarketState, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', code: string, name: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array<string> | null }, product: { __typename?: 'Future', quoteName: string } } } }> | null };
|
||||
|
||||
|
||||
export const MarketNamesDocument = gql`
|
||||
query MarketNames {
|
||||
markets {
|
||||
id
|
||||
state
|
||||
tradableInstrument {
|
||||
instrument {
|
||||
code
|
||||
name
|
||||
metadata {
|
||||
tags
|
||||
}
|
||||
product {
|
||||
... on Future {
|
||||
quoteName
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
/**
|
||||
* __useMarketNamesQuery__
|
||||
*
|
||||
* To run a query within a React component, call `useMarketNamesQuery` and pass it any options that fit your needs.
|
||||
* When your component renders, `useMarketNamesQuery` 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 } = useMarketNamesQuery({
|
||||
* variables: {
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useMarketNamesQuery(baseOptions?: Apollo.QueryHookOptions<MarketNamesQuery, MarketNamesQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useQuery<MarketNamesQuery, MarketNamesQueryVariables>(MarketNamesDocument, options);
|
||||
}
|
||||
export function useMarketNamesLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<MarketNamesQuery, MarketNamesQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useLazyQuery<MarketNamesQuery, MarketNamesQueryVariables>(MarketNamesDocument, options);
|
||||
}
|
||||
export type MarketNamesQueryHookResult = ReturnType<typeof useMarketNamesQuery>;
|
||||
export type MarketNamesLazyQueryHookResult = ReturnType<typeof useMarketNamesLazyQuery>;
|
||||
export type MarketNamesQueryResult = Apollo.QueryResult<MarketNamesQuery, MarketNamesQueryVariables>;
|
@ -0,0 +1,34 @@
|
||||
fragment DealTicketMarket on Market {
|
||||
id
|
||||
decimalPlaces
|
||||
positionDecimalPlaces
|
||||
state
|
||||
tradingMode
|
||||
tradableInstrument {
|
||||
instrument {
|
||||
id
|
||||
name
|
||||
product {
|
||||
... on Future {
|
||||
quoteName
|
||||
settlementAsset {
|
||||
id
|
||||
symbol
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
depth {
|
||||
lastTrade {
|
||||
price
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query DealTicket($marketId: ID!) {
|
||||
market(id: $marketId) {
|
||||
...DealTicketMarket
|
||||
}
|
||||
}
|
79
libs/deal-ticket/src/components/deal-ticket/__generated__/DealTicket.ts
generated
Normal file
79
libs/deal-ticket/src/components/deal-ticket/__generated__/DealTicket.ts
generated
Normal file
@ -0,0 +1,79 @@
|
||||
import { Schema as Types } from '@vegaprotocol/types';
|
||||
|
||||
import { gql } from '@apollo/client';
|
||||
import * as Apollo from '@apollo/client';
|
||||
const defaultOptions = {} as const;
|
||||
export type DealTicketMarketFragment = { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string } } } }, depth: { __typename?: 'MarketDepth', lastTrade?: { __typename?: 'Trade', price: string } | null } };
|
||||
|
||||
export type DealTicketQueryVariables = Types.Exact<{
|
||||
marketId: Types.Scalars['ID'];
|
||||
}>;
|
||||
|
||||
|
||||
export type DealTicketQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string } } } }, depth: { __typename?: 'MarketDepth', lastTrade?: { __typename?: 'Trade', price: string } | null } } | null };
|
||||
|
||||
export const DealTicketMarketFragmentDoc = gql`
|
||||
fragment DealTicketMarket on Market {
|
||||
id
|
||||
decimalPlaces
|
||||
positionDecimalPlaces
|
||||
state
|
||||
tradingMode
|
||||
tradableInstrument {
|
||||
instrument {
|
||||
id
|
||||
name
|
||||
product {
|
||||
... on Future {
|
||||
quoteName
|
||||
settlementAsset {
|
||||
id
|
||||
symbol
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
depth {
|
||||
lastTrade {
|
||||
price
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
export const DealTicketDocument = gql`
|
||||
query DealTicket($marketId: ID!) {
|
||||
market(id: $marketId) {
|
||||
...DealTicketMarket
|
||||
}
|
||||
}
|
||||
${DealTicketMarketFragmentDoc}`;
|
||||
|
||||
/**
|
||||
* __useDealTicketQuery__
|
||||
*
|
||||
* To run a query within a React component, call `useDealTicketQuery` and pass it any options that fit your needs.
|
||||
* When your component renders, `useDealTicketQuery` 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 } = useDealTicketQuery({
|
||||
* variables: {
|
||||
* marketId: // value for 'marketId'
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useDealTicketQuery(baseOptions: Apollo.QueryHookOptions<DealTicketQuery, DealTicketQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useQuery<DealTicketQuery, DealTicketQueryVariables>(DealTicketDocument, options);
|
||||
}
|
||||
export function useDealTicketLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<DealTicketQuery, DealTicketQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useLazyQuery<DealTicketQuery, DealTicketQueryVariables>(DealTicketDocument, options);
|
||||
}
|
||||
export type DealTicketQueryHookResult = ReturnType<typeof useDealTicketQuery>;
|
||||
export type DealTicketLazyQueryHookResult = ReturnType<typeof useDealTicketLazyQuery>;
|
||||
export type DealTicketQueryResult = Apollo.QueryResult<DealTicketQuery, DealTicketQueryVariables>;
|
@ -1,137 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
import { MarketState, MarketTradingMode } from "@vegaprotocol/types";
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: DealTicketQuery
|
||||
// ====================================================
|
||||
|
||||
export interface DealTicketQuery_market_tradableInstrument_instrument_product_settlementAsset {
|
||||
__typename: "Asset";
|
||||
/**
|
||||
* The ID of the asset
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* The symbol of the asset (e.g: GBP)
|
||||
*/
|
||||
symbol: string;
|
||||
/**
|
||||
* The full name of the asset (e.g: Great British Pound)
|
||||
*/
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface DealTicketQuery_market_tradableInstrument_instrument_product {
|
||||
__typename: "Future";
|
||||
/**
|
||||
* String representing the quote (e.g. BTCUSD -> USD is quote)
|
||||
*/
|
||||
quoteName: string;
|
||||
/**
|
||||
* The name of the asset (string)
|
||||
*/
|
||||
settlementAsset: DealTicketQuery_market_tradableInstrument_instrument_product_settlementAsset;
|
||||
}
|
||||
|
||||
export interface DealTicketQuery_market_tradableInstrument_instrument {
|
||||
__typename: "Instrument";
|
||||
/**
|
||||
* Uniquely identify an instrument across all instruments available on Vega (string)
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* Full and fairly descriptive name for the instrument
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* A reference to or instance of a fully specified product, including all required product parameters for that product (Product union)
|
||||
*/
|
||||
product: DealTicketQuery_market_tradableInstrument_instrument_product;
|
||||
}
|
||||
|
||||
export interface DealTicketQuery_market_tradableInstrument {
|
||||
__typename: "TradableInstrument";
|
||||
/**
|
||||
* An instance of, or reference to, a fully specified instrument.
|
||||
*/
|
||||
instrument: DealTicketQuery_market_tradableInstrument_instrument;
|
||||
}
|
||||
|
||||
export interface DealTicketQuery_market_depth_lastTrade {
|
||||
__typename: "Trade";
|
||||
/**
|
||||
* The price of the trade (probably initially the passive order price, other determination algorithms are possible though) (uint64)
|
||||
*/
|
||||
price: string;
|
||||
}
|
||||
|
||||
export interface DealTicketQuery_market_depth {
|
||||
__typename: "MarketDepth";
|
||||
/**
|
||||
* Last trade for the given market (if available)
|
||||
*/
|
||||
lastTrade: DealTicketQuery_market_depth_lastTrade | null;
|
||||
}
|
||||
|
||||
export interface DealTicketQuery_market {
|
||||
__typename: "Market";
|
||||
/**
|
||||
* Market ID
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* 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;
|
||||
/**
|
||||
* positionDecimalPlaces indicates the number of decimal places that an integer must be shifted in order to get a correct size (uint64).
|
||||
* i.e. 0 means there are no fractional orders for the market, and order sizes are always whole sizes.
|
||||
* 2 means sizes given as 10^2 * desired size, e.g. a desired size of 1.23 is represented as 123 in this market.
|
||||
* This sets how big the smallest order / position on the market can be.
|
||||
*/
|
||||
positionDecimalPlaces: number;
|
||||
/**
|
||||
* Current state of the market
|
||||
*/
|
||||
state: MarketState;
|
||||
/**
|
||||
* Current mode of execution of the market
|
||||
*/
|
||||
tradingMode: MarketTradingMode;
|
||||
/**
|
||||
* An instance of, or reference to, a tradable instrument.
|
||||
*/
|
||||
tradableInstrument: DealTicketQuery_market_tradableInstrument;
|
||||
/**
|
||||
* Current depth on the order book for this market
|
||||
*/
|
||||
depth: DealTicketQuery_market_depth;
|
||||
}
|
||||
|
||||
export interface DealTicketQuery {
|
||||
/**
|
||||
* An instrument that is trading on the Vega network
|
||||
*/
|
||||
market: DealTicketQuery_market | null;
|
||||
}
|
||||
|
||||
export interface DealTicketQueryVariables {
|
||||
marketId: string;
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
import { MarketState } from "@vegaprotocol/types";
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: MarketNames
|
||||
// ====================================================
|
||||
|
||||
export interface MarketNames_markets_tradableInstrument_instrument_metadata {
|
||||
__typename: "InstrumentMetadata";
|
||||
/**
|
||||
* An arbitrary list of tags to associated to associate to the Instrument (string list)
|
||||
*/
|
||||
tags: string[] | null;
|
||||
}
|
||||
|
||||
export interface MarketNames_markets_tradableInstrument_instrument_product {
|
||||
__typename: "Future";
|
||||
/**
|
||||
* String representing the quote (e.g. BTCUSD -> USD is quote)
|
||||
*/
|
||||
quoteName: string;
|
||||
}
|
||||
|
||||
export interface MarketNames_markets_tradableInstrument_instrument {
|
||||
__typename: "Instrument";
|
||||
/**
|
||||
* A short non necessarily unique code used to easily describe the instrument (e.g: FX:BTCUSD/DEC18) (string)
|
||||
*/
|
||||
code: string;
|
||||
/**
|
||||
* Full and fairly descriptive name for the instrument
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* Metadata for this instrument
|
||||
*/
|
||||
metadata: MarketNames_markets_tradableInstrument_instrument_metadata;
|
||||
/**
|
||||
* A reference to or instance of a fully specified product, including all required product parameters for that product (Product union)
|
||||
*/
|
||||
product: MarketNames_markets_tradableInstrument_instrument_product;
|
||||
}
|
||||
|
||||
export interface MarketNames_markets_tradableInstrument {
|
||||
__typename: "TradableInstrument";
|
||||
/**
|
||||
* An instance of, or reference to, a fully specified instrument.
|
||||
*/
|
||||
instrument: MarketNames_markets_tradableInstrument_instrument;
|
||||
}
|
||||
|
||||
export interface MarketNames_markets {
|
||||
__typename: "Market";
|
||||
/**
|
||||
* Market ID
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* Current state of the market
|
||||
*/
|
||||
state: MarketState;
|
||||
/**
|
||||
* An instance of, or reference to, a tradable instrument.
|
||||
*/
|
||||
tradableInstrument: MarketNames_markets_tradableInstrument;
|
||||
}
|
||||
|
||||
export interface MarketNames {
|
||||
/**
|
||||
* One or more instruments that are trading on the VEGA network
|
||||
*/
|
||||
markets: MarketNames_markets[] | null;
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
export * from './DealTicketQuery';
|
||||
export * from './MarketNames';
|
@ -2,12 +2,12 @@ import type { UseFormRegister } from 'react-hook-form';
|
||||
import type { Order } from '@vegaprotocol/orders';
|
||||
import { DealTicketMarketAmount } from './deal-ticket-market-amount';
|
||||
import { DealTicketLimitAmount } from './deal-ticket-limit-amount';
|
||||
import type { DealTicketQuery_market } from './__generated__/DealTicketQuery';
|
||||
import { OrderType } from '@vegaprotocol/types';
|
||||
import type { DealTicketMarketFragment } from './__generated__/DealTicket';
|
||||
import { Schema } from '@vegaprotocol/types';
|
||||
|
||||
export interface DealTicketAmountProps {
|
||||
orderType: OrderType;
|
||||
market: DealTicketQuery_market;
|
||||
orderType: Schema.OrderType;
|
||||
market: DealTicketMarketFragment;
|
||||
register: UseFormRegister<Order>;
|
||||
quoteName: string;
|
||||
price?: string;
|
||||
@ -18,9 +18,9 @@ export const DealTicketAmount = ({
|
||||
...props
|
||||
}: DealTicketAmountProps) => {
|
||||
switch (orderType) {
|
||||
case OrderType.TYPE_MARKET:
|
||||
case Schema.OrderType.TYPE_MARKET:
|
||||
return <DealTicketMarketAmount {...props} />;
|
||||
case OrderType.TYPE_LIMIT:
|
||||
case Schema.OrderType.TYPE_LIMIT:
|
||||
return <DealTicketLimitAmount {...props} />;
|
||||
default: {
|
||||
throw new Error('Invalid ticket type');
|
||||
|
@ -1,56 +1,19 @@
|
||||
import { gql, useQuery } from '@apollo/client';
|
||||
import { AsyncRenderer, Splash } from '@vegaprotocol/ui-toolkit';
|
||||
import { DealTicketManager } from './deal-ticket-manager';
|
||||
import { t } from '@vegaprotocol/react-helpers';
|
||||
import type { DealTicketQuery_market, DealTicketQuery } from './';
|
||||
|
||||
const DEAL_TICKET_QUERY = gql`
|
||||
query DealTicketQuery($marketId: ID!) {
|
||||
market(id: $marketId) {
|
||||
id
|
||||
decimalPlaces
|
||||
positionDecimalPlaces
|
||||
state
|
||||
tradingMode
|
||||
tradableInstrument {
|
||||
instrument {
|
||||
id
|
||||
name
|
||||
product {
|
||||
... on Future {
|
||||
quoteName
|
||||
settlementAsset {
|
||||
id
|
||||
symbol
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
depth {
|
||||
lastTrade {
|
||||
price
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
type childrenProps = {
|
||||
market: DealTicketQuery_market;
|
||||
};
|
||||
import { useDealTicketQuery } from './__generated__/DealTicket';
|
||||
import type { DealTicketQuery } from './__generated__/DealTicket';
|
||||
|
||||
export interface DealTicketContainerProps {
|
||||
marketId: string;
|
||||
children?(props: childrenProps): JSX.Element;
|
||||
children?(props: DealTicketQuery): JSX.Element;
|
||||
}
|
||||
|
||||
export const DealTicketContainer = ({
|
||||
marketId,
|
||||
children,
|
||||
}: DealTicketContainerProps) => {
|
||||
const { data, loading, error } = useQuery(DEAL_TICKET_QUERY, {
|
||||
const { data, loading, error } = useDealTicketQuery({
|
||||
variables: { marketId },
|
||||
});
|
||||
|
||||
|
@ -13,8 +13,8 @@ export const DealTicketLimitAmount = ({
|
||||
market,
|
||||
quoteName,
|
||||
}: DealTicketLimitAmountProps) => {
|
||||
const priceStep = toDecimal(market.decimalPlaces);
|
||||
const sizeStep = toDecimal(market.positionDecimalPlaces);
|
||||
const priceStep = toDecimal(market?.decimalPlaces);
|
||||
const sizeStep = toDecimal(market?.positionDecimalPlaces);
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-4">
|
||||
|
@ -1,14 +1,14 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { VegaTxStatus } from '@vegaprotocol/wallet';
|
||||
import { DealTicket } from './deal-ticket';
|
||||
import type { DealTicketQuery_market } from './__generated__/DealTicketQuery';
|
||||
import type { DealTicketMarketFragment } from './__generated__/DealTicket';
|
||||
import { useOrderSubmit, OrderFeedback } from '@vegaprotocol/orders';
|
||||
import { OrderStatus } from '@vegaprotocol/types';
|
||||
import { Schema } from '@vegaprotocol/types';
|
||||
import { Icon, Intent } from '@vegaprotocol/ui-toolkit';
|
||||
import { t } from '@vegaprotocol/react-helpers';
|
||||
|
||||
export interface DealTicketManagerProps {
|
||||
market: DealTicketQuery_market;
|
||||
market: DealTicketMarketFragment;
|
||||
children?: ReactNode | ReactNode[];
|
||||
}
|
||||
|
||||
@ -44,28 +44,28 @@ export const DealTicketManager = ({
|
||||
};
|
||||
|
||||
export const getOrderDialogTitle = (
|
||||
status?: OrderStatus
|
||||
status?: Schema.OrderStatus
|
||||
): string | undefined => {
|
||||
if (!status) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (status) {
|
||||
case OrderStatus.STATUS_ACTIVE:
|
||||
case Schema.OrderStatus.STATUS_ACTIVE:
|
||||
return t('Order submitted');
|
||||
case OrderStatus.STATUS_FILLED:
|
||||
case Schema.OrderStatus.STATUS_FILLED:
|
||||
return t('Order filled');
|
||||
case OrderStatus.STATUS_PARTIALLY_FILLED:
|
||||
case Schema.OrderStatus.STATUS_PARTIALLY_FILLED:
|
||||
return t('Order partially filled');
|
||||
case OrderStatus.STATUS_PARKED:
|
||||
case Schema.OrderStatus.STATUS_PARKED:
|
||||
return t('Order parked');
|
||||
case OrderStatus.STATUS_STOPPED:
|
||||
case Schema.OrderStatus.STATUS_STOPPED:
|
||||
return t('Order stopped');
|
||||
case OrderStatus.STATUS_CANCELLED:
|
||||
case Schema.OrderStatus.STATUS_CANCELLED:
|
||||
return t('Order cancelled');
|
||||
case OrderStatus.STATUS_EXPIRED:
|
||||
case Schema.OrderStatus.STATUS_EXPIRED:
|
||||
return t('Order expired');
|
||||
case OrderStatus.STATUS_REJECTED:
|
||||
case Schema.OrderStatus.STATUS_REJECTED:
|
||||
return t('Order rejected');
|
||||
default:
|
||||
return t('Submission failed');
|
||||
@ -73,22 +73,22 @@ export const getOrderDialogTitle = (
|
||||
};
|
||||
|
||||
export const getOrderDialogIntent = (
|
||||
status?: OrderStatus
|
||||
status?: Schema.OrderStatus
|
||||
): Intent | undefined => {
|
||||
if (!status) {
|
||||
return;
|
||||
}
|
||||
switch (status) {
|
||||
case OrderStatus.STATUS_PARKED:
|
||||
case OrderStatus.STATUS_EXPIRED:
|
||||
case OrderStatus.STATUS_PARTIALLY_FILLED:
|
||||
case Schema.OrderStatus.STATUS_PARKED:
|
||||
case Schema.OrderStatus.STATUS_EXPIRED:
|
||||
case Schema.OrderStatus.STATUS_PARTIALLY_FILLED:
|
||||
return Intent.Warning;
|
||||
case OrderStatus.STATUS_REJECTED:
|
||||
case OrderStatus.STATUS_STOPPED:
|
||||
case OrderStatus.STATUS_CANCELLED:
|
||||
case Schema.OrderStatus.STATUS_REJECTED:
|
||||
case Schema.OrderStatus.STATUS_STOPPED:
|
||||
case Schema.OrderStatus.STATUS_CANCELLED:
|
||||
return Intent.Danger;
|
||||
case OrderStatus.STATUS_FILLED:
|
||||
case OrderStatus.STATUS_ACTIVE:
|
||||
case Schema.OrderStatus.STATUS_FILLED:
|
||||
case Schema.OrderStatus.STATUS_ACTIVE:
|
||||
return Intent.Success;
|
||||
default:
|
||||
return;
|
||||
@ -96,19 +96,19 @@ export const getOrderDialogIntent = (
|
||||
};
|
||||
|
||||
export const getOrderDialogIcon = (
|
||||
status?: OrderStatus
|
||||
status?: Schema.OrderStatus
|
||||
): ReactNode | undefined => {
|
||||
if (!status) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (status) {
|
||||
case OrderStatus.STATUS_PARKED:
|
||||
case OrderStatus.STATUS_EXPIRED:
|
||||
case Schema.OrderStatus.STATUS_PARKED:
|
||||
case Schema.OrderStatus.STATUS_EXPIRED:
|
||||
return <Icon name="warning-sign" />;
|
||||
case OrderStatus.STATUS_REJECTED:
|
||||
case OrderStatus.STATUS_STOPPED:
|
||||
case OrderStatus.STATUS_CANCELLED:
|
||||
case Schema.OrderStatus.STATUS_REJECTED:
|
||||
case Schema.OrderStatus.STATUS_STOPPED:
|
||||
case Schema.OrderStatus.STATUS_CANCELLED:
|
||||
return <Icon name="error" />;
|
||||
default:
|
||||
return;
|
||||
|
@ -14,7 +14,7 @@ export const DealTicketMarketAmount = ({
|
||||
market,
|
||||
quoteName,
|
||||
}: DealTicketMarketAmountProps) => {
|
||||
const sizeStep = toDecimal(market.positionDecimalPlaces);
|
||||
const sizeStep = toDecimal(market?.positionDecimalPlaces);
|
||||
return (
|
||||
<div className="flex items-center gap-4">
|
||||
<div className="flex-1">
|
||||
|
@ -2,27 +2,23 @@ import { VegaWalletContext } from '@vegaprotocol/wallet';
|
||||
import { addDecimal } from '@vegaprotocol/react-helpers';
|
||||
import { fireEvent, render, screen, act } from '@testing-library/react';
|
||||
import { DealTicket } from './deal-ticket';
|
||||
import type { DealTicketQuery_market } from './__generated__/DealTicketQuery';
|
||||
import {
|
||||
MarketState,
|
||||
MarketTradingMode,
|
||||
OrderTimeInForce,
|
||||
OrderType,
|
||||
} from '@vegaprotocol/types';
|
||||
import type { DealTicketMarketFragment } from './__generated__/DealTicket';
|
||||
import { Schema } from '@vegaprotocol/types';
|
||||
import type { Order } from '@vegaprotocol/orders';
|
||||
|
||||
const market: DealTicketQuery_market = {
|
||||
const market: DealTicketMarketFragment = {
|
||||
__typename: 'Market',
|
||||
id: 'market-id',
|
||||
name: 'market-name',
|
||||
decimalPlaces: 2,
|
||||
positionDecimalPlaces: 1,
|
||||
tradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS,
|
||||
state: MarketState.STATE_ACTIVE,
|
||||
tradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS,
|
||||
state: Schema.MarketState.STATE_ACTIVE,
|
||||
tradableInstrument: {
|
||||
__typename: 'TradableInstrument',
|
||||
instrument: {
|
||||
__typename: 'Instrument',
|
||||
id: '1',
|
||||
name: 'Instrument name',
|
||||
product: {
|
||||
__typename: 'Future',
|
||||
quoteName: 'quote-name',
|
||||
@ -66,7 +62,7 @@ describe('DealTicket', () => {
|
||||
|
||||
// Assert defaults are used
|
||||
expect(
|
||||
screen.getByTestId(`order-type-${OrderType.TYPE_MARKET}-selected`)
|
||||
screen.getByTestId(`order-type-${Schema.OrderType.TYPE_MARKET}-selected`)
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.queryByTestId('order-side-SIDE_BUY-selected')
|
||||
@ -78,7 +74,7 @@ describe('DealTicket', () => {
|
||||
String(1 / Math.pow(10, market.positionDecimalPlaces))
|
||||
);
|
||||
expect(screen.getByTestId('order-tif')).toHaveValue(
|
||||
OrderTimeInForce.TIME_IN_FORCE_IOC
|
||||
Schema.OrderTimeInForce.TIME_IN_FORCE_IOC
|
||||
);
|
||||
|
||||
// Assert last price is shown
|
||||
@ -105,10 +101,10 @@ describe('DealTicket', () => {
|
||||
expect(screen.getByTestId('order-size')).toHaveDisplayValue('200');
|
||||
|
||||
fireEvent.change(screen.getByTestId('order-tif'), {
|
||||
target: { value: OrderTimeInForce.TIME_IN_FORCE_IOC },
|
||||
target: { value: Schema.OrderTimeInForce.TIME_IN_FORCE_IOC },
|
||||
});
|
||||
expect(screen.getByTestId('order-tif')).toHaveValue(
|
||||
OrderTimeInForce.TIME_IN_FORCE_IOC
|
||||
Schema.OrderTimeInForce.TIME_IN_FORCE_IOC
|
||||
);
|
||||
|
||||
// Switch to limit order
|
||||
@ -116,7 +112,7 @@ describe('DealTicket', () => {
|
||||
|
||||
// Check all TIF options shown
|
||||
expect(screen.getByTestId('order-tif').children).toHaveLength(
|
||||
Object.keys(OrderTimeInForce).length
|
||||
Object.keys(Schema.OrderTimeInForce).length
|
||||
);
|
||||
});
|
||||
|
||||
@ -133,35 +129,35 @@ describe('DealTicket', () => {
|
||||
// Switch to limit order and check all TIF options shown
|
||||
fireEvent.click(screen.getByTestId('order-type-TYPE_LIMIT'));
|
||||
expect(screen.getByTestId('order-tif').children).toHaveLength(
|
||||
Object.keys(OrderTimeInForce).length
|
||||
Object.keys(Schema.OrderTimeInForce).length
|
||||
);
|
||||
|
||||
// Change to GTC
|
||||
fireEvent.change(screen.getByTestId('order-tif'), {
|
||||
target: { value: OrderTimeInForce.TIME_IN_FORCE_GTC },
|
||||
target: { value: Schema.OrderTimeInForce.TIME_IN_FORCE_GTC },
|
||||
});
|
||||
expect(screen.getByTestId('order-tif')).toHaveValue(
|
||||
OrderTimeInForce.TIME_IN_FORCE_GTC
|
||||
Schema.OrderTimeInForce.TIME_IN_FORCE_GTC
|
||||
);
|
||||
|
||||
// Switch back to market order and TIF should now be IOC
|
||||
fireEvent.click(screen.getByTestId('order-type-TYPE_MARKET'));
|
||||
expect(screen.getByTestId('order-tif')).toHaveValue(
|
||||
OrderTimeInForce.TIME_IN_FORCE_IOC
|
||||
Schema.OrderTimeInForce.TIME_IN_FORCE_IOC
|
||||
);
|
||||
|
||||
// Switch tif to FOK
|
||||
fireEvent.change(screen.getByTestId('order-tif'), {
|
||||
target: { value: OrderTimeInForce.TIME_IN_FORCE_FOK },
|
||||
target: { value: Schema.OrderTimeInForce.TIME_IN_FORCE_FOK },
|
||||
});
|
||||
expect(screen.getByTestId('order-tif')).toHaveValue(
|
||||
OrderTimeInForce.TIME_IN_FORCE_FOK
|
||||
Schema.OrderTimeInForce.TIME_IN_FORCE_FOK
|
||||
);
|
||||
|
||||
// Change back to limit and check we are still on FOK
|
||||
fireEvent.click(screen.getByTestId('order-type-TYPE_LIMIT'));
|
||||
expect(screen.getByTestId('order-tif')).toHaveValue(
|
||||
OrderTimeInForce.TIME_IN_FORCE_GTC
|
||||
Schema.OrderTimeInForce.TIME_IN_FORCE_GTC
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -10,7 +10,7 @@ import { TypeSelector } from './type-selector';
|
||||
import { SideSelector } from './side-selector';
|
||||
import { DealTicketAmount } from './deal-ticket-amount';
|
||||
import { TimeInForceSelector } from './time-in-force-selector';
|
||||
import type { DealTicketQuery_market } from './__generated__/DealTicketQuery';
|
||||
import type { DealTicketMarketFragment } from './__generated__/DealTicket';
|
||||
import { ExpirySelector } from './expiry-selector';
|
||||
import type { Order } from '@vegaprotocol/orders';
|
||||
import { getDefaultOrder, useOrderValidation } from '@vegaprotocol/orders';
|
||||
@ -19,7 +19,7 @@ import { OrderTimeInForce, OrderType } from '@vegaprotocol/types';
|
||||
export type TransactionStatus = 'default' | 'pending';
|
||||
|
||||
export interface DealTicketProps {
|
||||
market: DealTicketQuery_market;
|
||||
market: DealTicketMarketFragment;
|
||||
submit: (order: Order) => void;
|
||||
transactionStatus: TransactionStatus;
|
||||
defaultOrder?: Order;
|
||||
|
@ -1,4 +1,4 @@
|
||||
export * from './__generated__';
|
||||
export * from './__generated__/DealTicket';
|
||||
export * from './deal-ticket-amount';
|
||||
export * from './deal-ticket-container';
|
||||
export * from './deal-ticket-limit-amount';
|
||||
|
@ -8,7 +8,7 @@ import React, {
|
||||
} from 'react';
|
||||
import * as DialogPrimitives from '@radix-ui/react-dialog';
|
||||
import classNames from 'classnames';
|
||||
import type { DealTicketQuery_market } from './';
|
||||
import type { DealTicketMarketFragment } from './';
|
||||
import {
|
||||
ButtonLink,
|
||||
Icon,
|
||||
@ -28,7 +28,7 @@ import type { Market } from '@vegaprotocol/market-list';
|
||||
import { marketsProvider } from '@vegaprotocol/market-list';
|
||||
|
||||
interface Props {
|
||||
market: DealTicketQuery_market;
|
||||
market: DealTicketMarketFragment;
|
||||
setMarket: (marketId: string) => void;
|
||||
ItemRenderer?: React.FC<{
|
||||
market: Market;
|
||||
|
@ -1,17 +1,17 @@
|
||||
import { FormGroup } from '@vegaprotocol/ui-toolkit';
|
||||
import { Toggle } from '@vegaprotocol/ui-toolkit';
|
||||
import { t } from '@vegaprotocol/react-helpers';
|
||||
import { Side } from '@vegaprotocol/types';
|
||||
import { Schema } from '@vegaprotocol/types';
|
||||
|
||||
interface SideSelectorProps {
|
||||
value: Side;
|
||||
onSelect: (side: Side) => void;
|
||||
value: Schema.Side;
|
||||
onSelect: (side: Schema.Side) => void;
|
||||
}
|
||||
|
||||
export const SideSelector = ({ value, onSelect }: SideSelectorProps) => {
|
||||
const toggles = [
|
||||
{ label: t('Long'), value: Side.SIDE_BUY },
|
||||
{ label: t('Short'), value: Side.SIDE_SELL },
|
||||
{ label: t('Long'), value: Schema.Side.SIDE_BUY },
|
||||
{ label: t('Short'), value: Schema.Side.SIDE_SELL },
|
||||
];
|
||||
|
||||
return (
|
||||
@ -21,7 +21,7 @@ export const SideSelector = ({ value, onSelect }: SideSelectorProps) => {
|
||||
name="order-side"
|
||||
toggles={toggles}
|
||||
checkedValue={value}
|
||||
onChange={(e) => onSelect(e.target.value as Side)}
|
||||
onChange={(e) => onSelect(e.target.value as Schema.Side)}
|
||||
/>
|
||||
</FormGroup>
|
||||
);
|
||||
|
@ -1,27 +1,27 @@
|
||||
import { FormGroup, Select } from '@vegaprotocol/ui-toolkit';
|
||||
import { OrderTimeInForce, OrderType } from '@vegaprotocol/types';
|
||||
import { Schema } from '@vegaprotocol/types';
|
||||
import { t } from '@vegaprotocol/react-helpers';
|
||||
|
||||
interface TimeInForceSelectorProps {
|
||||
value: OrderTimeInForce;
|
||||
orderType: OrderType;
|
||||
onSelect: (tif: OrderTimeInForce) => void;
|
||||
value: Schema.OrderTimeInForce;
|
||||
orderType: Schema.OrderType;
|
||||
onSelect: (tif: Schema.OrderTimeInForce) => void;
|
||||
}
|
||||
|
||||
// More detail in https://docs.vega.xyz/docs/mainnet/graphql/enums/order-time-in-force
|
||||
export const timeInForceLabel = (tif: string) => {
|
||||
switch (tif) {
|
||||
case OrderTimeInForce.TIME_IN_FORCE_GTC:
|
||||
case Schema.OrderTimeInForce.TIME_IN_FORCE_GTC:
|
||||
return t(`Good 'til Cancelled (GTC)`);
|
||||
case OrderTimeInForce.TIME_IN_FORCE_IOC:
|
||||
case Schema.OrderTimeInForce.TIME_IN_FORCE_IOC:
|
||||
return t('Immediate or Cancel (IOC)');
|
||||
case OrderTimeInForce.TIME_IN_FORCE_FOK:
|
||||
case Schema.OrderTimeInForce.TIME_IN_FORCE_FOK:
|
||||
return t('Fill or Kill (FOK)');
|
||||
case OrderTimeInForce.TIME_IN_FORCE_GTT:
|
||||
case Schema.OrderTimeInForce.TIME_IN_FORCE_GTT:
|
||||
return t(`Good 'til Time (GTT)`);
|
||||
case OrderTimeInForce.TIME_IN_FORCE_GFN:
|
||||
case Schema.OrderTimeInForce.TIME_IN_FORCE_GFN:
|
||||
return t('Good for Normal (GFN)');
|
||||
case OrderTimeInForce.TIME_IN_FORCE_GFA:
|
||||
case Schema.OrderTimeInForce.TIME_IN_FORCE_GFA:
|
||||
return t('Good for Auction (GFA)');
|
||||
default:
|
||||
return t(tif);
|
||||
@ -34,12 +34,12 @@ export const TimeInForceSelector = ({
|
||||
onSelect,
|
||||
}: TimeInForceSelectorProps) => {
|
||||
const options =
|
||||
orderType === OrderType.TYPE_LIMIT
|
||||
? Object.entries(OrderTimeInForce)
|
||||
: Object.entries(OrderTimeInForce).filter(
|
||||
orderType === Schema.OrderType.TYPE_LIMIT
|
||||
? Object.entries(Schema.OrderTimeInForce)
|
||||
: Object.entries(Schema.OrderTimeInForce).filter(
|
||||
([_, timeInForce]) =>
|
||||
timeInForce === OrderTimeInForce.TIME_IN_FORCE_FOK ||
|
||||
timeInForce === OrderTimeInForce.TIME_IN_FORCE_IOC
|
||||
timeInForce === Schema.OrderTimeInForce.TIME_IN_FORCE_FOK ||
|
||||
timeInForce === Schema.OrderTimeInForce.TIME_IN_FORCE_IOC
|
||||
);
|
||||
|
||||
return (
|
||||
@ -47,7 +47,7 @@ export const TimeInForceSelector = ({
|
||||
<Select
|
||||
id="select-time-in-force"
|
||||
value={value}
|
||||
onChange={(e) => onSelect(e.target.value as OrderTimeInForce)}
|
||||
onChange={(e) => onSelect(e.target.value as Schema.OrderTimeInForce)}
|
||||
className="w-full"
|
||||
data-testid="order-tif"
|
||||
>
|
||||
|
@ -1,16 +1,16 @@
|
||||
import { FormGroup } from '@vegaprotocol/ui-toolkit';
|
||||
import { t } from '@vegaprotocol/react-helpers';
|
||||
import { OrderType } from '@vegaprotocol/types';
|
||||
import { Schema } from '@vegaprotocol/types';
|
||||
import { Toggle } from '@vegaprotocol/ui-toolkit';
|
||||
|
||||
interface TypeSelectorProps {
|
||||
value: OrderType;
|
||||
onSelect: (type: OrderType) => void;
|
||||
value: Schema.OrderType;
|
||||
onSelect: (type: Schema.OrderType) => void;
|
||||
}
|
||||
|
||||
const toggles = [
|
||||
{ label: t('Market'), value: OrderType.TYPE_MARKET },
|
||||
{ label: t('Limit'), value: OrderType.TYPE_LIMIT },
|
||||
{ label: t('Market'), value: Schema.OrderType.TYPE_MARKET },
|
||||
{ label: t('Limit'), value: Schema.OrderType.TYPE_LIMIT },
|
||||
];
|
||||
|
||||
export const TypeSelector = ({ value, onSelect }: TypeSelectorProps) => {
|
||||
@ -21,7 +21,7 @@ export const TypeSelector = ({ value, onSelect }: TypeSelectorProps) => {
|
||||
name="order-type"
|
||||
toggles={toggles}
|
||||
checkedValue={value}
|
||||
onChange={(e) => onSelect(e.target.value as OrderType)}
|
||||
onChange={(e) => onSelect(e.target.value as Schema.OrderType)}
|
||||
/>
|
||||
</FormGroup>
|
||||
);
|
||||
|
@ -1,10 +1,35 @@
|
||||
subscription DepositEvent($partyId: ID!) {
|
||||
busEvents(partyId: $partyId, batchSize: 0, types: [Deposit]) {
|
||||
event {
|
||||
... on Deposit {
|
||||
id
|
||||
txHash
|
||||
status
|
||||
fragment DepositFields on Deposit {
|
||||
id
|
||||
status
|
||||
amount
|
||||
asset {
|
||||
id
|
||||
symbol
|
||||
decimals
|
||||
}
|
||||
createdTimestamp
|
||||
creditedTimestamp
|
||||
txHash
|
||||
}
|
||||
|
||||
query Deposits($partyId: ID!) {
|
||||
party(id: $partyId) {
|
||||
id
|
||||
depositsConnection {
|
||||
edges {
|
||||
node {
|
||||
...DepositFields
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
subscription DepositEvent($partyId: ID!) {
|
||||
busEvents(partyId: $partyId, batchSize: 0, types: [Deposit]) {
|
||||
event {
|
||||
... on Deposit {
|
||||
...DepositFields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
112
libs/deposits/src/lib/__generated__/Deposit.ts
generated
Normal file
112
libs/deposits/src/lib/__generated__/Deposit.ts
generated
Normal file
@ -0,0 +1,112 @@
|
||||
import { Schema as Types } from '@vegaprotocol/types';
|
||||
|
||||
import { gql } from '@apollo/client';
|
||||
import * as Apollo from '@apollo/client';
|
||||
const defaultOptions = {} as const;
|
||||
export type DepositFieldsFragment = { __typename?: 'Deposit', id: string, status: Types.DepositStatus, amount: string, createdTimestamp: string, creditedTimestamp?: string | null, txHash?: string | null, asset: { __typename?: 'Asset', id: string, symbol: string, decimals: number } };
|
||||
|
||||
export type DepositsQueryVariables = Types.Exact<{
|
||||
partyId: Types.Scalars['ID'];
|
||||
}>;
|
||||
|
||||
|
||||
export type DepositsQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, depositsConnection?: { __typename?: 'DepositsConnection', edges?: Array<{ __typename?: 'DepositEdge', node: { __typename?: 'Deposit', id: string, status: Types.DepositStatus, amount: string, createdTimestamp: string, creditedTimestamp?: string | null, txHash?: string | null, asset: { __typename?: 'Asset', id: string, symbol: string, decimals: number } } } | null> | null } | null } | null };
|
||||
|
||||
export type DepositEventSubscriptionVariables = Types.Exact<{
|
||||
partyId: Types.Scalars['ID'];
|
||||
}>;
|
||||
|
||||
|
||||
export type DepositEventSubscription = { __typename?: 'Subscription', busEvents?: Array<{ __typename?: 'BusEvent', event: { __typename?: 'Account' } | { __typename?: 'Asset' } | { __typename?: 'AuctionEvent' } | { __typename?: 'Deposit', id: string, status: Types.DepositStatus, amount: string, createdTimestamp: string, creditedTimestamp?: string | null, txHash?: string | null, asset: { __typename?: 'Asset', id: string, symbol: string, decimals: number } } | { __typename?: 'LiquidityProvision' } | { __typename?: 'LossSocialization' } | { __typename?: 'MarginLevels' } | { __typename?: 'Market' } | { __typename?: 'MarketData' } | { __typename?: 'MarketEvent' } | { __typename?: 'MarketTick' } | { __typename?: 'NodeSignature' } | { __typename?: 'OracleSpec' } | { __typename?: 'Order' } | { __typename?: 'Party' } | { __typename?: 'PositionResolution' } | { __typename?: 'Proposal' } | { __typename?: 'RiskFactor' } | { __typename?: 'SettleDistressed' } | { __typename?: 'SettlePosition' } | { __typename?: 'TimeUpdate' } | { __typename?: 'Trade' } | { __typename?: 'TransferResponses' } | { __typename?: 'Vote' } | { __typename?: 'Withdrawal' } }> | null };
|
||||
|
||||
export const DepositFieldsFragmentDoc = gql`
|
||||
fragment DepositFields on Deposit {
|
||||
id
|
||||
status
|
||||
amount
|
||||
asset {
|
||||
id
|
||||
symbol
|
||||
decimals
|
||||
}
|
||||
createdTimestamp
|
||||
creditedTimestamp
|
||||
txHash
|
||||
}
|
||||
`;
|
||||
export const DepositsDocument = gql`
|
||||
query Deposits($partyId: ID!) {
|
||||
party(id: $partyId) {
|
||||
id
|
||||
depositsConnection {
|
||||
edges {
|
||||
node {
|
||||
...DepositFields
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
${DepositFieldsFragmentDoc}`;
|
||||
|
||||
/**
|
||||
* __useDepositsQuery__
|
||||
*
|
||||
* To run a query within a React component, call `useDepositsQuery` and pass it any options that fit your needs.
|
||||
* When your component renders, `useDepositsQuery` 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 } = useDepositsQuery({
|
||||
* variables: {
|
||||
* partyId: // value for 'partyId'
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useDepositsQuery(baseOptions: Apollo.QueryHookOptions<DepositsQuery, DepositsQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useQuery<DepositsQuery, DepositsQueryVariables>(DepositsDocument, options);
|
||||
}
|
||||
export function useDepositsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<DepositsQuery, DepositsQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useLazyQuery<DepositsQuery, DepositsQueryVariables>(DepositsDocument, options);
|
||||
}
|
||||
export type DepositsQueryHookResult = ReturnType<typeof useDepositsQuery>;
|
||||
export type DepositsLazyQueryHookResult = ReturnType<typeof useDepositsLazyQuery>;
|
||||
export type DepositsQueryResult = Apollo.QueryResult<DepositsQuery, DepositsQueryVariables>;
|
||||
export const DepositEventDocument = gql`
|
||||
subscription DepositEvent($partyId: ID!) {
|
||||
busEvents(partyId: $partyId, batchSize: 0, types: [Deposit]) {
|
||||
event {
|
||||
... on Deposit {
|
||||
...DepositFields
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
${DepositFieldsFragmentDoc}`;
|
||||
|
||||
/**
|
||||
* __useDepositEventSubscription__
|
||||
*
|
||||
* To run a query within a React component, call `useDepositEventSubscription` and pass it any options that fit your needs.
|
||||
* When your component renders, `useDepositEventSubscription` 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 } = useDepositEventSubscription({
|
||||
* variables: {
|
||||
* partyId: // value for 'partyId'
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useDepositEventSubscription(baseOptions: Apollo.SubscriptionHookOptions<DepositEventSubscription, DepositEventSubscriptionVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useSubscription<DepositEventSubscription, DepositEventSubscriptionVariables>(DepositEventDocument, options);
|
||||
}
|
||||
export type DepositEventSubscriptionHookResult = ReturnType<typeof useDepositEventSubscription>;
|
||||
export type DepositEventSubscriptionResult = Apollo.SubscriptionResult<DepositEventSubscription>;
|
51
libs/deposits/src/lib/__generated__/DepositEvent.ts
generated
51
libs/deposits/src/lib/__generated__/DepositEvent.ts
generated
@ -1,51 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
import { DepositStatus } from "@vegaprotocol/types";
|
||||
|
||||
// ====================================================
|
||||
// GraphQL subscription operation: DepositEvent
|
||||
// ====================================================
|
||||
|
||||
export interface DepositEvent_busEvents_event_TimeUpdate {
|
||||
__typename: "TimeUpdate" | "MarketEvent" | "TransferResponses" | "PositionResolution" | "Order" | "Trade" | "Account" | "Party" | "MarginLevels" | "Proposal" | "Vote" | "MarketData" | "NodeSignature" | "LossSocialization" | "SettlePosition" | "Market" | "Asset" | "MarketTick" | "SettleDistressed" | "AuctionEvent" | "RiskFactor" | "Withdrawal" | "OracleSpec" | "LiquidityProvision";
|
||||
}
|
||||
|
||||
export interface DepositEvent_busEvents_event_Deposit {
|
||||
__typename: "Deposit";
|
||||
/**
|
||||
* The Vega internal ID of the deposit
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* Hash of the transaction on the foreign chain
|
||||
*/
|
||||
txHash: string | null;
|
||||
/**
|
||||
* The current status of the deposit
|
||||
*/
|
||||
status: DepositStatus;
|
||||
}
|
||||
|
||||
export type DepositEvent_busEvents_event = DepositEvent_busEvents_event_TimeUpdate | DepositEvent_busEvents_event_Deposit;
|
||||
|
||||
export interface DepositEvent_busEvents {
|
||||
__typename: "BusEvent";
|
||||
/**
|
||||
* the payload - the wrapped event
|
||||
*/
|
||||
event: DepositEvent_busEvents_event;
|
||||
}
|
||||
|
||||
export interface DepositEvent {
|
||||
/**
|
||||
* Subscribe to event data from the event bus
|
||||
*/
|
||||
busEvents: DepositEvent_busEvents[] | null;
|
||||
}
|
||||
|
||||
export interface DepositEventVariables {
|
||||
partyId: string;
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
import { DepositStatus } from "@vegaprotocol/types";
|
||||
|
||||
// ====================================================
|
||||
// GraphQL subscription operation: DepositEventSub
|
||||
// ====================================================
|
||||
|
||||
export interface DepositEventSub_busEvents_event_TimeUpdate {
|
||||
__typename: "TimeUpdate" | "MarketEvent" | "TransferResponses" | "PositionResolution" | "Order" | "Trade" | "Account" | "Party" | "MarginLevels" | "Proposal" | "Vote" | "MarketData" | "NodeSignature" | "LossSocialization" | "SettlePosition" | "Market" | "Asset" | "MarketTick" | "SettleDistressed" | "AuctionEvent" | "RiskFactor" | "Withdrawal" | "OracleSpec" | "LiquidityProvision";
|
||||
}
|
||||
|
||||
export interface DepositEventSub_busEvents_event_Deposit_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 DepositEventSub_busEvents_event_Deposit {
|
||||
__typename: "Deposit";
|
||||
/**
|
||||
* The Vega internal ID of the deposit
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* The current status of the deposit
|
||||
*/
|
||||
status: DepositStatus;
|
||||
/**
|
||||
* The amount to be withdrawn
|
||||
*/
|
||||
amount: string;
|
||||
/**
|
||||
* The asset to be withdrawn
|
||||
*/
|
||||
asset: DepositEventSub_busEvents_event_Deposit_asset;
|
||||
/**
|
||||
* RFC3339Nano time at which the deposit was created
|
||||
*/
|
||||
createdTimestamp: string;
|
||||
/**
|
||||
* RFC3339Nano time at which the deposit was finalised
|
||||
*/
|
||||
creditedTimestamp: string | null;
|
||||
/**
|
||||
* Hash of the transaction on the foreign chain
|
||||
*/
|
||||
txHash: string | null;
|
||||
}
|
||||
|
||||
export type DepositEventSub_busEvents_event = DepositEventSub_busEvents_event_TimeUpdate | DepositEventSub_busEvents_event_Deposit;
|
||||
|
||||
export interface DepositEventSub_busEvents {
|
||||
__typename: "BusEvent";
|
||||
/**
|
||||
* the payload - the wrapped event
|
||||
*/
|
||||
event: DepositEventSub_busEvents_event;
|
||||
}
|
||||
|
||||
export interface DepositEventSub {
|
||||
/**
|
||||
* Subscribe to event data from the event bus
|
||||
*/
|
||||
busEvents: DepositEventSub_busEvents[] | null;
|
||||
}
|
||||
|
||||
export interface DepositEventSubVariables {
|
||||
partyId: string;
|
||||
}
|
58
libs/deposits/src/lib/__generated__/DepositFields.ts
generated
58
libs/deposits/src/lib/__generated__/DepositFields.ts
generated
@ -1,58 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
import { DepositStatus } from "@vegaprotocol/types";
|
||||
|
||||
// ====================================================
|
||||
// GraphQL fragment: DepositFields
|
||||
// ====================================================
|
||||
|
||||
export interface DepositFields_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 DepositFields {
|
||||
__typename: "Deposit";
|
||||
/**
|
||||
* The Vega internal ID of the deposit
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* The current status of the deposit
|
||||
*/
|
||||
status: DepositStatus;
|
||||
/**
|
||||
* The amount to be withdrawn
|
||||
*/
|
||||
amount: string;
|
||||
/**
|
||||
* The asset to be withdrawn
|
||||
*/
|
||||
asset: DepositFields_asset;
|
||||
/**
|
||||
* RFC3339Nano time at which the deposit was created
|
||||
*/
|
||||
createdTimestamp: string;
|
||||
/**
|
||||
* RFC3339Nano time at which the deposit was finalised
|
||||
*/
|
||||
creditedTimestamp: string | null;
|
||||
/**
|
||||
* Hash of the transaction on the foreign chain
|
||||
*/
|
||||
txHash: string | null;
|
||||
}
|
94
libs/deposits/src/lib/__generated__/Deposits.ts
generated
94
libs/deposits/src/lib/__generated__/Deposits.ts
generated
@ -1,94 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
import { DepositStatus } from "@vegaprotocol/types";
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: Deposits
|
||||
// ====================================================
|
||||
|
||||
export interface Deposits_party_depositsConnection_edges_node_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 Deposits_party_depositsConnection_edges_node {
|
||||
__typename: "Deposit";
|
||||
/**
|
||||
* The Vega internal ID of the deposit
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* The current status of the deposit
|
||||
*/
|
||||
status: DepositStatus;
|
||||
/**
|
||||
* The amount to be withdrawn
|
||||
*/
|
||||
amount: string;
|
||||
/**
|
||||
* The asset to be withdrawn
|
||||
*/
|
||||
asset: Deposits_party_depositsConnection_edges_node_asset;
|
||||
/**
|
||||
* RFC3339Nano time at which the deposit was created
|
||||
*/
|
||||
createdTimestamp: string;
|
||||
/**
|
||||
* RFC3339Nano time at which the deposit was finalised
|
||||
*/
|
||||
creditedTimestamp: string | null;
|
||||
/**
|
||||
* Hash of the transaction on the foreign chain
|
||||
*/
|
||||
txHash: string | null;
|
||||
}
|
||||
|
||||
export interface Deposits_party_depositsConnection_edges {
|
||||
__typename: "DepositEdge";
|
||||
node: Deposits_party_depositsConnection_edges_node;
|
||||
}
|
||||
|
||||
export interface Deposits_party_depositsConnection {
|
||||
__typename: "DepositsConnection";
|
||||
/**
|
||||
* The deposits
|
||||
*/
|
||||
edges: (Deposits_party_depositsConnection_edges | null)[] | null;
|
||||
}
|
||||
|
||||
export interface Deposits_party {
|
||||
__typename: "Party";
|
||||
/**
|
||||
* Party identifier
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* The list of all deposits for a party by the party
|
||||
*/
|
||||
depositsConnection: Deposits_party_depositsConnection;
|
||||
}
|
||||
|
||||
export interface Deposits {
|
||||
/**
|
||||
* An entity that is trading on the Vega network
|
||||
*/
|
||||
party: Deposits_party | null;
|
||||
}
|
||||
|
||||
export interface DepositsVariables {
|
||||
partyId: string;
|
||||
}
|
94
libs/deposits/src/lib/__generated__/DepositsQuery.ts
generated
94
libs/deposits/src/lib/__generated__/DepositsQuery.ts
generated
@ -1,94 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
import { DepositStatus } from "@vegaprotocol/types";
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: DepositsQuery
|
||||
// ====================================================
|
||||
|
||||
export interface DepositsQuery_party_depositsConnection_edges_node_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 DepositsQuery_party_depositsConnection_edges_node {
|
||||
__typename: "Deposit";
|
||||
/**
|
||||
* The Vega internal ID of the deposit
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* The current status of the deposit
|
||||
*/
|
||||
status: DepositStatus;
|
||||
/**
|
||||
* The amount to be withdrawn
|
||||
*/
|
||||
amount: string;
|
||||
/**
|
||||
* The asset to be withdrawn
|
||||
*/
|
||||
asset: DepositsQuery_party_depositsConnection_edges_node_asset;
|
||||
/**
|
||||
* RFC3339Nano time at which the deposit was created
|
||||
*/
|
||||
createdTimestamp: string;
|
||||
/**
|
||||
* RFC3339Nano time at which the deposit was finalised
|
||||
*/
|
||||
creditedTimestamp: string | null;
|
||||
/**
|
||||
* Hash of the transaction on the foreign chain
|
||||
*/
|
||||
txHash: string | null;
|
||||
}
|
||||
|
||||
export interface DepositsQuery_party_depositsConnection_edges {
|
||||
__typename: "DepositEdge";
|
||||
node: DepositsQuery_party_depositsConnection_edges_node;
|
||||
}
|
||||
|
||||
export interface DepositsQuery_party_depositsConnection {
|
||||
__typename: "DepositsConnection";
|
||||
/**
|
||||
* The deposits
|
||||
*/
|
||||
edges: (DepositsQuery_party_depositsConnection_edges | null)[] | null;
|
||||
}
|
||||
|
||||
export interface DepositsQuery_party {
|
||||
__typename: "Party";
|
||||
/**
|
||||
* Party identifier
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* The list of all deposits for a party by the party
|
||||
*/
|
||||
depositsConnection: DepositsQuery_party_depositsConnection | null;
|
||||
}
|
||||
|
||||
export interface DepositsQuery {
|
||||
/**
|
||||
* An entity that is trading on the Vega network
|
||||
*/
|
||||
party: DepositsQuery_party | null;
|
||||
}
|
||||
|
||||
export interface DepositsQueryVariables {
|
||||
partyId: string;
|
||||
}
|
@ -1,49 +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 DepositEventSubscriptionVariables = Types.Exact<{
|
||||
partyId: Types.Scalars['ID'];
|
||||
}>;
|
||||
|
||||
|
||||
export type DepositEventSubscription = { __typename?: 'Subscription', busEvents?: Array<{ __typename?: 'BusEvent', event: { __typename?: 'Account' } | { __typename?: 'Asset' } | { __typename?: 'AuctionEvent' } | { __typename?: 'Deposit', id: string, txHash?: string | null, status: Types.DepositStatus } | { __typename?: 'LiquidityProvision' } | { __typename?: 'LossSocialization' } | { __typename?: 'MarginLevels' } | { __typename?: 'Market' } | { __typename?: 'MarketData' } | { __typename?: 'MarketEvent' } | { __typename?: 'MarketTick' } | { __typename?: 'NodeSignature' } | { __typename?: 'OracleSpec' } | { __typename?: 'Order' } | { __typename?: 'Party' } | { __typename?: 'PositionResolution' } | { __typename?: 'Proposal' } | { __typename?: 'RiskFactor' } | { __typename?: 'SettleDistressed' } | { __typename?: 'SettlePosition' } | { __typename?: 'TimeUpdate' } | { __typename?: 'Trade' } | { __typename?: 'TransferResponses' } | { __typename?: 'Vote' } | { __typename?: 'Withdrawal' } }> | null };
|
||||
|
||||
|
||||
export const DepositEventDocument = gql`
|
||||
subscription DepositEvent($partyId: ID!) {
|
||||
busEvents(partyId: $partyId, batchSize: 0, types: [Deposit]) {
|
||||
event {
|
||||
... on Deposit {
|
||||
id
|
||||
txHash
|
||||
status
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
/**
|
||||
* __useDepositEventSubscription__
|
||||
*
|
||||
* To run a query within a React component, call `useDepositEventSubscription` and pass it any options that fit your needs.
|
||||
* When your component renders, `useDepositEventSubscription` 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 } = useDepositEventSubscription({
|
||||
* variables: {
|
||||
* partyId: // value for 'partyId'
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useDepositEventSubscription(baseOptions: Apollo.SubscriptionHookOptions<DepositEventSubscription, DepositEventSubscriptionVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useSubscription<DepositEventSubscription, DepositEventSubscriptionVariables>(DepositEventDocument, options);
|
||||
}
|
||||
export type DepositEventSubscriptionHookResult = ReturnType<typeof useDepositEventSubscription>;
|
||||
export type DepositEventSubscriptionResult = Apollo.SubscriptionResult<DepositEventSubscription>;
|
@ -10,12 +10,12 @@ import type {
|
||||
VegaValueFormatterParams,
|
||||
} from '@vegaprotocol/ui-toolkit';
|
||||
import { AgGridDynamic as AgGrid, Link } from '@vegaprotocol/ui-toolkit';
|
||||
import type { DepositFields } from './__generated__/DepositFields';
|
||||
import type { DepositFieldsFragment } from './__generated__/Deposit';
|
||||
import { useEnvironment } from '@vegaprotocol/environment';
|
||||
import { DepositStatusMapping } from '@vegaprotocol/types';
|
||||
|
||||
export interface DepositsTableProps {
|
||||
deposits: DepositFields[];
|
||||
deposits: DepositFieldsFragment[];
|
||||
}
|
||||
|
||||
export const DepositsTable = ({ deposits }: DepositsTableProps) => {
|
||||
@ -35,7 +35,7 @@ export const DepositsTable = ({ deposits }: DepositsTableProps) => {
|
||||
valueFormatter={({
|
||||
value,
|
||||
data,
|
||||
}: VegaValueFormatterParams<DepositFields, 'amount'>) => {
|
||||
}: VegaValueFormatterParams<DepositFieldsFragment, 'amount'>) => {
|
||||
return addDecimalsFormatNumber(value, data.asset.decimals);
|
||||
}}
|
||||
/>
|
||||
@ -44,7 +44,10 @@ export const DepositsTable = ({ deposits }: DepositsTableProps) => {
|
||||
field="createdTimestamp"
|
||||
valueFormatter={({
|
||||
value,
|
||||
}: VegaValueFormatterParams<DepositFields, 'createdTimestamp'>) => {
|
||||
}: VegaValueFormatterParams<
|
||||
DepositFieldsFragment,
|
||||
'createdTimestamp'
|
||||
>) => {
|
||||
return getDateTimeFormat().format(new Date(value));
|
||||
}}
|
||||
/>
|
||||
@ -53,7 +56,7 @@ export const DepositsTable = ({ deposits }: DepositsTableProps) => {
|
||||
field="status"
|
||||
valueFormatter={({
|
||||
value,
|
||||
}: VegaValueFormatterParams<DepositFields, 'status'>) => {
|
||||
}: VegaValueFormatterParams<DepositFieldsFragment, 'status'>) => {
|
||||
return DepositStatusMapping[value];
|
||||
}}
|
||||
/>
|
||||
@ -62,7 +65,7 @@ export const DepositsTable = ({ deposits }: DepositsTableProps) => {
|
||||
field="txHash"
|
||||
cellRenderer={({
|
||||
value,
|
||||
}: VegaICellRendererParams<DepositFields, 'txHash'>) => {
|
||||
}: VegaICellRendererParams<DepositFieldsFragment, 'txHash'>) => {
|
||||
if (!value) return '-';
|
||||
return (
|
||||
<Link
|
||||
|
@ -1,80 +1,35 @@
|
||||
import uniqBy from 'lodash/uniqBy';
|
||||
import compact from 'lodash/compact';
|
||||
import orderBy from 'lodash/orderBy';
|
||||
import { gql, useQuery } from '@apollo/client';
|
||||
import { getNodes, getEvents } from '@vegaprotocol/react-helpers';
|
||||
import type { UpdateQueryFn } from '@apollo/client/core/watchQueryOptions';
|
||||
import { useVegaWallet } from '@vegaprotocol/wallet';
|
||||
import { useEffect, useMemo } from 'react';
|
||||
import { Schema } from '@vegaprotocol/types';
|
||||
import {
|
||||
useDepositsQuery,
|
||||
DepositEventDocument,
|
||||
} from './__generated__/Deposit';
|
||||
import type {
|
||||
DepositEventSub,
|
||||
DepositEventSubVariables,
|
||||
DepositEventSub_busEvents_event,
|
||||
DepositEventSub_busEvents_event_Deposit,
|
||||
} from './__generated__/DepositEventSub';
|
||||
import type { Deposits, DepositsVariables } from './__generated__/Deposits';
|
||||
|
||||
const DEPOSIT_FRAGMENT = gql`
|
||||
fragment DepositFields on Deposit {
|
||||
id
|
||||
status
|
||||
amount
|
||||
asset {
|
||||
id
|
||||
symbol
|
||||
decimals
|
||||
}
|
||||
createdTimestamp
|
||||
creditedTimestamp
|
||||
txHash
|
||||
}
|
||||
`;
|
||||
|
||||
const DEPOSITS_QUERY = gql`
|
||||
${DEPOSIT_FRAGMENT}
|
||||
query DepositsQuery($partyId: ID!) {
|
||||
party(id: $partyId) {
|
||||
id
|
||||
depositsConnection {
|
||||
edges {
|
||||
node {
|
||||
...DepositFields
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const DEPOSITS_BUS_EVENT_SUB = gql`
|
||||
${DEPOSIT_FRAGMENT}
|
||||
subscription DepositEventSub($partyId: ID!) {
|
||||
busEvents(partyId: $partyId, batchSize: 0, types: [Deposit]) {
|
||||
event {
|
||||
... on Deposit {
|
||||
...DepositFields
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
DepositFieldsFragment,
|
||||
DepositsQuery,
|
||||
DepositEventSubscription,
|
||||
DepositEventSubscriptionVariables,
|
||||
} from './__generated__/Deposit';
|
||||
|
||||
export const useDeposits = () => {
|
||||
const { keypair } = useVegaWallet();
|
||||
const { data, loading, error, subscribeToMore } = useQuery<
|
||||
Deposits,
|
||||
DepositsVariables
|
||||
>(DEPOSITS_QUERY, {
|
||||
const { data, loading, error, subscribeToMore } = useDepositsQuery({
|
||||
variables: { partyId: keypair?.pub || '' },
|
||||
skip: !keypair?.pub,
|
||||
});
|
||||
|
||||
const deposits = useMemo(() => {
|
||||
if (!data?.party?.depositsConnection.edges?.length) {
|
||||
if (!data?.party?.depositsConnection?.edges?.length) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return orderBy(
|
||||
compact(data.party?.depositsConnection.edges?.map((d) => d?.node)),
|
||||
getNodes<DepositFieldsFragment>(data.party?.depositsConnection),
|
||||
['createdTimestamp'],
|
||||
['desc']
|
||||
);
|
||||
@ -83,8 +38,11 @@ export const useDeposits = () => {
|
||||
useEffect(() => {
|
||||
if (!keypair?.pub) return;
|
||||
|
||||
const unsub = subscribeToMore<DepositEventSub, DepositEventSubVariables>({
|
||||
document: DEPOSITS_BUS_EVENT_SUB,
|
||||
const unsub = subscribeToMore<
|
||||
DepositEventSubscription,
|
||||
DepositEventSubscriptionVariables
|
||||
>({
|
||||
document: DepositEventDocument,
|
||||
variables: { partyId: keypair?.pub },
|
||||
updateQuery,
|
||||
});
|
||||
@ -98,20 +56,19 @@ export const useDeposits = () => {
|
||||
};
|
||||
|
||||
const updateQuery: UpdateQueryFn<
|
||||
Deposits,
|
||||
DepositEventSubVariables,
|
||||
DepositEventSub
|
||||
DepositsQuery,
|
||||
DepositEventSubscriptionVariables,
|
||||
DepositEventSubscription
|
||||
> = (prev, { subscriptionData, variables }) => {
|
||||
console.log(subscriptionData);
|
||||
if (!subscriptionData.data.busEvents?.length || !variables?.partyId) {
|
||||
return prev;
|
||||
}
|
||||
|
||||
const curr =
|
||||
compact(prev.party?.depositsConnection.edges?.map((e) => e?.node)) || [];
|
||||
const incoming = subscriptionData.data.busEvents
|
||||
.map((e) => e.event)
|
||||
.filter(isDepositEvent);
|
||||
const curr = getNodes<DepositFieldsFragment>(prev.party?.depositsConnection);
|
||||
const incoming = getEvents<DepositFieldsFragment>(
|
||||
Schema.BusEventType.Deposit,
|
||||
subscriptionData.data.busEvents
|
||||
);
|
||||
|
||||
const deposits = uniqBy([...incoming, ...curr], 'id');
|
||||
|
||||
@ -141,13 +98,3 @@ const updateQuery: UpdateQueryFn<
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
const isDepositEvent = (
|
||||
event: DepositEventSub_busEvents_event
|
||||
): event is DepositEventSub_busEvents_event_Deposit => {
|
||||
if (event.__typename === 'Deposit') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
@ -1,10 +1,11 @@
|
||||
import { gql, useSubscription } from '@apollo/client';
|
||||
import { useSubscription } from '@apollo/client';
|
||||
import * as Sentry from '@sentry/react';
|
||||
import type {
|
||||
DepositEvent,
|
||||
DepositEventVariables,
|
||||
} from './__generated__/DepositEvent';
|
||||
import { DepositStatus } from '@vegaprotocol/types';
|
||||
DepositEventSubscription,
|
||||
DepositEventSubscriptionVariables,
|
||||
} from './__generated__/Deposit';
|
||||
import { DepositEventDocument } from './__generated__/Deposit';
|
||||
import { Schema } from '@vegaprotocol/types';
|
||||
import { useState } from 'react';
|
||||
import {
|
||||
isAssetTypeERC20,
|
||||
@ -22,20 +23,6 @@ import { prepend0x } from '@vegaprotocol/smart-contracts';
|
||||
import { useDepositStore } from './deposit-store';
|
||||
import { useGetBalanceOfERC20Token } from './use-get-balance-of-erc20-token';
|
||||
|
||||
const DEPOSIT_EVENT_SUB = gql`
|
||||
subscription DepositEvent($partyId: ID!) {
|
||||
busEvents(partyId: $partyId, batchSize: 0, types: [Deposit]) {
|
||||
event {
|
||||
... on Deposit {
|
||||
id
|
||||
txHash
|
||||
status
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const useSubmitDeposit = () => {
|
||||
const { asset, update } = useDepositStore();
|
||||
const { config } = useEthereumConfig();
|
||||
@ -58,37 +45,40 @@ export const useSubmitDeposit = () => {
|
||||
true
|
||||
);
|
||||
|
||||
useSubscription<DepositEvent, DepositEventVariables>(DEPOSIT_EVENT_SUB, {
|
||||
variables: { partyId: partyId ? remove0x(partyId) : '' },
|
||||
skip: !partyId,
|
||||
onSubscriptionData: ({ subscriptionData }) => {
|
||||
if (!subscriptionData.data?.busEvents?.length) {
|
||||
return;
|
||||
}
|
||||
useSubscription<DepositEventSubscription, DepositEventSubscriptionVariables>(
|
||||
DepositEventDocument,
|
||||
{
|
||||
variables: { partyId: partyId ? remove0x(partyId) : '' },
|
||||
skip: !partyId,
|
||||
onSubscriptionData: ({ subscriptionData }) => {
|
||||
if (!subscriptionData.data?.busEvents?.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
const matchingDeposit = subscriptionData.data.busEvents.find((e) => {
|
||||
if (e.event.__typename !== 'Deposit') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
e.event.txHash === transaction.transaction.txHash &&
|
||||
// Note there is a bug in data node where the subscription is not emitted when the status
|
||||
// changes from 'Open' to 'Finalized' as a result the deposit UI will hang in a pending state right now
|
||||
// https://github.com/vegaprotocol/data-node/issues/460
|
||||
e.event.status === Schema.DepositStatus.STATUS_FINALIZED
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const matchingDeposit = subscriptionData.data.busEvents.find((e) => {
|
||||
if (e.event.__typename !== 'Deposit') {
|
||||
return false;
|
||||
});
|
||||
|
||||
if (matchingDeposit && matchingDeposit.event.__typename === 'Deposit') {
|
||||
transaction.setConfirmed();
|
||||
}
|
||||
|
||||
if (
|
||||
e.event.txHash === transaction.transaction.txHash &&
|
||||
// Note there is a bug in data node where the subscription is not emitted when the status
|
||||
// changes from 'Open' to 'Finalized' as a result the deposit UI will hang in a pending state right now
|
||||
// https://github.com/vegaprotocol/data-node/issues/460
|
||||
e.event.status === DepositStatus.STATUS_FINALIZED
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
if (matchingDeposit && matchingDeposit.event.__typename === 'Deposit') {
|
||||
transaction.setConfirmed();
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
...transaction,
|
||||
|
@ -1,7 +1,5 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useQuery } from '@apollo/client';
|
||||
import type { Statistics } from '../../utils/__generated__/Statistics';
|
||||
import { STATS_QUERY } from '../../utils/request-node';
|
||||
import { useStatisticsQuery } from '../../utils/__generated__/Node';
|
||||
|
||||
type NodeBlockHeightProps = {
|
||||
value?: number;
|
||||
@ -11,12 +9,9 @@ type NodeBlockHeightProps = {
|
||||
const POLL_INTERVAL = 3000;
|
||||
|
||||
export const NodeBlockHeight = ({ value, setValue }: NodeBlockHeightProps) => {
|
||||
const { data, startPolling, stopPolling } = useQuery<Statistics>(
|
||||
STATS_QUERY,
|
||||
{
|
||||
pollInterval: POLL_INTERVAL,
|
||||
}
|
||||
);
|
||||
const { data, startPolling, stopPolling } = useStatisticsQuery({
|
||||
pollInterval: POLL_INTERVAL,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const handleStartPoll = () => startPolling(POLL_INTERVAL);
|
||||
|
@ -4,7 +4,7 @@ import { render, screen, fireEvent } from '@testing-library/react';
|
||||
import { useEnvironment } from '../../hooks/use-environment';
|
||||
import { useNodes } from '../../hooks/use-nodes';
|
||||
import createMockClient from '../../hooks/mocks/apollo-client';
|
||||
import { STATS_QUERY } from '../../utils/request-node';
|
||||
import { StatisticsDocument } from '../../utils/__generated__/Node';
|
||||
import { NodeSwitcher } from './node-switcher';
|
||||
import { getErrorByType } from '../../utils/validate-node';
|
||||
import type { Configuration, NodeData } from '../../types';
|
||||
@ -66,7 +66,7 @@ const mockNodesImplementation =
|
||||
|
||||
const statsQueryMock = {
|
||||
request: {
|
||||
query: STATS_QUERY,
|
||||
query: StatisticsDocument,
|
||||
},
|
||||
result: {
|
||||
data: {
|
||||
|
@ -1,9 +1,11 @@
|
||||
import {
|
||||
STATS_QUERY,
|
||||
TIME_UPDATE_SUBSCRIPTION,
|
||||
} from '../../utils/request-node';
|
||||
import type { Statistics } from '../../utils/__generated__/Statistics';
|
||||
import type { BlockTime } from '../../utils/__generated__/BlockTime';
|
||||
StatisticsDocument,
|
||||
BlockTimeDocument,
|
||||
} from '../../utils/__generated__/Node';
|
||||
import type {
|
||||
StatisticsQuery,
|
||||
BlockTimeSubscription,
|
||||
} from '../../utils/__generated__/Node';
|
||||
import { Networks } from '../../types';
|
||||
import type { RequestHandlerResponse } from 'mock-apollo-client';
|
||||
import { createMockClient } from 'mock-apollo-client';
|
||||
@ -19,7 +21,7 @@ type MockClientProps = {
|
||||
busEvents?: MockRequestConfig;
|
||||
};
|
||||
|
||||
export const getMockBusEventsResult = (): BlockTime => ({
|
||||
export const getMockBusEventsResult = (): BlockTimeSubscription => ({
|
||||
busEvents: [
|
||||
{
|
||||
__typename: 'BusEvent',
|
||||
@ -30,7 +32,7 @@ export const getMockBusEventsResult = (): BlockTime => ({
|
||||
|
||||
export const getMockStatisticsResult = (
|
||||
env: Networks = Networks.TESTNET
|
||||
): Statistics => ({
|
||||
): StatisticsQuery => ({
|
||||
statistics: {
|
||||
__typename: 'Statistics',
|
||||
chainId: `${env.toLowerCase()}-0123`,
|
||||
@ -38,7 +40,7 @@ export const getMockStatisticsResult = (
|
||||
},
|
||||
});
|
||||
|
||||
export const getMockQueryResult = (env: Networks): Statistics => ({
|
||||
export const getMockQueryResult = (env: Networks): StatisticsQuery => ({
|
||||
statistics: {
|
||||
__typename: 'Statistics',
|
||||
chainId: `${env.toLowerCase()}-0123`,
|
||||
@ -70,11 +72,11 @@ export default function ({
|
||||
const mockClient = createMockClient();
|
||||
|
||||
mockClient.setRequestHandler(
|
||||
STATS_QUERY,
|
||||
StatisticsDocument,
|
||||
getHandler(statistics, getMockStatisticsResult(network))
|
||||
);
|
||||
mockClient.setRequestHandler(
|
||||
TIME_UPDATE_SUBSCRIPTION,
|
||||
BlockTimeDocument,
|
||||
getHandler(busEvents, getMockBusEventsResult())
|
||||
);
|
||||
|
||||
|
12
libs/environment/src/utils/Node.graphql
Normal file
12
libs/environment/src/utils/Node.graphql
Normal file
@ -0,0 +1,12 @@
|
||||
query Statistics {
|
||||
statistics {
|
||||
chainId
|
||||
blockHeight
|
||||
}
|
||||
}
|
||||
|
||||
subscription BlockTime {
|
||||
busEvents(types: TimeUpdate, batchSize: 1) {
|
||||
id
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL subscription operation: BlockTime
|
||||
// ====================================================
|
||||
|
||||
export interface BlockTime_busEvents {
|
||||
__typename: "BusEvent";
|
||||
/**
|
||||
* the ID for this event
|
||||
*/
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface BlockTime {
|
||||
/**
|
||||
* Subscribe to event data from the event bus
|
||||
*/
|
||||
busEvents: BlockTime_busEvents[] | null;
|
||||
}
|
80
libs/environment/src/utils/__generated__/Node.ts
generated
Normal file
80
libs/environment/src/utils/__generated__/Node.ts
generated
Normal file
@ -0,0 +1,80 @@
|
||||
import { Schema as Types } from '@vegaprotocol/types';
|
||||
|
||||
import { gql } from '@apollo/client';
|
||||
import * as Apollo from '@apollo/client';
|
||||
const defaultOptions = {} as const;
|
||||
export type StatisticsQueryVariables = Types.Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
export type StatisticsQuery = { __typename?: 'Query', statistics: { __typename?: 'Statistics', chainId: string, blockHeight: string } };
|
||||
|
||||
export type BlockTimeSubscriptionVariables = Types.Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
export type BlockTimeSubscription = { __typename?: 'Subscription', busEvents?: Array<{ __typename?: 'BusEvent', id: string }> | null };
|
||||
|
||||
|
||||
export const StatisticsDocument = gql`
|
||||
query Statistics {
|
||||
statistics {
|
||||
chainId
|
||||
blockHeight
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
/**
|
||||
* __useStatisticsQuery__
|
||||
*
|
||||
* To run a query within a React component, call `useStatisticsQuery` and pass it any options that fit your needs.
|
||||
* When your component renders, `useStatisticsQuery` 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 } = useStatisticsQuery({
|
||||
* variables: {
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useStatisticsQuery(baseOptions?: Apollo.QueryHookOptions<StatisticsQuery, StatisticsQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useQuery<StatisticsQuery, StatisticsQueryVariables>(StatisticsDocument, options);
|
||||
}
|
||||
export function useStatisticsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<StatisticsQuery, StatisticsQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useLazyQuery<StatisticsQuery, StatisticsQueryVariables>(StatisticsDocument, options);
|
||||
}
|
||||
export type StatisticsQueryHookResult = ReturnType<typeof useStatisticsQuery>;
|
||||
export type StatisticsLazyQueryHookResult = ReturnType<typeof useStatisticsLazyQuery>;
|
||||
export type StatisticsQueryResult = Apollo.QueryResult<StatisticsQuery, StatisticsQueryVariables>;
|
||||
export const BlockTimeDocument = gql`
|
||||
subscription BlockTime {
|
||||
busEvents(types: TimeUpdate, batchSize: 1) {
|
||||
id
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
/**
|
||||
* __useBlockTimeSubscription__
|
||||
*
|
||||
* To run a query within a React component, call `useBlockTimeSubscription` and pass it any options that fit your needs.
|
||||
* When your component renders, `useBlockTimeSubscription` 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 } = useBlockTimeSubscription({
|
||||
* variables: {
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useBlockTimeSubscription(baseOptions?: Apollo.SubscriptionHookOptions<BlockTimeSubscription, BlockTimeSubscriptionVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useSubscription<BlockTimeSubscription, BlockTimeSubscriptionVariables>(BlockTimeDocument, options);
|
||||
}
|
||||
export type BlockTimeSubscriptionHookResult = ReturnType<typeof useBlockTimeSubscription>;
|
||||
export type BlockTimeSubscriptionResult = Apollo.SubscriptionResult<BlockTimeSubscription>;
|
@ -1,27 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: Statistics
|
||||
// ====================================================
|
||||
|
||||
export interface Statistics_statistics {
|
||||
__typename: "Statistics";
|
||||
/**
|
||||
* Current chain ID
|
||||
*/
|
||||
chainId: string;
|
||||
/**
|
||||
* Current block number
|
||||
*/
|
||||
blockHeight: string;
|
||||
}
|
||||
|
||||
export interface Statistics {
|
||||
/**
|
||||
* get statistics about the Vega node
|
||||
*/
|
||||
statistics: Statistics_statistics;
|
||||
}
|
@ -1,26 +1,12 @@
|
||||
import { gql } from '@apollo/client';
|
||||
import createClient from './apollo-client';
|
||||
import type { Statistics } from './__generated__/Statistics';
|
||||
|
||||
export const STATS_QUERY = gql`
|
||||
query Statistics {
|
||||
statistics {
|
||||
chainId
|
||||
blockHeight
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const TIME_UPDATE_SUBSCRIPTION = gql`
|
||||
subscription BlockTime {
|
||||
busEvents(types: TimeUpdate, batchSize: 1) {
|
||||
id
|
||||
}
|
||||
}
|
||||
`;
|
||||
import { StatisticsDocument, BlockTimeDocument } from './__generated__/Node';
|
||||
import type {
|
||||
StatisticsQuery,
|
||||
BlockTimeSubscription,
|
||||
} from './__generated__/Node';
|
||||
|
||||
type Callbacks = {
|
||||
onStatsSuccess: (data: Statistics) => void;
|
||||
onStatsSuccess: (data: StatisticsQuery) => void;
|
||||
onStatsFailure: () => void;
|
||||
onSubscriptionSuccess: () => void;
|
||||
onSubscriptionFailure: () => void;
|
||||
@ -46,8 +32,8 @@ export const requestNode = (
|
||||
const client = createClient(url);
|
||||
|
||||
client
|
||||
.query<Statistics>({
|
||||
query: STATS_QUERY,
|
||||
.query<StatisticsQuery>({
|
||||
query: StatisticsDocument,
|
||||
})
|
||||
.then((res) => {
|
||||
onStatsSuccess(res.data);
|
||||
@ -57,8 +43,8 @@ export const requestNode = (
|
||||
});
|
||||
|
||||
const subscription = client
|
||||
.subscribe({
|
||||
query: TIME_UPDATE_SUBSCRIPTION,
|
||||
.subscribe<BlockTimeSubscription>({
|
||||
query: BlockTimeDocument,
|
||||
errorPolicy: 'all',
|
||||
})
|
||||
.subscribe({
|
||||
|
@ -1,6 +1,4 @@
|
||||
export * from './lib/fills-container';
|
||||
export * from './lib/use-fills-list';
|
||||
export * from './lib/fills-data-provider';
|
||||
export * from './lib/__generated__/FillFields';
|
||||
export * from './lib/__generated__/Fills';
|
||||
export * from './lib/__generated__/FillsSub';
|
||||
|
@ -1,5 +1,8 @@
|
||||
fragment FillFields on Trade {
|
||||
id
|
||||
market {
|
||||
id
|
||||
}
|
||||
createdAt
|
||||
price
|
||||
size
|
||||
@ -22,26 +25,13 @@ fragment FillFields on Trade {
|
||||
infrastructureFee
|
||||
liquidityFee
|
||||
}
|
||||
market {
|
||||
id
|
||||
decimalPlaces
|
||||
positionDecimalPlaces
|
||||
tradableInstrument {
|
||||
instrument {
|
||||
id
|
||||
code
|
||||
product {
|
||||
... on Future {
|
||||
settlementAsset {
|
||||
id
|
||||
symbol
|
||||
decimals
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fragment FillEdge on TradeEdge {
|
||||
node {
|
||||
...FillFields
|
||||
}
|
||||
cursor
|
||||
}
|
||||
|
||||
query Fills($partyId: ID!, $marketId: ID, $pagination: Pagination) {
|
||||
@ -49,10 +39,7 @@ query Fills($partyId: ID!, $marketId: ID, $pagination: Pagination) {
|
||||
id
|
||||
tradesConnection(marketId: $marketId, pagination: $pagination) {
|
||||
edges {
|
||||
node {
|
||||
...FillFields
|
||||
}
|
||||
cursor
|
||||
...FillEdge
|
||||
}
|
||||
pageInfo {
|
||||
startCursor
|
||||
@ -64,17 +51,19 @@ query Fills($partyId: ID!, $marketId: ID, $pagination: Pagination) {
|
||||
}
|
||||
}
|
||||
|
||||
subscription FillsSub($partyId: ID!) {
|
||||
subscription FillsEvent($partyId: ID!) {
|
||||
trades(partyId: $partyId) {
|
||||
id
|
||||
createdAt
|
||||
price
|
||||
size
|
||||
marketId
|
||||
buyOrder
|
||||
sellOrder
|
||||
aggressor
|
||||
buyerId
|
||||
sellerId
|
||||
aggressor
|
||||
price
|
||||
size
|
||||
createdAt
|
||||
type
|
||||
buyerFee {
|
||||
makerFee
|
||||
infrastructureFee
|
||||
@ -85,6 +74,5 @@ subscription FillsSub($partyId: ID!) {
|
||||
infrastructureFee
|
||||
liquidityFee
|
||||
}
|
||||
marketId
|
||||
}
|
||||
}
|
||||
|
198
libs/fills/src/lib/__generated__/FillFields.ts
generated
198
libs/fills/src/lib/__generated__/FillFields.ts
generated
@ -1,198 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
import { Side } from "@vegaprotocol/types";
|
||||
|
||||
// ====================================================
|
||||
// GraphQL fragment: FillFields
|
||||
// ====================================================
|
||||
|
||||
export interface FillFields_buyer {
|
||||
__typename: "Party";
|
||||
/**
|
||||
* Party identifier
|
||||
*/
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface FillFields_seller {
|
||||
__typename: "Party";
|
||||
/**
|
||||
* Party identifier
|
||||
*/
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface FillFields_buyerFee {
|
||||
__typename: "TradeFee";
|
||||
/**
|
||||
* The maker fee, paid by the aggressive party to the other party (the one who had an order in the book)
|
||||
*/
|
||||
makerFee: string;
|
||||
/**
|
||||
* The infrastructure fee, a fee paid to the validators to maintain the Vega network
|
||||
*/
|
||||
infrastructureFee: string;
|
||||
/**
|
||||
* The fee paid to the liquidity providers that committed liquidity to the market
|
||||
*/
|
||||
liquidityFee: string;
|
||||
}
|
||||
|
||||
export interface FillFields_sellerFee {
|
||||
__typename: "TradeFee";
|
||||
/**
|
||||
* The maker fee, paid by the aggressive party to the other party (the one who had an order in the book)
|
||||
*/
|
||||
makerFee: string;
|
||||
/**
|
||||
* The infrastructure fee, a fee paid to the validators to maintain the Vega network
|
||||
*/
|
||||
infrastructureFee: string;
|
||||
/**
|
||||
* The fee paid to the liquidity providers that committed liquidity to the market
|
||||
*/
|
||||
liquidityFee: string;
|
||||
}
|
||||
|
||||
export interface FillFields_market_tradableInstrument_instrument_product_settlementAsset {
|
||||
__typename: "Asset";
|
||||
/**
|
||||
* The ID of the asset
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* The symbol of the asset (e.g: GBP)
|
||||
*/
|
||||
symbol: string;
|
||||
/**
|
||||
* The 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 FillFields_market_tradableInstrument_instrument_product {
|
||||
__typename: "Future";
|
||||
/**
|
||||
* The name of the asset (string)
|
||||
*/
|
||||
settlementAsset: FillFields_market_tradableInstrument_instrument_product_settlementAsset;
|
||||
}
|
||||
|
||||
export interface FillFields_market_tradableInstrument_instrument {
|
||||
__typename: "Instrument";
|
||||
/**
|
||||
* Uniquely identify an instrument across all instruments available on Vega (string)
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* A short non necessarily unique code used to easily describe the instrument (e.g: FX:BTCUSD/DEC18) (string)
|
||||
*/
|
||||
code: string;
|
||||
/**
|
||||
* Full and fairly descriptive name for the instrument
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* A reference to or instance of a fully specified product, including all required product parameters for that product (Product union)
|
||||
*/
|
||||
product: FillFields_market_tradableInstrument_instrument_product;
|
||||
}
|
||||
|
||||
export interface FillFields_market_tradableInstrument {
|
||||
__typename: "TradableInstrument";
|
||||
/**
|
||||
* An instance of, or reference to, a fully specified instrument.
|
||||
*/
|
||||
instrument: FillFields_market_tradableInstrument_instrument;
|
||||
}
|
||||
|
||||
export interface FillFields_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;
|
||||
/**
|
||||
* positionDecimalPlaces indicates the number of decimal places that an integer must be shifted in order to get a correct size (uint64).
|
||||
* i.e. 0 means there are no fractional orders for the market, and order sizes are always whole sizes.
|
||||
* 2 means sizes given as 10^2 * desired size, e.g. a desired size of 1.23 is represented as 123 in this market.
|
||||
* This sets how big the smallest order / position on the market can be.
|
||||
*/
|
||||
positionDecimalPlaces: number;
|
||||
/**
|
||||
* An instance of, or reference to, a tradable instrument.
|
||||
*/
|
||||
tradableInstrument: FillFields_market_tradableInstrument;
|
||||
}
|
||||
|
||||
export interface FillFields {
|
||||
__typename: "Trade";
|
||||
/**
|
||||
* The hash of the trade data
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* RFC3339Nano time for when the trade occurred
|
||||
*/
|
||||
createdAt: string;
|
||||
/**
|
||||
* The price of the trade (probably initially the passive order price, other determination algorithms are possible though) (uint64)
|
||||
*/
|
||||
price: string;
|
||||
/**
|
||||
* The number of contracts trades, will always be <= the remaining size of both orders immediately before the trade (uint64)
|
||||
*/
|
||||
size: string;
|
||||
/**
|
||||
* The order that bought
|
||||
*/
|
||||
buyOrder: string;
|
||||
/**
|
||||
* The order that sold
|
||||
*/
|
||||
sellOrder: string;
|
||||
/**
|
||||
* The aggressor indicates whether this trade was related to a BUY or SELL
|
||||
*/
|
||||
aggressor: Side;
|
||||
/**
|
||||
* The party that bought
|
||||
*/
|
||||
buyer: FillFields_buyer;
|
||||
/**
|
||||
* The party that sold
|
||||
*/
|
||||
seller: FillFields_seller;
|
||||
/**
|
||||
* The fee paid by the buyer side of the trade
|
||||
*/
|
||||
buyerFee: FillFields_buyerFee;
|
||||
/**
|
||||
* The fee paid by the seller side of the trade
|
||||
*/
|
||||
sellerFee: FillFields_sellerFee;
|
||||
/**
|
||||
* The market the trade occurred on
|
||||
*/
|
||||
market: FillFields_market;
|
||||
}
|
309
libs/fills/src/lib/__generated__/Fills.ts
generated
309
libs/fills/src/lib/__generated__/Fills.ts
generated
@ -1,166 +1,161 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
import { Schema as Types } from '@vegaprotocol/types';
|
||||
|
||||
import { Pagination, Side } from "@vegaprotocol/types";
|
||||
import { gql } from '@apollo/client';
|
||||
import * as Apollo from '@apollo/client';
|
||||
const defaultOptions = {} as const;
|
||||
export type FillFieldsFragment = { __typename?: 'Trade', id: string, createdAt: string, price: string, size: string, buyOrder: string, sellOrder: string, aggressor: Types.Side, market: { __typename?: 'Market', id: string }, buyer: { __typename?: 'Party', id: string }, seller: { __typename?: 'Party', id: string }, buyerFee: { __typename?: 'TradeFee', makerFee: string, infrastructureFee: string, liquidityFee: string }, sellerFee: { __typename?: 'TradeFee', makerFee: string, infrastructureFee: string, liquidityFee: string } };
|
||||
|
||||
// ====================================================
|
||||
// GraphQL query operation: Fills
|
||||
// ====================================================
|
||||
export type FillEdgeFragment = { __typename?: 'TradeEdge', cursor: string, node: { __typename?: 'Trade', id: string, createdAt: string, price: string, size: string, buyOrder: string, sellOrder: string, aggressor: Types.Side, market: { __typename?: 'Market', id: string }, buyer: { __typename?: 'Party', id: string }, seller: { __typename?: 'Party', id: string }, buyerFee: { __typename?: 'TradeFee', makerFee: string, infrastructureFee: string, liquidityFee: string }, sellerFee: { __typename?: 'TradeFee', makerFee: string, infrastructureFee: string, liquidityFee: string } } };
|
||||
|
||||
export interface Fills_party_tradesConnection_edges_node_market {
|
||||
__typename: "Market";
|
||||
/**
|
||||
* Market ID
|
||||
*/
|
||||
id: string;
|
||||
export type FillsQueryVariables = Types.Exact<{
|
||||
partyId: Types.Scalars['ID'];
|
||||
marketId?: Types.InputMaybe<Types.Scalars['ID']>;
|
||||
pagination?: Types.InputMaybe<Types.Pagination>;
|
||||
}>;
|
||||
|
||||
|
||||
export type FillsQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, tradesConnection?: { __typename?: 'TradeConnection', edges: Array<{ __typename?: 'TradeEdge', cursor: string, node: { __typename?: 'Trade', id: string, createdAt: string, price: string, size: string, buyOrder: string, sellOrder: string, aggressor: Types.Side, market: { __typename?: 'Market', id: string }, buyer: { __typename?: 'Party', id: string }, seller: { __typename?: 'Party', id: string }, buyerFee: { __typename?: 'TradeFee', makerFee: string, infrastructureFee: string, liquidityFee: string }, sellerFee: { __typename?: 'TradeFee', makerFee: string, infrastructureFee: string, liquidityFee: string } } }>, pageInfo: { __typename?: 'PageInfo', startCursor: string, endCursor: string, hasNextPage: boolean, hasPreviousPage: boolean } } | null } | null };
|
||||
|
||||
export type FillsEventSubscriptionVariables = Types.Exact<{
|
||||
partyId: Types.Scalars['ID'];
|
||||
}>;
|
||||
|
||||
|
||||
export type FillsEventSubscription = { __typename?: 'Subscription', trades?: Array<{ __typename?: 'TradeUpdate', id: string, marketId: string, buyOrder: string, sellOrder: string, buyerId: string, sellerId: string, aggressor: Types.Side, price: string, size: string, createdAt: string, type: Types.TradeType, buyerFee: { __typename?: 'TradeFee', makerFee: string, infrastructureFee: string, liquidityFee: string }, sellerFee: { __typename?: 'TradeFee', makerFee: string, infrastructureFee: string, liquidityFee: string } }> | null };
|
||||
|
||||
export const FillFieldsFragmentDoc = gql`
|
||||
fragment FillFields on Trade {
|
||||
id
|
||||
market {
|
||||
id
|
||||
}
|
||||
createdAt
|
||||
price
|
||||
size
|
||||
buyOrder
|
||||
sellOrder
|
||||
aggressor
|
||||
buyer {
|
||||
id
|
||||
}
|
||||
seller {
|
||||
id
|
||||
}
|
||||
buyerFee {
|
||||
makerFee
|
||||
infrastructureFee
|
||||
liquidityFee
|
||||
}
|
||||
sellerFee {
|
||||
makerFee
|
||||
infrastructureFee
|
||||
liquidityFee
|
||||
}
|
||||
}
|
||||
|
||||
export interface Fills_party_tradesConnection_edges_node_buyer {
|
||||
__typename: "Party";
|
||||
/**
|
||||
* Party identifier
|
||||
*/
|
||||
id: string;
|
||||
`;
|
||||
export const FillEdgeFragmentDoc = gql`
|
||||
fragment FillEdge on TradeEdge {
|
||||
node {
|
||||
...FillFields
|
||||
}
|
||||
cursor
|
||||
}
|
||||
|
||||
export interface Fills_party_tradesConnection_edges_node_seller {
|
||||
__typename: "Party";
|
||||
/**
|
||||
* Party identifier
|
||||
*/
|
||||
id: string;
|
||||
${FillFieldsFragmentDoc}`;
|
||||
export const FillsDocument = gql`
|
||||
query Fills($partyId: ID!, $marketId: ID, $pagination: Pagination) {
|
||||
party(id: $partyId) {
|
||||
id
|
||||
tradesConnection(marketId: $marketId, pagination: $pagination) {
|
||||
edges {
|
||||
...FillEdge
|
||||
}
|
||||
pageInfo {
|
||||
startCursor
|
||||
endCursor
|
||||
hasNextPage
|
||||
hasPreviousPage
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
${FillEdgeFragmentDoc}`;
|
||||
|
||||
export interface Fills_party_tradesConnection_edges_node_buyerFee {
|
||||
__typename: "TradeFee";
|
||||
/**
|
||||
* The maker fee, paid by the aggressive party to the other party (the one who had an order in the book)
|
||||
*/
|
||||
makerFee: string;
|
||||
/**
|
||||
* The infrastructure fee, a fee paid to the validators to maintain the Vega network
|
||||
*/
|
||||
infrastructureFee: string;
|
||||
/**
|
||||
* The fee paid to the liquidity providers that committed liquidity to the market
|
||||
*/
|
||||
liquidityFee: string;
|
||||
/**
|
||||
* __useFillsQuery__
|
||||
*
|
||||
* To run a query within a React component, call `useFillsQuery` and pass it any options that fit your needs.
|
||||
* When your component renders, `useFillsQuery` 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 } = useFillsQuery({
|
||||
* variables: {
|
||||
* partyId: // value for 'partyId'
|
||||
* marketId: // value for 'marketId'
|
||||
* pagination: // value for 'pagination'
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useFillsQuery(baseOptions: Apollo.QueryHookOptions<FillsQuery, FillsQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useQuery<FillsQuery, FillsQueryVariables>(FillsDocument, options);
|
||||
}
|
||||
export function useFillsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<FillsQuery, FillsQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useLazyQuery<FillsQuery, FillsQueryVariables>(FillsDocument, options);
|
||||
}
|
||||
export type FillsQueryHookResult = ReturnType<typeof useFillsQuery>;
|
||||
export type FillsLazyQueryHookResult = ReturnType<typeof useFillsLazyQuery>;
|
||||
export type FillsQueryResult = Apollo.QueryResult<FillsQuery, FillsQueryVariables>;
|
||||
export const FillsEventDocument = gql`
|
||||
subscription FillsEvent($partyId: ID!) {
|
||||
trades(partyId: $partyId) {
|
||||
id
|
||||
marketId
|
||||
buyOrder
|
||||
sellOrder
|
||||
buyerId
|
||||
sellerId
|
||||
aggressor
|
||||
price
|
||||
size
|
||||
createdAt
|
||||
type
|
||||
buyerFee {
|
||||
makerFee
|
||||
infrastructureFee
|
||||
liquidityFee
|
||||
}
|
||||
sellerFee {
|
||||
makerFee
|
||||
infrastructureFee
|
||||
liquidityFee
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export interface Fills_party_tradesConnection_edges_node_sellerFee {
|
||||
__typename: "TradeFee";
|
||||
/**
|
||||
* The maker fee, paid by the aggressive party to the other party (the one who had an order in the book)
|
||||
*/
|
||||
makerFee: string;
|
||||
/**
|
||||
* The infrastructure fee, a fee paid to the validators to maintain the Vega network
|
||||
*/
|
||||
infrastructureFee: string;
|
||||
/**
|
||||
* The fee paid to the liquidity providers that committed liquidity to the market
|
||||
*/
|
||||
liquidityFee: string;
|
||||
}
|
||||
|
||||
export interface Fills_party_tradesConnection_edges_node {
|
||||
__typename: "Trade";
|
||||
/**
|
||||
* The hash of the trade data
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* The market the trade occurred on
|
||||
*/
|
||||
market: Fills_party_tradesConnection_edges_node_market;
|
||||
/**
|
||||
* RFC3339Nano time for when the trade occurred
|
||||
*/
|
||||
createdAt: string;
|
||||
/**
|
||||
* The price of the trade (probably initially the passive order price, other determination algorithms are possible though) (uint64)
|
||||
*/
|
||||
price: string;
|
||||
/**
|
||||
* The number of contracts trades, will always be <= the remaining size of both orders immediately before the trade (uint64)
|
||||
*/
|
||||
size: string;
|
||||
/**
|
||||
* The order that bought
|
||||
*/
|
||||
buyOrder: string;
|
||||
/**
|
||||
* The order that sold
|
||||
*/
|
||||
sellOrder: string;
|
||||
/**
|
||||
* The aggressor indicates whether this trade was related to a BUY or SELL
|
||||
*/
|
||||
aggressor: Side;
|
||||
/**
|
||||
* The party that bought
|
||||
*/
|
||||
buyer: Fills_party_tradesConnection_edges_node_buyer;
|
||||
/**
|
||||
* The party that sold
|
||||
*/
|
||||
seller: Fills_party_tradesConnection_edges_node_seller;
|
||||
/**
|
||||
* The fee paid by the buyer side of the trade
|
||||
*/
|
||||
buyerFee: Fills_party_tradesConnection_edges_node_buyerFee;
|
||||
/**
|
||||
* The fee paid by the seller side of the trade
|
||||
*/
|
||||
sellerFee: Fills_party_tradesConnection_edges_node_sellerFee;
|
||||
}
|
||||
|
||||
export interface Fills_party_tradesConnection_edges {
|
||||
__typename: "TradeEdge";
|
||||
node: Fills_party_tradesConnection_edges_node;
|
||||
cursor: string;
|
||||
}
|
||||
|
||||
export interface Fills_party_tradesConnection_pageInfo {
|
||||
__typename: "PageInfo";
|
||||
startCursor: string;
|
||||
endCursor: string;
|
||||
hasNextPage: boolean;
|
||||
hasPreviousPage: boolean;
|
||||
}
|
||||
|
||||
export interface Fills_party_tradesConnection {
|
||||
__typename: "TradeConnection";
|
||||
/**
|
||||
* The trade in this connection
|
||||
*/
|
||||
edges: Fills_party_tradesConnection_edges[];
|
||||
/**
|
||||
* The pagination information
|
||||
*/
|
||||
pageInfo: Fills_party_tradesConnection_pageInfo;
|
||||
}
|
||||
|
||||
export interface Fills_party {
|
||||
__typename: "Party";
|
||||
/**
|
||||
* Party identifier
|
||||
*/
|
||||
id: string;
|
||||
tradesConnection: Fills_party_tradesConnection | null;
|
||||
}
|
||||
|
||||
export interface Fills {
|
||||
/**
|
||||
* An entity that is trading on the Vega network
|
||||
*/
|
||||
party: Fills_party | null;
|
||||
}
|
||||
|
||||
export interface FillsVariables {
|
||||
partyId: string;
|
||||
marketId?: string | null;
|
||||
pagination?: Pagination | null;
|
||||
}
|
||||
/**
|
||||
* __useFillsEventSubscription__
|
||||
*
|
||||
* To run a query within a React component, call `useFillsEventSubscription` and pass it any options that fit your needs.
|
||||
* When your component renders, `useFillsEventSubscription` 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 } = useFillsEventSubscription({
|
||||
* variables: {
|
||||
* partyId: // value for 'partyId'
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useFillsEventSubscription(baseOptions: Apollo.SubscriptionHookOptions<FillsEventSubscription, FillsEventSubscriptionVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useSubscription<FillsEventSubscription, FillsEventSubscriptionVariables>(FillsEventDocument, options);
|
||||
}
|
||||
export type FillsEventSubscriptionHookResult = ReturnType<typeof useFillsEventSubscription>;
|
||||
export type FillsEventSubscriptionResult = Apollo.SubscriptionResult<FillsEventSubscription>;
|
109
libs/fills/src/lib/__generated__/FillsSub.ts
generated
109
libs/fills/src/lib/__generated__/FillsSub.ts
generated
@ -1,109 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
import { Side, TradeType } from "@vegaprotocol/types";
|
||||
|
||||
// ====================================================
|
||||
// GraphQL subscription operation: FillsSub
|
||||
// ====================================================
|
||||
|
||||
export interface FillsSub_trades_buyerFee {
|
||||
__typename: "TradeFee";
|
||||
/**
|
||||
* The maker fee, paid by the aggressive party to the other party (the one who had an order in the book)
|
||||
*/
|
||||
makerFee: string;
|
||||
/**
|
||||
* The infrastructure fee, a fee paid to the validators to maintain the Vega network
|
||||
*/
|
||||
infrastructureFee: string;
|
||||
/**
|
||||
* The fee paid to the liquidity providers that committed liquidity to the market
|
||||
*/
|
||||
liquidityFee: string;
|
||||
}
|
||||
|
||||
export interface FillsSub_trades_sellerFee {
|
||||
__typename: "TradeFee";
|
||||
/**
|
||||
* The maker fee, paid by the aggressive party to the other party (the one who had an order in the book)
|
||||
*/
|
||||
makerFee: string;
|
||||
/**
|
||||
* The infrastructure fee, a fee paid to the validators to maintain the Vega network
|
||||
*/
|
||||
infrastructureFee: string;
|
||||
/**
|
||||
* The fee paid to the liquidity providers that committed liquidity to the market
|
||||
*/
|
||||
liquidityFee: string;
|
||||
}
|
||||
|
||||
export interface FillsSub_trades {
|
||||
__typename: "TradeUpdate";
|
||||
/**
|
||||
* The hash of the trade data
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* The market the trade occurred on
|
||||
*/
|
||||
marketId: string;
|
||||
/**
|
||||
* The order that bought
|
||||
*/
|
||||
buyOrder: string;
|
||||
/**
|
||||
* The order that sold
|
||||
*/
|
||||
sellOrder: string;
|
||||
/**
|
||||
* The party that bought
|
||||
*/
|
||||
buyerId: string;
|
||||
/**
|
||||
* The party that sold
|
||||
*/
|
||||
sellerId: string;
|
||||
/**
|
||||
* The aggressor indicates whether this trade was related to a BUY or SELL
|
||||
*/
|
||||
aggressor: Side;
|
||||
/**
|
||||
* The price of the trade (probably initially the passive order price, other determination algorithms are possible though) (uint64)
|
||||
*/
|
||||
price: string;
|
||||
/**
|
||||
* The number of units traded, will always be <= the remaining size of both orders immediately before the trade (uint64)
|
||||
*/
|
||||
size: string;
|
||||
/**
|
||||
* RFC3339Nano time for when the trade occurred
|
||||
*/
|
||||
createdAt: string;
|
||||
/**
|
||||
* The type of trade
|
||||
*/
|
||||
type: TradeType;
|
||||
/**
|
||||
* The fee paid by the buyer side of the trade
|
||||
*/
|
||||
buyerFee: FillsSub_trades_buyerFee;
|
||||
/**
|
||||
* The fee paid by the seller side of the trade
|
||||
*/
|
||||
sellerFee: FillsSub_trades_sellerFee;
|
||||
}
|
||||
|
||||
export interface FillsSub {
|
||||
/**
|
||||
* Subscribe to the trades updates
|
||||
*/
|
||||
trades: FillsSub_trades[] | null;
|
||||
}
|
||||
|
||||
export interface FillsSubVariables {
|
||||
partyId: string;
|
||||
}
|
@ -1,170 +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 FillFieldsFragment = { __typename?: 'Trade', id: string, createdAt: string, price: string, size: string, buyOrder: string, sellOrder: string, aggressor: Types.Side, buyer: { __typename?: 'Party', id: string }, seller: { __typename?: 'Party', id: string }, buyerFee: { __typename?: 'TradeFee', makerFee: string, infrastructureFee: string, liquidityFee: string }, sellerFee: { __typename?: 'TradeFee', makerFee: string, infrastructureFee: string, liquidityFee: string }, market: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, code: string, product: { __typename?: 'Future', settlementAsset: { __typename?: 'Asset', id: string, symbol: string, decimals: number } } } } } };
|
||||
|
||||
export type FillsQueryVariables = Types.Exact<{
|
||||
partyId: Types.Scalars['ID'];
|
||||
marketId?: Types.InputMaybe<Types.Scalars['ID']>;
|
||||
pagination?: Types.InputMaybe<Types.Pagination>;
|
||||
}>;
|
||||
|
||||
|
||||
export type FillsQuery = { __typename?: 'Query', party?: { __typename?: 'Party', id: string, tradesConnection?: { __typename?: 'TradeConnection', edges: Array<{ __typename?: 'TradeEdge', cursor: string, node: { __typename?: 'Trade', id: string, createdAt: string, price: string, size: string, buyOrder: string, sellOrder: string, aggressor: Types.Side, buyer: { __typename?: 'Party', id: string }, seller: { __typename?: 'Party', id: string }, buyerFee: { __typename?: 'TradeFee', makerFee: string, infrastructureFee: string, liquidityFee: string }, sellerFee: { __typename?: 'TradeFee', makerFee: string, infrastructureFee: string, liquidityFee: string }, market: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, code: string, product: { __typename?: 'Future', settlementAsset: { __typename?: 'Asset', id: string, symbol: string, decimals: number } } } } } } }>, pageInfo: { __typename?: 'PageInfo', startCursor: string, endCursor: string, hasNextPage: boolean, hasPreviousPage: boolean } } | null } | null };
|
||||
|
||||
export type FillsSubSubscriptionVariables = Types.Exact<{
|
||||
partyId: Types.Scalars['ID'];
|
||||
}>;
|
||||
|
||||
|
||||
export type FillsSubSubscription = { __typename?: 'Subscription', trades?: Array<{ __typename?: 'TradeUpdate', id: string, createdAt: string, price: string, size: string, buyOrder: string, sellOrder: string, aggressor: Types.Side, buyerId: string, sellerId: string, marketId: string, buyerFee: { __typename?: 'TradeFee', makerFee: string, infrastructureFee: string, liquidityFee: string }, sellerFee: { __typename?: 'TradeFee', makerFee: string, infrastructureFee: string, liquidityFee: string } }> | null };
|
||||
|
||||
export const FillFieldsFragmentDoc = gql`
|
||||
fragment FillFields on Trade {
|
||||
id
|
||||
createdAt
|
||||
price
|
||||
size
|
||||
buyOrder
|
||||
sellOrder
|
||||
aggressor
|
||||
buyer {
|
||||
id
|
||||
}
|
||||
seller {
|
||||
id
|
||||
}
|
||||
buyerFee {
|
||||
makerFee
|
||||
infrastructureFee
|
||||
liquidityFee
|
||||
}
|
||||
sellerFee {
|
||||
makerFee
|
||||
infrastructureFee
|
||||
liquidityFee
|
||||
}
|
||||
market {
|
||||
id
|
||||
decimalPlaces
|
||||
positionDecimalPlaces
|
||||
tradableInstrument {
|
||||
instrument {
|
||||
id
|
||||
code
|
||||
product {
|
||||
... on Future {
|
||||
settlementAsset {
|
||||
id
|
||||
symbol
|
||||
decimals
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
export const FillsDocument = gql`
|
||||
query Fills($partyId: ID!, $marketId: ID, $pagination: Pagination) {
|
||||
party(id: $partyId) {
|
||||
id
|
||||
tradesConnection(marketId: $marketId, pagination: $pagination) {
|
||||
edges {
|
||||
node {
|
||||
...FillFields
|
||||
}
|
||||
cursor
|
||||
}
|
||||
pageInfo {
|
||||
startCursor
|
||||
endCursor
|
||||
hasNextPage
|
||||
hasPreviousPage
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
${FillFieldsFragmentDoc}`;
|
||||
|
||||
/**
|
||||
* __useFillsQuery__
|
||||
*
|
||||
* To run a query within a React component, call `useFillsQuery` and pass it any options that fit your needs.
|
||||
* When your component renders, `useFillsQuery` 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 } = useFillsQuery({
|
||||
* variables: {
|
||||
* partyId: // value for 'partyId'
|
||||
* marketId: // value for 'marketId'
|
||||
* pagination: // value for 'pagination'
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useFillsQuery(baseOptions: Apollo.QueryHookOptions<FillsQuery, FillsQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useQuery<FillsQuery, FillsQueryVariables>(FillsDocument, options);
|
||||
}
|
||||
export function useFillsLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions<FillsQuery, FillsQueryVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useLazyQuery<FillsQuery, FillsQueryVariables>(FillsDocument, options);
|
||||
}
|
||||
export type FillsQueryHookResult = ReturnType<typeof useFillsQuery>;
|
||||
export type FillsLazyQueryHookResult = ReturnType<typeof useFillsLazyQuery>;
|
||||
export type FillsQueryResult = Apollo.QueryResult<FillsQuery, FillsQueryVariables>;
|
||||
export const FillsSubDocument = gql`
|
||||
subscription FillsSub($partyId: ID!) {
|
||||
trades(partyId: $partyId) {
|
||||
id
|
||||
createdAt
|
||||
price
|
||||
size
|
||||
buyOrder
|
||||
sellOrder
|
||||
aggressor
|
||||
buyerId
|
||||
sellerId
|
||||
buyerFee {
|
||||
makerFee
|
||||
infrastructureFee
|
||||
liquidityFee
|
||||
}
|
||||
sellerFee {
|
||||
makerFee
|
||||
infrastructureFee
|
||||
liquidityFee
|
||||
}
|
||||
marketId
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
/**
|
||||
* __useFillsSubSubscription__
|
||||
*
|
||||
* To run a query within a React component, call `useFillsSubSubscription` and pass it any options that fit your needs.
|
||||
* When your component renders, `useFillsSubSubscription` 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 } = useFillsSubSubscription({
|
||||
* variables: {
|
||||
* partyId: // value for 'partyId'
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
export function useFillsSubSubscription(baseOptions: Apollo.SubscriptionHookOptions<FillsSubSubscription, FillsSubSubscriptionVariables>) {
|
||||
const options = {...defaultOptions, ...baseOptions}
|
||||
return Apollo.useSubscription<FillsSubSubscription, FillsSubSubscriptionVariables>(FillsSubDocument, options);
|
||||
}
|
||||
export type FillsSubSubscriptionHookResult = ReturnType<typeof useFillsSubSubscription>;
|
||||
export type FillsSubSubscriptionResult = Apollo.SubscriptionResult<FillsSubSubscription>;
|
@ -1,6 +1,5 @@
|
||||
import produce from 'immer';
|
||||
import orderBy from 'lodash/orderBy';
|
||||
import { gql } from '@apollo/client';
|
||||
import {
|
||||
makeDataProvider,
|
||||
makeDerivedDataProvider,
|
||||
@ -9,101 +8,27 @@ import {
|
||||
import type { Market } from '@vegaprotocol/market-list';
|
||||
import { marketsProvider } from '@vegaprotocol/market-list';
|
||||
import type { PageInfo } from '@vegaprotocol/react-helpers';
|
||||
import { FillsDocument, FillsEventDocument } from './__generated__/Fills';
|
||||
import type {
|
||||
Fills,
|
||||
Fills_party_tradesConnection_edges,
|
||||
Fills_party_tradesConnection_edges_node,
|
||||
FillsQuery,
|
||||
FillFieldsFragment,
|
||||
FillEdgeFragment,
|
||||
FillsEventSubscription,
|
||||
} from './__generated__/Fills';
|
||||
import type { FillsSub, FillsSub_trades } from './__generated__/FillsSub';
|
||||
|
||||
export const FILLS_QUERY = gql`
|
||||
query Fills($partyId: ID!, $marketId: ID, $pagination: Pagination) {
|
||||
party(id: $partyId) {
|
||||
id
|
||||
tradesConnection(marketId: $marketId, pagination: $pagination) {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
market {
|
||||
id
|
||||
}
|
||||
createdAt
|
||||
price
|
||||
size
|
||||
buyOrder
|
||||
sellOrder
|
||||
aggressor
|
||||
buyer {
|
||||
id
|
||||
}
|
||||
seller {
|
||||
id
|
||||
}
|
||||
buyerFee {
|
||||
makerFee
|
||||
infrastructureFee
|
||||
liquidityFee
|
||||
}
|
||||
sellerFee {
|
||||
makerFee
|
||||
infrastructureFee
|
||||
liquidityFee
|
||||
}
|
||||
}
|
||||
cursor
|
||||
}
|
||||
pageInfo {
|
||||
startCursor
|
||||
endCursor
|
||||
hasNextPage
|
||||
hasPreviousPage
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const FILLS_SUB = gql`
|
||||
subscription FillsSub($partyId: ID!) {
|
||||
trades(partyId: $partyId) {
|
||||
id
|
||||
marketId
|
||||
buyOrder
|
||||
sellOrder
|
||||
buyerId
|
||||
sellerId
|
||||
aggressor
|
||||
price
|
||||
size
|
||||
createdAt
|
||||
type
|
||||
buyerFee {
|
||||
makerFee
|
||||
infrastructureFee
|
||||
liquidityFee
|
||||
}
|
||||
sellerFee {
|
||||
makerFee
|
||||
infrastructureFee
|
||||
liquidityFee
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const update = (
|
||||
data: (Fills_party_tradesConnection_edges | null)[],
|
||||
delta: FillsSub_trades[]
|
||||
data: FillEdgeFragment[] | null,
|
||||
delta: FillsEventSubscription['trades']
|
||||
) => {
|
||||
return produce(data, (draft) => {
|
||||
orderBy(delta, 'createdAt').forEach((node) => {
|
||||
if (draft === null) {
|
||||
return;
|
||||
}
|
||||
const index = draft.findIndex((edge) => edge?.node.id === node.id);
|
||||
if (index !== -1) {
|
||||
if (draft[index]?.node) {
|
||||
Object.assign(
|
||||
draft[index]?.node as Fills_party_tradesConnection_edges_node,
|
||||
node
|
||||
);
|
||||
Object.assign(draft[index]?.node as FillFieldsFragment, node);
|
||||
}
|
||||
} else {
|
||||
const firstNode = draft[0]?.node;
|
||||
@ -129,24 +54,25 @@ const update = (
|
||||
});
|
||||
};
|
||||
|
||||
export type Trade = Fills_party_tradesConnection_edges_node;
|
||||
export type Trade = FillFieldsFragment;
|
||||
export type TradeWithMarket = Omit<Trade, 'market'> & { market?: Market };
|
||||
export type TradeWithMarketEdge = {
|
||||
cursor: Fills_party_tradesConnection_edges['cursor'];
|
||||
cursor: FillEdgeFragment['cursor'];
|
||||
node: TradeWithMarket;
|
||||
};
|
||||
|
||||
const getData = (responseData: Fills): Fills_party_tradesConnection_edges[] =>
|
||||
const getData = (responseData: FillsQuery): FillEdgeFragment[] =>
|
||||
responseData.party?.tradesConnection?.edges || [];
|
||||
|
||||
const getPageInfo = (responseData: Fills): PageInfo | null =>
|
||||
const getPageInfo = (responseData: FillsQuery): PageInfo | null =>
|
||||
responseData.party?.tradesConnection?.pageInfo || null;
|
||||
|
||||
const getDelta = (subscriptionData: FillsSub) => subscriptionData.trades || [];
|
||||
const getDelta = (subscriptionData: FillsEventSubscription) =>
|
||||
subscriptionData.trades || [];
|
||||
|
||||
export const fillsProvider = makeDataProvider({
|
||||
query: FILLS_QUERY,
|
||||
subscriptionQuery: FILLS_SUB,
|
||||
query: FillsDocument,
|
||||
subscriptionQuery: FillsEventDocument,
|
||||
update,
|
||||
getData,
|
||||
getDelta,
|
||||
@ -184,7 +110,7 @@ export const fillsWithMarketProvider = makeDerivedDataProvider<
|
||||
(deltaTrade) => ({
|
||||
...((parts[0].data as ReturnType<typeof getData>)?.find(
|
||||
(trade) => trade.node.id === deltaTrade.id
|
||||
)?.node as Fills_party_tradesConnection_edges_node),
|
||||
)?.node as FillFieldsFragment),
|
||||
market: (parts[1].data as Market[]).find(
|
||||
(market) => market.id === deltaTrade.marketId
|
||||
),
|
||||
|
@ -252,5 +252,4 @@ export interface MarketLiquidity {
|
||||
|
||||
export interface MarketLiquidityVariables {
|
||||
marketId: string;
|
||||
partyId: string;
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import * as Apollo from '@apollo/client';
|
||||
const defaultOptions = {} as const;
|
||||
export type MarketLiquidityQueryVariables = Types.Exact<{
|
||||
marketId: Types.Scalars['ID'];
|
||||
partyId: Types.Scalars['ID'];
|
||||
}>;
|
||||
|
||||
|
||||
@ -13,12 +12,12 @@ export type MarketLiquidityQuery = { __typename?: 'Query', market?: { __typename
|
||||
|
||||
|
||||
export const MarketLiquidityDocument = gql`
|
||||
query MarketLiquidity($marketId: ID!, $partyId: ID!) {
|
||||
query MarketLiquidity($marketId: ID!) {
|
||||
market(id: $marketId) {
|
||||
id
|
||||
decimalPlaces
|
||||
positionDecimalPlaces
|
||||
liquidityProvisionsConnection(partyId: $partyId) {
|
||||
liquidityProvisionsConnection {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
@ -89,7 +88,6 @@ export const MarketLiquidityDocument = gql`
|
||||
* const { data, loading, error } = useMarketLiquidityQuery({
|
||||
* variables: {
|
||||
* marketId: // value for 'marketId'
|
||||
* partyId: // value for 'partyId'
|
||||
* },
|
||||
* });
|
||||
*/
|
||||
|
@ -122,15 +122,15 @@ export interface MarketInfoQuery_market_priceMonitoringSettings {
|
||||
export interface MarketInfoQuery_market_riskFactors {
|
||||
__typename: "RiskFactor";
|
||||
/**
|
||||
* Market the risk factor was emitted for
|
||||
* market the risk factor was emitted for
|
||||
*/
|
||||
market: string;
|
||||
/**
|
||||
* Short factor
|
||||
* short factor
|
||||
*/
|
||||
short: string;
|
||||
/**
|
||||
* Long factor
|
||||
* long factor
|
||||
*/
|
||||
long: string;
|
||||
}
|
||||
@ -521,7 +521,7 @@ export interface MarketInfoQuery_market {
|
||||
*/
|
||||
priceMonitoringSettings: MarketInfoQuery_market_priceMonitoringSettings;
|
||||
/**
|
||||
* Risk factors for the market
|
||||
* risk factors for the market
|
||||
*/
|
||||
riskFactors: MarketInfoQuery_market_riskFactors | null;
|
||||
/**
|
||||
|
@ -4,6 +4,8 @@ export * from './lib/context';
|
||||
export * from './lib/determine-id';
|
||||
export * from './lib/format';
|
||||
export * from './lib/generic-data-provider';
|
||||
export * from './lib/get-nodes';
|
||||
export * from './lib/get-events';
|
||||
export * from './lib/grid';
|
||||
export * from './lib/i18n';
|
||||
export * from './lib/pagination';
|
||||
|
21
libs/react-helpers/src/lib/get-events.ts
Normal file
21
libs/react-helpers/src/lib/get-events.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import type { Schema } from '@vegaprotocol/types';
|
||||
|
||||
type Event = {
|
||||
__typename?: string;
|
||||
};
|
||||
|
||||
type BusEvent<T extends Event> = {
|
||||
event?: T | Event;
|
||||
};
|
||||
|
||||
export function getEvents<T extends Event>(
|
||||
eventType: Schema.BusEventType,
|
||||
busEvents: BusEvent<T>[]
|
||||
) {
|
||||
return busEvents.reduce<T[]>((acc, item) => {
|
||||
if (item.event && item.event.__typename === eventType) {
|
||||
acc.push(item.event as T);
|
||||
}
|
||||
return acc;
|
||||
}, []);
|
||||
}
|
25
libs/react-helpers/src/lib/get-nodes.ts
Normal file
25
libs/react-helpers/src/lib/get-nodes.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import type { Schema } from '@vegaprotocol/types';
|
||||
|
||||
export type Node<T> = {
|
||||
__typename?: string;
|
||||
node: T;
|
||||
};
|
||||
|
||||
export type Connection<A> = {
|
||||
__typename?: string;
|
||||
edges?: Schema.Maybe<Array<Schema.Maybe<A>>>;
|
||||
};
|
||||
|
||||
export function getNodes<
|
||||
T,
|
||||
A extends Node<T> = Node<T>,
|
||||
B extends Connection<A> = Connection<A>
|
||||
>(data?: B | null, filterBy?: (item?: T | null) => boolean) {
|
||||
const edges = data?.edges || [];
|
||||
return edges.reduce<T[]>((acc, edge) => {
|
||||
if (edge?.node && (filterBy ? filterBy(edge?.node) : true)) {
|
||||
acc.push(edge.node);
|
||||
}
|
||||
return acc;
|
||||
}, []);
|
||||
}
|
@ -6,6 +6,8 @@ export * from './validate';
|
||||
export * from './assets';
|
||||
export * from './determine-id';
|
||||
export * from './generic-data-provider';
|
||||
export * from './get-nodes';
|
||||
export * from './get-events';
|
||||
export * from './i18n';
|
||||
export * from './pagination';
|
||||
export * from './remove-0x';
|
||||
|
@ -17,6 +17,10 @@ module.exports = {
|
||||
'../../libs/accounts/**',
|
||||
'../../libs/assets/**',
|
||||
'../../libs/candles-chart/**',
|
||||
'../../libs/deal-ticket/**',
|
||||
'../../libs/deposits/**',
|
||||
'../../libs/environment/**',
|
||||
'../../libs/fills/**',
|
||||
],
|
||||
},
|
||||
};
|
||||
|
18
libs/types/src/__generated__/globalTypes.ts
generated
18
libs/types/src/__generated__/globalTypes.ts
generated
@ -84,15 +84,6 @@ export enum ConditionOperator {
|
||||
OPERATOR_LESS_THAN_OR_EQUAL = "OPERATOR_LESS_THAN_OR_EQUAL",
|
||||
}
|
||||
|
||||
/**
|
||||
* The status of a deposit
|
||||
*/
|
||||
export enum DepositStatus {
|
||||
STATUS_CANCELLED = "STATUS_CANCELLED",
|
||||
STATUS_FINALIZED = "STATUS_FINALIZED",
|
||||
STATUS_OPEN = "STATUS_OPEN",
|
||||
}
|
||||
|
||||
/**
|
||||
* The interval for trade candles when subscribing via Vega GraphQL, default is I15M
|
||||
*/
|
||||
@ -329,15 +320,6 @@ export enum StakeLinkingStatus {
|
||||
STATUS_REJECTED = "STATUS_REJECTED",
|
||||
}
|
||||
|
||||
/**
|
||||
* Valid trade types
|
||||
*/
|
||||
export enum TradeType {
|
||||
TYPE_DEFAULT = "TYPE_DEFAULT",
|
||||
TYPE_NETWORK_CLOSE_OUT_BAD = "TYPE_NETWORK_CLOSE_OUT_BAD",
|
||||
TYPE_NETWORK_CLOSE_OUT_GOOD = "TYPE_NETWORK_CLOSE_OUT_GOOD",
|
||||
}
|
||||
|
||||
export enum ValidatorStatus {
|
||||
VALIDATOR_NODE_STATUS_ERSATZ = "VALIDATOR_NODE_STATUS_ERSATZ",
|
||||
VALIDATOR_NODE_STATUS_PENDING = "VALIDATOR_NODE_STATUS_PENDING",
|
||||
|
Loading…
Reference in New Issue
Block a user