Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CLI with latest main #555

Merged
merged 23 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
02dd022
Fix RainbowKitCustomConnectButton dropdown styles (#500)
rin-st Aug 23, 2023
2e15c39
chore: footer missalignment & home page on small screens (#502)
technophile-04 Aug 24, 2023
3f7bd28
Update and typescript version (#499)
technophile-04 Aug 28, 2023
0b371df
fix: header links wrapping icons and text (#510)
technophile-04 Aug 29, 2023
82d6dca
Fix typos in useScaffoldContractWrite logs (#512)
ZakGriffith Aug 31, 2023
c11a01c
fix: spelling in test file name (#522)
rin-st Sep 6, 2023
30383ba
Add polygonZkEvm and polygonZkEvmTestnet (#309)
OwlWilderness Sep 13, 2023
e3b4bd2
fix: eth price showing 0 on sepolia network (#532)
technophile-04 Sep 15, 2023
ebfb874
use websockets client in useFetchBlocks hooks (#529)
portdeveloper Sep 21, 2023
44c5d50
Move from react-blockies to blo (#538)
bpierre Sep 22, 2023
41b1671
add Prettify type helper locally (#541)
technophile-04 Sep 25, 2023
8f7dc31
update hardhat version (#546)
technophile-04 Sep 27, 2023
c464451
Add indexed args to events (#540)
rin-st Sep 29, 2023
6664883
add out of box compatibility with SAFE{Wallet} (#346)
technophile-04 Sep 30, 2023
fc7914c
remove `parseEther` from useScaffoldContractWrite (#548)
technophile-04 Oct 3, 2023
d8448a6
Add Scroll Sepolia testnet (#547)
isabellewei Oct 3, 2023
b33a87d
use BuidlGuidl logo on footer (#551)
FilipHarald Oct 3, 2023
4348718
Fix conflicts
carletex Oct 3, 2023
55f64ce
add types to even data in useScaffoldEventHistory (#553)
technophile-04 Oct 3, 2023
21d15c9
Merge remote-tracking branch 'origin/main' into cli-backmerge
technophile-04 Oct 3, 2023
a92b2e2
@types packages with ^
carletex Oct 4, 2023
4f6fcb5
mention chainId 31337 in foundry fork script
technophile-04 Oct 5, 2023
f1d867c
add changeset
technophile-04 Oct 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions templates/base/packages/nextjs/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { hardhat } from "wagmi/chains";
import { CurrencyDollarIcon } from "@heroicons/react/24/outline";
import { HeartIcon } from "@heroicons/react/24/outline";
import { SwitchTheme } from "~~/components/SwitchTheme";
import { BuidlGuidlLogo } from "~~/components/assets/BuidlGuidlLogo";
import { Faucet } from "~~/components/scaffold-eth";
import { useGlobalState } from "~~/services/store/store";
import { getTargetNetwork } from "~~/utils/scaffold-eth";
Expand Down Expand Up @@ -42,18 +43,19 @@ export const Footer = () => {
</a>
</div>
<span>·</span>
<div>
<div className="flex justify-center items-center gap-2">
<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>
Built with <HeartIcon className="inline-block h-4 w-4" /> at
</p>
<a
className="flex justify-center items-center gap-1"
href="https://buidlguidl.com/"
target="_blank"
rel="noreferrer"
>
<BuidlGuidlLogo className="w-3 h-5 pb-1" />
<span className="underline underline-offset-2">BuidlGuidl</span>
</a>
</div>
<span>·</span>
<div className="text-center">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export const BuidlGuidlLogo = ({ className }: { className: string }) => {
return (
<svg
className={className}
width="53"
height="72"
viewBox="0 0 53 72"
fill="currentColor"
xmlns="http://www.w3.org/2000/svg"
>
<path
fillRule="evenodd"
d="M25.9 17.434v15.638h3.927v9.04h9.718v-9.04h6.745v18.08l-10.607 19.88-12.11-.182-12.11.183L.856 51.152v-18.08h6.713v9.04h9.75v-9.04h4.329V2.46a2.126 2.126 0 0 1 4.047-.914c1.074.412 2.157 1.5 3.276 2.626 1.33 1.337 2.711 2.726 4.193 3.095 1.496.373 2.605-.026 3.855-.475 1.31-.47 2.776-.997 5.005-.747 1.67.197 2.557 1.289 3.548 2.509 1.317 1.623 2.82 3.473 6.599 3.752l-.024.017c-2.42 1.709-5.726 4.043-10.86 3.587-1.605-.139-2.736-.656-3.82-1.153-1.546-.707-2.997-1.37-5.59-.832-2.809.563-4.227 1.892-5.306 2.903-.236.221-.456.427-.67.606Z"
clipRule="evenodd"
/>
</svg>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Address } from "~~/components/scaffold-eth";
import { TransactionWithFunction, getTargetNetwork } from "~~/utils/scaffold-eth";
import { TransactionsTableProps } from "~~/utils/scaffold-eth/";

export const TransactionsTable = ({ blocks, transactionReceipts, isLoading }: TransactionsTableProps) => {
export const TransactionsTable = ({ blocks, transactionReceipts }: TransactionsTableProps) => {
const targetNetwork = getTargetNetwork();

return (
Expand All @@ -22,64 +22,47 @@ export const TransactionsTable = ({ blocks, transactionReceipts, isLoading }: Tr
<th className="bg-primary text-end">Value ({targetNetwork.nativeCurrency.symbol})</th>
</tr>
</thead>
{isLoading ? (
<tbody>
{[...Array(20)].map((_, rowIndex) => (
<tr
key={rowIndex}
className="bg-base-200 hover:bg-base-300 transition-colors duration-200 h-12 text-sm"
>
{[...Array(7)].map((_, colIndex) => (
<td className="w-1/12 md:py-4" key={colIndex}>
<div className="h-2 bg-gray-200 rounded-full animate-pulse"></div>
</td>
))}
</tr>
))}
</tbody>
) : (
<tbody>
{blocks.map(block =>
(block.transactions as TransactionWithFunction[]).map(tx => {
const receipt = transactionReceipts[tx.hash];
const timeMined = new Date(Number(block.timestamp) * 1000).toLocaleString();
const functionCalled = tx.input.substring(0, 10);
<tbody>
{blocks.map(block =>
(block.transactions as TransactionWithFunction[]).map(tx => {
const receipt = transactionReceipts[tx.hash];
const timeMined = new Date(Number(block.timestamp) * 1000).toLocaleString();
const functionCalled = tx.input.substring(0, 10);

return (
<tr key={tx.hash} className="hover text-sm">
<td className="w-1/12 md:py-4">
<TransactionHash hash={tx.hash} />
</td>
<td className="w-2/12 md:py-4">
{tx.functionName === "0x" ? "" : <span className="mr-1">{tx.functionName}</span>}
{functionCalled !== "0x" && (
<span className="badge badge-primary font-bold text-xs">{functionCalled}</span>
)}
</td>
<td className="w-1/12 md:py-4">{block.number?.toString()}</td>
<td className="w-2/1 md:py-4">{timeMined}</td>
<td className="w-2/12 md:py-4">
<Address address={tx.from} size="sm" />
</td>
<td className="w-2/12 md:py-4">
{!receipt?.contractAddress ? (
tx.to && <Address address={tx.to} size="sm" />
) : (
<div className="relative">
<Address address={receipt.contractAddress} size="sm" />
<small className="absolute top-4 left-4">(Contract Creation)</small>
</div>
)}
</td>
<td className="text-right md:py-4">
{formatEther(tx.value)} {targetNetwork.nativeCurrency.symbol}
</td>
</tr>
);
}),
)}
</tbody>
)}
return (
<tr key={tx.hash} className="hover text-sm">
<td className="w-1/12 md:py-4">
<TransactionHash hash={tx.hash} />
</td>
<td className="w-2/12 md:py-4">
{tx.functionName === "0x" ? "" : <span className="mr-1">{tx.functionName}</span>}
{functionCalled !== "0x" && (
<span className="badge badge-primary font-bold text-xs">{functionCalled}</span>
)}
</td>
<td className="w-1/12 md:py-4">{block.number?.toString()}</td>
<td className="w-2/1 md:py-4">{timeMined}</td>
<td className="w-2/12 md:py-4">
<Address address={tx.from} size="sm" />
</td>
<td className="w-2/12 md:py-4">
{!receipt?.contractAddress ? (
tx.to && <Address address={tx.to} size="sm" />
) : (
<div className="relative">
<Address address={receipt.contractAddress} size="sm" />
<small className="absolute top-4 left-4">(Contract Creation)</small>
</div>
)}
</td>
<td className="text-right md:py-4">
{formatEther(tx.value)} {targetNetwork.nativeCurrency.symbol}
</td>
</tr>
);
}),
)}
</tbody>
</table>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useState } from "react";
import { CopyIcon } from "./assets/CopyIcon";
import { DiamondIcon } from "./assets/DiamondIcon";
import { HareIcon } from "./assets/HareIcon";
import { parseEther } from "viem";
import { ArrowSmallRightIcon, XMarkIcon } from "@heroicons/react/24/outline";
import { useScaffoldContractWrite } from "~~/hooks/scaffold-eth";

Expand All @@ -13,7 +14,7 @@ export const ContractInteraction = () => {
contractName: "YourContract",
functionName: "setGreeting",
args: [newGreeting],
value: "0.01",
value: parseEther("0.01"),
onBlockConfirmation: txnReceipt => {
console.log("📦 Transaction blockHash", txnReceipt.blockHash);
},
Expand Down
25 changes: 6 additions & 19 deletions templates/base/packages/nextjs/components/scaffold-eth/Address.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useEffect, useState } from "react";
import Link from "next/link";
import Blockies from "react-blockies";
import { CopyToClipboard } from "react-copy-to-clipboard";
import { isAddress } from "viem";
import { useEnsAvatar, useEnsName } from "wagmi";
import { hardhat } from "wagmi/chains";
import { CheckCircleIcon, DocumentDuplicateIcon } from "@heroicons/react/24/outline";
import { BlockieAvatar } from "~~/components/scaffold-eth";
import { getBlockExplorerAddressLink, getTargetNetwork } from "~~/utils/scaffold-eth";

type TAddressProps = {
Expand Down Expand Up @@ -78,24 +78,11 @@ export const Address = ({ address, disableAddressLink, format, size = "base" }:
return (
<div className="flex items-center">
<div className="flex-shrink-0">
{ensAvatar ? (
// Don't want to use nextJS Image here (and adding remote patterns for the URL)
// eslint-disable-next-line
<img
className="rounded-full"
src={ensAvatar}
width={(blockieSizeMap[size] * 24) / blockieSizeMap["base"]}
height={(blockieSizeMap[size] * 24) / blockieSizeMap["base"]}
alt={`${address} avatar`}
/>
) : (
<Blockies
className="mx-auto rounded-full"
size={blockieSizeMap[size]}
seed={address.toLowerCase()}
scale={3}
/>
)}
<BlockieAvatar
address={address}
ensImage={ensAvatar}
size={(blockieSizeMap[size] * 24) / blockieSizeMap["base"]}
/>
</div>
{disableAddressLink ? (
<span className={`ml-1.5 text-${size} font-normal`}>{displayAddress}</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { AvatarComponent } from "@rainbow-me/rainbowkit";
import Blockies from "react-blockies";
import { blo } from "blo";

// Custom Avatar for RainbowKit
export const BlockieAvatar: AvatarComponent = ({ address, ensImage, size }) =>
ensImage ? (
// Don't want to use nextJS Image here (and adding remote patterns for the URL)
// eslint-disable-next-line
<img className="rounded-full" src={ensImage} width={size} height={size} alt={`${address} avatar`} />
) : (
<Blockies className="rounded-full" seed={address?.toLowerCase() as string} scale={size > 30 ? 10 : 3.75} />
);
export const BlockieAvatar: AvatarComponent = ({ address, ensImage, size }) => (
// Don't want to use nextJS Image here (and adding remote patterns for the URL)
// eslint-disable-next-line @next/next/no-img-element
<img
className="rounded-full"
src={ensImage || blo(address as `0x${string}`)}
width={size}
height={size}
alt={`${address} avatar`}
/>
);
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useReducer } from "react";
import { ContractReadMethods } from "./ContractReadMethods";
import { ContractVariables } from "./ContractVariables";
import { ContractWriteMethods } from "./ContractWriteMethods";
import { Spinner } from "~~/components/Spinner";
import { Spinner } from "~~/components/assets/Spinner";
import { Address, Balance } from "~~/components/scaffold-eth";
import { useDeployedContractInfo, useNetworkColor } from "~~/hooks/scaffold-eth";
import { getTargetNetwork } from "~~/utils/scaffold-eth";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useCallback, useEffect, useState } from "react";
import Blockies from "react-blockies";
import { blo } from "blo";
import { isAddress } from "viem";
import { Address } from "viem";
import { useEnsAddress, useEnsAvatar, useEnsName } from "wagmi";
Expand Down Expand Up @@ -74,7 +74,11 @@ export const AddressInput = ({ value, name, placeholder, onChange, disabled }: C
</div>
)
}
suffix={value && <Blockies className="!rounded-full" seed={value?.toLowerCase() as string} size={7} scale={5} />}
suffix={
// Don't want to use nextJS Image here (and adding remote patterns for the URL)
// eslint-disable-next-line @next/next/no-img-element
value && <img alt="" className="!rounded-full" src={blo(value as `0x${string}`)} width="35" height="35" />
}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const RainbowKitCustomConnectButton = () => {
tabIndex={0}
className="btn btn-secondary btn-sm pl-0 pr-2 shadow-md dropdown-toggle gap-0 !h-auto"
>
<BlockieAvatar address={account.address} size={24} ensImage={account.ensAvatar} />
<BlockieAvatar address={account.address} size={30} ensImage={account.ensAvatar} />
<span className="ml-2 mr-1">{account.displayName}</span>
<ChevronDownIcon className="h-6 w-4 ml-2 sm:ml-0" />
</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import { getTargetNetwork } from "~~/utils/scaffold-eth";
const SCAFFOLD_WALLET_STROAGE_KEY = "scaffoldEth2.wallet";
const WAGMI_WALLET_STORAGE_KEY = "wagmi.wallet";

// ID of the SAFE connector instance
const SAFE_ID = "safe";

/**
* This function will get the initial wallet connector (if any), the app will connect to
* @param previousWalletId
Expand All @@ -19,8 +22,14 @@ const getInitialConnector = (
previousWalletId: string,
connectors: Connector[],
): { connector: Connector | undefined; chainId?: number } | undefined => {
const targetNetwork = getTargetNetwork();
// Look for the SAFE connector instance and connect to it instantly if loaded in SAFE frame
const safeConnectorInstance = connectors.find(connector => connector.id === SAFE_ID && connector.ready);

if (safeConnectorInstance) {
return { connector: safeConnectorInstance };
}

const targetNetwork = getTargetNetwork();
const allowBurner = scaffoldConfig.onlyLocalBurnerWallet ? targetNetwork.id === hardhat.id : true;

if (!previousWalletId) {
Expand Down
Loading