From 478cc9e753a42494d261387b4c67e4a37a3cf4ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Szpiech?= Date: Thu, 28 Sep 2023 17:38:00 +0200 Subject: [PATCH 01/37] chore(ci): publish main image in dockerhub (#4930) --- .github/workflows/publish-dist.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish-dist.yml b/.github/workflows/publish-dist.yml index 6f2e0f05d..f4ef0d7fc 100644 --- a/.github/workflows/publish-dist.yml +++ b/.github/workflows/publish-dist.yml @@ -30,12 +30,18 @@ jobs: echo IS_IPFS_RELEASE=false >> $GITHUB_ENV echo IS_S3_RELEASE=false >> $GITHUB_ENV echo IS_DEV_IMAGE=false >> $GITHUB_ENV + echo IS_MAIN_IMAGE=false >> $GITHUB_ENV - name: Is dev image - if: ${{ contains(github.ref, 'develop') && github.event_name == 'push' && matrix.app == 'trading' }} + if: ${{ github.ref_name == 'develop' && github.event_name == 'push' && matrix.app == 'trading' }} run: | echo IS_DEV_IMAGE=true >> $GITHUB_ENV + - name: Is main image + if: ${{ github.ref_name == 'main' && github.event_name == 'push' && matrix.app == 'trading' }} + run: | + echo IS_MAIN_IMAGE=true >> $GITHUB_ENV + - name: Is PR if: ${{ github.event_name == 'pull_request' }} run: | @@ -81,7 +87,7 @@ jobs: - name: Log in to the Container registry (docker hub) uses: docker/login-action@v2 - if: ${{ env.IS_IPFS_RELEASE == 'true' || env.IS_DEV_IMAGE == 'true' }} + if: ${{ env.IS_IPFS_RELEASE == 'true' || env.IS_DEV_IMAGE == 'true' || env.IS_MAIN_IMAGE == 'true' }} with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} @@ -179,7 +185,7 @@ jobs: uses: docker/build-push-action@v3 continue-on-error: true id: dockerhub-push - if: ${{ env.IS_IPFS_RELEASE == 'true' || env.IS_DEV_IMAGE == 'true' }} + if: ${{ env.IS_IPFS_RELEASE == 'true' || env.IS_DEV_IMAGE == 'true' || env.IS_MAIN_IMAGE == 'true' }} with: context: . file: docker/node-outside-docker.Dockerfile @@ -189,7 +195,7 @@ jobs: ENV_NAME=${{ env.ENV_NAME }} tags: | vegaprotocol/${{ matrix.app }}:${{ github.sha }} - vegaprotocol/${{ matrix.app }}:${{ env.IS_MAINNET_RELEASE == 'true' && 'mainnet' || env.IS_TESTNET_RELEASE == 'true' && 'testnet' || env.IS_DEV_IMAGE == 'true' && 'develop' || '' }} + vegaprotocol/${{ matrix.app }}:${{ env.IS_MAINNET_RELEASE == 'true' && 'mainnet' || env.IS_TESTNET_RELEASE == 'true' && 'testnet' || env.IS_DEV_IMAGE == 'true' && 'develop' || env.IS_MAIN_IMAGE == 'true && main' || '' }} - name: Publish dist as docker image (ghcr - retry) uses: docker/build-push-action@v3 @@ -216,7 +222,7 @@ jobs: ENV_NAME=${{ env.ENV_NAME }} tags: | vegaprotocol/${{ matrix.app }}:${{ github.sha }} - vegaprotocol/${{ matrix.app }}:${{ env.IS_MAINNET_RELEASE == 'true' && 'mainnet' || env.IS_TESTNET_RELEASE == 'true' && 'testnet' || '' }} + vegaprotocol/${{ matrix.app }}:${{ env.IS_MAINNET_RELEASE == 'true' && 'mainnet' || env.IS_TESTNET_RELEASE == 'true' && 'testnet' || env.IS_DEV_IMAGE == 'true' && 'develop' || env.IS_MAIN_IMAGE == 'true && main' || '' }} # bucket creation in github.com/vegaprotocol/terraform//frontend - name: Publish dist to s3 From ff2e2574f666c413cfd4714f91e9cf18711d584b Mon Sep 17 00:00:00 2001 From: Maciek Date: Thu, 28 Sep 2023 21:14:32 +0200 Subject: [PATCH 02/37] chore(trading): add handle of autosizing selected columns - main branch (#4888) --- .../src/integration/trading-orders.cy.ts | 7 +-- .../orders-container/orders-container.tsx | 12 +++- .../positions-container.tsx | 8 ++- .../src/lib/use-datagrid-events.spec.tsx | 63 ++++++++++++------- libs/datagrid/src/lib/use-datagrid-events.ts | 17 ++++- .../lib/components/order-list/order-list.tsx | 1 + 6 files changed, 76 insertions(+), 32 deletions(-) diff --git a/apps/trading-e2e/src/integration/trading-orders.cy.ts b/apps/trading-e2e/src/integration/trading-orders.cy.ts index c595f5aab..ae79c684c 100644 --- a/apps/trading-e2e/src/integration/trading-orders.cy.ts +++ b/apps/trading-e2e/src/integration/trading-orders.cy.ts @@ -9,7 +9,7 @@ import { testOrderAmendment, } from '../support/order-validation'; -const orderSymbol = 'market.tradableInstrument.instrument.code'; +const orderSymbol = 'instrument-code'; const orderSize = 'size'; const orderType = 'type'; const orderStatus = 'status'; @@ -229,10 +229,7 @@ describe('subscribe orders', { tags: '@smoke' }, () => { status: Schema.OrderStatus.STATUS_FILLED, }); cy.getByTestId(`order-status-${orderId}`).should('have.text', 'Filled'); - cy.get('[col-id="market.tradableInstrument.instrument.code"]').contains( - '[title="Future"]', - 'Futr' - ); + cy.get(`[col-id="${orderSymbol}"]`).contains('[title="Future"]', 'Futr'); }); it('must see a rejected order', () => { diff --git a/apps/trading/components/orders-container/orders-container.tsx b/apps/trading/components/orders-container/orders-container.tsx index c67979964..3f8d7a14b 100644 --- a/apps/trading/components/orders-container/orders-container.tsx +++ b/apps/trading/components/orders-container/orders-container.tsx @@ -28,14 +28,20 @@ export interface OrderContainerProps { filter?: Filter; } +const AUTO_SIZE_COLUMNS = ['instrument-code']; + export const OrdersContainer = ({ filter }: OrderContainerProps) => { const { pubKey, isReadOnly } = useVegaWallet(); const onMarketClick = useMarketClickHandler(true); const onOrderTypeClick = useMarketLiquidityClickHandler(); const { gridState, updateGridState } = useOrderListGridState(filter); - const gridStoreCallbacks = useDataGridEvents(gridState, (newState) => { - updateGridState(filter, newState); - }); + const gridStoreCallbacks = useDataGridEvents( + gridState, + (newState) => { + updateGridState(filter, newState); + }, + AUTO_SIZE_COLUMNS + ); if (!pubKey) { return {t('Please connect Vega wallet')}; diff --git a/apps/trading/components/positions-container/positions-container.tsx b/apps/trading/components/positions-container/positions-container.tsx index f830d4666..295fb9463 100644 --- a/apps/trading/components/positions-container/positions-container.tsx +++ b/apps/trading/components/positions-container/positions-container.tsx @@ -10,6 +10,8 @@ import { create } from 'zustand'; import { persist } from 'zustand/middleware'; import { useMarketClickHandler } from '../../lib/hooks/use-market-click-handler'; +const AUTO_SIZE_COLUMNS = ['marketCode']; + export const PositionsContainer = ({ allKeys }: { allKeys?: boolean }) => { const onMarketClick = useMarketClickHandler(true); const { pubKey, pubKeys, isReadOnly } = useVegaWallet(); @@ -17,7 +19,11 @@ export const PositionsContainer = ({ allKeys }: { allKeys?: boolean }) => { const showClosed = usePositionsStore((store) => store.showClosedMarkets); const gridStore = usePositionsStore((store) => store.gridStore); const updateGridStore = usePositionsStore((store) => store.updateGridStore); - const gridStoreCallbacks = useDataGridEvents(gridStore, updateGridStore); + const gridStoreCallbacks = useDataGridEvents( + gridStore, + updateGridStore, + AUTO_SIZE_COLUMNS + ); if (!pubKey) { return ( diff --git a/libs/datagrid/src/lib/use-datagrid-events.spec.tsx b/libs/datagrid/src/lib/use-datagrid-events.spec.tsx index 486a2f3b7..fb2a51aa0 100644 --- a/libs/datagrid/src/lib/use-datagrid-events.spec.tsx +++ b/libs/datagrid/src/lib/use-datagrid-events.spec.tsx @@ -5,8 +5,6 @@ import type { MutableRefObject } from 'react'; import { useRef } from 'react'; import type { AgGridReact } from 'ag-grid-react'; -const GRID_EVENT_DEBOUNCE_TIME = 500; - const gridProps = { rowData: [{ id: 1 }], columnDefs: [ @@ -18,25 +16,29 @@ const gridProps = { ], style: { width: 500, height: 300 }, }; +const GRID_EVENT_DEBOUNCE_TIME = 300; +let gridRef: MutableRefObject; +function TestComponent({ + hookParams, +}: { + hookParams: Parameters; +}) { + const hookCallbacks = useDataGridEvents(...hookParams); + gridRef = useRef(null); + return ; +} // Not using render hook so I can pass event callbacks // to a rendered grid function setup(...args: Parameters) { - let gridRef; - - function TestComponent() { - const hookCallbacks = useDataGridEvents(...args); - gridRef = useRef(null); - return ; - } - render(); - return gridRef as unknown as MutableRefObject; + return render(); } describe('useDataGridEvents', () => { const originalWarn = console.warn; beforeAll(() => { + gridRef = undefined; jest.useFakeTimers(); // disabling some ag grid warnings that are caused by test setup only @@ -55,15 +57,15 @@ describe('useDataGridEvents', () => { columnState: undefined, }; - const result = setup(initialState, callback); + setup(initialState, callback); // column state was not updated, so the default width provided by the // col def should be set - expect(result.current.columnApi.getColumnState()[0].width).toEqual( + expect(gridRef.current?.columnApi.getColumnState()[0].width).toEqual( gridProps.columnDefs[0].width ); // no filters set - expect(result.current.api.getFilterModel()).toEqual({}); + expect(gridRef.current?.api.getFilterModel()).toEqual({}); // Set filter const idFilter = { @@ -72,7 +74,7 @@ describe('useDataGridEvents', () => { type: 'equals', }; await act(async () => { - result.current.api.setFilterModel({ + gridRef.current?.api.setFilterModel({ id: idFilter, }); }); @@ -88,7 +90,7 @@ describe('useDataGridEvents', () => { }, }); callback.mockClear(); - expect(result.current.api.getFilterModel()['id']).toEqual(idFilter); + expect(gridRef.current?.api.getFilterModel()['id']).toEqual(idFilter); }); it('applies grid state on ready', async () => { @@ -105,11 +107,11 @@ describe('useDataGridEvents', () => { columnState: [colState], }; - const result = setup(initialState, jest.fn()); + setup(initialState, jest.fn()); await waitFor(() => { - expect(result.current.api.getFilterModel()['id']).toEqual(idFilter); - expect(result.current.columnApi.getColumnState()[0]).toEqual( + expect(gridRef.current?.api.getFilterModel()['id']).toEqual(idFilter); + expect(gridRef.current?.columnApi.getColumnState()[0]).toEqual( expect.objectContaining(colState) ); }); @@ -122,13 +124,13 @@ describe('useDataGridEvents', () => { columnState: undefined, }; - const result = setup(initialState, callback); + setup(initialState, callback); const newWidth = 400; // Set col width multiple times await act(async () => { - result.current.columnApi.setColumnWidth('id', newWidth); + gridRef.current?.columnApi.setColumnWidth('id', newWidth); }); expect(callback).not.toHaveBeenCalled(); @@ -139,4 +141,23 @@ describe('useDataGridEvents', () => { expect(callback).toHaveBeenCalledTimes(0); }); + + it('columns for autosizing should be handle', () => { + const callback = jest.fn(); + const initialState = { + filterModel: undefined, + columnState: undefined, + }; + + const { rerender } = setup(initialState, callback, ['id']); + jest.spyOn(gridRef.current?.columnApi, 'autoSizeColumns'); + rerender(); + act(() => { + gridRef.current?.api.setRowData([{ id: 'test-id' }]); + jest.advanceTimersByTime(GRID_EVENT_DEBOUNCE_TIME); + }); + expect(gridRef.current?.columnApi.autoSizeColumns).toHaveBeenCalledWith([ + 'id', + ]); + }); }); diff --git a/libs/datagrid/src/lib/use-datagrid-events.ts b/libs/datagrid/src/lib/use-datagrid-events.ts index 23aaf68e1..70a850be0 100644 --- a/libs/datagrid/src/lib/use-datagrid-events.ts +++ b/libs/datagrid/src/lib/use-datagrid-events.ts @@ -6,6 +6,7 @@ import type { FilterChangedEvent, FirstDataRenderedEvent, SortChangedEvent, + GridReadyEvent, } from 'ag-grid-community'; import { useCallback } from 'react'; @@ -17,7 +18,8 @@ type State = { export const useDataGridEvents = ( state: State, - callback: (data: State) => void + callback: (data: State) => void, + autoSizeColumns?: string[] ) => { /** * Callback for filter events @@ -78,7 +80,7 @@ export const useDataGridEvents = ( * State only applied if found, otherwise columns sized to fit available space */ const onGridReady = useCallback( - ({ api, columnApi }: FirstDataRenderedEvent) => { + ({ api, columnApi }: GridReadyEvent) => { if (!api || !columnApi) return; if (state.columnState) { @@ -97,6 +99,16 @@ export const useDataGridEvents = ( [state] ); + const onFirstDataRendered = useCallback( + ({ columnApi }: FirstDataRenderedEvent) => { + if (!columnApi) return; + if (!state?.columnState && autoSizeColumns?.length) { + columnApi.autoSizeColumns(autoSizeColumns); + } + }, + [state, autoSizeColumns] + ); + return { onGridReady, // these events don't use the 'finished' flag @@ -106,5 +118,6 @@ export const useDataGridEvents = ( // these trigger a lot so this callback uses the 'finished' flag onColumnMoved: onDebouncedColumnChange, onColumnResized: onDebouncedColumnChange, + onFirstDataRendered, }; }; diff --git a/libs/orders/src/lib/components/order-list/order-list.tsx b/libs/orders/src/lib/components/order-list/order-list.tsx index 7bba17e75..719e981d0 100644 --- a/libs/orders/src/lib/components/order-list/order-list.tsx +++ b/libs/orders/src/lib/components/order-list/order-list.tsx @@ -79,6 +79,7 @@ export const OrderListTable = memo< () => [ { headerName: t('Market'), + colId: 'instrument-code', field: 'market.tradableInstrument.instrument.code', cellRenderer: 'MarketNameCell', cellRendererParams: { idPath: 'market.id', onMarketClick }, From 3a149ddfb2be3ce45e1691811b8d205a14ff7e65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Szpiech?= Date: Fri, 29 Sep 2023 14:01:04 +0200 Subject: [PATCH 03/37] chore(ci): add mainnet compatible runner to release mainnet branch push actions (#4936) --- .github/workflows/cypress-run.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/cypress-run.yml b/.github/workflows/cypress-run.yml index c69ff6edd..f0829df38 100644 --- a/.github/workflows/cypress-run.yml +++ b/.github/workflows/cypress-run.yml @@ -23,10 +23,15 @@ jobs: run: | if [ ${{ github.base_ref }} == 'main' ]; then echo "runner=mainnet-compatible-runner" >> $GITHUB_OUTPUT + elif [ ${{ github.event_name }} == 'push' ] && [ ${{ contains(github.ref_name, 'release/mainnet') }} ]; then + echo "runner=mainnet-compatible-runner" >> $GITHUB_OUTPUT else echo "runner=self-hosted-runner" >> $GITHUB_OUTPUT fi + - name: Print runner + run: echo ${{ steps.step.outputs.runner }} + e2e: strategy: fail-fast: false From 5b5802104eda6093565d154d746c46368ab884c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Szpiech?= Date: Fri, 29 Sep 2023 15:03:58 +0200 Subject: [PATCH 04/37] chore(ci): trigger lint-pr on repoened and sync (#4937) --- .github/workflows/lint-pr.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/lint-pr.yml b/.github/workflows/lint-pr.yml index 344a607ac..8763b67cd 100644 --- a/.github/workflows/lint-pr.yml +++ b/.github/workflows/lint-pr.yml @@ -6,6 +6,8 @@ on: types: - opened - edited + - reopened + - synchronize jobs: lint_pr: From 2f0be0bf349312f81c9f3f7a132a4a398727642f Mon Sep 17 00:00:00 2001 From: Maciek Date: Fri, 29 Sep 2023 15:07:18 +0200 Subject: [PATCH 05/37] chore(trading): 4774 put connect dialog inside onboarding dialog - main branch (#4920) --- .../proposal/proposal-container.spec.tsx | 5 ++ .../components/welcome-dialog/get-started.tsx | 8 ++-- .../welcome-dialog/use-get-onboarding-step.ts | 4 ++ .../welcome-dialog/welcome-dialog.tsx | 44 ++++++++++++++---- .../src/connect-dialog/connect-dialog.tsx | 46 ++++++++++++++----- 5 files changed, 82 insertions(+), 25 deletions(-) diff --git a/apps/governance/src/routes/proposals/proposal/proposal-container.spec.tsx b/apps/governance/src/routes/proposals/proposal/proposal-container.spec.tsx index 09de480a4..e05f54571 100644 --- a/apps/governance/src/routes/proposals/proposal/proposal-container.spec.tsx +++ b/apps/governance/src/routes/proposals/proposal/proposal-container.spec.tsx @@ -6,6 +6,11 @@ import { MockedProvider } from '@apollo/client/testing'; import { MemoryRouter, Route, Routes } from 'react-router-dom'; import { ProposalDocument } from './__generated__/Proposal'; +jest.mock('@vegaprotocol/data-provider', () => ({ + ...jest.requireActual('@vegaprotocol/data-provider'), + useDataProvider: jest.fn(() => ({ data: [], loading: false })), +})); + jest.mock('../components/proposal', () => ({ Proposal: () =>
, })); diff --git a/apps/trading/components/welcome-dialog/get-started.tsx b/apps/trading/components/welcome-dialog/get-started.tsx index faa825cf2..1b14435e1 100644 --- a/apps/trading/components/welcome-dialog/get-started.tsx +++ b/apps/trading/components/welcome-dialog/get-started.tsx @@ -27,8 +27,8 @@ const GetStartedButton = ({ step }: { step: OnboardingStep }) => { const dismiss = useOnboardingStore((store) => store.dismiss); const setDialogOpen = useOnboardingStore((store) => store.setDialogOpen); const marketId = useGlobalStore((store) => store.marketId); - const openVegaWalletDialog = useVegaWalletDialogStore( - (store) => store.openVegaWalletDialog + const setWalletDialogOpen = useOnboardingStore( + (store) => store.setWalletDialogOpen ); const setViews = useSidebar((store) => store.setViews); @@ -40,7 +40,7 @@ const GetStartedButton = ({ step }: { step: OnboardingStep }) => { if (step <= OnboardingStep.ONBOARDING_CONNECT_STEP) { return ( - openVegaWalletDialog()}> + setWalletDialogOpen(true)}> {t('Connect')} ); @@ -70,7 +70,7 @@ const GetStartedButton = ({ step }: { step: OnboardingStep }) => { } return ( - openVegaWalletDialog()}> + setWalletDialogOpen(true)}> {t('Get started')} ); diff --git a/apps/trading/components/welcome-dialog/use-get-onboarding-step.ts b/apps/trading/components/welcome-dialog/use-get-onboarding-step.ts index 3f90fa82b..46ad65d8e 100644 --- a/apps/trading/components/welcome-dialog/use-get-onboarding-step.ts +++ b/apps/trading/components/welcome-dialog/use-get-onboarding-step.ts @@ -12,16 +12,20 @@ import { useGlobalStore } from '../../stores'; const ONBOARDING_STORAGE_KEY = 'vega_onboarding'; export const useOnboardingStore = create<{ dialogOpen: boolean; + walletDialogOpen: boolean; dismissed: boolean; dismiss: () => void; setDialogOpen: (isOpen: boolean) => void; + setWalletDialogOpen: (isOpen: boolean) => void; }>()( persist( (set) => ({ dialogOpen: true, + walletDialogOpen: false, dismissed: false, dismiss: () => set({ dismissed: true }), setDialogOpen: (isOpen) => set({ dialogOpen: isOpen }), + setWalletDialogOpen: (isOpen) => set({ walletDialogOpen: isOpen }), }), { name: ONBOARDING_STORAGE_KEY, diff --git a/apps/trading/components/welcome-dialog/welcome-dialog.tsx b/apps/trading/components/welcome-dialog/welcome-dialog.tsx index 0e40e7333..340bd0e7f 100644 --- a/apps/trading/components/welcome-dialog/welcome-dialog.tsx +++ b/apps/trading/components/welcome-dialog/welcome-dialog.tsx @@ -3,30 +3,54 @@ import { t } from '@vegaprotocol/i18n'; import { useEnvironment } from '@vegaprotocol/environment'; import { WelcomeDialogContent } from './welcome-dialog-content'; import { useOnboardingStore } from './use-get-onboarding-step'; +import { VegaConnectDialog } from '@vegaprotocol/wallet'; +import { Connectors } from '../../lib/vega-connectors'; +import { RiskMessage } from './risk-message'; export const WelcomeDialog = () => { const { VEGA_ENV } = useEnvironment(); const dismissed = useOnboardingStore((store) => store.dismissed); const dialogOpen = useOnboardingStore((store) => store.dialogOpen); const dismiss = useOnboardingStore((store) => store.dismiss); + const walletDialogOpen = useOnboardingStore( + (store) => store.walletDialogOpen + ); + const setWalletDialogOpen = useOnboardingStore( + (store) => store.setWalletDialogOpen + ); + + const content = walletDialogOpen ? ( + } + onClose={() => setWalletDialogOpen(false)} + contentOnly + /> + ) : ( + + ); + + const onClose = walletDialogOpen ? () => setWalletDialogOpen(false) : dismiss; + + const title = walletDialogOpen ? null : ( + + {t('Console')}{' '} + + {VEGA_ENV} + + + ); return ( - {t('Console')}{' '} - - {VEGA_ENV} - - - } + title={title} size="medium" - onChange={() => dismiss()} + onChange={onClose} intent={Intent.None} dataTestId="welcome-dialog" > - + {content} ); }; diff --git a/libs/wallet/src/connect-dialog/connect-dialog.tsx b/libs/wallet/src/connect-dialog/connect-dialog.tsx index ab10380ae..9fb81a5d9 100644 --- a/libs/wallet/src/connect-dialog/connect-dialog.tsx +++ b/libs/wallet/src/connect-dialog/connect-dialog.tsx @@ -50,11 +50,15 @@ export type WalletType = 'injected' | 'jsonRpc' | 'view' | 'snap'; export interface VegaConnectDialogProps { connectors: Connectors; riskMessage?: ReactNode; + contentOnly?: boolean; + onClose?: () => void; } export const VegaConnectDialog = ({ connectors, riskMessage, + contentOnly, + onClose, }: VegaConnectDialogProps) => { const { disconnect, acknowledgeNeeded } = useVegaWallet(); const vegaWalletDialogOpen = useVegaWalletDialogStore( @@ -80,19 +84,24 @@ export const VegaConnectDialog = ({ // This value will already be in the cache, if it failed the app wont render const { data } = useChainIdQuery(); + const content = data && ( + + ); + if (contentOnly) { + return content; + } return ( - {data && ( - - )} + {content} ); }; @@ -101,15 +110,20 @@ const ConnectDialogContainer = ({ connectors, appChainId, riskMessage, + onClose, }: { connectors: Connectors; appChainId: string; riskMessage?: ReactNode; + onClose?: () => void; }) => { const { vegaUrl, vegaWalletServiceUrl } = useVegaWallet(); - const closeDialog = useVegaWalletDialogStore( + const closeVegaWalletDialog = useVegaWalletDialogStore( (store) => store.closeVegaWalletDialog ); + const closeDialog = useCallback(() => { + onClose ? onClose() : closeVegaWalletDialog(); + }, [closeVegaWalletDialog, onClose]); const [selectedConnector, setSelectedConnector] = useState(); const [walletUrl, setWalletUrl] = useState(vegaWalletServiceUrl); @@ -254,7 +268,7 @@ const ConnectorList = ({ } description={t( - `Connect Vega Wallet extension + `Connect with Vega Wallet extension for %s to access all features including key management and detailed transaction views from your browser.`, @@ -286,8 +300,18 @@ const ConnectorList = ({ {connectors['snap'] !== undefined ? (
{snapStatus === SnapStatus.INSTALLED ? ( - + {t('Metamask Snap')} + {' '} + {t('quick start')} + + } + description={t( + `Connect directly via Metamask with the Vega Snap for single key support without advanced features.` + )} text={ <>
@@ -315,7 +339,7 @@ const ConnectorList = ({ } description={t( - `Connect directly via Metamask with the Vega Snap for single key support without advanced features.` + `Install Metamask with the Vega Snap for single key support without advanced features.` )} text={ <> From 79cbe62774ad564c27713d473251a3e65870135f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Szpiech?= Date: Fri, 29 Sep 2023 17:00:20 +0200 Subject: [PATCH 06/37] chore(ci): add mainnet compatible runner to release mainnet branch push actions (#4939) --- .github/workflows/cypress-run.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/cypress-run.yml b/.github/workflows/cypress-run.yml index c69ff6edd..f0829df38 100644 --- a/.github/workflows/cypress-run.yml +++ b/.github/workflows/cypress-run.yml @@ -23,10 +23,15 @@ jobs: run: | if [ ${{ github.base_ref }} == 'main' ]; then echo "runner=mainnet-compatible-runner" >> $GITHUB_OUTPUT + elif [ ${{ github.event_name }} == 'push' ] && [ ${{ contains(github.ref_name, 'release/mainnet') }} ]; then + echo "runner=mainnet-compatible-runner" >> $GITHUB_OUTPUT else echo "runner=self-hosted-runner" >> $GITHUB_OUTPUT fi + - name: Print runner + run: echo ${{ steps.step.outputs.runner }} + e2e: strategy: fail-fast: false From 30da1663eb43504ba2b75a35bd478e9559d56699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Szpiech?= Date: Fri, 29 Sep 2023 17:36:18 +0200 Subject: [PATCH 07/37] chore(ci): add main develop merge condition to runner (#4941) --- .github/workflows/cypress-run.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/cypress-run.yml b/.github/workflows/cypress-run.yml index f0829df38..150d4b199 100644 --- a/.github/workflows/cypress-run.yml +++ b/.github/workflows/cypress-run.yml @@ -23,6 +23,8 @@ jobs: run: | if [ ${{ github.base_ref }} == 'main' ]; then echo "runner=mainnet-compatible-runner" >> $GITHUB_OUTPUT + elif [ ${{ github.base_ref }} == 'develop' ] && [ ${{ github.ref_name }} == 'main' ]; then + echo "runner=mainnet-compatible-runner" >> $GITHUB_OUTPUT elif [ ${{ github.event_name }} == 'push' ] && [ ${{ contains(github.ref_name, 'release/mainnet') }} ]; then echo "runner=mainnet-compatible-runner" >> $GITHUB_OUTPUT else From acf1d50d0f47e22bf32837094c91d6fdd411c0e0 Mon Sep 17 00:00:00 2001 From: Edd Date: Fri, 29 Sep 2023 17:29:16 +0100 Subject: [PATCH 08/37] chore(explorer): ignore errors on oracle page (#4944) --- apps/explorer/src/app/routes/oracles/home/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/explorer/src/app/routes/oracles/home/index.tsx b/apps/explorer/src/app/routes/oracles/home/index.tsx index d088a0a47..ebcb92344 100644 --- a/apps/explorer/src/app/routes/oracles/home/index.tsx +++ b/apps/explorer/src/app/routes/oracles/home/index.tsx @@ -8,7 +8,9 @@ import { useScrollToLocation } from '../../../hooks/scroll-to-location'; import filter from 'recursive-key-filter'; const Oracles = () => { - const { data, loading, error } = useExplorerOracleSpecsQuery(); + const { data, loading, error } = useExplorerOracleSpecsQuery({ + errorPolicy: 'ignore', + }); useDocumentTitle(['Oracles']); useScrollToLocation(); From abb771e2f9d9322e90a159a51234245035ed1134 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Szpiech?= Date: Mon, 2 Oct 2023 14:29:59 +0200 Subject: [PATCH 09/37] chore(ci): add conditions to run e2e tests (#4946) --- .github/workflows/ci-cd-trigger.yml | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-cd-trigger.yml b/.github/workflows/ci-cd-trigger.yml index ac5f65f8b..5fe246392 100644 --- a/.github/workflows/ci-cd-trigger.yml +++ b/.github/workflows/ci-cd-trigger.yml @@ -5,6 +5,7 @@ on: branches: - release/* - develop + - main pull_request: types: - opened @@ -176,10 +177,33 @@ jobs: # with: # github-sha: ${{ github.event.pull_request.head.sha || github.sha }} - cypress: + check-e2e-needed: + runs-on: ubuntu-latest needs: build-sources + name: '(CI) check if e2e needed' + outputs: + run-tests: ${{ steps.check-test.outputs.e2e-needed }} + steps: + - name: Check branch + id: check-test + run: | + if [ ${{ github.base_ref }} == 'develop' ]; then + echo "e2e-needed=true" >> $GITHUB_OUTPUT + elif [ ${{ github.base_ref }} == 'main' ]; then + echo "e2e-needed=true" >> $GITHUB_OUTPUT + elif [ ${{ github.event_name }} == 'push' ] && [ ${{ contains(github.ref_name, 'release/') }} ]; then + echo "e2e-needed=true" >> $GITHUB_OUTPUT + else + echo "e2e-needed=false" >> $GITHUB_OUTPUT + fi + - name: Print result + run: | + echo "e2e-needed: ${{ steps.check-test.outputs.e2e-needed }}" + + cypress: + needs: [build-sources, check-e2e-needed] name: '(CI) cypress' - # if: ${{ needs.build-sources.outputs.projects-e2e != '[]' }} + if: ${{ needs.check-e2e-needed.outputs.run-tests == 'true' }} uses: ./.github/workflows/cypress-run.yml secrets: inherit with: From 13817e4d57676c3bcc653e64b8c48d97e547c2db Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 2 Oct 2023 14:57:54 +0100 Subject: [PATCH 10/37] chore(trading): delete duplicate asset details test (#4954) --- .../src/integration/trading-accounts.cy.ts | 42 ------------------- .../src/lib/asset-details-dialog.spec.tsx | 14 +++++++ 2 files changed, 14 insertions(+), 42 deletions(-) diff --git a/apps/trading-e2e/src/integration/trading-accounts.cy.ts b/apps/trading-e2e/src/integration/trading-accounts.cy.ts index 14cee0cbd..d559dd5d9 100644 --- a/apps/trading-e2e/src/integration/trading-accounts.cy.ts +++ b/apps/trading-e2e/src/integration/trading-accounts.cy.ts @@ -64,48 +64,6 @@ describe('accounts', { tags: '@smoke' }, () => { cy.getByTestId('Collateral').click({ force: true }); }); - it('should open asset details dialog when clicked on symbol', () => { - // 7001-COLL-008 - // 6501-ASSE-001 - // 6501-ASSE-002 - // 6501-ASSE-003 - // 6501-ASSE-004 - // 6501-ASSE-005 - // 6501-ASSE-006 - // 6501-ASSE-007 - // 6501-ASSE-008 - // 6501-ASSE-009 - // 6501-ASSE-010 - // 6501-ASSE-011 - // 6501-ASSE-012 - // 6501-ASSE-013 - const titles = [ - 'ID', - 'Type', - 'Name', - 'Symbol', - 'Decimals', - 'Quantum', - 'Status', - 'Contract address', - 'Withdrawal threshold', - 'Lifetime limit', - 'Infrastructure fee account balance', - 'Global reward pool account balance', - 'Maker paid fees account balance', - 'Maker received fees account balance', - 'Liquidity provision fee reward account balance', - 'Market proposer reward account balance', - ]; - cy.get('[col-id="asset.symbol"]').contains('tEURO').click(); - cy.get('[data-testid$="_label"]').should('have.length', 16); - cy.get('[data-testid$="_label"]').each((element, index) => { - cy.wrap(element).should('have.text', titles[index]); - }); - cy.getByTestId(dialogClose).click(); - cy.getByTestId(dialogClose).should('not.exist'); - }); - it('should open usage breakdown dialog when clicked on used', () => { // 7001-COLL-009 cy.get('[col-id="used"]').contains('1.01').click(); diff --git a/libs/assets/src/lib/asset-details-dialog.spec.tsx b/libs/assets/src/lib/asset-details-dialog.spec.tsx index 3d080abf2..124401b44 100644 --- a/libs/assets/src/lib/asset-details-dialog.spec.tsx +++ b/libs/assets/src/lib/asset-details-dialog.spec.tsx @@ -62,6 +62,20 @@ const WrappedAssetDetailsDialog = ({ assetId }: { assetId: string }) => ( ); describe('AssetDetailsDialog', () => { + // 7001-COLL-008 + // 6501-ASSE-001 + // 6501-ASSE-002 + // 6501-ASSE-003 + // 6501-ASSE-004 + // 6501-ASSE-005 + // 6501-ASSE-006 + // 6501-ASSE-007 + // 6501-ASSE-008 + // 6501-ASSE-009 + // 6501-ASSE-010 + // 6501-ASSE-011 + // 6501-ASSE-012 + // 6501-ASSE-013 it('should show no data message given unknown asset symbol', async () => { render(); expect((await screen.findByTestId('splash')).textContent).toContain( From 8b249e191752c307fcd6c3b7ab5d8235a44d8d42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Szpiech?= Date: Mon, 2 Oct 2023 16:12:24 +0200 Subject: [PATCH 11/37] chore(ci): fix some minor issues in workflows (#4953) --- .github/workflows/ci-cd-trigger.yml | 2 +- .github/workflows/cypress-run.yml | 5 +++-- .github/workflows/publish-dist.yml | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-cd-trigger.yml b/.github/workflows/ci-cd-trigger.yml index 5fe246392..d1753a0c9 100644 --- a/.github/workflows/ci-cd-trigger.yml +++ b/.github/workflows/ci-cd-trigger.yml @@ -191,7 +191,7 @@ jobs: echo "e2e-needed=true" >> $GITHUB_OUTPUT elif [ ${{ github.base_ref }} == 'main' ]; then echo "e2e-needed=true" >> $GITHUB_OUTPUT - elif [ ${{ github.event_name }} == 'push' ] && [ ${{ contains(github.ref_name, 'release/') }} ]; then + elif [[ ${{ github.event_name }} == 'push' && ${{ contains(github.ref_name, 'release/') }} ]]; then echo "e2e-needed=true" >> $GITHUB_OUTPUT else echo "e2e-needed=false" >> $GITHUB_OUTPUT diff --git a/.github/workflows/cypress-run.yml b/.github/workflows/cypress-run.yml index 150d4b199..deae2ae7b 100644 --- a/.github/workflows/cypress-run.yml +++ b/.github/workflows/cypress-run.yml @@ -23,9 +23,9 @@ jobs: run: | if [ ${{ github.base_ref }} == 'main' ]; then echo "runner=mainnet-compatible-runner" >> $GITHUB_OUTPUT - elif [ ${{ github.base_ref }} == 'develop' ] && [ ${{ github.ref_name }} == 'main' ]; then + elif [[ ${{ github.base_ref }} == 'develop' && ${{ github.ref_name }} == 'main' ]]; then echo "runner=mainnet-compatible-runner" >> $GITHUB_OUTPUT - elif [ ${{ github.event_name }} == 'push' ] && [ ${{ contains(github.ref_name, 'release/mainnet') }} ]; then + elif [[ ${{ github.event_name }} == 'push' && ${{ contains(github.ref_name, 'release/mainnet') }} ]]; then echo "runner=mainnet-compatible-runner" >> $GITHUB_OUTPUT else echo "runner=self-hosted-runner" >> $GITHUB_OUTPUT @@ -85,6 +85,7 @@ jobs: - name: Run Vegacapsule network and Vega wallet id: setup-vega uses: ./frontend-monorepo/.github/actions/run-vegacapsule + timeout-minutes: 10 ###### ## Run some tests diff --git a/.github/workflows/publish-dist.yml b/.github/workflows/publish-dist.yml index f4ef0d7fc..622d25b71 100644 --- a/.github/workflows/publish-dist.yml +++ b/.github/workflows/publish-dist.yml @@ -63,7 +63,7 @@ jobs: echo IS_IPFS_RELEASE=true >> $GITHUB_ENV - name: Is S3 Release - if: ${{ env.IS_IPFS_RELEASE == 'false' && github.event_name == 'push' }} + if: ${{ env.IS_IPFS_RELEASE == 'false' && github.event_name == 'push' && github.ref_name != 'main'}} run: | echo IS_S3_RELEASE=true >> $GITHUB_ENV @@ -195,7 +195,7 @@ jobs: ENV_NAME=${{ env.ENV_NAME }} tags: | vegaprotocol/${{ matrix.app }}:${{ github.sha }} - vegaprotocol/${{ matrix.app }}:${{ env.IS_MAINNET_RELEASE == 'true' && 'mainnet' || env.IS_TESTNET_RELEASE == 'true' && 'testnet' || env.IS_DEV_IMAGE == 'true' && 'develop' || env.IS_MAIN_IMAGE == 'true && main' || '' }} + vegaprotocol/${{ matrix.app }}:${{ env.IS_MAINNET_RELEASE == 'true' && 'mainnet' || env.IS_TESTNET_RELEASE == 'true' && 'testnet' || env.IS_DEV_IMAGE == 'true' && 'develop' || env.IS_MAIN_IMAGE == 'true' && 'main' || '' }} - name: Publish dist as docker image (ghcr - retry) uses: docker/build-push-action@v3 @@ -222,7 +222,7 @@ jobs: ENV_NAME=${{ env.ENV_NAME }} tags: | vegaprotocol/${{ matrix.app }}:${{ github.sha }} - vegaprotocol/${{ matrix.app }}:${{ env.IS_MAINNET_RELEASE == 'true' && 'mainnet' || env.IS_TESTNET_RELEASE == 'true' && 'testnet' || env.IS_DEV_IMAGE == 'true' && 'develop' || env.IS_MAIN_IMAGE == 'true && main' || '' }} + vegaprotocol/${{ matrix.app }}:${{ env.IS_MAINNET_RELEASE == 'true' && 'mainnet' || env.IS_TESTNET_RELEASE == 'true' && 'testnet' || env.IS_DEV_IMAGE == 'true' && 'develop' || env.IS_MAIN_IMAGE == 'true' && 'main' || '' }} # bucket creation in github.com/vegaprotocol/terraform//frontend - name: Publish dist to s3 From 0872a14f44f21eafca3e9cc0e59903cbe7d1d37b Mon Sep 17 00:00:00 2001 From: Maciek Date: Mon, 2 Oct 2023 16:38:22 +0200 Subject: [PATCH 12/37] feat(positions): close position with max possible size (#4940) --- .../src/lib/positions-manager.spec.tsx | 39 +++++++++++++++++++ libs/positions/src/lib/positions-manager.tsx | 6 +-- .../src/lib/positions-table.spec.tsx | 28 +------------ libs/positions/src/lib/positions.mock.ts | 29 ++++++++++++++ libs/utils/src/index.ts | 1 + libs/utils/src/lib/constants.ts | 1 + 6 files changed, 74 insertions(+), 30 deletions(-) create mode 100644 libs/positions/src/lib/positions-manager.spec.tsx create mode 100644 libs/utils/src/lib/constants.ts diff --git a/libs/positions/src/lib/positions-manager.spec.tsx b/libs/positions/src/lib/positions-manager.spec.tsx new file mode 100644 index 000000000..2f02b6f8b --- /dev/null +++ b/libs/positions/src/lib/positions-manager.spec.tsx @@ -0,0 +1,39 @@ +import { render, screen, fireEvent } from '@testing-library/react'; +import { PositionsManager } from './positions-manager'; +import { positionsMarketsProvider } from './positions-data-providers'; +import { singleRow } from './positions.mock'; +import { MockedProvider } from '@apollo/client/testing'; +import { MAXGOINT64 } from '@vegaprotocol/utils'; + +const mockCreate = jest.fn(); +jest.mock('@vegaprotocol/wallet', () => ({ + ...jest.requireActual('@vegaprotocol/wallet'), + useVegaWallet: jest.fn(() => ({ pubKey: 'partyId' })), + useVegaTransactionStore: jest.fn(() => mockCreate), +})); +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const mockUseDataProvider = (args: any) => { + if (args.dataProvider === positionsMarketsProvider) { + return { data: ['market-1', 'market-2'] }; + } + return { data: [singleRow] }; +}; +jest.mock('@vegaprotocol/data-provider', () => ({ + ...jest.requireActual('@vegaprotocol/data-provider'), + useDataProvider: jest.fn((args) => mockUseDataProvider(args)), +})); + +describe('PositionsManager', () => { + it('should close position with max uint64', async () => { + render(, { + wrapper: MockedProvider, + }); + expect(await screen.getByTestId('close-position')).toBeInTheDocument(); + + fireEvent.click(screen.getByTestId('close-position')); + + expect( + mockCreate.mock.lastCall[0].batchMarketInstructions.submissions[0].size + ).toEqual(MAXGOINT64); + }); +}); diff --git a/libs/positions/src/lib/positions-manager.tsx b/libs/positions/src/lib/positions-manager.tsx index 521ae1b45..98bf332cc 100644 --- a/libs/positions/src/lib/positions-manager.tsx +++ b/libs/positions/src/lib/positions-manager.tsx @@ -1,7 +1,7 @@ import { useCallback } from 'react'; import { PositionsTable } from './positions-table'; import * as Schema from '@vegaprotocol/types'; -import { useVegaTransactionStore } from '@vegaprotocol/wallet'; +import { useVegaTransactionStore, useVegaWallet } from '@vegaprotocol/wallet'; import { t } from '@vegaprotocol/i18n'; import { useDataProvider } from '@vegaprotocol/data-provider'; import { @@ -9,7 +9,7 @@ import { positionsMarketsProvider, } from './positions-data-providers'; import type { useDataGridEvents } from '@vegaprotocol/datagrid'; -import { useVegaWallet } from '@vegaprotocol/wallet'; +import { MAXGOINT64 } from '@vegaprotocol/utils'; interface PositionsManagerProps { partyIds: string[]; @@ -46,7 +46,7 @@ export const PositionsManager = ({ side: openVolume.startsWith('-') ? Schema.Side.SIDE_BUY : Schema.Side.SIDE_SELL, - size: openVolume.replace('-', ''), + size: MAXGOINT64, // improvement for avoiding leftovers filled in the meantime when close request has been sent reduceOnly: true, }, ], diff --git a/libs/positions/src/lib/positions-table.spec.tsx b/libs/positions/src/lib/positions-table.spec.tsx index ed2aebf4c..ec6e619bc 100644 --- a/libs/positions/src/lib/positions-table.spec.tsx +++ b/libs/positions/src/lib/positions-table.spec.tsx @@ -6,6 +6,7 @@ import * as Schema from '@vegaprotocol/types'; import { PositionStatus } from '@vegaprotocol/types'; import type { ICellRendererParams } from 'ag-grid-community'; import { addDecimalsFormatNumber } from '@vegaprotocol/utils'; +import { singleRow } from './positions.mock'; jest.mock('./liquidation-price', () => ({ LiquidationPrice: () => ( @@ -13,33 +14,6 @@ jest.mock('./liquidation-price', () => ({ ), })); -const singleRow: Position = { - partyId: 'partyId', - assetId: 'asset-id', - assetSymbol: 'BTC', - averageEntryPrice: '133', - currentLeverage: 1.1, - assetDecimals: 2, // this is settlementAsset.decimals - quantum: '0.1', - lossSocializationAmount: '0', - marginAccountBalance: '12345600', - marketDecimalPlaces: 1, - marketId: 'string', - marketCode: 'ETHBTC.QM21', - marketTradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS, - marketState: Schema.MarketState.STATE_ACTIVE, - markPrice: '123', - notional: '12300', - openVolume: '100', - positionDecimalPlaces: 0, - realisedPNL: '123', - status: PositionStatus.POSITION_STATUS_UNSPECIFIED, - totalBalance: '123456', - unrealisedPNL: '456', - updatedAt: '2022-07-27T15:02:58.400Z', - productType: 'Future', -}; - describe('Positions', () => { const renderComponent = async (rowData: Position) => { await act(async () => { diff --git a/libs/positions/src/lib/positions.mock.ts b/libs/positions/src/lib/positions.mock.ts index 635eda23d..5d906402b 100644 --- a/libs/positions/src/lib/positions.mock.ts +++ b/libs/positions/src/lib/positions.mock.ts @@ -10,6 +10,8 @@ import type { MarginsQuery, MarginFieldsFragment, } from '@vegaprotocol/accounts'; +import type { Position } from './positions-data-providers'; +import * as Schema from '@vegaprotocol/types'; export const positionsQuery = ( override?: PartialDeep @@ -168,3 +170,30 @@ const marginsFields: MarginFieldsFragment[] = [ }, }, ]; + +export const singleRow: Position = { + partyId: 'partyId', + assetId: 'asset-id', + assetSymbol: 'BTC', + averageEntryPrice: '133', + currentLeverage: 1.1, + assetDecimals: 2, // this is settlementAsset.decimals + quantum: '0.1', + lossSocializationAmount: '0', + marginAccountBalance: '12345600', + marketDecimalPlaces: 1, + marketId: 'string', + marketCode: 'ETHBTC.QM21', + marketTradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS, + marketState: Schema.MarketState.STATE_ACTIVE, + markPrice: '123', + notional: '12300', + openVolume: '100', + positionDecimalPlaces: 0, + realisedPNL: '123', + status: PositionStatus.POSITION_STATUS_UNSPECIFIED, + totalBalance: '123456', + unrealisedPNL: '456', + updatedAt: '2022-07-27T15:02:58.400Z', + productType: 'Future', +}; diff --git a/libs/utils/src/index.ts b/libs/utils/src/index.ts index d1e76477f..7babb85f6 100644 --- a/libs/utils/src/index.ts +++ b/libs/utils/src/index.ts @@ -15,3 +15,4 @@ export * from './lib/time'; export * from './lib/validate'; export * from './lib/resolve-network-name'; export * from './lib/is-test-env'; +export * from './lib/constants'; diff --git a/libs/utils/src/lib/constants.ts b/libs/utils/src/lib/constants.ts new file mode 100644 index 000000000..718b3e46f --- /dev/null +++ b/libs/utils/src/lib/constants.ts @@ -0,0 +1 @@ +export const MAXGOINT64 = '9223372036854775807'; From 8efadda98c922ea2ef7293cb00c72893d834e2f0 Mon Sep 17 00:00:00 2001 From: "m.ray" <16125548+MadalinaRaicu@users.noreply.github.com> Date: Mon, 2 Oct 2023 18:00:55 +0300 Subject: [PATCH 13/37] fix(trading): remove market value proxy and formatting (#4916) --- .../explorer-e2e/src/integration/market.cy.js | 8 +- .../liquidity-header/liquidity-header.tsx | 10 +- .../market-selector-item.spec.tsx | 1 - .../market-selector/market-selector.tsx | 6 +- libs/deal-ticket/src/test-helpers.ts | 3 + libs/fills/src/lib/test-helpers.ts | 3 + .../src/lib/__generated__/market-data.ts | 10 +- libs/markets/src/lib/__generated__/markets.ts | 7 +- .../market-info/market-info-panels.spec.tsx | 398 +++++++++--------- .../market-info/market-info-panels.tsx | 7 +- libs/markets/src/lib/market-data.graphql | 2 - libs/markets/src/lib/market-data.mock.ts | 2 - libs/markets/src/lib/markets.graphql | 3 + libs/markets/src/lib/markets.mock.ts | 3 + .../lib/components/mocks/generate-orders.ts | 3 + .../components/mocks/generate-stop-orders.ts | 3 + .../order-list/order-view-dialog.spec.tsx | 3 + .../src/lib/withdraw-form-container.spec.tsx | 3 + specs/6002-MDET-market-details.md | 1 - 19 files changed, 253 insertions(+), 223 deletions(-) diff --git a/apps/explorer-e2e/src/integration/market.cy.js b/apps/explorer-e2e/src/integration/market.cy.js index 7edabc633..301749e8e 100644 --- a/apps/explorer-e2e/src/integration/market.cy.js +++ b/apps/explorer-e2e/src/integration/market.cy.js @@ -87,7 +87,13 @@ context('Market page', { tags: '@regression' }, function () { // Liquidity cy.validate_element_from_table('Target Stake', '0.00 fUSDC'); cy.validate_element_from_table('Supplied Stake', '0.00 fUSDC'); - cy.validate_element_from_table('Market Value Proxy', '0.00 fUSDC'); + // Liquidity price range + cy.validate_element_from_table( + 'Liquidity Price Range', + '1,000.00% of mid price' + ); + cy.validate_element_from_table('Lowest Price', '0.00 fUSDC'); + cy.validate_element_from_table('Highest Price', '0.00 fUSDC'); cy.getByTestId('oracle-spec-links') .should('have.attr', 'href') .and( diff --git a/apps/trading/components/liquidity-header/liquidity-header.tsx b/apps/trading/components/liquidity-header/liquidity-header.tsx index 20f74ee9f..0863be127 100644 --- a/apps/trading/components/liquidity-header/liquidity-header.tsx +++ b/apps/trading/components/liquidity-header/liquidity-header.tsx @@ -12,10 +12,6 @@ import { import { t } from '@vegaprotocol/i18n'; import { ExternalLink, Indicator } from '@vegaprotocol/ui-toolkit'; import { DocsLinks } from '@vegaprotocol/environment'; -import { - NetworkParams, - useNetworkParams, -} from '@vegaprotocol/network-parameters'; import { useCheckLiquidityStatus } from '@vegaprotocol/liquidity'; import { useParams } from 'react-router-dom'; @@ -31,12 +27,8 @@ export const LiquidityHeader = () => { const assetDecimalPlaces = asset?.decimals || 0; const symbol = asset?.symbol; - const { params } = useNetworkParams([ - NetworkParams.market_liquidity_stakeToCcyVolume, - NetworkParams.market_liquidity_targetstake_triggering_ratio, - ]); const triggeringRatio = - params.market_liquidity_targetstake_triggering_ratio || '1'; + market?.liquidityMonitoringParameters.triggeringRatio || '1'; const { percentage, status } = useCheckLiquidityStatus({ suppliedStake: suppliedStake || 0, diff --git a/apps/trading/components/market-selector/market-selector-item.spec.tsx b/apps/trading/components/market-selector/market-selector-item.spec.tsx index ee97aac1c..6fa9c5692 100644 --- a/apps/trading/components/market-selector/market-selector-item.spec.tsx +++ b/apps/trading/components/market-selector/market-selector-item.spec.tsx @@ -61,7 +61,6 @@ describe('MarketSelectorItem', () => { indicativeVolume: '100', marketState: MarketState.STATE_ACTIVE, marketTradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, - marketValueProxy: '100', markPrice: '50000', midPrice: '100', staticMidPrice: '100', diff --git a/apps/trading/components/market-selector/market-selector.tsx b/apps/trading/components/market-selector/market-selector.tsx index 8e1c821fe..266ae6d82 100644 --- a/apps/trading/components/market-selector/market-selector.tsx +++ b/apps/trading/components/market-selector/market-selector.tsx @@ -126,10 +126,12 @@ export const MarketSelector = ({ onSelect={onSelect} noItems={ filter.product === Product.Perpetual - ? t('Perpetual markets coming soon.') + ? t('No perpetual markets.') : filter.product === Product.Spot ? t('Spot markets coming soon.') - : t('No markets') + : filter.product === Product.Future + ? t('No future markets.') + : t('No markets.') } allProducts={allProducts} /> diff --git a/libs/deal-ticket/src/test-helpers.ts b/libs/deal-ticket/src/test-helpers.ts index bce5e4006..6a4a408e7 100644 --- a/libs/deal-ticket/src/test-helpers.ts +++ b/libs/deal-ticket/src/test-helpers.ts @@ -11,6 +11,9 @@ export function generateMarket(override?: PartialDeep): Market { positionDecimalPlaces: 1, tradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS, state: Schema.MarketState.STATE_ACTIVE, + liquidityMonitoringParameters: { + triggeringRatio: '1', + }, marketTimestamps: { __typename: 'MarketTimestamps', close: '', diff --git a/libs/fills/src/lib/test-helpers.ts b/libs/fills/src/lib/test-helpers.ts index 2c45ce25b..febb37106 100644 --- a/libs/fills/src/lib/test-helpers.ts +++ b/libs/fills/src/lib/test-helpers.ts @@ -42,6 +42,9 @@ export const generateFill = (override?: PartialDeep) => { decimalPlaces: 5, state: MarketState.STATE_ACTIVE, tradingMode: MarketTradingMode.TRADING_MODE_CONTINUOUS, + liquidityMonitoringParameters: { + triggeringRatio: '1', + }, fees: { __typename: 'Fees', factors: { diff --git a/libs/markets/src/lib/__generated__/market-data.ts b/libs/markets/src/lib/__generated__/market-data.ts index 379e45b8d..4449a87ee 100644 --- a/libs/markets/src/lib/__generated__/market-data.ts +++ b/libs/markets/src/lib/__generated__/market-data.ts @@ -3,23 +3,23 @@ import * as Types from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; const defaultOptions = {} as const; -export type MarketDataUpdateFieldsFragment = { __typename?: 'ObservableMarketData', marketId: string, auctionEnd?: string | null, auctionStart?: string | null, bestBidPrice: string, bestBidVolume: string, bestOfferPrice: string, bestOfferVolume: string, bestStaticBidPrice: string, bestStaticBidVolume: string, bestStaticOfferPrice: string, bestStaticOfferVolume: string, indicativePrice: string, indicativeVolume: string, marketState: Types.MarketState, marketTradingMode: Types.MarketTradingMode, marketValueProxy: string, markPrice: string, midPrice: string, openInterest: string, staticMidPrice: string, suppliedStake?: string | null, targetStake?: string | null, trigger: Types.AuctionTrigger, lastTradedPrice: string, productData?: { __typename?: 'PerpetualData', fundingRate?: string | null, fundingPayment?: string | null, externalTwap?: string | null, internalTwap?: string | null } | null, priceMonitoringBounds?: Array<{ __typename?: 'PriceMonitoringBounds', minValidPrice: string, maxValidPrice: string, referencePrice: string, trigger: { __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number } }> | null }; +export type MarketDataUpdateFieldsFragment = { __typename?: 'ObservableMarketData', marketId: string, auctionEnd?: string | null, auctionStart?: string | null, bestBidPrice: string, bestBidVolume: string, bestOfferPrice: string, bestOfferVolume: string, bestStaticBidPrice: string, bestStaticBidVolume: string, bestStaticOfferPrice: string, bestStaticOfferVolume: string, indicativePrice: string, indicativeVolume: string, marketState: Types.MarketState, marketTradingMode: Types.MarketTradingMode, markPrice: string, midPrice: string, openInterest: string, staticMidPrice: string, suppliedStake?: string | null, targetStake?: string | null, trigger: Types.AuctionTrigger, lastTradedPrice: string, productData?: { __typename?: 'PerpetualData', fundingRate?: string | null, fundingPayment?: string | null, externalTwap?: string | null, internalTwap?: string | null } | null, priceMonitoringBounds?: Array<{ __typename?: 'PriceMonitoringBounds', minValidPrice: string, maxValidPrice: string, referencePrice: string, trigger: { __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number } }> | null }; export type MarketDataUpdateSubscriptionVariables = Types.Exact<{ marketId: Types.Scalars['ID']; }>; -export type MarketDataUpdateSubscription = { __typename?: 'Subscription', marketsData: Array<{ __typename?: 'ObservableMarketData', marketId: string, auctionEnd?: string | null, auctionStart?: string | null, bestBidPrice: string, bestBidVolume: string, bestOfferPrice: string, bestOfferVolume: string, bestStaticBidPrice: string, bestStaticBidVolume: string, bestStaticOfferPrice: string, bestStaticOfferVolume: string, indicativePrice: string, indicativeVolume: string, marketState: Types.MarketState, marketTradingMode: Types.MarketTradingMode, marketValueProxy: string, markPrice: string, midPrice: string, openInterest: string, staticMidPrice: string, suppliedStake?: string | null, targetStake?: string | null, trigger: Types.AuctionTrigger, lastTradedPrice: string, productData?: { __typename?: 'PerpetualData', fundingRate?: string | null, fundingPayment?: string | null, externalTwap?: string | null, internalTwap?: string | null } | null, priceMonitoringBounds?: Array<{ __typename?: 'PriceMonitoringBounds', minValidPrice: string, maxValidPrice: string, referencePrice: string, trigger: { __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number } }> | null }> }; +export type MarketDataUpdateSubscription = { __typename?: 'Subscription', marketsData: Array<{ __typename?: 'ObservableMarketData', marketId: string, auctionEnd?: string | null, auctionStart?: string | null, bestBidPrice: string, bestBidVolume: string, bestOfferPrice: string, bestOfferVolume: string, bestStaticBidPrice: string, bestStaticBidVolume: string, bestStaticOfferPrice: string, bestStaticOfferVolume: string, indicativePrice: string, indicativeVolume: string, marketState: Types.MarketState, marketTradingMode: Types.MarketTradingMode, markPrice: string, midPrice: string, openInterest: string, staticMidPrice: string, suppliedStake?: string | null, targetStake?: string | null, trigger: Types.AuctionTrigger, lastTradedPrice: string, productData?: { __typename?: 'PerpetualData', fundingRate?: string | null, fundingPayment?: string | null, externalTwap?: string | null, internalTwap?: string | null } | null, priceMonitoringBounds?: Array<{ __typename?: 'PriceMonitoringBounds', minValidPrice: string, maxValidPrice: string, referencePrice: string, trigger: { __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number } }> | null }> }; -export type MarketDataFieldsFragment = { __typename?: 'MarketData', auctionEnd?: string | null, auctionStart?: string | null, bestBidPrice: string, bestBidVolume: string, bestOfferPrice: string, bestOfferVolume: string, bestStaticBidPrice: string, bestStaticBidVolume: string, bestStaticOfferPrice: string, bestStaticOfferVolume: string, indicativePrice: string, indicativeVolume: string, marketState: Types.MarketState, marketTradingMode: Types.MarketTradingMode, marketValueProxy: string, markPrice: string, midPrice: string, openInterest: string, staticMidPrice: string, suppliedStake?: string | null, targetStake?: string | null, trigger: Types.AuctionTrigger, lastTradedPrice: string, market: { __typename?: 'Market', id: string }, productData?: { __typename?: 'PerpetualData', fundingRate?: string | null, fundingPayment?: string | null, externalTwap?: string | null, internalTwap?: string | null } | null, priceMonitoringBounds?: Array<{ __typename?: 'PriceMonitoringBounds', minValidPrice: string, maxValidPrice: string, referencePrice: string, trigger: { __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number } }> | null }; +export type MarketDataFieldsFragment = { __typename?: 'MarketData', auctionEnd?: string | null, auctionStart?: string | null, bestBidPrice: string, bestBidVolume: string, bestOfferPrice: string, bestOfferVolume: string, bestStaticBidPrice: string, bestStaticBidVolume: string, bestStaticOfferPrice: string, bestStaticOfferVolume: string, indicativePrice: string, indicativeVolume: string, marketState: Types.MarketState, marketTradingMode: Types.MarketTradingMode, markPrice: string, midPrice: string, openInterest: string, staticMidPrice: string, suppliedStake?: string | null, targetStake?: string | null, trigger: Types.AuctionTrigger, lastTradedPrice: string, market: { __typename?: 'Market', id: string }, productData?: { __typename?: 'PerpetualData', fundingRate?: string | null, fundingPayment?: string | null, externalTwap?: string | null, internalTwap?: string | null } | null, priceMonitoringBounds?: Array<{ __typename?: 'PriceMonitoringBounds', minValidPrice: string, maxValidPrice: string, referencePrice: string, trigger: { __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number } }> | null }; export type MarketDataQueryVariables = Types.Exact<{ marketId: Types.Scalars['ID']; }>; -export type MarketDataQuery = { __typename?: 'Query', marketsConnection?: { __typename?: 'MarketConnection', edges: Array<{ __typename?: 'MarketEdge', node: { __typename?: 'Market', data?: { __typename?: 'MarketData', auctionEnd?: string | null, auctionStart?: string | null, bestBidPrice: string, bestBidVolume: string, bestOfferPrice: string, bestOfferVolume: string, bestStaticBidPrice: string, bestStaticBidVolume: string, bestStaticOfferPrice: string, bestStaticOfferVolume: string, indicativePrice: string, indicativeVolume: string, marketState: Types.MarketState, marketTradingMode: Types.MarketTradingMode, marketValueProxy: string, markPrice: string, midPrice: string, openInterest: string, staticMidPrice: string, suppliedStake?: string | null, targetStake?: string | null, trigger: Types.AuctionTrigger, lastTradedPrice: string, market: { __typename?: 'Market', id: string }, productData?: { __typename?: 'PerpetualData', fundingRate?: string | null, fundingPayment?: string | null, externalTwap?: string | null, internalTwap?: string | null } | null, priceMonitoringBounds?: Array<{ __typename?: 'PriceMonitoringBounds', minValidPrice: string, maxValidPrice: string, referencePrice: string, trigger: { __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number } }> | null } | null } }> } | null }; +export type MarketDataQuery = { __typename?: 'Query', marketsConnection?: { __typename?: 'MarketConnection', edges: Array<{ __typename?: 'MarketEdge', node: { __typename?: 'Market', data?: { __typename?: 'MarketData', auctionEnd?: string | null, auctionStart?: string | null, bestBidPrice: string, bestBidVolume: string, bestOfferPrice: string, bestOfferVolume: string, bestStaticBidPrice: string, bestStaticBidVolume: string, bestStaticOfferPrice: string, bestStaticOfferVolume: string, indicativePrice: string, indicativeVolume: string, marketState: Types.MarketState, marketTradingMode: Types.MarketTradingMode, markPrice: string, midPrice: string, openInterest: string, staticMidPrice: string, suppliedStake?: string | null, targetStake?: string | null, trigger: Types.AuctionTrigger, lastTradedPrice: string, market: { __typename?: 'Market', id: string }, productData?: { __typename?: 'PerpetualData', fundingRate?: string | null, fundingPayment?: string | null, externalTwap?: string | null, internalTwap?: string | null } | null, priceMonitoringBounds?: Array<{ __typename?: 'PriceMonitoringBounds', minValidPrice: string, maxValidPrice: string, referencePrice: string, trigger: { __typename?: 'PriceMonitoringTrigger', horizonSecs: number, probability: number, auctionExtensionSecs: number } }> | null } | null } }> } | null }; export const MarketDataUpdateFieldsFragmentDoc = gql` fragment MarketDataUpdateFields on ObservableMarketData { @@ -46,7 +46,6 @@ export const MarketDataUpdateFieldsFragmentDoc = gql` indicativeVolume marketState marketTradingMode - marketValueProxy markPrice midPrice openInterest @@ -94,7 +93,6 @@ export const MarketDataFieldsFragmentDoc = gql` indicativeVolume marketState marketTradingMode - marketValueProxy markPrice midPrice openInterest diff --git a/libs/markets/src/lib/__generated__/markets.ts b/libs/markets/src/lib/__generated__/markets.ts index f787252ec..adb4597db 100644 --- a/libs/markets/src/lib/__generated__/markets.ts +++ b/libs/markets/src/lib/__generated__/markets.ts @@ -4,12 +4,12 @@ import { gql } from '@apollo/client'; import { FutureFragmentDoc, PerpetualFragmentDoc } from '../components/market-info/__generated__/MarketInfo'; import * as Apollo from '@apollo/client'; const defaultOptions = {} as const; -export type MarketFieldsFragment = { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, parentMarketID?: string | null, successorMarketID?: string | null, fees: { __typename?: 'Fees', factors: { __typename?: 'FeeFactors', makerFee: string, infrastructureFee: string, liquidityFee: string } }, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array | null }, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForTradingTermination: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecToFutureBinding', settlementDataProperty: string, tradingTerminationProperty: string } } | { __typename?: 'Perpetual', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForSettlementSchedule: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecPerpetualBinding', settlementDataProperty: string, settlementScheduleProperty: string } } | { __typename?: 'Spot' } } }, marketTimestamps: { __typename?: 'MarketTimestamps', open: any, close: any } }; +export type MarketFieldsFragment = { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, parentMarketID?: string | null, successorMarketID?: string | null, fees: { __typename?: 'Fees', factors: { __typename?: 'FeeFactors', makerFee: string, infrastructureFee: string, liquidityFee: string } }, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array | null }, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForTradingTermination: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecToFutureBinding', settlementDataProperty: string, tradingTerminationProperty: string } } | { __typename?: 'Perpetual', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForSettlementSchedule: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecPerpetualBinding', settlementDataProperty: string, settlementScheduleProperty: string } } | { __typename?: 'Spot' } } }, marketTimestamps: { __typename?: 'MarketTimestamps', open: any, close: any }, liquidityMonitoringParameters: { __typename?: 'LiquidityMonitoringParameters', triggeringRatio: string } }; export type MarketsQueryVariables = Types.Exact<{ [key: string]: never; }>; -export type MarketsQuery = { __typename?: 'Query', marketsConnection?: { __typename?: 'MarketConnection', edges: Array<{ __typename?: 'MarketEdge', node: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, parentMarketID?: string | null, successorMarketID?: string | null, fees: { __typename?: 'Fees', factors: { __typename?: 'FeeFactors', makerFee: string, infrastructureFee: string, liquidityFee: string } }, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array | null }, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForTradingTermination: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecToFutureBinding', settlementDataProperty: string, tradingTerminationProperty: string } } | { __typename?: 'Perpetual', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForSettlementSchedule: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecPerpetualBinding', settlementDataProperty: string, settlementScheduleProperty: string } } | { __typename?: 'Spot' } } }, marketTimestamps: { __typename?: 'MarketTimestamps', open: any, close: any } } }> } | null }; +export type MarketsQuery = { __typename?: 'Query', marketsConnection?: { __typename?: 'MarketConnection', edges: Array<{ __typename?: 'MarketEdge', node: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, parentMarketID?: string | null, successorMarketID?: string | null, fees: { __typename?: 'Fees', factors: { __typename?: 'FeeFactors', makerFee: string, infrastructureFee: string, liquidityFee: string } }, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array | null }, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForTradingTermination: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecToFutureBinding', settlementDataProperty: string, tradingTerminationProperty: string } } | { __typename?: 'Perpetual', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForSettlementSchedule: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecPerpetualBinding', settlementDataProperty: string, settlementScheduleProperty: string } } | { __typename?: 'Spot' } } }, marketTimestamps: { __typename?: 'MarketTimestamps', open: any, close: any }, liquidityMonitoringParameters: { __typename?: 'LiquidityMonitoringParameters', triggeringRatio: string } } }> } | null }; export const MarketFieldsFragmentDoc = gql` fragment MarketFields on Market { @@ -49,6 +49,9 @@ export const MarketFieldsFragmentDoc = gql` open close } + liquidityMonitoringParameters { + triggeringRatio + } } ${FutureFragmentDoc} ${PerpetualFragmentDoc}`; diff --git a/libs/markets/src/lib/components/market-info/market-info-panels.spec.tsx b/libs/markets/src/lib/components/market-info/market-info-panels.spec.tsx index 98d8aa390..12db84607 100644 --- a/libs/markets/src/lib/components/market-info/market-info-panels.spec.tsx +++ b/libs/markets/src/lib/components/market-info/market-info-panels.spec.tsx @@ -6,226 +6,234 @@ import { import { DataSourceProof, SuccessionLineInfoPanel } from './market-info-panels'; import { MockedProvider } from '@apollo/react-testing'; import { SuccessorMarketIdsDocument } from '../../__generated__'; +import { getDateTimeFormat } from '@vegaprotocol/utils'; jest.mock('../../hooks/use-oracle-markets', () => ({ useOracleMarkets: () => [], })); -describe('DataSourceProof', () => { - const ORACLE_PUBKEY = - '69464e35bcb8e8a2900ca0f87acaf252d50cf2ab2fc73694845a16b7c8a0dc6f'; +describe('MarketInfoPanels', () => { + describe('DataSourceProof', () => { + const ORACLE_PUBKEY = + '69464e35bcb8e8a2900ca0f87acaf252d50cf2ab2fc73694845a16b7c8a0dc6f'; - it('renders message if there are no providers', () => { - const props = { - data: { - sourceType: { - __typename: 'DataSourceDefinitionExternal' as const, + it('renders message if there are no providers', () => { + const props = { + data: { sourceType: { - __typename: 'DataSourceSpecConfiguration' as const, - signers: [ - { - __typename: 'Signer' as const, - signer: { - __typename: 'PubKey' as const, - key: ORACLE_PUBKEY, + __typename: 'DataSourceDefinitionExternal' as const, + sourceType: { + __typename: 'DataSourceSpecConfiguration' as const, + signers: [ + { + __typename: 'Signer' as const, + signer: { + __typename: 'PubKey' as const, + key: ORACLE_PUBKEY, + }, }, - }, - ], + ], + }, }, }, - }, - providers: [], - type: 'termination' as const, - }; - render(); - expect( - screen.getByText('No oracle proof for termination') - ).toBeInTheDocument(); - }); + providers: [], + type: 'termination' as const, + }; + render(); + expect( + screen.getByText('No oracle proof for termination') + ).toBeInTheDocument(); + }); - it('renders message if there are no matching proofs', () => { - const props = { - data: { - sourceType: { - __typename: 'DataSourceDefinitionExternal' as const, + it('renders message if there are no matching proofs', () => { + const props = { + data: { sourceType: { - __typename: 'DataSourceSpecConfiguration' as const, - signers: [ - { - __typename: 'Signer' as const, - signer: { - __typename: 'PubKey' as const, - key: ORACLE_PUBKEY, + __typename: 'DataSourceDefinitionExternal' as const, + sourceType: { + __typename: 'DataSourceSpecConfiguration' as const, + signers: [ + { + __typename: 'Signer' as const, + signer: { + __typename: 'PubKey' as const, + key: ORACLE_PUBKEY, + }, }, - }, - ], + ], + }, }, }, - }, - providers: [ - { - name: 'Another oracle', - url: 'https://zombo.com', - description_markdown: - 'Some markdown describing the oracle provider.\n\nTwitter: @FacesPics2\n', - oracle: { - status: 'GOOD' as const, - status_reason: '', - first_verified: '2022-01-01T00:00:00.000Z', - last_verified: '2022-12-31T00:00:00.000Z', - type: 'public_key' as const, - public_key: 'not-the-pubkey', - }, - proofs: [ - { - format: 'signed_message' as const, - available: true, + providers: [ + { + name: 'Another oracle', + url: 'https://zombo.com', + description_markdown: + 'Some markdown describing the oracle provider.\n\nTwitter: @FacesPics2\n', + oracle: { + status: 'GOOD' as const, + status_reason: '', + first_verified: '2022-01-01T00:00:00.000Z', + last_verified: '2022-12-31T00:00:00.000Z', type: 'public_key' as const, public_key: 'not-the-pubkey', - message: 'SOMEHEX', }, - ], - github_link: `https://github.com/vegaprotocol/well-known/blob/main/oracle-providers/PubKey-${ORACLE_PUBKEY}.toml`, - }, - ], - type: 'settlementData' as const, - }; - render(); - expect( - screen.getByText('No oracle proof for settlement data') - ).toBeInTheDocument(); - }); - - it('renders message if no data source on market', () => { - const props = { - data: { - sourceType: { - __typename: 'Invalid', - }, - }, - providers: [], - type: 'termination' as const, - }; - // @ts-ignore types are invalid - render(); - expect(screen.getByText('Invalid data source')).toBeInTheDocument(); - }); - - it('renders conditions for internal data sources', () => { - const condition = { - __typename: 'Condition' as const, - operator: ConditionOperator.OPERATOR_GREATER_THAN, - value: '100', - }; - const props = { - data: { - sourceType: { - __typename: 'DataSourceDefinitionInternal' as const, - sourceType: { - __typename: 'DataSourceSpecConfigurationTime' as const, - conditions: [condition], - }, - }, - }, - providers: [], - type: 'termination' as const, - }; - render(); - expect(screen.getByText('Internal conditions')).toBeInTheDocument(); - expect( - screen.getByText( - `${ConditionOperatorMapping[condition.operator]} ${condition.value}` - ) - ).toBeInTheDocument(); - }); -}); - -describe('SuccessionLineInfoPanel', () => { - const mocks = [ - { - request: { - query: SuccessorMarketIdsDocument, - }, - result: { - data: { - __typename: 'Query', - marketsConnection: { - __typename: 'MarketConnection', - edges: [ + proofs: [ { - __typename: 'MarketEdge', - node: { - __typename: 'Market', - id: 'abc', - successorMarketID: 'def', - parentMarketID: null, - }, - }, - { - __typename: 'MarketEdge', - node: { - __typename: 'Market', - id: 'def', - successorMarketID: 'ghi', - parentMarketID: 'abc', - }, - }, - { - __typename: 'MarketEdge', - node: { - __typename: 'Market', - id: 'ghi', - successorMarketID: null, - parentMarketID: 'def', - }, + format: 'signed_message' as const, + available: true, + type: 'public_key' as const, + public_key: 'not-the-pubkey', + message: 'SOMEHEX', }, ], + github_link: `https://github.com/vegaprotocol/well-known/blob/main/oracle-providers/PubKey-${ORACLE_PUBKEY}.toml`, + }, + ], + type: 'settlementData' as const, + }; + render(); + expect( + screen.getByText('No oracle proof for settlement data') + ).toBeInTheDocument(); + }); + + it('renders message if no data source on market', () => { + const props = { + data: { + sourceType: { + __typename: 'Invalid', + }, + }, + providers: [], + type: 'termination' as const, + }; + // @ts-ignore types are invalid + render(); + expect(screen.getByText('Invalid data source')).toBeInTheDocument(); + }); + + it('renders conditions for internal data sources', () => { + const condition = { + __typename: 'Condition' as const, + operator: ConditionOperator.OPERATOR_GREATER_THAN, + value: '1696238009', + }; + const props = { + data: { + sourceType: { + __typename: 'DataSourceDefinitionInternal' as const, + sourceType: { + __typename: 'DataSourceSpecConfigurationTime' as const, + conditions: [condition], + }, + }, + }, + providers: [], + type: 'termination' as const, + }; + render(); + expect(screen.getByText('Internal conditions')).toBeInTheDocument(); + const dateFromUnixTimestamp = condition.value + ? getDateTimeFormat().format(new Date(parseInt(condition.value))) + : '-'; + expect( + screen.getByText( + `${ + ConditionOperatorMapping[condition.operator] + } ${dateFromUnixTimestamp}` + ) + ).toBeInTheDocument(); + }); + }); + + describe('SuccessionLineInfoPanel', () => { + const mocks = [ + { + request: { + query: SuccessorMarketIdsDocument, + }, + result: { + data: { + __typename: 'Query', + marketsConnection: { + __typename: 'MarketConnection', + edges: [ + { + __typename: 'MarketEdge', + node: { + __typename: 'Market', + id: 'abc', + successorMarketID: 'def', + parentMarketID: null, + }, + }, + { + __typename: 'MarketEdge', + node: { + __typename: 'Market', + id: 'def', + successorMarketID: 'ghi', + parentMarketID: 'abc', + }, + }, + { + __typename: 'MarketEdge', + node: { + __typename: 'Market', + id: 'ghi', + successorMarketID: null, + parentMarketID: 'def', + }, + }, + ], + }, }, }, }, - }, - ]; + ]; - it.each([ - ['abc', 1], - ['def', 2], - ['ghi', 3], - ])( - 'renders succession line for %s (current position %d)', - async (id, number) => { - render( - - - - ); + it.each([ + ['abc', 1], + ['def', 2], + ['ghi', 3], + ])( + 'renders succession line for %s (current position %d)', + async (id, number) => { + render( + + + + ); - await waitFor(() => { - const items = screen.getAllByTestId('succession-line-item'); - expect(items.length).toBe(3); - expect( - items[0].querySelector( - '[data-testid="succession-line-item-market-id"]' - )?.textContent - ).toBe('abc'); - expect( - items[1].querySelector( - '[data-testid="succession-line-item-market-id"]' - )?.textContent - ).toBe('def'); - expect( - items[2].querySelector( - '[data-testid="succession-line-item-market-id"]' - )?.textContent - ).toBe('ghi'); + await waitFor(() => { + const items = screen.getAllByTestId('succession-line-item'); + expect(items.length).toBe(3); + expect( + items[0].querySelector( + '[data-testid="succession-line-item-market-id"]' + )?.textContent + ).toBe('abc'); + expect( + items[1].querySelector( + '[data-testid="succession-line-item-market-id"]' + )?.textContent + ).toBe('def'); + expect( + items[2].querySelector( + '[data-testid="succession-line-item-market-id"]' + )?.textContent + ).toBe('ghi'); - expect( - items[number - 1].querySelector('[data-testid="icon-bullet"]') - ).toBeInTheDocument(); - }); - } - ); + expect( + items[number - 1].querySelector('[data-testid="icon-bullet"]') + ).toBeInTheDocument(); + }); + } + ); + }); }); diff --git a/libs/markets/src/lib/components/market-info/market-info-panels.tsx b/libs/markets/src/lib/components/market-info/market-info-panels.tsx index 4be9e15bd..aac443bdf 100644 --- a/libs/markets/src/lib/components/market-info/market-info-panels.tsx +++ b/libs/markets/src/lib/components/market-info/market-info-panels.tsx @@ -858,7 +858,6 @@ export const LiquidityInfoPanel = ({ market, children }: MarketInfoProps) => { data={{ targetStake: data?.targetStake, suppliedStake: data?.suppliedStake, - marketValueProxy: data?.marketValueProxy, }} decimalPlaces={asset.decimals} assetSymbol={asset.symbol} @@ -1033,9 +1032,13 @@ export const DataSourceProof = ({

{t('Internal conditions')}

{data.sourceType.sourceType?.conditions?.map((condition, i) => { if (!condition) return null; + const dateFromUnixTimestamp = condition.value + ? getDateTimeFormat().format(new Date(parseInt(condition.value))) + : '-'; return (

- {ConditionOperatorMapping[condition.operator]} {condition.value} + {ConditionOperatorMapping[condition.operator]}{' '} + {dateFromUnixTimestamp}

); })} diff --git a/libs/markets/src/lib/market-data.graphql b/libs/markets/src/lib/market-data.graphql index f1aff79b6..4698a173e 100644 --- a/libs/markets/src/lib/market-data.graphql +++ b/libs/markets/src/lib/market-data.graphql @@ -22,7 +22,6 @@ fragment MarketDataUpdateFields on ObservableMarketData { indicativeVolume marketState marketTradingMode - marketValueProxy markPrice midPrice openInterest @@ -75,7 +74,6 @@ fragment MarketDataFields on MarketData { indicativeVolume marketState marketTradingMode - marketValueProxy markPrice midPrice openInterest diff --git a/libs/markets/src/lib/market-data.mock.ts b/libs/markets/src/lib/market-data.mock.ts index d248acb92..edd12e7e4 100644 --- a/libs/markets/src/lib/market-data.mock.ts +++ b/libs/markets/src/lib/market-data.mock.ts @@ -58,7 +58,6 @@ const marketDataFields: MarketDataFieldsFragment = { indicativeVolume: '0', marketState: Schema.MarketState.STATE_ACTIVE, marketTradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS, - marketValueProxy: '2000000', markPrice: '4612690058', midPrice: '4612690000', openInterest: '0', @@ -97,7 +96,6 @@ const marketDataUpdateFields: MarketDataUpdateFieldsFragment = { marketId: 'market-0', marketState: Schema.MarketState.STATE_ACTIVE, marketTradingMode: Schema.MarketTradingMode.TRADING_MODE_CONTINUOUS, - marketValueProxy: '', markPrice: '4612690058', midPrice: '0', lastTradedPrice: '0', diff --git a/libs/markets/src/lib/markets.graphql b/libs/markets/src/lib/markets.graphql index b33dc3dae..76b377fce 100644 --- a/libs/markets/src/lib/markets.graphql +++ b/libs/markets/src/lib/markets.graphql @@ -35,6 +35,9 @@ fragment MarketFields on Market { open close } + liquidityMonitoringParameters { + triggeringRatio + } } query Markets { diff --git a/libs/markets/src/lib/markets.mock.ts b/libs/markets/src/lib/markets.mock.ts index 86fd00202..6c092b55b 100644 --- a/libs/markets/src/lib/markets.mock.ts +++ b/libs/markets/src/lib/markets.mock.ts @@ -53,6 +53,9 @@ export const createMarketFragment = ( liquidityFee: '', }, }, + liquidityMonitoringParameters: { + triggeringRatio: '1', + }, tradableInstrument: { instrument: { id: '', diff --git a/libs/orders/src/lib/components/mocks/generate-orders.ts b/libs/orders/src/lib/components/mocks/generate-orders.ts index 60e9c3cc1..a831e1660 100644 --- a/libs/orders/src/lib/components/mocks/generate-orders.ts +++ b/libs/orders/src/lib/components/mocks/generate-orders.ts @@ -20,6 +20,9 @@ export const generateOrder = (partialOrder?: PartialDeep) => { makerFee: '0.1', }, }, + liquidityMonitoringParameters: { + triggeringRatio: '1', + }, marketTimestamps: { __typename: 'MarketTimestamps', close: '', diff --git a/libs/orders/src/lib/components/mocks/generate-stop-orders.ts b/libs/orders/src/lib/components/mocks/generate-stop-orders.ts index f13f949d9..364e3929a 100644 --- a/libs/orders/src/lib/components/mocks/generate-stop-orders.ts +++ b/libs/orders/src/lib/components/mocks/generate-stop-orders.ts @@ -21,6 +21,9 @@ export const generateStopOrder = ( __typename: 'Market', id: 'market-id', decimalPlaces: 1, + liquidityMonitoringParameters: { + triggeringRatio: '0.7', + }, fees: { __typename: 'Fees', factors: { diff --git a/libs/orders/src/lib/components/order-list/order-view-dialog.spec.tsx b/libs/orders/src/lib/components/order-list/order-view-dialog.spec.tsx index 585db7f34..3f8f8d91f 100644 --- a/libs/orders/src/lib/components/order-list/order-view-dialog.spec.tsx +++ b/libs/orders/src/lib/components/order-list/order-view-dialog.spec.tsx @@ -31,6 +31,9 @@ describe('OrderViewDialog', () => { liquidityFee: '0.001', }, }, + liquidityMonitoringParameters: { + triggeringRatio: '1', + }, tradableInstrument: { __typename: 'TradableInstrument', instrument: { diff --git a/libs/withdraws/src/lib/withdraw-form-container.spec.tsx b/libs/withdraws/src/lib/withdraw-form-container.spec.tsx index 2d59791a2..d0e7b2b73 100644 --- a/libs/withdraws/src/lib/withdraw-form-container.spec.tsx +++ b/libs/withdraws/src/lib/withdraw-form-container.spec.tsx @@ -149,6 +149,9 @@ describe('WithdrawFormContainer', () => { liquidityFee: '0.001', }, }, + liquidityMonitoringParameters: { + triggeringRatio: '0.7', + }, tradableInstrument: { __typename: 'TradableInstrument', instrument: { diff --git a/specs/6002-MDET-market-details.md b/specs/6002-MDET-market-details.md index c5c80ac9f..3024fbe1d 100644 --- a/specs/6002-MDET-market-details.md +++ b/specs/6002-MDET-market-details.md @@ -105,7 +105,6 @@ When I look into market info I **Must** see following specification: - Liquidity: (6002-MDET-214) - Target Stake - Supplied Stake - - Market Value Proxy - link to liquidity provision table - Liquidity price range: (6002-MDET-215) - Liquidity Price Range From 6c5cd85d96eed1679e14e25d8d9ff883b26b0542 Mon Sep 17 00:00:00 2001 From: Maciek Date: Mon, 2 Oct 2023 18:26:10 +0200 Subject: [PATCH 14/37] fix(deal-ticket): prevent empty call estimate position (#4950) --- libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx | 6 +++++- libs/deal-ticket/src/hooks/use-position-estimate.ts | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx b/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx index 50e832b55..231cb8733 100644 --- a/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx +++ b/libs/deal-ticket/src/components/deal-ticket/deal-ticket.tsx @@ -264,7 +264,11 @@ export const DealTicket = ({ orders, collateralAvailable: marginAccountBalance || generalAccountBalance ? balance : undefined, - skip: !normalizedOrder, + skip: + !normalizedOrder || + (normalizedOrder.type !== Schema.OrderType.TYPE_MARKET && + (!normalizedOrder.price || normalizedOrder.price === '0')) || + normalizedOrder.size === '0', }); const assetSymbol = getAsset(market).symbol; diff --git a/libs/deal-ticket/src/hooks/use-position-estimate.ts b/libs/deal-ticket/src/hooks/use-position-estimate.ts index 6dd5255d1..faa972068 100644 --- a/libs/deal-ticket/src/hooks/use-position-estimate.ts +++ b/libs/deal-ticket/src/hooks/use-position-estimate.ts @@ -30,9 +30,11 @@ export const usePositionEstimate = ({ fetchPolicy: 'no-cache', }); useEffect(() => { - if (data) { + if (skip) { + setEstimates(undefined); + } else if (data) { setEstimates(data); } - }, [data]); + }, [data, skip]); return estimates; }; From c65c296db2ada490d172e13ae1a8abe6c7a4ae44 Mon Sep 17 00:00:00 2001 From: "m.ray" <16125548+MadalinaRaicu@users.noreply.github.com> Date: Mon, 2 Oct 2023 19:48:12 +0300 Subject: [PATCH 15/37] feat(trading): ethereum oracle spec in oracle panels (#4914) Co-authored-by: Matthew Russell --- .../src/app/routes/oracles/Oracles.graphql | 31 ++++ .../routes/oracles/__generated__/Oracles.ts | 37 +++- apps/trading/.env.devnet | 1 + .../lib/__generated__/OracleMarketsSpec.ts | 4 +- libs/markets/src/lib/__generated__/markets.ts | 4 +- .../components/market-info/MarketInfo.graphql | 35 ++++ .../market-info/__generated__/MarketInfo.ts | 45 ++++- .../market-info/market-info-panels.tsx | 121 ++++++++++++- .../market-info/tooltip-mapping.tsx | 8 +- libs/types/src/__generated__/types.ts | 166 +++++++++++++++--- .../copy-with-tooltip/copy-with-tooltip.tsx | 2 +- 11 files changed, 413 insertions(+), 41 deletions(-) diff --git a/apps/explorer/src/app/routes/oracles/Oracles.graphql b/apps/explorer/src/app/routes/oracles/Oracles.graphql index 17adf4e7c..a2d870b5e 100644 --- a/apps/explorer/src/app/routes/oracles/Oracles.graphql +++ b/apps/explorer/src/app/routes/oracles/Oracles.graphql @@ -49,6 +49,37 @@ fragment ExplorerOracleDataSource on OracleSpec { } ... on DataSourceDefinitionExternal { sourceType { + ... on EthCallSpec { + abi + args + method + requiredConfirmations + address + normalisers { + name + expression + } + trigger { + trigger { + ... on EthTimeTrigger { + initial + every + until + } + } + } + filters { + key { + name + type + numberDecimalPlaces + } + conditions { + value + operator + } + } + } ... on DataSourceSpecConfiguration { signers { signer { diff --git a/apps/explorer/src/app/routes/oracles/__generated__/Oracles.ts b/apps/explorer/src/app/routes/oracles/__generated__/Oracles.ts index 94a56942c..857250a4c 100644 --- a/apps/explorer/src/app/routes/oracles/__generated__/Oracles.ts +++ b/apps/explorer/src/app/routes/oracles/__generated__/Oracles.ts @@ -5,19 +5,19 @@ import * as Apollo from '@apollo/client'; const defaultOptions = {} as const; export type ExplorerOracleDataConnectionFragment = { __typename?: 'OracleSpec', dataConnection: { __typename?: 'OracleDataConnection', edges?: Array<{ __typename?: 'OracleDataEdge', node: { __typename?: 'OracleData', externalData: { __typename?: 'ExternalData', data: { __typename?: 'Data', matchedSpecIds?: Array | null, broadcastAt: any, signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, data?: Array<{ __typename?: 'Property', name: string, value: string }> | null } } } } | null> | null } }; -export type ExplorerOracleDataSourceFragment = { __typename?: 'OracleSpec', dataSourceSpec: { __typename?: 'ExternalDataSourceSpec', spec: { __typename?: 'DataSourceSpec', id: string, createdAt: any, updatedAt?: any | null, status: Types.DataSourceSpecStatus, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger' } } } } }, dataConnection: { __typename?: 'OracleDataConnection', edges?: Array<{ __typename?: 'OracleDataEdge', node: { __typename?: 'OracleData', externalData: { __typename?: 'ExternalData', data: { __typename?: 'Data', matchedSpecIds?: Array | null, broadcastAt: any, signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, data?: Array<{ __typename?: 'Property', name: string, value: string }> | null } } } } | null> | null } }; +export type ExplorerOracleDataSourceFragment = { __typename?: 'OracleSpec', dataSourceSpec: { __typename?: 'ExternalDataSourceSpec', spec: { __typename?: 'DataSourceSpec', id: string, createdAt: any, updatedAt?: any | null, status: Types.DataSourceSpecStatus, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array | null, args?: Array | null, method: string, requiredConfirmations: number, address: string, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger' } } } } }, dataConnection: { __typename?: 'OracleDataConnection', edges?: Array<{ __typename?: 'OracleDataEdge', node: { __typename?: 'OracleData', externalData: { __typename?: 'ExternalData', data: { __typename?: 'Data', matchedSpecIds?: Array | null, broadcastAt: any, signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, data?: Array<{ __typename?: 'Property', name: string, value: string }> | null } } } } | null> | null } }; export type ExplorerOracleSpecsQueryVariables = Types.Exact<{ [key: string]: never; }>; -export type ExplorerOracleSpecsQuery = { __typename?: 'Query', oracleSpecsConnection?: { __typename?: 'OracleSpecsConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean }, edges?: Array<{ __typename?: 'OracleSpecEdge', node: { __typename?: 'OracleSpec', dataSourceSpec: { __typename?: 'ExternalDataSourceSpec', spec: { __typename?: 'DataSourceSpec', id: string, createdAt: any, updatedAt?: any | null, status: Types.DataSourceSpecStatus, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger' } } } } }, dataConnection: { __typename?: 'OracleDataConnection', edges?: Array<{ __typename?: 'OracleDataEdge', node: { __typename?: 'OracleData', externalData: { __typename?: 'ExternalData', data: { __typename?: 'Data', matchedSpecIds?: Array | null, broadcastAt: any, signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, data?: Array<{ __typename?: 'Property', name: string, value: string }> | null } } } } | null> | null } } } | null> | null } | null }; +export type ExplorerOracleSpecsQuery = { __typename?: 'Query', oracleSpecsConnection?: { __typename?: 'OracleSpecsConnection', pageInfo: { __typename?: 'PageInfo', hasNextPage: boolean }, edges?: Array<{ __typename?: 'OracleSpecEdge', node: { __typename?: 'OracleSpec', dataSourceSpec: { __typename?: 'ExternalDataSourceSpec', spec: { __typename?: 'DataSourceSpec', id: string, createdAt: any, updatedAt?: any | null, status: Types.DataSourceSpecStatus, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array | null, args?: Array | null, method: string, requiredConfirmations: number, address: string, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger' } } } } }, dataConnection: { __typename?: 'OracleDataConnection', edges?: Array<{ __typename?: 'OracleDataEdge', node: { __typename?: 'OracleData', externalData: { __typename?: 'ExternalData', data: { __typename?: 'Data', matchedSpecIds?: Array | null, broadcastAt: any, signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, data?: Array<{ __typename?: 'Property', name: string, value: string }> | null } } } } | null> | null } } } | null> | null } | null }; export type ExplorerOracleSpecByIdQueryVariables = Types.Exact<{ id: Types.Scalars['ID']; }>; -export type ExplorerOracleSpecByIdQuery = { __typename?: 'Query', oracleSpec?: { __typename?: 'OracleSpec', dataSourceSpec: { __typename?: 'ExternalDataSourceSpec', spec: { __typename?: 'DataSourceSpec', id: string, createdAt: any, updatedAt?: any | null, status: Types.DataSourceSpecStatus, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger' } } } } }, dataConnection: { __typename?: 'OracleDataConnection', edges?: Array<{ __typename?: 'OracleDataEdge', node: { __typename?: 'OracleData', externalData: { __typename?: 'ExternalData', data: { __typename?: 'Data', matchedSpecIds?: Array | null, broadcastAt: any, signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, data?: Array<{ __typename?: 'Property', name: string, value: string }> | null } } } } | null> | null } } | null }; +export type ExplorerOracleSpecByIdQuery = { __typename?: 'Query', oracleSpec?: { __typename?: 'OracleSpec', dataSourceSpec: { __typename?: 'ExternalDataSourceSpec', spec: { __typename?: 'DataSourceSpec', id: string, createdAt: any, updatedAt?: any | null, status: Types.DataSourceSpecStatus, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array | null, args?: Array | null, method: string, requiredConfirmations: number, address: string, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator } | null> } | { __typename?: 'DataSourceSpecConfigurationTimeTrigger' } } } } }, dataConnection: { __typename?: 'OracleDataConnection', edges?: Array<{ __typename?: 'OracleDataEdge', node: { __typename?: 'OracleData', externalData: { __typename?: 'ExternalData', data: { __typename?: 'Data', matchedSpecIds?: Array | null, broadcastAt: any, signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, data?: Array<{ __typename?: 'Property', name: string, value: string }> | null } } } } | null> | null } } | null }; export const ExplorerOracleDataConnectionFragmentDoc = gql` fragment ExplorerOracleDataConnection on OracleSpec { @@ -72,6 +72,37 @@ export const ExplorerOracleDataSourceFragmentDoc = gql` } ... on DataSourceDefinitionExternal { sourceType { + ... on EthCallSpec { + abi + args + method + requiredConfirmations + address + normalisers { + name + expression + } + trigger { + trigger { + ... on EthTimeTrigger { + initial + every + until + } + } + } + filters { + key { + name + type + numberDecimalPlaces + } + conditions { + value + operator + } + } + } ... on DataSourceSpecConfiguration { signers { signer { diff --git a/apps/trading/.env.devnet b/apps/trading/.env.devnet index d315419a8..7863d77b5 100644 --- a/apps/trading/.env.devnet +++ b/apps/trading/.env.devnet @@ -15,6 +15,7 @@ NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/annou NX_VEGA_INCIDENT_URL=https://blog.vega.xyz/tagged/vega-incident-reports NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/firefox/addon/vega-wallet-fairground +NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json # Cosmic elevator flags NX_SUCCESSOR_MARKETS=true diff --git a/libs/markets/src/lib/__generated__/OracleMarketsSpec.ts b/libs/markets/src/lib/__generated__/OracleMarketsSpec.ts index a037132e3..b664fb1bf 100644 --- a/libs/markets/src/lib/__generated__/OracleMarketsSpec.ts +++ b/libs/markets/src/lib/__generated__/OracleMarketsSpec.ts @@ -4,12 +4,12 @@ import { gql } from '@apollo/client'; import { FutureFragmentDoc, PerpetualFragmentDoc } from '../components/market-info/__generated__/MarketInfo'; import * as Apollo from '@apollo/client'; const defaultOptions = {} as const; -export type OracleMarketSpecFieldsFragment = { __typename?: 'Market', id: string, state: Types.MarketState, tradingMode: Types.MarketTradingMode, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForTradingTermination: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecToFutureBinding', settlementDataProperty: string, tradingTerminationProperty: string } } | { __typename?: 'Perpetual', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForSettlementSchedule: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecPerpetualBinding', settlementDataProperty: string, settlementScheduleProperty: string } } | { __typename?: 'Spot' } } } }; +export type OracleMarketSpecFieldsFragment = { __typename?: 'Market', id: string, state: Types.MarketState, tradingMode: Types.MarketTradingMode, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array | null, address: string, args?: Array | null, method: string, requiredConfirmations: number, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForTradingTermination: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array | null, address: string, args?: Array | null, method: string, requiredConfirmations: number, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecToFutureBinding', settlementDataProperty: string, tradingTerminationProperty: string } } | { __typename?: 'Perpetual', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array | null, address: string, args?: Array | null, method: string, requiredConfirmations: number, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForSettlementSchedule: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array | null, address: string, args?: Array | null, method: string, requiredConfirmations: number, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecPerpetualBinding', settlementDataProperty: string, settlementScheduleProperty: string } } | { __typename?: 'Spot' } } } }; export type OracleMarketsSpecQueryVariables = Types.Exact<{ [key: string]: never; }>; -export type OracleMarketsSpecQuery = { __typename?: 'Query', marketsConnection?: { __typename?: 'MarketConnection', edges: Array<{ __typename?: 'MarketEdge', node: { __typename?: 'Market', id: string, state: Types.MarketState, tradingMode: Types.MarketTradingMode, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForTradingTermination: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecToFutureBinding', settlementDataProperty: string, tradingTerminationProperty: string } } | { __typename?: 'Perpetual', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForSettlementSchedule: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecPerpetualBinding', settlementDataProperty: string, settlementScheduleProperty: string } } | { __typename?: 'Spot' } } } } }> } | null }; +export type OracleMarketsSpecQuery = { __typename?: 'Query', marketsConnection?: { __typename?: 'MarketConnection', edges: Array<{ __typename?: 'MarketEdge', node: { __typename?: 'Market', id: string, state: Types.MarketState, tradingMode: Types.MarketTradingMode, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array | null, address: string, args?: Array | null, method: string, requiredConfirmations: number, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForTradingTermination: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array | null, address: string, args?: Array | null, method: string, requiredConfirmations: number, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecToFutureBinding', settlementDataProperty: string, tradingTerminationProperty: string } } | { __typename?: 'Perpetual', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array | null, address: string, args?: Array | null, method: string, requiredConfirmations: number, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForSettlementSchedule: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array | null, address: string, args?: Array | null, method: string, requiredConfirmations: number, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecPerpetualBinding', settlementDataProperty: string, settlementScheduleProperty: string } } | { __typename?: 'Spot' } } } } }> } | null }; export const OracleMarketSpecFieldsFragmentDoc = gql` fragment OracleMarketSpecFields on Market { diff --git a/libs/markets/src/lib/__generated__/markets.ts b/libs/markets/src/lib/__generated__/markets.ts index adb4597db..a8ff7430d 100644 --- a/libs/markets/src/lib/__generated__/markets.ts +++ b/libs/markets/src/lib/__generated__/markets.ts @@ -4,12 +4,12 @@ import { gql } from '@apollo/client'; import { FutureFragmentDoc, PerpetualFragmentDoc } from '../components/market-info/__generated__/MarketInfo'; import * as Apollo from '@apollo/client'; const defaultOptions = {} as const; -export type MarketFieldsFragment = { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, parentMarketID?: string | null, successorMarketID?: string | null, fees: { __typename?: 'Fees', factors: { __typename?: 'FeeFactors', makerFee: string, infrastructureFee: string, liquidityFee: string } }, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array | null }, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForTradingTermination: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecToFutureBinding', settlementDataProperty: string, tradingTerminationProperty: string } } | { __typename?: 'Perpetual', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForSettlementSchedule: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecPerpetualBinding', settlementDataProperty: string, settlementScheduleProperty: string } } | { __typename?: 'Spot' } } }, marketTimestamps: { __typename?: 'MarketTimestamps', open: any, close: any }, liquidityMonitoringParameters: { __typename?: 'LiquidityMonitoringParameters', triggeringRatio: string } }; +export type MarketFieldsFragment = { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, parentMarketID?: string | null, successorMarketID?: string | null, fees: { __typename?: 'Fees', factors: { __typename?: 'FeeFactors', makerFee: string, infrastructureFee: string, liquidityFee: string } }, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array | null }, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array | null, address: string, args?: Array | null, method: string, requiredConfirmations: number, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForTradingTermination: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array | null, address: string, args?: Array | null, method: string, requiredConfirmations: number, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecToFutureBinding', settlementDataProperty: string, tradingTerminationProperty: string } } | { __typename?: 'Perpetual', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array | null, address: string, args?: Array | null, method: string, requiredConfirmations: number, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForSettlementSchedule: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array | null, address: string, args?: Array | null, method: string, requiredConfirmations: number, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecPerpetualBinding', settlementDataProperty: string, settlementScheduleProperty: string } } | { __typename?: 'Spot' } } }, marketTimestamps: { __typename?: 'MarketTimestamps', open: any, close: any }, liquidityMonitoringParameters: { __typename?: 'LiquidityMonitoringParameters', triggeringRatio: string } }; export type MarketsQueryVariables = Types.Exact<{ [key: string]: never; }>; -export type MarketsQuery = { __typename?: 'Query', marketsConnection?: { __typename?: 'MarketConnection', edges: Array<{ __typename?: 'MarketEdge', node: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, parentMarketID?: string | null, successorMarketID?: string | null, fees: { __typename?: 'Fees', factors: { __typename?: 'FeeFactors', makerFee: string, infrastructureFee: string, liquidityFee: string } }, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array | null }, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForTradingTermination: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecToFutureBinding', settlementDataProperty: string, tradingTerminationProperty: string } } | { __typename?: 'Perpetual', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForSettlementSchedule: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecPerpetualBinding', settlementDataProperty: string, settlementScheduleProperty: string } } | { __typename?: 'Spot' } } }, marketTimestamps: { __typename?: 'MarketTimestamps', open: any, close: any }, liquidityMonitoringParameters: { __typename?: 'LiquidityMonitoringParameters', triggeringRatio: string } } }> } | null }; +export type MarketsQuery = { __typename?: 'Query', marketsConnection?: { __typename?: 'MarketConnection', edges: Array<{ __typename?: 'MarketEdge', node: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, parentMarketID?: string | null, successorMarketID?: string | null, fees: { __typename?: 'Fees', factors: { __typename?: 'FeeFactors', makerFee: string, infrastructureFee: string, liquidityFee: string } }, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array | null }, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array | null, address: string, args?: Array | null, method: string, requiredConfirmations: number, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForTradingTermination: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array | null, address: string, args?: Array | null, method: string, requiredConfirmations: number, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecToFutureBinding', settlementDataProperty: string, tradingTerminationProperty: string } } | { __typename?: 'Perpetual', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array | null, address: string, args?: Array | null, method: string, requiredConfirmations: number, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForSettlementSchedule: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array | null, address: string, args?: Array | null, method: string, requiredConfirmations: number, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecPerpetualBinding', settlementDataProperty: string, settlementScheduleProperty: string } } | { __typename?: 'Spot' } } }, marketTimestamps: { __typename?: 'MarketTimestamps', open: any, close: any }, liquidityMonitoringParameters: { __typename?: 'LiquidityMonitoringParameters', triggeringRatio: string } } }> } | null }; export const MarketFieldsFragmentDoc = gql` fragment MarketFields on Market { diff --git a/libs/markets/src/lib/components/market-info/MarketInfo.graphql b/libs/markets/src/lib/components/market-info/MarketInfo.graphql index 5af790ccc..759943f42 100644 --- a/libs/markets/src/lib/components/market-info/MarketInfo.graphql +++ b/libs/markets/src/lib/components/market-info/MarketInfo.graphql @@ -4,6 +4,10 @@ fragment DataSourceFilter on Filter { type numberDecimalPlaces } + conditions { + value + operator + } } fragment DataSource on DataSourceSpec { @@ -12,6 +16,37 @@ fragment DataSource on DataSourceSpec { sourceType { ... on DataSourceDefinitionExternal { sourceType { + ... on EthCallSpec { + abi + address + args + method + requiredConfirmations + normalisers { + name + expression + } + trigger { + trigger { + ... on EthTimeTrigger { + initial + every + until + } + } + } + filters { + key { + name + type + numberDecimalPlaces + } + conditions { + value + operator + } + } + } ... on DataSourceSpecConfiguration { signers { signer { diff --git a/libs/markets/src/lib/components/market-info/__generated__/MarketInfo.ts b/libs/markets/src/lib/components/market-info/__generated__/MarketInfo.ts index 120243f9b..216e4ebbf 100644 --- a/libs/markets/src/lib/components/market-info/__generated__/MarketInfo.ts +++ b/libs/markets/src/lib/components/market-info/__generated__/MarketInfo.ts @@ -3,20 +3,20 @@ import * as Types from '@vegaprotocol/types'; import { gql } from '@apollo/client'; import * as Apollo from '@apollo/client'; const defaultOptions = {} as const; -export type DataSourceFilterFragment = { __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }; +export type DataSourceFilterFragment = { __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }; -export type DataSourceFragment = { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }; +export type DataSourceFragment = { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array | null, address: string, args?: Array | null, method: string, requiredConfirmations: number, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }; -export type FutureFragment = { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForTradingTermination: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecToFutureBinding', settlementDataProperty: string, tradingTerminationProperty: string } }; +export type FutureFragment = { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array | null, address: string, args?: Array | null, method: string, requiredConfirmations: number, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForTradingTermination: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array | null, address: string, args?: Array | null, method: string, requiredConfirmations: number, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecToFutureBinding', settlementDataProperty: string, tradingTerminationProperty: string } }; -export type PerpetualFragment = { __typename?: 'Perpetual', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForSettlementSchedule: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecPerpetualBinding', settlementDataProperty: string, settlementScheduleProperty: string } }; +export type PerpetualFragment = { __typename?: 'Perpetual', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array | null, address: string, args?: Array | null, method: string, requiredConfirmations: number, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForSettlementSchedule: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array | null, address: string, args?: Array | null, method: string, requiredConfirmations: number, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecPerpetualBinding', settlementDataProperty: string, settlementScheduleProperty: string } }; export type MarketInfoQueryVariables = Types.Exact<{ marketId: Types.Scalars['ID']; }>; -export type MarketInfoQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, proposal?: { __typename?: 'Proposal', id?: string | null, rationale: { __typename?: 'ProposalRationale', title: string, description: string } } | null, marketTimestamps: { __typename?: 'MarketTimestamps', open: any, close: any }, openingAuction: { __typename?: 'AuctionDuration', durationSecs: number, volume: number }, accountsConnection?: { __typename?: 'AccountsConnection', edges?: Array<{ __typename?: 'AccountEdge', node: { __typename?: 'AccountBalance', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', id: string } } } | null> | null } | 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, liquidityMonitoringParameters: { __typename?: 'LiquidityMonitoringParameters', triggeringRatio: string, targetStakeParameters: { __typename?: 'TargetStakeParameters', timeWindow: number, scalingFactor: number } }, liquiditySLAParameters?: { __typename?: 'LiquiditySLAParameters', priceRange: string, commitmentMinTimeFraction: string, performanceHysteresisEpochs: number, slaCompetitionFactor: string } | null, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array | null }, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForTradingTermination: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecToFutureBinding', settlementDataProperty: string, tradingTerminationProperty: string } } | { __typename?: 'Perpetual', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForSettlementSchedule: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null } }> | null } | { __typename?: 'EthCallSpec' } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecPerpetualBinding', settlementDataProperty: string, settlementScheduleProperty: string } } | { __typename?: 'Spot' } }, 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 } }, marginCalculator?: { __typename?: 'MarginCalculator', scalingFactors: { __typename?: 'ScalingFactors', searchLevel: number, initialMargin: number, collateralRelease: number } } | null } } | null }; +export type MarketInfoQuery = { __typename?: 'Query', market?: { __typename?: 'Market', id: string, decimalPlaces: number, positionDecimalPlaces: number, state: Types.MarketState, tradingMode: Types.MarketTradingMode, proposal?: { __typename?: 'Proposal', id?: string | null, rationale: { __typename?: 'ProposalRationale', title: string, description: string } } | null, marketTimestamps: { __typename?: 'MarketTimestamps', open: any, close: any }, openingAuction: { __typename?: 'AuctionDuration', durationSecs: number, volume: number }, accountsConnection?: { __typename?: 'AccountsConnection', edges?: Array<{ __typename?: 'AccountEdge', node: { __typename?: 'AccountBalance', type: Types.AccountType, balance: string, asset: { __typename?: 'Asset', id: string } } } | null> | null } | 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, liquidityMonitoringParameters: { __typename?: 'LiquidityMonitoringParameters', triggeringRatio: string, targetStakeParameters: { __typename?: 'TargetStakeParameters', timeWindow: number, scalingFactor: number } }, liquiditySLAParameters?: { __typename?: 'LiquiditySLAParameters', priceRange: string, commitmentMinTimeFraction: string, performanceHysteresisEpochs: number, slaCompetitionFactor: string } | null, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', id: string, name: string, code: string, metadata: { __typename?: 'InstrumentMetadata', tags?: Array | null }, product: { __typename?: 'Future', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array | null, address: string, args?: Array | null, method: string, requiredConfirmations: number, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForTradingTermination: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array | null, address: string, args?: Array | null, method: string, requiredConfirmations: number, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecToFutureBinding', settlementDataProperty: string, tradingTerminationProperty: string } } | { __typename?: 'Perpetual', quoteName: string, settlementAsset: { __typename?: 'Asset', id: string, symbol: string, name: string, decimals: number, quantum: string }, dataSourceSpecForSettlementData: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array | null, address: string, args?: Array | null, method: string, requiredConfirmations: number, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecForSettlementSchedule: { __typename?: 'DataSourceSpec', id: string, data: { __typename?: 'DataSourceDefinition', sourceType: { __typename?: 'DataSourceDefinitionExternal', sourceType: { __typename?: 'DataSourceSpecConfiguration', signers?: Array<{ __typename?: 'Signer', signer: { __typename?: 'ETHAddress', address?: string | null } | { __typename?: 'PubKey', key?: string | null } }> | null, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } | { __typename?: 'EthCallSpec', abi?: Array | null, address: string, args?: Array | null, method: string, requiredConfirmations: number, normalisers?: Array<{ __typename?: 'Normaliser', name: string, expression: string }> | null, trigger: { __typename?: 'EthCallTrigger', trigger: { __typename?: 'EthTimeTrigger', initial?: any | null, every?: number | null, until?: any | null } }, filters?: Array<{ __typename?: 'Filter', key: { __typename?: 'PropertyKey', name?: string | null, type: Types.PropertyKeyType, numberDecimalPlaces?: number | null }, conditions?: Array<{ __typename?: 'Condition', value?: string | null, operator: Types.ConditionOperator }> | null }> | null } } | { __typename?: 'DataSourceDefinitionInternal', sourceType: { __typename?: 'DataSourceSpecConfigurationTime', conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } | { __typename: 'DataSourceSpecConfigurationTimeTrigger', triggers: Array<{ __typename?: 'InternalTimeTrigger', initial?: number | null, every?: number | null } | null>, conditions: Array<{ __typename?: 'Condition', operator: Types.ConditionOperator, value?: string | null } | null> } } } }, dataSourceSpecBinding: { __typename?: 'DataSourceSpecPerpetualBinding', settlementDataProperty: string, settlementScheduleProperty: string } } | { __typename?: 'Spot' } }, 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 } }, marginCalculator?: { __typename?: 'MarginCalculator', scalingFactors: { __typename?: 'ScalingFactors', searchLevel: number, initialMargin: number, collateralRelease: number } } | null } } | null }; export const DataSourceFilterFragmentDoc = gql` fragment DataSourceFilter on Filter { @@ -25,6 +25,10 @@ export const DataSourceFilterFragmentDoc = gql` type numberDecimalPlaces } + conditions { + value + operator + } } `; export const DataSourceFragmentDoc = gql` @@ -34,6 +38,37 @@ export const DataSourceFragmentDoc = gql` sourceType { ... on DataSourceDefinitionExternal { sourceType { + ... on EthCallSpec { + abi + address + args + method + requiredConfirmations + normalisers { + name + expression + } + trigger { + trigger { + ... on EthTimeTrigger { + initial + every + until + } + } + } + filters { + key { + name + type + numberDecimalPlaces + } + conditions { + value + operator + } + } + } ... on DataSourceSpecConfiguration { signers { signer { diff --git a/libs/markets/src/lib/components/market-info/market-info-panels.tsx b/libs/markets/src/lib/components/market-info/market-info-panels.tsx index aac443bdf..26308a88d 100644 --- a/libs/markets/src/lib/components/market-info/market-info-panels.tsx +++ b/libs/markets/src/lib/components/market-info/market-info-panels.tsx @@ -6,13 +6,21 @@ import { t } from '@vegaprotocol/i18n'; import { marketDataProvider } from '../../market-data-provider'; import { totalFeesPercentage } from '../../market-utils'; import { + Accordion, + AccordionChevron, + AccordionPanel, + CopyWithTooltip, ExternalLink, Intent, + KeyValueTable, + KeyValueTableRow, Lozenge, Splash, + SyntaxHighlighter, Tooltip, VegaIcon, VegaIconNames, + truncateMiddle, } from '@vegaprotocol/ui-toolkit'; import { addDecimalsFormatNumber, @@ -31,6 +39,7 @@ import { Last24hVolume } from '../last-24h-volume'; import BigNumber from 'bignumber.js'; import type { DataSourceDefinition, + EthCallSpec, MarketTradingMode, SignerKind, } from '@vegaprotocol/types'; @@ -40,6 +49,7 @@ import { } from '@vegaprotocol/types'; import { DApp, + EtherscanLink, FLAGS, TOKEN_PROPOSAL, useEnvironment, @@ -65,6 +75,7 @@ import { } from '@vegaprotocol/network-parameters'; import type { DataSourceFragment } from './__generated__/MarketInfo'; import { formatDuration } from 'date-fns'; +import * as AccordionPrimitive from '@radix-ui/react-accordion'; type MarketInfoProps = { market: MarketInfo; @@ -659,6 +670,97 @@ export const LiquidityMonitoringParametersInfoPanel = ({ return ; }; +export const EthOraclePanel = ({ sourceType }: { sourceType: EthCallSpec }) => { + const abis = sourceType.abi?.map((abi) => JSON.parse(abi)); + const header = 'uppercase my-1 text-left'; + return ( + <> +

{t('Ethereum Oracle')}

+ {sourceType.address && ( + <> + + +
{t('Address')}
+ + + +
+
+ +
+ + {t('View on Etherscan')} + +
+ + )} + + + + +
+
+ {t('ABI specification')} +
+ +
+
+ + } + > + +
+
+ +

{t('Normalisers')}

+ {sourceType.normalisers?.map((normaliser, i) => ( + + ))} +

{t('Filters')}

+

{t('Key')}

+ {sourceType.filters?.map((filter, i) => ( + <> + +

{t('Conditions')}

+ {filter.conditions?.map((condition, i) => ( + + {ConditionOperatorMapping[condition.operator]} {condition.value} + + ))} + + ))} + + ); +}; + export const LiquidityPriceRangeInfoPanel = ({ market, parentMarket, @@ -782,7 +884,7 @@ export const LiquiditySLAParametersInfoPanel = ({ market.liquiditySLAParameters?.slaCompetitionFactor ).times(100) ), - commitmentMinimumTimeFraction: + commitmentMinTimeFraction: market.liquiditySLAParameters?.commitmentMinTimeFraction && formatNumberPercentage( new BigNumber( @@ -797,7 +899,7 @@ export const LiquiditySLAParametersInfoPanel = ({ parentMarket.liquiditySLAParameters?.performanceHysteresisEpochs, slaCompetitionFactor: parentMarket.liquiditySLAParameters?.slaCompetitionFactor, - commitmentMinimumTimeFraction: + commitmentMinTimeFraction: parentMarket.liquiditySLAParameters?.commitmentMinTimeFraction, } : undefined; @@ -823,13 +925,13 @@ export const LiquiditySLAParametersInfoPanel = ({ networkParams['market_liquidity_nonPerformanceBondPenaltySlope'], nonPerformanceBondPenaltyMax: networkParams['market_liquidity_sla_nonPerformanceBondPenaltyMax'], - maximumLiquidityFeeFactorLevel: + maxLiquidityFeeFactorLevel: networkParams['market_liquidity_maximumLiquidityFeeFactorLevel'], stakeToCCYVolume: networkParams['market_liquidity_stakeToCcyVolume'], earlyExitPenalty: networkParams['market_liquidity_earlyExitPenalty'], probabilityOfTradingTauScaling: networkParams['market_liquidity_probabilityOfTrading_tau_scaling'], - minimumProbabilityOfTradingLPOrders: + minProbabilityOfTradingLPOrders: networkParams['market_liquidity_minimum_probabilityOfTrading_lpOrders'], feeCalculationTimeStep: networkParams['market_liquidity_feeCalculationTimeStep'] && @@ -931,6 +1033,10 @@ export const OracleInfoPanel = ({ )} + {dataSourceSpec?.sourceType.sourceType.__typename === 'EthCallSpec' && ( + + )} +
{shouldShowParentData && parentDataSourceSpec && @@ -945,6 +1051,13 @@ export const OracleInfoPanel = ({ dataSourceSpecId={parentDataSourceSpecId} /> + {parentDataSourceSpec?.sourceType.sourceType.__typename === + 'EthCallSpec' && ( + + )} + {dataSourceSpecId && ( = { insurancePoolFraction: t( 'The fraction of the insurance pool balance that is carried over from the parent market to the successor.' ), - commitmentMinimumTimeFraction: t( + commitmentMinTimeFraction: t( `Specifies the minimum fraction of time LPs must spend 'on the book' providing their committed liquidity. This is a market parameter.` ), feeCalculationTimeStep: t( @@ -127,7 +127,7 @@ export const tooltipMapping: Record = { nonPerformanceBondPenaltyMax: t( `The maximum amount, as a fraction, that an LP's bond can be slashed by if they fail to reach the minimum SLA. This is a network parameter.` ), - maximumLiquidityFeeFactorLevel: t( + maxLiquidityFeeFactorLevel: t( 'Maximum value that a proposed fee amount can be, which is submitted as part of the LP commitment transaction. Note that a value of 0.05 = 5%. This is a network parameter.' ), stakeToCCYVolume: t( @@ -137,12 +137,12 @@ export const tooltipMapping: Record = { 'How long an epoch is. LP rewards from liquidity fees are paid out once per epoch. How much they receive depends on whether they met the liquidity SLA and their previous performance in recent epochs. This is a network parameter.' ), earlyExitPenalty: t( - `How much an LP forfeits of their bond if they reduce their commitment while the market is below target stake, expressed as a factor. If set to 0 there is no penalty for early exit. If set to 1 an LP's entire bond is forfeited when an LP removes their full commitment. This is a network parameter.` + `The percentage of their bond an LP forfeits if they reduce their commitment while the market is below target stake. If 100%, an LP's entire bond is forfeited when they cancel their full commitment. This is a network parameter.` ), probabilityOfTradingTauScaling: t( `Determines how the probability of trading is scaled from the risk model, and is used to measure the relative competitiveness of an LP's supplied volume. This is a network parameter.` ), - minimumProbabilityOfTradingLPOrders: t( + minProbabilityOfTradingLPOrders: t( 'The lower bound for the probability of trading calculation, used to measure liquidity available on a market to determine if LPs are meeting their commitment. This is a network parameter.' ), }; diff --git a/libs/types/src/__generated__/types.ts b/libs/types/src/__generated__/types.ts index 273f0710f..ad3606ce2 100644 --- a/libs/types/src/__generated__/types.ts +++ b/libs/types/src/__generated__/types.ts @@ -505,6 +505,29 @@ export type CoreSnapshotEdge = { node: CoreSnapshotData; }; +/** Referral program information reported by data node with additional endedAt timestamp. */ +export type CurrentReferralProgram = { + __typename?: 'CurrentReferralProgram'; + /** Defined tiers in increasing order. First element will give Tier 1, second element will give Tier 2, etc. */ + benefitTiers: Array; + /** Timestamp as RFC3339Nano, after which when the current epoch ends, the program will end and benefits will be disabled. */ + endOfProgramTimestamp: Scalars['Timestamp']; + /** Timestamp as RFC3339Nano when the program ended. If present, the current program has ended and no program is currently running. */ + endedAt?: Maybe; + /** Unique ID generated from the proposal that created this program. */ + id: Scalars['ID']; + /** + * Defined staking tiers in increasing order. First element will give Tier 1, + * second element will give Tier 2, and so on. Determines the level of + * benefit a party can expect based on their staking. + */ + stakingTiers: Array; + /** Incremental version of the program. It is incremented each time the referral program is edited. */ + version: Scalars['Int']; + /** Number of epochs over which to evaluate a referral set's running volume. */ + windowLength: Scalars['Int']; +}; + /** A data source contains the data sent by a data source */ export type Data = { __typename?: 'Data'; @@ -1607,6 +1630,8 @@ export type LiquidityProvider = { marketId: Scalars['ID']; /** Party ID of the liquidity provider */ partyId: Scalars['ID']; + /** SLA performance statistics */ + sla?: Maybe; }; /** Connection type for retrieving cursor-based paginated liquidity provider information */ @@ -1642,6 +1667,29 @@ export type LiquidityProviderFeeShare = { virtualStake: Scalars['String']; }; +/** The SLA statistics for each liquidity provider */ +export type LiquidityProviderSLA = { + __typename?: 'LiquidityProviderSLA'; + /** Indicates how often LP meets the commitment during the current epoch. */ + currentEpochFractionOfTimeOnBook: Scalars['String']; + /** Determines how the fee penalties from past epochs affect future fee revenue. */ + hysteresisPeriodFeePenalties?: Maybe>; + /** Indicates the bond penalty amount applied in the previous epoch. */ + lastEpochBondPenalty: Scalars['String']; + /** Indicates the fee penalty amount applied in the previous epoch. */ + lastEpochFeePenalty: Scalars['String']; + /** Indicates how often LP met the commitment in the previous epoch. */ + lastEpochFractionOfTimeOnBook: Scalars['String']; + /** Notional volume of orders within the range provided on the buy side of the book. */ + notionalVolumeBuys: Scalars['String']; + /** Notional volume of orders within the range provided on the sell side of the book. */ + notionalVolumeSells: Scalars['String']; + /** The liquidity provider party ID */ + party: Party; + /** Represents the total amount of funds LP must supply. The amount to be supplied is in the market’s settlement currency, spread on both buy and sell sides of the order book within a defined range. */ + requiredLiquidity: Scalars['String']; +}; + /** The command to be sent to the chain for a liquidity provision submission */ export type LiquidityProvision = { __typename?: 'LiquidityProvision'; @@ -2030,6 +2078,8 @@ export type MarketData = { lastTradedPrice: Scalars['String']; /** The equity like share of liquidity fee for each liquidity provider */ liquidityProviderFeeShare?: Maybe>; + /** SLA performance statistics */ + liquidityProviderSla?: Maybe>; /** The mark price (an unsigned integer) */ markPrice: Scalars['String']; /** Market of the associated mark price */ @@ -2562,6 +2612,29 @@ export type ObservableLiquidityProviderFeeShare = { partyId: Scalars['ID']; }; +/** The SLA statistics for each liquidity provider */ +export type ObservableLiquidityProviderSLA = { + __typename?: 'ObservableLiquidityProviderSLA'; + /** Indicates how often LP meets the commitment during the current epoch. */ + currentEpochFractionOfTimeOnBook: Scalars['String']; + /** Determines how the fee penalties from past epochs affect future fee revenue. */ + hysteresisPeriodFeePenalties?: Maybe>; + /** Indicates the bond penalty amount applied in the previous epoch. */ + lastEpochBondPenalty: Scalars['String']; + /** Indicates the fee penalty amount applied in the previous epoch. */ + lastEpochFeePenalty: Scalars['String']; + /** Indicates how often LP meets the commitment during last epoch. */ + lastEpochFractionOfTimeOnBook: Scalars['String']; + /** Notional volume of orders within the range provided on the buy side of the book. */ + notionalVolumeBuys: Scalars['String']; + /** Notional volume of orders within the range provided on the sell side of the book. */ + notionalVolumeSells: Scalars['String']; + /** The liquidity provider party ID */ + party: Scalars['ID']; + /** Represents the total amount of funds LP must supply. The amount to be supplied is in the market’s settlement currency, spread on both buy and sell sides of the order book within a defined range. */ + requiredLiquidity: Scalars['String']; +}; + /** Live data of a Market */ export type ObservableMarketData = { __typename?: 'ObservableMarketData'; @@ -2595,6 +2668,8 @@ export type ObservableMarketData = { lastTradedPrice: Scalars['String']; /** The equity like share of liquidity fee for each liquidity provider */ liquidityProviderFeeShare?: Maybe>; + /** SLA performance statistics */ + liquidityProviderSla?: Maybe>; /** The mark price (an unsigned integer) */ markPrice: Scalars['String']; /** The market growth factor for the last market time window */ @@ -3289,6 +3364,15 @@ export type PartyActivityStreak = { tradedVolume: Scalars['String']; }; +/** An amount received by a party as a reward or a discount */ +export type PartyAmount = { + __typename?: 'PartyAmount'; + /** Amount received by the party */ + amount: Scalars['String']; + /** Id of the party that received the payment */ + partyId: Scalars['String']; +}; + /** Connection type for retrieving cursor-based paginated party information */ export type PartyConnection = { __typename?: 'PartyConnection'; @@ -3861,6 +3945,8 @@ export type ProposalTerms = { /** Various proposal types that are supported by Vega */ export enum ProposalType { + /** Proposal to cancel a transfer */ + TYPE_CANCEL_TRANSFER = 'TYPE_CANCEL_TRANSFER', /** Proposal to change Vega network parameters */ TYPE_NETWORK_PARAMETERS = 'TYPE_NETWORK_PARAMETERS', /** Proposal to add a new asset */ @@ -3869,10 +3955,22 @@ export enum ProposalType { TYPE_NEW_FREE_FORM = 'TYPE_NEW_FREE_FORM', /** Propose a new market */ TYPE_NEW_MARKET = 'TYPE_NEW_MARKET', + /** Propose a new spot market */ + TYPE_NEW_SPOT_MARKET = 'TYPE_NEW_SPOT_MARKET', + /** Propose a new transfer */ + TYPE_NEW_TRANSFER = 'TYPE_NEW_TRANSFER', /** Proposal to update an existing asset */ TYPE_UPDATE_ASSET = 'TYPE_UPDATE_ASSET', /** Update an existing market */ - TYPE_UPDATE_MARKET = 'TYPE_UPDATE_MARKET' + TYPE_UPDATE_MARKET = 'TYPE_UPDATE_MARKET', + /** Proposal for updating the state of a market */ + TYPE_UPDATE_MARKET_STATE = 'TYPE_UPDATE_MARKET_STATE', + /** Proposal to update the referral program */ + TYPE_UPDATE_REFERRAL_PROGRAM = 'TYPE_UPDATE_REFERRAL_PROGRAM', + /** Update an existing spot market */ + TYPE_UPDATE_SPOT_MARKET = 'TYPE_UPDATE_SPOT_MARKET', + /** Proposal to update the volume discount program */ + TYPE_UPDATE_VOLUME_DISCOUNT_PROGRAM = 'TYPE_UPDATE_VOLUME_DISCOUNT_PROGRAM' } export type ProposalVote = { @@ -3998,7 +4096,7 @@ export type Query = { /** List core snapshots */ coreSnapshots?: Maybe; /** Get the current referral program */ - currentReferralProgram?: Maybe; + currentReferralProgram?: Maybe; /** Find a deposit using its ID */ deposit?: Maybe; /** Fetch all deposits */ @@ -4095,6 +4193,8 @@ export type Query = { protocolUpgradeProposals?: Maybe; /** Flag indicating whether the data-node is ready to begin the protocol upgrade */ protocolUpgradeStatus?: Maybe; + /** Get referrer fee and discount stats */ + referralFeeStats?: Maybe; referralSetReferees: ReferralSetRefereeConnection; /** List referral sets */ referralSets: ReferralSetConnection; @@ -4259,6 +4359,7 @@ export type QueryestimatePositionArgs = { marketId: Scalars['ID']; openVolume: Scalars['String']; orders?: InputMaybe>; + scaleLiquidationPriceToMarketDecimals?: InputMaybe; }; @@ -4450,6 +4551,14 @@ export type QueryprotocolUpgradeProposalsArgs = { }; +/** Queries allow a caller to read data and filter data via GraphQL. */ +export type QueryreferralFeeStatsArgs = { + assetId?: InputMaybe; + epoch?: InputMaybe; + marketId?: InputMaybe; +}; + + /** Queries allow a caller to read data and filter data via GraphQL. */ export type QueryreferralSetRefereesArgs = { id?: InputMaybe; @@ -4595,6 +4704,8 @@ export type RefereeStats = { __typename?: 'RefereeStats'; /** Discount factor applied to the party. */ discountFactor: Scalars['String']; + /** Current referee notional taker volume */ + epochNotionalTakerVolume: Scalars['String']; /** Unique ID of the party. */ partyId: Scalars['ID']; /** Reward factor applied to the party. */ @@ -4606,10 +4717,8 @@ export type ReferralProgram = { __typename?: 'ReferralProgram'; /** Defined tiers in increasing order. First element will give Tier 1, second element will give Tier 2, etc. */ benefitTiers: Array; - /** Timestamp as RFC3339Nano, after which when the current epoch ends, the programs status will become STATE_CLOSED and benefits will be disabled. */ - endOfProgramTimestamp: Scalars['Timestamp']; - /** Timestamp as RFC3339Nano when the program ended. If present, the current program has ended and no program is currently running. */ - endedAt?: Maybe; + /** Timestamp as RFC3339, after which when the current epoch ends, the programs will end and benefits will be disabled. */ + endOfProgramTimestamp: Scalars['String']; /** Unique ID generated from the proposal that created this program. */ id: Scalars['ID']; /** @@ -4667,6 +4776,25 @@ export type ReferralSetEdge = { node: ReferralSet; }; +/** Referral rewards and discounts that have been applied on a specific market/asset up to the given epoch. */ +export type ReferralSetFeeStats = { + __typename?: 'ReferralSetFeeStats'; + /** The settlement asset of the market. */ + assetId: Scalars['String']; + /** The epoch for which these stats were valid. */ + epoch: Scalars['Int']; + /** The market the fees were paid in */ + marketId: Scalars['String']; + /** The total referral discounts applied to all referee taker fees */ + refereesDiscountApplied: Array; + /** The total referral rewards generated by all referee taker fees. */ + referrerRewardsGenerated: Array; + /** The total referral rewards paid to the referrer of the referral set. */ + totalRewardsPaid: Array; + /** The total volume discounts applied to all referee taker fees */ + volumeDiscountApplied: Array; +}; + /** Data relating to referees that have joined a referral set */ export type ReferralSetReferee = { __typename?: 'ReferralSetReferee'; @@ -4710,6 +4838,15 @@ export type ReferralSetStats = { setId: Scalars['ID']; }; +/** Rewards generated for referrers by each of their referees */ +export type ReferrerRewardsGenerated = { + __typename?: 'ReferrerRewardsGenerated'; + /** The amount of rewards generated per party */ + generatedReward: Array; + /** ID of the referral set's referrer */ + referrerId: Scalars['String']; +}; + /** Reward information for a single party */ export type Reward = { __typename?: 'Reward'; @@ -5152,10 +5289,10 @@ export enum StopOrderRejectionReason { REJECTION_REASON_MAX_STOP_ORDERS_PER_PARTY_REACHED = 'REJECTION_REASON_MAX_STOP_ORDERS_PER_PARTY_REACHED', /** Stop orders submission must be reduce only */ REJECTION_REASON_MUST_BE_REDUCE_ONLY = 'REJECTION_REASON_MUST_BE_REDUCE_ONLY', - /** This stop order does not close the position */ - REJECTION_REASON_STOP_ORDER_DOES_NOT_CLOSE_POSITION = 'REJECTION_REASON_STOP_ORDER_DOES_NOT_CLOSE_POSITION', /** Stop orders are not allowed without a position */ REJECTION_REASON_STOP_ORDER_NOT_ALLOWED_WITHOUT_A_POSITION = 'REJECTION_REASON_STOP_ORDER_NOT_ALLOWED_WITHOUT_A_POSITION', + /** This stop order does not close the position */ + REJECTION_REASON_STOP_ORDER_NOT_CLOSING_THE_POSITION = 'REJECTION_REASON_STOP_ORDER_NOT_CLOSING_THE_POSITION', /** Trading is not allowed yet */ REJECTION_REASON_TRADING_NOT_ALLOWED = 'REJECTION_REASON_TRADING_NOT_ALLOWED' } @@ -5942,18 +6079,7 @@ export type UpdateProductConfiguration = UpdateFutureProduct | UpdatePerpetualPr export type UpdateReferralProgram = { __typename?: 'UpdateReferralProgram'; - /** Benefit tiers for the program */ - benefitTiers: Array; - /** The end time of the program */ - endOfProgramTimestamp: Scalars['Timestamp']; - /** ID of the proposal that created the referral program */ - id: Scalars['ID']; - /** Determines the level of benefit a party can expect based on their staking */ - stakingTiers: Array; - /** Current version of the referral program */ - version: Scalars['Int']; - /** The window legnth to consider for the referral program */ - windowLength: Scalars['Int']; + changes: ReferralProgram; }; /** Update an existing spot market on Vega */ diff --git a/libs/ui-toolkit/src/components/copy-with-tooltip/copy-with-tooltip.tsx b/libs/ui-toolkit/src/components/copy-with-tooltip/copy-with-tooltip.tsx index e97a9d721..c1f0a3870 100644 --- a/libs/ui-toolkit/src/components/copy-with-tooltip/copy-with-tooltip.tsx +++ b/libs/ui-toolkit/src/components/copy-with-tooltip/copy-with-tooltip.tsx @@ -15,7 +15,7 @@ export function CopyWithTooltip({ children, text }: CopyWithTooltipProps) { return ( setCopied(true)}> - {/* Needs this wrapping div as tooltip component interfers with element used to capture click for copy */} + {/* Needs this wrapping div as tooltip component interferes with element used to capture click for copy */} {children} From a19ea1c939d38707dc1b6095914cdb409934d50f Mon Sep 17 00:00:00 2001 From: "m.ray" <16125548+MadalinaRaicu@users.noreply.github.com> Date: Mon, 2 Oct 2023 20:00:49 +0300 Subject: [PATCH 16/37] fix(trading): update filter for market selector to include suspended via governance (#4957) --- .../components/market-state/market-state.tsx | 17 +++++++++++++++++ apps/trading/lib/utils/index.ts | 1 + .../trading-mode-tooltip.tsx | 14 ++++++++++++++ libs/environment/src/hooks/use-links.ts | 1 + 4 files changed, 33 insertions(+) diff --git a/apps/trading/components/market-state/market-state.tsx b/apps/trading/components/market-state/market-state.tsx index 7aa77d584..d5dbb10e8 100644 --- a/apps/trading/components/market-state/market-state.tsx +++ b/apps/trading/components/market-state/market-state.tsx @@ -7,6 +7,8 @@ import * as Schema from '@vegaprotocol/types'; import { HeaderStat } from '../header'; import { useCallback, useRef, useState } from 'react'; import * as constants from '../constants'; +import { DocsLinks } from '@vegaprotocol/environment'; +import { ExternalLink } from '@vegaprotocol/ui-toolkit'; export const MarketState = ({ market }: { market: Market | null }) => { const [marketState, setMarketState] = useState( @@ -90,5 +92,20 @@ const getMarketStateTooltip = (state: Schema.MarketState | null) => { ); } + if (state === Schema.MarketState.STATE_SUSPENDED_VIA_GOVERNANCE) { + return ( +

+ {t( + `This market has been suspended via a governance vote and can be resumed or terminated by further votes.` + )} + {DocsLinks && ( + + {t('Find out more')} + + )} +

+ ); + } + return undefined; }; diff --git a/apps/trading/lib/utils/index.ts b/apps/trading/lib/utils/index.ts index 95c3e7329..b8c02e991 100644 --- a/apps/trading/lib/utils/index.ts +++ b/apps/trading/lib/utils/index.ts @@ -5,6 +5,7 @@ const MARKET_TEMPLATE = [ MarketState.STATE_ACTIVE, MarketState.STATE_SUSPENDED, MarketState.STATE_PENDING, + MarketState.STATE_SUSPENDED_VIA_GOVERNANCE, ]; export const isMarketActive = (state: MarketState) => { diff --git a/libs/deal-ticket/src/components/trading-mode-tooltip/trading-mode-tooltip.tsx b/libs/deal-ticket/src/components/trading-mode-tooltip/trading-mode-tooltip.tsx index e23c0ee28..808970218 100644 --- a/libs/deal-ticket/src/components/trading-mode-tooltip/trading-mode-tooltip.tsx +++ b/libs/deal-ticket/src/components/trading-mode-tooltip/trading-mode-tooltip.tsx @@ -114,6 +114,20 @@ export const TradingModeTooltip = ({ ); } + case Schema.MarketTradingMode.TRADING_MODE_SUSPENDED_VIA_GOVERNANCE: { + return ( +
+ {t( + `This market has been suspended via a governance vote and can be resumed or terminated by further votes.` + )} + {DocsLinks && ( + + {t('Find out more')} + + )} +
+ ); + } case Schema.MarketTradingMode.TRADING_MODE_MONITORING_AUCTION: { switch (trigger) { case Schema.AuctionTrigger.AUCTION_TRIGGER_LIQUIDITY_TARGET_NOT_MET: { diff --git a/libs/environment/src/hooks/use-links.ts b/libs/environment/src/hooks/use-links.ts index c9ea45195..f4d208359 100644 --- a/libs/environment/src/hooks/use-links.ts +++ b/libs/environment/src/hooks/use-links.ts @@ -80,6 +80,7 @@ export const DocsLinks = VEGA_DOCS_URL LIQUIDITY: `${VEGA_DOCS_URL}/concepts/liquidity/provision`, WITHDRAWAL_LIMITS: `${VEGA_DOCS_URL}/concepts/assets/deposits-withdrawals#withdrawal-limits`, VALIDATOR_SCORES_REWARDS: `${VEGA_DOCS_URL}/concepts/vega-chain/validator-scores-and-rewards`, + MARKET_LIFECYCLE: `${VEGA_DOCS_URL}/concepts/trading-on-vega/market-lifecycle`, } : undefined; From 14928d318da6cc27896a2079178d172f0c61a7fc Mon Sep 17 00:00:00 2001 From: Joe Tsang <30622993+jtsang586@users.noreply.github.com> Date: Mon, 2 Oct 2023 20:50:47 +0100 Subject: [PATCH 17/37] chore(governance): add e2e tests for market update proposals (#4945) --- apps/governance-e2e/.env | 1 + .../src/fixtures/proposals/asset.json | 21 ---- .../fixtures/proposals/resume-market-raw.json | 16 +++ .../proposals/suspend-market-raw.json | 16 +++ .../proposals/terminate-market-raw.json | 17 +++ .../fixtures/proposals/update-market-old.json | 85 -------------- .../integration/flow/proposal-details.cy.ts | 107 ++++++++++++++++-- .../src/support/governance.functions.ts | 5 + 8 files changed, 151 insertions(+), 117 deletions(-) delete mode 100644 apps/governance-e2e/src/fixtures/proposals/asset.json create mode 100644 apps/governance-e2e/src/fixtures/proposals/resume-market-raw.json create mode 100644 apps/governance-e2e/src/fixtures/proposals/suspend-market-raw.json create mode 100644 apps/governance-e2e/src/fixtures/proposals/terminate-market-raw.json delete mode 100644 apps/governance-e2e/src/fixtures/proposals/update-market-old.json diff --git a/apps/governance-e2e/.env b/apps/governance-e2e/.env index fa5f7d475..169071218 100644 --- a/apps/governance-e2e/.env +++ b/apps/governance-e2e/.env @@ -22,6 +22,7 @@ NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72 NX_VEGA_REST_URL=http://localhost:3008/api/v2/ NX_SUCCESSOR_MARKETS=true NX_PRODUCT_PERPETUALS=true +NX_UPDATE_MARKET_STATE=true NX_VEGA_EXPLORER_URL=https://explorer.fairground.wtf NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn diff --git a/apps/governance-e2e/src/fixtures/proposals/asset.json b/apps/governance-e2e/src/fixtures/proposals/asset.json deleted file mode 100644 index 6ea2d69b3..000000000 --- a/apps/governance-e2e/src/fixtures/proposals/asset.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "rationale": { - "title": "Add USDT Coin (USDT)", - "description": "Proposal to add USDT Coin (USDT) as an asset" - }, - "terms": { - "newAsset": { - "changes": { - "name": "USDT Coin", - "symbol": "USDT", - "decimals": "18", - "quantum": "1", - "erc20": { - "contractAddress": "0xb404c51bbc10dcbe948077f18a4b8e553d160084" - } - } - }, - "closingTimestamp": 1662374250, - "enactmentTimestamp": 1662460650 - } -} diff --git a/apps/governance-e2e/src/fixtures/proposals/resume-market-raw.json b/apps/governance-e2e/src/fixtures/proposals/resume-market-raw.json new file mode 100644 index 000000000..c9a103eb7 --- /dev/null +++ b/apps/governance-e2e/src/fixtures/proposals/resume-market-raw.json @@ -0,0 +1,16 @@ +{ + "rationale": { + "title": "Market resume test", + "description": "E2E test for market resume proposal" + }, + "terms": { + "updateMarketState": { + "changes": { + "marketId": "b33bb4157e12355db22e41f277ddd0c10104dec29a4d6960bbcb96d186c40cbd", + "updateType": "MARKET_STATE_UPDATE_TYPE_RESUME" + } + }, + "closingTimestamp": 0, + "enactmentTimestamp": 0 + } +} diff --git a/apps/governance-e2e/src/fixtures/proposals/suspend-market-raw.json b/apps/governance-e2e/src/fixtures/proposals/suspend-market-raw.json new file mode 100644 index 000000000..91f74eef1 --- /dev/null +++ b/apps/governance-e2e/src/fixtures/proposals/suspend-market-raw.json @@ -0,0 +1,16 @@ +{ + "rationale": { + "title": "Market suspended test", + "description": "E2E test for market suspended proposal" + }, + "terms": { + "updateMarketState": { + "changes": { + "marketId": "", + "updateType": "MARKET_STATE_UPDATE_TYPE_SUSPEND" + } + }, + "closingTimestamp": 0, + "enactmentTimestamp": 0 + } +} diff --git a/apps/governance-e2e/src/fixtures/proposals/terminate-market-raw.json b/apps/governance-e2e/src/fixtures/proposals/terminate-market-raw.json new file mode 100644 index 000000000..c08abc4b8 --- /dev/null +++ b/apps/governance-e2e/src/fixtures/proposals/terminate-market-raw.json @@ -0,0 +1,17 @@ +{ + "rationale": { + "title": "Market terminate test", + "description": "E2E test for market terminate proposal" + }, + "terms": { + "updateMarketState": { + "changes": { + "marketId": "", + "updateType": "MARKET_STATE_UPDATE_TYPE_TERMINATE", + "price": "100" + } + }, + "closingTimestamp": 0, + "enactmentTimestamp": 0 + } +} diff --git a/apps/governance-e2e/src/fixtures/proposals/update-market-old.json b/apps/governance-e2e/src/fixtures/proposals/update-market-old.json deleted file mode 100644 index 7b3c214f6..000000000 --- a/apps/governance-e2e/src/fixtures/proposals/update-market-old.json +++ /dev/null @@ -1,85 +0,0 @@ -{ - "instrument": { - "code": "Token.24h", - "future": { - "quoteName": "fBTC", - "dataSourceSpecForSettlementData": { - "external": { - "oracle": { - "signers": [ - { - "pubKey": { - "key": "70d14a321e02e71992fd115563df765000ccc4775cbe71a0e2f9ff5a3b9dc680" - } - } - ], - "filters": [ - { - "key": { - "name": "prices.BTC.value", - "type": "TYPE_INTEGER" - }, - "conditions": [ - { - "operator": "OPERATOR_GREATER_THAN", - "value": "0" - } - ] - } - ] - } - } - }, - "dataSourceSpecForTradingTermination": { - "external": { - "oracle": { - "signers": [ - { - "pubKey": { - "key": "70d14a321e02e71992fd115563df765000ccc4775cbe71a0e2f9ff5a3b9dc680" - } - } - ], - "filters": [ - { - "key": { - "name": "trading.terminated.ETH5", - "type": "TYPE_BOOLEAN" - }, - "conditions": [ - { - "operator": "OPERATOR_GREATER_THAN_OR_EQUAL", - "value": "1648684800000000000" - } - ] - } - ] - } - } - }, - "dataSourceSpecBinding": { - "settlementDataProperty": "prices.BTC.value", - "tradingTerminationProperty": "trading.terminated.ETH5" - } - } - }, - "metadata": ["sector:energy", "sector:food", "source:docs.vega.xyz"], - "priceMonitoringParameters": { - "triggers": [ - { - "horizon": "43200", - "probability": "0.9999999", - "auctionExtension": "600" - } - ] - }, - "logNormal": { - "tau": 0.0001140771161, - "riskAversionParameter": 0.001, - "params": { - "mu": 0, - "r": 0.016, - "sigma": 0.3 - } - } -} diff --git a/apps/governance-e2e/src/integration/flow/proposal-details.cy.ts b/apps/governance-e2e/src/integration/flow/proposal-details.cy.ts index f9f3aee7c..0bc586370 100644 --- a/apps/governance-e2e/src/integration/flow/proposal-details.cy.ts +++ b/apps/governance-e2e/src/integration/flow/proposal-details.cy.ts @@ -60,6 +60,17 @@ describe( before('connect wallets and set approval limit', function () { cy.visit('/'); ethereumWalletConnect(); + cy.createMarket(); + navigateTo(navigation.proposals); + cy.getByTestId('closed-proposals').within(() => { + cy.contains('Add Lorem Ipsum market') + .parentsUntil(proposalListItem) + .last() + .within(() => { + cy.getByTestId(viewProposalButton).click(); + }); + }); + getProposalInformationFromTable('ID').invoke('text').as('parentMarketId'); }); beforeEach('visit proposals tab', function () { @@ -298,9 +309,6 @@ describe( }); it('Able to see successor market details with new and updated values', function () { - cy.createMarket(); - cy.reload(); - waitForSpinner(); cy.getByTestId('closed-proposals').within(() => { cy.contains('Add Lorem Ipsum market') .parentsUntil(proposalListItem) @@ -309,14 +317,9 @@ describe( cy.getByTestId(viewProposalButton).click(); }); }); - getProposalInformationFromTable('ID') - .invoke('text') - .as('parentMarketId') - .then(() => { - cy.VegaWalletSubmitProposal( - createSuccessorMarketProposalTxBody(this.parentMarketId) - ); - }); + cy.VegaWalletSubmitProposal( + createSuccessorMarketProposalTxBody(this.parentMarketId) + ); navigateTo(navigation.proposals); cy.reload(); getProposalFromTitle('Test successor market proposal details').within( @@ -434,5 +437,87 @@ describe( 'Minimum Probability Of Trading LP Orders' ).should('contain.text', '1e-8'); }); + + it('Able to see suspended market proposal', function () { + const proposalPath = 'src/fixtures/proposals/suspend-market-raw.json'; + const enactmentTimestamp = createTenDigitUnixTimeStampForSpecifiedDays(3); + const closingTimestamp = createTenDigitUnixTimeStampForSpecifiedDays(2); + submitUniqueRawProposal({ + proposalBody: proposalPath, + updateMarketId: this.parentMarketId, + enactmentTimestamp: enactmentTimestamp, + closingTimestamp: closingTimestamp, + }); + getProposalFromTitle('Market suspended test').within(() => { + cy.getByTestId(marketProposalType).should( + 'have.text', + 'Suspend market' + ); + cy.getByTestId(viewProposalButton).click(); + }); + cy.getByTestId(marketProposalType).should('have.text', 'Suspend market'); + cy.getByTestId(marketDataToggle).click(); + cy.getByTestId('proposal-update-market-state').within(() => { + getProposalInformationFromTable('Market ID') + .invoke('text') + .and('eq', this.parentMarketId); + }); + }); + + it('Able to see resume market proposal', function () { + const proposalPath = 'src/fixtures/proposals/resume-market-raw.json'; + const enactmentTimestamp = createTenDigitUnixTimeStampForSpecifiedDays(3); + const closingTimestamp = createTenDigitUnixTimeStampForSpecifiedDays(2); + submitUniqueRawProposal({ + proposalBody: proposalPath, + updateMarketId: this.parentMarketId, + enactmentTimestamp: enactmentTimestamp, + closingTimestamp: closingTimestamp, + }); + getProposalFromTitle('Market resume test').within(() => { + cy.getByTestId(marketProposalType).should('have.text', 'Resume market'); + cy.getByTestId(viewProposalButton).click(); + }); + cy.getByTestId(marketProposalType).should('have.text', 'Resume market'); + cy.getByTestId(marketDataToggle).click(); + cy.getByTestId('proposal-update-market-state').within(() => { + getProposalInformationFromTable('Market ID') + .invoke('text') + .and('eq', this.parentMarketId); + }); + }); + + it('Able to see terminate market proposal', function () { + const proposalPath = 'src/fixtures/proposals/terminate-market-raw.json'; + const enactmentTimestamp = createTenDigitUnixTimeStampForSpecifiedDays(3); + const closingTimestamp = createTenDigitUnixTimeStampForSpecifiedDays(2); + submitUniqueRawProposal({ + proposalBody: proposalPath, + updateMarketId: this.parentMarketId, + enactmentTimestamp: enactmentTimestamp, + closingTimestamp: closingTimestamp, + }); + getProposalFromTitle('Market terminate test').within(() => { + cy.getByTestId(marketProposalType).should( + 'have.text', + 'Terminate market' + ); + cy.getByTestId(viewProposalButton).click(); + }); + cy.getByTestId(marketProposalType).should( + 'have.text', + 'Terminate market' + ); + cy.getByTestId(marketDataToggle).click(); + cy.getByTestId('proposal-update-market-state').within(() => { + getProposalInformationFromTable('Market ID') + .invoke('text') + .and('eq', this.parentMarketId); + getProposalDetailsValue('Termination Price').should( + 'contain.text', + '0.001 fUSDC' + ); + }); + }); } ); diff --git a/apps/governance-e2e/src/support/governance.functions.ts b/apps/governance-e2e/src/support/governance.functions.ts index c908a1509..f86e46afb 100644 --- a/apps/governance-e2e/src/support/governance.functions.ts +++ b/apps/governance-e2e/src/support/governance.functions.ts @@ -54,6 +54,7 @@ export function submitUniqueRawProposal(proposalFields: { proposalBody?: string; proposalTitle?: string; proposalDescription?: string; + updateMarketId?: string; closingTimestamp?: number; enactmentTimestamp?: number; submit?: boolean; @@ -71,6 +72,10 @@ export function submitUniqueRawProposal(proposalFields: { if (proposalFields.proposalDescription) { rawProposal.rationale.description = proposalFields.proposalDescription; } + if (proposalFields.updateMarketId) { + rawProposal.terms.updateMarketState.changes.marketId = + proposalFields.updateMarketId; + } if (proposalFields.closingTimestamp) { rawProposal.terms.closingTimestamp = proposalFields.closingTimestamp; } else if ( From ee73e4d5e287d20f05a7408dee29b005c15ca162 Mon Sep 17 00:00:00 2001 From: Art Date: Tue, 3 Oct 2023 11:38:37 +0200 Subject: [PATCH 18/37] fix(trading): missing wallet connect button (#4959) --- apps/trading/.env | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/trading/.env b/apps/trading/.env index c4df25faa..0dfa4c6e1 100644 --- a/apps/trading/.env +++ b/apps/trading/.env @@ -12,6 +12,7 @@ NX_VEGA_WALLET_URL=http://localhost:1789 NX_VEGA_DOCS_URL=https://docs.vega.xyz/testnet NX_VEGA_REPO_URL=https://github.com/vegaprotocol/vega/releases NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json +NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72 NX_VEGA_INCIDENT_URL=https://blog.vega.xyz/tagged/vega-incident-reports NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/firefox/addon/vega-wallet-fairground From 73ae00f12ce0da6de47a0294d0c51f5fbaddcd66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Szpiech?= Date: Tue, 3 Oct 2023 11:44:12 +0200 Subject: [PATCH 19/37] chore(ci): add missing quote marks that may have caused some workflow fails (#4963) --- .github/workflows/ci-cd-trigger.yml | 6 +++--- .github/workflows/cypress-run.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-cd-trigger.yml b/.github/workflows/ci-cd-trigger.yml index d1753a0c9..3f6f6ea08 100644 --- a/.github/workflows/ci-cd-trigger.yml +++ b/.github/workflows/ci-cd-trigger.yml @@ -187,11 +187,11 @@ jobs: - name: Check branch id: check-test run: | - if [ ${{ github.base_ref }} == 'develop' ]; then + if [ '${{ github.base_ref }}' == 'develop' ]; then echo "e2e-needed=true" >> $GITHUB_OUTPUT - elif [ ${{ github.base_ref }} == 'main' ]; then + elif [ '${{ github.base_ref }}' == 'main' ]; then echo "e2e-needed=true" >> $GITHUB_OUTPUT - elif [[ ${{ github.event_name }} == 'push' && ${{ contains(github.ref_name, 'release/') }} ]]; then + elif [[ '${{ github.event_name }}' == 'push' && ${{ contains(github.ref_name, 'release/') }} ]]; then echo "e2e-needed=true" >> $GITHUB_OUTPUT else echo "e2e-needed=false" >> $GITHUB_OUTPUT diff --git a/.github/workflows/cypress-run.yml b/.github/workflows/cypress-run.yml index deae2ae7b..349b36280 100644 --- a/.github/workflows/cypress-run.yml +++ b/.github/workflows/cypress-run.yml @@ -21,11 +21,11 @@ jobs: - name: Check branch id: step run: | - if [ ${{ github.base_ref }} == 'main' ]; then + if [ '${{ github.base_ref }}' == 'main' ]; then echo "runner=mainnet-compatible-runner" >> $GITHUB_OUTPUT - elif [[ ${{ github.base_ref }} == 'develop' && ${{ github.ref_name }} == 'main' ]]; then + elif [[ '${{ github.base_ref }}' == 'develop' && '${{ github.ref_name }}' == 'main' ]]; then echo "runner=mainnet-compatible-runner" >> $GITHUB_OUTPUT - elif [[ ${{ github.event_name }} == 'push' && ${{ contains(github.ref_name, 'release/mainnet') }} ]]; then + elif [[ '${{ github.event_name }}' == 'push' && ${{ contains(github.ref_name, 'release/mainnet') }} ]]; then echo "runner=mainnet-compatible-runner" >> $GITHUB_OUTPUT else echo "runner=self-hosted-runner" >> $GITHUB_OUTPUT From eeff4ffcd404bacc6760de265f5a4bd4855e4d68 Mon Sep 17 00:00:00 2001 From: Art Date: Tue, 3 Oct 2023 11:53:32 +0200 Subject: [PATCH 20/37] fix(trading): missing wallet connect button (#4960) --- apps/trading/.env | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/trading/.env b/apps/trading/.env index 78caf98d6..55a75d9a2 100644 --- a/apps/trading/.env +++ b/apps/trading/.env @@ -12,6 +12,7 @@ NX_VEGA_WALLET_URL=http://localhost:1789 NX_VEGA_DOCS_URL=https://docs.vega.xyz/testnet NX_VEGA_REPO_URL=https://github.com/vegaprotocol/vega/releases NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json +NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72 NX_VEGA_INCIDENT_URL=https://blog.vega.xyz/tagged/vega-incident-reports NX_VEGA_CONSOLE_URL=https://console.fairground.wtf NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-fairground/nmmjkiafpmphlikhefgjbblebfgclikn From 60ca6c2eb600c80414bb98f297940dc01269a7c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20G=C5=82ownia?= Date: Tue, 3 Oct 2023 12:00:26 +0200 Subject: [PATCH 21/37] feat(trading): show fills for all markets (#4951) --- apps/trading/client-pages/market/trade-grid.tsx | 2 +- apps/trading/components/fills-container/fills-container.tsx | 3 +-- libs/fills/src/lib/fills-manager.tsx | 5 ----- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/apps/trading/client-pages/market/trade-grid.tsx b/apps/trading/client-pages/market/trade-grid.tsx index 79433a3b1..4755fd4e5 100644 --- a/apps/trading/client-pages/market/trade-grid.tsx +++ b/apps/trading/client-pages/market/trade-grid.tsx @@ -128,7 +128,7 @@ const MainGrid = memo( ) : null} - + { +export const FillsContainer = () => { const onMarketClick = useMarketClickHandler(true); const { pubKey } = useVegaWallet(); @@ -31,7 +31,6 @@ export const FillsContainer = ({ marketId }: { marketId?: string }) => { return ( diff --git a/libs/fills/src/lib/fills-manager.tsx b/libs/fills/src/lib/fills-manager.tsx index 33a610449..85f2ffcae 100644 --- a/libs/fills/src/lib/fills-manager.tsx +++ b/libs/fills/src/lib/fills-manager.tsx @@ -9,14 +9,12 @@ import { fillsWithMarketProvider } from './fills-data-provider'; interface FillsManagerProps { partyId: string; - marketId?: string; onMarketClick?: (marketId: string, metaKey?: boolean) => void; gridProps: ReturnType; } export const FillsManager = ({ partyId, - marketId, onMarketClick, gridProps, }: FillsManagerProps) => { @@ -24,9 +22,6 @@ export const FillsManager = ({ const filter: Schema.TradesFilter | Schema.TradesSubscriptionFilter = { partyIds: [partyId], }; - if (marketId) { - filter.marketIds = [marketId]; - } const { data, error } = useDataProvider({ dataProvider: fillsWithMarketProvider, update: ({ data }) => { From 539abce8afb7420a4435284962140f3d80ebf762 Mon Sep 17 00:00:00 2001 From: Maciek Date: Tue, 3 Oct 2023 12:08:30 +0200 Subject: [PATCH 22/37] chore(trading): cant view settled market (#4958) --- .../closed-market/closed-market.tsx | 5 ++++ .../client-pages/closed-market/index.ts | 1 + apps/trading/client-pages/market/market.tsx | 30 +++++++++++++++---- apps/trading/client-pages/markets/closed.tsx | 24 +++++++++++++++ .../layouts/layout-with-sidebar.tsx | 4 +++ apps/trading/components/sidebar/sidebar.tsx | 15 ++++++++++ .../lib/hooks/use-market-click-handler.ts | 13 ++++++++ apps/trading/lib/links.ts | 3 ++ apps/trading/pages/client-router.tsx | 6 ++++ 9 files changed, 95 insertions(+), 6 deletions(-) create mode 100644 apps/trading/client-pages/closed-market/closed-market.tsx create mode 100644 apps/trading/client-pages/closed-market/index.ts diff --git a/apps/trading/client-pages/closed-market/closed-market.tsx b/apps/trading/client-pages/closed-market/closed-market.tsx new file mode 100644 index 000000000..e3327f495 --- /dev/null +++ b/apps/trading/client-pages/closed-market/closed-market.tsx @@ -0,0 +1,5 @@ +import MarketPage from '../market'; + +export const ClosedMarketPage = () => { + return ; +}; diff --git a/apps/trading/client-pages/closed-market/index.ts b/apps/trading/client-pages/closed-market/index.ts new file mode 100644 index 000000000..d660b555a --- /dev/null +++ b/apps/trading/client-pages/closed-market/index.ts @@ -0,0 +1 @@ +export { ClosedMarketPage as default } from './closed-market'; diff --git a/apps/trading/client-pages/market/market.tsx b/apps/trading/client-pages/market/market.tsx index fd29cdec0..bc649619a 100644 --- a/apps/trading/client-pages/market/market.tsx +++ b/apps/trading/client-pages/market/market.tsx @@ -9,9 +9,10 @@ import { useGlobalStore, usePageTitleStore } from '../../stores'; import { TradeGrid } from './trade-grid'; import { TradePanels } from './trade-panels'; import { useNavigate, useParams } from 'react-router-dom'; -import { Links } from '../../lib/links'; +import { Links, Routes } from '../../lib/links'; import { ViewType, useSidebar } from '../../components/sidebar'; import { useGetCurrentRouteId } from '../../lib/hooks/use-get-current-route-id'; +import { MarketState } from '@vegaprotocol/types'; const calculatePrice = (markPrice?: string, decimalPlaces?: number) => { return markPrice && decimalPlaces @@ -56,7 +57,7 @@ const TitleUpdater = ({ return null; }; -export const MarketPage = () => { +export const MarketPage = ({ closed }: { closed?: boolean }) => { const { marketId } = useParams(); const navigate = useNavigate(); const currentRouteId = useGetCurrentRouteId(); @@ -70,16 +71,33 @@ export const MarketPage = () => { const { data, error, loading } = useMarket(marketId); useEffect(() => { - if (data?.id && data.id !== lastMarketId) { + if ( + data?.state && + [ + MarketState.STATE_SETTLED, + MarketState.STATE_TRADING_TERMINATED, + ].includes(data.state) && + currentRouteId !== Routes.CLOSED_MARKETS && + marketId + ) { + navigate(Links.CLOSED_MARKETS(marketId)); + } + }, [data?.state, currentRouteId, navigate, marketId]); + + useEffect(() => { + if (data?.id && data.id !== lastMarketId && !closed) { update({ marketId: data.id }); } - }, [update, lastMarketId, data?.id]); + }, [update, lastMarketId, data?.id, closed]); useEffect(() => { if (largeScreen && view === undefined) { - setViews({ type: ViewType.Order }, currentRouteId); + setViews( + { type: closed ? ViewType.Info : ViewType.Order }, + currentRouteId + ); } - }, [setViews, view, currentRouteId, largeScreen]); + }, [setViews, view, currentRouteId, largeScreen, closed]); const pinnedAsset = data && getAsset(data); diff --git a/apps/trading/client-pages/markets/closed.tsx b/apps/trading/client-pages/markets/closed.tsx index de2a71f63..b07349879 100644 --- a/apps/trading/client-pages/markets/closed.tsx +++ b/apps/trading/client-pages/markets/closed.tsx @@ -22,6 +22,8 @@ import { SettlementPriceCell } from './settlement-price-cell'; import { useDataProvider } from '@vegaprotocol/data-provider'; import { MarketCodeCell } from './market-code-cell'; import { MarketActionsDropdown } from './market-table-actions'; +import type { CellClickedEvent } from 'ag-grid-community'; +import { useClosedMarketClickHandler } from '../../lib/hooks/use-market-click-handler'; type SettlementAsset = Pick< Asset, @@ -125,6 +127,7 @@ const ClosedMarketsDataGrid = ({ rowData: Row[]; error: Error | undefined; }) => { + const handleOnSelect = useClosedMarketClickHandler(); const openAssetDialog = useAssetDetailsDialogStore((store) => store.open); const colDefs = useMemo(() => { @@ -281,6 +284,27 @@ const ClosedMarketsDataGrid = ({ overlayNoRowsTemplate={error ? error.message : t('No markets')} components={components} rowHeight={45} + onCellClicked={({ data, column, event }: CellClickedEvent) => { + if (!data) return; + + // prevent navigating to the market page if any of the below cells are clicked + // event.preventDefault or event.stopPropagation dont seem to apply for aggird + const colId = column.getColId(); + + if ( + [ + 'settlementDate', + 'settlementDataOracleId', + 'settlementAsset', + 'market-actions', + ].includes(colId) + ) { + return; + } + + // @ts-ignore metaKey exists + handleOnSelect(data.id, event ? event.metaKey : false); + }} /> ); }; diff --git a/apps/trading/components/layouts/layout-with-sidebar.tsx b/apps/trading/components/layouts/layout-with-sidebar.tsx index a3391f42d..c7f982540 100644 --- a/apps/trading/components/layouts/layout-with-sidebar.tsx +++ b/apps/trading/components/layouts/layout-with-sidebar.tsx @@ -23,6 +23,10 @@ export const LayoutWithSidebar = () => {
} /> + } + /> } />
diff --git a/apps/trading/components/sidebar/sidebar.tsx b/apps/trading/components/sidebar/sidebar.tsx index 9d28a1302..ab44dd4ed 100644 --- a/apps/trading/components/sidebar/sidebar.tsx +++ b/apps/trading/components/sidebar/sidebar.tsx @@ -135,6 +135,21 @@ export const Sidebar = () => { } /> + + + + + + } + />
@@ -614,26 +614,26 @@ export const DealTicket = ({ name="iceberg" control={control} render={({ field }) => ( - - {t(`Trade only a fraction of the order size at once. + + {t(`Trade only a fraction of the order size at once. After the peak size of the order has traded, the size is reset. This is repeated until the order is cancelled, expires, or its full volume trades away. For example, an iceberg order with a size of 1000 and a peak size of 100 will effectively be split into 10 orders with a size of 100 each. Note that the full volume of the order is not hidden and is still reflected in the order book.`)} -

- } - > - {t('Iceberg')} -
+

} - /> + > +
+ +
+ )} />
diff --git a/libs/ui-toolkit/src/components/checkbox/checkbox.tsx b/libs/ui-toolkit/src/components/checkbox/checkbox.tsx index a5f13155c..5c3c8193b 100644 --- a/libs/ui-toolkit/src/components/checkbox/checkbox.tsx +++ b/libs/ui-toolkit/src/components/checkbox/checkbox.tsx @@ -4,6 +4,8 @@ import classNames from 'classnames'; import type { ReactNode } from 'react'; type CheckedState = boolean | 'indeterminate'; +export const labelClasses = + "relative before:content-[''] before:block before:absolute before:top-1/2 before:left-[0] before:right-[0] before:-translate-y-1/2 before:h-6"; export interface CheckboxProps { checked?: CheckedState; label?: ReactNode; @@ -30,7 +32,7 @@ export const Checkbox = ({ ); return ( -
+
+ + ); }; diff --git a/libs/ui-toolkit/src/components/radio-group/radio-group.tsx b/libs/ui-toolkit/src/components/radio-group/radio-group.tsx index f7cb5b173..76e4497b4 100644 --- a/libs/ui-toolkit/src/components/radio-group/radio-group.tsx +++ b/libs/ui-toolkit/src/components/radio-group/radio-group.tsx @@ -2,6 +2,7 @@ import { forwardRef } from 'react'; import * as RadioGroupPrimitive from '@radix-ui/react-radio-group'; import classNames from 'classnames'; import type { ReactNode } from 'react'; +import { labelClasses } from '../checkbox'; export interface RadioGroupProps { name?: string; @@ -56,7 +57,7 @@ interface RadioProps { } export const Radio = ({ id, value, label, disabled }: RadioProps) => { - const wrapperClasses = classNames('flex items-center gap-2', { + const wrapperClasses = classNames('flex items-center gap-2', labelClasses, { 'opacity-40': disabled, }); const itemClasses = classNames( @@ -71,7 +72,7 @@ export const Radio = ({ id, value, label, disabled }: RadioProps) => { 'border-black dark:border-white' ); return ( -
+
+ {label} + ); }; diff --git a/libs/ui-toolkit/src/components/trading-checkbox/checkbox.tsx b/libs/ui-toolkit/src/components/trading-checkbox/checkbox.tsx index 9e1f6befe..cd0ceb3ed 100644 --- a/libs/ui-toolkit/src/components/trading-checkbox/checkbox.tsx +++ b/libs/ui-toolkit/src/components/trading-checkbox/checkbox.tsx @@ -2,6 +2,7 @@ import { VegaIcon, VegaIconNames } from '../icon'; import * as CheckboxPrimitive from '@radix-ui/react-checkbox'; import classNames from 'classnames'; import type { ReactNode } from 'react'; +import { labelClasses } from '../checkbox'; type CheckedState = boolean | 'indeterminate'; export interface TradingCheckboxProps { @@ -29,7 +30,10 @@ export const TradingCheckbox = ({ ); return ( -
+
+ + ); }; diff --git a/libs/ui-toolkit/src/components/trading-radio-group/radio-group.tsx b/libs/ui-toolkit/src/components/trading-radio-group/radio-group.tsx index c9710979d..7c0a3c99f 100644 --- a/libs/ui-toolkit/src/components/trading-radio-group/radio-group.tsx +++ b/libs/ui-toolkit/src/components/trading-radio-group/radio-group.tsx @@ -2,6 +2,7 @@ import { forwardRef } from 'react'; import * as RadioGroupPrimitive from '@radix-ui/react-radio-group'; import classNames from 'classnames'; import type { ReactNode } from 'react'; +import { labelClasses } from '../checkbox'; export interface TradingRadioGroupProps { name?: string; @@ -59,7 +60,10 @@ interface RadioProps { } export const TradingRadio = ({ id, value, label, disabled }: RadioProps) => { - const wrapperClasses = classNames('flex items-center gap-1.5 text-xs'); + const wrapperClasses = classNames( + 'flex items-center gap-1.5 text-xs', + labelClasses + ); const itemClasses = classNames( 'flex justify-center items-center', 'w-3 h-3 rounded-full border', @@ -74,7 +78,7 @@ export const TradingRadio = ({ id, value, label, disabled }: RadioProps) => { 'border-vega-clight-700 dark:border-vega-cdark-700' ); return ( -
+
+ + ); }; From bb4cc1e51d9528e0ac8ba5b2697789afe2266a56 Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 5 Oct 2023 00:12:47 +0100 Subject: [PATCH 34/37] chore(trading): set default sort order (#4978) --- libs/accounts/src/lib/breakdown-table.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/accounts/src/lib/breakdown-table.tsx b/libs/accounts/src/lib/breakdown-table.tsx index d7fc7ae26..cd7df26bf 100644 --- a/libs/accounts/src/lib/breakdown-table.tsx +++ b/libs/accounts/src/lib/breakdown-table.tsx @@ -37,6 +37,7 @@ const BreakdownTable = forwardRef( headerName: t('Market'), field: 'market.tradableInstrument.instrument.code', minWidth: 200, + sort: 'desc', cellRenderer: ({ value, data, @@ -140,6 +141,7 @@ const BreakdownTable = forwardRef( tooltipShowDelay={500} defaultColDef={defaultColDef} columnDefs={coldefs} + domLayout="autoHeight" /> ); } From 3b978118dc83ecf5523071dba7233890c2ccb912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20G=C5=82ownia?= Date: Thu, 5 Oct 2023 07:40:25 +0200 Subject: [PATCH 35/37] feat(deal-ticket): fix margin and fees alignment (#4956) --- .../components/deal-ticket/deal-ticket-fee-details.tsx | 2 +- libs/deal-ticket/src/components/deal-ticket/key-value.tsx | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-fee-details.tsx b/libs/deal-ticket/src/components/deal-ticket/deal-ticket-fee-details.tsx index 0eeb5e511..8e13c0643 100644 --- a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-fee-details.tsx +++ b/libs/deal-ticket/src/components/deal-ticket/deal-ticket-fee-details.tsx @@ -273,7 +273,7 @@ export const DealTicketMarginDetails = ({ key={'value-dropdown'} className="flex items-center justify-between w-full gap-2" > -
+
{t('Margin required')} diff --git a/libs/deal-ticket/src/components/deal-ticket/key-value.tsx b/libs/deal-ticket/src/components/deal-ticket/key-value.tsx index e287461f5..010342c74 100644 --- a/libs/deal-ticket/src/components/deal-ticket/key-value.tsx +++ b/libs/deal-ticket/src/components/deal-ticket/key-value.tsx @@ -25,11 +25,11 @@ export const KeyValue = ({ }: KeyValuePros) => { const displayValue = `${formattedValue ?? '-'} ${symbol || ''}`; const valueElement = onClick ? ( - ) : ( -
{displayValue}
+
{displayValue}
); return (
-
{label}
+
{label}
{valueElement} From f4abd7cef5219b1c7333ae9baca125531d67e5d3 Mon Sep 17 00:00:00 2001 From: daro-maj <119658839+daro-maj@users.noreply.github.com> Date: Thu, 5 Oct 2023 10:05:02 +0200 Subject: [PATCH 36/37] test(trading): remove account test (#4983) --- ...account.cy.ts => vega-wallet-prompt.cy.ts} | 85 +------------------ 1 file changed, 2 insertions(+), 83 deletions(-) rename apps/trading-e2e/src/integration/{trading-deal-ticket-submit-account.cy.ts => vega-wallet-prompt.cy.ts} (52%) diff --git a/apps/trading-e2e/src/integration/trading-deal-ticket-submit-account.cy.ts b/apps/trading-e2e/src/integration/vega-wallet-prompt.cy.ts similarity index 52% rename from apps/trading-e2e/src/integration/trading-deal-ticket-submit-account.cy.ts rename to apps/trading-e2e/src/integration/vega-wallet-prompt.cy.ts index 50c311a44..444f12e3a 100644 --- a/apps/trading-e2e/src/integration/trading-deal-ticket-submit-account.cy.ts +++ b/apps/trading-e2e/src/integration/vega-wallet-prompt.cy.ts @@ -1,92 +1,11 @@ import * as Schema from '@vegaprotocol/types'; -import { aliasGQLQuery } from '@vegaprotocol/cypress'; -import { - accountsQuery, - amendGeneralAccountBalance, - amendMarginAccountBalance, -} from '@vegaprotocol/mock'; import type { OrderSubmission } from '@vegaprotocol/wallet'; import { createOrder } from '../support/create-order'; -describe.skip( - 'account validation', +describe( + 'vega wallet - prompt', { tags: '@regression', testIsolation: true }, () => { - describe.skip('zero balance error', () => { - beforeEach(() => { - cy.setVegaWallet(); - cy.mockTradingPage(); - let accounts = accountsQuery(); - accounts = amendMarginAccountBalance(accounts, 'market-0', '1000'); - accounts = amendGeneralAccountBalance(accounts, 'market-0', '0'); - cy.mockGQL((req) => { - aliasGQLQuery(req, 'Accounts', accounts); - }); - cy.mockSubscription(); - cy.visit('/#/markets/market-0'); - cy.wait('@Markets'); - }); - - it('should show an error if your balance is zero', () => { - const accounts = accountsQuery(); - amendMarginAccountBalance(accounts, 'market-0', '0'); - cy.mockGQL((req) => { - aliasGQLQuery(req, 'Accounts', accounts); - }); - // 7002-SORD-060 - cy.getByTestId('place-order').should('be.enabled'); - // 7002-SORD-003 - cy.getByTestId('deal-ticket-error-message-zero-balance').should( - 'have.text', - 'You need ' + - 'tDAI' + - ' in your wallet to trade in this market. See all your collateral.Make a deposit' - ); - cy.getByTestId('deal-ticket-deposit-dialog-button').should('exist'); - }); - }); - - describe('not enough balance warning', () => { - beforeEach(() => { - cy.setVegaWallet(); - cy.mockTradingPage(); - let accounts = accountsQuery(); - accounts = amendMarginAccountBalance(accounts, 'market-0', '1000'); - accounts = amendGeneralAccountBalance(accounts, 'market-0', '1'); - cy.mockGQL((req) => { - aliasGQLQuery(req, 'Accounts', accounts); - }); - cy.mockSubscription(); - cy.visit('/#/markets/market-0'); - cy.wait('@Markets'); - - cy.get('[data-testid="deal-ticket-form"]').then(($form) => { - if (!$form.length) { - cy.getByTestId('Order').click(); - } - }); - }); - - it('should display info and button for deposit', () => { - // 7002-SORD-003 - - // warning should show immediately - cy.getByTestId('deal-ticket-warning-margin').should( - 'contain.text', - 'You may not have enough margin available to open this position' - ); - cy.getByTestId('deal-ticket-warning-margin').should( - 'contain.text', - 'You may not have enough margin available to open this position. 5.00 tDAI is currently required. You have only 0.01001 tDAI available.' - ); - cy.getByTestId('deal-ticket-deposit-dialog-button').click(); - cy.getByTestId('sidebar-content') - .find('h2') - .eq(0) - .should('have.text', 'Deposit'); - }); - }); - describe('must submit order', { tags: '@smoke' }, () => { // 7002-SORD-039 beforeEach(() => { From 6dbde76c84fec35f79d5579e39747e01c50a2989 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20G=C5=82ownia?= Date: Thu, 5 Oct 2023 11:25:54 +0200 Subject: [PATCH 37/37] chore(wallet): remove dependency on apollo from wallet lib (#4814) --- .../src/integration/view/validators.cy.ts | 16 +- .../src/integration/view/wallet-vega.cy.ts | 12 +- apps/governance-e2e/src/support/index.js | 7 +- apps/governance/src/app.tsx | 4 +- .../proposal-form-transaction-dialog.tsx | 2 +- .../components/vote-details/user-vote.tsx | 2 +- .../vega-transaction-dialog.spec.tsx | 2 +- .../components/vote-details/vote-buttons.tsx | 2 +- .../vote-details/vote-transaction-dialog.tsx | 2 +- apps/trading-e2e/src/support/trading.ts | 5 +- .../referrals/apply-code-form.tsx | 6 +- .../withdraw-container/withdraw-container.tsx | 2 +- apps/trading/pages/_app.page.tsx | 6 +- libs/accounts/src/lib/transfer-container.tsx | 3 +- libs/cypress/mock.ts | 1 - libs/cypress/src/index.ts | 3 +- .../cypress/src/lib/commands/mock-chain-id.ts | 21 +- libs/cypress/src/lib/mock-gql.ts | 11 + .../deal-ticket/deal-ticket-container.tsx | 2 +- .../open-orders-menu/open-orders-menu.tsx | 3 +- .../order-data-provider/Orders.graphql | 12 -- .../__generated__/Orders.ts | 86 +------- .../order-list-manager/order-list-manager.tsx | 8 +- .../order-list/order-list.stories.tsx | 23 +-- .../stop-orders-manager.tsx | 2 +- libs/orders/src/lib/order-hooks/index.ts | 1 - .../src/lib/order-hooks/use-order-update.ts | 60 ------ libs/orders/src/lib/utils.spec.ts | 107 +--------- libs/orders/src/lib/utils.ts | 71 ------- .../src/lib/positions-manager.spec.tsx | 3 + libs/positions/src/lib/positions-manager.tsx | 3 +- libs/proposals/src/components/index.ts | 1 + .../vega-transaction-dialog/index.ts | 0 .../vega-transaction-dialog.spec.tsx | 8 +- .../vega-transaction-dialog.tsx | 6 +- .../src/lib/proposals-hooks/index.ts | 1 + .../lib/proposals-hooks/use-proposal-event.ts | 2 +- .../proposals-hooks/use-proposal-submit.ts | 7 +- .../use-vega-transaction.spec.tsx | 13 +- .../proposals-hooks}/use-vega-transaction.tsx | 28 ++- .../src/lib/voting-hooks/use-vote-event.ts | 2 +- .../src/lib/voting-hooks/use-vote-submit.ts | 3 +- .../wallet/src/connect-dialog/ChainId.graphql | 5 - .../connect-dialog/__generated__/ChainId.ts | 45 ---- .../src/connect-dialog/chain-id.mock.ts | 16 -- .../connect-dialog/connect-dialog.spec.tsx | 31 +-- .../src/connect-dialog/connect-dialog.tsx | 8 +- .../wallet/src/connect-dialog/use-chain-id.ts | 37 ++++ libs/wallet/src/index.ts | 9 - libs/web3/src/index.ts | 7 + libs/web3/src/lib/Orders.graphql | 74 +++++++ .../src/lib}/TransactionResult.graphql | 0 .../src/lib}/WithdrawalApproval.graphql | 0 libs/web3/src/lib/__generated__/Orders.ts | 153 ++++++++++++++ .../lib}/__generated__/TransactionResult.ts | 0 .../lib}/__generated__/WithdrawalApproval.ts | 0 libs/web3/src/lib/setup-tests.ts | 4 + libs/{wallet/src => web3/src/lib}/types.ts | 0 .../lib/use-ethereum-transaction-store.tsx | 2 +- .../use-ethereum-transaction-updater.spec.tsx | 10 +- .../lib/use-ethereum-transaction-updater.tsx | 6 +- ...hereum-withdraw-approvals-manager.spec.tsx | 4 +- ...se-ethereum-withdraw-approvals-manager.tsx | 4 +- ...ethereum-withdraw-approvals-store.spec.tsx | 4 +- .../use-ethereum-withdraw-approvals-store.tsx | 6 +- .../src/lib/use-get-withdraw-threshold.tsx | 2 +- .../src/lib}/use-transaction-result.spec.tsx | 0 .../src/lib}/use-transaction-result.ts | 0 .../use-vega-transaction-manager.spec.tsx | 7 +- .../src/lib}/use-vega-transaction-manager.tsx | 4 +- .../lib}/use-vega-transaction-store.spec.tsx | 6 +- .../src/lib}/use-vega-transaction-store.tsx | 6 +- .../lib/use-vega-transaction-toasts.spec.tsx | 113 ++++++++++- .../src/lib/use-vega-transaction-toasts.tsx | 86 +++++++- .../use-vega-transaction-updater.spec.tsx | 2 +- .../src/lib}/use-vega-transaction-updater.tsx | 2 +- .../lib}/wait-for-withdrawal-approval.spec.ts | 0 .../src/lib}/wait-for-withdrawal-approval.ts | 0 .../src/lib/withdrawal-approval-dialog.tsx | 2 +- libs/withdraws/src/index.ts | 2 - .../src/lib/create-withdrawal-dialog.tsx | 2 +- .../src/lib/use-create-withdraw.spec.tsx | 192 ------------------ libs/withdraws/src/lib/use-create-withdraw.ts | 79 ------- ...se-ready-to-complete-withdrawals-toast.tsx | 6 +- .../withdraws/src/lib/use-withdrawal-event.ts | 2 +- .../src/lib/withdraw-form-container.tsx | 3 +- libs/withdraws/src/lib/withdraw-form.tsx | 8 +- libs/withdraws/src/lib/withdraw-manager.tsx | 2 +- libs/withdraws/src/lib/withdrawal-dialog.tsx | 53 ----- .../withdraws/src/lib/withdrawal-feedback.tsx | 2 +- 90 files changed, 632 insertions(+), 933 deletions(-) delete mode 100644 libs/orders/src/lib/order-hooks/use-order-update.ts rename libs/{wallet/src => proposals/src/components}/vega-transaction-dialog/index.ts (100%) rename libs/{wallet/src => proposals/src/components}/vega-transaction-dialog/vega-transaction-dialog.spec.tsx (94%) rename libs/{wallet/src => proposals/src/components}/vega-transaction-dialog/vega-transaction-dialog.tsx (96%) rename libs/{wallet/src => proposals/src/lib/proposals-hooks}/use-vega-transaction.spec.tsx (93%) rename libs/{wallet/src => proposals/src/lib/proposals-hooks}/use-vega-transaction.tsx (82%) delete mode 100644 libs/wallet/src/connect-dialog/ChainId.graphql delete mode 100644 libs/wallet/src/connect-dialog/__generated__/ChainId.ts delete mode 100644 libs/wallet/src/connect-dialog/chain-id.mock.ts create mode 100644 libs/wallet/src/connect-dialog/use-chain-id.ts create mode 100644 libs/web3/src/lib/Orders.graphql rename libs/{wallet/src => web3/src/lib}/TransactionResult.graphql (100%) rename libs/{wallet/src => web3/src/lib}/WithdrawalApproval.graphql (100%) create mode 100644 libs/web3/src/lib/__generated__/Orders.ts rename libs/{wallet/src => web3/src/lib}/__generated__/TransactionResult.ts (100%) rename libs/{wallet/src => web3/src/lib}/__generated__/WithdrawalApproval.ts (100%) create mode 100644 libs/web3/src/lib/setup-tests.ts rename libs/{wallet/src => web3/src/lib}/types.ts (100%) rename libs/{wallet/src => web3/src/lib}/use-transaction-result.spec.tsx (100%) rename libs/{wallet/src => web3/src/lib}/use-transaction-result.ts (100%) rename libs/{wallet/src => web3/src/lib}/use-vega-transaction-manager.spec.tsx (94%) rename libs/{wallet/src => web3/src/lib}/use-vega-transaction-manager.tsx (93%) rename libs/{wallet/src => web3/src/lib}/use-vega-transaction-store.spec.tsx (97%) rename libs/{wallet/src => web3/src/lib}/use-vega-transaction-store.tsx (98%) rename libs/{wallet/src => web3/src/lib}/use-vega-transaction-updater.spec.tsx (99%) rename libs/{wallet/src => web3/src/lib}/use-vega-transaction-updater.tsx (97%) rename libs/{wallet/src => web3/src/lib}/wait-for-withdrawal-approval.spec.ts (100%) rename libs/{wallet/src => web3/src/lib}/wait-for-withdrawal-approval.ts (100%) delete mode 100644 libs/withdraws/src/lib/use-create-withdraw.spec.tsx delete mode 100644 libs/withdraws/src/lib/use-create-withdraw.ts diff --git a/apps/governance-e2e/src/integration/view/validators.cy.ts b/apps/governance-e2e/src/integration/view/validators.cy.ts index 2ed63d8ba..496a29069 100644 --- a/apps/governance-e2e/src/integration/view/validators.cy.ts +++ b/apps/governance-e2e/src/integration/view/validators.cy.ts @@ -11,7 +11,6 @@ import { waitForBeginningOfEpoch, } from '../../support/staking.functions'; import { previousEpochData } from '../../fixtures/mocks/previous-epoch'; -import { chainIdQuery, statisticsQuery } from '@vegaprotocol/mock'; const guideLink = 'staking-guide-link'; const validatorTitle = 'validator-node-title'; @@ -38,17 +37,11 @@ const txTimeout = Cypress.env('txTimeout'); context('Validators Page - verify elements on page', function () { before('navigate to validators page', () => { - cy.mockGQL((req) => { - aliasGQLQuery(req, 'ChainId', chainIdQuery()); - aliasGQLQuery(req, 'Statistics', statisticsQuery()); - }); + cy.mockChainId(); cy.visit('/validators'); }); beforeEach(() => { - cy.mockGQL((req) => { - aliasGQLQuery(req, 'ChainId', chainIdQuery()); - aliasGQLQuery(req, 'Statistics', statisticsQuery()); - }); + cy.mockChainId(); }); describe('with wallets disconnected', { tags: '@smoke' }, function () { @@ -189,10 +182,7 @@ context('Validators Page - verify elements on page', function () { { tags: '@smoke' }, function () { before('connect wallets and click on validator', function () { - cy.mockGQL((req) => { - aliasGQLQuery(req, 'ChainId', chainIdQuery()); - aliasGQLQuery(req, 'Statistics', statisticsQuery()); - }); + cy.mockChainId(); cy.visit('/validators'); cy.connectVegaWallet(); clickOnValidatorFromList(0); diff --git a/apps/governance-e2e/src/integration/view/wallet-vega.cy.ts b/apps/governance-e2e/src/integration/view/wallet-vega.cy.ts index df7d4682f..942490c08 100644 --- a/apps/governance-e2e/src/integration/view/wallet-vega.cy.ts +++ b/apps/governance-e2e/src/integration/view/wallet-vega.cy.ts @@ -4,8 +4,6 @@ import { vegaWalletFaucetAssetsWithoutCheck, vegaWalletTeardown, } from '../../support/wallet-functions'; -import { aliasGQLQuery } from '@vegaprotocol/cypress'; -import { chainIdQuery, statisticsQuery } from '@vegaprotocol/mock'; const walletContainer = 'aside [data-testid="vega-wallet"]'; const walletHeader = '[data-testid="wallet-header"] h1'; @@ -88,10 +86,7 @@ context( describe('when vega wallet connected', function () { before('connect vega wallet', function () { - cy.mockGQL((req) => { - aliasGQLQuery(req, 'ChainId', chainIdQuery()); - aliasGQLQuery(req, 'Statistics', statisticsQuery()); - }); + cy.mockChainId(); cy.visit('/'); cy.wait('@ChainId'); cy.connectVegaWallet(); @@ -276,10 +271,7 @@ context( ]; before('faucet assets to connected vega wallet', function () { - cy.mockGQL((req) => { - aliasGQLQuery(req, 'ChainId', chainIdQuery()); - aliasGQLQuery(req, 'Statistics', statisticsQuery()); - }); + cy.mockChainId(); for (const { id, amount } of assets) { vegaWalletFaucetAssetsWithoutCheck(id, amount, vegaWalletPublicKey); } diff --git a/apps/governance-e2e/src/support/index.js b/apps/governance-e2e/src/support/index.js index 9527fd3ff..b1eedef94 100644 --- a/apps/governance-e2e/src/support/index.js +++ b/apps/governance-e2e/src/support/index.js @@ -9,8 +9,6 @@ import './wallet-functions.ts'; import './proposal.functions.ts'; import 'cypress-mochawesome-reporter/register'; import registerCypressGrep from '@cypress/grep'; -import { aliasGQLQuery } from '@vegaprotocol/cypress'; -import { chainIdQuery, statisticsQuery } from '@vegaprotocol/mock'; import { turnTelemetryOff } from './common.functions.ts'; registerCypressGrep(); @@ -29,10 +27,7 @@ before(() => { // // Ensuring the telemetry modal doesn't disrupt the tests turnTelemetryOff(); // Mock chainId fetch which happens on every page for wallet connection - cy.mockGQL((req) => { - aliasGQLQuery(req, 'ChainId', chainIdQuery()); - aliasGQLQuery(req, 'Statistics', statisticsQuery()); - }); + cy.mockChainId(); // Self stake validators so they are displayed cy.validatorsSelfDelegate(); }); diff --git a/apps/governance/src/app.tsx b/apps/governance/src/app.tsx index c7c3850b2..098a6b865 100644 --- a/apps/governance/src/app.tsx +++ b/apps/governance/src/app.tsx @@ -26,11 +26,11 @@ import { } from '@vegaprotocol/web3'; import { Web3Provider } from '@vegaprotocol/web3'; import { VegaWalletDialogs } from './components/vega-wallet-dialogs'; +import { VegaWalletProvider } from '@vegaprotocol/wallet'; import { useVegaTransactionManager, useVegaTransactionUpdater, - VegaWalletProvider, -} from '@vegaprotocol/wallet'; +} from '@vegaprotocol/web3'; import { AsyncRenderer } from '@vegaprotocol/ui-toolkit'; import { useEthereumConfig } from '@vegaprotocol/web3'; import { diff --git a/apps/governance/src/routes/proposals/components/propose/proposal-form-transaction-dialog.tsx b/apps/governance/src/routes/proposals/components/propose/proposal-form-transaction-dialog.tsx index 1761981f8..e9bbd0db8 100644 --- a/apps/governance/src/routes/proposals/components/propose/proposal-form-transaction-dialog.tsx +++ b/apps/governance/src/routes/proposals/components/propose/proposal-form-transaction-dialog.tsx @@ -4,7 +4,7 @@ import { getProposalDialogTitle, } from '@vegaprotocol/proposals'; import type { ProposalEventFieldsFragment } from '@vegaprotocol/proposals'; -import type { DialogProps } from '@vegaprotocol/wallet'; +import type { DialogProps } from '@vegaprotocol/proposals'; interface ProposalFormTransactionDialogProps { finalizedProposal: ProposalEventFieldsFragment | null; diff --git a/apps/governance/src/routes/proposals/components/vote-details/user-vote.tsx b/apps/governance/src/routes/proposals/components/vote-details/user-vote.tsx index 70e764d18..67624194e 100644 --- a/apps/governance/src/routes/proposals/components/vote-details/user-vote.tsx +++ b/apps/governance/src/routes/proposals/components/vote-details/user-vote.tsx @@ -6,7 +6,7 @@ import { ConnectToVega } from '../../../../components/connect-to-vega'; import { VoteButtonsContainer } from './vote-buttons'; import { SubHeading } from '../../../../components/heading'; import type { VoteValue } from '@vegaprotocol/types'; -import type { DialogProps, VegaTxState } from '@vegaprotocol/wallet'; +import type { DialogProps, VegaTxState } from '@vegaprotocol/proposals'; import type { ProposalFieldsFragment } from '../../proposals/__generated__/Proposals'; import type { ProposalQuery } from '../../proposal/__generated__/Proposal'; import type { VoteState } from './use-user-vote'; diff --git a/apps/governance/src/routes/proposals/components/vote-details/vega-transaction-dialog.spec.tsx b/apps/governance/src/routes/proposals/components/vote-details/vega-transaction-dialog.spec.tsx index 6ef513333..4fa7dc6cc 100644 --- a/apps/governance/src/routes/proposals/components/vote-details/vega-transaction-dialog.spec.tsx +++ b/apps/governance/src/routes/proposals/components/vote-details/vega-transaction-dialog.spec.tsx @@ -1,7 +1,7 @@ import { render, screen } from '@testing-library/react'; import { VoteTransactionDialog } from './vote-transaction-dialog'; import { VoteState } from './use-user-vote'; -import { VegaTxStatus } from '@vegaprotocol/wallet'; +import { VegaTxStatus } from '@vegaprotocol/proposals'; describe('VoteTransactionDialog', () => { const mockTransactionDialog = jest.fn(({ title, content }) => ( diff --git a/apps/governance/src/routes/proposals/components/vote-details/vote-buttons.tsx b/apps/governance/src/routes/proposals/components/vote-details/vote-buttons.tsx index 911c2d41a..a528ebff2 100644 --- a/apps/governance/src/routes/proposals/components/vote-details/vote-buttons.tsx +++ b/apps/governance/src/routes/proposals/components/vote-details/vote-buttons.tsx @@ -17,7 +17,7 @@ import { VoteState } from './use-user-vote'; import { ProposalMinRequirements, ProposalUserAction } from '../shared'; import { VoteTransactionDialog } from './vote-transaction-dialog'; import { useVoteButtonsQuery } from './__generated__/Stake'; -import type { DialogProps, VegaTxState } from '@vegaprotocol/wallet'; +import type { DialogProps, VegaTxState } from '@vegaprotocol/proposals'; interface VoteButtonsContainerProps { voteState: VoteState | null; diff --git a/apps/governance/src/routes/proposals/components/vote-details/vote-transaction-dialog.tsx b/apps/governance/src/routes/proposals/components/vote-details/vote-transaction-dialog.tsx index c0d9b3da9..5980a9c6f 100644 --- a/apps/governance/src/routes/proposals/components/vote-details/vote-transaction-dialog.tsx +++ b/apps/governance/src/routes/proposals/components/vote-details/vote-transaction-dialog.tsx @@ -1,6 +1,6 @@ import { t } from '@vegaprotocol/i18n'; import { VoteState } from './use-user-vote'; -import type { DialogProps, VegaTxState } from '@vegaprotocol/wallet'; +import type { DialogProps, VegaTxState } from '@vegaprotocol/proposals'; interface VoteTransactionDialogProps { voteState: VoteState; diff --git a/apps/trading-e2e/src/support/trading.ts b/apps/trading-e2e/src/support/trading.ts index e4b7cc8b7..faa005822 100644 --- a/apps/trading-e2e/src/support/trading.ts +++ b/apps/trading-e2e/src/support/trading.ts @@ -7,7 +7,6 @@ import { assetQuery, assetsQuery, candlesQuery, - chainIdQuery, chartQuery, depositsQuery, estimateFeesQuery, @@ -25,7 +24,6 @@ import { estimatePositionQuery, positionsQuery, proposalListQuery, - statisticsQuery, tradesQuery, withdrawalsQuery, protocolUpgradeProposalsQuery, @@ -91,8 +89,6 @@ const mockTradingPage = ( tradingMode?: Schema.MarketTradingMode, trigger?: Schema.AuctionTrigger ) => { - aliasGQLQuery(req, 'ChainId', chainIdQuery()); - aliasGQLQuery(req, 'NodeCheck', statisticsQuery()); aliasGQLQuery(req, 'NodeGuard', nodeGuardQuery()); aliasGQLQuery( req, @@ -218,6 +214,7 @@ export const addMockTradingPage = () => { trigger, oracleStatus ) => { + cy.mockChainId(); cy.mockGQL((req) => { mockTradingPage(req, state, tradingMode, trigger); }); diff --git a/apps/trading/client-pages/referrals/apply-code-form.tsx b/apps/trading/client-pages/referrals/apply-code-form.tsx index 44d3c8f26..3f9b2826d 100644 --- a/apps/trading/client-pages/referrals/apply-code-form.tsx +++ b/apps/trading/client-pages/referrals/apply-code-form.tsx @@ -10,12 +10,10 @@ import classNames from 'classnames'; import { Navigate, useSearchParams } from 'react-router-dom'; import { useEffect, useRef, useState } from 'react'; import { Button } from './buttons'; -import { - useTransactionEventSubscription, - useVegaWallet, -} from '@vegaprotocol/wallet'; +import { useVegaWallet } from '@vegaprotocol/wallet'; import { useReferral } from './hooks/use-referral'; import { Routes } from '../../lib/links'; +import { useTransactionEventSubscription } from '@vegaprotocol/web3'; export const ApplyCodeForm = () => { const [status, setStatus] = useState< diff --git a/apps/trading/components/withdraw-container/withdraw-container.tsx b/apps/trading/components/withdraw-container/withdraw-container.tsx index e8810b5f3..faa76f6ac 100644 --- a/apps/trading/components/withdraw-container/withdraw-container.tsx +++ b/apps/trading/components/withdraw-container/withdraw-container.tsx @@ -1,6 +1,6 @@ import { useVegaWallet } from '@vegaprotocol/wallet'; import { WithdrawFormContainer } from '@vegaprotocol/withdraws'; -import { useVegaTransactionStore } from '@vegaprotocol/wallet'; +import { useVegaTransactionStore } from '@vegaprotocol/web3'; export const WithdrawContainer = ({ assetId }: { assetId?: string }) => { const { pubKey } = useVegaWallet(); diff --git a/apps/trading/pages/_app.page.tsx b/apps/trading/pages/_app.page.tsx index c9677744d..27b3cddfb 100644 --- a/apps/trading/pages/_app.page.tsx +++ b/apps/trading/pages/_app.page.tsx @@ -4,10 +4,12 @@ import type { AppProps } from 'next/app'; import { t } from '@vegaprotocol/i18n'; import { useEagerConnect as useVegaEagerConnect, - useVegaTransactionManager, - useVegaTransactionUpdater, useVegaWallet, } from '@vegaprotocol/wallet'; +import { + useVegaTransactionManager, + useVegaTransactionUpdater, +} from '@vegaprotocol/web3'; import { useEagerConnect as useEthereumEagerConnect, useEthTransactionManager, diff --git a/libs/accounts/src/lib/transfer-container.tsx b/libs/accounts/src/lib/transfer-container.tsx index b8dca4110..c831fe624 100644 --- a/libs/accounts/src/lib/transfer-container.tsx +++ b/libs/accounts/src/lib/transfer-container.tsx @@ -7,7 +7,8 @@ import { } from '@vegaprotocol/network-parameters'; import { useDataProvider } from '@vegaprotocol/data-provider'; import type { Transfer } from '@vegaprotocol/wallet'; -import { useVegaTransactionStore, useVegaWallet } from '@vegaprotocol/wallet'; +import { useVegaTransactionStore } from '@vegaprotocol/web3'; +import { useVegaWallet } from '@vegaprotocol/wallet'; import { useCallback, useMemo } from 'react'; import { accountsDataProvider } from './accounts-data-provider'; import { TransferForm } from './transfer-form'; diff --git a/libs/cypress/mock.ts b/libs/cypress/mock.ts index 598b05b3f..ba354853b 100644 --- a/libs/cypress/mock.ts +++ b/libs/cypress/mock.ts @@ -22,7 +22,6 @@ export * from '../markets/src/lib/oracle-spec-data-connection.mock'; export * from '../orders/src/lib/components/order-data-provider/orders.mock'; export * from '../positions/src/lib/positions.mock'; export * from '../network-parameters/src/network-params.mock'; -export * from '../wallet/src/connect-dialog/chain-id.mock'; export * from '../positions/src/lib/estimate-position.mock'; export * from '../trades/src/lib/trades.mock'; export * from '../withdraws/src/lib/withdrawal.mock'; diff --git a/libs/cypress/src/index.ts b/libs/cypress/src/index.ts index b2a77bdff..ea181b01f 100644 --- a/libs/cypress/src/index.ts +++ b/libs/cypress/src/index.ts @@ -1,5 +1,5 @@ import { addGetTestIdcommand } from './lib/commands/get-by-test-id'; -import { addMockGQLCommand } from './lib/mock-gql'; +import { addMockGQLCommand, addMockStatistics } from './lib/mock-gql'; import { addMockSubscription } from './lib/mock-ws'; import { addMockWalletCommand } from './lib/mock-rest'; import { addMockWeb3ProviderCommand } from './lib/commands/mock-web3-provider'; @@ -28,6 +28,7 @@ import { addMockChainId } from './lib/commands/mock-chain-id'; addGetTestIdcommand(); addMockGQLCommand(); +addMockStatistics(); addMockSubscription(); addMockWalletCommand(); addMockWeb3ProviderCommand(); diff --git a/libs/cypress/src/lib/commands/mock-chain-id.ts b/libs/cypress/src/lib/commands/mock-chain-id.ts index 541c05c80..1c90f7938 100644 --- a/libs/cypress/src/lib/commands/mock-chain-id.ts +++ b/libs/cypress/src/lib/commands/mock-chain-id.ts @@ -1,6 +1,6 @@ import { aliasGQLQuery } from '../mock-gql'; // eslint-disable-next-line @nx/enforce-module-boundaries -import { chainIdQuery, statisticsQuery } from '@vegaprotocol/mock'; +import { statisticsQuery } from '@vegaprotocol/mock'; declare global { // eslint-disable-next-line @typescript-eslint/no-namespace @@ -12,11 +12,26 @@ declare global { } } +const chainId = 'test-id'; + export function addMockChainId() { Cypress.Commands.add('mockChainId', () => { + const result = { + statistics: { + chainId, + }, + }; cy.mockGQL((req) => { - aliasGQLQuery(req, 'ChainId', chainIdQuery()); - aliasGQLQuery(req, 'Statistics', statisticsQuery()); + aliasGQLQuery(req, 'NodeCheck', statisticsQuery(result)); + }); + cy.mockStatistics((req) => { + req.reply({ + statusCode: 200, + body: result, + headers: { + 'Content-Type': 'application/json', + }, + }); }); }); } diff --git a/libs/cypress/src/lib/mock-gql.ts b/libs/cypress/src/lib/mock-gql.ts index f8a9512be..34a3e83fc 100644 --- a/libs/cypress/src/lib/mock-gql.ts +++ b/libs/cypress/src/lib/mock-gql.ts @@ -8,6 +8,7 @@ declare global { // eslint-disable-next-line @typescript-eslint/no-unused-vars interface Chainable { mockGQL(handler: RouteHandler): void; + mockStatistics(handler: RouteHandler): void; } } } @@ -40,6 +41,16 @@ const extractVariables = (req: CyHttpMessages.IncomingHttpRequest): object => { ); }; +export function addMockStatistics() { + Cypress.Commands.add('mockStatistics', (handler: RouteHandler) => { + cy.intercept( + 'GET', + Cypress.env('VEGA_URL').replace('graphql', 'statistics'), + handler + ).as('ChainId'); + }); +} + export function addMockGQLCommand() { Cypress.Commands.add('mockGQL', (handler: RouteHandler) => { cy.intercept('POST', Cypress.env('VEGA_URL'), handler).as('GQL'); diff --git a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-container.tsx b/libs/deal-ticket/src/components/deal-ticket/deal-ticket-container.tsx index 37673f3a8..4ae9a04f7 100644 --- a/libs/deal-ticket/src/components/deal-ticket/deal-ticket-container.tsx +++ b/libs/deal-ticket/src/components/deal-ticket/deal-ticket-container.tsx @@ -1,4 +1,4 @@ -import { useVegaTransactionStore } from '@vegaprotocol/wallet'; +import { useVegaTransactionStore } from '@vegaprotocol/web3'; import { isStopOrderType, useDealTicketFormValues, diff --git a/libs/orders/src/lib/components/open-orders-menu/open-orders-menu.tsx b/libs/orders/src/lib/components/open-orders-menu/open-orders-menu.tsx index 1f3879aa1..8716d46fe 100644 --- a/libs/orders/src/lib/components/open-orders-menu/open-orders-menu.tsx +++ b/libs/orders/src/lib/components/open-orders-menu/open-orders-menu.tsx @@ -1,6 +1,7 @@ import { t } from '@vegaprotocol/i18n'; import { TradingButton } from '@vegaprotocol/ui-toolkit'; -import { useVegaTransactionStore, useVegaWallet } from '@vegaprotocol/wallet'; +import { useVegaWallet } from '@vegaprotocol/wallet'; +import { useVegaTransactionStore } from '@vegaprotocol/web3'; import { useHasAmendableOrder } from '../../order-hooks'; export const OpenOrdersMenu = ({ marketId }: { marketId: string }) => { diff --git a/libs/orders/src/lib/components/order-data-provider/Orders.graphql b/libs/orders/src/lib/components/order-data-provider/Orders.graphql index 85bef975a..bc8db1163 100644 --- a/libs/orders/src/lib/components/order-data-provider/Orders.graphql +++ b/libs/orders/src/lib/components/order-data-provider/Orders.graphql @@ -32,12 +32,6 @@ fragment OrderFields on Order { } } -query OrderById($orderId: ID!) { - orderByID(id: $orderId) { - ...OrderFields - } -} - query Orders( $partyId: ID! $marketIds: [ID!] @@ -153,9 +147,3 @@ query StopOrders($filter: StopOrderFilter) { } } } - -query StopOrderById($stopOrderId: ID!) { - stopOrder(id: $stopOrderId) { - ...StopOrderFields - } -} diff --git a/libs/orders/src/lib/components/order-data-provider/__generated__/Orders.ts b/libs/orders/src/lib/components/order-data-provider/__generated__/Orders.ts index 94507dbb4..8dfd89d10 100644 --- a/libs/orders/src/lib/components/order-data-provider/__generated__/Orders.ts +++ b/libs/orders/src/lib/components/order-data-provider/__generated__/Orders.ts @@ -5,13 +5,6 @@ import * as Apollo from '@apollo/client'; const defaultOptions = {} as const; export type OrderFieldsFragment = { __typename?: 'Order', id: string, type?: Types.OrderType | null, side: Types.Side, size: string, status: Types.OrderStatus, rejectionReason?: Types.OrderRejectionReason | null, price: string, timeInForce: Types.OrderTimeInForce, remaining: string, expiresAt?: any | null, createdAt: any, updatedAt?: any | null, postOnly?: boolean | null, reduceOnly?: boolean | null, market: { __typename?: 'Market', id: string }, liquidityProvision?: { __typename: 'LiquidityProvision' } | null, peggedOrder?: { __typename: 'PeggedOrder', reference: Types.PeggedReference, offset: string } | null, icebergOrder?: { __typename: 'IcebergOrder', peakSize: string, minimumVisibleSize: string, reservedRemaining: string } | null }; -export type OrderByIdQueryVariables = Types.Exact<{ - orderId: Types.Scalars['ID']; -}>; - - -export type OrderByIdQuery = { __typename?: 'Query', orderByID: { __typename?: 'Order', id: string, type?: Types.OrderType | null, side: Types.Side, size: string, status: Types.OrderStatus, rejectionReason?: Types.OrderRejectionReason | null, price: string, timeInForce: Types.OrderTimeInForce, remaining: string, expiresAt?: any | null, createdAt: any, updatedAt?: any | null, postOnly?: boolean | null, reduceOnly?: boolean | null, market: { __typename?: 'Market', id: string }, liquidityProvision?: { __typename: 'LiquidityProvision' } | null, peggedOrder?: { __typename: 'PeggedOrder', reference: Types.PeggedReference, offset: string } | null, icebergOrder?: { __typename: 'IcebergOrder', peakSize: string, minimumVisibleSize: string, reservedRemaining: string } | null } }; - export type OrdersQueryVariables = Types.Exact<{ partyId: Types.Scalars['ID']; marketIds?: Types.InputMaybe | Types.Scalars['ID']>; @@ -43,13 +36,6 @@ export type StopOrdersQueryVariables = Types.Exact<{ export type StopOrdersQuery = { __typename?: 'Query', stopOrders?: { __typename?: 'StopOrderConnection', edges?: Array<{ __typename?: 'StopOrderEdge', node?: { __typename?: 'StopOrder', id: string, ocoLinkId?: string | null, expiresAt?: any | null, expiryStrategy?: Types.StopOrderExpiryStrategy | null, triggerDirection: Types.StopOrderTriggerDirection, status: Types.StopOrderStatus, createdAt: any, updatedAt?: any | null, partyId: string, marketId: string, order?: { __typename?: 'Order', id: string, type?: Types.OrderType | null, side: Types.Side, size: string, status: Types.OrderStatus, rejectionReason?: Types.OrderRejectionReason | null, price: string, timeInForce: Types.OrderTimeInForce, remaining: string, expiresAt?: any | null, createdAt: any, updatedAt?: any | null, postOnly?: boolean | null, reduceOnly?: boolean | null, market: { __typename?: 'Market', id: string }, liquidityProvision?: { __typename: 'LiquidityProvision' } | null, peggedOrder?: { __typename: 'PeggedOrder', reference: Types.PeggedReference, offset: string } | null, icebergOrder?: { __typename: 'IcebergOrder', peakSize: string, minimumVisibleSize: string, reservedRemaining: string } | null } | null, trigger: { __typename?: 'StopOrderPrice', price: string } | { __typename?: 'StopOrderTrailingPercentOffset', trailingPercentOffset: string }, submission: { __typename?: 'OrderSubmission', marketId: string, price: string, size: string, side: Types.Side, timeInForce: Types.OrderTimeInForce, expiresAt: any, type: Types.OrderType, reference?: string | null, postOnly?: boolean | null, reduceOnly?: boolean | null, peggedOrder?: { __typename?: 'PeggedOrder', reference: Types.PeggedReference, offset: string } | null } } | null }> | null } | null }; -export type StopOrderByIdQueryVariables = Types.Exact<{ - stopOrderId: Types.Scalars['ID']; -}>; - - -export type StopOrderByIdQuery = { __typename?: 'Query', stopOrder?: { __typename?: 'StopOrder', id: string, ocoLinkId?: string | null, expiresAt?: any | null, expiryStrategy?: Types.StopOrderExpiryStrategy | null, triggerDirection: Types.StopOrderTriggerDirection, status: Types.StopOrderStatus, createdAt: any, updatedAt?: any | null, partyId: string, marketId: string, order?: { __typename?: 'Order', id: string, type?: Types.OrderType | null, side: Types.Side, size: string, status: Types.OrderStatus, rejectionReason?: Types.OrderRejectionReason | null, price: string, timeInForce: Types.OrderTimeInForce, remaining: string, expiresAt?: any | null, createdAt: any, updatedAt?: any | null, postOnly?: boolean | null, reduceOnly?: boolean | null, market: { __typename?: 'Market', id: string }, liquidityProvision?: { __typename: 'LiquidityProvision' } | null, peggedOrder?: { __typename: 'PeggedOrder', reference: Types.PeggedReference, offset: string } | null, icebergOrder?: { __typename: 'IcebergOrder', peakSize: string, minimumVisibleSize: string, reservedRemaining: string } | null } | null, trigger: { __typename?: 'StopOrderPrice', price: string } | { __typename?: 'StopOrderTrailingPercentOffset', trailingPercentOffset: string }, submission: { __typename?: 'OrderSubmission', marketId: string, price: string, size: string, side: Types.Side, timeInForce: Types.OrderTimeInForce, expiresAt: any, type: Types.OrderType, reference?: string | null, postOnly?: boolean | null, reduceOnly?: boolean | null, peggedOrder?: { __typename?: 'PeggedOrder', reference: Types.PeggedReference, offset: string } | null } } | null }; - export const OrderUpdateFieldsFragmentDoc = gql` fragment OrderUpdateFields on OrderUpdate { id @@ -161,41 +147,6 @@ export const StopOrderFieldsFragmentDoc = gql` } ${OrderFieldsFragmentDoc} ${OrderSubmissionFieldsFragmentDoc}`; -export const OrderByIdDocument = gql` - query OrderById($orderId: ID!) { - orderByID(id: $orderId) { - ...OrderFields - } -} - ${OrderFieldsFragmentDoc}`; - -/** - * __useOrderByIdQuery__ - * - * To run a query within a React component, call `useOrderByIdQuery` and pass it any options that fit your needs. - * When your component renders, `useOrderByIdQuery` 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 } = useOrderByIdQuery({ - * variables: { - * orderId: // value for 'orderId' - * }, - * }); - */ -export function useOrderByIdQuery(baseOptions: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(OrderByIdDocument, options); - } -export function useOrderByIdLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(OrderByIdDocument, options); - } -export type OrderByIdQueryHookResult = ReturnType; -export type OrderByIdLazyQueryHookResult = ReturnType; -export type OrderByIdQueryResult = Apollo.QueryResult; export const OrdersDocument = gql` query Orders($partyId: ID!, $marketIds: [ID!], $pagination: Pagination, $filter: OrderFilter) { party(id: $partyId) { @@ -320,39 +271,4 @@ export function useStopOrdersLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions } export type StopOrdersQueryHookResult = ReturnType; export type StopOrdersLazyQueryHookResult = ReturnType; -export type StopOrdersQueryResult = Apollo.QueryResult; -export const StopOrderByIdDocument = gql` - query StopOrderById($stopOrderId: ID!) { - stopOrder(id: $stopOrderId) { - ...StopOrderFields - } -} - ${StopOrderFieldsFragmentDoc}`; - -/** - * __useStopOrderByIdQuery__ - * - * To run a query within a React component, call `useStopOrderByIdQuery` and pass it any options that fit your needs. - * When your component renders, `useStopOrderByIdQuery` 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 } = useStopOrderByIdQuery({ - * variables: { - * stopOrderId: // value for 'stopOrderId' - * }, - * }); - */ -export function useStopOrderByIdQuery(baseOptions: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(StopOrderByIdDocument, options); - } -export function useStopOrderByIdLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(StopOrderByIdDocument, options); - } -export type StopOrderByIdQueryHookResult = ReturnType; -export type StopOrderByIdLazyQueryHookResult = ReturnType; -export type StopOrderByIdQueryResult = Apollo.QueryResult; \ No newline at end of file +export type StopOrdersQueryResult = Apollo.QueryResult; \ No newline at end of file diff --git a/libs/orders/src/lib/components/order-list-manager/order-list-manager.tsx b/libs/orders/src/lib/components/order-list-manager/order-list-manager.tsx index cf9a612ec..2100934bf 100644 --- a/libs/orders/src/lib/components/order-list-manager/order-list-manager.tsx +++ b/libs/orders/src/lib/components/order-list-manager/order-list-manager.tsx @@ -5,11 +5,9 @@ import { OrderListTable } from '../order-list/order-list'; import type { useDataGridEvents } from '@vegaprotocol/datagrid'; import { useDataProvider } from '@vegaprotocol/data-provider'; import { ordersWithMarketProvider } from '../order-data-provider/order-data-provider'; -import { - normalizeOrderAmendment, - useVegaTransactionStore, -} from '@vegaprotocol/wallet'; -import type { OrderTxUpdateFieldsFragment } from '@vegaprotocol/wallet'; +import { normalizeOrderAmendment } from '@vegaprotocol/wallet'; +import { useVegaTransactionStore } from '@vegaprotocol/web3'; +import type { OrderTxUpdateFieldsFragment } from '@vegaprotocol/web3'; import { OrderEditDialog } from '../order-list/order-edit-dialog'; import type { Order } from '../order-data-provider'; import { OrderViewDialog } from '../order-list/order-view-dialog'; diff --git a/libs/orders/src/lib/components/order-list/order-list.stories.tsx b/libs/orders/src/lib/components/order-list/order-list.stories.tsx index 576ca88ea..3e03de129 100644 --- a/libs/orders/src/lib/components/order-list/order-list.stories.tsx +++ b/libs/orders/src/lib/components/order-list/order-list.stories.tsx @@ -1,8 +1,6 @@ import type { Story, Meta } from '@storybook/react'; import { OrderListTable } from './order-list'; import { useState } from 'react'; -import type { VegaTxState } from '@vegaprotocol/wallet'; -import { VegaTransactionDialog, VegaTxStatus } from '@vegaprotocol/wallet'; import { generateOrdersArray } from '../mocks'; import { OrderEditDialog } from './order-edit-dialog'; import type { Order } from '../order-data-provider'; @@ -32,25 +30,15 @@ const Template: Story = (args) => { }; const Template2: Story = (args) => { - const [open, setOpen] = useState(false); const [editOrder, setEditOrder] = useState(); - const cancel = () => { - setOpen(!open); - return Promise.resolve(); - }; - const transaction: VegaTxState = { - status: VegaTxStatus.Requested, - error: null, - txHash: null, - signature: null, - dialogOpen: false, - }; return ( <>
{ + return; + }} onEdit={setEditOrder} onView={() => { return; @@ -58,11 +46,6 @@ const Template2: Story = (args) => { isReadOnly={false} />
- {editOrder && ( Promise; - -export const useOrderUpdate = (transaction: VegaTxState) => { - const client = useApolloClient(); - const subRef = useRef(null); - - const waitForOrderUpdate = useCallback( - (id: string, partyId: string) => { - return new Promise((resolve) => { - subRef.current = client - .subscribe({ - query: OrderSubDocument, - variables: { partyId }, - }) - .subscribe(({ data }) => { - if (!data?.orders?.length) { - return; - } - - // No types available for the subscription result - const matchingOrder = data.orders.find((order) => { - return order.id === id; - }); - - if (matchingOrder) { - resolve(matchingOrder); - subRef.current?.unsubscribe(); - } - }); - }); - }, - [client] - ); - - useEffect(() => { - if (!transaction.dialogOpen) { - subRef.current?.unsubscribe(); - } - - return () => { - subRef.current?.unsubscribe(); - }; - }, [transaction.dialogOpen]); - - return waitForOrderUpdate; -}; diff --git a/libs/orders/src/lib/utils.spec.ts b/libs/orders/src/lib/utils.spec.ts index d4aca7163..c69c73581 100644 --- a/libs/orders/src/lib/utils.spec.ts +++ b/libs/orders/src/lib/utils.spec.ts @@ -1,110 +1,7 @@ -import { Intent } from '@vegaprotocol/ui-toolkit'; -import { - getOrderToastIntent, - getOrderToastTitle, - getRejectionReason, - timeInForceLabel, -} from './utils'; +import { timeInForceLabel } from './utils'; import * as Types from '@vegaprotocol/types'; -describe('WithdrawalsTable', () => { - describe('getOrderToastTitle', () => { - it('should return the correct title', () => { - expect(getOrderToastTitle(Types.OrderStatus.STATUS_ACTIVE)).toBe( - 'Order submitted' - ); - expect(getOrderToastTitle(Types.OrderStatus.STATUS_FILLED)).toBe( - 'Order filled' - ); - expect( - getOrderToastTitle(Types.OrderStatus.STATUS_PARTIALLY_FILLED) - ).toBe('Order partially filled'); - expect(getOrderToastTitle(Types.OrderStatus.STATUS_PARKED)).toBe( - 'Order parked' - ); - expect(getOrderToastTitle(Types.OrderStatus.STATUS_STOPPED)).toBe( - 'Order stopped' - ); - expect(getOrderToastTitle(Types.OrderStatus.STATUS_CANCELLED)).toBe( - 'Order cancelled' - ); - expect(getOrderToastTitle(Types.OrderStatus.STATUS_EXPIRED)).toBe( - 'Order expired' - ); - expect(getOrderToastTitle(Types.OrderStatus.STATUS_REJECTED)).toBe( - 'Order rejected' - ); - expect(getOrderToastTitle(undefined)).toBe(undefined); - }); - }); - - describe('getOrderToastIntent', () => { - it('should return the correct intent', () => { - expect(getOrderToastIntent(Types.OrderStatus.STATUS_PARKED)).toBe( - Intent.Warning - ); - expect(getOrderToastIntent(Types.OrderStatus.STATUS_EXPIRED)).toBe( - Intent.Warning - ); - expect( - getOrderToastIntent(Types.OrderStatus.STATUS_PARTIALLY_FILLED) - ).toBe(Intent.Warning); - expect(getOrderToastIntent(Types.OrderStatus.STATUS_REJECTED)).toBe( - Intent.Danger - ); - expect(getOrderToastIntent(Types.OrderStatus.STATUS_STOPPED)).toBe( - Intent.Warning - ); - expect(getOrderToastIntent(Types.OrderStatus.STATUS_FILLED)).toBe( - Intent.Success - ); - expect(getOrderToastIntent(Types.OrderStatus.STATUS_ACTIVE)).toBe( - Intent.Success - ); - expect(getOrderToastIntent(Types.OrderStatus.STATUS_CANCELLED)).toBe( - Intent.Success - ); - expect(getOrderToastIntent(undefined)).toBe(undefined); - }); - }); - - describe('getRejectionReason', () => { - it('should return the correct rejection reason for insufficient asset balance', () => { - expect( - getRejectionReason({ - rejectionReason: - Types.OrderRejectionReason.ORDER_ERROR_INSUFFICIENT_ASSET_BALANCE, - status: Types.OrderStatus.STATUS_REJECTED, - id: '', - createdAt: undefined, - size: '', - price: '', - timeInForce: Types.OrderTimeInForce.TIME_IN_FORCE_FOK, - side: Types.Side.SIDE_BUY, - marketId: '', - }) - ).toBe('Insufficient asset balance'); - }); - - it('should return the correct rejection reason when order is stopped', () => { - expect( - getRejectionReason({ - rejectionReason: null, - status: Types.OrderStatus.STATUS_STOPPED, - id: '', - createdAt: undefined, - size: '', - price: '', - timeInForce: Types.OrderTimeInForce.TIME_IN_FORCE_FOK, - side: Types.Side.SIDE_BUY, - marketId: '', - }) - ).toBe( - 'Your Fill or Kill (FOK) order was not filled and it has been stopped' - ); - }); - }); - +describe('utils', () => { describe('timeInForceLabel', () => { it('should return the correct label for time in force', () => { expect(timeInForceLabel(Types.OrderTimeInForce.TIME_IN_FORCE_FOK)).toBe( diff --git a/libs/orders/src/lib/utils.ts b/libs/orders/src/lib/utils.ts index 9faa39d41..556d2865d 100644 --- a/libs/orders/src/lib/utils.ts +++ b/libs/orders/src/lib/utils.ts @@ -1,7 +1,5 @@ import { t } from '@vegaprotocol/i18n'; import * as Schema from '@vegaprotocol/types'; -import type { OrderSubFieldsFragment } from './order-hooks'; -import { Intent } from '@vegaprotocol/ui-toolkit'; // More detail in https://docs.vega.xyz/mainnet/graphql/enums/order-time-in-force export const timeInForceLabel = (tif: string) => { @@ -22,72 +20,3 @@ export const timeInForceLabel = (tif: string) => { return t(tif); } }; - -export const getRejectionReason = ( - order: OrderSubFieldsFragment -): string | null => { - switch (order.status) { - case Schema.OrderStatus.STATUS_STOPPED: - return t( - `Your ${ - Schema.OrderTimeInForceMapping[order.timeInForce] - } order was not filled and it has been stopped` - ); - default: - return order.rejectionReason - ? t(Schema.OrderRejectionReasonMapping[order.rejectionReason]) - : ''; - } -}; - -export const getOrderToastTitle = ( - status?: Schema.OrderStatus -): string | undefined => { - if (!status) { - return; - } - - switch (status) { - case Schema.OrderStatus.STATUS_ACTIVE: - return t('Order submitted'); - case Schema.OrderStatus.STATUS_FILLED: - return t('Order filled'); - case Schema.OrderStatus.STATUS_PARTIALLY_FILLED: - return t('Order partially filled'); - case Schema.OrderStatus.STATUS_PARKED: - return t('Order parked'); - case Schema.OrderStatus.STATUS_STOPPED: - return t('Order stopped'); - case Schema.OrderStatus.STATUS_CANCELLED: - return t('Order cancelled'); - case Schema.OrderStatus.STATUS_EXPIRED: - return t('Order expired'); - case Schema.OrderStatus.STATUS_REJECTED: - return t('Order rejected'); - default: - return t('Submission failed'); - } -}; - -export const getOrderToastIntent = ( - status?: Schema.OrderStatus -): Intent | undefined => { - if (!status) { - return; - } - switch (status) { - case Schema.OrderStatus.STATUS_PARKED: - case Schema.OrderStatus.STATUS_EXPIRED: - case Schema.OrderStatus.STATUS_PARTIALLY_FILLED: - case Schema.OrderStatus.STATUS_STOPPED: - return Intent.Warning; - case Schema.OrderStatus.STATUS_REJECTED: - return Intent.Danger; - case Schema.OrderStatus.STATUS_FILLED: - case Schema.OrderStatus.STATUS_ACTIVE: - case Schema.OrderStatus.STATUS_CANCELLED: - return Intent.Success; - default: - return; - } -}; diff --git a/libs/positions/src/lib/positions-manager.spec.tsx b/libs/positions/src/lib/positions-manager.spec.tsx index 2f02b6f8b..6bd2d3825 100644 --- a/libs/positions/src/lib/positions-manager.spec.tsx +++ b/libs/positions/src/lib/positions-manager.spec.tsx @@ -9,6 +9,9 @@ const mockCreate = jest.fn(); jest.mock('@vegaprotocol/wallet', () => ({ ...jest.requireActual('@vegaprotocol/wallet'), useVegaWallet: jest.fn(() => ({ pubKey: 'partyId' })), +})); +jest.mock('@vegaprotocol/web3', () => ({ + ...jest.requireActual('@vegaprotocol/web3'), useVegaTransactionStore: jest.fn(() => mockCreate), })); // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/libs/positions/src/lib/positions-manager.tsx b/libs/positions/src/lib/positions-manager.tsx index 98bf332cc..d431ef019 100644 --- a/libs/positions/src/lib/positions-manager.tsx +++ b/libs/positions/src/lib/positions-manager.tsx @@ -1,7 +1,8 @@ import { useCallback } from 'react'; import { PositionsTable } from './positions-table'; import * as Schema from '@vegaprotocol/types'; -import { useVegaTransactionStore, useVegaWallet } from '@vegaprotocol/wallet'; +import { useVegaTransactionStore } from '@vegaprotocol/web3'; +import { useVegaWallet } from '@vegaprotocol/wallet'; import { t } from '@vegaprotocol/i18n'; import { useDataProvider } from '@vegaprotocol/data-provider'; import { diff --git a/libs/proposals/src/components/index.ts b/libs/proposals/src/components/index.ts index 0e9a767ba..fcd956727 100644 --- a/libs/proposals/src/components/index.ts +++ b/libs/proposals/src/components/index.ts @@ -5,3 +5,4 @@ export * from './protocol-upgrade-countdown'; export * from './protocol-upgrade-in-progress-notification'; export * from './protocol-upgrade-proposal-notification'; export * from './voting-progress'; +export * from './vega-transaction-dialog'; diff --git a/libs/wallet/src/vega-transaction-dialog/index.ts b/libs/proposals/src/components/vega-transaction-dialog/index.ts similarity index 100% rename from libs/wallet/src/vega-transaction-dialog/index.ts rename to libs/proposals/src/components/vega-transaction-dialog/index.ts diff --git a/libs/wallet/src/vega-transaction-dialog/vega-transaction-dialog.spec.tsx b/libs/proposals/src/components/vega-transaction-dialog/vega-transaction-dialog.spec.tsx similarity index 94% rename from libs/wallet/src/vega-transaction-dialog/vega-transaction-dialog.spec.tsx rename to libs/proposals/src/components/vega-transaction-dialog/vega-transaction-dialog.spec.tsx index 3c45853c2..fe9a25fe0 100644 --- a/libs/wallet/src/vega-transaction-dialog/vega-transaction-dialog.spec.tsx +++ b/libs/proposals/src/components/vega-transaction-dialog/vega-transaction-dialog.spec.tsx @@ -1,8 +1,8 @@ import { render, screen } from '@testing-library/react'; -import { WalletError } from '../connectors'; -import type { VegaWalletContextShape } from '../context'; -import { VegaWalletContext } from '../context'; -import { VegaTxStatus } from '../types'; +import { WalletError } from '@vegaprotocol/wallet'; +import type { VegaWalletContextShape } from '@vegaprotocol/wallet'; +import { VegaWalletContext } from '@vegaprotocol/wallet'; +import { VegaTxStatus } from '../../lib/proposals-hooks/use-vega-transaction'; import type { VegaTransactionDialogProps } from './vega-transaction-dialog'; import { VegaTransactionDialog } from './vega-transaction-dialog'; diff --git a/libs/wallet/src/vega-transaction-dialog/vega-transaction-dialog.tsx b/libs/proposals/src/components/vega-transaction-dialog/vega-transaction-dialog.tsx similarity index 96% rename from libs/wallet/src/vega-transaction-dialog/vega-transaction-dialog.tsx rename to libs/proposals/src/components/vega-transaction-dialog/vega-transaction-dialog.tsx index a53307598..297c2cf29 100644 --- a/libs/wallet/src/vega-transaction-dialog/vega-transaction-dialog.tsx +++ b/libs/proposals/src/components/vega-transaction-dialog/vega-transaction-dialog.tsx @@ -2,9 +2,9 @@ import type { ReactNode } from 'react'; import { t } from '@vegaprotocol/i18n'; import { Dialog, Icon, Intent, Loader } from '@vegaprotocol/ui-toolkit'; import { WalletClientError } from '@vegaprotocol/wallet-client'; -import type { VegaTxState } from '../types'; -import { VegaTxStatus } from '../types'; -import { useVegaWallet } from '../use-vega-wallet'; +import type { VegaTxState } from '../../lib/proposals-hooks/use-vega-transaction'; +import { VegaTxStatus } from '../../lib/proposals-hooks/use-vega-transaction'; +import { useVegaWallet } from '@vegaprotocol/wallet'; export type VegaTransactionContentMap = { [C in VegaTxStatus]?: JSX.Element; diff --git a/libs/proposals/src/lib/proposals-hooks/index.ts b/libs/proposals/src/lib/proposals-hooks/index.ts index 45d0ad444..d61f740be 100644 --- a/libs/proposals/src/lib/proposals-hooks/index.ts +++ b/libs/proposals/src/lib/proposals-hooks/index.ts @@ -1,5 +1,6 @@ export * from './__generated__/Proposal'; export * from './use-proposal-event'; +export * from './use-vega-transaction'; export * from './use-proposal-submit'; export * from './use-update-proposal'; export * from './use-update-network-paramaters-toasts'; diff --git a/libs/proposals/src/lib/proposals-hooks/use-proposal-event.ts b/libs/proposals/src/lib/proposals-hooks/use-proposal-event.ts index 2c33f32a7..92042a445 100644 --- a/libs/proposals/src/lib/proposals-hooks/use-proposal-event.ts +++ b/libs/proposals/src/lib/proposals-hooks/use-proposal-event.ts @@ -7,7 +7,7 @@ import type { ProposalEventFieldsFragment, } from './__generated__/Proposal'; import type { Subscription } from 'zen-observable-ts'; -import type { VegaTxState } from '@vegaprotocol/wallet'; +import type { VegaTxState } from '../proposals-hooks/use-vega-transaction'; export const useProposalEvent = (transaction: VegaTxState) => { const client = useApolloClient(); diff --git a/libs/proposals/src/lib/proposals-hooks/use-proposal-submit.ts b/libs/proposals/src/lib/proposals-hooks/use-proposal-submit.ts index 75ef7d579..bd39fa5cd 100644 --- a/libs/proposals/src/lib/proposals-hooks/use-proposal-submit.ts +++ b/libs/proposals/src/lib/proposals-hooks/use-proposal-submit.ts @@ -1,10 +1,7 @@ import { useCallback, useState } from 'react'; import * as Sentry from '@sentry/react'; -import { - useVegaWallet, - useVegaTransaction, - determineId, -} from '@vegaprotocol/wallet'; +import { useVegaWallet, determineId } from '@vegaprotocol/wallet'; +import { useVegaTransaction } from './use-vega-transaction'; import { useProposalEvent } from './use-proposal-event'; import type { ProposalSubmission } from '@vegaprotocol/wallet'; import type { ProposalEventFieldsFragment } from './__generated__/Proposal'; diff --git a/libs/wallet/src/use-vega-transaction.spec.tsx b/libs/proposals/src/lib/proposals-hooks/use-vega-transaction.spec.tsx similarity index 93% rename from libs/wallet/src/use-vega-transaction.spec.tsx rename to libs/proposals/src/lib/proposals-hooks/use-vega-transaction.spec.tsx index 0e85fbd13..3fb39b131 100644 --- a/libs/wallet/src/use-vega-transaction.spec.tsx +++ b/libs/proposals/src/lib/proposals-hooks/use-vega-transaction.spec.tsx @@ -1,11 +1,12 @@ import { act, renderHook } from '@testing-library/react'; -import type { VegaWalletContextShape } from './context'; -import { VegaWalletContext } from './context'; +import type { VegaWalletContextShape, Transaction } from '@vegaprotocol/wallet'; +import { VegaWalletContext, WalletError } from '@vegaprotocol/wallet'; import type { ReactNode } from 'react'; -import { initialState, useVegaTransaction } from './use-vega-transaction'; -import type { Transaction } from './connectors'; -import { WalletError } from './connectors'; -import { VegaTxStatus } from './types'; +import { + initialState, + useVegaTransaction, + VegaTxStatus, +} from './use-vega-transaction'; const mockPubKey = '0x123'; diff --git a/libs/wallet/src/use-vega-transaction.tsx b/libs/proposals/src/lib/proposals-hooks/use-vega-transaction.tsx similarity index 82% rename from libs/wallet/src/use-vega-transaction.tsx rename to libs/proposals/src/lib/proposals-hooks/use-vega-transaction.tsx index 63deb226f..b87b81e9d 100644 --- a/libs/wallet/src/use-vega-transaction.tsx +++ b/libs/proposals/src/lib/proposals-hooks/use-vega-transaction.tsx @@ -4,15 +4,27 @@ import { WalletClientError, WalletHttpError, } from '@vegaprotocol/wallet-client'; -import { useVegaWallet } from './use-vega-wallet'; -import type { VegaTransactionContentMap } from './vega-transaction-dialog'; -import { VegaTransactionDialog } from './vega-transaction-dialog'; +import { useVegaWallet, WalletError, ClientErrors } from '@vegaprotocol/wallet'; +import type { Transaction } from '@vegaprotocol/wallet'; +import type { VegaTransactionContentMap } from '../../components/vega-transaction-dialog'; +import { VegaTransactionDialog } from '../../components/vega-transaction-dialog'; import type { Intent } from '@vegaprotocol/ui-toolkit'; -import type { Transaction } from './connectors'; -import { WalletError } from './connectors'; -import { ClientErrors } from './connectors'; -import type { VegaTxState } from './types'; -import { VegaTxStatus } from './types'; + +export enum VegaTxStatus { + Default = 'Default', + Requested = 'Requested', + Pending = 'Pending', + Error = 'Error', + Complete = 'Complete', +} + +export interface VegaTxState { + status: VegaTxStatus; + error: Error | null; + txHash: string | null; + signature: string | null; + dialogOpen: boolean; +} export interface DialogProps { intent?: Intent; diff --git a/libs/proposals/src/lib/voting-hooks/use-vote-event.ts b/libs/proposals/src/lib/voting-hooks/use-vote-event.ts index 591d2ddc6..8b5fec9c7 100644 --- a/libs/proposals/src/lib/voting-hooks/use-vote-event.ts +++ b/libs/proposals/src/lib/voting-hooks/use-vote-event.ts @@ -2,7 +2,7 @@ import { useApolloClient } from '@apollo/client'; import { useCallback, useEffect, useRef } from 'react'; import { VoteEventDocument } from './__generated__/VoteSubsciption'; import type { Subscription } from 'zen-observable-ts'; -import type { VegaTxState } from '@vegaprotocol/wallet'; +import type { VegaTxState } from '../proposals-hooks/use-vega-transaction'; import type { VoteEventFieldsFragment, VoteEventSubscription, diff --git a/libs/proposals/src/lib/voting-hooks/use-vote-submit.ts b/libs/proposals/src/lib/voting-hooks/use-vote-submit.ts index 55485eae4..375516336 100644 --- a/libs/proposals/src/lib/voting-hooks/use-vote-submit.ts +++ b/libs/proposals/src/lib/voting-hooks/use-vote-submit.ts @@ -1,6 +1,7 @@ import { useCallback, useState } from 'react'; import * as Sentry from '@sentry/react'; -import { useVegaTransaction, useVegaWallet } from '@vegaprotocol/wallet'; +import { useVegaTransaction } from '../proposals-hooks/use-vega-transaction'; +import { useVegaWallet } from '@vegaprotocol/wallet'; import { useVoteEvent } from './use-vote-event'; import type { VoteValue } from '@vegaprotocol/types'; import type { VoteEventFieldsFragment } from './__generated__/VoteSubsciption'; diff --git a/libs/wallet/src/connect-dialog/ChainId.graphql b/libs/wallet/src/connect-dialog/ChainId.graphql deleted file mode 100644 index a5524e4ec..000000000 --- a/libs/wallet/src/connect-dialog/ChainId.graphql +++ /dev/null @@ -1,5 +0,0 @@ -query ChainId { - statistics { - chainId - } -} diff --git a/libs/wallet/src/connect-dialog/__generated__/ChainId.ts b/libs/wallet/src/connect-dialog/__generated__/ChainId.ts deleted file mode 100644 index f23524e47..000000000 --- a/libs/wallet/src/connect-dialog/__generated__/ChainId.ts +++ /dev/null @@ -1,45 +0,0 @@ -import * as Types from '@vegaprotocol/types'; - -import { gql } from '@apollo/client'; -import * as Apollo from '@apollo/client'; -const defaultOptions = {} as const; -export type ChainIdQueryVariables = Types.Exact<{ [key: string]: never; }>; - - -export type ChainIdQuery = { __typename?: 'Query', statistics: { __typename?: 'Statistics', chainId: string } }; - - -export const ChainIdDocument = gql` - query ChainId { - statistics { - chainId - } -} - `; - -/** - * __useChainIdQuery__ - * - * To run a query within a React component, call `useChainIdQuery` and pass it any options that fit your needs. - * When your component renders, `useChainIdQuery` 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 } = useChainIdQuery({ - * variables: { - * }, - * }); - */ -export function useChainIdQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(ChainIdDocument, options); - } -export function useChainIdLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(ChainIdDocument, options); - } -export type ChainIdQueryHookResult = ReturnType; -export type ChainIdLazyQueryHookResult = ReturnType; -export type ChainIdQueryResult = Apollo.QueryResult; \ No newline at end of file diff --git a/libs/wallet/src/connect-dialog/chain-id.mock.ts b/libs/wallet/src/connect-dialog/chain-id.mock.ts deleted file mode 100644 index 4df27b583..000000000 --- a/libs/wallet/src/connect-dialog/chain-id.mock.ts +++ /dev/null @@ -1,16 +0,0 @@ -import type { ChainIdQuery } from './__generated__/ChainId'; -import merge from 'lodash/merge'; -import type { PartialDeep } from 'type-fest'; - -export const chainIdQuery = ( - override?: PartialDeep -): ChainIdQuery => { - const defaultResult = { - statistics: { - __typename: 'Statistics', - chainId: 'test-id', - }, - }; - - return merge(defaultResult, override); -}; diff --git a/libs/wallet/src/connect-dialog/connect-dialog.spec.tsx b/libs/wallet/src/connect-dialog/connect-dialog.spec.tsx index dad85fbeb..c08ceb020 100644 --- a/libs/wallet/src/connect-dialog/connect-dialog.spec.tsx +++ b/libs/wallet/src/connect-dialog/connect-dialog.spec.tsx @@ -1,6 +1,4 @@ import { act, fireEvent, render, screen } from '@testing-library/react'; -import type { MockedResponse } from '@apollo/client/testing'; -import { MockedProvider } from '@apollo/client/testing'; import type { VegaWalletConfig } from '../provider'; import { VegaWalletProvider } from '../provider'; import { VegaConnectDialog, CLOSE_DELAY } from './connect-dialog'; @@ -13,8 +11,6 @@ import { ViewConnector, WalletError, } from '../connectors'; -import type { ChainIdQuery } from './__generated__/ChainId'; -import { ChainIdDocument } from './__generated__/ChainId'; import { mockBrowserWallet, clearBrowserWallet, @@ -26,6 +22,7 @@ const mockUpdateDialogOpen = jest.fn(); const mockCloseVegaDialog = jest.fn(); let mockIsDesktopRunning = true; +const mockChainId = 'chain-id'; jest.mock('../use-is-wallet-service-running', () => ({ useIsWalletServiceRunning: jest @@ -33,6 +30,10 @@ jest.mock('../use-is-wallet-service-running', () => ({ .mockImplementation(() => mockIsDesktopRunning), })); +jest.mock('./use-chain-id', () => ({ + useChainId: jest.fn().mockImplementation(() => mockChainId), +})); + let defaultProps: VegaConnectDialogProps; const INITIAL_KEY = 'some-key'; @@ -60,8 +61,6 @@ beforeEach(() => { }); }); -const mockChainId = 'chain-id'; - const defaultConfig: VegaWalletConfig = { network: 'TESTNET', vegaUrl: 'https://vega.xyz', @@ -78,24 +77,10 @@ function generateJSX( props?: Partial, config?: Partial ) { - const chainIdMock: MockedResponse = { - request: { - query: ChainIdDocument, - }, - result: { - data: { - statistics: { - chainId: mockChainId, - }, - }, - }, - }; return ( - - - - - + + + ); } diff --git a/libs/wallet/src/connect-dialog/connect-dialog.tsx b/libs/wallet/src/connect-dialog/connect-dialog.tsx index 9fb81a5d9..4073006f4 100644 --- a/libs/wallet/src/connect-dialog/connect-dialog.tsx +++ b/libs/wallet/src/connect-dialog/connect-dialog.tsx @@ -35,13 +35,13 @@ import type { Status as JsonRpcStatus } from '../use-json-rpc-connect'; import { useJsonRpcConnect } from '../use-json-rpc-connect'; import type { Status as InjectedStatus } from '../use-injected-connector'; import { useInjectedConnector } from '../use-injected-connector'; -import { useChainIdQuery } from './__generated__/ChainId'; import { useVegaWallet } from '../use-vega-wallet'; import { InjectedConnectorForm } from './injected-connector-form'; import { isBrowserWalletInstalled } from '../utils'; import { useIsWalletServiceRunning } from '../use-is-wallet-service-running'; import { SnapStatus, useSnapStatus } from '../use-snap-status'; import { useVegaWalletDialogStore } from './vega-wallet-dialog-store'; +import { useChainId } from './use-chain-id'; export const CLOSE_DELAY = 1700; @@ -82,12 +82,12 @@ export const VegaConnectDialog = ({ // Ensure we have a chain Id so we can compare with wallet chain id. // This value will already be in the cache, if it failed the app wont render - const { data } = useChainIdQuery(); + const chainId = useChainId(); - const content = data && ( + const content = chainId && ( diff --git a/libs/wallet/src/connect-dialog/use-chain-id.ts b/libs/wallet/src/connect-dialog/use-chain-id.ts new file mode 100644 index 000000000..d346bd2b9 --- /dev/null +++ b/libs/wallet/src/connect-dialog/use-chain-id.ts @@ -0,0 +1,37 @@ +import { useEffect, useState } from 'react'; +import { useVegaWallet } from '../use-vega-wallet'; + +const cache: Record = {}; + +export const useChainId = () => { + const { vegaUrl } = useVegaWallet(); + const [chainId, setChainId] = useState(cache[vegaUrl]); + const [fetchAttempt, setFetchAttempt] = useState(1); + useEffect(() => { + let isCancelled = false; + if (cache[vegaUrl]) { + setChainId(cache[vegaUrl]); + return; + } + fetch(vegaUrl.replace('graphql', 'statistics')) + .then((response) => response.json()) + .then((response) => { + if (isCancelled) { + return; + } + if (!response?.statistics?.chainId) { + throw new Error('statistics.chainId not present in fetched response'); + } + setChainId(response?.statistics?.chainId); + }) + .catch(() => { + if (fetchAttempt < 3) { + setFetchAttempt((value) => (value += 1)); + } + }); + return () => { + isCancelled = true; + }; + }, [fetchAttempt, vegaUrl]); + return chainId; +}; diff --git a/libs/wallet/src/index.ts b/libs/wallet/src/index.ts index e9ae2340b..fc7c958cf 100644 --- a/libs/wallet/src/index.ts +++ b/libs/wallet/src/index.ts @@ -1,18 +1,9 @@ export * from './connectors'; export * from './context'; -export * from './use-vega-transaction'; export * from './use-vega-wallet'; -export * from './use-vega-transaction-manager'; -export * from './use-vega-transaction-store'; -export * from './use-vega-transaction-updater'; -export * from './use-transaction-result'; export * from './use-eager-connect'; export * from './manage-dialog'; export * from './provider'; export * from './connect-dialog'; export * from './utils'; export * from './storage'; -export * from './types'; -export * from './vega-transaction-dialog'; -export * from './__generated__/TransactionResult'; -export * from './__generated__/WithdrawalApproval'; diff --git a/libs/web3/src/index.ts b/libs/web3/src/index.ts index 8134e8660..aa41d514a 100644 --- a/libs/web3/src/index.ts +++ b/libs/web3/src/index.ts @@ -28,3 +28,10 @@ export * from './lib/web3-provider'; export * from './lib/withdrawal-approval-dialog'; export * from './lib/withdrawal-approval-status'; export * from './lib/default-web3-provider'; +export * from './lib/use-vega-transaction-manager'; +export * from './lib/use-vega-transaction-store'; +export * from './lib/use-vega-transaction-updater'; +export * from './lib/use-transaction-result'; +export * from './lib/types'; +export * from './lib/__generated__/TransactionResult'; +export * from './lib/__generated__/WithdrawalApproval'; diff --git a/libs/web3/src/lib/Orders.graphql b/libs/web3/src/lib/Orders.graphql new file mode 100644 index 000000000..ea41306f5 --- /dev/null +++ b/libs/web3/src/lib/Orders.graphql @@ -0,0 +1,74 @@ +query OrderById($orderId: ID!) { + orderByID(id: $orderId) { + id + market { + id + } + type + side + size + status + rejectionReason + price + timeInForce + remaining + expiresAt + createdAt + updatedAt + postOnly + reduceOnly + liquidityProvision { + __typename + } + peggedOrder { + __typename + reference + offset + } + icebergOrder { + __typename + peakSize + minimumVisibleSize + reservedRemaining + } + } +} + +query StopOrderById($stopOrderId: ID!) { + stopOrder(id: $stopOrderId) { + id + ocoLinkId + expiresAt + expiryStrategy + triggerDirection + status + createdAt + updatedAt + partyId + marketId + trigger { + ... on StopOrderPrice { + price + } + ... on StopOrderTrailingPercentOffset { + trailingPercentOffset + } + } + submission { + marketId + price + size + side + timeInForce + expiresAt + type + reference + peggedOrder { + reference + offset + } + postOnly + reduceOnly + } + } +} diff --git a/libs/wallet/src/TransactionResult.graphql b/libs/web3/src/lib/TransactionResult.graphql similarity index 100% rename from libs/wallet/src/TransactionResult.graphql rename to libs/web3/src/lib/TransactionResult.graphql diff --git a/libs/wallet/src/WithdrawalApproval.graphql b/libs/web3/src/lib/WithdrawalApproval.graphql similarity index 100% rename from libs/wallet/src/WithdrawalApproval.graphql rename to libs/web3/src/lib/WithdrawalApproval.graphql diff --git a/libs/web3/src/lib/__generated__/Orders.ts b/libs/web3/src/lib/__generated__/Orders.ts new file mode 100644 index 000000000..e53c1f02c --- /dev/null +++ b/libs/web3/src/lib/__generated__/Orders.ts @@ -0,0 +1,153 @@ +import * as Types from '@vegaprotocol/types'; + +import { gql } from '@apollo/client'; +import * as Apollo from '@apollo/client'; +const defaultOptions = {} as const; +export type OrderByIdQueryVariables = Types.Exact<{ + orderId: Types.Scalars['ID']; +}>; + + +export type OrderByIdQuery = { __typename?: 'Query', orderByID: { __typename?: 'Order', id: string, type?: Types.OrderType | null, side: Types.Side, size: string, status: Types.OrderStatus, rejectionReason?: Types.OrderRejectionReason | null, price: string, timeInForce: Types.OrderTimeInForce, remaining: string, expiresAt?: any | null, createdAt: any, updatedAt?: any | null, postOnly?: boolean | null, reduceOnly?: boolean | null, market: { __typename?: 'Market', id: string }, liquidityProvision?: { __typename: 'LiquidityProvision' } | null, peggedOrder?: { __typename: 'PeggedOrder', reference: Types.PeggedReference, offset: string } | null, icebergOrder?: { __typename: 'IcebergOrder', peakSize: string, minimumVisibleSize: string, reservedRemaining: string } | null } }; + +export type StopOrderByIdQueryVariables = Types.Exact<{ + stopOrderId: Types.Scalars['ID']; +}>; + + +export type StopOrderByIdQuery = { __typename?: 'Query', stopOrder?: { __typename?: 'StopOrder', id: string, ocoLinkId?: string | null, expiresAt?: any | null, expiryStrategy?: Types.StopOrderExpiryStrategy | null, triggerDirection: Types.StopOrderTriggerDirection, status: Types.StopOrderStatus, createdAt: any, updatedAt?: any | null, partyId: string, marketId: string, trigger: { __typename?: 'StopOrderPrice', price: string } | { __typename?: 'StopOrderTrailingPercentOffset', trailingPercentOffset: string }, submission: { __typename?: 'OrderSubmission', marketId: string, price: string, size: string, side: Types.Side, timeInForce: Types.OrderTimeInForce, expiresAt: any, type: Types.OrderType, reference?: string | null, postOnly?: boolean | null, reduceOnly?: boolean | null, peggedOrder?: { __typename?: 'PeggedOrder', reference: Types.PeggedReference, offset: string } | null } } | null }; + + +export const OrderByIdDocument = gql` + query OrderById($orderId: ID!) { + orderByID(id: $orderId) { + id + market { + id + } + type + side + size + status + rejectionReason + price + timeInForce + remaining + expiresAt + createdAt + updatedAt + postOnly + reduceOnly + liquidityProvision { + __typename + } + peggedOrder { + __typename + reference + offset + } + icebergOrder { + __typename + peakSize + minimumVisibleSize + reservedRemaining + } + } +} + `; + +/** + * __useOrderByIdQuery__ + * + * To run a query within a React component, call `useOrderByIdQuery` and pass it any options that fit your needs. + * When your component renders, `useOrderByIdQuery` 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 } = useOrderByIdQuery({ + * variables: { + * orderId: // value for 'orderId' + * }, + * }); + */ +export function useOrderByIdQuery(baseOptions: Apollo.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useQuery(OrderByIdDocument, options); + } +export function useOrderByIdLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useLazyQuery(OrderByIdDocument, options); + } +export type OrderByIdQueryHookResult = ReturnType; +export type OrderByIdLazyQueryHookResult = ReturnType; +export type OrderByIdQueryResult = Apollo.QueryResult; +export const StopOrderByIdDocument = gql` + query StopOrderById($stopOrderId: ID!) { + stopOrder(id: $stopOrderId) { + id + ocoLinkId + expiresAt + expiryStrategy + triggerDirection + status + createdAt + updatedAt + partyId + marketId + trigger { + ... on StopOrderPrice { + price + } + ... on StopOrderTrailingPercentOffset { + trailingPercentOffset + } + } + submission { + marketId + price + size + side + timeInForce + expiresAt + type + reference + peggedOrder { + reference + offset + } + postOnly + reduceOnly + } + } +} + `; + +/** + * __useStopOrderByIdQuery__ + * + * To run a query within a React component, call `useStopOrderByIdQuery` and pass it any options that fit your needs. + * When your component renders, `useStopOrderByIdQuery` 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 } = useStopOrderByIdQuery({ + * variables: { + * stopOrderId: // value for 'stopOrderId' + * }, + * }); + */ +export function useStopOrderByIdQuery(baseOptions: Apollo.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useQuery(StopOrderByIdDocument, options); + } +export function useStopOrderByIdLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useLazyQuery(StopOrderByIdDocument, options); + } +export type StopOrderByIdQueryHookResult = ReturnType; +export type StopOrderByIdLazyQueryHookResult = ReturnType; +export type StopOrderByIdQueryResult = Apollo.QueryResult; \ No newline at end of file diff --git a/libs/wallet/src/__generated__/TransactionResult.ts b/libs/web3/src/lib/__generated__/TransactionResult.ts similarity index 100% rename from libs/wallet/src/__generated__/TransactionResult.ts rename to libs/web3/src/lib/__generated__/TransactionResult.ts diff --git a/libs/wallet/src/__generated__/WithdrawalApproval.ts b/libs/web3/src/lib/__generated__/WithdrawalApproval.ts similarity index 100% rename from libs/wallet/src/__generated__/WithdrawalApproval.ts rename to libs/web3/src/lib/__generated__/WithdrawalApproval.ts diff --git a/libs/web3/src/lib/setup-tests.ts b/libs/web3/src/lib/setup-tests.ts new file mode 100644 index 000000000..68773380a --- /dev/null +++ b/libs/web3/src/lib/setup-tests.ts @@ -0,0 +1,4 @@ +import '@testing-library/jest-dom'; +import ResizeObserver from 'resize-observer-polyfill'; + +global.ResizeObserver = ResizeObserver; diff --git a/libs/wallet/src/types.ts b/libs/web3/src/lib/types.ts similarity index 100% rename from libs/wallet/src/types.ts rename to libs/web3/src/lib/types.ts diff --git a/libs/web3/src/lib/use-ethereum-transaction-store.tsx b/libs/web3/src/lib/use-ethereum-transaction-store.tsx index 386a86044..5787a0311 100644 --- a/libs/web3/src/lib/use-ethereum-transaction-store.tsx +++ b/libs/web3/src/lib/use-ethereum-transaction-store.tsx @@ -7,7 +7,7 @@ import type { Token } from '@vegaprotocol/smart-contracts'; import type { DepositBusEventFieldsFragment, WithdrawalBusEventFieldsFragment, -} from '@vegaprotocol/wallet'; +} from './__generated__/TransactionResult'; import type { EthTxState } from './use-ethereum-transaction'; import { EthTxStatus } from './use-ethereum-transaction'; diff --git a/libs/web3/src/lib/use-ethereum-transaction-updater.spec.tsx b/libs/web3/src/lib/use-ethereum-transaction-updater.spec.tsx index 5ff84aa2e..b608e4ef1 100644 --- a/libs/web3/src/lib/use-ethereum-transaction-updater.spec.tsx +++ b/libs/web3/src/lib/use-ethereum-transaction-updater.spec.tsx @@ -3,15 +3,13 @@ import type { MockedResponse } from '@apollo/client/testing'; import { MockedProvider } from '@apollo/client/testing'; import type { ReactNode } from 'react'; import { useEthTransactionUpdater } from './use-ethereum-transaction-updater'; -import { - DepositBusEventDocument, - VegaWalletContext, -} from '@vegaprotocol/wallet'; +import { DepositBusEventDocument } from './__generated__/TransactionResult'; +import { VegaWalletContext } from '@vegaprotocol/wallet'; import type { DepositBusEventSubscription, DepositBusEventFieldsFragment, - VegaWalletContextShape, -} from '@vegaprotocol/wallet'; +} from './__generated__/TransactionResult'; +import type { VegaWalletContextShape } from '@vegaprotocol/wallet'; import type { EthTransactionStore } from './use-ethereum-transaction-store'; import { DepositStatus } from '@vegaprotocol/types'; diff --git a/libs/web3/src/lib/use-ethereum-transaction-updater.tsx b/libs/web3/src/lib/use-ethereum-transaction-updater.tsx index 307dfbe95..b680ddc57 100644 --- a/libs/web3/src/lib/use-ethereum-transaction-updater.tsx +++ b/libs/web3/src/lib/use-ethereum-transaction-updater.tsx @@ -1,8 +1,6 @@ import { DepositStatus } from '@vegaprotocol/types'; -import { - useDepositBusEventSubscription, - useVegaWallet, -} from '@vegaprotocol/wallet'; +import { useVegaWallet } from '@vegaprotocol/wallet'; +import { useDepositBusEventSubscription } from './__generated__/TransactionResult'; import { useEthTransactionStore } from './use-ethereum-transaction-store'; export const useEthTransactionUpdater = () => { diff --git a/libs/web3/src/lib/use-ethereum-withdraw-approvals-manager.spec.tsx b/libs/web3/src/lib/use-ethereum-withdraw-approvals-manager.spec.tsx index 167248fef..e3d127990 100644 --- a/libs/web3/src/lib/use-ethereum-withdraw-approvals-manager.spec.tsx +++ b/libs/web3/src/lib/use-ethereum-withdraw-approvals-manager.spec.tsx @@ -16,8 +16,8 @@ import type { } from './use-ethereum-withdraw-approvals-store'; import type { EthTransactionStore } from './use-ethereum-transaction-store'; -import { WithdrawalApprovalDocument } from '@vegaprotocol/wallet'; -import type { WithdrawalApprovalQuery } from '@vegaprotocol/wallet'; +import { WithdrawalApprovalDocument } from './__generated__/WithdrawalApproval'; +import type { WithdrawalApprovalQuery } from './__generated__/WithdrawalApproval'; import { NetworkParamsDocument } from '@vegaprotocol/network-parameters'; import type { NetworkParamsQuery } from '@vegaprotocol/network-parameters'; diff --git a/libs/web3/src/lib/use-ethereum-withdraw-approvals-manager.tsx b/libs/web3/src/lib/use-ethereum-withdraw-approvals-manager.tsx index 4f00e6abb..ca293f7e8 100644 --- a/libs/web3/src/lib/use-ethereum-withdraw-approvals-manager.tsx +++ b/libs/web3/src/lib/use-ethereum-withdraw-approvals-manager.tsx @@ -15,9 +15,9 @@ import { useWeb3React } from '@web3-react/core'; import type { WithdrawalApprovalQuery, WithdrawalApprovalQueryVariables, -} from '@vegaprotocol/wallet'; +} from './__generated__/WithdrawalApproval'; -import { WithdrawalApprovalDocument } from '@vegaprotocol/wallet'; +import { WithdrawalApprovalDocument } from './__generated__/WithdrawalApproval'; import { useEthTransactionStore } from './use-ethereum-transaction-store'; import { diff --git a/libs/web3/src/lib/use-ethereum-withdraw-approvals-store.spec.tsx b/libs/web3/src/lib/use-ethereum-withdraw-approvals-store.spec.tsx index c10db04b6..bb5e6fec7 100644 --- a/libs/web3/src/lib/use-ethereum-withdraw-approvals-store.spec.tsx +++ b/libs/web3/src/lib/use-ethereum-withdraw-approvals-store.spec.tsx @@ -1,12 +1,12 @@ import { useEthWithdrawApprovalsStore } from './use-ethereum-withdraw-approvals-store'; -import type { VegaStoredTxState } from '@vegaprotocol/wallet'; +import type { VegaStoredTxState } from './use-vega-transaction-store'; import { ApprovalStatus } from './use-ethereum-withdraw-approvals-store'; import type { EthWithdrawalApprovalState } from './use-ethereum-withdraw-approvals-store'; const mockFindVegaTransaction = jest.fn(); const mockDismissVegaTransaction = jest.fn(); -jest.mock('@vegaprotocol/wallet', () => ({ +jest.mock('./use-vega-transaction-store', () => ({ useVegaTransactionStore: { getState: () => ({ transactions: { diff --git a/libs/web3/src/lib/use-ethereum-withdraw-approvals-store.tsx b/libs/web3/src/lib/use-ethereum-withdraw-approvals-store.tsx index 6949a8716..aca635776 100644 --- a/libs/web3/src/lib/use-ethereum-withdraw-approvals-store.tsx +++ b/libs/web3/src/lib/use-ethereum-withdraw-approvals-store.tsx @@ -1,10 +1,10 @@ import { create } from 'zustand'; import produce from 'immer'; import type BigNumber from 'bignumber.js'; -import type { WithdrawalBusEventFieldsFragment } from '@vegaprotocol/wallet'; -import { useVegaTransactionStore } from '@vegaprotocol/wallet'; +import type { WithdrawalBusEventFieldsFragment } from './__generated__/TransactionResult'; +import { useVegaTransactionStore } from './use-vega-transaction-store'; -import type { WithdrawalApprovalQuery } from '@vegaprotocol/wallet'; +import type { WithdrawalApprovalQuery } from './__generated__/WithdrawalApproval'; import { subscribeWithSelector } from 'zustand/middleware'; export enum ApprovalStatus { diff --git a/libs/web3/src/lib/use-get-withdraw-threshold.tsx b/libs/web3/src/lib/use-get-withdraw-threshold.tsx index af01c8e65..ba5b2c69f 100644 --- a/libs/web3/src/lib/use-get-withdraw-threshold.tsx +++ b/libs/web3/src/lib/use-get-withdraw-threshold.tsx @@ -2,7 +2,7 @@ import { useCallback } from 'react'; import { useBridgeContract } from './use-bridge-contract'; import BigNumber from 'bignumber.js'; import { addDecimal } from '@vegaprotocol/utils'; -import type { WithdrawalBusEventFieldsFragment } from '@vegaprotocol/wallet'; +import type { WithdrawalBusEventFieldsFragment } from './__generated__/TransactionResult'; import { localLoggerFactory } from '@vegaprotocol/logger'; type Asset = Pick< diff --git a/libs/wallet/src/use-transaction-result.spec.tsx b/libs/web3/src/lib/use-transaction-result.spec.tsx similarity index 100% rename from libs/wallet/src/use-transaction-result.spec.tsx rename to libs/web3/src/lib/use-transaction-result.spec.tsx diff --git a/libs/wallet/src/use-transaction-result.ts b/libs/web3/src/lib/use-transaction-result.ts similarity index 100% rename from libs/wallet/src/use-transaction-result.ts rename to libs/web3/src/lib/use-transaction-result.ts diff --git a/libs/wallet/src/use-vega-transaction-manager.spec.tsx b/libs/web3/src/lib/use-vega-transaction-manager.spec.tsx similarity index 94% rename from libs/wallet/src/use-vega-transaction-manager.spec.tsx rename to libs/web3/src/lib/use-vega-transaction-manager.spec.tsx index 76292c2ee..5e216174a 100644 --- a/libs/wallet/src/use-vega-transaction-manager.spec.tsx +++ b/libs/web3/src/lib/use-vega-transaction-manager.spec.tsx @@ -1,19 +1,20 @@ import { useVegaTransactionManager } from './use-vega-transaction-manager'; import { renderHook } from '@testing-library/react'; import waitForNextTick from 'flush-promises'; -import type { TransactionResponse } from './connectors/vega-connector'; +import type { TransactionResponse } from '@vegaprotocol/wallet'; import { VegaTxStatus } from './types'; import type { VegaTransactionStore, VegaStoredTxState, } from './use-vega-transaction-store'; -const mockSendTx = jest.fn | null>, []>(); +const mockSendTx = jest.fn(); const pubKey = 'pubKey'; const mockDisconnect = jest.fn(); -jest.mock('./use-vega-wallet', () => ({ +jest.mock('@vegaprotocol/wallet', () => ({ + ...jest.requireActual('@vegaprotocol/wallet'), useVegaWallet: () => ({ sendTx: mockSendTx, pubKey, diff --git a/libs/wallet/src/use-vega-transaction-manager.tsx b/libs/web3/src/lib/use-vega-transaction-manager.tsx similarity index 93% rename from libs/wallet/src/use-vega-transaction-manager.tsx rename to libs/web3/src/lib/use-vega-transaction-manager.tsx index 7a7192c32..26e73c261 100644 --- a/libs/wallet/src/use-vega-transaction-manager.tsx +++ b/libs/web3/src/lib/use-vega-transaction-manager.tsx @@ -1,7 +1,5 @@ -import { useVegaWallet } from './use-vega-wallet'; +import { useVegaWallet, WalletError, ClientErrors } from '@vegaprotocol/wallet'; import { useEffect, useRef } from 'react'; -import { WalletError } from './connectors'; -import { ClientErrors } from './connectors'; import { useVegaTransactionStore } from './use-vega-transaction-store'; import { WalletClientError, diff --git a/libs/wallet/src/use-vega-transaction-store.spec.tsx b/libs/web3/src/lib/use-vega-transaction-store.spec.tsx similarity index 97% rename from libs/wallet/src/use-vega-transaction-store.spec.tsx rename to libs/web3/src/lib/use-vega-transaction-store.spec.tsx index 070bd0a46..50201ab92 100644 --- a/libs/wallet/src/use-vega-transaction-store.spec.tsx +++ b/libs/web3/src/lib/use-vega-transaction-store.spec.tsx @@ -4,7 +4,7 @@ import type { OrderAmendmentBody, OrderCancellationBody, WithdrawSubmissionBody, -} from './connectors/vega-connector'; +} from '@vegaprotocol/wallet'; import { OrderStatus, OrderTimeInForce, @@ -13,8 +13,8 @@ import { } from '@vegaprotocol/types'; import { VegaTxStatus } from './types'; -jest.mock('./utils', () => ({ - ...jest.requireActual('./utils'), +jest.mock('@vegaprotocol/wallet', () => ({ + ...jest.requireActual('@vegaprotocol/wallet'), determineId: jest.fn((v) => v), })); diff --git a/libs/wallet/src/use-vega-transaction-store.tsx b/libs/web3/src/lib/use-vega-transaction-store.tsx similarity index 98% rename from libs/wallet/src/use-vega-transaction-store.tsx rename to libs/web3/src/lib/use-vega-transaction-store.tsx index 20c159415..b39ac17ab 100644 --- a/libs/wallet/src/use-vega-transaction-store.tsx +++ b/libs/web3/src/lib/use-vega-transaction-store.tsx @@ -1,5 +1,5 @@ import produce from 'immer'; -import type { Transaction } from './connectors'; +import type { Transaction } from '@vegaprotocol/wallet'; import { isWithdrawTransaction, isOrderSubmissionTransaction, @@ -9,8 +9,8 @@ import { isTransferTransaction, isStopOrdersSubmissionTransaction, isStopOrdersCancellationTransaction, -} from './connectors'; -import { determineId } from './utils'; + determineId, +} from '@vegaprotocol/wallet'; import { create } from 'zustand'; import type { diff --git a/libs/web3/src/lib/use-vega-transaction-toasts.spec.tsx b/libs/web3/src/lib/use-vega-transaction-toasts.spec.tsx index ea0e58376..f70324c6e 100644 --- a/libs/web3/src/lib/use-vega-transaction-toasts.spec.tsx +++ b/libs/web3/src/lib/use-vega-transaction-toasts.spec.tsx @@ -1,18 +1,26 @@ import { render } from '@testing-library/react'; +import * as Types from '@vegaprotocol/types'; import { OrderStatus, OrderTimeInForce, OrderType, Side, } from '@vegaprotocol/types'; -import type { VegaStoredTxState } from '@vegaprotocol/wallet'; -import { VegaTxStatus } from '@vegaprotocol/wallet'; + import { VegaTransactionDetails, getVegaTransactionContentIntent, + getOrderToastIntent, + getOrderToastTitle, + getRejectionReason, } from './use-vega-transaction-toasts'; import { Intent } from '@vegaprotocol/ui-toolkit'; -import type { OrderByIdQuery, StopOrderByIdQuery } from '@vegaprotocol/orders'; +import type { + OrderByIdQuery, + StopOrderByIdQuery, +} from './__generated__/Orders'; +import type { VegaStoredTxState } from './use-vega-transaction-store'; +import { VegaTxStatus } from './types'; jest.mock('@vegaprotocol/assets', () => { const A1 = { @@ -56,9 +64,8 @@ jest.mock('@vegaprotocol/markets', () => { }; }); -jest.mock('@vegaprotocol/orders', () => { +jest.mock('./__generated__/Orders', () => { return { - ...jest.requireActual('@vegaprotocol/orders'), useOrderByIdQuery: jest.fn(({ variables: { orderId } }) => { if (orderId === '0') { const data: OrderByIdQuery = { @@ -408,3 +415,99 @@ describe('getVegaTransactionContentIntent', () => { expect(getVegaTransactionContentIntent(batch).intent).toBe(Intent.Primary); }); }); +describe('getOrderToastTitle', () => { + it('should return the correct title', () => { + expect(getOrderToastTitle(Types.OrderStatus.STATUS_ACTIVE)).toBe( + 'Order submitted' + ); + expect(getOrderToastTitle(Types.OrderStatus.STATUS_FILLED)).toBe( + 'Order filled' + ); + expect(getOrderToastTitle(Types.OrderStatus.STATUS_PARTIALLY_FILLED)).toBe( + 'Order partially filled' + ); + expect(getOrderToastTitle(Types.OrderStatus.STATUS_PARKED)).toBe( + 'Order parked' + ); + expect(getOrderToastTitle(Types.OrderStatus.STATUS_STOPPED)).toBe( + 'Order stopped' + ); + expect(getOrderToastTitle(Types.OrderStatus.STATUS_CANCELLED)).toBe( + 'Order cancelled' + ); + expect(getOrderToastTitle(Types.OrderStatus.STATUS_EXPIRED)).toBe( + 'Order expired' + ); + expect(getOrderToastTitle(Types.OrderStatus.STATUS_REJECTED)).toBe( + 'Order rejected' + ); + expect(getOrderToastTitle(undefined)).toBe(undefined); + }); +}); + +describe('getOrderToastIntent', () => { + it('should return the correct intent', () => { + expect(getOrderToastIntent(Types.OrderStatus.STATUS_PARKED)).toBe( + Intent.Warning + ); + expect(getOrderToastIntent(Types.OrderStatus.STATUS_EXPIRED)).toBe( + Intent.Warning + ); + expect(getOrderToastIntent(Types.OrderStatus.STATUS_PARTIALLY_FILLED)).toBe( + Intent.Warning + ); + expect(getOrderToastIntent(Types.OrderStatus.STATUS_REJECTED)).toBe( + Intent.Danger + ); + expect(getOrderToastIntent(Types.OrderStatus.STATUS_STOPPED)).toBe( + Intent.Warning + ); + expect(getOrderToastIntent(Types.OrderStatus.STATUS_FILLED)).toBe( + Intent.Success + ); + expect(getOrderToastIntent(Types.OrderStatus.STATUS_ACTIVE)).toBe( + Intent.Success + ); + expect(getOrderToastIntent(Types.OrderStatus.STATUS_CANCELLED)).toBe( + Intent.Success + ); + expect(getOrderToastIntent(undefined)).toBe(undefined); + }); +}); + +describe('getRejectionReason', () => { + it('should return the correct rejection reason for insufficient asset balance', () => { + expect( + getRejectionReason({ + rejectionReason: + Types.OrderRejectionReason.ORDER_ERROR_INSUFFICIENT_ASSET_BALANCE, + status: Types.OrderStatus.STATUS_REJECTED, + id: '', + createdAt: undefined, + size: '', + price: '', + timeInForce: Types.OrderTimeInForce.TIME_IN_FORCE_FOK, + side: Types.Side.SIDE_BUY, + marketId: '', + }) + ).toBe('Insufficient asset balance'); + }); + + it('should return the correct rejection reason when order is stopped', () => { + expect( + getRejectionReason({ + rejectionReason: null, + status: Types.OrderStatus.STATUS_STOPPED, + id: '', + createdAt: undefined, + size: '', + price: '', + timeInForce: Types.OrderTimeInForce.TIME_IN_FORCE_FOK, + side: Types.Side.SIDE_BUY, + marketId: '', + }) + ).toBe( + 'Your Fill or Kill (FOK) order was not filled and it has been stopped' + ); + }); +}); diff --git a/libs/web3/src/lib/use-vega-transaction-toasts.tsx b/libs/web3/src/lib/use-vega-transaction-toasts.tsx index 4eba5b3fe..af322445f 100644 --- a/libs/web3/src/lib/use-vega-transaction-toasts.tsx +++ b/libs/web3/src/lib/use-vega-transaction-toasts.tsx @@ -4,13 +4,15 @@ import compact from 'lodash/compact'; import type { BatchMarketInstructionSubmissionBody, OrderAmendment, - OrderTxUpdateFieldsFragment, OrderSubmission, - VegaStoredTxState, - WithdrawalBusEventFieldsFragment, StopOrdersSubmission, StopOrderSetup, } from '@vegaprotocol/wallet'; +import type { + OrderTxUpdateFieldsFragment, + WithdrawalBusEventFieldsFragment, +} from './__generated__/TransactionResult'; +import type { VegaStoredTxState } from './use-vega-transaction-store'; import { isTransferTransaction, isBatchMarketInstructionsTransaction, @@ -21,12 +23,12 @@ import { isOrderCancellationTransaction, isOrderSubmissionTransaction, isWithdrawTransaction, - useVegaTransactionStore, - VegaTxStatus, isStopOrdersSubmissionTransaction, isStopOrdersCancellationTransaction, isReferralRelatedTransaction, } from '@vegaprotocol/wallet'; +import { useVegaTransactionStore } from './use-vega-transaction-store'; +import { VegaTxStatus } from './types'; import type { Toast, ToastContent } from '@vegaprotocol/ui-toolkit'; import { ToastHeading } from '@vegaprotocol/ui-toolkit'; import { Panel } from '@vegaprotocol/ui-toolkit'; @@ -45,12 +47,9 @@ import { useAssetsMapProvider } from '@vegaprotocol/assets'; import { useEthWithdrawApprovalsStore } from './use-ethereum-withdraw-approvals-store'; import { DApp, EXPLORER_TX, useLinks } from '@vegaprotocol/environment'; import { - getOrderToastIntent, - getOrderToastTitle, - getRejectionReason, useOrderByIdQuery, useStopOrderByIdQuery, -} from '@vegaprotocol/orders'; +} from './__generated__/Orders'; import { getAsset, useMarketsMapProvider } from '@vegaprotocol/markets'; import type { Market } from '@vegaprotocol/markets'; import type { Side } from '@vegaprotocol/types'; @@ -59,6 +58,75 @@ import { Size } from '@vegaprotocol/datagrid'; import { useWithdrawalApprovalDialog } from './withdrawal-approval-dialog'; import * as Schema from '@vegaprotocol/types'; +export const getRejectionReason = ( + order: OrderTxUpdateFieldsFragment +): string | null => { + switch (order.status) { + case Schema.OrderStatus.STATUS_STOPPED: + return t( + `Your ${ + Schema.OrderTimeInForceMapping[order.timeInForce] + } order was not filled and it has been stopped` + ); + default: + return order.rejectionReason + ? t(Schema.OrderRejectionReasonMapping[order.rejectionReason]) + : ''; + } +}; + +export const getOrderToastTitle = ( + status?: Schema.OrderStatus +): string | undefined => { + if (!status) { + return; + } + + switch (status) { + case Schema.OrderStatus.STATUS_ACTIVE: + return t('Order submitted'); + case Schema.OrderStatus.STATUS_FILLED: + return t('Order filled'); + case Schema.OrderStatus.STATUS_PARTIALLY_FILLED: + return t('Order partially filled'); + case Schema.OrderStatus.STATUS_PARKED: + return t('Order parked'); + case Schema.OrderStatus.STATUS_STOPPED: + return t('Order stopped'); + case Schema.OrderStatus.STATUS_CANCELLED: + return t('Order cancelled'); + case Schema.OrderStatus.STATUS_EXPIRED: + return t('Order expired'); + case Schema.OrderStatus.STATUS_REJECTED: + return t('Order rejected'); + default: + return t('Submission failed'); + } +}; + +export const getOrderToastIntent = ( + status?: Schema.OrderStatus +): Intent | undefined => { + if (!status) { + return; + } + switch (status) { + case Schema.OrderStatus.STATUS_PARKED: + case Schema.OrderStatus.STATUS_EXPIRED: + case Schema.OrderStatus.STATUS_PARTIALLY_FILLED: + case Schema.OrderStatus.STATUS_STOPPED: + return Intent.Warning; + case Schema.OrderStatus.STATUS_REJECTED: + return Intent.Danger; + case Schema.OrderStatus.STATUS_FILLED: + case Schema.OrderStatus.STATUS_ACTIVE: + case Schema.OrderStatus.STATUS_CANCELLED: + return Intent.Success; + default: + return; + } +}; + const intentMap: { [s in VegaTxStatus]: Intent } = { Default: Intent.Primary, Requested: Intent.Warning, diff --git a/libs/wallet/src/use-vega-transaction-updater.spec.tsx b/libs/web3/src/lib/use-vega-transaction-updater.spec.tsx similarity index 99% rename from libs/wallet/src/use-vega-transaction-updater.spec.tsx rename to libs/web3/src/lib/use-vega-transaction-updater.spec.tsx index 10d833eed..1250ddfc0 100644 --- a/libs/wallet/src/use-vega-transaction-updater.spec.tsx +++ b/libs/web3/src/lib/use-vega-transaction-updater.spec.tsx @@ -38,7 +38,7 @@ const render = (mocks?: MockedResponse[]) => { const pubKey = 'pubKey'; -jest.mock('./use-vega-wallet', () => ({ +jest.mock('@vegaprotocol/wallet', () => ({ useVegaWallet: () => ({ pubKey, }), diff --git a/libs/wallet/src/use-vega-transaction-updater.tsx b/libs/web3/src/lib/use-vega-transaction-updater.tsx similarity index 97% rename from libs/wallet/src/use-vega-transaction-updater.tsx rename to libs/web3/src/lib/use-vega-transaction-updater.tsx index 9a5e742ff..d7d40d44f 100644 --- a/libs/wallet/src/use-vega-transaction-updater.tsx +++ b/libs/web3/src/lib/use-vega-transaction-updater.tsx @@ -1,5 +1,5 @@ import { useApolloClient } from '@apollo/client'; -import { useVegaWallet } from './use-vega-wallet'; +import { useVegaWallet } from '@vegaprotocol/wallet'; import { useOrderTxUpdateSubscription, useWithdrawalBusEventSubscription, diff --git a/libs/wallet/src/wait-for-withdrawal-approval.spec.ts b/libs/web3/src/lib/wait-for-withdrawal-approval.spec.ts similarity index 100% rename from libs/wallet/src/wait-for-withdrawal-approval.spec.ts rename to libs/web3/src/lib/wait-for-withdrawal-approval.spec.ts diff --git a/libs/wallet/src/wait-for-withdrawal-approval.ts b/libs/web3/src/lib/wait-for-withdrawal-approval.ts similarity index 100% rename from libs/wallet/src/wait-for-withdrawal-approval.ts rename to libs/web3/src/lib/wait-for-withdrawal-approval.ts diff --git a/libs/web3/src/lib/withdrawal-approval-dialog.tsx b/libs/web3/src/lib/withdrawal-approval-dialog.tsx index 69148a903..47c76b3d2 100644 --- a/libs/web3/src/lib/withdrawal-approval-dialog.tsx +++ b/libs/web3/src/lib/withdrawal-approval-dialog.tsx @@ -10,7 +10,7 @@ import { VegaIcon, VegaIconNames, } from '@vegaprotocol/ui-toolkit'; -import { useWithdrawalApprovalQuery } from '@vegaprotocol/wallet'; +import { useWithdrawalApprovalQuery } from './__generated__/WithdrawalApproval'; import omit from 'lodash/omit'; import { create } from 'zustand'; diff --git a/libs/withdraws/src/index.ts b/libs/withdraws/src/index.ts index 5808716d0..f4e50ee1d 100644 --- a/libs/withdraws/src/index.ts +++ b/libs/withdraws/src/index.ts @@ -1,8 +1,6 @@ export * from './lib/__generated__/Erc20Approval'; export * from './lib/__generated__/Withdrawal'; export * from './lib/create-withdrawal-dialog'; -export * from './lib/use-complete-withdraw'; -export * from './lib/use-create-withdraw'; export * from './lib/use-verify-withdrawal'; export * from './lib/withdraw-form-container'; export * from './lib/withdraw-form'; diff --git a/libs/withdraws/src/lib/create-withdrawal-dialog.tsx b/libs/withdraws/src/lib/create-withdrawal-dialog.tsx index ed3760664..33e81fb9f 100644 --- a/libs/withdraws/src/lib/create-withdrawal-dialog.tsx +++ b/libs/withdraws/src/lib/create-withdrawal-dialog.tsx @@ -4,7 +4,7 @@ import { useVegaWallet } from '@vegaprotocol/wallet'; import { WithdrawFormContainer } from './withdraw-form-container'; import { useWeb3ConnectStore } from '@vegaprotocol/web3'; import { useWithdrawalDialog } from './withdrawal-dialog'; -import { useVegaTransactionStore } from '@vegaprotocol/wallet'; +import { useVegaTransactionStore } from '@vegaprotocol/web3'; export const CreateWithdrawalDialog = () => { const { assetId, isOpen, open, close } = useWithdrawalDialog(); diff --git a/libs/withdraws/src/lib/use-create-withdraw.spec.tsx b/libs/withdraws/src/lib/use-create-withdraw.spec.tsx deleted file mode 100644 index 6ab287f4c..000000000 --- a/libs/withdraws/src/lib/use-create-withdraw.spec.tsx +++ /dev/null @@ -1,192 +0,0 @@ -import { act, renderHook } from '@testing-library/react'; -import type { MockedResponse } from '@apollo/client/testing'; -import { MockedProvider } from '@apollo/client/testing'; -import type { ReactNode } from 'react'; -import type { WithdrawalArgs } from './use-create-withdraw'; -import { useCreateWithdraw } from './use-create-withdraw'; -import { Erc20ApprovalDocument } from './__generated__/Erc20Approval'; -import type { Erc20ApprovalQuery } from './__generated__/Erc20Approval'; -import type { VegaWalletContextShape } from '@vegaprotocol/wallet'; -import { - initialState, - VegaTxStatus, - VegaWalletContext, - determineId, -} from '@vegaprotocol/wallet'; -import { waitFor } from '@testing-library/react'; -import type { - WithdrawalEventSubscription, - WithdrawalFieldsFragment, -} from './__generated__/Withdrawal'; -import { WithdrawalEventDocument } from './__generated__/Withdrawal'; -import * as Schema from '@vegaprotocol/types'; - -function setup( - vegaWalletContext: Partial, - mocks?: MockedResponse[] -) { - const wrapper = ({ children }: { children: ReactNode }) => ( - - - {children} - - - ); - return renderHook(() => useCreateWithdraw(), { wrapper }); -} - -const txHash = 'tx-hash'; -const signature = - 'cfe592d169f87d0671dd447751036d0dddc165b9c4b65e5a5060e2bbadd1aa726d4cbe9d3c3b327bcb0bff4f83999592619a2493f9bbd251fae99ce7ce766909'; -const derivedWithdrawalId = determineId(signature); - -beforeAll(() => { - jest.useFakeTimers(); -}); - -afterAll(() => { - jest.useRealTimers(); -}); - -const pubKey = '0x123'; -let mockSend: jest.Mock; -let withdrawalInput: WithdrawalArgs; -let withdrawalEvent: WithdrawalFieldsFragment; -let mockERC20Approval: MockedResponse; -let mockWithdrawalEvent: MockedResponse; - -beforeEach(() => { - mockSend = jest - .fn() - .mockReturnValue(Promise.resolve({ transactionHash: txHash, signature })); - withdrawalEvent = { - id: '2fca514cebf9f465ae31ecb4c5721e3a6f5f260425ded887ca50ba15b81a5d50', - status: Schema.WithdrawalStatus.STATUS_OPEN, - amount: '100', - asset: { - __typename: 'Asset', - id: 'asset-id', - name: 'asset-name', - symbol: 'asset-symbol', - decimals: 2, - status: Schema.AssetStatus.STATUS_ENABLED, - source: { - __typename: 'ERC20', - contractAddress: '0x123', - }, - }, - createdTimestamp: '2022-07-05T14:25:47.815283706Z', - withdrawnTimestamp: '2022-07-05T14:25:47.815283706Z', - txHash: '0x123', - details: { - __typename: 'Erc20WithdrawalDetails', - receiverAddress: '0x123', - }, - pendingOnForeignChain: false, - __typename: 'Withdrawal', - }; - withdrawalInput = { - amount: '100', - asset: 'asset-id', - receiverAddress: 'receiver-address', - availableTimestamp: null, - }; - mockERC20Approval = { - request: { - query: Erc20ApprovalDocument, - variables: { withdrawalId: derivedWithdrawalId }, - }, - result: { - data: { - erc20WithdrawalApproval: { - __typename: 'Erc20WithdrawalApproval', - assetSource: 'asset-source', - amount: '100', - nonce: '1', - signatures: 'signatures', - targetAddress: 'targetAddress', - creation: '1', - }, - }, - }, - delay: 2000, - }; - mockWithdrawalEvent = { - request: { - query: WithdrawalEventDocument, - variables: { partyId: pubKey }, - }, - result: { - data: { - busEvents: [ - { - event: withdrawalEvent, - __typename: 'BusEvent', - }, - ], - }, - }, - delay: 1000, - }; -}); - -it('creates withdrawal and waits for approval creation', async () => { - const { result } = setup({ sendTx: mockSend, pubKey }, [ - mockWithdrawalEvent, - mockERC20Approval, - ]); - - expect(result.current.transaction).toEqual(initialState); - expect(result.current.submit).toEqual(expect.any(Function)); - expect(result.current.reset).toEqual(expect.any(Function)); - expect(result.current.approval).toEqual(null); - - act(() => { - result.current.submit(withdrawalInput); - }); - - expect(mockSend).toHaveBeenCalledWith(pubKey, { - withdrawSubmission: { - amount: withdrawalInput.amount, - asset: withdrawalInput.asset, - ext: { - erc20: { - receiverAddress: withdrawalInput.receiverAddress, - }, - }, - }, - }); - - expect(result.current.transaction.status).toEqual(VegaTxStatus.Requested); - - await waitFor(() => { - expect(result.current.transaction.status).toEqual(VegaTxStatus.Pending); - expect(result.current.transaction.dialogOpen).toBe(true); - // Withdrawal event should not be found yet - expect(result.current.withdrawal).toEqual(null); - // Poll for erc20Approval should not be complete yet - expect(result.current.approval).toEqual(null); - }); - - await act(async () => { - // Advance time by delay plus interval length to ensure mock result is triggered - // eslint-disable-next-line - jest.advanceTimersByTime(mockWithdrawalEvent.delay! + 1000); - }); - - expect(result.current.withdrawal).toEqual(withdrawalEvent); - - await act(async () => { - // Advance time by delay plus interval length to ensure mock result is triggered - // eslint-disable-next-line - jest.advanceTimersByTime(mockERC20Approval.delay! + 1000); - }); - - expect(result.current.transaction.status).toEqual(VegaTxStatus.Complete); - expect(result.current.approval).toEqual( - // @ts-ignore MockedRespones types inteferring - mockERC20Approval.result.data.erc20WithdrawalApproval - ); -}); diff --git a/libs/withdraws/src/lib/use-create-withdraw.ts b/libs/withdraws/src/lib/use-create-withdraw.ts deleted file mode 100644 index 52cb2c347..000000000 --- a/libs/withdraws/src/lib/use-create-withdraw.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { - useVegaTransaction, - useVegaWallet, - determineId, -} from '@vegaprotocol/wallet'; -import { useCallback, useState } from 'react'; -import { useWithdrawalApproval } from './use-withdrawal-approval'; -import { useWithdrawalEvent } from './use-withdrawal-event'; -import type { Erc20ApprovalQuery } from './__generated__/Erc20Approval'; -import type { WithdrawalFieldsFragment } from './__generated__/Withdrawal'; - -export interface WithdrawalArgs { - amount: string; - asset: string; - receiverAddress: string; - availableTimestamp: number | null; -} - -export const useCreateWithdraw = () => { - const waitForWithdrawalApproval = useWithdrawalApproval(); - const [approval, setApproval] = useState< - Erc20ApprovalQuery['erc20WithdrawalApproval'] | null - >(null); - const [withdrawal, setWithdrawal] = useState( - null - ); - const [availableTimestamp, setAvailableTimestamp] = useState( - null - ); - - const { pubKey } = useVegaWallet(); - const { transaction, send, setComplete, reset, Dialog } = - useVegaTransaction(); - - const waitForWithdrawal = useWithdrawalEvent(transaction); - - const submit = useCallback( - async (withdrawal: WithdrawalArgs) => { - if (!pubKey) { - return; - } - - setAvailableTimestamp(withdrawal.availableTimestamp); - - const res = await send(pubKey, { - withdrawSubmission: { - amount: withdrawal.amount, - asset: withdrawal.asset, - ext: { - erc20: { - receiverAddress: withdrawal.receiverAddress, - }, - }, - }, - }); - - if (res) { - const withdrawalId = determineId(res.signature); - - const withdrawal = await waitForWithdrawal(withdrawalId, pubKey); - setWithdrawal(withdrawal); - const approval = await waitForWithdrawalApproval(withdrawal.id); - setApproval(approval); - setComplete(); - } - }, - [pubKey, send, waitForWithdrawal, waitForWithdrawalApproval, setComplete] - ); - - return { - transaction, - submit, - reset, - approval, - withdrawal, - availableTimestamp, - Dialog, - }; -}; diff --git a/libs/withdraws/src/lib/use-ready-to-complete-withdrawals-toast.tsx b/libs/withdraws/src/lib/use-ready-to-complete-withdrawals-toast.tsx index 47c3e20e8..ce7942101 100644 --- a/libs/withdraws/src/lib/use-ready-to-complete-withdrawals-toast.tsx +++ b/libs/withdraws/src/lib/use-ready-to-complete-withdrawals-toast.tsx @@ -1,8 +1,5 @@ import { useDataProvider } from '@vegaprotocol/data-provider'; -import { - useVegaWallet, - useWithdrawalApprovalQuery, -} from '@vegaprotocol/wallet'; +import { useVegaWallet } from '@vegaprotocol/wallet'; import BigNumber from 'bignumber.js'; import type { Toast } from '@vegaprotocol/ui-toolkit'; import { Button, Intent, Panel, ToastHeading } from '@vegaprotocol/ui-toolkit'; @@ -15,6 +12,7 @@ import { useEthWithdrawApprovalsStore, useGetWithdrawDelay, useGetWithdrawThreshold, + useWithdrawalApprovalQuery, } from '@vegaprotocol/web3'; import { withdrawalProvider } from './withdrawals-provider'; import type { WithdrawalFieldsFragment } from './__generated__/Withdrawal'; diff --git a/libs/withdraws/src/lib/use-withdrawal-event.ts b/libs/withdraws/src/lib/use-withdrawal-event.ts index f7985c88c..ebfa7bee4 100644 --- a/libs/withdraws/src/lib/use-withdrawal-event.ts +++ b/libs/withdraws/src/lib/use-withdrawal-event.ts @@ -1,5 +1,5 @@ import { useApolloClient } from '@apollo/client'; -import type { VegaTxState } from '@vegaprotocol/wallet'; +import type { VegaTxState } from '@vegaprotocol/web3'; import { useCallback, useEffect, useRef } from 'react'; import type { Subscription } from 'zen-observable-ts'; import { WithdrawalEventDocument } from './__generated__/Withdrawal'; diff --git a/libs/withdraws/src/lib/withdraw-form-container.tsx b/libs/withdraws/src/lib/withdraw-form-container.tsx index 2a04d26c8..d04a545d6 100644 --- a/libs/withdraws/src/lib/withdraw-form-container.tsx +++ b/libs/withdraws/src/lib/withdraw-form-container.tsx @@ -4,9 +4,10 @@ import { t } from '@vegaprotocol/i18n'; import { useDataProvider } from '@vegaprotocol/data-provider'; import { AsyncRendererInline } from '@vegaprotocol/ui-toolkit'; import { accountsDataProvider } from '@vegaprotocol/accounts'; -import type { WithdrawalArgs } from './use-create-withdraw'; + import { WithdrawManager } from './withdraw-manager'; import * as Types from '@vegaprotocol/types'; +import type { WithdrawalArgs } from './withdraw-form'; interface WithdrawFormContainerProps { partyId?: string; diff --git a/libs/withdraws/src/lib/withdraw-form.tsx b/libs/withdraws/src/lib/withdraw-form.tsx index 60b1b5f4c..9fd87b553 100644 --- a/libs/withdraws/src/lib/withdraw-form.tsx +++ b/libs/withdraws/src/lib/withdraw-form.tsx @@ -26,7 +26,6 @@ import { useEffect, type ButtonHTMLAttributes } from 'react'; import type { ControllerRenderProps } from 'react-hook-form'; import { formatDistanceToNow } from 'date-fns'; import { useForm, Controller, useWatch } from 'react-hook-form'; -import type { WithdrawalArgs } from './use-create-withdraw'; import { WithdrawLimits } from './withdraw-limits'; import { ETHEREUM_EAGER_CONNECT, @@ -36,6 +35,13 @@ import { import { AssetBalance } from './asset-balance'; import { DocsLinks } from '@vegaprotocol/environment'; +export interface WithdrawalArgs { + amount: string; + asset: string; + receiverAddress: string; + availableTimestamp: number | null; +} + interface FormFields { asset: string; to: string; diff --git a/libs/withdraws/src/lib/withdraw-manager.tsx b/libs/withdraws/src/lib/withdraw-manager.tsx index f20f7153d..fca082d1a 100644 --- a/libs/withdraws/src/lib/withdraw-manager.tsx +++ b/libs/withdraws/src/lib/withdraw-manager.tsx @@ -1,6 +1,6 @@ import sortBy from 'lodash/sortBy'; +import type { WithdrawalArgs } from './withdraw-form'; import { WithdrawForm } from './withdraw-form'; -import type { WithdrawalArgs } from './use-create-withdraw'; import type { Asset } from '@vegaprotocol/assets'; import type { AccountFieldsFragment } from '@vegaprotocol/accounts'; import { useWithdrawAsset } from './use-withdraw-asset'; diff --git a/libs/withdraws/src/lib/withdrawal-dialog.tsx b/libs/withdraws/src/lib/withdrawal-dialog.tsx index ccdfd5059..3a7b32f0a 100644 --- a/libs/withdraws/src/lib/withdrawal-dialog.tsx +++ b/libs/withdraws/src/lib/withdrawal-dialog.tsx @@ -1,12 +1,4 @@ import { create } from 'zustand'; -import { t } from '@vegaprotocol/i18n'; -import { Dialog } from '@vegaprotocol/ui-toolkit'; -import { useVegaWallet } from '@vegaprotocol/wallet'; -import { useCompleteWithdraw } from './use-complete-withdraw'; -import { useCreateWithdraw } from './use-create-withdraw'; -import { WithdrawFormContainer } from './withdraw-form-container'; -import { WithdrawalFeedback } from './withdrawal-feedback'; -import { useWeb3ConnectStore } from '@vegaprotocol/web3'; interface State { isOpen: boolean; assetId?: string; @@ -23,48 +15,3 @@ export const useWithdrawalDialog = create()((set) => ({ open: (assetId) => set(() => ({ assetId, isOpen: true })), close: () => set(() => ({ assetId: undefined, isOpen: false })), })); - -export const WithdrawalDialog = () => { - const { assetId, isOpen, open, close } = useWithdrawalDialog(); - const { pubKey } = useVegaWallet(); - const createWithdraw = useCreateWithdraw(); - const completeWithdraw = useCompleteWithdraw(); - const connectWalletDialogIsOpen = useWeb3ConnectStore( - (state) => state.isOpen - ); - return ( - <> - (isOpen ? open() : close())} - size="small" - > - { - close(); - createWithdraw.submit(args); - }} - /> - - { - createWithdraw.reset(); - completeWithdraw.submit(id); - }} - /> - ), - }} - /> - - - ); -}; diff --git a/libs/withdraws/src/lib/withdrawal-feedback.tsx b/libs/withdraws/src/lib/withdrawal-feedback.tsx index 647cd5fa1..fa7284d73 100644 --- a/libs/withdraws/src/lib/withdrawal-feedback.tsx +++ b/libs/withdraws/src/lib/withdrawal-feedback.tsx @@ -6,7 +6,7 @@ import { KeyValueTable, KeyValueTableRow, } from '@vegaprotocol/ui-toolkit'; -import type { VegaTxState } from '@vegaprotocol/wallet'; +import type { VegaTxState } from '@vegaprotocol/web3'; import { getChainName, useWeb3ConnectStore } from '@vegaprotocol/web3'; import { useWeb3React } from '@web3-react/core'; import { formatDistanceToNow } from 'date-fns';