Skip to content

Commit 9e9c0d2

Browse files
committed
fix batching claim conditions
1 parent 9758608 commit 9e9c0d2

File tree

4 files changed

+37
-34
lines changed

4 files changed

+37
-34
lines changed

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/assets/create/nft/_common/form.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,11 @@ export type CreateNFTCollectionFunctions = {
4949
contractAddress: string;
5050
}>;
5151
setClaimConditions: (params: {
52-
nftCollectionInfo: NFTCollectionInfoFormValues;
53-
nftBatch: NFTMetadataWithPrice[];
52+
values: CreateNFTCollectionAllValues;
53+
batch: {
54+
startIndex: number;
55+
endIndex: number;
56+
};
5457
}) => Promise<void>;
5558
lazyMintNFTs: (values: CreateNFTCollectionAllValues) => Promise<void>;
5659
};

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/assets/create/nft/create-nft-page.tsx

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,12 @@ import { useActiveAccount } from "thirdweb/react";
2424
import { maxUint256 } from "thirdweb/utils";
2525
import { parseError } from "utils/errorParser";
2626
import { useAddContractToProject } from "../../../hooks/project-contracts";
27-
import type {
28-
CreateNFTCollectionAllValues,
29-
NFTCollectionInfoFormValues,
30-
} from "./_common/form";
27+
import type { CreateNFTCollectionAllValues } from "./_common/form";
3128
import {
3229
getNFTDeploymentTrackingData,
3330
getNFTStepTrackingData,
3431
} from "./_common/tracking";
3532
import { CreateNFTPageUI } from "./create-nft-page-ui";
36-
import type { NFTMetadataWithPrice } from "./upload-nfts/batch-upload/process-files";
3733

3834
export function CreateNFTPage(props: {
3935
accountAddress: string;
@@ -336,34 +332,37 @@ export function CreateNFTPage(props: {
336332
}
337333

338334
async function handleSetClaimConditionsERC1155(params: {
339-
nftCollectionInfo: NFTCollectionInfoFormValues;
340-
nftBatch: NFTMetadataWithPrice[];
335+
values: CreateNFTCollectionAllValues;
336+
batch: {
337+
startIndex: number;
338+
endIndex: number;
339+
};
341340
}) {
342-
const { nftCollectionInfo, nftBatch } = params;
341+
const { values, batch } = params;
343342
const { contract, activeAccount } = getContractAndAccount({
344-
chain: nftCollectionInfo.chain,
343+
chain: values.collectionInfo.chain,
345344
});
346345

347-
const nfts = nftBatch;
346+
const nfts = values.nfts.slice(batch.startIndex, batch.endIndex);
348347

349348
// fetch nfts
350349
const fetchedNFTs = await getNFTs1155({
351350
contract,
352-
start: 0,
351+
start: batch.startIndex,
352+
count: batch.endIndex - batch.startIndex,
353353
});
354354

355-
const transactions = nfts.map((uploadedNFT, nftIndex) => {
356-
const fetchedNFT =
357-
fetchedNFTs.find(
358-
(nft) =>
359-
nft.metadata.name === uploadedNFT.name &&
360-
nft.metadata.description === uploadedNFT.description,
361-
) || fetchedNFTs[nftIndex];
355+
const transactions = nfts.map((uploadedNFT, i) => {
356+
const fetchedNFT = fetchedNFTs[i];
362357

363358
if (!fetchedNFT) {
364359
throw new Error("Failed to find NFT");
365360
}
366361

362+
if (fetchedNFT.metadata.name !== uploadedNFT.name) {
363+
throw new Error("Failed to find NFT in batch");
364+
}
365+
367366
return setClaimConditions1155({
368367
contract,
369368
tokenId: fetchedNFT.id,
@@ -395,7 +394,7 @@ export function CreateNFTPage(props: {
395394
getNFTStepTrackingData({
396395
action: "claim-conditions",
397396
ercType: "erc1155",
398-
chainId: Number(nftCollectionInfo.chain),
397+
chainId: Number(values.collectionInfo.chain),
399398
status: "attempt",
400399
}),
401400
);
@@ -410,7 +409,7 @@ export function CreateNFTPage(props: {
410409
getNFTStepTrackingData({
411410
action: "claim-conditions",
412411
ercType: "erc1155",
413-
chainId: Number(nftCollectionInfo.chain),
412+
chainId: Number(values.collectionInfo.chain),
414413
status: "success",
415414
}),
416415
);
@@ -423,7 +422,7 @@ export function CreateNFTPage(props: {
423422
getNFTStepTrackingData({
424423
action: "claim-conditions",
425424
ercType: "erc1155",
426-
chainId: Number(nftCollectionInfo.chain),
425+
chainId: Number(values.collectionInfo.chain),
427426
status: "error",
428427
errorMessage,
429428
}),
@@ -456,8 +455,8 @@ export function CreateNFTPage(props: {
456455
ercType: "erc1155",
457456
});
458457
},
459-
setClaimConditions: async (formValues) => {
460-
return handleSetClaimConditionsERC1155(formValues);
458+
setClaimConditions: async (params) => {
459+
return handleSetClaimConditionsERC1155(params);
461460
},
462461
},
463462
erc721: {

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/assets/create/nft/launch/launch-nft.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ export function LaunchNFT(props: {
164164
if (ercType === "erc721") {
165165
await props.createNFTFunctions.erc721.setClaimConditions(formValues);
166166
} else {
167-
const { nfts, collectionInfo } = formValues;
168167
if (batchCount > 1) {
169168
const batchStartIndex = batchesProcessedRef.current;
170169
for (
@@ -184,19 +183,22 @@ export function LaunchNFT(props: {
184183
}
185184

186185
await props.createNFTFunctions.erc1155.setClaimConditions({
187-
nftCollectionInfo: collectionInfo,
188-
nftBatch: nfts.slice(
189-
batchIndex * batchSize,
190-
(batchIndex + 1) * batchSize,
191-
),
186+
values: formValues,
187+
batch: {
188+
startIndex: batchIndex * batchSize,
189+
endIndex: (batchIndex + 1) * batchSize,
190+
},
192191
});
193192

194193
batchesProcessedRef.current += 1;
195194
}
196195
} else {
197196
await props.createNFTFunctions.erc1155.setClaimConditions({
198-
nftCollectionInfo: collectionInfo,
199-
nftBatch: nfts,
197+
values: formValues,
198+
batch: {
199+
startIndex: 0,
200+
endIndex: formValues.nfts.length - 1,
201+
},
200202
});
201203
}
202204
}

apps/dashboard/src/components/shared/FileInput.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ interface IFileInputProps {
2626
children?: React.ReactNode;
2727
className?: string;
2828
disableHelperText?: boolean;
29-
// fileUrl?: string;
3029
client: ThirdwebClient;
3130
}
3231

0 commit comments

Comments
 (0)