Skip to content

Commit

Permalink
Add cache for is22 in debug ui to help mitigate 429s (#320)
Browse files Browse the repository at this point in the history
  • Loading branch information
brittcyr authored Dec 16, 2024
1 parent 70c3a23 commit 465903b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion debug-ui/lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,18 @@ export const checkForToken22 = async (
conn: Connection,
mint: PublicKey,
): Promise<boolean> => {
const localStorageKey: string = mint.toBase58() + '-Is22';

if (localStorage.getItem(localStorageKey)) {
return localStorage.getItem(localStorageKey)! === 'true';
}

const acc = await conn.getAccountInfo(mint);
if (!acc) {
throw new Error('checkForToken22: account does not exist');
}

return acc.owner.toBase58() !== TOKEN_PROGRAM_ID.toBase58();
const is22: boolean = acc.owner.toBase58() !== TOKEN_PROGRAM_ID.toBase58();
localStorage.setItem(localStorageKey, is22.toString());
return is22;
};

0 comments on commit 465903b

Please sign in to comment.