From ce054c6d1f2717cb6f71ae2e3b5e026571f1220e Mon Sep 17 00:00:00 2001 From: 0xIchigo <0xIchigo@protonmail.com> Date: Mon, 12 Feb 2024 15:29:15 -0500 Subject: [PATCH 1/2] Fixooorrr --- src/lib/xray/lib/search.ts | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/lib/xray/lib/search.ts b/src/lib/xray/lib/search.ts index 654016bc..3f988c66 100644 --- a/src/lib/xray/lib/search.ts +++ b/src/lib/xray/lib/search.ts @@ -58,26 +58,19 @@ export const search = async ( if (isValidPublicKey(query)) { const pubkey = new PublicKey(query); - const account = await connection.getParsedAccountInfo(pubkey); - // TODO Property 'program' does not exist on type 'Buffer | ParsedAccountData'. - // @ts-ignore - const program = account?.value?.data?.program; - // @ts-ignore - const parsedType = account?.value?.data?.parsed?.type; - - /* - * spl-token -> spl token - * spl-token-2022 -> token 2022 - * null -> compressed nft - */ + const account = await connection.getAccountInfo(pubkey); + + const program = account?.owner; const probablyToken = - program === "spl-token" || - program === "spl-token-2022" || - account?.value === null; + program === + new PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA") || + program === + new PublicKey("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb") || + account === null; let addressType!: "token" | "account"; if (probablyToken) { - addressType = parsedType === "account" ? "account" : "token"; + addressType = "token"; } addressType ??= "account"; From f584768c358773579f02c6fbb53740bab3cff137 Mon Sep 17 00:00:00 2001 From: 0xIchigo <0xIchigo@protonmail.com> Date: Mon, 12 Feb 2024 15:45:23 -0500 Subject: [PATCH 2/2] ... --- src/lib/xray/lib/search.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/lib/xray/lib/search.ts b/src/lib/xray/lib/search.ts index 3f988c66..a3491b2c 100644 --- a/src/lib/xray/lib/search.ts +++ b/src/lib/xray/lib/search.ts @@ -59,13 +59,11 @@ export const search = async ( if (isValidPublicKey(query)) { const pubkey = new PublicKey(query); const account = await connection.getAccountInfo(pubkey); + const program = account?.owner.toString(); - const program = account?.owner; const probablyToken = - program === - new PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA") || - program === - new PublicKey("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb") || + program === "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" || + program === "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" || account === null; let addressType!: "token" | "account";