From 86231959c686fa4fc6a2091dcd6a6e29aad2f078 Mon Sep 17 00:00:00 2001 From: abstract829 Date: Wed, 12 Jun 2024 09:48:13 -0400 Subject: [PATCH] fix fetchBalance --- src/hooks/useGetNativeTokenBalance.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/hooks/useGetNativeTokenBalance.ts b/src/hooks/useGetNativeTokenBalance.ts index b681e11b..a1399854 100644 --- a/src/hooks/useGetNativeTokenBalance.ts +++ b/src/hooks/useGetNativeTokenBalance.ts @@ -25,12 +25,13 @@ const fetchBalance = async ({ sorobanContext, address }: FetchBalanceProps) => { return { data: 0, validAccount: false }; } - try { - const balance = await tokenBalance(networkNativeToken.address, address, sorobanContext); - return { data: balance, validAccount: true }; - } catch (error) { - return { data: 0, validAccount: true }; + const balance = await tokenBalance(networkNativeToken.address, address, sorobanContext); + + if (balance === null) { + throw new Error('Failed to fetch balance'); } + + return { data: balance, validAccount: true }; }; const useGetNativeTokenBalance = () => {