Skip to content

Commit

Permalink
Merge pull request #756 from scaffold-eth/main-backmerge
Browse files Browse the repository at this point in the history
  • Loading branch information
technophile-04 committed Mar 11, 2024
2 parents 62553fd + ea5e355 commit a9e8e9e
Show file tree
Hide file tree
Showing 20 changed files with 137 additions and 29 deletions.
12 changes: 12 additions & 0 deletions .changeset/wicked-bugs-doubt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"create-eth": patch
---

- Yarn flatten (#745)
- Fix local next build (#749)
- Fix emit event value in contract (#765, 833d09b)
- Fix useScaffoldContractWrite so it properly throws errors (#758)
- Fix vercel deployment mismatch (#757)
- Remove extra notifications when using useTransactor (#766)
- Ignore JetBrains IDE settings file (#732)
- Fix hardhat lint errors (ac1d2ac)
5 changes: 4 additions & 1 deletion templates/base/.gitignore.template.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const contents = () =>
!.yarn/versions
.eslintcache
.vscode/**
.DS_Store`
.DS_Store
.vscode
.idea
.vercel`;

export default contents
58 changes: 58 additions & 0 deletions templates/base/.vercelignore.template.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { withDefaults } from "../utils.js";

const contents = ({ packageVercelIgnoreContent }) =>
`# --- 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
${packageVercelIgnoreContent.join("\n")}`;

export default withDefaults(contents, {
packageVercelIgnoreContent: "",
});
9 changes: 6 additions & 3 deletions templates/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,19 @@
"next:lint": "yarn workspace @se-2/nextjs lint",
"next:format": "yarn workspace @se-2/nextjs format",
"next:check-types": "yarn workspace @se-2/nextjs check-types",
"next:build": "yarn workspace @se-2/nextjs build",
"format": "yarn next:format",
"postinstall": "husky install",
"precommit": "lint-staged",
"vercel": "yarn workspace @se-2/nextjs vercel",
"vercel:yolo": "yarn workspace @se-2/nextjs vercel:yolo"
"vercel": "vercel",
"vercel:yolo": "vercel --build-env NEXT_PUBLIC_IGNORE_BUILD_ERROR=true"
},
"packageManager": "yarn@3.2.3",
"devDependencies": {
"husky": "~8.0.3",
"lint-staged": "~13.2.2"
"lint-staged": "~13.2.2",
"next": "~14.0.4",
"vercel": "~32.4.1"
},
"resolutions": {
"usehooks-ts@^2.7.2": "patch:usehooks-ts@npm:^2.7.2#./.yarn/patches/usehooks-ts-npm-2.7.2-fceffe0e43.patch"
Expand Down
3 changes: 0 additions & 3 deletions templates/base/packages/nextjs/.gitignore.template.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ yarn-error.log*
.env.test.local
.env.production.local
# vercel
.vercel
# typescript
*.tsbuildinfo`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
import { IntegerInput } from "~~/components/scaffold-eth";
import { useTransactor } from "~~/hooks/scaffold-eth";
import { useTargetNetwork } from "~~/hooks/scaffold-eth/useTargetNetwork";
import { getParsedError, notification } from "~~/utils/scaffold-eth";

type WriteOnlyFunctionFormProps = {
abi: Abi;
Expand Down Expand Up @@ -58,8 +57,7 @@ export const WriteOnlyFunctionForm = ({
await writeTxn(makeWriteWithParams);
onChange();
} catch (e: any) {
const message = getParsedError(e);
notification.error(message);
console.error("⚡️ ~ file: WriteOnlyFunctionForm.tsx:handleWrite ~ error", e);
}
}
};
Expand Down
6 changes: 3 additions & 3 deletions templates/base/packages/nextjs/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { ScaffoldEthAppWithProviders } from "~~/components/ScaffoldEthAppWithPro
import { ThemeProvider } from "~~/components/ThemeProvider";
import "~~/styles/globals.css";

const baseUrl = process.env.NEXT_PUBLIC_VERCEL_URL
? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`
: `http://localhost:${process.env.PORT}`;
const baseUrl = process.env.VERCEL_URL
? `https://${process.env.VERCEL_URL}`
: `http://localhost:${process.env.PORT || 3000}`;
const imageUrl = `${baseUrl}/thumbnail.jpg`;

export const metadata: Metadata = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useNetwork } from "wagmi";
import { BanknotesIcon } from "@heroicons/react/24/outline";
import { Address, AddressInput, Balance, EtherInput } from "~~/components/scaffold-eth";
import { useTransactor } from "~~/hooks/scaffold-eth";
import { getParsedError, notification } from "~~/utils/scaffold-eth";
import { notification } from "~~/utils/scaffold-eth";

// Account index to use from generated hardhat accounts.
const FAUCET_ACCOUNT_INDEX = 0;
Expand Down Expand Up @@ -70,9 +70,7 @@ export const Faucet = () => {
setInputAddress(undefined);
setSendValue("");
} catch (error) {
const parsedError = getParsedError(error);
console.error("⚡️ ~ file: Faucet.tsx:sendETH ~ error", error);
notification.error(parsedError);
setLoading(false);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useTargetNetwork } from "./useTargetNetwork";
import { Abi, ExtractAbiFunctionNames } from "abitype";
import { useContractWrite, useNetwork } from "wagmi";
import { useDeployedContractInfo, useTransactor } from "~~/hooks/scaffold-eth";
import { getParsedError, notification } from "~~/utils/scaffold-eth";
import { notification } from "~~/utils/scaffold-eth";
import { ContractAbi, ContractName, UseScaffoldWriteConfig } from "~~/utils/scaffold-eth/contract";

type UpdatedArgs = Parameters<ReturnType<typeof useContractWrite<Abi, string, undefined>>["writeAsync"]>[0];
Expand Down Expand Up @@ -83,8 +83,7 @@ export const useScaffoldContractWrite = <

return writeTxResult;
} catch (e: any) {
const message = getParsedError(e);
notification.error(message);
throw e;
} finally {
setIsMining(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export const useTransactor = (_walletClient?: WalletClient): TransactionFunc =>
console.error("⚡️ ~ file: useTransactor.ts ~ error", error);
const message = getParsedError(error);
notification.error(message);
throw error;
}

return transactionHash;
Expand Down
3 changes: 1 addition & 2 deletions templates/base/packages/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"prettier": "~2.8.4",
"tailwindcss": "~3.3.3",
"type-fest": "~4.6.0",
"typescript": "~5.1.6",
"vercel": "~32.4.1"
"typescript": "~5.1.6"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ export const getMetadata = ({
description: string;
imageRelativePath?: string;
}): Metadata => {
const baseUrl = process.env.NEXT_PUBLIC_VERCEL_URL
? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`
: `http://localhost:${process.env.PORT}`;
const baseUrl = process.env.VERCEL_URL
? `https://${process.env.VERCEL_URL}`
: `http://localhost:${process.env.PORT || 3000}`;
const imageUrl = `${baseUrl}${imageRelativePath}`;
return {
title: title,
Expand Down
6 changes: 6 additions & 0 deletions templates/base/vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"installCommand": "yarn install --frozen-lockfile",
"buildCommand": "yarn next:build",
"outputDirectory": "packages/nextjs/.next",
"framework": "nextjs"
}
15 changes: 15 additions & 0 deletions templates/extensions/foundry/.vercelignore.args.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export const packageVercelIgnoreContent = `# --- Foundry files ---
# Compiler files
packages/foundry/cache
packages/foundry/out
# Ignores development broadcast logs
packages/foundry/broadcast
# Docs
packages/foundry/docs
# Dotenv file
packages/foundry/.env
packages/foundry/localhost.json`;
2 changes: 1 addition & 1 deletion templates/extensions/foundry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"test": "yarn foundry:test",
"verify": "yarn workspace @se-2/foundry verify",
"generate": "yarn workspace @se-2/foundry generate",
"flatten": "yarn workspace @se-1/foundry flatten",
"flatten": "yarn workspace @se-2/foundry flatten",
"format": "yarn next:format && yarn foundry:format"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ contract YourContract {
}

// emit: keyword used to trigger an event
emit GreetingChange(msg.sender, _newGreeting, msg.value > 0, 0);
emit GreetingChange(msg.sender, _newGreeting, msg.value > 0, msg.value);
}

/**
Expand Down
17 changes: 17 additions & 0 deletions templates/extensions/hardhat/.vercelignore.args.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export const packageVercelIgnoreContent = `# --- 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`;
1 change: 1 addition & 0 deletions templates/extensions/hardhat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"hardhat:format": "yarn workspace @se-2/hardhat format",
"hardhat:test": "yarn workspace @se-2/hardhat test",
"test": "yarn hardhat:test",
"flatten": "yarn workspace @se-2/hardhat flatten",
"format": "yarn next:format && yarn hardhat:format"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ contract YourContract {
}

// emit: keyword used to trigger an event
emit GreetingChange(msg.sender, _newGreeting, msg.value > 0, 0);
emit GreetingChange(msg.sender, _newGreeting, msg.value > 0, msg.value);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions templates/extensions/hardhat/packages/hardhat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"deploy": "hardhat deploy",
"fork": "MAINNET_FORKING_ENABLED=true hardhat node --network hardhat --no-deploy",
"generate": "hardhat run scripts/generateAccount.ts",
"flatten": "hardhat flatten",
"lint": "eslint --config ./.eslintrc.json --ignore-path ./.eslintignore ./*.ts ./deploy/**/*.ts ./scripts/**/*.ts ./test/**/*.ts",
"lint-staged": "eslint --config ./.eslintrc.json --ignore-path ./.eslintignore",
"format": "prettier --write ./*.ts ./deploy/**/*.ts ./scripts/**/*.ts ./test/**/*.ts",
Expand All @@ -28,8 +29,8 @@
"@types/mocha": "~9.1.1",
"@types/prettier": "~2",
"@types/qrcode": "~1",
"@typescript-eslint/eslint-plugin": "latest",
"@typescript-eslint/parser": "latest",
"@typescript-eslint/eslint-plugin": "~6.7.3",
"@typescript-eslint/parser": "~6.7.3",
"chai": "~4.3.6",
"eslint": "~8.26.0",
"eslint-config-prettier": "~8.5.0",
Expand Down

0 comments on commit a9e8e9e

Please sign in to comment.