From c382f1fbd7c03659f8edae0e0bd9d87048507647 Mon Sep 17 00:00:00 2001 From: Aren Date: Thu, 26 Dec 2024 20:29:17 +0400 Subject: [PATCH] Refactor FuelWalletWithdrawal component to remove unused contract ABI and simplify transaction handling --- .../Withdraw/Wallet/FuelWalletWithdrawal.tsx | 27 ++------ lib/abis/FuelWatchContractABI.json | 69 ------------------- 2 files changed, 7 insertions(+), 89 deletions(-) delete mode 100644 lib/abis/FuelWatchContractABI.json diff --git a/components/Swap/Withdraw/Wallet/FuelWalletWithdrawal.tsx b/components/Swap/Withdraw/Wallet/FuelWalletWithdrawal.tsx index d2169db5a..8729991b8 100644 --- a/components/Swap/Withdraw/Wallet/FuelWalletWithdrawal.tsx +++ b/components/Swap/Withdraw/Wallet/FuelWalletWithdrawal.tsx @@ -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 = ({ network, callData, swapId, token, amount, depositAddress }) => { +const FuelWalletWithdrawStep: FC = ({ network, callData, swapId }) => { const [loading, setLoading] = useState(false); const { setSwapTransaction } = useSwapTransactionStore() @@ -21,27 +19,16 @@ const FuelWalletWithdrawStep: FC = ({ 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) { @@ -53,7 +40,7 @@ const FuelWalletWithdrawStep: FC = ({ network, callData, swap finally { setLoading(false) } - }, [swapId, callData, network, token, amount, fuelWallet]) + }, [swapId, callData, fuelWallet]) if (!wallet) { return diff --git a/lib/abis/FuelWatchContractABI.json b/lib/abis/FuelWatchContractABI.json deleted file mode 100644 index a665cdd74..000000000 --- a/lib/abis/FuelWatchContractABI.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "programType": "contract", - "specVersion": "1", - "encodingVersion": "1", - "concreteTypes": [ - { - "type": "()", - "concreteTypeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d" - }, - { - "type": "str", - "concreteTypeId": "8c25cb3686462e9a86d2883c5688a22fe738b0bbc85f458d2d2b5f3f667c6d5a" - }, - { - "type": "struct MyEvent", - "concreteTypeId": "35f8825c39ae1a89edbc75e86805508f15548895730edcd1f2b1321b5291970c", - "metadataTypeId": 0 - }, - { - "type": "u256", - "concreteTypeId": "1b5759d94094368cfd443019e7ca5ec4074300e544e5ea993a979f5da627261e" - } - ], - "metadataTypes": [ - { - "type": "struct MyEvent", - "metadataTypeId": 0, - "components": [ - { - "name": "num", - "typeId": "1b5759d94094368cfd443019e7ca5ec4074300e544e5ea993a979f5da627261e" - } - ] - } - ], - "functions": [ - { - "inputs": [ - { - "name": "id", - "concreteTypeId": "1b5759d94094368cfd443019e7ca5ec4074300e544e5ea993a979f5da627261e" - } - ], - "name": "test_function", - "output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d", - "attributes": [ - { - "name": "storage", - "arguments": [ - "read", - "write" - ] - } - ] - } - ], - "loggedTypes": [ - { - "logId": "10098701174489624218", - "concreteTypeId": "8c25cb3686462e9a86d2883c5688a22fe738b0bbc85f458d2d2b5f3f667c6d5a" - }, - { - "logId": "3889001610850736777", - "concreteTypeId": "35f8825c39ae1a89edbc75e86805508f15548895730edcd1f2b1321b5291970c" - } - ], - "messagesTypes": [], - "configurables": [] - } \ No newline at end of file