diff --git a/web3.js/src/connection.ts b/web3.js/src/connection.ts index 36d4b8b74310eb..7bc37a6fdc4ee2 100644 --- a/web3.js/src/connection.ts +++ b/web3.js/src/connection.ts @@ -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 */ @@ -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 */ @@ -3592,11 +3612,14 @@ export class Connection { */ async getBlock( slot: number, - opts?: {commitment?: Finality}, + rawConfig?: GetBlockConfig, ): Promise { + 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); @@ -3684,11 +3707,14 @@ export class Connection { */ async getTransaction( signature: string, - opts?: {commitment?: Finality}, + rawConfig?: GetTransactionConfig, ): Promise { + 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);