diff --git a/packages/nextjs/components/EIPs/Token/DataDisplay.tsx b/packages/nextjs/components/EIPs/Token/DataDisplay.tsx index 34851a3..7907f12 100644 --- a/packages/nextjs/components/EIPs/Token/DataDisplay.tsx +++ b/packages/nextjs/components/EIPs/Token/DataDisplay.tsx @@ -1,7 +1,7 @@ import React, { useEffect } from "react"; import tokenAbi from "../../../abi/eips/Token"; import { chainData } from "../../../utils/scaffold-eth/networks"; -import { createPublicClient, createWalletClient, custom, encodeFunctionData } from "viem"; +import { createPublicClient, createWalletClient, custom, encodeFunctionData, formatEther } from "viem"; import { useNetwork } from "wagmi"; interface TokenReturnDataType { @@ -99,8 +99,12 @@ const DataDisplay: React.FC = ({ returnData, setReturnData, di data: totalSupplyCallData, to: goldContract, }); - console.log("silver supply:", silverSupply); - console.log("gold supply:", goldSupply); + if (!silverSupply?.data || !goldSupply?.data) { + displayError("Silver or Gold supply is undefined!"); + return; + } + console.log("silver supply:", parseInt(silverSupply.data.toString())); + console.log("gold supply:", parseInt(goldSupply.data.toString())); setReturnData(prevData => ({ ...prevData, @@ -149,21 +153,21 @@ const DataDisplay: React.FC = ({ returnData, setReturnData, di
{" "} Silver balance: - {returnData.silverBalance} + {formatEther(BigInt(returnData.silverBalance))}
{" "} Total supply: - {returnData.silverSupply} + {formatEther(BigInt(returnData.silverSupply))}
{" "} Gold balance: - {returnData.goldBalance} + {formatEther(BigInt(returnData.goldBalance))}
Total supply: - {returnData.goldSupply} + {formatEther(BigInt(returnData.goldSupply))}
{chain && chain?.id && ( @@ -176,7 +180,12 @@ const DataDisplay: React.FC = ({ returnData, setReturnData, di )} {returnData.hash !== "" && (
- + {/* Checkbox input */} +
+ + {useWei ? "WEI" : "ETH"} +
diff --git a/packages/nextjs/pages/book/EIPs/20_Token/index.tsx b/packages/nextjs/pages/book/EIPs/20_Token/index.tsx index a8c2cc3..9f5b325 100644 --- a/packages/nextjs/pages/book/EIPs/20_Token/index.tsx +++ b/packages/nextjs/pages/book/EIPs/20_Token/index.tsx @@ -16,6 +16,9 @@ const Home: NextPage = () => { hash: "", }); + // Handle the state of tx interaction, if false the transaction will actually be submitted + const [useWei, setUseWei] = useState(true); + // State variable for storing error messages const [errorMessage, setErrorMessage] = useState(""); @@ -43,7 +46,13 @@ const Home: NextPage = () => {
- + {/* Conditionally render the custom error popup */} {showErrorPopup && }