Skip to content

Commit 6c28866

Browse files
Merge pull request #211 from scaffold-eth/backmerge-10-02-24
backmerge 10-02-25
2 parents b1718ec + 21a8cb8 commit 6c28866

File tree

6 files changed

+21
-19
lines changed

6 files changed

+21
-19
lines changed

.changeset/ten-pears-explode.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"create-eth": patch
3+
---
4+
5+
- fix typo in package.json scripts for lint
6+
- Add `hardhat:clean` command to root of monorepo (https://github.com/scaffold-eth/scaffold-eth-2/pull/1043)
7+
- Only render FaucetButton on localhost (https://github.com/scaffold-eth/scaffold-eth-2/pull/1047)
8+
- fix: remove indexed event params (https://github.com/scaffold-eth/scaffold-eth-2/pull/1048)

templates/base/packages/nextjs/components/Header.tsx.template.mjs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ import React, { useCallback, useRef, useState } from "react";
88
import Image from "next/image";
99
import Link from "next/link";
1010
import { usePathname } from "next/navigation";
11+
import { hardhat } from "viem/chains";
1112
import { Bars3Icon, BugAntIcon } from "@heroicons/react/24/outline";
1213
import { FaucetButton, RainbowKitCustomConnectButton } from "~~/components/scaffold-eth";
13-
import { useOutsideClick } from "~~/hooks/scaffold-eth";
14+
import { useOutsideClick, useTargetNetwork } from "~~/hooks/scaffold-eth";
1415
${menuIconImports.filter(Boolean).join("\n")}
1516
1617
type HeaderMenuLink = {
@@ -62,6 +63,9 @@ export const HeaderMenuLinks = () => {
6263
* Site header
6364
*/
6465
export const Header = () => {
66+
const { targetNetwork } = useTargetNetwork();
67+
const isLocalNetwork = targetNetwork.id === hardhat.id;
68+
6569
const [isDrawerOpen, setIsDrawerOpen] = useState(false);
6670
const burgerMenuRef = useRef<HTMLDivElement>(null);
6771
useOutsideClick(
@@ -109,7 +113,7 @@ export const Header = () => {
109113
</div>
110114
<div className="navbar-end flex-grow mr-4">
111115
<RainbowKitCustomConnectButton />
112-
<FaucetButton />
116+
{isLocalNetwork && <FaucetButton />}
113117
</div>
114118
</div>
115119
);

templates/base/packages/nextjs/hooks/scaffold-eth/useScaffoldEventHistory.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@ export const useScaffoldEventHistory = <
142142
return nextBlock;
143143
},
144144
select: data => {
145-
const events = data.pages.flat();
146-
const eventHistoryData = events?.map(addIndexedArgsToEvent) as UseScaffoldEventHistoryData<
145+
const events = data.pages.flat() as unknown as UseScaffoldEventHistoryData<
147146
TContractName,
148147
TEventName,
149148
TBlockData,
@@ -152,7 +151,7 @@ export const useScaffoldEventHistory = <
152151
>;
153152

154153
return {
155-
pages: eventHistoryData?.reverse(),
154+
pages: events?.reverse(),
156155
pageParams: data.pageParams,
157156
};
158157
},
@@ -180,11 +179,3 @@ export const useScaffoldEventHistory = <
180179
refetch: query.refetch,
181180
};
182181
};
183-
184-
export const addIndexedArgsToEvent = (event: any) => {
185-
if (event.args && !Array.isArray(event.args)) {
186-
return { ...event, args: { ...event.args, ...Object.values(event.args) } };
187-
}
188-
189-
return event;
190-
};

templates/base/packages/nextjs/hooks/scaffold-eth/useScaffoldWatchContractEvent.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Abi, ExtractAbiEventNames } from "abitype";
22
import { Log } from "viem";
33
import { useWatchContractEvent } from "wagmi";
44
import { useSelectedNetwork } from "~~/hooks/scaffold-eth";
5-
import { addIndexedArgsToEvent, useDeployedContractInfo } from "~~/hooks/scaffold-eth";
5+
import { useDeployedContractInfo } from "~~/hooks/scaffold-eth";
66
import { AllowedChainIds } from "~~/utils/scaffold-eth";
77
import { ContractAbi, ContractName, UseScaffoldEventConfig } from "~~/utils/scaffold-eth/contract";
88

@@ -30,14 +30,11 @@ export const useScaffoldWatchContractEvent = <
3030
chainId: selectedNetwork.id as AllowedChainIds,
3131
});
3232

33-
const addIndexedArgsToLogs = (logs: Log[]) => logs.map(addIndexedArgsToEvent);
34-
const listenerWithIndexedArgs = (logs: Log[]) => onLogs(addIndexedArgsToLogs(logs) as Parameters<typeof onLogs>[0]);
35-
3633
return useWatchContractEvent({
3734
address: deployedContractData?.address,
3835
abi: deployedContractData?.abi as Abi,
3936
chainId: selectedNetwork.id,
40-
onLogs: listenerWithIndexedArgs,
37+
onLogs: (logs: Log[]) => onLogs(logs as Parameters<typeof onLogs>[0]),
4138
eventName,
4239
});
4340
};

templates/solidity-frameworks/hardhat/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"hardhat:account": "yarn workspace @se-2/hardhat account",
1313
"hardhat:chain": "yarn workspace @se-2/hardhat chain",
1414
"hardhat:check-types": "yarn workspace @se-2/hardhat check-types",
15+
"hardhat:clean": "yarn workspace @se-2/hardhat clean",
1516
"hardhat:compile": "yarn workspace @se-2/hardhat compile",
1617
"hardhat:deploy": "yarn workspace @se-2/hardhat deploy",
1718
"hardhat:flatten": "yarn workspace @se-2/hardhat flatten",
@@ -23,7 +24,7 @@
2324
"hardhat:lint-staged": "yarn workspace @se-2/hardhat lint-staged",
2425
"hardhat:test": "yarn workspace @se-2/hardhat test",
2526
"hardhat:verify": "yarn workspace @se-2/hardhat verify",
26-
"lint": "yarn nextjs:lint && yarn hardhat:lint",
27+
"lint": "yarn next:lint && yarn hardhat:lint",
2728
"test": "yarn hardhat:test",
2829
"verify": "yarn hardhat:verify"
2930
}

templates/solidity-frameworks/hardhat/packages/hardhat/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"chain": "hardhat node --network hardhat --no-deploy",
99
"check-types": "tsc --noEmit --incremental",
1010
"compile": "hardhat compile",
11+
"clean": "hardhat clean",
1112
"deploy": "ts-node scripts/runHardhatDeployWithPK.ts",
1213
"flatten": "hardhat flatten",
1314
"fork": "MAINNET_FORKING_ENABLED=true hardhat node --network hardhat --no-deploy",

0 commit comments

Comments
 (0)