From ba43747236d98ab2b0f4c15701959a2aae2367df Mon Sep 17 00:00:00 2001 From: alcercu <333aleix333@gmail.com> Date: Mon, 24 Jun 2024 18:37:33 +0200 Subject: [PATCH 1/2] fix: fail gracefully in case of problems fetching from IPFS --- src/utils/index.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/utils/index.ts b/src/utils/index.ts index 2b1d691..3ddfe18 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -4,9 +4,13 @@ import { isAddress } from "ethers"; export const ipfs = (uri: string) => `${process.env.NEXT_PUBLIC_IPFS_ENDPOINT}${uri}`; -export const ipfsFetcher = async (ipfsURI: string): Promise => { - const res = await axios.get(ipfs(ipfsURI)); - return res.data; +export const ipfsFetcher = async (ipfsURI: string): Promise => { + try { + const res = await axios.get(ipfs(ipfsURI)); + return res.data; + } catch { + return undefined; + } }; export const explorerLink = (address: string) => From 32878be74d30e0490d215f02f7fbc93fe59aba90 Mon Sep 17 00:00:00 2001 From: alcercu <333aleix333@gmail.com> Date: Mon, 24 Jun 2024 18:37:52 +0200 Subject: [PATCH 2/2] fix: account for undefined when fetching from ipfs --- src/app/[lang]/case/[id]/page.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/[lang]/case/[id]/page.tsx b/src/app/[lang]/case/[id]/page.tsx index 7af91ac..d5c711a 100644 --- a/src/app/[lang]/case/[id]/page.tsx +++ b/src/app/[lang]/case/[id]/page.tsx @@ -44,7 +44,7 @@ export default async function Page({ params: { lang, id } }: DisputePageProps) { period={dispute.period} nbChoices={+dispute.nbChoices > 10 ? undefined : +dispute.nbChoices} lastPeriodChange={dispute.lastPeriodChangeTs} - metaEvidence={metaEvidence} + metaEvidence={metaEvidence ?? null} evidenceList={evidence} justifications={justifications} nbJurors={