Skip to content

Commit

Permalink
Merge pull request #286 from helius-labs/fix/token-routing-2
Browse files Browse the repository at this point in the history
[Fix] Token Routing
  • Loading branch information
0xIchigo authored Feb 13, 2024
2 parents 1886ad4 + f584768 commit 76aa736
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions src/lib/xray/lib/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,16 @@ export const search = async (
if (isValidPublicKey(query)) {
const pubkey = new PublicKey(query);
const account = await connection.getAccountInfo(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 program = account?.owner.toString();

const probablyToken =
program === "spl-token" ||
program === "spl-token-2022" ||
account?.value === null;
program === "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" ||
program === "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" ||
account === null;

let addressType!: "token" | "account";
if (probablyToken) {
addressType = parsedType === "account" ? "account" : "token";
addressType = "token";
}
addressType ??= "account";

Expand Down

0 comments on commit 76aa736

Please sign in to comment.