Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add maxSupportedTransactionVersion option to getBlock and getTransaction #26726

Merged
merged 1 commit into from
Jul 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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