Skip to content

Commit

Permalink
try/catch addTransaction
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfsayo committed Dec 2, 2024
1 parent 5bda755 commit d3d3080
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ProposalsResponse>(
isReady ? [SWR_KEYS.PROPOSALS, chainId, query.token, '0'] : null,
Expand Down Expand Up @@ -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)
Expand All @@ -131,14 +133,20 @@ export const Escrow: React.FC = () => {
value: formatEther(BigInt(fundAmount)),
}

try {
// add to queue
addTransaction({
type: TransactionType.ESCROW,
summary: `Create and fund new Escrow with ${formatEther(BigInt(fundAmount))} ETH`,
transactions: [escrow],
})

setIsIPFSUploading(false)

} catch (err) {
console.log('Error', err);
setIpfsCID('');
}
setIsIPFSUploading(false)
},
[formValues]
)
Expand Down

0 comments on commit d3d3080

Please sign in to comment.