Skip to content

Commit

Permalink
Merge 48137fd into 069dd8a
Browse files Browse the repository at this point in the history
  • Loading branch information
steveluscher authored Jul 22, 2022
2 parents 069dd8a + 48137fd commit 9a5a248
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions web3.js/src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,16 @@ export type GetBalanceConfig = {
minContextSlot?: number;
};

/**
* Configuration object for changing `getBlock` query behavior
*/
export type GetBlockConfig = {
/** The level of finality desired */
commitment?: Finality;
/** The max transaction version to return in responses. If the requested transaction is a higher version, an error will be returned */
maxSupportedTransactionVersion?: number;
};

/**
* Configuration object for changing `getBlockHeight` query behavior
*/
Expand Down Expand Up @@ -505,6 +515,16 @@ export type GetSlotLeaderConfig = {
minContextSlot?: number;
};

/**
* Configuration object for changing `getTransaction` query behavior
*/
export type GetTransactionConfig = {
/** The level of finality desired */
commitment?: Finality;
/** The max transaction version to return in responses. If the requested transaction is a higher version, an error will be returned */
maxSupportedTransactionVersion?: number;
};

/**
* Configuration object for changing `getLargestAccounts` query behavior
*/
Expand Down Expand Up @@ -3592,11 +3612,14 @@ export class Connection {
*/
async getBlock(
slot: number,
opts?: {commitment?: Finality},
rawConfig?: GetBlockConfig,
): Promise<BlockResponse | null> {
const {commitment, config} = extractCommitmentFromConfig(rawConfig);
const args = this._buildArgsAtLeastConfirmed(
[slot],
opts && opts.commitment,
commitment as Finality,
undefined /* encoding */,
config,
);
const unsafeRes = await this._rpcRequest('getBlock', args);
const res = create(unsafeRes, GetBlockRpcResult);
Expand Down Expand Up @@ -3684,11 +3707,14 @@ export class Connection {
*/
async getTransaction(
signature: string,
opts?: {commitment?: Finality},
rawConfig?: GetTransactionConfig,
): Promise<TransactionResponse | null> {
const {commitment, config} = extractCommitmentFromConfig(rawConfig);
const args = this._buildArgsAtLeastConfirmed(
[signature],
opts && opts.commitment,
commitment as Finality,
undefined /* encoding */,
config,
);
const unsafeRes = await this._rpcRequest('getTransaction', args);
const res = create(unsafeRes, GetTransactionRpcResult);
Expand Down

0 comments on commit 9a5a248

Please sign in to comment.