Skip to content

Commit 2a27e74

Browse files
committed
Update
1 parent 519349b commit 2a27e74

File tree

2 files changed

+31
-4
lines changed
  • apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/claim-conditions/claim-conditions-form

2 files changed

+31
-4
lines changed

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/claim-conditions/claim-conditions-form/hooks.ts

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
type BaseTransactionOptions,
33
type ThirdwebClient,
44
toTokens,
5+
toUnits,
56
} from "thirdweb";
67
import type { OverrideEntry } from "thirdweb/dist/types/utils/extensions/drops/types";
78
import type { Prettify } from "thirdweb/dist/types/utils/type-utils";
@@ -107,15 +108,41 @@ export async function getClaimPhasesInLegacyFormat(
107108

108109
type PhaseInput = z.input<typeof LegacyClaimConditionInputSchema>;
109110

110-
export function setClaimPhasesTx(
111+
export async function setClaimPhasesTx(
111112
baseOptions: BaseTransactionOptions<Options>,
112113
rawPhases: PhaseInput[],
113114
) {
115+
const tokenDecimals =
116+
baseOptions.type === "erc20"
117+
? await ERC20Ext.decimals({
118+
contract: baseOptions.contract,
119+
}).catch(() => 0)
120+
: 0;
114121
const phases = rawPhases.map((phase) => {
122+
let _maxClaimable = toBigInt(phase.maxClaimableSupply);
123+
if (typeof _maxClaimable === "bigint" && _maxClaimable !== maxUint256) {
124+
_maxClaimable = toUnits(String(_maxClaimable), tokenDecimals);
125+
}
126+
let _maxClaimablePerWallet = toBigInt(phase.maxClaimablePerWallet);
127+
if (
128+
typeof _maxClaimablePerWallet === "bigint" &&
129+
_maxClaimablePerWallet !== maxUint256
130+
) {
131+
_maxClaimablePerWallet = toUnits(
132+
String(_maxClaimablePerWallet),
133+
tokenDecimals,
134+
);
135+
}
115136
return {
116137
startTime: toDate(phase.startTime),
117-
maxClaimableSupply: toBigInt(phase.maxClaimableSupply),
118-
maxClaimablePerWallet: toBigInt(phase.maxClaimablePerWallet),
138+
maxClaimableSupply:
139+
baseOptions.type === "erc20"
140+
? _maxClaimable
141+
: toBigInt(phase.maxClaimableSupply),
142+
maxClaimablePerWallet:
143+
baseOptions.type === "erc20"
144+
? _maxClaimablePerWallet
145+
: toBigInt(phase.maxClaimablePerWallet),
119146
merkleRootHash: phase.merkleRootHash as string | undefined,
120147
overrideList: phase.snapshot?.length
121148
? snapshotToOverrides(phase.snapshot)

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/_components/claim-conditions/claim-conditions-form/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ export const ClaimConditionsForm: React.FC<ClaimConditionsFormProps> = ({
355355
});
356356

357357
try {
358-
const tx = setClaimPhasesTx(
358+
const tx = await setClaimPhasesTx(
359359
{
360360
contract,
361361
...(isErc20

0 commit comments

Comments
 (0)