From 465903bc0ec30a088bda69103eec5f045999c305 Mon Sep 17 00:00:00 2001 From: Britt Cyr Date: Mon, 16 Dec 2024 14:45:24 -0500 Subject: [PATCH] Add cache for is22 in debug ui to help mitigate 429s (#320) --- debug-ui/lib/util.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/debug-ui/lib/util.ts b/debug-ui/lib/util.ts index b29459619..233b5e889 100644 --- a/debug-ui/lib/util.ts +++ b/debug-ui/lib/util.ts @@ -98,10 +98,18 @@ export const checkForToken22 = async ( conn: Connection, mint: PublicKey, ): Promise => { + 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; };