From 410ebdb015f2fa24863f81729d3c7e683518f6a5 Mon Sep 17 00:00:00 2001 From: abtestingalpha <104046418+abtestingalpha@users.noreply.github.com> Date: Sun, 7 Jan 2024 09:27:34 -0500 Subject: [PATCH] Adds try catch to prevent app crashing (#1762) --- .../helpers/useBridgeTxStatus.tsx | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/packages/synapse-interface/components/_Transaction/helpers/useBridgeTxStatus.tsx b/packages/synapse-interface/components/_Transaction/helpers/useBridgeTxStatus.tsx index 581d59f04b..d3c5901e58 100644 --- a/packages/synapse-interface/components/_Transaction/helpers/useBridgeTxStatus.tsx +++ b/packages/synapse-interface/components/_Transaction/helpers/useBridgeTxStatus.tsx @@ -28,11 +28,17 @@ export const useBridgeTxStatus = ({ const getKappa = async (): Promise => { if (!synapseSDK) return null if (!bridgeModuleName || !originChainId || !originTxHash) return null - return await synapseSDK.getSynapseTxId( - originChainId, - bridgeModuleName, - originTxHash - ) + try { + const kappa = await synapseSDK.getSynapseTxId( + originChainId, + bridgeModuleName, + originTxHash + ) + return kappa + } catch (error) { + console.error('Error in getKappa:', error) + return null + } } const getBridgeTxStatus = async ( @@ -42,11 +48,17 @@ export const useBridgeTxStatus = ({ ) => { if (!synapseSDK) return null if (!destinationChainId || !bridgeModuleName || !kappa) return null - return await synapseSDK.getBridgeTxStatus( - destinationChainId, - bridgeModuleName, - kappa - ) + try { + const status = await synapseSDK.getBridgeTxStatus( + destinationChainId, + bridgeModuleName, + kappa + ) + return status + } catch (error) { + console.error('Error in getBridgeTxStatus:', error) + return null + } } useEffect(() => {