69b19e4b7b
* feat: add network-switcher lib * feat: add env variables for some deployed app urls * feat: add network processing to environment hoook * refactor: network handling * refactor: remove dialog from provider and add env setter * feat: add network switcher dialog to the trading app * refactor: add network redirect to dialog connect callback * fix: lint * feat: add network configuration files to static app * feat: update environments to use config file instead of static node url * refactor: split out network switcher utils * refactor: split up environment hook * fix: jsonify env variable for possible networks * fix: add formatter file * feat: add network loader component * feat: add network loader to the trading app * fix: assign correct global state to network swicther * feat: add status modal * feat: add network-switcher lib * feat: add env variables for some deployed app urls * feat: add network processing to environment hoook * refactor: network handling * refactor: remove dialog from provider and add env setter * feat: add network switcher dialog to the trading app * refactor: add network redirect to dialog connect callback * fix: lint * fix: jsonify env variable for possible networks * fix: add formatter file * fix: assign correct global state to network swicther * fix: failing tests from UI changes * feat: add environment validation * feat: add runtime validation for network configs * fix: readd node urls to envs to avoid breaking the apps for now * chore: rename network swicther lib to environmnet * fix: lint * feat: add tests for config hook * feat: add environment hook tests * fix: lint * fix: lint * feat: add environment hook tests * feat: add storage tests * fix: formet * feat: improve loading states * fix: format * fix: use router instead of window location * fix: rearrange network loader props and components * fix: remove FC type * fix: env validation * fix: untangle returns in network loader * fix: add teardown for env and localstorage * fix: add custom to env networks * fix: lint * fix: format * fix: lint * fix: remove env provider from simple trading app * fix: remove failing promise hacks * fix: some leftover format files * fix: remove network switcher from tsconf * fix: move Networks to libs/environment * fix: add defaults for ether env vars * feat: add tests for default ether env vars * fix: remove chain id env var from web3 container * fix: remove chain id from the environment * fix: format * fix: lint token * fix: lint env * fix: add comment to callout hack * fix: lint token again * fix: remove skip * fix: move addresses to token app * fix: improve schema validation errors and fix token app * fix: lint * fix: format * fix: format * fix: add network loaders to apps * fix: format * fix: remove logs * fix: cypress process errors * fix: change network loader hierarchy in token * fix: remove stray console.log * fix: revert test changes in simple trading app * fix: prefix env vars with NX Co-authored-by: Dexter Edwards <dexter.edwards93@gmail.com> * fix: improve schema validation errors and fix token app * fix: format * fix: disable lint rules for catch block any types * fix: format again * fix: remove redundant process.platform injections * fix: format Co-authored-by: Joe <joe@vega.xyz> Co-authored-by: Matthew Russell <mattrussell36@gmail.com> Co-authored-by: Dexter Edwards <dexter.edwards93@gmail.com>
86 lines
3.2 KiB
TypeScript
86 lines
3.2 KiB
TypeScript
import './i18n';
|
|
|
|
import React, { useMemo } from 'react';
|
|
import { BrowserRouter as Router } from 'react-router-dom';
|
|
import { AppLoader } from './app-loader';
|
|
import { AppBanner } from './components/app-banner';
|
|
import { AppFooter } from './components/app-footer';
|
|
import { BalanceManager } from './components/balance-manager';
|
|
import { EthWallet } from './components/eth-wallet';
|
|
import { TemplateSidebar } from './components/page-templates/template-sidebar';
|
|
import { TransactionModal } from './components/transactions-modal';
|
|
import { VegaWallet } from './components/vega-wallet';
|
|
import { Web3Connector } from './components/web3-connector';
|
|
import { AppStateProvider } from './contexts/app-state/app-state-provider';
|
|
import { ContractsProvider } from './contexts/contracts/contracts-provider';
|
|
import { AppRouter } from './routes';
|
|
import { Web3Provider } from '@vegaprotocol/web3';
|
|
import { VegaWalletDialogs } from './components/vega-wallet-dialogs';
|
|
import { VegaWalletProvider } from '@vegaprotocol/wallet';
|
|
import { AsyncRenderer } from '@vegaprotocol/ui-toolkit';
|
|
import { useEthereumConfig } from '@vegaprotocol/web3';
|
|
import {
|
|
useEnvironment,
|
|
EnvironmentProvider,
|
|
NetworkLoader,
|
|
} from '@vegaprotocol/environment';
|
|
import { createClient } from './lib/apollo-client';
|
|
import { createConnectors } from './lib/web3-connectors';
|
|
|
|
const AppContainer = () => {
|
|
const sideBar = React.useMemo(() => [<EthWallet />, <VegaWallet />], []);
|
|
const { config, loading, error } = useEthereumConfig();
|
|
const { ETHEREUM_PROVIDER_URL } = useEnvironment();
|
|
const Connectors = useMemo(() => {
|
|
if (config?.chain_id) {
|
|
return createConnectors(ETHEREUM_PROVIDER_URL, Number(config.chain_id));
|
|
}
|
|
return undefined;
|
|
}, [config?.chain_id, ETHEREUM_PROVIDER_URL]);
|
|
return (
|
|
<Router>
|
|
<AppStateProvider>
|
|
<AsyncRenderer loading={loading} data={config} error={error}>
|
|
{Connectors && (
|
|
<Web3Provider connectors={Connectors}>
|
|
<Web3Connector>
|
|
<VegaWalletProvider>
|
|
<ContractsProvider>
|
|
<AppLoader>
|
|
<BalanceManager>
|
|
<>
|
|
<div className="app dark max-w-[1300px] mx-auto my-0 grid grid-rows-[min-content_1fr_min-content] min-h-full lg:border-l-1 lg:border-r-1 lg:border-white font-sans text-body lg:text-body-large text-white-80">
|
|
<AppBanner />
|
|
<TemplateSidebar sidebar={sideBar}>
|
|
<AppRouter />
|
|
</TemplateSidebar>
|
|
<AppFooter />
|
|
</div>
|
|
<VegaWalletDialogs />
|
|
<TransactionModal />
|
|
</>
|
|
</BalanceManager>
|
|
</AppLoader>
|
|
</ContractsProvider>
|
|
</VegaWalletProvider>
|
|
</Web3Connector>
|
|
</Web3Provider>
|
|
)}
|
|
</AsyncRenderer>
|
|
</AppStateProvider>
|
|
</Router>
|
|
);
|
|
};
|
|
|
|
function App() {
|
|
return (
|
|
<EnvironmentProvider>
|
|
<NetworkLoader createClient={createClient}>
|
|
<AppContainer />
|
|
</NetworkLoader>
|
|
</EnvironmentProvider>
|
|
);
|
|
}
|
|
|
|
export default App;
|