diff --git a/packages/nextjs/app/page.tsx b/packages/nextjs/app/page.tsx index 287690d..e14bc03 100644 --- a/packages/nextjs/app/page.tsx +++ b/packages/nextjs/app/page.tsx @@ -19,6 +19,7 @@ import { displayTxResult } from "./debug/_components/contract"; import BigNumber from "bignumber.js"; const Home: NextPage = () => { + const connectedAddress = useAccount(); const [isModalOpen, setIsModalOpen] = useState(false); @@ -41,7 +42,7 @@ const Home: NextPage = () => { const [nftSymbol, setNftSymbol] = useState(""); - const base = "http://localhost:3300/"; + const base = "https://starkai.cryptea.me/"; const deployContract = async () => { if (isLoading) return; @@ -65,6 +66,7 @@ const Home: NextPage = () => { // return; try { + const res = await axios.post(`${base}create`, { name: nftName, desc: nftDesc, @@ -72,6 +74,8 @@ const Home: NextPage = () => { const image = `https://gateway.pinata.cloud/ipfs/${res.data.hash}?1`; + console.log(image, "sss"); + setImage(image); // 0x0758e5854628069e27bc547b75c1a5aa8e24a5fccace22984183fa08199871a2 @@ -84,6 +88,8 @@ const Home: NextPage = () => { base_uri: image, }); + console.log(constructorCalldata, "sss"); + const classDeploy = await connectedAddress.account?.deploy({ classHash: "0x07d2fa6fb834a03ccab365379ff25b0f9b91f0eea9be115cd216f01a430e913c", @@ -105,6 +111,10 @@ const Home: NextPage = () => { console.log(mres, "sss"); + toast.success( + `NFT deployed successfully 🎉 \n hash - ${classDeploy.transaction_hash}` + ); + setIsModalOpen(false); setSuccess(true); } @@ -133,7 +143,7 @@ const Home: NextPage = () => { console.log(res, "contract"); await axios.post(`${base}ondeploy`, { - address: connectedAddress.address, + address, contract: cnt, desc: nftDesc, }); @@ -144,7 +154,7 @@ const Home: NextPage = () => { setAddress(""); - toast.success("NFT minted to address successfully"); + toast.success(`NFT minted to address successfully \n hash - ${res.transaction_hash}`); } catch (error) { toast.dismiss(ee); @@ -161,12 +171,9 @@ const Home: NextPage = () => { const [nftDx, setNftDx] = useState([]); function feltToString(felt: any) { - let hexStr = felt.toString(16); - if (hexStr.length % 2 !== 0) { - hexStr = "0" + hexStr; - } + const hexStr = felt.toString(16); const bytes = Buffer.from(hexStr, "hex"); - return bytes.toString("utf-8"); + return bytes.toString("utf-8").replace(/\0/g, ""); // Remove padding null characters } useEffect(() => { @@ -197,19 +204,24 @@ const Home: NextPage = () => { function feltToNumber(felt: any) { return new BigNumber(felt.toString()).toNumber(); } + return { ...e, - uri: feltToString(uri.data[0]), + uri: displayTxResult(uri, false, [ + { type: "core::byte_array::ByteArray" }, + ]), symbol: feltToString(symbol.pending_word), name: feltToString(name.pending_word), }; }) ); + console.log(dx, 'dd') + setNfts(dx); - setPageLoader(false); + if (connectedAddress.address) setPageLoader(false); } catch (error) { console.log(error); @@ -223,7 +235,15 @@ const Home: NextPage = () => { className={`w-[60vw] mx-auto md:max-h-[30rem] md:max-w-[45rem]`} isOpen={success} animate={true} - onClose={() => {}} + onClose={() => { + setSuccess(false); + setNftDesc(""); + setImage(""); + setAddress(""); + setContract(""); + setNftName(""); + window.location.reload(); + }} >
@@ -240,6 +260,7 @@ const Home: NextPage = () => { setAddress(""); setContract(""); setNftName(""); + window.location.reload(); }} > Close @@ -410,6 +431,9 @@ const Home: NextPage = () => { > {/* show a list of nfts */} {nfts.map((e: any, i: number) => { + + console.log(e.url, 'from map') + return (
{}} @@ -418,7 +442,7 @@ const Home: NextPage = () => { >
nft => { recipient: deployer.address, // the deployer address is the owner of the contract name: "StarkNFT", symbol: "SNFT", - base_uri: "https://gateway.pinata.cloud/ipfs/", + base_uri: + "https://gateway.pinata.cloud/ipfs/QmZqALrmo8S6xw1fz9Xr9GrNM896enrxBHDYricBRECxFE?1", }, "StarkNFT" );