diff --git a/web3.js/src/blockhash.js b/web3.js/src/blockhash.js index d275a3a372..fc4677ffcf 100644 --- a/web3.js/src/blockhash.js +++ b/web3.js/src/blockhash.js @@ -1,6 +1,6 @@ // @flow /** - * @typedef {string} Blockhhash + * @typedef {string} Blockhash */ export type Blockhash = string; diff --git a/web3.js/src/connection.js b/web3.js/src/connection.js index a3bdcacf04..b15800b23a 100644 --- a/web3.js/src/connection.js +++ b/web3.js/src/connection.js @@ -21,6 +21,13 @@ import type {TransactionSignature} from './transaction'; type RpcRequest = (methodName: string, args: Array) => any; +/** + * RPC Response with extra contextual information + * + * @typedef {Object} RpcResponseAndContext + * @property {{slot: number}} context + * @property {T} value response + */ type RpcResponseAndContext = { context: { slot: number, @@ -658,22 +665,6 @@ export type TransactionError = {| Err: Object, |}; -/** - * @ignore - */ -type BlockhashAndFeeCalculator = { - blockhash: Blockhash, - feeCalculator: FeeCalculator, -}; // This type exists to workaround an esdoc parse error - -/** - * @ignore - */ -type PublicKeyAndAccount = { - pubkey: PublicKey, - account: AccountInfo, -}; // This type exists to workaround an esdoc parse error - /** * A connection to a fullnode JSON RPC endpoint */ @@ -834,11 +825,13 @@ export class Connection { /** * Fetch all the accounts owned by the specified program id + * + * @return {Promise>} */ async getProgramAccounts( programId: PublicKey, commitment: ?Commitment, - ): Promise> { + ): Promise> { const args = this._argsWithCommitment([programId.toBase58()], commitment); const unsafeRes = await this._rpcRequest('getProgramAccounts', args); const res = GetProgramAccountsRpcResult(unsafeRes); @@ -1060,10 +1053,13 @@ export class Connection { /** * Fetch a recent blockhash from the cluster, return with context + * @return {Promise>} */ async getRecentBlockhashAndContext( commitment: ?Commitment, - ): Promise> { + ): Promise< + RpcResponseAndContext<{blockhash: Blockhash, feeCalculator: FeeCalculator}>, + > { const args = this._argsWithCommitment([], commitment); const unsafeRes = await this._rpcRequest('getRecentBlockhash', args); @@ -1077,10 +1073,11 @@ export class Connection { /** * Fetch a recent blockhash from the cluster + * @return {Promise<{blockhash: Blockhash, feeCalculator: FeeCalculator}>} */ async getRecentBlockhash( commitment: ?Commitment, - ): Promise { + ): Promise<{blockhash: Blockhash, feeCalculator: FeeCalculator}> { return await this.getRecentBlockhashAndContext(commitment) .then(x => x.value) .catch(e => { diff --git a/web3.js/src/index.js b/web3.js/src/index.js index 0fbbac7cc2..527f15e9d1 100644 --- a/web3.js/src/index.js +++ b/web3.js/src/index.js @@ -32,5 +32,7 @@ export { export {sendAndConfirmRawTransaction} from './util/send-and-confirm-raw-transaction'; export {testnetChannelEndpoint} from './util/testnet'; -// There are 1-billion lamports in one SOL +/** + * There are 1-billion lamports in one SOL + */ export const LAMPORTS_PER_SOL = 1000000000;