Skip to content

Commit

Permalink
feat: move to nextjs
Browse files Browse the repository at this point in the history
  • Loading branch information
apoorvlathey committed May 6, 2024
1 parent 602ae43 commit 032785a
Show file tree
Hide file tree
Showing 49 changed files with 9,929 additions and 8,487 deletions.
10 changes: 5 additions & 5 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
REACT_APP_INFURA_KEY=
REACT_APP_WC_PROJECT_ID=
REACT_APP_GITCOIN_GRANTS_ACTIVE=
REACT_APP_GITCOIN_GRANTS_LINK=
REACT_APP_DONATION_ADDRESS=
NEXT_PUBLIC_INFURA_KEY=
NEXT_PUBLIC_WC_PROJECT_ID=
NEXT_PUBLIC_GITCOIN_GRANTS_ACTIVE=
NEXT_PUBLIC_GITCOIN_GRANTS_LINK=
NEXT_PUBLIC_DONATION_ADDRESS=
21 changes: 15 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
.env
.vercel

# dependencies
/node_modules
Expand All @@ -10,17 +8,28 @@
# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18.16.1
v18.17.0
File renamed without changes
17 changes: 17 additions & 0 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { IndexLayout as IndexLayoutC } from "@/components/layouts/IndexLayout";
import { getMetadata } from "@/utils";

export const metadata = getMetadata({
title: "Impersonator",
description:
"Impersonate any Ethereum Account and Login into DApps via WalletConnect, iframe or Extension!",
images: "https://www.impersonator.xyz/metaIMG.PNG",
});

export default function IndexLayout({
children,
}: {
children: React.ReactNode;
}) {
return <IndexLayoutC>{children}</IndexLayoutC>;
}
15 changes: 15 additions & 0 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Body from "@/components/Body";
import Navbar from "@/components/Navbar";
import Footer from "@/components/Footer";

const Home = () => {
return (
<div>
<Navbar />
<Body />
<Footer />
</div>
);
};

export default Home;
44 changes: 23 additions & 21 deletions src/index.tsx → app/providers.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"use client";

import "@rainbow-me/rainbowkit/styles.css";

