From aa2c54366cec7954a0b52893033e30a9c46c0705 Mon Sep 17 00:00:00 2001 From: borcherd Date: Fri, 1 Mar 2024 11:34:50 +0100 Subject: [PATCH] feat: trycatch --- src/index.ts | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/index.ts b/src/index.ts index 285b680..a22fa45 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1459,21 +1459,25 @@ async function prepareClaimLinkSenderTx({ chainId: string contractVersion?: string }) { - if (!provider) { - provider = await getDefaultProvider(chainId) - } + try { + if (!provider) { + provider = await getDefaultProvider(chainId) + } - if (contractVersion == null) { - contractVersion = getLatestContractVersion({ chainId, type: 'normal' }) - } + if (contractVersion == null) { + contractVersion = getLatestContractVersion({ chainId, type: 'normal' }) + } - const contract = await getContract(chainId, provider, contractVersion) + const contract = await getContract(chainId, provider, contractVersion) - const tx = await contract.populateTransaction.withdrawDepositSender(depositIndex) + const tx = await contract.populateTransaction.withdrawDepositSender(depositIndex) - const x = ethersV5ToPeanutTx(tx) + const convertedTx = ethersV5ToPeanutTx(tx) - return x + return convertedTx + } catch (error) { + throw new interfaces.SDKStatus(interfaces.EClaimLinkStatusCodes.ERROR, error) + } } /**