Skip to content

Commit

Permalink
migreate to wagmiV1 and viem and daisy v3
Browse files Browse the repository at this point in the history
  • Loading branch information
technophile-04 committed Sep 28, 2023
1 parent 8b20603 commit f23ba1a
Show file tree
Hide file tree
Showing 86 changed files with 3,640 additions and 2,342 deletions.
13 changes: 13 additions & 0 deletions .yarn/patches/usehooks-ts-npm-2.7.2-fceffe0e43.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/dist/esm/useLocalStorage/useLocalStorage.js b/dist/esm/useLocalStorage/useLocalStorage.js
index b0d584d4df29953551dfcf8febac002f89fa7acd..920ae5c52d28af73e3a892bdb935a7805a0f8224 100644
--- a/dist/esm/useLocalStorage/useLocalStorage.js
+++ b/dist/esm/useLocalStorage/useLocalStorage.js
@@ -14,7 +14,7 @@ function useLocalStorage(key, initialValue) {
return initialValue;
}
}, [initialValue, key]);
- const [storedValue, setStoredValue] = useState(readValue);
+ const [storedValue, setStoredValue] = useState(initialValue);
const setValue = useEventCallback(value => {
if (typeof window === 'undefined') {
console.warn(`Tried setting localStorage key “${key}” even though environment is not a client`);
Empty file modified .yarn/releases/yarn-3.2.3.cjs
100644 → 100755
Empty file.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"hardhat:lint": "yarn workspace @se-2/hardhat lint",
"hardhat:lint-staged": "yarn workspace @se-2/hardhat lint-staged",
"hardhat:test": "yarn workspace @se-2/hardhat test",
"test": "yarn hardhat:test",
"start": "yarn workspace @se-2/nextjs dev",
"next:lint": "yarn workspace @se-2/nextjs lint",
"next:format": "yarn workspace @se-2/nextjs format",
Expand All @@ -32,5 +33,8 @@
"devDependencies": {
"husky": "^8.0.1",
"lint-staged": "^13.0.3"
},
"resolutions": {
"usehooks-ts@^2.7.2": "patch:usehooks-ts@npm:^2.7.2#./.yarn/patches/usehooks-ts-npm-2.7.2-fceffe0e43.patch"
}
}
85 changes: 85 additions & 0 deletions packages/hardhat/deploy/99_generateTsAbis.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/**
* DON'T MODIFY OR DELETE THIS SCRIPT (unless you know what you're doing)
*
* This script generates the file containing the contracts Abi definitions.
* These definitions are used to derive the types needed in the custom scaffold-eth hooks, for example.
* This script should run as the last deploy script.
* */

import * as fs from "fs";
import prettier from "prettier";
import { DeployFunction } from "hardhat-deploy/types";

function getDirectories(path: string) {
return fs
.readdirSync(path, { withFileTypes: true })
.filter(dirent => dirent.isDirectory())
.map(dirent => dirent.name);
}

function getContractNames(path: string) {
return fs
.readdirSync(path, { withFileTypes: true })
.filter(dirent => dirent.isFile() && dirent.name.endsWith(".json"))
.map(dirent => dirent.name.split(".")[0]);
}

const DEPLOYMENTS_DIR = "./deployments";

function getContractDataFromDeployments() {
if (!fs.existsSync(DEPLOYMENTS_DIR)) {
throw Error("At least one other deployment script should exist to generate an actual contract.");
}
const output = {} as Record<string, any>;
for (const chainName of getDirectories(DEPLOYMENTS_DIR)) {
const chainId = fs.readFileSync(`${DEPLOYMENTS_DIR}/${chainName}/.chainId`).toString();
const contracts = {} as Record<string, any>;
for (const contractName of getContractNames(`${DEPLOYMENTS_DIR}/${chainName}`)) {
const { abi, address } = JSON.parse(
fs.readFileSync(`${DEPLOYMENTS_DIR}/${chainName}/${contractName}.json`).toString(),
);
contracts[contractName] = { address, abi };
}
output[chainId] = [
{
chainId,
name: chainName,
contracts,
},
];
}
return output;
}

/**
* Generates the TypeScript contract definition file based on the json output of the contract deployment scripts
* This script should be run last.
*/
const generateTsAbis: DeployFunction = async function () {
const TARGET_DIR = "../nextjs/generated/";
const allContractsData = getContractDataFromDeployments();

const fileContent = Object.entries(allContractsData).reduce((content, [chainId, chainConfig]) => {
return `${content}${parseInt(chainId).toFixed(0)}:${JSON.stringify(chainConfig, null, 2)},`;
}, "");

if (!fs.existsSync(TARGET_DIR)) {
fs.mkdirSync(TARGET_DIR);
}
fs.writeFileSync(
`${TARGET_DIR}deployedContracts.ts`,
prettier.format(`const contracts = {${fileContent}} as const; \n\n export default contracts`, {
parser: "typescript",
}),
);

console.log(`📝 Updated TypeScript contract definition file on ${TARGET_DIR}deployedContracts.ts`);
};

export default generateTsAbis;

// Tags are useful if you have multiple deploy files and only want to run one of them.
// e.g. yarn deploy --tags generateTsAbis
generateTsAbis.tags = ["generateTsAbis"];

generateTsAbis.runAtTheEnd = true;
55 changes: 45 additions & 10 deletions packages/hardhat/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ dotenv.config();
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import "hardhat-deploy";
import "@matterlabs/hardhat-zksync-solc";
import "@matterlabs/hardhat-zksync-verify";

// If not set, it uses ours Alchemy's default API key.
// You can get your own at https://dashboard.alchemyapi.io
Expand All @@ -15,17 +17,14 @@ const etherscanApiKey = process.env.ETHERSCAN_API_KEY || "DNXJA8RX2Q3VZ4URQIWP7Z

const config: HardhatUserConfig = {
solidity: {
compilers: [
{
version: "0.8.17",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
version: "0.8.17",
settings: {
optimizer: {
enabled: true,
// https://docs.soliditylang.org/en/latest/using-the-compiler.html#optimizer-options
runs: 200,
},
],
},
},
defaultNetwork: "localhost",
namedAccounts: {
Expand Down Expand Up @@ -79,6 +78,42 @@ const config: HardhatUserConfig = {
url: `https://polygon-mumbai.g.alchemy.com/v2/${providerApiKey}`,
accounts: [deployerPrivateKey],
},
polygonZkEvm: {
url: `https://polygonzkevm-mainnet.g.alchemy.com/v2/${providerApiKey}`,
accounts: [deployerPrivateKey],
},
polygonZkEvmTestnet: {
url: `https://polygonzkevm-testnet.g.alchemy.com/v2/${providerApiKey}`,
accounts: [deployerPrivateKey],
},
zkSyncTestnet: {
url: "https://testnet.era.zksync.dev",
zksync: true,
accounts: [deployerPrivateKey],
verifyURL: "https://zksync2-testnet-explorer.zksync.dev/contract_verification",
},
zkSync: {
url: "https://mainnet.era.zksync.io",
zksync: true,
accounts: [deployerPrivateKey],
verifyURL: "https://zksync2-mainnet-explorer.zksync.io/contract_verification",
},
gnosis: {
url: "https://rpc.gnosischain.com",
accounts: [deployerPrivateKey],
},
chiado: {
url: "https://rpc.chiadochain.net",
accounts: [deployerPrivateKey],
},
base: {
url: "https://mainnet.base.org",
accounts: [deployerPrivateKey],
},
baseGoerli: {
url: "https://goerli.base.org",
accounts: [deployerPrivateKey],
},
},
verify: {
etherscan: {
Expand Down
10 changes: 6 additions & 4 deletions packages/hardhat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"account": "hardhat run scripts/listAccount.ts",
"chain": "hardhat node --network hardhat --no-deploy",
"compile": "hardhat compile",
"deploy": "hardhat deploy --export-all ./temp/hardhat_contracts.json \"$@\" && hardhat run scripts/generateTsAbis.ts",
"deploy": "hardhat deploy",
"fork": "MAINNET_FORKING_ENABLED=true hardhat node --network hardhat --no-deploy",
"generate": "hardhat run scripts/generateAccount.ts",
"lint": "eslint --config ./.eslintrc.json --ignore-path ./.eslintignore ./*.ts ./deploy/**/*.ts ./scripts/**/*.ts ./test/**/*.ts",
Expand All @@ -16,6 +16,8 @@
"devDependencies": {
"@ethersproject/abi": "^5.7.0",
"@ethersproject/providers": "^5.7.1",
"@matterlabs/hardhat-zksync-solc": "^0.3.17",
"@matterlabs/hardhat-zksync-verify": "^0.1.8",
"@nomicfoundation/hardhat-chai-matchers": "^1.0.3",
"@nomicfoundation/hardhat-network-helpers": "^1.0.6",
"@nomicfoundation/hardhat-toolbox": "^2.0.0",
Expand All @@ -34,14 +36,14 @@
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"ethers": "^5.7.1",
"hardhat": "^2.11.2",
"hardhat-deploy": "^0.11.25",
"hardhat": "^2.17.3",
"hardhat-deploy": "^0.11.26",
"hardhat-gas-reporter": "^1.0.9",
"prettier": "^2.8.4",
"solidity-coverage": "^0.8.2",
"ts-node": "^10.9.1",
"typechain": "^8.1.0",
"typescript": "^4.9.5"
"typescript": "^5.1.6"
},
"dependencies": {
"@openzeppelin/contracts": "^4.8.1",
Expand Down
32 changes: 0 additions & 32 deletions packages/hardhat/scripts/generateTsAbis.ts

This file was deleted.

38 changes: 20 additions & 18 deletions packages/nextjs/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ import { CurrencyDollarIcon } from "@heroicons/react/24/outline";
import { HeartIcon } from "@heroicons/react/24/outline";
import { SwitchTheme } from "~~/components/SwitchTheme";
import { Faucet } from "~~/components/scaffold-eth";
import { useAppStore } from "~~/services/store/store";
import { useGlobalState } from "~~/services/store/store";
import { getTargetNetwork } from "~~/utils/scaffold-eth";

/**
* Site footer
*/
export const Footer = () => {
const ethPrice = useAppStore(state => state.ethPrice);
const nativeCurrencyPrice = useGlobalState(state => state.nativeCurrencyPrice);

return (
<div className="min-h-0 p-5 mb-11 lg:mb-0">
<div className="min-h-0 py-5 px-1 mb-11 lg:mb-0">
<div>
<div className="fixed flex justify-between items-center w-full z-20 p-4 bottom-0 left-0 pointer-events-none">
<div className="fixed flex justify-between items-center w-full z-10 p-4 bottom-0 left-0 pointer-events-none">
<div className="flex space-x-2 pointer-events-auto">
{ethPrice > 0 && (
<div className="btn btn-primary btn-sm font-normal cursor-auto">
{nativeCurrencyPrice > 0 && (
<div className="btn btn-primary btn-sm font-normal cursor-auto gap-0">
<CurrencyDollarIcon className="h-4 w-4 mr-0.5" />
<span>{ethPrice}</span>
<span>{nativeCurrencyPrice}</span>
</div>
)}
{getTargetNetwork().id === hardhat.id && <Faucet />}
Expand All @@ -31,7 +31,7 @@ export const Footer = () => {
<div className="w-full">
<ul className="menu menu-horizontal w-full">
<div className="flex justify-center items-center gap-2 text-sm w-full">
<div>
<div className="text-center">
<a
href="https://github.com/scaffold-eth/se-2"
target="_blank"
Expand All @@ -43,18 +43,20 @@ export const Footer = () => {
</div>
<span>·</span>
<div>
Built with <HeartIcon className="inline-block h-4 w-4" /> at 🏰{" "}
<a
href="https://buidlguidl.com/"
target="_blank"
rel="noreferrer"
className="underline underline-offset-2"
>
BuidlGuidl
</a>
<p className="m-0 text-center">
Built with <HeartIcon className="inline-block h-4 w-4" /> at 🏰{" "}
<a
href="https://buidlguidl.com/"
target="_blank"
rel="noreferrer"
className="underline underline-offset-2"
>
BuidlGuidl
</a>
</p>
</div>
<span>·</span>
<div>
<div className="text-center">
<a
href="https://t.me/joinchat/KByvmRe5wkR-8F_zz6AjpA"
target="_blank"
Expand Down
Loading

0 comments on commit f23ba1a

Please sign in to comment.