From 4939210a639d128119286e855af2e5ff4de0390a Mon Sep 17 00:00:00 2001 From: Krystian Fras Date: Tue, 31 Dec 2024 18:28:23 +0100 Subject: [PATCH] fix error handling --- src/components/HostCalls/form.tsx | 61 ------------------------------ src/components/HostCalls/index.tsx | 2 + 2 files changed, 2 insertions(+), 61 deletions(-) delete mode 100644 src/components/HostCalls/form.tsx diff --git a/src/components/HostCalls/form.tsx b/src/components/HostCalls/form.tsx deleted file mode 100644 index f40253c..0000000 --- a/src/components/HostCalls/form.tsx +++ /dev/null @@ -1,61 +0,0 @@ -// import { Button } from "@/components/ui/button"; -// import { Textarea } from "../ui/textarea"; -// import { CheckCircle } from "lucide-react"; -// import { hash, bytes } from "@typeberry/jam-host-calls"; -// import { Storage } from "@/packages/web-worker/types"; -// import { useEffect, useState } from "react"; -// import { logger } from "@/utils/loggerService"; -// import { setHasHostCallOpen, setStorage } from "@/store/debugger/debuggerSlice"; -// import { setAllWorkersStorage } from "@/store/workers/workersSlice"; -// import { useAppDispatch, useAppSelector } from "@/store/hooks"; -// import { TrieInput } from "./trie-input"; - -// const parseJSONToStorage = (value: { [key: string]: string }) => { -// const parsedValue: Storage = new Map(); - -// Object.entries(value).forEach(([key, value]) => { -// parsedValue.set( -// hash.hashBytes(bytes.BytesBlob.blobFromString(key)).toString(), -// bytes.BytesBlob.blobFromString(value), -// ); -// }); - -// return parsedValue; -// }; - -// export const HostCallsForm = (props: { onChange: () }) => { -// const { storage } = useAppSelector((state) => state.debugger); -// const dispatch = useAppDispatch(); -// const [inputValue, setInputValue] = useState(); - -// useEffect(() => { -// setInputValue(storage ? JSON.stringify(Object.fromEntries(storage.entries())) : ""); -// }, [storage]); - -// const onSubmit = async () => { -// try { -// const jsonValue = inputValue ? (JSON.parse(inputValue) as { [key: string]: string }) : {}; -// const parsedValue = parseJSONToStorage(jsonValue); -// dispatch(setStorage(parsedValue)); -// await dispatch(setAllWorkersStorage()).unwrap(); -// dispatch(setHasHostCallOpen(false)); -// props.onAfterSubmit?.(); - -// // dispatch(setIsDebugFinished(false)); -// // await dispatch(stepAllWorkers()).unwrap(); -// } catch (error) { -// logger.error("Wrong JSON", { error }); -// } -// }; - -// return ( -//
-// Storage Value -// -// Set storage for read & write host calls. Confirm empty, if you want to process. Storage can be modified by -// running program. -// -// console.log(v)} /> -//
-// ); -// }; diff --git a/src/components/HostCalls/index.tsx b/src/components/HostCalls/index.tsx index a2537b6..a0f9c71 100644 --- a/src/components/HostCalls/index.tsx +++ b/src/components/HostCalls/index.tsx @@ -40,6 +40,8 @@ export const HostCalls = () => { }, [storage]); const onSubmit = async () => { + setError(""); + try { dispatch(setStorage(newStorage || [])); await dispatch(setAllWorkersStorage()).unwrap();