From 2329a22bf111c49d6247964a4b462b59aac4feea Mon Sep 17 00:00:00 2001 From: MananTank Date: Wed, 4 Jun 2025 20:14:51 +0000 Subject: [PATCH] Dashboard: Poll for active claim condition before continuing with minting in coin launch (#7273) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ## PR-Codex overview This PR introduces a polling mechanism to ensure that claim conditions are set before proceeding with token minting in the `CreateTokenAssetPage` component. ### Detailed summary - Added import for `pollWithTimeout` utility. - Implemented polling logic to check for active claim conditions before minting. - Set a timeout of 30 seconds for the polling process. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` ## Summary by CodeRabbit - **New Features** - Improved the token creation process by ensuring minting only begins after claim conditions are confirmed, providing a more reliable experience for users. --- .../assets/create/create-token-page-impl.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/assets/create/create-token-page-impl.tsx b/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/assets/create/create-token-page-impl.tsx index 58229d3a9d2..c4e934075ff 100644 --- a/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/assets/create/create-token-page-impl.tsx +++ b/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/assets/create/create-token-page-impl.tsx @@ -21,10 +21,12 @@ import { deployERC20Contract } from "thirdweb/deploys"; import type { ClaimConditionsInput } from "thirdweb/dist/types/utils/extensions/drops/types"; import { claimTo, + getActiveClaimCondition, setClaimConditions as setClaimConditionsExtension, transferBatch, } from "thirdweb/extensions/erc20"; import { useActiveAccount } from "thirdweb/react"; +import { pollWithTimeout } from "../../../../../../../../utils/pollWithTimeout"; import { useAddContractToProject } from "../../hooks/project-contracts"; import { CreateTokenAssetPageUI } from "./create-token-page.client"; import type { CreateAssetFormValues } from "./form"; @@ -241,6 +243,17 @@ export function CreateTokenAssetPage(props: { chain, }); + // poll until claim conditions are set before moving on to minting + await pollWithTimeout({ + shouldStop: async () => { + const claimConditions = await getActiveClaimCondition({ + contract, + }); + return !!claimConditions; + }, + timeoutMs: 30000, + }); + const totalSupply = Number(formValues.supply); const salePercent = formValues.saleEnabled ? Number(formValues.saleAllocationPercentage)