import ReactDOM from "react-dom";
import App from "./App";
import { CacheProvider } from "@chakra-ui/next-js";
import { ChakraProvider } from "@chakra-ui/react";
import {
connectorsForWallets,
Expand All @@ -17,16 +18,16 @@ import { configureChains, createConfig, WagmiConfig } from "wagmi";
import { mainnet, optimism, base, arbitrum } from "wagmi/chains";
import { publicProvider } from "wagmi/providers/public";

import theme from "./theme";
import { SafeInjectProvider } from "./contexts/SafeInjectContext";
import theme from "@/style/theme";
import { SafeInjectProvider } from "@/contexts/SafeInjectContext";

const { chains, publicClient } = configureChains(
// the first chain is used by rainbowWallet to determine which chain to use
[mainnet, optimism, base, arbitrum],
[publicProvider()]
);

const projectId = process.env.REACT_APP_WC_PROJECT_ID!;
const projectId = process.env.NEXT_PUBLIC_WC_PROJECT_ID!;
const connectors = connectorsForWallets([
{
groupName: "Recommended",
Expand All @@ -44,19 +45,20 @@ export const wagmiConfig = createConfig({
publicClient,
});

ReactDOM.render(
<ChakraProvider theme={theme}>
<WagmiConfig config={wagmiConfig}>
<RainbowKitProvider
chains={chains}
theme={darkTheme()}
modalSize={"compact"}
>
<SafeInjectProvider>
<App />
</SafeInjectProvider>
</RainbowKitProvider>
</WagmiConfig>
</ChakraProvider>,
document.getElementById("root")
);
export const Providers = ({ children }: { children: React.ReactNode }) => {
return (
<CacheProvider>
<ChakraProvider theme={theme}>
<WagmiConfig config={wagmiConfig}>
<RainbowKitProvider
chains={chains}
theme={darkTheme()}
modalSize={"compact"}
>
<SafeInjectProvider>{children}</SafeInjectProvider>
</RainbowKitProvider>
</WagmiConfig>
</ChakraProvider>
</CacheProvider>
);
};
26 changes: 26 additions & 0 deletions components/Analytics.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Script from "next/script";

const GA_ID = "G-QFNMM9LXBY";

export const Analytics = () => {
return (
<>
<Script
strategy="afterInteractive"
src={`https://www.googletagmanager.com/gtag/js?id=${GA_ID}`}
/>
<Script
id="google-analytics"
strategy="afterInteractive"
dangerouslySetInnerHTML={{
__html: `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${GA_ID}');
`,
}}
/>
</>
);
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 5 additions & 12 deletions src/components/Body/index.tsx → components/Body/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
"use client";

import { useState, useEffect } from "react";
import {
Container,
useColorMode,
useToast,
Center,
Spacer,
Flex,
} from "@chakra-ui/react";
import { Container, useToast, Center, Spacer, Flex } from "@chakra-ui/react";

import { SingleValue } from "chakra-react-select";
// WC v2
Expand Down Expand Up @@ -37,7 +32,7 @@ const WCMetadata = {
};

const core = new Core({
projectId: process.env.REACT_APP_WC_PROJECT_ID,
projectId: process.env.NEXT_PUBLIC_WC_PROJECT_ID,
});

const primaryNetworkIds = [
Expand Down Expand Up @@ -70,8 +65,6 @@ const allNetworksOptions = [
];

function Body() {
const { colorMode } = useColorMode();
const bgColor = { light: "white", dark: "gray.700" };
const addressFromURL = new URLSearchParams(window.location.search).get(
"address"
);
Expand Down Expand Up @@ -143,7 +136,7 @@ function Body() {

setProvider(
new ethers.providers.JsonRpcProvider(
`https://mainnet.infura.io/v3/${process.env.REACT_APP_INFURA_KEY}`
`https://mainnet.infura.io/v3/${process.env.NEXT_PUBLIC_INFURA_KEY}`
)
);

Expand Down
File renamed without changes.
14 changes: 6 additions & 8 deletions src/components/Footer.tsx → components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use client";

import { useState } from "react";
import {
useColorMode,
Flex,
VStack,
Heading,
Expand Down Expand Up @@ -46,9 +47,6 @@ const Social = ({ icon, link }: { icon: IconProp; link: string }) => {
};

function Footer() {
const { colorMode } = useColorMode();
const underlineColor = { light: "gray.500", dark: "gray.400" };

const { isConnected } = useAccount();
const { chain } = useNetwork();

Expand All @@ -64,7 +62,7 @@ function Footer() {
const handleDonate = async (value: string) => {
try {
await sendTransaction({
to: process.env.REACT_APP_DONATION_ADDRESS!,
to: process.env.NEXT_PUBLIC_DONATION_ADDRESS!,
value: parseEther(value),
});
launchConfetti();
Expand All @@ -79,7 +77,7 @@ function Footer() {
};

return (
<Flex py="4" borderTop="2px" borderTopColor={underlineColor[colorMode]}>
<Flex py="4" borderTop="2px" borderTopColor={"gray.400"}>
<Spacer flex="1" />
{showConfetti && (
<Box zIndex={9999} position={"fixed"} top={0} left={0}>
Expand All @@ -102,11 +100,11 @@ function Footer() {
<Stack direction={{ base: "column", md: "row" }}>
<Center>Found the project helpful?</Center>
<HStack>
{process.env.REACT_APP_GITCOIN_GRANTS_ACTIVE === "true" ? (
{process.env.NEXT_PUBLIC_GITCOIN_GRANTS_ACTIVE === "true" ? (
<>
<Text>Support it on</Text>
<Link
href={process.env.REACT_APP_GITCOIN_GRANTS_LINK}
href={process.env.NEXT_PUBLIC_GITCOIN_GRANTS_LINK}
isExternal
>
<HStack fontWeight="bold" textDecor="underline">
Expand Down
7 changes: 1 addition & 6 deletions src/components/Navbar.tsx → components/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
Button,
useColorMode,
Flex,
Heading,
Spacer,
Expand All @@ -10,20 +9,16 @@ import {
Text,
Image,
} from "@chakra-ui/react";
import { SunIcon, MoonIcon } from "@chakra-ui/icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faGithub } from "@fortawesome/free-brands-svg-icons";

function Navbar() {
const { colorMode } = useColorMode();
const underlineColor = { light: "gray.500", dark: "gray.400" };

return (
<Flex
py="4"
px={["2", "4", "10", "10"]}
borderBottom="2px"
borderBottomColor={underlineColor[colorMode]}
borderBottomColor={"gray.400"}
>
<Spacer flex="1" />
<Heading
Expand Down
30 changes: 30 additions & 0 deletions components/layouts/IndexLayout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Providers } from "@/app/providers";
import { Analytics } from "@/components/Analytics";

export const IndexLayout = ({ children }: { children: React.ReactNode }) => {
return (
<html lang="en">
{/* Farcaster Frame */}
<head>
<meta property="fc:frame" content="vNext" />
<meta
property="fc:frame:image"
content="https://frame.impersonator.xyz/impersonator.gif"
/>
<meta
property="fc:frame:post_url"
content="https://frame.impersonator.xyz/api/frame"
/>
<meta
property="fc:frame:input:text"
content="Type ENS or Address to impersonate..."
/>
<meta property="fc:frame:button:1" content="🕵️ Start" />
</head>
<body>
<Analytics />
<Providers>{children}</Providers>
</body>
</html>
);
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const nextConfig = {
reactStrictMode: true,
webpack: (config) => {
config.resolve.fallback = { fs: false, net: false, tls: false };
config.externals.push("pino-pretty");
return config;
},
compiler: {
styledComponents: true,
},
experimental: {
windowHistorySupport: true,
},
};

module.exports = nextConfig;
Loading

0 comments on commit 032785a

Please sign in to comment.