chore: fix up docs
This commit is contained in:
parent
8cf98ec4e2
commit
830c55d07b
|
@ -1,6 +1,6 @@
|
|||
// @flow
|
||||
|
||||
/**
|
||||
* @typedef {string} Blockhhash
|
||||
* @typedef {string} Blockhash
|
||||
*/
|
||||
export type Blockhash = string;
|
||||
|
|
|
@ -21,6 +21,13 @@ import type {TransactionSignature} from './transaction';
|
|||
|
||||
type RpcRequest = (methodName: string, args: Array<any>) => any;
|
||||
|
||||
/**
|
||||
* RPC Response with extra contextual information
|
||||
*
|
||||
* @typedef {Object} RpcResponseAndContext
|
||||
* @property {{slot: number}} context
|
||||
* @property {T} value response
|
||||
*/
|
||||
type RpcResponseAndContext<T> = {
|
||||
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<Array<{pubkey: PublicKey, account: AccountInfo}>>}
|
||||
*/
|
||||
async getProgramAccounts(
|
||||
programId: PublicKey,
|
||||
commitment: ?Commitment,
|
||||
): Promise<Array<PublicKeyAndAccount>> {
|
||||
): Promise<Array<{pubkey: PublicKey, account: AccountInfo}>> {
|
||||
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<RpcResponseAndContext<{blockhash: Blockhash, feeCalculator: FeeCalculator}>>}
|
||||
*/
|
||||
async getRecentBlockhashAndContext(
|
||||
commitment: ?Commitment,
|
||||
): Promise<RpcResponseAndContext<BlockhashAndFeeCalculator>> {
|
||||
): 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<BlockhashAndFeeCalculator> {
|
||||
): Promise<{blockhash: Blockhash, feeCalculator: FeeCalculator}> {
|
||||
return await this.getRecentBlockhashAndContext(commitment)
|
||||
.then(x => x.value)
|
||||
.catch(e => {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue