2022-03-30 09:49:48 +00:00
|
|
|
import type { AppProps } from 'next/app';
|
2022-02-11 13:56:28 +00:00
|
|
|
import Head from 'next/head';
|
2022-02-17 05:08:17 +00:00
|
|
|
import { Navbar } from '../components/navbar';
|
2022-03-31 17:16:30 +00:00
|
|
|
import { t, ThemeContext, useThemeSwitcher } from '@vegaprotocol/react-helpers';
|
|
|
|
import {
|
|
|
|
VegaConnectDialog,
|
|
|
|
VegaManageDialog,
|
|
|
|
VegaWalletProvider,
|
|
|
|
} from '@vegaprotocol/wallet';
|
2022-06-01 00:30:02 +00:00
|
|
|
import { EnvironmentProvider } from '@vegaprotocol/react-helpers';
|
2022-03-25 07:44:10 +00:00
|
|
|
import { Connectors } from '../lib/vega-connectors';
|
2022-06-01 14:21:36 +00:00
|
|
|
import { useMemo } from 'react';
|
2022-02-28 23:43:36 +00:00
|
|
|
import { createClient } from '../lib/apollo-client';
|
2022-03-09 13:05:42 +00:00
|
|
|
import { ThemeSwitcher } from '@vegaprotocol/ui-toolkit';
|
2022-02-24 00:04:58 +00:00
|
|
|
import { ApolloProvider } from '@apollo/client';
|
2022-03-11 00:28:48 +00:00
|
|
|
import { AppLoader } from '../components/app-loader';
|
2022-03-31 17:16:30 +00:00
|
|
|
import { VegaWalletConnectButton } from '../components/vega-wallet-connect-button';
|
2022-03-14 13:18:11 +00:00
|
|
|
import './styles.css';
|
2022-06-01 14:21:36 +00:00
|
|
|
import { useGlobalStore } from '../stores';
|
2022-03-14 13:18:11 +00:00
|
|
|
|
2022-02-17 05:03:46 +00:00
|
|
|
function VegaTradingApp({ Component, pageProps }: AppProps) {
|
2022-03-25 07:44:10 +00:00
|
|
|
const client = useMemo(() => createClient(process.env['NX_VEGA_URL']), []);
|
2022-06-01 14:21:36 +00:00
|
|
|
const store = useGlobalStore();
|
2022-03-14 13:18:11 +00:00
|
|
|
const [theme, toggleTheme] = useThemeSwitcher();
|
2022-02-24 00:04:58 +00:00
|
|
|
|
2022-02-11 13:56:28 +00:00
|
|
|
return (
|
2022-06-01 00:30:02 +00:00
|
|
|
<EnvironmentProvider>
|
|
|
|
<ThemeContext.Provider value={theme}>
|
|
|
|
<ApolloProvider client={client}>
|
|
|
|
<VegaWalletProvider>
|
|
|
|
<AppLoader>
|
|
|
|
<Head>
|
|
|
|
<link
|
|
|
|
rel="preload"
|
|
|
|
href="https://static.vega.xyz/AlphaLyrae-Medium.woff2"
|
|
|
|
as="font"
|
|
|
|
type="font/woff2"
|
|
|
|
crossOrigin="anonymous"
|
|
|
|
/>
|
|
|
|
<title>{t('Welcome to Vega trading!')}</title>
|
|
|
|
<link
|
|
|
|
rel="icon"
|
|
|
|
type="image/x-icon"
|
|
|
|
href="https://static.vega.xyz/favicon.ico"
|
|
|
|
/>
|
|
|
|
<link
|
|
|
|
rel="stylesheet"
|
|
|
|
href="https://static.vega.xyz/fonts.css"
|
|
|
|
/>
|
|
|
|
</Head>
|
|
|
|
<div className="h-full dark:bg-black dark:text-white-60 bg-white relative z-0 text-black-60 grid grid-rows-[min-content,1fr]">
|
|
|
|
<div className="flex items-stretch border-b-[7px] border-vega-yellow">
|
|
|
|
<Navbar />
|
|
|
|
<div className="flex items-center gap-4 ml-auto mr-8">
|
|
|
|
<VegaWalletConnectButton
|
2022-06-01 14:21:36 +00:00
|
|
|
setConnectDialog={(open) => {
|
|
|
|
store.setVegaWalletConnectDialog(open);
|
|
|
|
}}
|
|
|
|
setManageDialog={(open) => {
|
|
|
|
store.setVegaWalletManageDialog(open);
|
|
|
|
}}
|
2022-06-01 00:30:02 +00:00
|
|
|
/>
|
|
|
|
<ThemeSwitcher onToggle={toggleTheme} className="-my-4" />
|
|
|
|
</div>
|
2022-03-14 13:18:11 +00:00
|
|
|
</div>
|
2022-06-01 00:30:02 +00:00
|
|
|
<main data-testid={pageProps.page}>
|
|
|
|
{/* @ts-ignore conflict between @types/react and nextjs internal types */}
|
|
|
|
<Component {...pageProps} />
|
|
|
|
</main>
|
|
|
|
<VegaConnectDialog
|
|
|
|
connectors={Connectors}
|
2022-06-01 14:21:36 +00:00
|
|
|
dialogOpen={store.vegaWalletConnectDialog}
|
2022-06-01 00:30:02 +00:00
|
|
|
setDialogOpen={(open) =>
|
2022-06-01 14:21:36 +00:00
|
|
|
store.setVegaWalletConnectDialog(open)
|
2022-06-01 00:30:02 +00:00
|
|
|
}
|
|
|
|
/>
|
|
|
|
<VegaManageDialog
|
2022-06-01 14:21:36 +00:00
|
|
|
dialogOpen={store.vegaWalletManageDialog}
|
2022-06-01 00:30:02 +00:00
|
|
|
setDialogOpen={(open) =>
|
2022-06-01 14:21:36 +00:00
|
|
|
store.setVegaWalletManageDialog(open)
|
2022-06-01 00:30:02 +00:00
|
|
|
}
|
|
|
|
/>
|
2022-03-11 00:28:48 +00:00
|
|
|
</div>
|
2022-06-01 00:30:02 +00:00
|
|
|
</AppLoader>
|
|
|
|
</VegaWalletProvider>
|
|
|
|
</ApolloProvider>
|
|
|
|
</ThemeContext.Provider>
|
|
|
|
</EnvironmentProvider>
|
2022-02-11 13:56:28 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-02-17 05:03:46 +00:00
|
|
|
export default VegaTradingApp;
|