Skip to content

Commit

Permalink
Add null-guards for token balances
Browse files Browse the repository at this point in the history
  • Loading branch information
MidnightLightning committed Nov 14, 2023
1 parent 6dcb643 commit 3b6d267
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/hooks/useGetSourceParsedTokenAccounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -640,18 +640,17 @@ const createNFTParsedTokenAccountFromCovalent = (
covalent: CovalentData,
nft_data: CovalentNFTData
): NFTParsedTokenAccount => {
let amount =
nft_data.token_balance == null
? "0"
: formatUnits(nft_data.token_balance, covalent.contract_decimals);
return {
publicKey: walletAddress,
mintKey: covalent.contract_address,
amount: nft_data.token_balance,
amount: nft_data.token_balance == null ? "" : nft_data.token_balance,
decimals: covalent.contract_decimals,
uiAmount: Number(
formatUnits(nft_data.token_balance, covalent.contract_decimals)
),
uiAmountString: formatUnits(
nft_data.token_balance,
covalent.contract_decimals
),
uiAmount: Number(amount),
uiAmountString: amount,
symbol: covalent.contract_ticker_symbol,
name: covalent.contract_name,
logo: covalent.logo_url,
Expand Down Expand Up @@ -689,7 +688,7 @@ export type CovalentNFTExternalData = {

export type CovalentNFTData = {
token_id: string;
token_balance: string;
token_balance: string | null;
external_data: CovalentNFTExternalData;
token_url: string;
};
Expand Down

0 comments on commit 3b6d267

Please sign in to comment.