Skip to content

Commit

Permalink
Merge pull request #39 from bdtren/main
Browse files Browse the repository at this point in the history
add metaAccountsRequestChunkSize
  • Loading branch information
VeritasV committed Dec 23, 2023
2 parents 2d2a22b + de89de5 commit 031853e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/sol-rayz/README.md
Expand Up @@ -106,6 +106,11 @@ const tokenList = await getParsedNftAccountsByOwner({
* by default response limited by 5000 NFTs
*/
limit?: number;
/**
* Limit number of PublicKeys per request to `getMultipleAccountsInfo`
* Default is 99
*/
metaAccountsRequestChunkSize?: number;
});
```

Expand Down
8 changes: 7 additions & 1 deletion packages/sol-rayz/src/getParsedNftAccountsByOwner.ts
Expand Up @@ -51,6 +51,11 @@ export type Options = {
* by default response limited by 5000 NFTs.
*/
limit?: number;
/**
* Limit number of PublicKeys per request to `getMultipleAccountsInfo`
* Default is 99
*/
metaAccountsRequestChunkSize?: number;
};

enum sortKeys {
Expand All @@ -64,6 +69,7 @@ export const getParsedNftAccountsByOwner = async ({
stringifyPubKeys = true,
sort = true,
limit = 5000,
metaAccountsRequestChunkSize = 99,
}: Options) => {
const isValidAddress = isValidSolanaAddress(publicAddress);
if (!isValidAddress) {
Expand Down Expand Up @@ -113,7 +119,7 @@ export const getParsedNftAccountsByOwner = async ({
const metaAccountsRawPromises: PromiseSettledResult<
(AccountInfo<Buffer | ParsedAccountData> | null)[]
>[] = await Promise.allSettled(
chunks(metadataAccounts, 99).map((chunk) =>
chunks(metadataAccounts, metaAccountsRequestChunkSize).map((chunk) =>
connection.getMultipleAccountsInfo(chunk as PublicKey[])
)
);
Expand Down

0 comments on commit 031853e

Please sign in to comment.