{"version":3,"file":"getAllProgramAccounts.cjs","sources":["../../../../../src/rpc/methods/getAllProgramAccounts.ts"],"sourcesContent":["import type { RpcCaller } from \"../caller\";\nimport {\n  type GetProgramAccountsV2Config,\n  type GetProgramAccountsV2Response,\n  type GpaV2Account,\n} from \"../../types\";\nimport { makeGetProgramAccountsV2 } from \"./getProgramAccountsV2\";\n\nexport type GetAllProgramAccountsFn = (\n  programId: string,\n  options?: Omit<GetProgramAccountsV2Config, \"paginationKey\" | \"limit\">\n) => Promise<ReadonlyArray<GpaV2Account>>;\n\nexport const makeGetAllProgramAccounts =\n  (call: RpcCaller): GetAllProgramAccountsFn =>\n  async (programId, options = {}) => {\n    const getPage = makeGetProgramAccountsV2(call);\n\n    const results: GpaV2Account[] = [];\n    let paginationKey: string | null = null;\n\n    do {\n      const res: GetProgramAccountsV2Response = await getPage([\n        programId,\n        {\n          ...options,\n          limit: 10_000,\n          ...(paginationKey ? { paginationKey } : {}),\n        } as GetProgramAccountsV2Config,\n      ]);\n\n      // Unwrap RpcResponse<T> if withContext = true\n      const page = (res as any)?.value ?? (res as any);\n\n      results.push(...page.accounts);\n      paginationKey = page.paginationKey;\n    } while (paginationKey);\n\n    return results;\n  };\n"],"names":["makeGetProgramAccountsV2"],"mappings":";;;;AAaO,MAAM,yBAAyB,GACpC,CAAC,IAAe,KAChB,OAAO,SAAS,EAAE,OAAO,GAAG,EAAE,KAAI;AAChC,IAAA,MAAM,OAAO,GAAGA,6CAAwB,CAAC,IAAI,CAAC;IAE9C,MAAM,OAAO,GAAmB,EAAE;IAClC,IAAI,aAAa,GAAkB,IAAI;AAEvC,IAAA,GAAG;AACD,QAAA,MAAM,GAAG,GAAiC,MAAM,OAAO,CAAC;YACtD,SAAS;AACT,YAAA;AACE,gBAAA,GAAG,OAAO;AACV,gBAAA,KAAK,EAAE,KAAM;AACb,gBAAA,IAAI,aAAa,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,CAAC;AACd,aAAA;AAChC,SAAA,CAAC;;AAGF,QAAA,MAAM,IAAI,GAAI,GAAW,EAAE,KAAK,IAAK,GAAW;QAEhD,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC;AAC9B,QAAA,aAAa,GAAG,IAAI,CAAC,aAAa;IACpC,CAAC,QAAQ,aAAa;AAEtB,IAAA,OAAO,OAAO;AAChB;;;;"}