mars-v2-frontend/pages/_app.tsx

60 lines
1.5 KiB
TypeScript
Raw Normal View History

2022-09-02 11:26:03 +00:00
import type { AppProps } from "next/app";
import Head from "next/head";
import { ToastContainer, Zoom } from "react-toastify";
import "react-toastify/dist/ReactToastify.min.css";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import detectEthereumProvider from "@metamask/detect-provider";
2022-09-02 11:26:03 +00:00
import "../styles/globals.css";
2022-09-02 14:30:58 +00:00
import Layout from "components/Layout";
import { useEffect } from "react";
import useWalletStore from "stores/useWalletStore";
async function isMetamaskInstalled(): Promise<boolean> {
const provider = await detectEthereumProvider();
return !!provider;
}
const queryClient = new QueryClient();
2022-09-02 11:17:39 +00:00
function MyApp({ Component, pageProps }: AppProps) {
const actions = useWalletStore((state) => state.actions);
// init store
useEffect(() => {
const verifyMetamask = async () => {
actions.setMetamaskInstalledStatus(await isMetamaskInstalled());
};
console.log("HERE");
verifyMetamask();
}, [actions]);
2022-09-02 11:26:03 +00:00
return (
<>
<Head>
<title>Mars V2</title>
{/* <meta name="description" content="Generated by create next app" /> */}
2022-09-03 13:21:43 +00:00
<link rel="icon" href="/favicon.svg" />
2022-09-02 11:26:03 +00:00
</Head>
<QueryClientProvider client={queryClient}>
<Layout>
<Component {...pageProps} />
</Layout>
<ToastContainer
autoClose={1500}
closeButton={false}
position="bottom-right"
hideProgressBar
newestOnTop
transition={Zoom}
/>
</QueryClientProvider>
2022-09-02 11:26:03 +00:00
</>
);
2022-09-02 11:17:39 +00:00
}
2022-09-02 11:26:03 +00:00
export default MyApp;