From 09b740498503b1ed035a5d7447f32c495bd80f62 Mon Sep 17 00:00:00 2001 From: MananTank Date: Wed, 23 Oct 2024 16:52:10 +0000 Subject: [PATCH] Show 404 on deprecated chain contract page (#5139) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Problem solved Short description of the bug fixed or feature added --- ## PR-Codex overview This PR focuses on improving the handling of contract metadata and checking for deprecated chains in the `layout.tsx` file. It ensures that the correct contract information is used and adds a condition to handle deprecated chain statuses. ### Detailed summary - Added a check for `chainMetadata.status` to call `notFound()` if the status is "deprecated". - Updated the `isValidContract` check to use `contract` from `info` instead of the previous variable. - Rearranged the destructuring of `contract` and `chainMetadata` for clarity. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` --- .../(chain)/[chain_id]/[contractAddress]/layout.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/layout.tsx b/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/layout.tsx index da83be77f27..0d2025f47eb 100644 --- a/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/layout.tsx +++ b/apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/layout.tsx @@ -28,14 +28,19 @@ export default async function Layout(props: { return ; } + const { contract, chainMetadata } = info; + + if (chainMetadata.status === "deprecated") { + notFound(); + } + // check if the contract exists - const isValidContract = await isContractDeployed(info.contract); + const isValidContract = await isContractDeployed(contract); if (!isValidContract) { // TODO - replace 404 with a better page to upsale deploy or other thirdweb products notFound(); } - const { contract, chainMetadata } = info; const contractPageMetadata = await getContractPageMetadata(contract); const sidebarLinks = getContractPageSidebarLinks({ chainSlug: chainMetadata.slug,