Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add null-guards for token balances #519

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 =
MidnightLightning marked this conversation as resolved.
Show resolved Hide resolved
nft_data.token_balance == null
MidnightLightning marked this conversation as resolved.
Show resolved Hide resolved
? "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,
MidnightLightning marked this conversation as resolved.
Show resolved Hide resolved
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
Loading