diff --git a/apps/web/.eslintrc.js b/apps/web/.eslintrc.js index c8df607..d6c9537 100644 --- a/apps/web/.eslintrc.js +++ b/apps/web/.eslintrc.js @@ -1,4 +1,18 @@ module.exports = { root: true, - extends: ["custom"], -}; + env: { browser: true, es2020: true }, + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:react-hooks/recommended', + ], + ignorePatterns: ['dist', '.eslintrc.cjs'], + parser: '@typescript-eslint/parser', + plugins: ['react-refresh'], + rules: { + 'react-refresh/only-export-components': [ + 'warn', + { allowConstantExport: true }, + ], + }, +} diff --git a/apps/web/.gitignore b/apps/web/.gitignore new file mode 100644 index 0000000..a547bf3 --- /dev/null +++ b/apps/web/.gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/apps/web/index.html b/apps/web/index.html new file mode 100644 index 0000000..e4b78ea --- /dev/null +++ b/apps/web/index.html @@ -0,0 +1,13 @@ + + + + + + + Vite + React + TS + + +
+ + + diff --git a/apps/web/next-env.d.ts b/apps/web/next-env.d.ts deleted file mode 100644 index 4f11a03..0000000 --- a/apps/web/next-env.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -/// -/// - -// NOTE: This file should not be edited -// see https://nextjs.org/docs/basic-features/typescript for more information. diff --git a/apps/web/next.config.js b/apps/web/next.config.js deleted file mode 100644 index 5e578c4..0000000 --- a/apps/web/next.config.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - reactStrictMode: true, - experimental: { - transpilePackages: ["ui"], - }, -}; diff --git a/apps/web/package.json b/apps/web/package.json index 80b94d5..890f8d3 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -3,16 +3,17 @@ "version": "0.0.0", "private": true, "scripts": { - "dev": "next dev", - "build": "next build", - "start": "next start", - "lint": "next lint" + "dev": "vite", + "build": "tsc && vite build", + "preview": "vite preview", + "lint": "eslint \"src/**/*.ts\"" }, "dependencies": { "@chakra-ui/react": "^2.8.0", "@emotion/react": "^11.11.1", "@emotion/styled": "^11.11.0", "@rainbow-me/rainbowkit": "^1.0.8", + "buffer": "^6.0.3", "ethers": "^5.7.2", "framer-motion": "^10.16.0", "next": "13.0.0", @@ -23,18 +24,17 @@ "wagmi": "^1.3.10" }, "devDependencies": { - "@babel/core": "^7.0.0", - "@types/node": "^17.0.12", - "@types/react": "^18.0.22", - "@types/react-dom": "^18.0.7", - "eslint": "7.32.0", + "@types/react": "^18.2.15", + "@types/react-dom": "^18.2.7", + "@typescript-eslint/eslint-plugin": "^6.0.0", + "@typescript-eslint/parser": "^6.0.0", + "@vitejs/plugin-react": "^4.0.3", + "eslint": "^8.45.0", "eslint-config-custom": "workspace:*", + "eslint-plugin-react-hooks": "^4.6.0", + "eslint-plugin-react-refresh": "^0.4.3", "tsconfig": "workspace:*", - "typescript": "^5.1.6" - }, - "browser": { - "fs": false, - "net": false, - "tls": false + "typescript": "^5.0.2", + "vite": "^4.4.5" } } diff --git a/apps/web/pages/_app.tsx b/apps/web/pages/_app.tsx deleted file mode 100644 index a94679d..0000000 --- a/apps/web/pages/_app.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import "@rainbow-me/rainbowkit/styles.css"; -import { RainbowKitProvider } from "@rainbow-me/rainbowkit"; -import type { AppProps } from "next/app"; -import NextHead from "next/head"; -import * as React from "react"; -import { WagmiConfig } from "wagmi"; -import { chains, wagmiConfig } from "../wagmi"; -import { ChakraProvider, ChakraProviderProps } from "@chakra-ui/react" - -function App({ Component, pageProps }: AppProps) { - const [mounted, setMounted] = React.useState(false); - React.useEffect(() => setMounted(true), []); - return ( - - - - - My App - - - {mounted && } - - - - ); -} - -export default App; diff --git a/apps/web/pages/index.tsx b/apps/web/pages/index.tsx deleted file mode 100644 index eb92951..0000000 --- a/apps/web/pages/index.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import { ConnectButton } from "@rainbow-me/rainbowkit"; -import { useAccount } from "wagmi"; - -import { Account } from "~/components"; - -function Page() { - const { isConnected } = useAccount(); - return ( - <> -

