Skip to content

Commit 7cbd2be

Browse files
Merge pull request #674 from scaffold-eth/cli-backmerge
Weekly CLI backmerge
2 parents f9e614b + 8af19db commit 7cbd2be

File tree

10 files changed

+53
-101
lines changed

10 files changed

+53
-101
lines changed

.changeset/quiet-ligers-invent.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"create-eth": patch
3+
---
4+
5+
- Track hardhat-deploy deployments, except localhost (#666)
6+
- feat: add external flag to external contracts (#647)
7+
- Remove `.github/ISSUE_TEMPLATE` and pull request template when using npx

templates/base/.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 0 additions & 58 deletions
This file was deleted.

templates/base/.github/ISSUE_TEMPLATE/config.yml

Lines changed: 0 additions & 8 deletions
This file was deleted.

templates/base/.github/pull_request_template.md

Lines changed: 0 additions & 16 deletions
This file was deleted.

templates/base/.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
33

4-
yarn lint-staged --verbose
4+
yarn lint-staged --verbose

templates/base/packages/nextjs/pages/debug.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import { useEffect } from "react";
22
import type { NextPage } from "next";
33
import { useLocalStorage } from "usehooks-ts";
4+
import { BarsArrowUpIcon } from "@heroicons/react/20/solid";
45
import { MetaHeader } from "~~/components/MetaHeader";
56
import { ContractUI } from "~~/components/scaffold-eth";
67
import { ContractName } from "~~/utils/scaffold-eth/contract";
7-
import { getContractNames } from "~~/utils/scaffold-eth/contractNames";
8+
import { getAllContracts } from "~~/utils/scaffold-eth/contractsData";
89

910
const selectedContractStorageKey = "scaffoldEth2.selectedContract";
10-
const contractNames = getContractNames();
11+
const contractsData = getAllContracts();
12+
const contractNames = Object.keys(contractsData) as ContractName[];
1113

1214
const Debug: NextPage = () => {
1315
const [selectedContract, setSelectedContract] = useLocalStorage<ContractName>(
@@ -36,13 +38,20 @@ const Debug: NextPage = () => {
3638
<div className="flex flex-row gap-2 w-full max-w-7xl pb-1 px-6 lg:px-10 flex-wrap">
3739
{contractNames.map(contractName => (
3840
<button
39-
className={`btn btn-secondary btn-sm font-thin ${
40-
contractName === selectedContract ? "bg-base-300" : "bg-base-100"
41+
className={`btn btn-secondary btn-sm font-light hover:border-transparent ${
42+
contractName === selectedContract
43+
? "bg-base-300 hover:bg-base-300 no-animation"
44+
: "bg-base-100 hover:bg-secondary"
4145
}`}
4246
key={contractName}
4347
onClick={() => setSelectedContract(contractName)}
4448
>
4549
{contractName}
50+
{contractsData[contractName].external && (
51+
<span className="tooltip tooltip-top tooltip-accent" data-tip="External contract">
52+
<BarsArrowUpIcon className="h-4 w-4 cursor-pointer" />
53+
</span>
54+
)}
4655
</button>
4756
))}
4857
</div>

templates/base/packages/nextjs/utils/scaffold-eth/contract.ts

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,34 @@ import deployedContractsData from "~~/contracts/deployedContracts";
2323
import externalContractsData from "~~/contracts/externalContracts";
2424
import scaffoldConfig from "~~/scaffold.config";
2525

26-
const deepMergeContracts = <D extends Record<PropertyKey, any>, S extends Record<PropertyKey, any>>(
27-
destination: D,
28-
source: S,
26+
type AddExternalFlag<T> = {
27+
[ChainId in keyof T]: {
28+
[ContractName in keyof T[ChainId]]: T[ChainId][ContractName] & { external?: true };
29+
};
30+
};
31+
32+
const deepMergeContracts = <L extends Record<PropertyKey, any>, E extends Record<PropertyKey, any>>(
33+
local: L,
34+
external: E,
2935
) => {
3036
const result: Record<PropertyKey, any> = {};
31-
const allKeys = Array.from(new Set([...Object.keys(source), ...Object.keys(destination)]));
37+
const allKeys = Array.from(new Set([...Object.keys(external), ...Object.keys(local)]));
3238
for (const key of allKeys) {
33-
result[key] = { ...destination[key], ...source[key] };
39+
if (!external[key]) {
40+
result[key] = local[key];
41+
continue;
42+
}
43+
const amendedExternal = Object.fromEntries(
44+
Object.entries(external[key] as Record<string, Record<string, unknown>>).map(([contractName, declaration]) => [
45+
contractName,
46+
{ ...declaration, external: true },
47+
]),
48+
);
49+
result[key] = { ...local[key], ...amendedExternal };
3450
}
35-
return result as MergeDeepRecord<D, S, { arrayMergeMode: "replace" }>;
51+
return result as MergeDeepRecord<AddExternalFlag<L>, AddExternalFlag<E>, { arrayMergeMode: "replace" }>;
3652
};
53+
3754
const contractsData = deepMergeContracts(deployedContractsData, externalContractsData);
3855

3956
export type InheritedFunctions = { readonly [key: string]: string };
@@ -42,6 +59,7 @@ export type GenericContract = {
4259
address: Address;
4360
abi: Abi;
4461
inheritedFunctions?: InheritedFunctions;
62+
external?: true;
4563
};
4664

4765
export type GenericContractsDeclaration = {

templates/base/packages/nextjs/utils/scaffold-eth/contractNames.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import scaffoldConfig from "~~/scaffold.config";
2+
import { contracts } from "~~/utils/scaffold-eth/contract";
3+
4+
export function getAllContracts() {
5+
const contractsData = contracts?.[scaffoldConfig.targetNetworks[0].id];
6+
return contractsData ? contractsData : {};
7+
}

templates/extensions/hardhat/packages/hardhat/.gitignore.template.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ artifacts
1515
artifacts-zk
1616
cache-zk
1717
18-
deployments`
18+
deployments/localhost`
1919

2020
export default contents

0 commit comments

Comments
 (0)