Skip to content

Commit

Permalink
fix mrege conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
technophile-04 committed Mar 21, 2024
2 parents 6c5dbed + 892d229 commit 6c8bf8d
Show file tree
Hide file tree
Showing 15 changed files with 66 additions and 53 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ node_modules
!.yarn/sdks
!.yarn/versions
.eslintcache
.vscode/**
.DS_Store
.vscode
.idea
.vercel
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"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",
"postinstall": "husky install",
"precommit": "lint-staged",
"vercel": "yarn workspace @se-2/nextjs vercel",
Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat/contracts/YourContract.sol
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
2 changes: 1 addition & 1 deletion packages/hardhat/deploy/00_deploy_your_contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions packages/hardhat/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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],
Expand Down
6 changes: 2 additions & 4 deletions packages/nextjs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ yarn-error.log*
.env.test.local
.env.production.local

# vercel
.vercel

# typescript
*.tsbuildinfo
*.tsbuildinfo
.vercel
51 changes: 36 additions & 15 deletions packages/nextjs/app/blockexplorer/page.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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(
<>
<p className="font-bold mt-0 mb-1">Cannot connect to local provider</p>
<p className="m-0">
- Did you forget to run <code className="italic bg-base-300 text-base font-bold">yarn chain</code> ?
</p>
<p className="mt-1 break-normal">
- Or you can change <code className="italic bg-base-300 text-base font-bold">targetNetwork</code> in{" "}
<code className="italic bg-base-300 text-base font-bold">scaffold.config.ts</code>
</p>
</>,
);
setHasError(true);
}
}, [targetNetwork.id, error]);

if (targetNetwork.id !== hardhat.id) {
useEffect(() => {
if (!isLocalNetwork) {
notification.error(
<>
<p className="font-bold mt-0 mb-1">
Expand All @@ -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(
<>
<p className="font-bold mt-0 mb-1">Cannot connect to local provider</p>
<p className="m-0">
- Did you forget to run <code className="italic bg-base-300 text-base font-bold">yarn chain</code> ?
</p>
<p className="mt-1 break-normal">
- Or you can change <code className="italic bg-base-300 text-base font-bold">targetNetwork</code> in{" "}
<code className="italic bg-base-300 text-base font-bold">scaffold.config.ts</code>
</p>
</>,
);
}
}, [hasError]);

return (
<div className="container mx-auto my-10">
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 @@ -59,8 +58,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
22 changes: 13 additions & 9 deletions packages/nextjs/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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" }],
Expand Down
4 changes: 1 addition & 3 deletions packages/nextjs/components/scaffold-eth/Faucet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useAccount } 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 @@ -35,7 +35,7 @@ export const InputBase = <T extends { toString: () => 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<HTMLInputElement, Element>) => {
if (reFocus !== undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Config, UseWriteContractParameters, useAccount, useWriteContract } from
import { WriteContractErrorType, WriteContractReturnType } from "wagmi/actions";
import { WriteContractVariables } from "wagmi/query";
import { useDeployedContractInfo, useTransactor } from "~~/hooks/scaffold-eth";
import { getParsedError, notification } from "~~/utils/scaffold-eth";
import { notification } from "~~/utils/scaffold-eth";
import {
ContractAbi,
ContractName,
Expand Down Expand Up @@ -78,13 +78,11 @@ export const useScaffoldWriteContract = <TContractName extends ContractName>(

return writeTxResult;
} catch (e: any) {
const message = getParsedError(e);
notification.error(message);
throw e;
} finally {
setIsMining(false);
}
};

return {
...wagmiContractWrite,
isMining,
Expand Down
1 change: 1 addition & 0 deletions packages/nextjs/hooks/scaffold-eth/useTransactor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,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: 0 additions & 3 deletions packages/nextjs/utils/scaffold-eth/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ export const NETWORKS_EXTRA_DATA: Record<string, ChainAttributes> = {
[chains.sepolia.id]: {
color: ["#5f4bb6", "#87ff65"],
},
[chains.goerli.id]: {
color: "#0975F6",
},
[chains.gnosis.id]: {
color: "#48a9a6",
},
Expand Down
3 changes: 3 additions & 0 deletions packages/nextjs/vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"installCommand": "yarn install"
}

0 comments on commit 6c8bf8d

Please sign in to comment.