Skip to content

Commit e0ab3d5

Browse files
committed
Dashboard: Fix NFT Collection creation error reported twice (#7868)
<!-- ## 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 refactoring the `CreateNFTPage` component in `create-nft-page.tsx` to streamline contract deployment processes and improve error handling by removing redundant code and optimizing the reporting of contract deployment. ### Detailed summary - Removed the import of `reportAssetCreationFailed`. - Simplified the contract deployment logic for `erc721` and `erc1155`. - Moved the `reportContractDeployed` call directly after contract creation. - Eliminated redundant error handling in several transaction functions. - Updated calls to `sendAndConfirmTransaction` to remove try-catch blocks. > ✨ 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 - None - Refactor - Streamlined NFT creation flows for a smoother experience: deterministic ERC721/ERC1155 deployment, simplified lazy minting, claim condition setup, and admin assignment. - Contracts are automatically linked to the project in the background after deployment. - Chores - Improved post-deployment tracking by recording deployed contract details (address, chain, name, type, publisher) for better observability. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 2c7d841 commit e0ab3d5

File tree

1 file changed

+72
-148
lines changed
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/tokens/create/nft

1 file changed

+72
-148
lines changed

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

Lines changed: 72 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,9 @@ import { useActiveAccount } from "thirdweb/react";
2323
import { maxUint256 } from "thirdweb/utils";
2424
import { create7702MinimalAccount } from "thirdweb/wallets/smart";
2525
import { revalidatePathAction } from "@/actions/revalidate";
26-
import {
27-
reportAssetCreationFailed,
28-
reportContractDeployed,
29-
} from "@/analytics/report";
26+
import { reportContractDeployed } from "@/analytics/report";
3027
import type { Team } from "@/api/team/get-team";
3128
import { useAddContractToProject } from "@/hooks/project-contracts";
32-
import { parseError } from "@/utils/errorParser";
3329
import type { CreateNFTCollectionAllValues } from "./_common/form";
3430
import { CreateNFTPageUI } from "./create-nft-page-ui";
3531

@@ -96,81 +92,67 @@ export function CreateNFTPage(props: {
9692
// eslint-disable-next-line no-restricted-syntax
9793
const chain = defineChain(Number(collectionInfo.chain));
9894

99-
try {
100-
let contractAddress: string;
101-
102-
if (ercType === "erc721") {
103-
contractAddress = await deployERC721Contract({
104-
account,
105-
chain: chain,
106-
client: props.client,
107-
params: {
108-
description: collectionInfo.description,
109-
image: collectionInfo.image,
110-
name: collectionInfo.name,
111-
royaltyBps: BigInt(sales.royaltyBps),
112-
royaltyRecipient: sales.royaltyRecipient,
113-
saleRecipient: sales.primarySaleRecipient,
114-
social_urls: transformSocialUrls(collectionInfo.socialUrls),
115-
symbol: collectionInfo.symbol,
116-
},
117-
type: "DropERC721",
118-
});
119-
} else {
120-
contractAddress = await deployERC1155Contract({
121-
account,
122-
chain: chain,
123-
client: props.client,
124-
params: {
125-
description: collectionInfo.description,
126-
image: collectionInfo.image,
127-
name: collectionInfo.name,
128-
royaltyBps: BigInt(sales.royaltyBps),
129-
royaltyRecipient: sales.royaltyRecipient,
130-
saleRecipient: sales.primarySaleRecipient,
131-
social_urls: transformSocialUrls(collectionInfo.socialUrls),
132-
symbol: collectionInfo.symbol,
133-
},
134-
type: "DropERC1155",
135-
});
136-
}
95+
let contractAddress: string;
13796

138-
reportContractDeployed({
139-
address: contractAddress,
140-
chainId: Number(collectionInfo.chain),
141-
contractName: contractType,
142-
deploymentType: "asset",
143-
publisher: "deployer.thirdweb.eth",
97+
if (ercType === "erc721") {
98+
contractAddress = await deployERC721Contract({
99+
account,
100+
chain: chain,
101+
client: props.client,
102+
params: {
103+
description: collectionInfo.description,
104+
image: collectionInfo.image,
105+
name: collectionInfo.name,
106+
royaltyBps: BigInt(sales.royaltyBps),
107+
royaltyRecipient: sales.royaltyRecipient,
108+
saleRecipient: sales.primarySaleRecipient,
109+
social_urls: transformSocialUrls(collectionInfo.socialUrls),
110+
symbol: collectionInfo.symbol,
111+
},
112+
type: "DropERC721",
113+
});
114+
} else {
115+
contractAddress = await deployERC1155Contract({
116+
account,
117+
chain: chain,
118+
client: props.client,
119+
params: {
120+
description: collectionInfo.description,
121+
image: collectionInfo.image,
122+
name: collectionInfo.name,
123+
royaltyBps: BigInt(sales.royaltyBps),
124+
royaltyRecipient: sales.royaltyRecipient,
125+
saleRecipient: sales.primarySaleRecipient,
126+
social_urls: transformSocialUrls(collectionInfo.socialUrls),
127+
symbol: collectionInfo.symbol,
128+
},
129+
type: "DropERC1155",
144130
});
131+
}
145132

146-
contractAddressRef.current = contractAddress;
133+
reportContractDeployed({
134+
address: contractAddress,
135+
chainId: Number(collectionInfo.chain),
136+
contractName: contractType,
137+
deploymentType: "asset",
138+
publisher: "deployer.thirdweb.eth",
139+
});
147140

148-
// add contract to project in background
149-
addContractToProject.mutateAsync({
150-
chainId: collectionInfo.chain,
151-
contractAddress: contractAddress,
152-
contractType: ercType === "erc721" ? "DropERC721" : "DropERC1155",
153-
deploymentType: "asset",
154-
projectId: props.projectId,
155-
teamId: props.teamId,
156-
});
141+
contractAddressRef.current = contractAddress;
157142

158-
return {
159-
contractAddress,
160-
};
161-
} catch (error) {
162-
const errorMessage = parseError(error);
163-
console.error(errorMessage);
164-
165-
reportAssetCreationFailed({
166-
assetType: "nft",
167-
contractType,
168-
error: errorMessage,
169-
step: "deploy-contract",
170-
});
143+
// add contract to project in background
144+
addContractToProject.mutateAsync({
145+
chainId: collectionInfo.chain,
146+
contractAddress: contractAddress,
147+
contractType: ercType === "erc721" ? "DropERC721" : "DropERC1155",
148+
deploymentType: "asset",
149+
projectId: props.projectId,
150+
teamId: props.teamId,
151+
});
171152

172-
throw error;
173-
}
153+
return {
154+
contractAddress,
155+
};
174156
}
175157

176158
async function handleLazyMintNFTs(params: {
@@ -179,8 +161,6 @@ export function CreateNFTPage(props: {
179161
gasless: boolean;
180162
}) {
181163
const { values, ercType } = params;
182-
const contractType =
183-
ercType === "erc721" ? ("DropERC721" as const) : ("DropERC1155" as const);
184164

185165
const contract = getDeployedContract({
186166
chain: values.collectionInfo.chain,
@@ -197,24 +177,10 @@ export function CreateNFTPage(props: {
197177
nfts: values.nfts,
198178
});
199179

200-
try {
201-
await sendAndConfirmTransaction({
202-
account,
203-
transaction,
204-
});
205-
} catch (error) {
206-
const errorMessage = parseError(error);
207-
console.error(error);
208-
209-
reportAssetCreationFailed({
210-
assetType: "nft",
211-
contractType,
212-
error: errorMessage,
213-
step: "mint-nfts",
214-
});
215-
216-
throw error;
217-
}
180+
await sendAndConfirmTransaction({
181+
account,
182+
transaction,
183+
});
218184
}
219185

220186
async function handleSetClaimConditionsERC721(params: {
@@ -251,24 +217,10 @@ export function CreateNFTPage(props: {
251217
],
252218
});
253219

254-
try {
255-
await sendAndConfirmTransaction({
256-
account,
257-
transaction,
258-
});
259-
} catch (error) {
260-
const errorMessage = parseError(error);
261-
console.error(errorMessage);
262-
263-
reportAssetCreationFailed({
264-
assetType: "nft",
265-
contractType: "DropERC721",
266-
error: errorMessage,
267-
step: "set-claim-conditions",
268-
});
269-
270-
throw error;
271-
}
220+
await sendAndConfirmTransaction({
221+
account,
222+
transaction,
223+
});
272224
}
273225

274226
async function handleSetClaimConditionsERC1155(params: {
@@ -336,24 +288,10 @@ export function CreateNFTPage(props: {
336288
data: encodedTransactions,
337289
});
338290

339-
try {
340-
await sendAndConfirmTransaction({
341-
account,
342-
transaction: tx,
343-
});
344-
} catch (error) {
345-
const errorMessage = parseError(error);
346-
console.error(errorMessage);
347-
348-
reportAssetCreationFailed({
349-
assetType: "nft",
350-
contractType: "DropERC1155",
351-
error: errorMessage,
352-
step: "set-claim-conditions",
353-
});
354-
355-
throw error;
356-
}
291+
await sendAndConfirmTransaction({
292+
account,
293+
transaction: tx,
294+
});
357295
}
358296

359297
async function handleSetAdmins(params: {
@@ -395,24 +333,10 @@ export function CreateNFTPage(props: {
395333
data: encodedTxs,
396334
});
397335

398-
try {
399-
await sendAndConfirmTransaction({
400-
account,
401-
transaction: tx,
402-
});
403-
} catch (e) {
404-
const errorMessage = parseError(e);
405-
console.error(errorMessage);
406-
407-
reportAssetCreationFailed({
408-
assetType: "nft",
409-
contractType: params.contractType,
410-
error: errorMessage,
411-
step: "set-admins",
412-
});
413-
414-
throw e;
415-
}
336+
await sendAndConfirmTransaction({
337+
account,
338+
transaction: tx,
339+
});
416340
}
417341

418342
return (

0 commit comments

Comments
 (0)