feat: add token methods (#11303)

This commit is contained in:
Justin Starry
2020-07-31 12:33:54 +08:00
committed by GitHub
parent a5b6fd3d9b
commit 5a69c66877
7 changed files with 509 additions and 1 deletions

View File

@@ -66,6 +66,14 @@ declare module '@solana/web3.js' {
skipPreflight: ?boolean,
};
declare export type TokenAccountsFilter =
| {
mint: PublicKey,
}
| {
programId: PublicKey,
};
declare export type RpcResponseAndContext<T> = {
context: Context,
value: T,
@@ -166,6 +174,23 @@ declare module '@solana/web3.js' {
root: number,
};
declare export type TokenAccountInfo = {
mint: PublicKey,
owner: PublicKey,
amount: number,
delegate: null | PublicKey,
delegatedAmount: number,
isInitialized: boolean,
isNative: boolean,
};
declare export type TokenAccount = {
executable: boolean,
owner: PublicKey,
lamports: number,
data: TokenAccountInfo,
};
declare type AccountChangeCallback = (
accountInfo: AccountInfo,
context: Context,
@@ -255,6 +280,21 @@ declare module '@solana/web3.js' {
getMinimumLedgerSlot(): Promise<number>;
getFirstAvailableBlock(): Promise<number>;
getSupply(commitment: ?Commitment): Promise<RpcResponseAndContext<Supply>>;
getTokenSupply(
tokenMintAddress: PublicKey,
commitment: ?Commitment,
): Promise<RpcResponseAndContext<number>>;
getTokenAccountBalance(
tokenAddress: PublicKey,
commitment: ?Commitment,
): Promise<RpcResponseAndContext<number>>;
getTokenAccountsByOwner(
ownerAddress: PublicKey,
filter: TokenAccountsFilter,
commitment: ?Commitment,
): Promise<
RpcResponseAndContext<Array<{pubkey: PublicKey, account: TokenAccount}>>,
>;
getLargestAccounts(
config: ?GetLargestAccountsConfig,
): Promise<RpcResponseAndContext<Array<AccountBalancePair>>>;