"use client"; import { lazy, useEffect, useState } from "react"; import type { NextPage } from "next"; import { notification } from "~~/utils/scaffold-eth"; import { getMetadataFromIPFS } from "~~/utils/tokenization/ipfs-fetch"; const LazyReactJson = lazy(() => import("react-json-view")); const IpfsDownload: NextPage = () => { const [yourJSON, setYourJSON] = useState({}); const [ipfsPath, setIpfsPath] = useState(""); const [loading, setLoading] = useState(false); const [mounted, setMounted] = useState(false); useEffect(() => { setMounted(true); }, []); const handleIpfsDownload = async () => { setLoading(true); const notificationId = notification.loading("Getting data from IPFS"); try { const metaData = await getMetadataFromIPFS(ipfsPath); notification.remove(notificationId); notification.success("Downloaded from IPFS"); setYourJSON(metaData); } catch (error) { notification.remove(notificationId); notification.error("Error downloading from IPFS"); console.log(error); } finally { setLoading(false); } }; return ( <>

Download from IPFS

setIpfsPath(e.target.value)} autoComplete="off" />
{mounted && ( { setYourJSON(edit.updated_src); }} onAdd={add => { setYourJSON(add.updated_src); }} onDelete={del => { setYourJSON(del.updated_src); }} /> )}
); }; export default IpfsDownload;