wagmi + RainbowKit + Next.js

- - - {isConnected && } - - ); -} - -export default Page; diff --git a/apps/web/public/vite.svg b/apps/web/public/vite.svg new file mode 100644 index 0000000..e7b8dfb --- /dev/null +++ b/apps/web/public/vite.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/web/src/App.css b/apps/web/src/App.css new file mode 100644 index 0000000..b9d355d --- /dev/null +++ b/apps/web/src/App.css @@ -0,0 +1,42 @@ +#root { + max-width: 1280px; + margin: 0 auto; + padding: 2rem; + text-align: center; +} + +.logo { + height: 6em; + padding: 1.5em; + will-change: filter; + transition: filter 300ms; +} +.logo:hover { + filter: drop-shadow(0 0 2em #646cffaa); +} +.logo.react:hover { + filter: drop-shadow(0 0 2em #61dafbaa); +} + +@keyframes logo-spin { + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } +} + +@media (prefers-reduced-motion: no-preference) { + a:nth-of-type(2) .logo { + animation: logo-spin infinite 20s linear; + } +} + +.card { + padding: 2em; +} + +.read-the-docs { + color: #888; +} diff --git a/apps/web/src/App.tsx b/apps/web/src/App.tsx new file mode 100644 index 0000000..9f95b35 --- /dev/null +++ b/apps/web/src/App.tsx @@ -0,0 +1,38 @@ +import { useState } from 'react' +import reactLogo from './assets/react.svg' +import viteLogo from '/vite.svg' +import './App.css' +import { Button } from '@chakra-ui/react' +import { ConnectButton } from '@rainbow-me/rainbowkit' + +function App() { + const [count, setCount] = useState(0) + + return ( + <> + + +

Vite + React + Turborepo

+
+ +

+ Edit src/App.tsx and save to test HMR +

+
+

+ Click on the Vite and React logos to learn more +

