2021-11-25 09:28:45 +00:00
|
|
|
import React, { Suspense } from "react";
|
2022-10-25 21:54:28 +00:00
|
|
|
import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
|
2021-07-24 08:46:48 +00:00
|
|
|
import WarningHeader from "./WarningHeader";
|
2021-07-01 18:21:40 +00:00
|
|
|
import Home from "./Home";
|
2021-11-25 09:28:45 +00:00
|
|
|
import Main from "./Main";
|
2021-07-12 20:10:16 +00:00
|
|
|
import ConnectionErrorPanel from "./ConnectionErrorPanel";
|
2021-07-10 06:17:07 +00:00
|
|
|
import Footer from "./Footer";
|
2021-07-12 20:10:16 +00:00
|
|
|
import { ConnectionStatus } from "./types";
|
2021-07-09 05:07:20 +00:00
|
|
|
import { RuntimeContext, useRuntime } from "./useRuntime";
|
2022-03-28 17:10:42 +00:00
|
|
|
import { ChainInfoContext, useChainInfoFromMetadataFile } from "./useChainInfo";
|
2021-07-01 18:21:40 +00:00
|
|
|
|
2022-08-05 21:54:30 +00:00
|
|
|
const Block = React.lazy(() => import("./Block"));
|
|
|
|
const BlockTransactions = React.lazy(() => import("./BlockTransactions"));
|
|
|
|
const Address = React.lazy(() => import("./Address"));
|
|
|
|
const Transaction = React.lazy(() => import("./Transaction"));
|
|
|
|
const London = React.lazy(() => import("./special/london/London"));
|
|
|
|
const Faucets = React.lazy(() => import("./Faucets"));
|
|
|
|
const PageNotFound = React.lazy(() => import("./PageNotFound"));
|
2021-07-01 18:21:40 +00:00
|
|
|
|
2021-07-08 19:02:42 +00:00
|
|
|
const App = () => {
|
2021-07-09 05:07:20 +00:00
|
|
|
const runtime = useRuntime();
|
2022-03-28 17:10:42 +00:00
|
|
|
const chainInfo = useChainInfoFromMetadataFile(runtime);
|
2021-07-08 19:02:42 +00:00
|
|
|
|
|
|
|
return (
|
2021-10-24 04:12:05 +00:00
|
|
|
<Suspense fallback={null}>
|
2022-03-28 17:10:42 +00:00
|
|
|
{runtime.connStatus !== ConnectionStatus.CONNECTED ||
|
|
|
|
chainInfo === undefined ? (
|
2021-07-12 20:10:16 +00:00
|
|
|
<ConnectionErrorPanel
|
|
|
|
connStatus={runtime.connStatus}
|
|
|
|
config={runtime.config}
|
|
|
|
/>
|
|
|
|
) : (
|
|
|
|
<RuntimeContext.Provider value={runtime}>
|
2022-03-28 17:10:42 +00:00
|
|
|
<ChainInfoContext.Provider value={chainInfo}>
|
2022-03-26 00:38:12 +00:00
|
|
|
<div className="h-screen flex flex-col">
|
|
|
|
<WarningHeader />
|
|
|
|
<Router>
|
|
|
|
<Routes>
|
|
|
|
<Route index element={<Home />} />
|
|
|
|
<Route path="/special/london" element={<London />} />
|
|
|
|
<Route path="*" element={<Main />}>
|
|
|
|
<Route
|
|
|
|
path="block/:blockNumberOrHash"
|
|
|
|
element={<Block />}
|
|
|
|
/>
|
|
|
|
<Route
|
|
|
|
path="block/:blockNumber/txs"
|
|
|
|
element={<BlockTransactions />}
|
|
|
|
/>
|
|
|
|
<Route path="tx/:txhash/*" element={<Transaction />} />
|
|
|
|
<Route
|
|
|
|
path="address/:addressOrName/*"
|
|
|
|
element={<Address />}
|
|
|
|
/>
|
2022-04-06 01:38:27 +00:00
|
|
|
<Route path="faucets/*" element={<Faucets />} />
|
2022-03-26 00:38:12 +00:00
|
|
|
<Route path="*" element={<PageNotFound />} />
|
|
|
|
</Route>
|
|
|
|
</Routes>
|
|
|
|
</Router>
|
|
|
|
<Footer />
|
|
|
|
</div>
|
|
|
|
</ChainInfoContext.Provider>
|
2021-07-12 20:10:16 +00:00
|
|
|
</RuntimeContext.Provider>
|
|
|
|
)}
|
2021-07-08 19:02:42 +00:00
|
|
|
</Suspense>
|
|
|
|
);
|
|
|
|
};
|
2021-07-01 18:21:40 +00:00
|
|
|
|
2021-11-25 09:28:45 +00:00
|
|
|
export default App;
|