From 50ed8b78ca79e3801a082392258d1652f3816104 Mon Sep 17 00:00:00 2001 From: michael1011 Date: Sat, 9 Nov 2024 13:56:48 +0100 Subject: [PATCH] fix: catch EVM provider error in create --- src/components/CreateButton.tsx | 35 ++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/components/CreateButton.tsx b/src/components/CreateButton.tsx index 9195a9c8..242d74c7 100644 --- a/src/components/CreateButton.tsx +++ b/src/components/CreateButton.tsx @@ -250,27 +250,30 @@ export const CreateButton = () => { let claimAddress = onchainAddress(); - if (assetReceive() === RBTC) { - const [balance, gasPrice] = await Promise.all([ - signer().provider.getBalance(await signer().getAddress()), - signer() - .provider.getFeeData() - .then((data) => data.gasPrice), - ]); - log.debug("RSK balance", balance); + try { + if (assetReceive() === RBTC) { + const [balance, gasPrice] = await Promise.all([ + signer().provider.getBalance(await signer().getAddress()), + signer() + .provider.getFeeData() + .then((data) => data.gasPrice), + ]); + log.debug("RSK balance", balance); - const balanceNeeded = gasPrice * GasNeededToClaim; - log.debug("RSK balance needed", balanceNeeded); + const balanceNeeded = gasPrice * GasNeededToClaim; + log.debug("RSK balance needed", balanceNeeded); - if (balance <= balanceNeeded) { - claimAddress = (await getSmartWalletAddress(signer())).address; - log.info("Using RIF smart wallet as claim address"); + if (balance <= balanceNeeded) { + claimAddress = (await getSmartWalletAddress(signer())) + .address; + log.info("Using RIF smart wallet as claim address"); + } else { + log.info("RIF smart wallet not needed"); + } } - } - const useRif = onchainAddress() !== claimAddress; + const useRif = onchainAddress() !== claimAddress; - try { let data: SomeSwap; switch (swapType()) { case SwapType.Submarine: