Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type Options =
};

export async function getClaimPhasesInLegacyFormat(
options: BaseTransactionOptions<Options>,
options: BaseTransactionOptions<Options> & { isMultiPhase: boolean },
): Promise<CombinedClaimCondition[]> {
const conditions = await (async () => {
switch (options.type) {
Expand All @@ -64,7 +64,10 @@ export async function getClaimPhasesInLegacyFormat(
case "erc721":
return ERC721Ext.getClaimConditions(options);
case "erc1155":
return ERC1155Ext.getClaimConditions(options);
return ERC1155Ext.getClaimConditions({
...options,
singlePhaseDrop: !options.isMultiPhase,
});
}
})();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ export const ClaimConditionsForm: React.FC<ClaimConditionsFormProps> = ({

const claimConditionsQuery = useReadContract(getClaimPhasesInLegacyFormat, {
contract,
isMultiPhase,
...(isErc20
? { type: "erc20", decimals: tokenDecimals.data }
: isErc721
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,36 @@ export type GetClaimConditionsParams = {
* ```
*/
export async function getClaimConditions(
options: BaseTransactionOptions<GetClaimConditionsParams>,
options: BaseTransactionOptions<GetClaimConditionsParams> & {
singlePhaseDrop?: boolean;
},
): Promise<ClaimCondition[]> {
const [multi, single] = await Promise.allSettled([
(async () => {
try {
if (options.singlePhaseDrop) {
return SinglePhase.claimCondition(options).then(
([
startTimestamp,
maxClaimableSupply,
supplyClaimed,
quantityLimitPerWallet,
merkleRoot,
pricePerToken,
currency,
metadata,
]) => [
{
startTimestamp,
maxClaimableSupply,
supplyClaimed,
quantityLimitPerWallet,
merkleRoot,
pricePerToken,
currency,
metadata,
},
],
);
} else {
const [startId, count] = await MultiPhase.claimCondition(options);

const conditionPromises: Array<
Expand All @@ -38,37 +64,10 @@ export async function getClaimConditions(
);
}
return Promise.all(conditionPromises);
})(),
SinglePhase.claimCondition(options).then(
([
startTimestamp,
maxClaimableSupply,
supplyClaimed,
quantityLimitPerWallet,
merkleRoot,
pricePerToken,
currency,
metadata,
]) => ({
startTimestamp,
maxClaimableSupply,
supplyClaimed,
quantityLimitPerWallet,
merkleRoot,
pricePerToken,
currency,
metadata,
}),
),
]);
if (multi.status === "fulfilled") {
return multi.value;
}
} catch {
throw new Error("Claim condition not found");
}
if (single.status === "fulfilled") {
return [single.value];
}

throw new Error("Claim condition not found");
}

/**
Expand Down
Loading