Skip to content

Commit

Permalink
Refactor FuelWalletWithdrawal component to remove unused contract ABI…
Browse files Browse the repository at this point in the history
… and simplify transaction handling
  • Loading branch information
arentant committed Dec 26, 2024
1 parent d03c146 commit c382f1f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 89 deletions.
27 changes: 7 additions & 20 deletions components/Swap/Withdraw/Wallet/FuelWalletWithdrawal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ import { ButtonWrapper, ConnectWalletButton } from './WalletTransfer/buttons';
import {
useWallet as useFuelWallet,
} from '@fuels/react';
import { Provider, Contract } from 'fuels';
import FuelWatchContractABI from '../../../../lib/abis/FuelWatchContractABI.json';

const FuelWalletWithdrawStep: FC<WithdrawPageProps> = ({ network, callData, swapId, token, amount, depositAddress }) => {
const FuelWalletWithdrawStep: FC<WithdrawPageProps> = ({ network, callData, swapId }) => {
const [loading, setLoading] = useState(false);
const { setSwapTransaction } = useSwapTransactionStore()

Expand All @@ -21,27 +19,16 @@ const FuelWalletWithdrawStep: FC<WithdrawPageProps> = ({ network, callData, swap
const wallet = provider?.activeWallet

const handleTransfer = useCallback(async () => {
setLoading(true)
try {
setLoading(true)

if (!fuelWallet) throw Error("Fuel wallet not connected")
if (!network) throw Error("Network not found")
if (!callData) throw Error("Call data not found")

const fuelProvider = await Provider.create(network.node_url);
const contract = new Contract('0x9599a0fee081405d22a33b1ce892b47688660a38c5f8509559f34a3f960b89f7', FuelWatchContractABI, fuelWallet);
const tx = JSON.parse(callData)
const transactionResponse = await fuelWallet.sendTransaction(tx)

const { waitForResult } = await contract.functions
.test_function(42069)
.addTransfer({
destination: depositAddress as string,
amount: 100,
assetId: fuelProvider.getBaseAssetId(),
})
.call();

const transactionResponse = await waitForResult()

// if (swapId && transactionResponse) setSwapTransaction(swapId, BackendTransactionStatus.Completed, transactionResponse.id)
if (swapId && transactionResponse) setSwapTransaction(swapId, BackendTransactionStatus.Completed, transactionResponse.id)

}
catch (e) {
Expand All @@ -53,7 +40,7 @@ const FuelWalletWithdrawStep: FC<WithdrawPageProps> = ({ network, callData, swap
finally {
setLoading(false)
}
}, [swapId, callData, network, token, amount, fuelWallet])
}, [swapId, callData, fuelWallet])

if (!wallet) {
return <ConnectWalletButton />
Expand Down
69 changes: 0 additions & 69 deletions lib/abis/FuelWatchContractABI.json

This file was deleted.

0 comments on commit c382f1f

Please sign in to comment.