Skip to content

Commit dbc0316

Browse files
committed
[TOOL-4867] Dashboard: Fix Coin asset page crash on "unlimited" maxClaimableSupply (#7457)
<!-- ## 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 focuses on updating the handling of the `totalSupply` property in the `SupplyClaimedProgress` component and related files to support the string value `"unlimited"` instead of using a constant value from `thirdweb/utils`. ### Detailed summary - Changed `totalSupply` type from `bigint` to `bigint | "unlimited"` in `SupplyClaimedProgress`. - Updated the condition to check for `"unlimited"` instead of `maxUint256`. - Modified the story for `SupplyClaimedProgress` to use `"unlimited"` instead of `maxUint256`. - Adjusted `totalSupply` handling in `TokenDropClaim` to return `"unlimited"` if `maxClaimableSupply` equals `maxUint256`. > ✨ 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** * Updated the supply progress display to clearly indicate when the total supply is unlimited. * **Refactor** * Improved internal handling and representation of unlimited supply for better clarity in the UI. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 5640d48 commit dbc0316

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/_components/supply-claimed-progress.stories.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { Meta, StoryObj } from "@storybook/nextjs";
2-
import { maxUint256 } from "thirdweb/utils";
3-
import { BadgeContainer } from "../../../../../../../../@/storybook/utils";
2+
import { BadgeContainer } from "@/storybook/utils";
43
import { SupplyClaimedProgress } from "./supply-claimed-progress";
54

65
const meta = {
@@ -19,7 +18,7 @@ function StoryVariants() {
1918
return (
2019
<div className="container max-w-md space-y-10 py-10">
2120
<BadgeContainer label="10 / Unlimited Supply">
22-
<SupplyClaimedProgress claimedSupply={10n} totalSupply={maxUint256} />
21+
<SupplyClaimedProgress claimedSupply={10n} totalSupply="unlimited" />
2322
</BadgeContainer>
2423

2524
<BadgeContainer label="500/1000 Supply">

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/_components/supply-claimed-progress.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import { InfinityIcon } from "lucide-react";
2-
import { maxUint256 } from "thirdweb/utils";
32
import { Progress } from "@/components/ui/progress";
43
import { supplyFormatter } from "../nft/format";
54

65
export function SupplyClaimedProgress(props: {
76
claimedSupply: bigint;
8-
totalSupply: bigint;
7+
totalSupply: bigint | "unlimited";
98
}) {
109
// if total supply is unlimited
11-
if (props.totalSupply === maxUint256) {
10+
if (props.totalSupply === "unlimited") {
1211
return (
1312
<p className="flex items-center justify-between gap-2">
1413
<span className="font-medium text-sm">Claimed Supply </span>

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/erc20/_components/claim-tokens/claim-tokens-ui.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
getApprovalForTransaction,
2727
} from "thirdweb/extensions/erc20";
2828
import { useActiveAccount, useSendTransaction } from "thirdweb/react";
29-
import { getClaimParams } from "thirdweb/utils";
29+
import { getClaimParams, maxUint256 } from "thirdweb/utils";
3030
import {
3131
reportAssetBuyFailed,
3232
reportAssetBuySuccessful,
@@ -328,9 +328,16 @@ export function TokenDropClaim(props: {
328328
claimedSupply={BigInt(
329329
toTokens(props.claimCondition.supplyClaimed, props.decimals),
330330
)}
331-
totalSupply={BigInt(
332-
toTokens(props.claimCondition.maxClaimableSupply, props.decimals),
333-
)}
331+
totalSupply={
332+
props.claimCondition.maxClaimableSupply === maxUint256
333+
? "unlimited"
334+
: BigInt(
335+
toTokens(
336+
props.claimCondition.maxClaimableSupply,
337+
props.decimals,
338+
),
339+
)
340+
}
334341
/>
335342

336343
<div className="h-4" />

0 commit comments

Comments
 (0)