chore: add encoding param to getMultipleAccounts
This commit is contained in:
parent
6895eb7ef6
commit
33ad74fbcd
|
@ -1711,6 +1711,16 @@ export type GetParsedProgramAccountsConfig = {
|
|||
filters?: GetProgramAccountsFilter[];
|
||||
};
|
||||
|
||||
/**
|
||||
* Configuration object for getMultipleAccounts
|
||||
*/
|
||||
export type GetMultipleAccountsConfig = {
|
||||
/** Optional commitment level */
|
||||
commitment?: Commitment;
|
||||
/** Optional encoding for account data (default base64) */
|
||||
encoding?: 'base64' | 'jsonParsed';
|
||||
};
|
||||
|
||||
/**
|
||||
* Information describing an account
|
||||
*/
|
||||
|
@ -2479,14 +2489,27 @@ export class Connection {
|
|||
*/
|
||||
async getMultipleAccountsInfo(
|
||||
publicKeys: PublicKey[],
|
||||
commitment?: Commitment,
|
||||
): Promise<(AccountInfo<Buffer> | null)[]> {
|
||||
configOrCommitment?: GetMultipleAccountsConfig | Commitment,
|
||||
): Promise<(AccountInfo<Buffer | ParsedAccountData> | null)[]> {
|
||||
const keys = publicKeys.map(key => key.toBase58());
|
||||
const args = this._buildArgs([keys], commitment, 'base64');
|
||||
|
||||
let commitment;
|
||||
let encoding: 'base64' | 'jsonParsed' = 'base64';
|
||||
if (configOrCommitment) {
|
||||
if (typeof configOrCommitment === 'string') {
|
||||
commitment = configOrCommitment;
|
||||
encoding = 'base64';
|
||||
} else {
|
||||
commitment = configOrCommitment.commitment;
|
||||
encoding = configOrCommitment.encoding || 'base64';
|
||||
}
|
||||
}
|
||||
|
||||
const args = this._buildArgs([keys], commitment, encoding);
|
||||
const unsafeRes = await this._rpcRequest('getMultipleAccounts', args);
|
||||
const res = create(
|
||||
unsafeRes,
|
||||
jsonRpcResultAndContext(array(nullable(AccountInfoResult))),
|
||||
jsonRpcResultAndContext(array(nullable(ParsedAccountInfoResult))),
|
||||
);
|
||||
if ('error' in res) {
|
||||
throw new Error(
|
||||
|
|
Loading…
Reference in New Issue