Skip to content

Commit

Permalink
fix: catch errors getting evm balances
Browse files Browse the repository at this point in the history
  • Loading branch information
genaroibc committed Jun 28, 2024
1 parent 217b41a commit 30d4780
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/handlers/evm/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,25 @@ export class Utils {
);

const getTokenData = async () => {
const balanceInWei =
await contract[isNativeToken ? "getEthBalance" : "balanceOf"](userAddress);
const { decimals, symbol, address, chainId } = token;

let balance: string;

try {
const balanceInWei =
await contract[isNativeToken ? "getEthBalance" : "balanceOf"](userAddress);

balance = balanceInWei.toString();
} catch (error) {
balance = "0";
}

return {
balance: balanceInWei.toString(),
symbol: token.symbol,
address: token.address,
decimals: token.decimals,
chainId: token.chainId,
balance,
symbol,
address,
decimals,
chainId,
};
};

Expand Down

0 comments on commit 30d4780

Please sign in to comment.