feat: add getMultipleAccountsInfo which uses the getMultipleAccounts RPC method (#18736)
* feat(web3): add getMultipleAccountsInfo which uses the getMultipleAccounts RPC method * fix: add airdrop to get multiple accounts info Co-authored-by: Josh Hundley <josh.hundley@gmail.com>
This commit is contained in:
@@ -2407,6 +2407,28 @@ export class Connection {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch all the account info for multiple accounts specified by an array of public keys
|
||||
*/
|
||||
async getMultipleAccountsInfo(
|
||||
publicKeys: PublicKey[],
|
||||
commitment?: Commitment,
|
||||
): Promise<AccountInfo<Buffer>[] | null> {
|
||||
const keys = publicKeys.map(key => key.toBase58());
|
||||
const args = this._buildArgs([keys], commitment, 'base64');
|
||||
const unsafeRes = await this._rpcRequest('getMultipleAccounts', args);
|
||||
const res = create(
|
||||
unsafeRes,
|
||||
jsonRpcResultAndContext(nullable(array(AccountInfoResult))),
|
||||
);
|
||||
if ('error' in res) {
|
||||
throw new Error(
|
||||
'failed to get info for accounts ' + keys + ': ' + res.error.message,
|
||||
);
|
||||
}
|
||||
return res.result.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns epoch activation information for a stake account that has been delegated
|
||||
*/
|
||||
|
Reference in New Issue
Block a user