diff --git a/.changeset/quiet-ligers-invent.md b/.changeset/quiet-ligers-invent.md new file mode 100644 index 000000000..d8d36acef --- /dev/null +++ b/.changeset/quiet-ligers-invent.md @@ -0,0 +1,7 @@ +--- +"create-eth": patch +--- + +- 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 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: diff --git a/templates/base/.husky/pre-commit b/templates/base/.husky/pre-commit index 44d21ba2f..9c6495440 100755 --- a/templates/base/.husky/pre-commit +++ b/templates/base/.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/templates/base/packages/nextjs/pages/debug.tsx b/templates/base/packages/nextjs/pages/debug.tsx index 02bdd4ab4..824c8ceb8 100644 --- a/templates/base/packages/nextjs/pages/debug.tsx +++ b/templates/base/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<ContractName>( @@ -36,13 +38,20 @@ const Debug: NextPage = () => { <div className="flex flex-row gap-2 w-full max-w-7xl pb-1 px-6 lg:px-10 flex-wrap"> {contractNames.map(contractName => ( <button - className={`btn btn-secondary btn-sm font-thin ${ - contractName === selectedContract ? "bg-base-300" : "bg-base-100" + className={`btn btn-secondary btn-sm font-light hover:border-transparent ${ + contractName === selectedContract + ? "bg-base-300 hover:bg-base-300 no-animation" + : "bg-base-100 hover:bg-secondary" }`} key={contractName} onClick={() => setSelectedContract(contractName)} > {contractName} + {contractsData[contractName].external && ( + <span className="tooltip tooltip-top tooltip-accent" data-tip="External contract"> + <BarsArrowUpIcon className="h-4 w-4 cursor-pointer" /> + </span> + )} </button> ))} </div> diff --git a/templates/base/packages/nextjs/utils/scaffold-eth/contract.ts b/templates/base/packages/nextjs/utils/scaffold-eth/contract.ts index e9ad461f0..ac7fe4a39 100644 --- a/templates/base/packages/nextjs/utils/scaffold-eth/contract.ts +++ b/templates/base/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 = <D extends Record<PropertyKey, any>, S extends Record<PropertyKey, any>>( - destination: D, - source: S, +type AddExternalFlag<T> = { + [ChainId in keyof T]: { + [ContractName in keyof T[ChainId]]: T[ChainId][ContractName] & { external?: true }; + }; +}; + +const deepMergeContracts = <L extends Record<PropertyKey, any>, E extends Record<PropertyKey, any>>( + local: L, + external: E, ) => { const result: Record<PropertyKey, any> = {}; - 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<string, Record<string, unknown>>).map(([contractName, declaration]) => [ + contractName, + { ...declaration, external: true }, + ]), + ); + result[key] = { ...local[key], ...amendedExternal }; } - return result as MergeDeepRecord<D, S, { arrayMergeMode: "replace" }>; + return result as MergeDeepRecord<AddExternalFlag<L>, AddExternalFlag<E>, { 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/templates/base/packages/nextjs/utils/scaffold-eth/contractNames.ts b/templates/base/packages/nextjs/utils/scaffold-eth/contractNames.ts deleted file mode 100644 index caed60145..000000000 --- a/templates/base/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/templates/base/packages/nextjs/utils/scaffold-eth/contractsData.ts b/templates/base/packages/nextjs/utils/scaffold-eth/contractsData.ts new file mode 100644 index 000000000..84d4278a9 --- /dev/null +++ b/templates/base/packages/nextjs/utils/scaffold-eth/contractsData.ts @@ -0,0 +1,7 @@ +import scaffoldConfig from "~~/scaffold.config"; +import { contracts } from "~~/utils/scaffold-eth/contract"; + +export function getAllContracts() { + const contractsData = contracts?.[scaffoldConfig.targetNetworks[0].id]; + return contractsData ? contractsData : {}; +} diff --git a/templates/extensions/hardhat/packages/hardhat/.gitignore.template.mjs b/templates/extensions/hardhat/packages/hardhat/.gitignore.template.mjs index 65bb30b2f..217008e0e 100644 --- a/templates/extensions/hardhat/packages/hardhat/.gitignore.template.mjs +++ b/templates/extensions/hardhat/packages/hardhat/.gitignore.template.mjs @@ -15,6 +15,6 @@ artifacts artifacts-zk cache-zk -deployments` +deployments/localhost` export default contents