Skip to content

Commit

Permalink
change rpc method for get acc by mint
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrii Zdrobylko authored and Andrii Zdrobylko committed Nov 24, 2021
1 parent 65040d8 commit 4aa6e24
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions packages/sol-rayz/src/getParsedAccountByMint.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { PublicKey, Connection } from "@solana/web3.js";
import { TOKEN_PROGRAM } from "./config/solana";
import { createConnectionConfig } from "./utils";
import { StringPublicKey } from "./types";

Expand Down Expand Up @@ -31,26 +30,15 @@ export const getParsedAccountByMint = async ({
connection = createConnectionConfig(),
stringifyPubKeys = true,
}: Props) => {
const res = await connection.getParsedProgramAccounts(
new PublicKey(TOKEN_PROGRAM),
{
filters: [
{ dataSize: 165 },
{
memcmp: {
offset: 0,
bytes: mintAddress,
},
},
],
}
const res = await connection.getTokenLargestAccounts(
new PublicKey(mintAddress)
);

if (!res?.length) {
if (!res.value?.length) {
return undefined;
}

const firstResult = res[0];
const firstResult = res.value[0];
const formatedData = stringifyPubKeys
? publicKeyToString(firstResult)
: firstResult;
Expand Down

0 comments on commit 4aa6e24

Please sign in to comment.