From d3d30806d7a7521095470ea7adb38b0b2b590a5d Mon Sep 17 00:00:00 2001 From: Sayo <82053242+wtfsayo@users.noreply.github.com> Date: Tue, 3 Dec 2024 00:12:34 +0530 Subject: [PATCH] try/catch `addTransaction` --- .../components/TransactionForm/Escrow/Escrow.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/web/src/modules/create-proposal/components/TransactionForm/Escrow/Escrow.tsx b/apps/web/src/modules/create-proposal/components/TransactionForm/Escrow/Escrow.tsx index 61831f4d..faec182e 100644 --- a/apps/web/src/modules/create-proposal/components/TransactionForm/Escrow/Escrow.tsx +++ b/apps/web/src/modules/create-proposal/components/TransactionForm/Escrow/Escrow.tsx @@ -33,7 +33,6 @@ export const Escrow: React.FC = () => { const { id: chainId } = getChainFromLocalStorage() const addTransaction = useProposalStore((state) => state.addTransaction) - const removeTransactions = useProposalStore((state) => state.removeAllTransactions) const { data } = useSWR( isReady ? [SWR_KEYS.PROPOSALS, chainId, query.token, '0'] : null, @@ -111,7 +110,10 @@ export const Escrow: React.FC = () => { } // add 1s delay here - await new Promise((resolve) => setTimeout(resolve, 1000)) + await new Promise(resolve => setTimeout(() => { + console.log('Wait for Ipfs upload'); + resolve(); + }, 1000)); // create bundler transaction data const escrowData = createEscrowData(values, ipfsCID, chainId) @@ -131,6 +133,7 @@ export const Escrow: React.FC = () => { value: formatEther(BigInt(fundAmount)), } + try { // add to queue addTransaction({ type: TransactionType.ESCROW, @@ -138,7 +141,12 @@ export const Escrow: React.FC = () => { transactions: [escrow], }) - setIsIPFSUploading(false) + + } catch (err) { + console.log('Error', err); + setIpfsCID(''); + } + setIsIPFSUploading(false) }, [formValues] )