From 2449726e0a84db35cf3a52f6e65b5d28edb855a9 Mon Sep 17 00:00:00 2001 From: broody Date: Wed, 8 Jan 2025 19:43:28 -1000 Subject: [PATCH] remove unused --- examples/next/src/app/token/page.tsx | 134 --------------------------- 1 file changed, 134 deletions(-) delete mode 100644 examples/next/src/app/token/page.tsx diff --git a/examples/next/src/app/token/page.tsx b/examples/next/src/app/token/page.tsx deleted file mode 100644 index a41d385f3..000000000 --- a/examples/next/src/app/token/page.tsx +++ /dev/null @@ -1,134 +0,0 @@ -"use client"; - -import { - useAccount, - useReadContract, - useSendTransaction, -} from "@starknet-react/core"; -import { useCallback, useMemo, useState } from "react"; -import { cairo, uint256 } from "starknet"; -import { ConnectWallet } from "components/ConnectWallet"; -import { useTokenContract } from "hooks/token"; -import { Abi } from "starknet"; -import Erc20Abi from "abi/erc20.json"; -import { Button, Input } from "@cartridge/ui-next"; - -function UserBalance() { - const { account } = useAccount(); - - const { data, isLoading, error } = useReadContract({ - abi: Erc20Abi as Abi, - address: - "0x07394cbe418daa16e42b87ba67372d4ab4a5df0b05c6e554d158458ce245bc10", - functionName: "balanceOf", - args: account ? [account] : undefined, - }); - - const content = useMemo(() => { - if (isLoading || !(data as [])?.length) { - return
Loading balance
; - } - - if (error) { - console.error(error); - return
Error!
; - } - - const balance = uint256.uint256ToBN(cairo.uint256(data[0])); - return
{balance.toString(10)}
; - }, [data, isLoading, error]); - - return ( -
-

User balance

- {content} -
- ); -} - -function MintToken() { - const { account, address } = useAccount(); - const [amount, setAmount] = useState(""); - const [amountError, setAmountError] = useState(); - - const { contract } = useTokenContract(); - - const calls = useMemo(() => { - if (!address || !contract) return []; - - const amountBn = cairo.uint256(amount); - return contract.populateTransaction["mint"]!(address, [address, amountBn]); - }, [address, contract, amount]); - - const { sendAsync, isPending, error, reset } = useSendTransaction({ - calls, - }); - - const updateAmount = useCallback( - (newAmount: string) => { - // soft-validate amount - setAmount(newAmount); - try { - BigInt(newAmount); - setAmountError(undefined); - } catch (err) { - console.error(err); - setAmountError("Please input a valid number"); - } - }, - [setAmount], - ); - - const onMint = useCallback(() => { - reset(); - if (account && !amountError) { - sendAsync(); - } - }, [account, amountError, reset, sendAsync]); - - const mintButtonDisabled = useMemo(() => { - if (isPending) return true; - return !account || !!amountError; - }, [isPending, account, amountError]); - - return ( -
-

Mint token

-

- Amount: - updateAmount(evt.target.value)} - /> -

- - {error && ( -

- <>Error: {error} -

- )} -
- ); -} - -export default function TokenPage() { - const { address } = useAccount(); - - if (!address) { - return ( -
-

Connect Wallet

- -
- ); - } - return ( -
-

Connected: {address}

- - -
- ); -}