From ca23ddc1ff1174244f592b1c1d75b986efbec82f Mon Sep 17 00:00:00 2001 From: Tifa Date: Tue, 2 Apr 2024 10:10:22 +0700 Subject: [PATCH] fix: decode uplc crash app --- src/components/Contracts/UPLCTree/index.tsx | 9 +++++++++ src/components/Contracts/common/CompiledCodeDataCard.tsx | 9 +++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/components/Contracts/UPLCTree/index.tsx b/src/components/Contracts/UPLCTree/index.tsx index cbf584de1c..b1525f8606 100644 --- a/src/components/Contracts/UPLCTree/index.tsx +++ b/src/components/Contracts/UPLCTree/index.tsx @@ -3,6 +3,7 @@ import { useTheme } from "@emotion/react"; import { CloseSquareIcon, MinusSquareIcon, PlusSquareIcon } from "src/commons/resources"; import { UPLCData, UPLCProgram } from "src/types/uplc"; +import NotAvailable from "src/components/commons/NotAvailable"; import { StyledTreeItem, TreeContainer } from "./styles"; @@ -43,6 +44,14 @@ export const UPLCTree: React.FC = ({ uplc }) => { return nodeIds; }; + if (!uplc.version.major) { + return ( + <> + + + ); + } + return ( } diff --git a/src/components/Contracts/common/CompiledCodeDataCard.tsx b/src/components/Contracts/common/CompiledCodeDataCard.tsx index 8c7e15a74b..07fc291d78 100644 --- a/src/components/Contracts/common/CompiledCodeDataCard.tsx +++ b/src/components/Contracts/common/CompiledCodeDataCard.tsx @@ -31,8 +31,13 @@ const CompiledCodeDataCard: React.FC = ({ value, titl const { t } = useTranslation(); const [checked, setChecked] = useState(false); const [uplc, setUplc] = useState(); - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const str = (window as any).decodeUPLC(`${value}`); + let str = ""; + try { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + str = (window as any).decodeUPLC(`${value}`); + } catch (error) { + /* empty */ + } const version = str .substring(0, findSecondIndex(str, "("))