From eaea6a38ece576e71b3f9e97e0c9623064b2d2c9 Mon Sep 17 00:00:00 2001 From: botond <105208209+notbot00@users.noreply.github.com> Date: Thu, 25 Aug 2022 15:23:57 +0100 Subject: [PATCH] Feat/722: Network switcher in console2 (#1073) * feat: add network switcher dropdown to the trading app * fix: refactor label text * fix: format * fix: paddings * fix: use theme spacing instead of px --- apps/static/src/assets/stagnet3-tranches.json | 2 +- apps/token/src/hooks/use-tranches.ts | 2 +- apps/trading/components/navbar/navbar.tsx | 24 +- libs/environment/src/components/index.ts | 1 + .../src/components/network-switcher/index.tsx | 1 + .../network-switcher.spec.tsx | 227 ++++++++++++++++++ .../network-switcher/network-switcher.tsx | 183 ++++++++++++++ .../node-switcher/node-switcher.spec.tsx | 4 +- .../src/hooks/use-environment-errors.spec.tsx | 2 +- .../src/hooks/use-environment.spec.tsx | 2 +- libs/environment/src/setup-tests.ts | 21 ++ .../src/utils/compile-environment.ts | 10 + 12 files changed, 463 insertions(+), 16 deletions(-) create mode 100644 libs/environment/src/components/network-switcher/index.tsx create mode 100644 libs/environment/src/components/network-switcher/network-switcher.spec.tsx create mode 100644 libs/environment/src/components/network-switcher/network-switcher.tsx diff --git a/apps/static/src/assets/stagnet3-tranches.json b/apps/static/src/assets/stagnet3-tranches.json index 626451c00..b14b4a2b2 100644 --- a/apps/static/src/assets/stagnet3-tranches.json +++ b/apps/static/src/assets/stagnet3-tranches.json @@ -10,4 +10,4 @@ "withdrawals": [], "users": [] } -] \ No newline at end of file +] diff --git a/apps/token/src/hooks/use-tranches.ts b/apps/token/src/hooks/use-tranches.ts index 1b6740744..cb4ab7f07 100644 --- a/apps/token/src/hooks/use-tranches.ts +++ b/apps/token/src/hooks/use-tranches.ts @@ -10,7 +10,7 @@ const TRANCHES_URLS: { [N in Networks]: string } = { MAINNET: 'https://static.vega.xyz/assets/mainnet-tranches.json', TESTNET: 'https://static.vega.xyz/assets/testnet-tranches.json', STAGNET: 'https://static.vega.xyz/assets/stagnet1-tranches.json', - STAGNET3: 'https://static.vega.xyz/assets/stagnet2-tranches.json', + STAGNET3: 'https://static.vega.xyz/assets/stagnet3-tranches.json', DEVNET: 'https://static.vega.xyz/assets/devnet-tranches.json', CUSTOM: 'https://static.vega.xyz/assets/testnet-tranches.json', }; diff --git a/apps/trading/components/navbar/navbar.tsx b/apps/trading/components/navbar/navbar.tsx index 17fe3b994..d6427aa8a 100644 --- a/apps/trading/components/navbar/navbar.tsx +++ b/apps/trading/components/navbar/navbar.tsx @@ -1,8 +1,9 @@ -import { useRouter } from 'next/router'; -import { Vega } from '../icons/vega'; -import Link from 'next/link'; -import { t } from '@vegaprotocol/react-helpers'; import classNames from 'classnames'; +import { useRouter } from 'next/router'; +import Link from 'next/link'; +import { NetworkSwitcher } from '@vegaprotocol/environment'; +import { t } from '@vegaprotocol/react-helpers'; +import { Vega } from '../icons/vega'; import { useGlobalStore } from '../../stores/global'; export const Navbar = () => { @@ -10,12 +11,15 @@ export const Navbar = () => { const tradingPath = marketId ? `/markets/${marketId}` : '/'; return (