Skip to content

Commit eaeb532

Browse files
committed
Show 404 on invalid contract address in contract page (#5140)
## Problem solved Short description of the bug fixed or feature added <!-- start pr-codex --> --- ## PR-Codex overview This PR enhances the `Layout` component by adding a validation check to ensure that the `contractAddress` parameter is a valid address using `isAddress`. If the address is invalid, it returns a "not found" response. ### Detailed summary - Imported `isAddress` from `thirdweb/utils`. - Added a check to validate `props.params.contractAddress` using `isAddress`. - If the address is invalid, the function returns `notFound()`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 09b7404 commit eaeb532

File tree

1 file changed

+5
-1
lines changed
  • apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]

1 file changed

+5
-1
lines changed

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/layout.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { DeprecatedAlert } from "components/shared/DeprecatedAlert";
55
import type { Metadata } from "next";
66
import { notFound } from "next/navigation";
77
import { getContractMetadata } from "thirdweb/extensions/common";
8-
import { isContractDeployed } from "thirdweb/utils";
8+
import { isAddress, isContractDeployed } from "thirdweb/utils";
99
import { resolveFunctionSelectors } from "../../../../../lib/selectors";
1010
import { shortenIfAddress } from "../../../../../utils/usedapp-external";
1111
import { ConfigureCustomChain } from "./ConfigureCustomChain";
@@ -22,6 +22,10 @@ export default async function Layout(props: {
2222
};
2323
children: React.ReactNode;
2424
}) {
25+
if (!isAddress(props.params.contractAddress)) {
26+
return notFound();
27+
}
28+
2529
const info = await getContractPageParamsInfo(props.params);
2630

2731
if (!info) {

0 commit comments

Comments
 (0)