Skip to content

Commit

Permalink
chore: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
bluecco committed Nov 4, 2024
1 parent 90e80de commit 31162ae
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
12 changes: 8 additions & 4 deletions src/components/sections/Transactions/SendERC20.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -99,9 +99,13 @@ const SendERC20 = () => {
<Button
type="submit"
disabled={buttonsDisabled}
style={{ maxWidth: "100px" }}
style={{ maxWidth: "200px" }}
>
<span>Send</span>
<span>
{lastTxStatus === "approve"
? "Waiting for transaction"
: "Send transaction"}
</span>
</Button>
{lastTxError ? (
<span style={{ color: "red" }}>Error: {lastTxError}</span>
Expand Down
10 changes: 6 additions & 4 deletions src/components/sections/Transactions/SendMulticall.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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 = [
{
Expand Down Expand Up @@ -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)
Expand All @@ -80,7 +80,9 @@ const SendMulticall = () => {
onClick={handleTransferSubmit}
disabled={buttonsDisabled}
>
Send Multicall
{lastTxStatus === "approve"
? "Waiting for transaction"
: "Send Multicall"}
</Button>
{lastTxError ? (
<span style={{ color: "red" }}>Error: {lastTxError}</span>
Expand Down

0 comments on commit 31162ae

Please sign in to comment.