Skip to content

Commit 67c3d86

Browse files
committed
[TOOL-4986] Dashboard: Fix ERC20 asset page crash (#7541)
<!-- ## 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 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}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## 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. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent d2c12cc commit 67c3d86

File tree

1 file changed

+17
-13
lines changed
  • apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/_components

1 file changed

+17
-13
lines changed

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/_components/getContractCreator.tsx

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,23 @@ export async function getContractCreator(
99
contract: ThirdwebContract,
1010
functionSelectors: string[],
1111
) {
12-
if (isOwnerSupported(functionSelectors)) {
13-
return owner({
14-
contract,
15-
});
16-
}
12+
try {
13+
if (isOwnerSupported(functionSelectors)) {
14+
return await owner({
15+
contract,
16+
});
17+
}
1718

18-
if (isGetRoleAdminSupported(functionSelectors)) {
19-
return getRoleMember({
20-
contract,
21-
index: BigInt(0),
22-
role: "admin",
23-
});
24-
}
19+
if (isGetRoleAdminSupported(functionSelectors)) {
20+
return await getRoleMember({
21+
contract,
22+
index: BigInt(0),
23+
role: "admin",
24+
});
25+
}
2526

26-
return null;
27+
return null;
28+
} catch {
29+
return null;
30+
}
2731
}

0 commit comments

Comments
 (0)