|
@@ -73,58 +73,10 @@ async function getMultipleAccountsCore(
|
|
|
Array<null | { publicKey: PublicKey; account: AccountInfo<Buffer> }>
|
|
|
> {
|
|
|
const commitment = commitmentOverride ?? connection.commitment;
|
|
|
- const args: (
|
|
|
- | string[]
|
|
|
- | {
|
|
|
- commitment: Commitment;
|
|
|
- }
|
|
|
- )[] = [publicKeys.map((k) => k.toBase58())];
|
|
|
- if (commitment) {
|
|
|
- args.push({ commitment });
|
|
|
- }
|
|
|
- // @ts-ignore
|
|
|
- const res = await connection._rpcRequest("getMultipleAccounts", args);
|
|
|
- if (res.error) {
|
|
|
- throw new Error(
|
|
|
- "failed to get info about accounts " +
|
|
|
- publicKeys.map((k) => k.toBase58()).join(", ") +
|
|
|
- ": " +
|
|
|
- res.error.message
|
|
|
- );
|
|
|
- }
|
|
|
- assert(typeof res.result !== "undefined");
|
|
|
- const accounts: Array<null | {
|
|
|
- executable: any;
|
|
|
- owner: PublicKey;
|
|
|
- lamports: any;
|
|
|
- data: Buffer;
|
|
|
- }> = [];
|
|
|
- for (const account of res.result.value) {
|
|
|
- let value: {
|
|
|
- executable: any;
|
|
|
- owner: PublicKey;
|
|
|
- lamports: any;
|
|
|
- data: Buffer;
|
|
|
- } | null = null;
|
|
|
- if (account === null) {
|
|
|
- accounts.push(null);
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (res.result.value) {
|
|
|
- const { executable, owner, lamports, data } = account;
|
|
|
- assert(data[1] === "base64");
|
|
|
- value = {
|
|
|
- executable,
|
|
|
- owner: new PublicKey(owner),
|
|
|
- lamports,
|
|
|
- data: Buffer.from(data[0], "base64"),
|
|
|
- };
|
|
|
- }
|
|
|
- if (value === null) {
|
|
|
- throw new Error("Invalid response");
|
|
|
- }
|
|
|
- accounts.push(value);
|
|
|
- }
|
|
|
+ const accounts = await connection.getMultipleAccountsInfo(
|
|
|
+ publicKeys,
|
|
|
+ commitment
|
|
|
+ );
|
|
|
return accounts.map((account, idx) => {
|
|
|
if (account === null) {
|
|
|
return null;
|