Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
feat: implement new response format for __WithCommitment() methods
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnygleason committed Nov 16, 2019
1 parent 31ecd91 commit bd987a6
Show file tree
Hide file tree
Showing 2 changed files with 201 additions and 51 deletions.
22 changes: 22 additions & 0 deletions module.flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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]>;
Expand Down
Loading

0 comments on commit bd987a6

Please sign in to comment.