Skip to content

Commit e50cd98

Browse files
committed
Catch fetchDeployMetadata error and redirect to 404
1 parent e4b4008 commit e50cd98

File tree

2 files changed

+12
-2
lines changed
  • apps/dashboard/src/app/(dashboard)/contracts

2 files changed

+12
-2
lines changed

apps/dashboard/src/app/(dashboard)/contracts/deploy/[compiler_uri]/page.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { getThirdwebClient } from "@/constants/thirdweb.server";
2+
import { notFound } from "next/navigation";
23
import { fetchDeployMetadata } from "thirdweb/contract";
34
import { DeployContractInfo } from "../../../published-contract/components/contract-info";
45
import { DeployFormForUri } from "../../../published-contract/components/uri-based-deploy";
@@ -16,7 +17,12 @@ export default async function DirectDeployPage(props: DirectDeployPageProps) {
1617
client: getThirdwebClient(),
1718
// force `ipfs://` prefix
1819
uri: parsedUri.startsWith("ipfs://") ? parsedUri : `ipfs://${parsedUri}`,
19-
});
20+
}).catch(() => null);
21+
22+
if (!metadata) {
23+
return notFound();
24+
}
25+
2026
return (
2127
<div className="container flex flex-col gap-4 py-8">
2228
<DeployContractInfo

apps/dashboard/src/app/(dashboard)/contracts/publish/[publish_uri]/page.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ export default async function PublishContractPage(
2525
const publishMetadataFromUri = await fetchDeployMetadata({
2626
uri: publishUri,
2727
client: getThirdwebClient(),
28-
});
28+
}).catch(() => null);
29+
30+
if (!publishMetadataFromUri) {
31+
notFound();
32+
}
2933

3034
let publishMetadata = publishMetadataFromUri;
3135

0 commit comments

Comments
 (0)