From 0005bb32bd802aaba493fefc5617dacf5ac2a301 Mon Sep 17 00:00:00 2001 From: Luciano Oliva Bianco Date: Wed, 18 Sep 2024 13:04:52 -0300 Subject: [PATCH] Changed buttons color to match marketplace style --- packages/nextjs/app/simpleMint/page.tsx | 38 ++++++++++++++----- packages/nextjs/components/Header.tsx | 5 +-- .../nextjs/contracts/deployedContracts.ts | 8 ++-- 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/packages/nextjs/app/simpleMint/page.tsx b/packages/nextjs/app/simpleMint/page.tsx index 87b54ca..cb88656 100644 --- a/packages/nextjs/app/simpleMint/page.tsx +++ b/packages/nextjs/app/simpleMint/page.tsx @@ -78,17 +78,20 @@ const SimpleMint: NextPage = () => { const handleMPaidMint = async () => { const notificationId = notification.loading("Uploading to IPFS"); + try { const uploadedItem = await addToIPFS(yourJSON); - notification.remove(notificationId); notification.success("Metadata uploaded to IPFS"); // Log IPFS path before sending to contract console.log("IPFS Path:", uploadedItem.path); - // Mint the NFT - await writeContractAsync({ + if (!connectedAddress) { + throw new Error("No connected address found."); + } + + const contractResponse = await writeContractAsync({ functionName: "startCollection", args: [ collectionName, @@ -100,13 +103,28 @@ const SimpleMint: NextPage = () => { ], }); + if (!contractResponse) { + throw new Error("Contract response is null or undefined."); + } + + console.log("Contract Response:", contractResponse); notification.success("Collection started successfully!"); } catch (error) { notification.remove(notificationId); - console.error("Error during minting:", error); - // Log the error and notify the user - notification.error("Minting failed, please try again."); + // Type guard to narrow the type of 'error' + if (error instanceof Error) { + console.error("Error during minting:", error); + + if (error.message.includes("gasLimit")) { + notification.error("Minting failed due to gas limit issue, please check your network and wallet setup."); + } else { + notification.error("Minting failed, please try again."); + } + } else { + console.error("An unknown error occurred:", error); + notification.error("An unknown error occurred."); + } } }; @@ -398,7 +416,7 @@ const SimpleMint: NextPage = () => {
{isGaslessMinting ? ( ) : (