From 31162ae1b38e838ddc5021f17d67c7f37c11cd8a Mon Sep 17 00:00:00 2001 From: bluecco Date: Mon, 4 Nov 2024 14:01:07 +0100 Subject: [PATCH] chore: refactor --- src/components/sections/Transactions/SendERC20.tsx | 12 ++++++++---- .../sections/Transactions/SendMulticall.tsx | 10 ++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/components/sections/Transactions/SendERC20.tsx b/src/components/sections/Transactions/SendERC20.tsx index 25f438c..b840aa4 100644 --- a/src/components/sections/Transactions/SendERC20.tsx +++ b/src/components/sections/Transactions/SendERC20.tsx @@ -1,5 +1,5 @@ import { Flex } from "@/components/ui/Flex" -import { ETHTokenAddress, provider } from "@/constants" +import { ETHTokenAddress } from "@/constants" import { parseInputAmountToUint256 } from "@/helper/token" import { Abi, @@ -58,10 +58,10 @@ const SendERC20 = () => { const handleTransferSubmit = async (e: React.FormEvent) => { try { + setLastTxError("") e.preventDefault() setLastTxStatus("approve") const { transaction_hash } = await sendAsync() - await provider.waitForTransaction(transaction_hash) alert(`Transaction sent: ${transaction_hash}`) } catch (error) { setLastTxError((error as Error).message) @@ -99,9 +99,13 @@ const SendERC20 = () => { {lastTxError ? ( Error: {lastTxError} diff --git a/src/components/sections/Transactions/SendMulticall.tsx b/src/components/sections/Transactions/SendMulticall.tsx index 3a1fb66..8a5b3ee 100644 --- a/src/components/sections/Transactions/SendMulticall.tsx +++ b/src/components/sections/Transactions/SendMulticall.tsx @@ -1,5 +1,6 @@ // TokenOperations.tsx -import { ETHTokenAddress, provider } from "@/constants" +import { Flex } from "@/components/ui/Flex" +import { ETHTokenAddress } from "@/constants" import { parseInputAmountToUint256 } from "@/helper/token" import { Abi, @@ -9,7 +10,6 @@ import { } from "@starknet-react/core" import { useState } from "react" import { Button } from "../../ui/Button" -import { Flex } from "@/components/ui/Flex" const abi = [ { @@ -61,10 +61,10 @@ const SendMulticall = () => { const handleTransferSubmit = async (e: React.FormEvent) => { try { + setLastTxError("") e.preventDefault() setLastTxStatus("approve") const { transaction_hash } = await sendAsync() - await provider.waitForTransaction(transaction_hash) alert(`Transaction sent: ${transaction_hash}`) } catch (error) { setLastTxError((error as Error).message) @@ -80,7 +80,9 @@ const SendMulticall = () => { onClick={handleTransferSubmit} disabled={buttonsDisabled} > - Send Multicall + {lastTxStatus === "approve" + ? "Waiting for transaction" + : "Send Multicall"} {lastTxError ? ( Error: {lastTxError}