explorer: Don't show token holdings for accounts with too many tokens (#27604)

This commit is contained in:
Justin Starry 2022-09-06 09:16:39 -05:00 committed by GitHub
parent 12d2147efa
commit db0bff0668
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -66,6 +66,12 @@ export function OwnedTokensCard({ pubkey }: { pubkey: PublicKey }) {
);
}
if (tokens.length > 100) {
return (
<ErrorCard text="Token holdings is not available for accounts with over 100 token accounts" />
);
}
return (
<>
{showDropdown && (

View File

@ -66,7 +66,7 @@ async function fetchAccountTokens(
"processed"
).getParsedTokenAccountsByOwner(pubkey, { programId: TOKEN_PROGRAM_ID });
data = {
tokens: value.map((accountInfo) => {
tokens: value.slice(0, 101).map((accountInfo) => {
const parsedInfo = accountInfo.account.data.parsed.info;
const info = create(parsedInfo, TokenAccountInfo);
return { info, pubkey: accountInfo.pubkey };