From acf1d50d0f47e22bf32837094c91d6fdd411c0e0 Mon Sep 17 00:00:00 2001 From: Edd Date: Fri, 29 Sep 2023 17:29:16 +0100 Subject: [PATCH 01/12] 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 02/12] 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 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 03/12] 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 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 04/12] 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 05/12] 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 06/12] 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 872f1d300f54eaba325a1550189329afa171f489 Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Tue, 3 Oct 2023 07:21:19 -0400 Subject: [PATCH 07/12] fix(wallet): dont show error state if user rejects connection (#4901) Co-authored-by: Madalina Raicu --- libs/wallet/src/connect-dialog/injected-connector-form.tsx | 7 ++++++- libs/wallet/src/connectors/injected-connector.ts | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libs/wallet/src/connect-dialog/injected-connector-form.tsx b/libs/wallet/src/connect-dialog/injected-connector-form.tsx index 1fce47bd3..88ca00a39 100644 --- a/libs/wallet/src/connect-dialog/injected-connector-form.tsx +++ b/libs/wallet/src/connect-dialog/injected-connector-form.tsx @@ -131,7 +131,12 @@ const Error = ({ ); if (error) { - if (error.message === InjectedConnectorErrors.INVALID_CHAIN.message) { + if (error.message === InjectedConnectorErrors.USER_REJECTED.message) { + title = t('User rejected'); + text = t('The user rejected the wallet connection'); + } else if ( + error.message === InjectedConnectorErrors.INVALID_CHAIN.message + ) { title = t('Wrong network'); text = t( 'To complete your wallet connection, set your wallet network in your app to "%s".', diff --git a/libs/wallet/src/connectors/injected-connector.ts b/libs/wallet/src/connectors/injected-connector.ts index 8ebc66b3e..dbe9f106e 100644 --- a/libs/wallet/src/connectors/injected-connector.ts +++ b/libs/wallet/src/connectors/injected-connector.ts @@ -42,6 +42,7 @@ declare global { } export const InjectedConnectorErrors = { + USER_REJECTED: new Error('Connection denied'), VEGA_UNDEFINED: new Error('window.vega not found'), INVALID_CHAIN: new Error('Invalid chain'), }; From 2a7574bd8e75a9d7e18927944543cb74989a5ce2 Mon Sep 17 00:00:00 2001 From: "m.ray" <16125548+MadalinaRaicu@users.noreply.github.com> Date: Tue, 3 Oct 2023 14:30:24 +0300 Subject: [PATCH 08/12] fix(governance): add wallet connect project ID (#4966) --- apps/governance/.env | 1 + apps/governance/.env.mainnet | 2 +- apps/governance/.env.stagnet1 | 1 + apps/governance/.env.testnet | 1 + apps/trading/.env.mainnet | 1 + apps/trading/.env.stagnet1 | 2 +- apps/trading/.env.testnet | 1 + 7 files changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/governance/.env b/apps/governance/.env index b29f0272c..7aef36d66 100644 --- a/apps/governance/.env +++ b/apps/governance/.env @@ -8,6 +8,7 @@ NX_FAIRGROUND=false NX_VEGA_NETWORKS='{"DEVNET":"https://dev.governance.vega.xyz","STAGNET1":"https://governance.stagnet1.vega.rocks","TESTNET":"https://governance.fairground.wtf","MAINNET":"https://governance.vega.xyz"}' NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions NX_VEGA_WALLET_URL=http://localhost:1789 +NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72 NX_VEGA_EXPLORER_URL=https://explorer.stagnet1.vega.rocks NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json diff --git a/apps/governance/.env.mainnet b/apps/governance/.env.mainnet index 9208e58b4..eaa56e38e 100644 --- a/apps/governance/.env.mainnet +++ b/apps/governance/.env.mainnet @@ -17,7 +17,7 @@ NX_VEGA_REST_URL=https://api.vega.community/api/v2/ 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-mainnet NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json - +NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72 NX_TENDERMINT_URL=https://be.vega.community NX_TENDERMINT_WEBSOCKET_URL=wss://be.vega.community/websocket diff --git a/apps/governance/.env.stagnet1 b/apps/governance/.env.stagnet1 index 29d15032f..8cca38b0a 100644 --- a/apps/governance/.env.stagnet1 +++ b/apps/governance/.env.stagnet1 @@ -10,6 +10,7 @@ NX_TRANCHES_SERVICE_URL=https://tranches-stagnet1-k8s.ops.vega.xyz NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json NX_VEGA_REST_URL=https://api.n00.stagnet1.vega.xyz/api/v2/ NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json +NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72 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 diff --git a/apps/governance/.env.testnet b/apps/governance/.env.testnet index 38cf946ce..ef36bb0b4 100644 --- a/apps/governance/.env.testnet +++ b/apps/governance/.env.testnet @@ -15,6 +15,7 @@ NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/annou NX_VEGA_REST_URL=https://api.n07.testnet.vega.xyz/api/v2/ NX_SENTRY_DSN=https://4b8c8a8ba07742648aa4dfe1b8d17e40@o286262.ingest.sentry.io/5882996 NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json +NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72 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 diff --git a/apps/trading/.env.mainnet b/apps/trading/.env.mainnet index 19f9f45cb..463709c93 100644 --- a/apps/trading/.env.mainnet +++ b/apps/trading/.env.mainnet @@ -16,6 +16,7 @@ NX_VEGA_CONSOLE_URL=https://console.vega.xyz NX_CHROME_EXTENSION_URL=https://chrome.google.com/webstore/detail/vega-wallet-mainnet/codfcglpplgmmlokgilfkpcjnmkbfiel NX_MOZILLA_EXTENSION_URL=https://addons.mozilla.org/firefox/addon/vega-wallet-mainnet NX_ORACLE_PROOFS_URL=https://raw.githubusercontent.com/vegaprotocol/well-known/main/__generated__/oracle-proofs.json +NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72 # Cosmic elevator flags NX_SUCCESSOR_MARKETS=true diff --git a/apps/trading/.env.stagnet1 b/apps/trading/.env.stagnet1 index fc93d40cb..0d9a94800 100644 --- a/apps/trading/.env.stagnet1 +++ b/apps/trading/.env.stagnet1 @@ -16,7 +16,7 @@ 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 - +NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72 # Cosmic elevator flags NX_SUCCESSOR_MARKETS=true diff --git a/apps/trading/.env.testnet b/apps/trading/.env.testnet index 78caf98d6..f635b582a 100644 --- a/apps/trading/.env.testnet +++ b/apps/trading/.env.testnet @@ -17,6 +17,7 @@ NX_VEGA_CONSOLE_URL=https://console.fairground.wtf 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 +NX_WALLETCONNECT_PROJECT_ID=fe8091dc35738863e509fc4947525c72 # Cosmic elevator flags NX_SUCCESSOR_MARKETS=true From f74687d30c17570d475c0f712b34fbda144922d1 Mon Sep 17 00:00:00 2001 From: Maciek Date: Tue, 3 Oct 2023 13:31:05 +0200 Subject: [PATCH 09/12] chore(trading): 4947 cant view settled market main (#4964) --- .../closed-market/closed-market.tsx | 5 ++++ .../client-pages/closed-market/index.ts | 1 + apps/trading/client-pages/market/market.tsx | 28 +++++++++++++++---- apps/trading/client-pages/markets/closed.tsx | 24 ++++++++++++++++ .../layouts/layout-with-sidebar.tsx | 1 + apps/trading/components/sidebar/sidebar.tsx | 14 ++++++++++ .../lib/hooks/use-market-click-handler.ts | 13 +++++++++ apps/trading/pages/client-router.tsx | 12 ++++++++ 8 files changed, 93 insertions(+), 5 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 05f8a3159..8f07b11fc 100644 --- a/apps/trading/client-pages/market/market.tsx +++ b/apps/trading/client-pages/market/market.tsx @@ -12,6 +12,7 @@ import { useNavigate, useParams } from 'react-router-dom'; import { Links, Routes } from '../../pages/client-router'; 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[Routes.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 tradeView = useMemo(() => { if (largeScreen) { diff --git a/apps/trading/client-pages/markets/closed.tsx b/apps/trading/client-pages/markets/closed.tsx index a1ebba418..46932bedb 100644 --- a/apps/trading/client-pages/markets/closed.tsx +++ b/apps/trading/client-pages/markets/closed.tsx @@ -24,6 +24,8 @@ import { SettlementPriceCell } from './settlement-price-cell'; import { useDataProvider } from '@vegaprotocol/data-provider'; import { MarketActionsDropdown } from './market-table-actions'; import { MarketCodeCell } from './market-code-cell'; +import type { CellClickedEvent } from 'ag-grid-community'; +import { useClosedMarketClickHandler } from '../../lib/hooks/use-market-click-handler'; type SettlementAsset = MarketMaybeWithData['tradableInstrument']['instrument']['product']['settlementAsset']; @@ -112,6 +114,7 @@ const ClosedMarketsDataGrid = ({ rowData: Row[]; error: Error | undefined; }) => { + const handleOnSelect = useClosedMarketClickHandler(); const openAssetDialog = useAssetDetailsDialogStore((store) => store.open); const colDefs = useMemo(() => { @@ -268,6 +271,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 0e777b993..34e69c57e 100644 --- a/apps/trading/components/layouts/layout-with-sidebar.tsx +++ b/apps/trading/components/layouts/layout-with-sidebar.tsx @@ -24,6 +24,7 @@ export const LayoutWithSidebar = () => {
} /> + } /> } />
diff --git a/apps/trading/components/sidebar/sidebar.tsx b/apps/trading/components/sidebar/sidebar.tsx index 6eb66a593..ff137ec9e 100644 --- a/apps/trading/components/sidebar/sidebar.tsx +++ b/apps/trading/components/sidebar/sidebar.tsx @@ -110,6 +110,20 @@ export const Sidebar = () => { } /> + + + + + } + />