-
Notifications
You must be signed in to change notification settings - Fork 619
[MNY-214] Dashboard: ERC1155 set claim conditions step UX improvements #8146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MNY-214] Dashboard: ERC1155 set claim conditions step UX improvements #8146
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
WalkthroughAdds an Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant UI as Launch UI
participant Page as Create NFT Page
participant Chain as Chain/Wallet
Note over UI,Page: Set Claim Conditions (ERC1155)
User->>UI: Start launch
UI->>Page: setClaimConditions({ values, batch, gasless, onNotEnoughFunds })
alt Not gasless and first batch
Page->>Chain: estimate gas + value
Page->>Chain: get wallet balance
alt Balance >= totalCost
Page->>Chain: send and confirm (standard or no-pay-modal)
Chain-->>Page: tx receipt
Page-->>UI: success
else Insufficient funds
Page-->>UI: onNotEnoughFunds({ requiredAmount, balance })
UI->>UI: Show Insufficient Funds panel (BuyWidget / Retry)
end
else Gasless or subsequent batches
Page->>Chain: send and confirm
Chain-->>Page: tx receipt
Page-->>UI: success
end
sequenceDiagram
autonumber
actor User
participant UI as Launch UI
participant Buy as BuyWidget
participant Chain as Chain/Wallet
Note over UI: Insufficient funds flow
UI->>User: Display required vs balance, actions
User-->>UI: Click "Buy Funds"
UI->>Buy: Open with amount (required - balance)
Buy->>Chain: Purchase flow
Chain-->>Buy: Funds received
Buy-->>UI: onSuccess
UI->>User: Enable Retry
User-->>UI: Click "Retry"
UI->>Page: Re-run setClaimConditions (with same onNotEnoughFunds)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Pre-merge checks and finishing touches❌ Failed checks (4 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
Comment |
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
db0b012 to
5830b1a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (9)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/_common/form.ts (1)
77-81: Clarify units and carry precise values (avoid float rounding).requiredAmount/balance are strings, but downstream code subtracts them via Number(), which can round/overflow. Surface precise values as wei alongside the human strings.
Apply this typing tweak (backward‑compatible) so callers can use bigint math:
- onNotEnoughFunds: (data: { - requiredAmount: string; - balance: string; - }) => void; + onNotEnoughFunds: (data: { + // precise amounts for math + requiredWei: bigint; + balanceWei: bigint; + // optional humanized strings for UI + requiredAmount?: string; + balance?: string; + }) => void;Then emit both wei and human strings where available. This prevents under/over‑buy issues later.
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsx (4)
80-83: Use resolvedTheme to avoid “system” mis‑mapping.theme can be "system". Use resolvedTheme to pass an accurate light/dark to getSDKTheme.
-import { useTheme } from "next-themes"; +import { useTheme } from "next-themes"; ... - const { theme } = useTheme(); + const { resolvedTheme } = useTheme();And later:
- theme={getSDKTheme(theme === "dark" ? "dark" : "light")} + theme={getSDKTheme(resolvedTheme === "dark" ? "dark" : "light")}
81-83: Avoid duplicate chain lookups; reuse the same hook result.You call useV5DashboardChain twice for the same chainId (chainMeta and chain). Keep one value (e.g., chain) and reuse for symbol and props.
- const chainMeta = useV5DashboardChain(Number(formValues.collectionInfo.chain)); + const chain = useV5DashboardChain(Number(formValues.collectionInfo.chain)); ... - buttonLabel={`Buy ${chainMeta?.nativeCurrency?.symbol || "ETH"}`} + buttonLabel={`Buy ${chain?.nativeCurrency?.symbol || "ETH"}`} ... - const chain = useV5DashboardChain(Number(formValues.collectionInfo.chain)); + // reuse the existing `chain`Also applies to: 353-354
446-535: Error panel coupling to stale notEnoughFunds state.renderError shows the “Not enough funds” block whenever notEnoughFunds is truthy, even if the current error is unrelated (e.g., RPC error after a successful top‑up). You reset state on Retry, but a second failure before reset can mislead.
Gate the block on both notEnoughFunds and an errorMessage that includes “insufficient funds” or a dedicated error code, or clear notEnoughFunds on modal open and set it only from the current failed step.
398-439: Consider code‑splitting BuyWidget to keep the dialog light.BuyWidget is heavy. Load it only when needed.
- import { BuyWidget, ... } from "thirdweb/react"; + import dynamic from "next/dynamic"; + const BuyWidget = dynamic(() => import("thirdweb/react").then(m => m.BuyWidget), { ssr: false });This defers its cost until the buy flow is shown.
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/create-nft-page.tsx (4)
301-335: Funds check only on first batch; confirm intended UX.You pre‑check balance for totalBatches and then send only the first batch without the pay modal; subsequent batches use the default sender. That’s fine if the precheck succeeds, but confirm you don’t want to disable the pay modal for later batches too (it won’t show with sufficient funds, but the hook still runs).
Optionally pass the same no‑pay‑modal sender for all batches after a successful precheck to keep behavior uniform.
315-329: Emit precise values to onNotEnoughFunds for downstream math.You currently pass strings via toEther and then throw. Surface the wei values too so consumers can compute exact deltas without string→Number casts.
- params.onNotEnoughFunds({ - balance: toEther(walletBalance.value), - requiredAmount: toEther(totalCost), - }); + params.onNotEnoughFunds({ + requiredWei: totalCost, + balanceWei: walletBalance.value, + requiredAmount: toEther(totalCost), + balance: toEther(walletBalance.value), + });
466-472: Naive gas fallback can be too low; tie to data length.Fallback uses 1,000,000 gas regardless of batch size. For large multicalls, this can still under‑estimate and trip the buy flow again.
Scale fallback by call count (or calldata length) and increase buffer:
- return 1_000_000n * gasPrice; + // heuristic: 100k per call + 200k base, then 20% buffer + const calls = Array.isArray((tx as any).data) ? (tx as any).data.length : 1; + const base = BigInt(200_000 + 100_000 * calls); + return (base * gasPrice * 12n) / 10n;Also consider exposing a knob to tune the buffer.
448-484: Minor: tighten comment and ensure value retrieval order is safe.The note says “get tx.value AFTER estimateGasCost”, but value is retrieved in getTotalTransactionCost. If this ordering matters for your PreparedTransaction, add a short explanation or move value resolution next to estimateGasCost to make the dependency obvious.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/_common/form.ts(1 hunks)apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/create-nft-page.tsx(6 hunks)apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsx(7 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity
Re-use shared types from@/typesor localtypes.tsbarrels
Prefer type aliases over interface except for nominal shapes
Avoidanyandunknownunless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial,Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
**/*.{ts,tsx}: Use explicit function declarations and explicit return types in TypeScript
Limit each file to one stateless, single‑responsibility function
Re‑use shared types from@/typeswhere applicable
Prefertypealiases overinterfaceexcept for nominal shapes
Avoidanyandunknownunless unavoidable; narrow generics when possible
Prefer composition over inheritance; use utility types (Partial, Pick, etc.)
Lazy‑import optional features and avoid top‑level side‑effects to reduce bundle size
Files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/_common/form.tsapps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsxapps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/create-nft-page.tsx
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)
Files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/_common/form.tsapps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsxapps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/create-nft-page.tsx
apps/{dashboard,playground-web}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
apps/{dashboard,playground-web}/**/*.{ts,tsx}: Import UI primitives from@/components/ui/*(Button, Input, Select, Tabs, Card, Sidebar, Badge, Separator) in dashboard and playground apps
UseNavLinkfor internal navigation with automatic active states in dashboard and playground apps
Use Tailwind CSS only – no inline styles or CSS modules
Usecn()from@/lib/utilsfor conditional class logic
Use design system tokens (e.g.,bg-card,border-border,text-muted-foreground)
Server Components (Node edge): Start files withimport "server-only";
Client Components (browser): Begin files with'use client';
Always callgetAuthToken()to retrieve JWT from cookies on server side
UseAuthorization: Bearerheader – never embed tokens in URLs
Return typed results (e.g.,Project[],User[]) – avoidany
Wrap client-side data fetching calls in React Query (@tanstack/react-query)
Use descriptive, stablequeryKeysfor React Query cache hits
ConfigurestaleTime/cacheTimein React Query based on freshness (default ≥ 60s)
Keep tokens secret via internal API routes or server actions
Never importposthog-jsin server components
Files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/_common/form.tsapps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsxapps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/create-nft-page.tsx
apps/{dashboard,playground}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
apps/{dashboard,playground}/**/*.{ts,tsx}: Import UI primitives from@/components/ui/_(e.g., Button, Input, Tabs, Card)
UseNavLinkfor internal navigation to get active state handling
Use Tailwind CSS for styling; no inline styles
Merge class names withcn()from@/lib/utilsfor conditional classes
Stick to design tokens (e.g., bg-card, border-border, text-muted-foreground)
Server Components must start withimport "server-only"; usenext/headers, server‑only env, heavy data fetching, andredirect()where appropriate
Client Components must start with'use client'; handle interactivity with hooks and browser APIs
Server-side data fetching: callgetAuthToken()from cookies, sendAuthorization: Bearer <token>header, and return typed results (avoidany)
Client-side data fetching: wrap calls in React Query with descriptive, stablequeryKeysand set sensiblestaleTime/cacheTime(≥ 60s default); keep tokens secret via internal routes or server actions
Do not importposthog-jsin server components (client-side only)
Files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/_common/form.tsapps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsxapps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/create-nft-page.tsx
apps/{dashboard,playground}/**/*.tsx
📄 CodeRabbit inference engine (AGENTS.md)
Expose a
classNameprop on the root element of every component
Files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsxapps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/create-nft-page.tsx
🧠 Learnings (16)
📚 Learning: 2025-06-10T00:46:00.514Z
Learnt from: MananTank
PR: thirdweb-dev/js#7315
File: apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/assets/create/nft/form.ts:25-42
Timestamp: 2025-06-10T00:46:00.514Z
Learning: In NFT creation functions, the setClaimConditions function signatures are intentionally different between ERC721 and ERC1155. ERC721 setClaimConditions accepts the full CreateNFTFormValues, while ERC1155 setClaimConditions accepts a custom object with nftCollectionInfo and nftBatch parameters because it processes batches differently than the entire form data.
Applied to files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/_common/form.ts
📚 Learning: 2025-06-10T00:50:20.795Z
Learnt from: MananTank
PR: thirdweb-dev/js#7315
File: apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/assets/create/nft/launch-nft.tsx:153-226
Timestamp: 2025-06-10T00:50:20.795Z
Learning: In apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/assets/create/nft/launch-nft.tsx, the updateStatus function correctly expects a complete MultiStepState["status"] object. For pending states, { type: "pending" } is the entire status object. For error states, { type: "error", message: React.ReactNode } is the entire status object. The current code incorrectly spreads the entire step object instead of passing just the status object.
Applied to files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsx
📚 Learning: 2025-07-18T19:20:32.530Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*client.tsx : Interactive UI that relies on hooks (`useState`, `useEffect`, React Query, wallet hooks).
Applied to files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsx
📚 Learning: 2025-07-31T16:17:42.753Z
Learnt from: MananTank
PR: thirdweb-dev/js#7768
File: apps/playground-web/src/app/navLinks.ts:1-1
Timestamp: 2025-07-31T16:17:42.753Z
Learning: Configuration files that import and reference React components (like icon components from lucide-react) need the "use client" directive, even if they primarily export static data, because the referenced components need to be executed in a client context when used by other client components.
Applied to files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsx
📚 Learning: 2025-07-18T19:20:32.530Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*client.tsx : Anything that consumes hooks from `tanstack/react-query` or thirdweb SDKs.
Applied to files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsxapps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/create-nft-page.tsx
📚 Learning: 2025-07-07T21:21:47.488Z
Learnt from: saminacodes
PR: thirdweb-dev/js#7543
File: apps/portal/src/app/pay/page.mdx:4-4
Timestamp: 2025-07-07T21:21:47.488Z
Learning: In the thirdweb-dev/js repository, lucide-react icons must be imported with the "Icon" suffix (e.g., ExternalLinkIcon, RocketIcon) as required by the new linting rule, contrary to the typical lucide-react convention of importing without the suffix.
Applied to files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsx
📚 Learning: 2025-05-30T17:14:25.332Z
Learnt from: MananTank
PR: thirdweb-dev/js#7227
File: apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/modules/components/OpenEditionMetadata.tsx:26-26
Timestamp: 2025-05-30T17:14:25.332Z
Learning: The ModuleCardUIProps interface already includes a client prop of type ThirdwebClient, so when components use `Omit<ModuleCardUIProps, "children" | "updateButton">`, they inherit the client prop without needing to add it explicitly.
Applied to files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsx
📚 Learning: 2025-07-18T19:20:32.530Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*client.tsx : When you need access to browser APIs (localStorage, window, IntersectionObserver etc.).
Applied to files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsx
📚 Learning: 2025-07-18T19:20:32.530Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*.{tsx,jsx} : For notices & skeletons rely on `AnnouncementBanner`, `GenericLoadingPage`, `EmptyStateCard`.
Applied to files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsx
📚 Learning: 2025-07-18T19:19:55.613Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to apps/{dashboard,playground-web}/**/*.{ts,tsx} : Import UI primitives from `@/components/ui/*` (Button, Input, Select, Tabs, Card, Sidebar, Badge, Separator) in dashboard and playground apps
Applied to files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsx
📚 Learning: 2025-07-18T19:20:32.530Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*.{tsx,jsx} : Reuse core UI primitives; avoid re-implementing buttons, cards, modals.
Applied to files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsx
📚 Learning: 2025-08-29T15:37:38.513Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: AGENTS.md:0-0
Timestamp: 2025-08-29T15:37:38.513Z
Learning: Applies to apps/{dashboard,playground}/**/*.{ts,tsx} : Import UI primitives from `@/components/ui/_` (e.g., Button, Input, Tabs, Card)
Applied to files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsx
📚 Learning: 2025-09-17T11:02:13.528Z
Learnt from: MananTank
PR: thirdweb-dev/js#8044
File: packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-tokens.ts:15-17
Timestamp: 2025-09-17T11:02:13.528Z
Learning: The thirdweb `client` object is serializable and can safely be used in React Query keys, similar to the `contract` object.
Applied to files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/create-nft-page.tsx
📚 Learning: 2025-07-18T19:19:55.613Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to packages/thirdweb/src/wallets/** : EIP-1193, EIP-5792, EIP-7702 standard support in wallet modules
Applied to files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/create-nft-page.tsx
📚 Learning: 2025-07-18T19:19:55.613Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to packages/thirdweb/src/wallets/** : Smart wallets with account abstraction
Applied to files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/create-nft-page.tsx
📚 Learning: 2025-07-18T19:19:55.613Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to packages/thirdweb/src/wallets/** : Unified `Wallet` and `Account` interfaces in wallet architecture
Applied to files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/create-nft-page.tsx
🧬 Code graph analysis (2)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsx (4)
apps/dashboard/src/@/hooks/chains/v5-adapter.ts (1)
useV5DashboardChain(14-28)apps/dashboard/src/@/utils/sdk-component-theme.ts (1)
getSDKTheme(8-43)apps/dashboard/src/@/components/blocks/multi-step-status/multi-step-status.tsx (1)
MultiStepStatus(27-97)apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/_common/storage-error-upsell.tsx (1)
StorageErrorPlanUpsell(16-123)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/create-nft-page.tsx (3)
apps/dashboard/src/@/hooks/useSendTx.ts (1)
useSendAndConfirmTx(9-19)packages/thirdweb/src/exports/thirdweb.ts (3)
PreparedTransaction(179-179)estimateGasCost(154-154)getGasPrice(118-118)packages/thirdweb/src/exports/utils.ts (1)
resolvePromisedValue(198-198)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
- GitHub Check: E2E Tests (pnpm, vite)
- GitHub Check: E2E Tests (pnpm, webpack)
- GitHub Check: E2E Tests (pnpm, esbuild)
- GitHub Check: Size
- GitHub Check: Unit Tests
- GitHub Check: Build Packages
- GitHub Check: Lint Packages
- GitHub Check: Analyze (javascript)
.../app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsx
Show resolved
Hide resolved
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8146 +/- ##
=======================================
Coverage 56.28% 56.28%
=======================================
Files 906 906
Lines 59208 59208
Branches 4180 4180
=======================================
Hits 33324 33324
Misses 25779 25779
Partials 105 105
🚀 New features to boost your workflow:
|
Merge activity
|
#8146) <!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR introduces functionality for handling insufficient funds when creating NFTs, enhancing the user experience by allowing users to buy funds directly if their balance is low. ### Detailed summary - Added `onNotEnoughFunds` callback to handle insufficient funds. - Implemented logic to calculate total transaction costs. - Integrated `BuyWidget` to enable users to purchase funds directly. - Enhanced error handling and user feedback for fund-related issues. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - New Features - Gas-cost–aware NFT minting with total cost estimation and balance pre-checks. - Insufficient funds handling with a user-facing prompt showing required vs. available balance. - Integrated Buy Funds widget with theme and chain awareness, plus retry and back controls. - Optional transaction path that skips the pay modal in eligible scenarios. - Enhanced batch processing for ERC1155/721 flows with a callback to surface funding issues. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
5830b1a to
b2239c9
Compare
size-limit report 📦
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (1)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsx (1)
424-429: Precision bug in BuyWidget amount: avoid Number() for token mathNumber() on decimal strings can under/over-estimate 18‑decimals; compute in wei and clamp to 0 before converting to display units. This also resolves potential negative values when balance ≈ required.
Apply this diff:
- amount={String( - Number(notEnoughFunds.values.requiredAmount) - - Number(notEnoughFunds.values.balance), - )} + amount={(() => { + const required = toWei(notEnoughFunds.values.requiredAmount); + const balance = toWei(notEnoughFunds.values.balance); + const delta = required > balance ? required - balance : 0n; + return toEther(delta); + })()}And update imports:
-import type { ThirdwebClient } from "thirdweb"; +import { toEther, toWei, type ThirdwebClient } from "thirdweb";
🧹 Nitpick comments (5)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsx (2)
469-470: Scope “not enough funds” UI to the relevant step onlyRender the funding panel only for Set Claim Conditions errors to avoid shadowing unrelated step errors.
- if (notEnoughFunds) { + if (notEnoughFunds && step.id === stepIds["set-claim-conditions"]) {
81-84: De-duplicate chain hook usage (one call, reuse everywhere)useV5DashboardChain is called twice; compute once and reuse to reduce work and avoid identity drift.
- const chainMeta = useV5DashboardChain( + const chain = useV5DashboardChain( Number(formValues.collectionInfo.chain), );- const chain = useV5DashboardChain(Number(formValues.collectionInfo.chain)); + // reuse the `chain` computed above- buttonLabel={`Buy ${chainMeta?.nativeCurrency?.symbol || "ETH"}`} + buttonLabel={`Buy ${chain?.nativeCurrency?.symbol || "ETH"}`}- {chainMeta?.nativeCurrency?.symbol || "ETH"} + {chain?.nativeCurrency?.symbol || "ETH"}- {chainMeta?.nativeCurrency?.symbol || "ETH"} + {chain?.nativeCurrency?.symbol || "ETH"}Also applies to: 353-355, 428-429, 484-489
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/create-nft-page.tsx (3)
301-334: Keep pay‑modal behavior consistent across all batchesAfter prechecking funds on batch 1, send the remaining batches via the no‑pay‑modal path too to avoid a pay modal popping up mid‑flow.
- const totalBatches = Math.ceil(values.nfts.length / batch.count); - - if (batch.startIndex === 0 && totalBatches > 1 && !params.gasless) { + const totalBatches = Math.ceil(values.nfts.length / batch.count); + const shouldUseNoPayModal = totalBatches > 1 && !params.gasless; + + if (batch.startIndex === 0 && shouldUseNoPayModal) { if (!activeAccount) { throw new Error("Wallet is not connected"); } - const costPerBatch = await getTotalTransactionCost({ + const costPerBatch = await getTotalTransactionCost({ tx: tx, from: activeAccount.address, + // scale fallback by tx count to be safer if estimation fails + fallbackGasUnits: 300_000n * BigInt(encodedTransactions.length), }); const totalCost = costPerBatch * BigInt(totalBatches); ... - await sendAndConfirmTxNoPayModal.mutateAsync(tx); - } else { - await sendAndConfirmTx.mutateAsync(tx); - } + await sendAndConfirmTxNoPayModal.mutateAsync(tx); + } else if (shouldUseNoPayModal) { + await sendAndConfirmTxNoPayModal.mutateAsync(tx); + } else { + await sendAndConfirmTx.mutateAsync(tx); + }
448-485: Make gas fallback tunable; scale with batch size when estimation failsA fixed 1,000,000 gas fallback can under/over‑estimate multicalls of varying sizes. Accept an optional fallbackGasUnits and let callers scale it (e.g., 300k × calls).
-async function getTransactionGasCost(tx: PreparedTransaction, from?: string) { +async function getTransactionGasCost( + tx: PreparedTransaction, + from?: string, + fallbackGasUnits?: bigint, +) { try { const gasCost = await estimateGasCost({ from, transaction: tx, }); const bufferCost = gasCost.wei / 10n; // Note: get tx.value AFTER estimateGasCost // add 10% extra gas cost to the estimate to ensure user buys enough to cover the tx cost return gasCost.wei + bufferCost; } catch { if (from) { // try again without passing from - return await getTransactionGasCost(tx); + return await getTransactionGasCost(tx, undefined, fallbackGasUnits); } // fallback if both fail, use the tx value + 1M * gas price const gasPrice = await getGasPrice({ chain: tx.chain, client: tx.client, }); - return 1_000_000n * gasPrice; + return (fallbackGasUnits ?? 1_000_000n) * gasPrice; } } -async function getTotalTransactionCost(params: { - tx: PreparedTransaction; - from?: string; -}) { +async function getTotalTransactionCost(params: { + tx: PreparedTransaction; + from?: string; + fallbackGasUnits?: bigint; +}) { const [txValue, txGasCost] = await Promise.all([ resolvePromisedValue(params.tx.value), - getTransactionGasCost(params.tx, params.from), + getTransactionGasCost(params.tx, params.from, params.fallbackGasUnits), ]); return (txValue || 0n) + txGasCost; }
234-238: Optional: include wei fields in onNotEnoughFunds to eliminate downstream parsingPassing BigInt wei alongside human strings avoids repeated string→wei conversions in the UI and prevents precision bugs.
- onNotEnoughFunds: (data: { - requiredAmount: string; - balance: string; - }) => void; + onNotEnoughFunds: (data: { + requiredAmount: string; + balance: string; + requiredWei: bigint; + balanceWei: bigint; + }) => void;- params.onNotEnoughFunds({ - balance: toEther(walletBalance.value), - requiredAmount: toEther(totalCost), - }); + params.onNotEnoughFunds({ + balance: toEther(walletBalance.value), + requiredAmount: toEther(totalCost), + balanceWei: walletBalance.value, + requiredWei: totalCost, + });If you adopt this, the Launch UI amount becomes a simple toEther(requiredWei - balanceWei) without toWei. Based on learnings.
Also applies to: 321-325
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/_common/form.ts(1 hunks)apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/create-nft-page.tsx(6 hunks)apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsx(7 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/_common/form.ts
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity
Re-use shared types from@/typesor localtypes.tsbarrels
Prefer type aliases over interface except for nominal shapes
Avoidanyandunknownunless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial,Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
**/*.{ts,tsx}: Use explicit function declarations and explicit return types in TypeScript
Limit each file to one stateless, single‑responsibility function
Re‑use shared types from@/typeswhere applicable
Prefertypealiases overinterfaceexcept for nominal shapes
Avoidanyandunknownunless unavoidable; narrow generics when possible
Prefer composition over inheritance; use utility types (Partial, Pick, etc.)
Lazy‑import optional features and avoid top‑level side‑effects to reduce bundle size
Files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/create-nft-page.tsxapps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsx
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)
Files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/create-nft-page.tsxapps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsx
apps/{dashboard,playground-web}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
apps/{dashboard,playground-web}/**/*.{ts,tsx}: Import UI primitives from@/components/ui/*(Button, Input, Select, Tabs, Card, Sidebar, Badge, Separator) in dashboard and playground apps
UseNavLinkfor internal navigation with automatic active states in dashboard and playground apps
Use Tailwind CSS only – no inline styles or CSS modules
Usecn()from@/lib/utilsfor conditional class logic
Use design system tokens (e.g.,bg-card,border-border,text-muted-foreground)
Server Components (Node edge): Start files withimport "server-only";
Client Components (browser): Begin files with'use client';
Always callgetAuthToken()to retrieve JWT from cookies on server side
UseAuthorization: Bearerheader – never embed tokens in URLs
Return typed results (e.g.,Project[],User[]) – avoidany
Wrap client-side data fetching calls in React Query (@tanstack/react-query)
Use descriptive, stablequeryKeysfor React Query cache hits
ConfigurestaleTime/cacheTimein React Query based on freshness (default ≥ 60s)
Keep tokens secret via internal API routes or server actions
Never importposthog-jsin server components
Files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/create-nft-page.tsxapps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsx
apps/{dashboard,playground}/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
apps/{dashboard,playground}/**/*.{ts,tsx}: Import UI primitives from@/components/ui/_(e.g., Button, Input, Tabs, Card)
UseNavLinkfor internal navigation to get active state handling
Use Tailwind CSS for styling; no inline styles
Merge class names withcn()from@/lib/utilsfor conditional classes
Stick to design tokens (e.g., bg-card, border-border, text-muted-foreground)
Server Components must start withimport "server-only"; usenext/headers, server‑only env, heavy data fetching, andredirect()where appropriate
Client Components must start with'use client'; handle interactivity with hooks and browser APIs
Server-side data fetching: callgetAuthToken()from cookies, sendAuthorization: Bearer <token>header, and return typed results (avoidany)
Client-side data fetching: wrap calls in React Query with descriptive, stablequeryKeysand set sensiblestaleTime/cacheTime(≥ 60s default); keep tokens secret via internal routes or server actions
Do not importposthog-jsin server components (client-side only)
Files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/create-nft-page.tsxapps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsx
apps/{dashboard,playground}/**/*.tsx
📄 CodeRabbit inference engine (AGENTS.md)
Expose a
classNameprop on the root element of every component
Files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/create-nft-page.tsxapps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsx
🧠 Learnings (6)
📚 Learning: 2025-09-17T11:02:13.528Z
Learnt from: MananTank
PR: thirdweb-dev/js#8044
File: packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-tokens.ts:15-17
Timestamp: 2025-09-17T11:02:13.528Z
Learning: The thirdweb `client` object is serializable and can safely be used in React Query keys, similar to the `contract` object.
Applied to files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/create-nft-page.tsx
📚 Learning: 2025-06-10T00:50:20.795Z
Learnt from: MananTank
PR: thirdweb-dev/js#7315
File: apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/assets/create/nft/launch-nft.tsx:153-226
Timestamp: 2025-06-10T00:50:20.795Z
Learning: In apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/assets/create/nft/launch-nft.tsx, the updateStatus function correctly expects a complete MultiStepState["status"] object. For pending states, { type: "pending" } is the entire status object. For error states, { type: "error", message: React.ReactNode } is the entire status object. The current code incorrectly spreads the entire step object instead of passing just the status object.
Applied to files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsx
📚 Learning: 2025-06-26T19:46:04.024Z
Learnt from: gregfromstl
PR: thirdweb-dev/js#7450
File: packages/thirdweb/src/bridge/Webhook.ts:57-81
Timestamp: 2025-06-26T19:46:04.024Z
Learning: In the onramp webhook schema (`packages/thirdweb/src/bridge/Webhook.ts`), the `currencyAmount` field is intentionally typed as `z.number()` while other amount fields use `z.string()` because `currencyAmount` represents fiat currency amounts in decimals (like $10.50), whereas other amount fields represent token amounts in wei (very large integers that benefit from bigint representation). The different naming convention (`currencyAmount` vs `amount`) reflects this intentional distinction.
Applied to files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsx
📚 Learning: 2025-07-18T19:20:32.530Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*client.tsx : Interactive UI that relies on hooks (`useState`, `useEffect`, React Query, wallet hooks).
Applied to files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsx
📚 Learning: 2025-07-31T16:17:42.753Z
Learnt from: MananTank
PR: thirdweb-dev/js#7768
File: apps/playground-web/src/app/navLinks.ts:1-1
Timestamp: 2025-07-31T16:17:42.753Z
Learning: Configuration files that import and reference React components (like icon components from lucide-react) need the "use client" directive, even if they primarily export static data, because the referenced components need to be executed in a client context when used by other client components.
Applied to files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsx
📚 Learning: 2025-07-18T19:20:32.530Z
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*.{tsx,jsx} : For notices & skeletons rely on `AnnouncementBanner`, `GenericLoadingPage`, `EmptyStateCard`.
Applied to files:
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsx
🧬 Code graph analysis (2)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/create-nft-page.tsx (3)
apps/dashboard/src/@/hooks/useSendTx.ts (1)
useSendAndConfirmTx(9-19)packages/thirdweb/src/exports/thirdweb.ts (3)
PreparedTransaction(179-179)estimateGasCost(154-154)getGasPrice(118-118)packages/thirdweb/src/exports/utils.ts (1)
resolvePromisedValue(198-198)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsx (4)
apps/dashboard/src/@/hooks/chains/v5-adapter.ts (1)
useV5DashboardChain(14-28)apps/dashboard/src/@/utils/sdk-component-theme.ts (1)
getSDKTheme(8-43)apps/dashboard/src/@/components/blocks/multi-step-status/multi-step-status.tsx (1)
MultiStepStatus(27-97)apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/_common/storage-error-upsell.tsx (1)
StorageErrorPlanUpsell(16-123)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Size
- GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/launch/launch-nft.tsx (1)
402-440: Funds UX flow looks solidNice integration of BuyWidget with back/ retry paths and descriptive error content; status model updates are correctly scoped and consistent with MultiStepStatus expectations.
Also applies to: 446-457, 493-526, 538-557
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft/create-nft-page.tsx (1)
297-334: Pre‑batch funds check and error surfacing: solid approachThe total‑cost precheck, descriptive error, and callback for UI handling are well‑structured and keep batching resilient.
Please verify the multicall estimate path on low‑liquidity RPCs (where estimateGas can fail) once with the new fallbackGasUnits to ensure the Buy flow triggers reliably in those environments.

PR-Codex overview
This PR focuses on enhancing the
CreateNFTPageandLaunchNFTcomponents to handle insufficient funds scenarios, including new callbacks and UI elements for notifying users about their balance and required funds. It also introduces gas estimation functions.Detailed summary
onNotEnoughFundscallback to handle insufficient funds inCreateNFTPage.notEnoughFundsstate inLaunchNFTfor user notifications.getTransactionGasCostandgetTotalTransactionCost.Summary by CodeRabbit