+ + ) +} + +export default App diff --git a/apps/web/src/assets/react.svg b/apps/web/src/assets/react.svg new file mode 100644 index 0000000..6c87de9 --- /dev/null +++ b/apps/web/src/assets/react.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/apps/web/components/Account.tsx b/apps/web/src/components/Account.tsx similarity index 100% rename from apps/web/components/Account.tsx rename to apps/web/src/components/Account.tsx diff --git a/apps/web/components/index.ts b/apps/web/src/components/index.ts similarity index 100% rename from apps/web/components/index.ts rename to apps/web/src/components/index.ts diff --git a/apps/web/src/index.css b/apps/web/src/index.css new file mode 100644 index 0000000..2c3fac6 --- /dev/null +++ b/apps/web/src/index.css @@ -0,0 +1,69 @@ +:root { + font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; + line-height: 1.5; + font-weight: 400; + + color-scheme: light dark; + color: rgba(255, 255, 255, 0.87); + background-color: #242424; + + font-synthesis: none; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + -webkit-text-size-adjust: 100%; +} + +a { + font-weight: 500; + color: #646cff; + text-decoration: inherit; +} +a:hover { + color: #535bf2; +} + +body { + margin: 0; + display: flex; + place-items: center; + min-width: 320px; + min-height: 100vh; +} + +h1 { + font-size: 3.2em; + line-height: 1.1; +} + +button { + border-radius: 8px; + border: 1px solid transparent; + padding: 0.6em 1.2em; + font-size: 1em; + font-weight: 500; + font-family: inherit; + background-color: #1a1a1a; + cursor: pointer; + transition: border-color 0.25s; +} +button:hover { + border-color: #646cff; +} +button:focus, +button:focus-visible { + outline: 4px auto -webkit-focus-ring-color; +} + +@media (prefers-color-scheme: light) { + :root { + color: #213547; + background-color: #ffffff; + } + a:hover { + color: #747bff; + } + button { + background-color: #f9f9f9; + } +} diff --git a/apps/web/src/main.tsx b/apps/web/src/main.tsx new file mode 100644 index 0000000..6a8fdba --- /dev/null +++ b/apps/web/src/main.tsx @@ -0,0 +1,22 @@ +import './polyfills.ts' +import "@rainbow-me/rainbowkit/styles.css"; +import { RainbowKitProvider } from "@rainbow-me/rainbowkit"; +import React from 'react' +import ReactDOM from 'react-dom/client' +import { ChakraProvider } from '@chakra-ui/react' +import { WagmiConfig } from "wagmi"; +import { chains, wagmiConfig } from "../wagmi"; +import App from './App.tsx' +import './index.css' + +ReactDOM.createRoot(document.getElementById('root')!).render( + + + + + + + + + , +) diff --git a/apps/web/src/polyfills.ts b/apps/web/src/polyfills.ts new file mode 100644 index 0000000..a476630 --- /dev/null +++ b/apps/web/src/polyfills.ts @@ -0,0 +1,7 @@ +import { Buffer } from 'buffer'; + +window.global = window.global ?? window; +window.Buffer = window.Buffer ?? Buffer; +window.process = window.process ?? { env: {} }; // Minimal process polyfill + +export {}; \ No newline at end of file diff --git a/apps/web/src/vite-env.d.ts b/apps/web/src/vite-env.d.ts new file mode 100644 index 0000000..11f02fe --- /dev/null +++ b/apps/web/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/apps/web/tsconfig.json b/apps/web/tsconfig.json index 1badd61..a7fc6fb 100644 --- a/apps/web/tsconfig.json +++ b/apps/web/tsconfig.json @@ -1,11 +1,25 @@ { - "extends": "tsconfig/nextjs.json", - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], "compilerOptions": { - "preserveSymlinks": true, - "paths": { - "~/*": ["./*"] - } + "target": "ES2020", + "useDefineForClassFields": true, + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "module": "ESNext", + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx", + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true }, - "exclude": ["node_modules"] + "include": ["src"], + "references": [{ "path": "./tsconfig.node.json" }] } diff --git a/apps/web/tsconfig.node.json b/apps/web/tsconfig.node.json new file mode 100644 index 0000000..42872c5 --- /dev/null +++ b/apps/web/tsconfig.node.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "composite": true, + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true + }, + "include": ["vite.config.ts"] +} diff --git a/apps/web/vite.config.ts b/apps/web/vite.config.ts new file mode 100644 index 0000000..5a33944 --- /dev/null +++ b/apps/web/vite.config.ts @@ -0,0 +1,7 @@ +import { defineConfig } from 'vite' +import react from '@vitejs/plugin-react' + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [react()], +}) diff --git a/apps/web/wagmi.ts b/apps/web/wagmi.ts index 476f4fb..2269e4e 100644 --- a/apps/web/wagmi.ts +++ b/apps/web/wagmi.ts @@ -1,9 +1,8 @@ import '@rainbow-me/rainbowkit/styles.css'; import { getDefaultWallets, - RainbowKitProvider, } from '@rainbow-me/rainbowkit'; -import { configureChains, createConfig, WagmiConfig } from 'wagmi'; +import { configureChains, createConfig } from 'wagmi'; import { mainnet, polygon, @@ -16,9 +15,11 @@ import { publicProvider } from 'wagmi/providers/public'; export const { chains, publicClient } = configureChains( [mainnet, polygon, optimism, arbitrum, zora], - [ + process.env.ALCHEMY_ID ? [ alchemyProvider({ apiKey: process.env.ALCHEMY_ID }), publicProvider() + ] : [ + publicProvider() ] );