Display warning header when not on mainnet
This commit is contained in:
parent
26f66cb4fb
commit
fddfbfc29b
@ -1,5 +1,6 @@
|
|||||||
import React, { Suspense } from "react";
|
import React, { Suspense } from "react";
|
||||||
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
|
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
|
||||||
|
import WarningHeader from "./WarningHeader";
|
||||||
import Home from "./Home";
|
import Home from "./Home";
|
||||||
import Search from "./Search";
|
import Search from "./Search";
|
||||||
import Title from "./Title";
|
import Title from "./Title";
|
||||||
@ -26,6 +27,7 @@ const App = () => {
|
|||||||
) : (
|
) : (
|
||||||
<RuntimeContext.Provider value={runtime}>
|
<RuntimeContext.Provider value={runtime}>
|
||||||
<div className="h-screen flex flex-col">
|
<div className="h-screen flex flex-col">
|
||||||
|
<WarningHeader />
|
||||||
<Router>
|
<Router>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path="/" exact>
|
<Route path="/" exact>
|
||||||
|
28
src/WarningHeader.tsx
Normal file
28
src/WarningHeader.tsx
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import React, { useContext } from "react";
|
||||||
|
import { RuntimeContext } from "./useRuntime";
|
||||||
|
|
||||||
|
const WarningHeader: React.FC = () => {
|
||||||
|
const { provider } = useContext(RuntimeContext);
|
||||||
|
const chainId = provider?.network.chainId;
|
||||||
|
if (chainId === 1) {
|
||||||
|
return <></>;
|
||||||
|
}
|
||||||
|
|
||||||
|
let chainMsg = `ChainID: ${chainId}`;
|
||||||
|
if (chainId === 3) {
|
||||||
|
chainMsg = "Ropsten Testnet";
|
||||||
|
} else if (chainId === 4) {
|
||||||
|
chainMsg = "Rinkeby Testnet";
|
||||||
|
} else if (chainId === 5) {
|
||||||
|
chainMsg = "Görli Testnet";
|
||||||
|
} else if (chainId === 42) {
|
||||||
|
chainMsg = "Kovan Testnet";
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div className="w-full bg-orange-400 text-white text-center font-bold px-2 py-1">
|
||||||
|
You are on {chainMsg}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default React.memo(WarningHeader);
|
Loading…
Reference in New Issue
Block a user