diff --git a/.changeset/long-deers-tease.md b/.changeset/long-deers-tease.md new file mode 100644 index 00000000000..989acd68e55 --- /dev/null +++ b/.changeset/long-deers-tease.md @@ -0,0 +1,5 @@ +--- +"thirdweb": patch +--- + +Split create contract flow into two steps diff --git a/packages/cli/constants/constants.ts b/packages/cli/constants/constants.ts index adc8ef54785..fc0d82f0f61 100644 --- a/packages/cli/constants/constants.ts +++ b/packages/cli/constants/constants.ts @@ -3,7 +3,8 @@ export const CREATE_MESSAGES = { projectName: "What is your project named?", framework: "What framework do you want to use?", language: "What language do you want to use?", - contract: "What contract do you want to start from?", + contract: "What type of contract do you want to start from?", + extensions: "What extensions do you want to add to your contract?", } as const; export const ERROR_MESSAGES = { diff --git a/packages/cli/e2e/detect.test.ts b/packages/cli/e2e/detect.test.ts index 98ca14ab3f8..a2129c8dfa7 100644 --- a/packages/cli/e2e/detect.test.ts +++ b/packages/cli/e2e/detect.test.ts @@ -20,9 +20,12 @@ describe("npx thirdweb detect", () => { // select hardhat await create.pressKey("enter"); await create.waitForText(CREATE_MESSAGES.contract); - // select ERC721Base + // select ERC721 await create.pressKey("arrowDown"); await create.pressKey("enter"); + await create.waitForText(CREATE_MESSAGES.extensions); + // select no extra extensions + await create.pressKey("enter"); // wait for program to finish await create.waitForFinish(); diff --git a/packages/cli/src/constants/base-contracts.ts b/packages/cli/src/constants/base-contracts.ts index 6680115a560..05477a688aa 100644 --- a/packages/cli/src/constants/base-contracts.ts +++ b/packages/cli/src/constants/base-contracts.ts @@ -21,7 +21,7 @@ contract Contract is ERC721Base { {} }`, - ERC721Signature: `// SPDX-License-Identifier: Apache-2.0 + ERC721SignatureMint: `// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; import "@thirdweb-dev/contracts/base/ERC721SignatureMint.sol"; @@ -113,7 +113,7 @@ contract Contract is ERC1155Base { {} }`, - ERC1155Signature: `// SPDX-License-Identifier: Apache-2.0 + ERC1155SignatureMint: `// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; import "@thirdweb-dev/contracts/base/ERC1155SignatureMint.sol"; diff --git a/packages/cli/src/create/command.ts b/packages/cli/src/create/command.ts index 21be83a0f3c..a1241d14a6c 100644 --- a/packages/cli/src/create/command.ts +++ b/packages/cli/src/create/command.ts @@ -175,36 +175,64 @@ export async function twCreate(options: any) { // Select base contract if (projectType === "contract" && !baseContract) { - const res = await prompts({ + let standard = "none"; + const standardPrompt = await prompts({ type: "select", - name: "baseContract", + name: "standard", message: CREATE_MESSAGES.contract, choices: [ - { title: "Empty Contract", value: "" }, - { title: "ERC721 Base", value: "ERC721Base" }, - { title: "ERC721 + Signature Mint", value: "ERC721Signature" }, - { title: "ERC721 + Lazy Mint", value: "ERC721LazyMint" }, - { title: "ERC721 + Delayed Reveal", value: "ERC721DelayedReveal" }, - { title: "ERC721 + Drop", value: "ERC721Drop" }, - { title: "ERC1155 Base", value: "ERC1155Base" }, - { title: "ERC1155 + Signature Mint", value: "ERC1155Signature" }, - { title: "ERC1155 + Lazy Mint", value: "ERC1155LazyMint" }, - { title: "ERC1155 + Delayed Reveal", value: "ERC1155DelayedReveal" }, - { title: "ERC1155 + Drop", value: "ERC1155Drop" }, - { title: "ERC20 Base", value: "ERC20Base" }, - { title: "ERC20 + Vote", value: "ERC20Vote" }, - { title: "ERC20 + Signature Mint", value: "ERC20SignatureMint" }, - { - title: "ERC20 + Vote + Signature Mint", - value: "ERC20SignatureMintVote", - }, - { title: "ERC20 + Drop", value: "ERC20Drop" }, - { title: "ERC20 + Vote + Drop", value: "ERC20DropVote" }, + { title: "Empty Contract", value: "none" }, + { title: "ERC721", value: "erc721" }, + { title: "ERC20", value: "erc20" }, + { title: "ERC1155", value: "erc1155" }, ], }); - if (typeof res.baseContract === "string") { - baseContract = res.baseContract.trim(); + if (typeof standardPrompt.standard === "string") { + standard = standardPrompt.standard.trim(); + } + + if (standard === "none") { + baseContract = ""; + } else { + let choices: prompts.Choice[] = []; + if (standard === "erc721") { + choices = [ + { title: "None", value: "ERC721Base" }, + { title: "Signature Mint", value: "ERC721SignatureMint" }, + { title: "Lazy Mint", value: "ERC721LazyMint" }, + { title: "Delayed Reveal", value: "ERC721DelayedReveal" }, + { title: "Drop", value: "ERC721Drop" }, + ]; + } else if (standard === "erc20") { + choices = [ + { title: "None", value: "ERC20Base" }, + { title: "Vote", value: "ERC20Vote" }, + { title: "Signature Mint", value: "ERC20SignatureMint" }, + { title: "Vote + Signature Mint", value: "ERC20SignatureMintVote" }, + { title: "Drop", value: "ERC20Drop" }, + { title: "Vote + Drop", value: "ERC20DropVote" }, + ]; + } else if (standard === "erc1155") { + choices = [ + { title: "None", value: "ERC1155Base" }, + { title: "Signature Mint", value: "ERC1155SignatureMint" }, + { title: "Lazy Mint", value: "ERC1155LazyMint" }, + { title: "Delayed Reveal", value: "ERC1155DelayedReveal" }, + { title: "Drop", value: "ERC1155Drop" }, + ]; + } + + const res = await prompts({ + type: "select", + name: "baseContract", + message: CREATE_MESSAGES.extensions, + choices: choices, + }); + + if (typeof res.baseContract === "string") { + baseContract = res.baseContract.trim(); + } } }