feat: add parsed account data APIs

This commit is contained in:
Justin Starry
2020-08-06 23:47:22 +08:00
committed by Justin Starry
parent b36e60738e
commit c7a2fbe7eb
5 changed files with 452 additions and 59 deletions

View File

@ -125,16 +125,16 @@ declare module '@solana/web3.js' {
feeCalculator: FeeCalculator,
};
declare export type PublicKeyAndAccount = {
declare export type PublicKeyAndAccount<T> = {
pubkey: PublicKey,
account: AccountInfo,
account: AccountInfo<T>,
};
declare export type AccountInfo = {
declare export type AccountInfo<T> = {
executable: boolean,
owner: PublicKey,
lamports: number,
data: Buffer,
data: T,
rentEpoch: number | null,
};
@ -169,6 +169,11 @@ declare module '@solana/web3.js' {
meta: ConfirmedTransactionMeta | null,
};
declare export type ParsedAccountData = {
program: string,
parsed: any,
};
declare export type ParsedMessageAccount = {
pubkey: PublicKey,
signer: boolean,
@ -204,7 +209,7 @@ declare module '@solana/web3.js' {
declare export type KeyedAccountInfo = {
accountId: PublicKey,
accountInfo: AccountInfo,
accountInfo: AccountInfo<Buffer>,
};
declare export type Version = {
@ -231,7 +236,7 @@ declare module '@solana/web3.js' {
};
declare type AccountChangeCallback = (
accountInfo: AccountInfo,
accountInfo: AccountInfo<Buffer>,
context: Context,
) => void;
declare type ProgramAccountChangeCallback = (
@ -301,15 +306,25 @@ declare module '@solana/web3.js' {
getAccountInfoAndContext(
publicKey: PublicKey,
commitment: ?Commitment,
): Promise<RpcResponseAndContext<AccountInfo | null>>;
): Promise<RpcResponseAndContext<AccountInfo<Buffer> | null>>;
getAccountInfo(
publicKey: PublicKey,
commitment: ?Commitment,
): Promise<AccountInfo | null>;
): Promise<AccountInfo<Buffer> | null>;
getParsedAccountInfo(
publicKey: PublicKey,
commitment: ?Commitment,
): Promise<
RpcResponseAndContext<AccountInfo<Buffer | ParsedAccountData> | null>,
>;
getProgramAccounts(
programId: PublicKey,
commitment: ?Commitment,
): Promise<Array<PublicKeyAndAccount>>;
): Promise<Array<PublicKeyAndAccount<Buffer>>>;
getParsedProgramAccounts(
programId: PublicKey,
commitment: ?Commitment,
): Promise<Array<PublicKeyAndAccount<Buffer | ParsedAccountData>>>;
getBalanceAndContext(
publicKey: PublicKey,
commitment: ?Commitment,
@ -332,7 +347,9 @@ declare module '@solana/web3.js' {
filter: TokenAccountsFilter,
commitment: ?Commitment,
): Promise<
RpcResponseAndContext<Array<{pubkey: PublicKey, account: AccountInfo}>>,
RpcResponseAndContext<
Array<{pubkey: PublicKey, account: AccountInfo<Buffer>}>,
>,
>;
getLargestAccounts(
config: ?GetLargestAccountsConfig,