From 07134f5b268ab1fbe9016c5a8b3890af3b61a386 Mon Sep 17 00:00:00 2001 From: "Shiv Bhonde | shivbhonde.eth" Date: Fri, 22 Dec 2023 15:26:41 +0530 Subject: [PATCH 1/6] Track hardhat-deploy deployments, except localhost (#666) --- .husky/pre-commit | 2 +- packages/hardhat/.gitignore | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 44d21ba2f..9c6495440 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,4 @@ #!/bin/sh . "$(dirname "$0")/_/husky.sh" -yarn lint-staged --verbose \ No newline at end of file +yarn lint-staged --verbose diff --git a/packages/hardhat/.gitignore b/packages/hardhat/.gitignore index 29b645c2c..be5e27655 100644 --- a/packages/hardhat/.gitignore +++ b/packages/hardhat/.gitignore @@ -14,4 +14,4 @@ artifacts artifacts-zk cache-zk -deployments +deployments/localhost From 2dfe898098ff4dcfd0f400d2144e8da0bea947b1 Mon Sep 17 00:00:00 2001 From: Samuel Van Erps Date: Wed, 27 Dec 2023 08:44:43 +0100 Subject: [PATCH 2/6] feat: add external flag to external contracts (#647) Co-authored-by: Shiv Bhonde | shivbhonde.eth --- packages/nextjs/pages/debug.tsx | 17 ++++++++--- .../nextjs/utils/scaffold-eth/contract.ts | 30 +++++++++++++++---- .../utils/scaffold-eth/contractNames.ts | 7 ----- .../utils/scaffold-eth/contractsData.ts | 8 +++++ 4 files changed, 45 insertions(+), 17 deletions(-) delete mode 100644 packages/nextjs/utils/scaffold-eth/contractNames.ts create mode 100644 packages/nextjs/utils/scaffold-eth/contractsData.ts diff --git a/packages/nextjs/pages/debug.tsx b/packages/nextjs/pages/debug.tsx index 02bdd4ab4..824c8ceb8 100644 --- a/packages/nextjs/pages/debug.tsx +++ b/packages/nextjs/pages/debug.tsx @@ -1,13 +1,15 @@ import { useEffect } from "react"; import type { NextPage } from "next"; import { useLocalStorage } from "usehooks-ts"; +import { BarsArrowUpIcon } from "@heroicons/react/20/solid"; import { MetaHeader } from "~~/components/MetaHeader"; import { ContractUI } from "~~/components/scaffold-eth"; import { ContractName } from "~~/utils/scaffold-eth/contract"; -import { getContractNames } from "~~/utils/scaffold-eth/contractNames"; +import { getAllContracts } from "~~/utils/scaffold-eth/contractsData"; const selectedContractStorageKey = "scaffoldEth2.selectedContract"; -const contractNames = getContractNames(); +const contractsData = getAllContracts(); +const contractNames = Object.keys(contractsData) as ContractName[]; const Debug: NextPage = () => { const [selectedContract, setSelectedContract] = useLocalStorage( @@ -36,13 +38,20 @@ const Debug: NextPage = () => {
{contractNames.map(contractName => ( ))}
diff --git a/packages/nextjs/utils/scaffold-eth/contract.ts b/packages/nextjs/utils/scaffold-eth/contract.ts index e9ad461f0..ac7fe4a39 100644 --- a/packages/nextjs/utils/scaffold-eth/contract.ts +++ b/packages/nextjs/utils/scaffold-eth/contract.ts @@ -23,17 +23,34 @@ import deployedContractsData from "~~/contracts/deployedContracts"; import externalContractsData from "~~/contracts/externalContracts"; import scaffoldConfig from "~~/scaffold.config"; -const deepMergeContracts = , S extends Record>( - destination: D, - source: S, +type AddExternalFlag = { + [ChainId in keyof T]: { + [ContractName in keyof T[ChainId]]: T[ChainId][ContractName] & { external?: true }; + }; +}; + +const deepMergeContracts = , E extends Record>( + local: L, + external: E, ) => { const result: Record = {}; - const allKeys = Array.from(new Set([...Object.keys(source), ...Object.keys(destination)])); + const allKeys = Array.from(new Set([...Object.keys(external), ...Object.keys(local)])); for (const key of allKeys) { - result[key] = { ...destination[key], ...source[key] }; + if (!external[key]) { + result[key] = local[key]; + continue; + } + const amendedExternal = Object.fromEntries( + Object.entries(external[key] as Record>).map(([contractName, declaration]) => [ + contractName, + { ...declaration, external: true }, + ]), + ); + result[key] = { ...local[key], ...amendedExternal }; } - return result as MergeDeepRecord; + return result as MergeDeepRecord, AddExternalFlag, { arrayMergeMode: "replace" }>; }; + const contractsData = deepMergeContracts(deployedContractsData, externalContractsData); export type InheritedFunctions = { readonly [key: string]: string }; @@ -42,6 +59,7 @@ export type GenericContract = { address: Address; abi: Abi; inheritedFunctions?: InheritedFunctions; + external?: true; }; export type GenericContractsDeclaration = { diff --git a/packages/nextjs/utils/scaffold-eth/contractNames.ts b/packages/nextjs/utils/scaffold-eth/contractNames.ts deleted file mode 100644 index caed60145..000000000 --- a/packages/nextjs/utils/scaffold-eth/contractNames.ts +++ /dev/null @@ -1,7 +0,0 @@ -import scaffoldConfig from "~~/scaffold.config"; -import { ContractName, contracts } from "~~/utils/scaffold-eth/contract"; - -export function getContractNames() { - const contractsData = contracts?.[scaffoldConfig.targetNetworks[0].id]; - return contractsData ? (Object.keys(contractsData) as ContractName[]) : []; -} diff --git a/packages/nextjs/utils/scaffold-eth/contractsData.ts b/packages/nextjs/utils/scaffold-eth/contractsData.ts new file mode 100644 index 000000000..6ffb47b64 --- /dev/null +++ b/packages/nextjs/utils/scaffold-eth/contractsData.ts @@ -0,0 +1,8 @@ +import scaffoldConfig from "~~/scaffold.config"; +import { contracts } from "~~/utils/scaffold-eth/contract"; + +export function getAllContracts() { + const contractsData = contracts?.[scaffoldConfig.targetNetworks[0].id]; + console.log("The contracts data is:", contractsData); + return contractsData ? contractsData : {}; +} From 7d62ce737f62762446fc70f8f32c28e95c24f674 Mon Sep 17 00:00:00 2001 From: Shiv Bhonde Date: Thu, 28 Dec 2023 16:17:01 +0530 Subject: [PATCH 3/6] add changeset --- .changeset/quiet-ligers-invent.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/quiet-ligers-invent.md diff --git a/.changeset/quiet-ligers-invent.md b/.changeset/quiet-ligers-invent.md new file mode 100644 index 000000000..0f26bc6d2 --- /dev/null +++ b/.changeset/quiet-ligers-invent.md @@ -0,0 +1,6 @@ +--- +"create-eth": patch +--- + +- Track hardhat-deploy deployments, except localhost (#666) +- feat: add external flag to external contracts (#647) From f87db1144ecc058c9a38ed01fec9793b81dd6779 Mon Sep 17 00:00:00 2001 From: Shiv Bhonde Date: Fri, 29 Dec 2023 21:25:27 +0530 Subject: [PATCH 4/6] remove log from contractsData --- .../base/packages/nextjs/utils/scaffold-eth/contractsData.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/templates/base/packages/nextjs/utils/scaffold-eth/contractsData.ts b/templates/base/packages/nextjs/utils/scaffold-eth/contractsData.ts index 6ffb47b64..84d4278a9 100644 --- a/templates/base/packages/nextjs/utils/scaffold-eth/contractsData.ts +++ b/templates/base/packages/nextjs/utils/scaffold-eth/contractsData.ts @@ -3,6 +3,5 @@ import { contracts } from "~~/utils/scaffold-eth/contract"; export function getAllContracts() { const contractsData = contracts?.[scaffoldConfig.targetNetworks[0].id]; - console.log("The contracts data is:", contractsData); return contractsData ? contractsData : {}; } From 42e276692d7a1fde79b7d8b59aa821a20d4d4400 Mon Sep 17 00:00:00 2001 From: Shiv Bhonde Date: Fri, 29 Dec 2023 21:33:36 +0530 Subject: [PATCH 5/6] remove github issue and pr template --- .../.github/ISSUE_TEMPLATE/bug_report.yml | 58 ------------------- .../base/.github/ISSUE_TEMPLATE/config.yml | 8 --- .../base/.github/pull_request_template.md | 16 ----- 3 files changed, 82 deletions(-) delete mode 100644 templates/base/.github/ISSUE_TEMPLATE/bug_report.yml delete mode 100644 templates/base/.github/ISSUE_TEMPLATE/config.yml delete mode 100644 templates/base/.github/pull_request_template.md diff --git a/templates/base/.github/ISSUE_TEMPLATE/bug_report.yml b/templates/base/.github/ISSUE_TEMPLATE/bug_report.yml deleted file mode 100644 index 13ea6fb14..000000000 --- a/templates/base/.github/ISSUE_TEMPLATE/bug_report.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: Bug Report -description: File a bug/issue -title: 'bug: ' -body: - - type: markdown - attributes: - value: | - Thanks for taking the time to fill out this bug report! The more info you provide, the more we can help you 🙌 - - - type: checkboxes - attributes: - label: Is there an existing issue for this? - description: Please search to see if an issue already exists for the bug you encountered. - options: - - label: I have looked through the [existing issues](https://github.com/scaffold-eth/scaffold-eth-2/issues) - required: true - - - type: dropdown - attributes: - label: Which method was used to setup Scaffold-ETH 2 ? - description: You may select both, if the bug is present in both the methods. - multiple: true - options: - - git clone - - npx create-eth@latest - validations: - required: true - - - type: textarea - attributes: - label: Current Behavior - description: A concise description of what you're experiencing. - validations: - required: false - - - type: textarea - attributes: - label: Expected Behavior - description: A concise description of what you expected to happen. - validations: - required: false - - - type: textarea - attributes: - label: Steps To Reproduce - description: Steps or code snippets to reproduce the behavior. - validations: - required: false - - - type: textarea - attributes: - label: Anything else? - description: | - Browser info? Screenshots? Anything that will give us more context about the issue you are encountering! - - Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in. - validations: - required: false \ No newline at end of file diff --git a/templates/base/.github/ISSUE_TEMPLATE/config.yml b/templates/base/.github/ISSUE_TEMPLATE/config.yml deleted file mode 100644 index 026121090..000000000 --- a/templates/base/.github/ISSUE_TEMPLATE/config.yml +++ /dev/null @@ -1,8 +0,0 @@ -blank_issues_enabled: true -contact_links: - - name: Ask Question - url: https://github.com/scaffold-eth/scaffold-eth-2/discussions/new?category=q-a - about: Ask questions and discuss with other community members - - name: Request Feature - url: https://github.com/scaffold-eth/scaffold-eth-2/discussions/new?category=ideas - about: Requests features or brainstorm ideas for new functionality \ No newline at end of file diff --git a/templates/base/.github/pull_request_template.md b/templates/base/.github/pull_request_template.md deleted file mode 100644 index 9db886804..000000000 --- a/templates/base/.github/pull_request_template.md +++ /dev/null @@ -1,16 +0,0 @@ -## Description - -_Concise description of proposed changes, We recommend using screenshots and videos for better description_ - -## Additional Information - -- [ ] I have read the [contributing docs](/scaffold-eth/scaffold-eth-2/blob/main/CONTRIBUTING.md) (if this is your first contribution) -- [ ] This is not a duplicate of any [existing pull request](https://github.com/scaffold-eth/scaffold-eth-2/pulls) - -## Related Issues - -_Closes #{issue number}_ - -_Note: If your changes are small and straightforward, you may skip the creation of an issue beforehand and remove this section. However, for medium-to-large changes, it is recommended to have an open issue for discussion and approval prior to submitting a pull request._ - -Your ENS/address: From 8af19dbf4354fa9c21b35ae6ccc504137b4139c8 Mon Sep 17 00:00:00 2001 From: Shiv Bhonde <shivbhonde04@gmail.com> Date: Fri, 29 Dec 2023 21:39:16 +0530 Subject: [PATCH 6/6] update changeset --- .changeset/quiet-ligers-invent.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.changeset/quiet-ligers-invent.md b/.changeset/quiet-ligers-invent.md index 0f26bc6d2..d8d36acef 100644 --- a/.changeset/quiet-ligers-invent.md +++ b/.changeset/quiet-ligers-invent.md @@ -4,3 +4,4 @@ - Track hardhat-deploy deployments, except localhost (#666) - feat: add external flag to external contracts (#647) +- Remove `.github/ISSUE_TEMPLATE` and pull request template when using npx