From 67c3d861fe42103392086e233ba4e633cb6c69a9 Mon Sep 17 00:00:00 2001 From: MananTank Date: Mon, 7 Jul 2025 14:15:01 +0000 Subject: [PATCH] [TOOL-4986] Dashboard: Fix ERC20 asset page crash (#7541) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ## PR-Codex overview This PR focuses on improving error handling by adding `try-catch` blocks around asynchronous calls in the `getContractCreator` function. This change ensures that if an error occurs during the execution of `owner` or `getRoleMember`, the function will return `null` instead of throwing an unhandled error. ### Detailed summary - Wrapped the calls to `owner` and `getRoleMember` in a `try-catch` block. - Changed the calls to `owner` and `getRoleMember` to use `await` for proper asynchronous handling. - Ensured that if an error occurs, the function returns `null` instead of failing silently. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` ## Summary by CodeRabbit * **Bug Fixes** * Improved error handling when retrieving contract creator information, ensuring failures no longer cause crashes and instead return a safe null value. --- .../_components/getContractCreator.tsx | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/_components/getContractCreator.tsx b/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/_components/getContractCreator.tsx index 9a4e67ed3b2..4b1a24a1464 100644 --- a/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/_components/getContractCreator.tsx +++ b/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/_components/getContractCreator.tsx @@ -9,19 +9,23 @@ export async function getContractCreator( contract: ThirdwebContract, functionSelectors: string[], ) { - if (isOwnerSupported(functionSelectors)) { - return owner({ - contract, - }); - } + try { + if (isOwnerSupported(functionSelectors)) { + return await owner({ + contract, + }); + } - if (isGetRoleAdminSupported(functionSelectors)) { - return getRoleMember({ - contract, - index: BigInt(0), - role: "admin", - }); - } + if (isGetRoleAdminSupported(functionSelectors)) { + return await getRoleMember({ + contract, + index: BigInt(0), + role: "admin", + }); + } - return null; + return null; + } catch { + return null; + } }