feat: implement new response format for __WithCommitment() methods

This commit is contained in:
Sunny Gleason
2019-11-13 17:31:31 -05:00
committed by Michael Vines
parent 890f6f4d9d
commit 5212a98b83
2 changed files with 208 additions and 58 deletions

View File

@ -47,6 +47,13 @@ declare module '@solana/web3.js' {
/* TODO */
// === src/connection.js ===
declare export type RpcResponseAndContext<T> = {
context: {
slot: number,
},
value: T,
};
declare export type Commitment = 'max' | 'recent';
declare export type AccountInfo = {
@ -111,6 +118,10 @@ declare module '@solana/web3.js' {
declare export class Connection {
constructor(endpoint: string, commitment: ?Commitment): Connection;
getAccountInfoAndContext(
publicKey: PublicKey,
commitment: ?Commitment,
): Promise<RpcResponseAndContext<AccountInfo>>;
getAccountInfo(
publicKey: PublicKey,
commitment: ?Commitment,
@ -119,9 +130,17 @@ declare module '@solana/web3.js' {
programId: PublicKey,
commitment: ?Commitment,
): Promise<Array<[PublicKey, AccountInfo]>>;
getBalanceAndContext(
publicKey: PublicKey,
commitment: ?Commitment,
): Promise<RpcResponseAndContext<number>>;
getBalance(publicKey: PublicKey, commitment: ?Commitment): Promise<number>;
getClusterNodes(): Promise<Array<ContactInfo>>;
getVoteAccounts(commitment: ?Commitment): Promise<VoteAccountStatus>;
confirmTransactionAndContext(
signature: TransactionSignature,
commitment: ?Commitment,
): Promise<RpcResponseAndContext<boolean>>;
confirmTransaction(
signature: TransactionSignature,
commitment: ?Commitment,
@ -137,6 +156,9 @@ declare module '@solana/web3.js' {
getVersion(): Promise<Version>;
getInflation(commitment: ?Commitment): Promise<Inflation>;
getEpochSchedule(): Promise<EpochSchedule>;
getRecentBlockhashAndContext(
commitment: ?Commitment,
): Promise<RpcResponseAndContext<[Blockhash, FeeCalculator]>>;
getRecentBlockhash(
commitment: ?Commitment,
): Promise<[Blockhash, FeeCalculator]>;