From d7334d258ccec0d97883db486bfdb55272372b41 Mon Sep 17 00:00:00 2001 From: "Shiv Bhonde | shivbhonde.eth" Date: Tue, 12 Mar 2024 04:30:05 +0530 Subject: [PATCH 01/12] add .vercelignore (#768) --- .vercelignore | 66 ++++++++++++++++++++++++++++++++++++++ packages/nextjs/.gitignore | 5 +-- 2 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 .vercelignore diff --git a/.vercelignore b/.vercelignore new file mode 100644 index 000000000..f455f15ee --- /dev/null +++ b/.vercelignore @@ -0,0 +1,66 @@ +# --- Monorepo files --- +.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/sdks +!.yarn/versions +.eslintcache +.DS_Store +.vscode +.idea +.vercel + +# --- Next.js files --- + +# dependencies +packages/nextjs/node_modules +packages/nextjs/.pnp +packages/nextjs/.pnp.js + +# testing +packages/nextjs/coverage + +# next.js +packages/nextjs/.next/ +packages/nextjs/out/ + +# production +packages/nextjs/build + +# misc +packages/nextjs/.DS_Store +packages/nextjs/*.pem + +# debug +packages/nextjs/npm-debug.log* +packages/nextjs/yarn-debug.log* +packages/nextjs/yarn-error.log* +packages/nextjs/.pnpm-debug.log* + +# local env files +packages/nextjs/.env.local +packages/nextjs/.env.development.local +packages/nextjs/.env.test.local +packages/nextjs/.env.production.local + +# typescript +packages/nextjs/*.tsbuildinfo + +# --- Hardhat files --- + +packages/hardhat/node_modules +packages/hardhat/.env +packages/hardhat/coverage +packages/hardhat/coverage.json +packages/hardhat/typechain +packages/hardhat/typechain-types +packages/hardhat/temp + +packages/hardhat/cache +packages/hardhat/artifacts + +packages/hardhat/artifacts-zk +packages/hardhat/cache-zk + +packages/hardhat/deployments diff --git a/packages/nextjs/.gitignore b/packages/nextjs/.gitignore index 6985d5523..cb31783f6 100644 --- a/packages/nextjs/.gitignore +++ b/packages/nextjs/.gitignore @@ -31,8 +31,5 @@ yarn-error.log* .env.test.local .env.production.local -# vercel -.vercel - # typescript -*.tsbuildinfo \ No newline at end of file +*.tsbuildinfo From 2e7dc5afdaca60d363e53b8316ed92db1c7d4668 Mon Sep 17 00:00:00 2001 From: Hunter Chang <716376+ChangoMan@users.noreply.github.com> Date: Tue, 12 Mar 2024 23:03:25 +0800 Subject: [PATCH 02/12] Extract metadata title and description (#770) --- packages/nextjs/app/layout.tsx | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/packages/nextjs/app/layout.tsx b/packages/nextjs/app/layout.tsx index 4e02a1456..8ed8ca41f 100644 --- a/packages/nextjs/app/layout.tsx +++ b/packages/nextjs/app/layout.tsx @@ -9,19 +9,23 @@ const baseUrl = process.env.VERCEL_URL : `http://localhost:${process.env.PORT || 3000}`; const imageUrl = `${baseUrl}/thumbnail.jpg`; +const title = "Scaffold-ETH 2 App"; +const titleTemplate = "%s | Scaffold-ETH 2"; +const description = "Built with 🏗 Scaffold-ETH 2"; + export const metadata: Metadata = { metadataBase: new URL(baseUrl), title: { - default: "Scaffold-ETH 2 App", - template: "%s | Scaffold-ETH 2", + default: title, + template: titleTemplate, }, - description: "Built with 🏗 Scaffold-ETH 2", + description, openGraph: { title: { - default: "Scaffold-ETH 2 App", - template: "%s | Scaffold-ETH 2", + default: title, + template: titleTemplate, }, - description: "Built with 🏗 Scaffold-ETH 2", + description, images: [ { url: imageUrl, @@ -32,10 +36,10 @@ export const metadata: Metadata = { card: "summary_large_image", images: [imageUrl], title: { - default: "Scaffold-ETH 2", - template: "%s | Scaffold-ETH 2", + default: title, + template: titleTemplate, }, - description: "Built with 🏗 Scaffold-ETH 2", + description, }, icons: { icon: [{ url: "/favicon.png", sizes: "32x32", type: "image/png" }], From 9b9fbaacef8c1ce0e7b8e6ce22887d026088c043 Mon Sep 17 00:00:00 2001 From: Jacob Homanics <32080359+Hotmanics@users.noreply.github.com> Date: Tue, 12 Mar 2024 16:29:33 -0500 Subject: [PATCH 03/12] Remove Goerli from supported networks (#771) --- packages/hardhat/deploy/00_deploy_your_contract.ts | 2 +- packages/hardhat/hardhat.config.ts | 8 -------- packages/nextjs/utils/scaffold-eth/networks.ts | 3 --- 3 files changed, 1 insertion(+), 12 deletions(-) diff --git a/packages/hardhat/deploy/00_deploy_your_contract.ts b/packages/hardhat/deploy/00_deploy_your_contract.ts index 1c12ac796..716fec79e 100644 --- a/packages/hardhat/deploy/00_deploy_your_contract.ts +++ b/packages/hardhat/deploy/00_deploy_your_contract.ts @@ -12,7 +12,7 @@ const deployYourContract: DeployFunction = async function (hre: HardhatRuntimeEn /* On localhost, the deployer account is the one that comes with Hardhat, which is already funded. - When deploying to live networks (e.g `yarn deploy --network goerli`), the deployer account + When deploying to live networks (e.g `yarn deploy --network sepolia`), the deployer account should have sufficient balance to pay for the gas fees for contract creation. You can generate a random account with `yarn generate` which will fill DEPLOYER_PRIVATE_KEY diff --git a/packages/hardhat/hardhat.config.ts b/packages/hardhat/hardhat.config.ts index a34332c0a..d165b65b1 100644 --- a/packages/hardhat/hardhat.config.ts +++ b/packages/hardhat/hardhat.config.ts @@ -54,10 +54,6 @@ const config: HardhatUserConfig = { url: `https://eth-sepolia.g.alchemy.com/v2/${providerApiKey}`, accounts: [deployerPrivateKey], }, - goerli: { - url: `https://eth-goerli.alchemyapi.io/v2/${providerApiKey}`, - accounts: [deployerPrivateKey], - }, arbitrum: { url: `https://arb-mainnet.g.alchemy.com/v2/${providerApiKey}`, accounts: [deployerPrivateKey], @@ -102,10 +98,6 @@ const config: HardhatUserConfig = { url: "https://mainnet.base.org", accounts: [deployerPrivateKey], }, - baseGoerli: { - url: "https://goerli.base.org", - accounts: [deployerPrivateKey], - }, baseSepolia: { url: "https://sepolia.base.org", accounts: [deployerPrivateKey], diff --git a/packages/nextjs/utils/scaffold-eth/networks.ts b/packages/nextjs/utils/scaffold-eth/networks.ts index 789898449..074074d3e 100644 --- a/packages/nextjs/utils/scaffold-eth/networks.ts +++ b/packages/nextjs/utils/scaffold-eth/networks.ts @@ -21,9 +21,6 @@ export const NETWORKS_EXTRA_DATA: Record = { [chains.sepolia.id]: { color: ["#5f4bb6", "#87ff65"], }, - [chains.goerli.id]: { - color: "#0975F6", - }, [chains.gnosis.id]: { color: "#48a9a6", }, From 49a6a4e09a8f767e5af2d9547bd98c72c247f273 Mon Sep 17 00:00:00 2001 From: Hunter Chang <716376+ChangoMan@users.noreply.github.com> Date: Wed, 13 Mar 2024 20:35:14 +0800 Subject: [PATCH 04/12] fix: redundant error notifications on block explorer (#775) --- packages/nextjs/app/blockexplorer/page.tsx | 51 +++++++++++++++------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/packages/nextjs/app/blockexplorer/page.tsx b/packages/nextjs/app/blockexplorer/page.tsx index 80f481cac..61e6fc6de 100644 --- a/packages/nextjs/app/blockexplorer/page.tsx +++ b/packages/nextjs/app/blockexplorer/page.tsx @@ -1,6 +1,6 @@ "use client"; -import { useEffect } from "react"; +import { useEffect, useState } from "react"; import { PaginationButton, SearchBar, TransactionsTable } from "./_components"; import type { NextPage } from "next"; import { hardhat } from "viem/chains"; @@ -11,24 +11,23 @@ import { notification } from "~~/utils/scaffold-eth"; const BlockExplorer: NextPage = () => { const { blocks, transactionReceipts, currentPage, totalBlocks, setCurrentPage, error } = useFetchBlocks(); const { targetNetwork } = useTargetNetwork(); + const [isLocalNetwork, setIsLocalNetwork] = useState(true); + const [hasError, setHasError] = useState(false); + + useEffect(() => { + if (targetNetwork.id !== hardhat.id) { + setIsLocalNetwork(false); + } + }, [targetNetwork.id]); useEffect(() => { if (targetNetwork.id === hardhat.id && error) { - notification.error( - <> -

Cannot connect to local provider

-

- - Did you forget to run yarn chain ? -

-

- - Or you can change targetNetwork in{" "} - scaffold.config.ts -

- , - ); + setHasError(true); } + }, [targetNetwork.id, error]); - if (targetNetwork.id !== hardhat.id) { + useEffect(() => { + if (!isLocalNetwork) { notification.error( <>

@@ -48,7 +47,29 @@ const BlockExplorer: NextPage = () => { , ); } - }, [error, targetNetwork]); + }, [ + isLocalNetwork, + targetNetwork.blockExplorers?.default.name, + targetNetwork.blockExplorers?.default.url, + targetNetwork.name, + ]); + + useEffect(() => { + if (hasError) { + notification.error( + <> +

Cannot connect to local provider

+

+ - Did you forget to run yarn chain ? +

+

+ - Or you can change targetNetwork in{" "} + scaffold.config.ts +

+ , + ); + } + }, [hasError]); return (
From 283190e2c6b8321f5628c2708515bdd93c9e5bd6 Mon Sep 17 00:00:00 2001 From: huajin tong <137764712+thirdkeyword@users.noreply.github.com> Date: Thu, 14 Mar 2024 17:28:57 +0800 Subject: [PATCH 05/12] chore: fix typo (#777) --- packages/nextjs/components/scaffold-eth/Input/InputBase.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nextjs/components/scaffold-eth/Input/InputBase.tsx b/packages/nextjs/components/scaffold-eth/Input/InputBase.tsx index f38bca217..cf57692f7 100644 --- a/packages/nextjs/components/scaffold-eth/Input/InputBase.tsx +++ b/packages/nextjs/components/scaffold-eth/Input/InputBase.tsx @@ -35,7 +35,7 @@ export const InputBase = string } | undefined = str [onChange], ); - // Runs only when reFocus prop is passed, usefull for setting the cursor + // Runs only when reFocus prop is passed, useful for setting the cursor // at the end of the input. Example AddressInput const onFocus = (e: FocusEvent) => { if (reFocus !== undefined) { From 892d229a3ec6c4535576573c08ab26e7fce77d15 Mon Sep 17 00:00:00 2001 From: "Shiv Bhonde | shivbhonde.eth" Date: Tue, 19 Mar 2024 11:08:34 +0000 Subject: [PATCH 06/12] fix: vercel deployment linking from github (#780) --- .vercelignore | 66 ------------------------------------ package.json | 8 ++--- packages/nextjs/.gitignore | 1 + packages/nextjs/package.json | 3 +- packages/nextjs/vercel.json | 3 ++ vercel.json | 6 ---- yarn.lock | 3 +- 7 files changed, 10 insertions(+), 80 deletions(-) delete mode 100644 .vercelignore create mode 100644 packages/nextjs/vercel.json delete mode 100644 vercel.json diff --git a/.vercelignore b/.vercelignore deleted file mode 100644 index f455f15ee..000000000 --- a/.vercelignore +++ /dev/null @@ -1,66 +0,0 @@ -# --- Monorepo files --- -.yarn/* -!.yarn/patches -!.yarn/plugins -!.yarn/releases -!.yarn/sdks -!.yarn/versions -.eslintcache -.DS_Store -.vscode -.idea -.vercel - -# --- Next.js files --- - -# dependencies -packages/nextjs/node_modules -packages/nextjs/.pnp -packages/nextjs/.pnp.js - -# testing -packages/nextjs/coverage - -# next.js -packages/nextjs/.next/ -packages/nextjs/out/ - -# production -packages/nextjs/build - -# misc -packages/nextjs/.DS_Store -packages/nextjs/*.pem - -# debug -packages/nextjs/npm-debug.log* -packages/nextjs/yarn-debug.log* -packages/nextjs/yarn-error.log* -packages/nextjs/.pnpm-debug.log* - -# local env files -packages/nextjs/.env.local -packages/nextjs/.env.development.local -packages/nextjs/.env.test.local -packages/nextjs/.env.production.local - -# typescript -packages/nextjs/*.tsbuildinfo - -# --- Hardhat files --- - -packages/hardhat/node_modules -packages/hardhat/.env -packages/hardhat/coverage -packages/hardhat/coverage.json -packages/hardhat/typechain -packages/hardhat/typechain-types -packages/hardhat/temp - -packages/hardhat/cache -packages/hardhat/artifacts - -packages/hardhat/artifacts-zk -packages/hardhat/cache-zk - -packages/hardhat/deployments diff --git a/package.json b/package.json index a4fc79db0..3e026f114 100644 --- a/package.json +++ b/package.json @@ -31,14 +31,12 @@ "next:build": "yarn workspace @se-2/nextjs build", "postinstall": "husky install", "precommit": "lint-staged", - "vercel": "vercel", - "vercel:yolo": "vercel --build-env NEXT_PUBLIC_IGNORE_BUILD_ERROR=true" + "vercel": "yarn workspace @se-2/nextjs vercel", + "vercel:yolo": "yarn workspace @se-2/nextjs vercel:yolo" }, "packageManager": "yarn@3.2.3", "devDependencies": { "husky": "^8.0.1", - "lint-staged": "^13.0.3", - "next": "^14.0.4", - "vercel": "^32.4.1" + "lint-staged": "^13.0.3" } } diff --git a/packages/nextjs/.gitignore b/packages/nextjs/.gitignore index cb31783f6..2e243c7d6 100644 --- a/packages/nextjs/.gitignore +++ b/packages/nextjs/.gitignore @@ -33,3 +33,4 @@ yarn-error.log* # typescript *.tsbuildinfo +.vercel diff --git a/packages/nextjs/package.json b/packages/nextjs/package.json index ff0917991..c77574eef 100644 --- a/packages/nextjs/package.json +++ b/packages/nextjs/package.json @@ -51,6 +51,7 @@ "prettier": "^2.8.4", "tailwindcss": "^3.3.3", "type-fest": "^4.6.0", - "typescript": "^5.1.6" + "typescript": "^5.1.6", + "vercel": "^32.4.1" } } diff --git a/packages/nextjs/vercel.json b/packages/nextjs/vercel.json new file mode 100644 index 000000000..f5e3cac2b --- /dev/null +++ b/packages/nextjs/vercel.json @@ -0,0 +1,3 @@ +{ + "installCommand": "yarn install" +} diff --git a/vercel.json b/vercel.json deleted file mode 100644 index 106ca9cd5..000000000 --- a/vercel.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "installCommand": "yarn install --frozen-lockfile", - "buildCommand": "yarn next:build", - "outputDirectory": "packages/nextjs/.next", - "framework": "nextjs" -} diff --git a/yarn.lock b/yarn.lock index 0b947bfa0..cdd9ea40e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1891,6 +1891,7 @@ __metadata: typescript: ^5.1.6 use-debounce: ^8.0.4 usehooks-ts: ^2.13.0 + vercel: ^32.4.1 viem: 1.19.9 wagmi: 1.4.12 zustand: ^4.1.2 @@ -12273,8 +12274,6 @@ __metadata: dependencies: husky: ^8.0.1 lint-staged: ^13.0.3 - next: ^14.0.4 - vercel: ^32.4.1 languageName: unknown linkType: soft From 601ca8f0555260fbf9b97dc7ad95c0ecfc507d9e Mon Sep 17 00:00:00 2001 From: Jacob Homanics <32080359+Hotmanics@users.noreply.github.com> Date: Wed, 27 Mar 2024 07:43:34 -0500 Subject: [PATCH 07/12] Remove useAccountBalance (#788) --- .../components/scaffold-eth/Balance.tsx | 21 ++++++++--- .../components/scaffold-eth/FaucetButton.tsx | 13 +++++-- packages/nextjs/hooks/scaffold-eth/index.ts | 1 - .../hooks/scaffold-eth/useAccountBalance.ts | 36 ------------------- 4 files changed, 27 insertions(+), 44 deletions(-) delete mode 100644 packages/nextjs/hooks/scaffold-eth/useAccountBalance.ts diff --git a/packages/nextjs/components/scaffold-eth/Balance.tsx b/packages/nextjs/components/scaffold-eth/Balance.tsx index 7811f5fd1..d778cb44f 100644 --- a/packages/nextjs/components/scaffold-eth/Balance.tsx +++ b/packages/nextjs/components/scaffold-eth/Balance.tsx @@ -2,8 +2,9 @@ import { useState } from "react"; import { Address } from "viem"; -import { useAccountBalance } from "~~/hooks/scaffold-eth"; +import { useBalance } from "wagmi"; import { useTargetNetwork } from "~~/hooks/scaffold-eth/useTargetNetwork"; +import { useGlobalState } from "~~/services/store/store"; type BalanceProps = { address?: Address; @@ -16,7 +17,17 @@ type BalanceProps = { */ export const Balance = ({ address, className = "", usdMode }: BalanceProps) => { const { targetNetwork } = useTargetNetwork(); - const { balance, price, isError, isLoading } = useAccountBalance(address); + + const price = useGlobalState(state => state.nativeCurrencyPrice); + const { + data: balance, + isError, + isLoading, + } = useBalance({ + address, + watch: true, + }); + const [displayUsdMode, setDisplayUsdMode] = useState(price > 0 ? Boolean(usdMode) : false); const toggleBalanceMode = () => { @@ -44,6 +55,8 @@ export const Balance = ({ address, className = "", usdMode }: BalanceProps) => { ); } + const formattedBalance = balance ? Number(balance.formatted) : 0; + return (