feat: add `minContextSlot` configuration to (almost) all web3.js methods (#26296)

* feat: add `minContextSlot` config to `getAccountInfo`

* feat: add `minContextSlot` config to `getBalance`

* feat: add `minContextSlot` config to `getBlockHeight``

* feat: add `minContextSlot` config to `getEpochInfo`

* feat: add `minContextSlot` config to `getInflationReward`

* feat: add `minContextSlot` config to `getLatestBlockhash`

* feat: add `minContextSlot` config to `getMultipleAccounts`

* feat: add `minContextSlot` config to `getProgramAccounts`

* feat: add `minContextSlot` config to `getSignaturesForAddress`

* feat: add `minContextSlot` config to `getSlot`

* feat: add `minContextSlot` config to `getSlotLeader`

* feat: add `minContextSlot` config to `getStakeActivation`

* feat: add `minContextSlot` config to `getTokenAccountsByOwner`

* feat: add `minContextSlot` config to `getTransactionCount`

* feat: add `minContextSlot` config to `sendTransaction`
This commit is contained in:
Steven Luscher 2022-06-29 09:22:34 -07:00 committed by GitHub
parent e241906db2
commit f57f228126
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 271 additions and 73 deletions

View File

@ -228,6 +228,8 @@ export type SendOptions = {
preflightCommitment?: Commitment; preflightCommitment?: Commitment;
/** Maximum number of times for the RPC node to retry sending the transaction to the leader. */ /** Maximum number of times for the RPC node to retry sending the transaction to the leader. */
maxRetries?: number; maxRetries?: number;
/** The minimum slot that the request can be evaluated at */
minContextSlot?: number;
}; };
/** /**
@ -242,6 +244,8 @@ export type ConfirmOptions = {
preflightCommitment?: Commitment; preflightCommitment?: Commitment;
/** Maximum number of times for the RPC node to retry sending the transaction to the leader. */ /** Maximum number of times for the RPC node to retry sending the transaction to the leader. */
maxRetries?: number; maxRetries?: number;
/** The minimum slot that the request can be evaluated at */
minContextSlot?: number;
}; };
/** /**
@ -272,6 +276,8 @@ export type SignaturesForAddressOptions = {
until?: TransactionSignature; until?: TransactionSignature;
/** Maximum transaction signatures to return (between 1 and 1,000, default: 1,000). */ /** Maximum transaction signatures to return (between 1 and 1,000, default: 1,000). */
limit?: number; limit?: number;
/** The minimum slot that the request can be evaluated at */
minContextSlot?: number;
}; };
/** /**
@ -297,6 +303,23 @@ export type BlockheightBasedTransactionConfirmationStrategy = {
signature: TransactionSignature; signature: TransactionSignature;
} & BlockhashWithExpiryBlockHeight; } & BlockhashWithExpiryBlockHeight;
/** @internal */
function extractCommitmentFromConfig<TConfig>(
commitmentOrConfig?: Commitment | ({commitment?: Commitment} & TConfig),
) {
let commitment: Commitment | undefined;
let config: Omit<TConfig, 'commitment'> | undefined;
if (typeof commitmentOrConfig === 'string') {
commitment = commitmentOrConfig;
} else if (commitmentOrConfig) {
const {commitment: specifiedCommitment, ...specifiedConfig} =
commitmentOrConfig;
commitment = specifiedCommitment;
config = specifiedConfig;
}
return {commitment, config};
}
/** /**
* @internal * @internal
*/ */
@ -399,6 +422,88 @@ export type Finality = 'confirmed' | 'finalized';
*/ */
export type LargestAccountsFilter = 'circulating' | 'nonCirculating'; export type LargestAccountsFilter = 'circulating' | 'nonCirculating';
/**
* Configuration object for changing `getAccountInfo` query behavior
*/
export type GetAccountInfoConfig = {
/** The level of commitment desired */
commitment?: Commitment;
/** The minimum slot that the request can be evaluated at */
minContextSlot?: number;
};
/**
* Configuration object for changing `getBalance` query behavior
*/
export type GetBalanceConfig = {
/** The level of commitment desired */
commitment?: Commitment;
/** The minimum slot that the request can be evaluated at */
minContextSlot?: number;
};
/**
* Configuration object for changing `getBlockHeight` query behavior
*/
export type GetBlockHeightConfig = {
/** The level of commitment desired */
commitment?: Commitment;
/** The minimum slot that the request can be evaluated at */
minContextSlot?: number;
};
/**
* Configuration object for changing `getEpochInfo` query behavior
*/
export type GetEpochInfoConfig = {
/** The level of commitment desired */
commitment?: Commitment;
/** The minimum slot that the request can be evaluated at */
minContextSlot?: number;
};
/**
* Configuration object for changing `getInflationReward` query behavior
*/
export type GetInflationRewardConfig = {
/** The level of commitment desired */
commitment?: Commitment;
/** An epoch for which the reward occurs. If omitted, the previous epoch will be used */
epoch?: number;
/** The minimum slot that the request can be evaluated at */
minContextSlot?: number;
};
/**
* Configuration object for changing `getLatestBlockhash` query behavior
*/
export type GetLatestBlockhashConfig = {
/** The level of commitment desired */
commitment?: Commitment;
/** The minimum slot that the request can be evaluated at */
minContextSlot?: number;
};
/**
* Configuration object for changing `getSlot` query behavior
*/
export type GetSlotConfig = {
/** The level of commitment desired */
commitment?: Commitment;
/** The minimum slot that the request can be evaluated at */
minContextSlot?: number;
};
/**
* Configuration object for changing `getSlotLeader` query behavior
*/
export type GetSlotLeaderConfig = {
/** The level of commitment desired */
commitment?: Commitment;
/** The minimum slot that the request can be evaluated at */
minContextSlot?: number;
};
/** /**
* Configuration object for changing `getLargestAccounts` query behavior * Configuration object for changing `getLargestAccounts` query behavior
*/ */
@ -1949,6 +2054,8 @@ export type GetProgramAccountsConfig = {
dataSlice?: DataSlice; dataSlice?: DataSlice;
/** Optional array of filters to apply to accounts */ /** Optional array of filters to apply to accounts */
filters?: GetProgramAccountsFilter[]; filters?: GetProgramAccountsFilter[];
/** The minimum slot that the request can be evaluated at */
minContextSlot?: number;
}; };
/** /**
@ -1959,6 +2066,8 @@ export type GetParsedProgramAccountsConfig = {
commitment?: Commitment; commitment?: Commitment;
/** Optional array of filters to apply to accounts */ /** Optional array of filters to apply to accounts */
filters?: GetProgramAccountsFilter[]; filters?: GetProgramAccountsFilter[];
/** The minimum slot that the request can be evaluated at */
minContextSlot?: number;
}; };
/** /**
@ -1967,8 +2076,40 @@ export type GetParsedProgramAccountsConfig = {
export type GetMultipleAccountsConfig = { export type GetMultipleAccountsConfig = {
/** Optional commitment level */ /** Optional commitment level */
commitment?: Commitment; commitment?: Commitment;
/** Optional encoding for account data (default base64) */ /** The minimum slot that the request can be evaluated at */
encoding?: 'base64' | 'jsonParsed'; minContextSlot?: number;
};
/**
* Configuration object for `getStakeActivation`
*/
export type GetStakeActivationConfig = {
/** Optional commitment level */
commitment?: Commitment;
/** Epoch for which to calculate activation details. If parameter not provided, defaults to current epoch */
epoch?: number;
/** The minimum slot that the request can be evaluated at */
minContextSlot?: number;
};
/**
* Configuration object for `getStakeActivation`
*/
export type GetTokenAccountsByOwnerConfig = {
/** Optional commitment level */
commitment?: Commitment;
/** The minimum slot that the request can be evaluated at */
minContextSlot?: number;
};
/**
* Configuration object for `getStakeActivation`
*/
export type GetTransactionCountConfig = {
/** Optional commitment level */
commitment?: Commitment;
/** The minimum slot that the request can be evaluated at */
minContextSlot?: number;
}; };
/** /**
@ -2377,9 +2518,17 @@ export class Connection {
*/ */
async getBalanceAndContext( async getBalanceAndContext(
publicKey: PublicKey, publicKey: PublicKey,
commitment?: Commitment, commitmentOrConfig?: Commitment | GetBalanceConfig,
): Promise<RpcResponseAndContext<number>> { ): Promise<RpcResponseAndContext<number>> {
const args = this._buildArgs([publicKey.toBase58()], commitment); /** @internal */
const {commitment, config} =
extractCommitmentFromConfig(commitmentOrConfig);
const args = this._buildArgs(
[publicKey.toBase58()],
commitment,
undefined /* encoding */,
config,
);
const unsafeRes = await this._rpcRequest('getBalance', args); const unsafeRes = await this._rpcRequest('getBalance', args);
const res = create(unsafeRes, jsonRpcResultAndContext(number())); const res = create(unsafeRes, jsonRpcResultAndContext(number()));
if ('error' in res) { if ('error' in res) {
@ -2398,9 +2547,9 @@ export class Connection {
*/ */
async getBalance( async getBalance(
publicKey: PublicKey, publicKey: PublicKey,
commitment?: Commitment, commitmentOrConfig?: Commitment | GetBalanceConfig,
): Promise<number> { ): Promise<number> {
return await this.getBalanceAndContext(publicKey, commitment) return await this.getBalanceAndContext(publicKey, commitmentOrConfig)
.then(x => x.value) .then(x => x.value)
.catch(e => { .catch(e => {
throw new Error( throw new Error(
@ -2522,12 +2671,14 @@ export class Connection {
async getTokenAccountsByOwner( async getTokenAccountsByOwner(
ownerAddress: PublicKey, ownerAddress: PublicKey,
filter: TokenAccountsFilter, filter: TokenAccountsFilter,
commitment?: Commitment, commitmentOrConfig?: Commitment | GetTokenAccountsByOwnerConfig,
): Promise< ): Promise<
RpcResponseAndContext< RpcResponseAndContext<
Array<{pubkey: PublicKey; account: AccountInfo<Buffer>}> Array<{pubkey: PublicKey; account: AccountInfo<Buffer>}>
> >
> { > {
const {commitment, config} =
extractCommitmentFromConfig(commitmentOrConfig);
let _args: any[] = [ownerAddress.toBase58()]; let _args: any[] = [ownerAddress.toBase58()];
if ('mint' in filter) { if ('mint' in filter) {
_args.push({mint: filter.mint.toBase58()}); _args.push({mint: filter.mint.toBase58()});
@ -2535,7 +2686,7 @@ export class Connection {
_args.push({programId: filter.programId.toBase58()}); _args.push({programId: filter.programId.toBase58()});
} }
const args = this._buildArgs(_args, commitment, 'base64'); const args = this._buildArgs(_args, commitment, 'base64', config);
const unsafeRes = await this._rpcRequest('getTokenAccountsByOwner', args); const unsafeRes = await this._rpcRequest('getTokenAccountsByOwner', args);
const res = create(unsafeRes, GetTokenAccountsByOwner); const res = create(unsafeRes, GetTokenAccountsByOwner);
if ('error' in res) { if ('error' in res) {
@ -2627,9 +2778,16 @@ export class Connection {
*/ */
async getAccountInfoAndContext( async getAccountInfoAndContext(
publicKey: PublicKey, publicKey: PublicKey,
commitment?: Commitment, commitmentOrConfig?: Commitment | GetAccountInfoConfig,
): Promise<RpcResponseAndContext<AccountInfo<Buffer> | null>> { ): Promise<RpcResponseAndContext<AccountInfo<Buffer> | null>> {
const args = this._buildArgs([publicKey.toBase58()], commitment, 'base64'); const {commitment, config} =
extractCommitmentFromConfig(commitmentOrConfig);
const args = this._buildArgs(
[publicKey.toBase58()],
commitment,
'base64',
config,
);
const unsafeRes = await this._rpcRequest('getAccountInfo', args); const unsafeRes = await this._rpcRequest('getAccountInfo', args);
const res = create( const res = create(
unsafeRes, unsafeRes,
@ -2681,10 +2839,13 @@ export class Connection {
*/ */
async getAccountInfo( async getAccountInfo(
publicKey: PublicKey, publicKey: PublicKey,
commitment?: Commitment, commitmentOrConfig?: Commitment | GetAccountInfoConfig,
): Promise<AccountInfo<Buffer> | null> { ): Promise<AccountInfo<Buffer> | null> {
try { try {
const res = await this.getAccountInfoAndContext(publicKey, commitment); const res = await this.getAccountInfoAndContext(
publicKey,
commitmentOrConfig,
);
return res.value; return res.value;
} catch (e) { } catch (e) {
throw new Error( throw new Error(
@ -2698,10 +2859,12 @@ export class Connection {
*/ */
async getMultipleAccountsInfoAndContext( async getMultipleAccountsInfoAndContext(
publicKeys: PublicKey[], publicKeys: PublicKey[],
commitment?: Commitment, commitmentOrConfig?: Commitment | GetMultipleAccountsConfig,
): Promise<RpcResponseAndContext<(AccountInfo<Buffer> | null)[]>> { ): Promise<RpcResponseAndContext<(AccountInfo<Buffer> | null)[]>> {
const {commitment, config} =
extractCommitmentFromConfig(commitmentOrConfig);
const keys = publicKeys.map(key => key.toBase58()); const keys = publicKeys.map(key => key.toBase58());
const args = this._buildArgs([keys], commitment, 'base64'); const args = this._buildArgs([keys], commitment, 'base64', config);
const unsafeRes = await this._rpcRequest('getMultipleAccounts', args); const unsafeRes = await this._rpcRequest('getMultipleAccounts', args);
const res = create( const res = create(
unsafeRes, unsafeRes,
@ -2720,11 +2883,11 @@ export class Connection {
*/ */
async getMultipleAccountsInfo( async getMultipleAccountsInfo(
publicKeys: PublicKey[], publicKeys: PublicKey[],
commitment?: Commitment, commitmentOrConfig?: Commitment | GetMultipleAccountsConfig,
): Promise<(AccountInfo<Buffer> | null)[]> { ): Promise<(AccountInfo<Buffer> | null)[]> {
const res = await this.getMultipleAccountsInfoAndContext( const res = await this.getMultipleAccountsInfoAndContext(
publicKeys, publicKeys,
commitment, commitmentOrConfig,
); );
return res.value; return res.value;
} }
@ -2734,14 +2897,19 @@ export class Connection {
*/ */
async getStakeActivation( async getStakeActivation(
publicKey: PublicKey, publicKey: PublicKey,
commitment?: Commitment, commitmentOrConfig?: Commitment | GetStakeActivationConfig,
epoch?: number, epoch?: number,
): Promise<StakeActivationData> { ): Promise<StakeActivationData> {
const {commitment, config} =
extractCommitmentFromConfig(commitmentOrConfig);
const args = this._buildArgs( const args = this._buildArgs(
[publicKey.toBase58()], [publicKey.toBase58()],
commitment, commitment,
undefined, undefined /* encoding */,
epoch !== undefined ? {epoch} : undefined, {
...config,
epoch: epoch != null ? epoch : config?.epoch,
},
); );
const unsafeRes = await this._rpcRequest('getStakeActivation', args); const unsafeRes = await this._rpcRequest('getStakeActivation', args);
@ -2765,31 +2933,14 @@ export class Connection {
programId: PublicKey, programId: PublicKey,
configOrCommitment?: GetProgramAccountsConfig | Commitment, configOrCommitment?: GetProgramAccountsConfig | Commitment,
): Promise<Array<{pubkey: PublicKey; account: AccountInfo<Buffer>}>> { ): Promise<Array<{pubkey: PublicKey; account: AccountInfo<Buffer>}>> {
const extra: Pick<GetProgramAccountsConfig, 'dataSlice' | 'filters'> = {}; const {commitment, config} =
extractCommitmentFromConfig(configOrCommitment);
let commitment; const {encoding, ...configWithoutEncoding} = config || {};
let encoding;
if (configOrCommitment) {
if (typeof configOrCommitment === 'string') {
commitment = configOrCommitment;
} else {
commitment = configOrCommitment.commitment;
encoding = configOrCommitment.encoding;
if (configOrCommitment.dataSlice) {
extra.dataSlice = configOrCommitment.dataSlice;
}
if (configOrCommitment.filters) {
extra.filters = configOrCommitment.filters;
}
}
}
const args = this._buildArgs( const args = this._buildArgs(
[programId.toBase58()], [programId.toBase58()],
commitment, commitment,
encoding || 'base64', encoding || 'base64',
extra, configWithoutEncoding,
); );
const unsafeRes = await this._rpcRequest('getProgramAccounts', args); const unsafeRes = await this._rpcRequest('getProgramAccounts', args);
const res = create(unsafeRes, jsonRpcResult(array(KeyedAccountInfoResult))); const res = create(unsafeRes, jsonRpcResult(array(KeyedAccountInfoResult)));
@ -2818,26 +2969,13 @@ export class Connection {
account: AccountInfo<Buffer | ParsedAccountData>; account: AccountInfo<Buffer | ParsedAccountData>;
}> }>
> { > {
const extra: Pick<GetParsedProgramAccountsConfig, 'filters'> = {}; const {commitment, config} =
extractCommitmentFromConfig(configOrCommitment);
let commitment;
if (configOrCommitment) {
if (typeof configOrCommitment === 'string') {
commitment = configOrCommitment;
} else {
commitment = configOrCommitment.commitment;
if (configOrCommitment.filters) {
extra.filters = configOrCommitment.filters;
}
}
}
const args = this._buildArgs( const args = this._buildArgs(
[programId.toBase58()], [programId.toBase58()],
commitment, commitment,
'jsonParsed', 'jsonParsed',
extra, config,
); );
const unsafeRes = await this._rpcRequest('getProgramAccounts', args); const unsafeRes = await this._rpcRequest('getProgramAccounts', args);
const res = create( const res = create(
@ -3025,8 +3163,17 @@ export class Connection {
/** /**
* Fetch the current slot that the node is processing * Fetch the current slot that the node is processing
*/ */
async getSlot(commitment?: Commitment): Promise<number> { async getSlot(
const args = this._buildArgs([], commitment); commitmentOrConfig?: Commitment | GetSlotConfig,
): Promise<number> {
const {commitment, config} =
extractCommitmentFromConfig(commitmentOrConfig);
const args = this._buildArgs(
[],
commitment,
undefined /* encoding */,
config,
);
const unsafeRes = await this._rpcRequest('getSlot', args); const unsafeRes = await this._rpcRequest('getSlot', args);
const res = create(unsafeRes, jsonRpcResult(number())); const res = create(unsafeRes, jsonRpcResult(number()));
if ('error' in res) { if ('error' in res) {
@ -3038,8 +3185,17 @@ export class Connection {
/** /**
* Fetch the current slot leader of the cluster * Fetch the current slot leader of the cluster
*/ */
async getSlotLeader(commitment?: Commitment): Promise<string> { async getSlotLeader(
const args = this._buildArgs([], commitment); commitmentOrConfig?: Commitment | GetSlotLeaderConfig,
): Promise<string> {
const {commitment, config} =
extractCommitmentFromConfig(commitmentOrConfig);
const args = this._buildArgs(
[],
commitment,
undefined /* encoding */,
config,
);
const unsafeRes = await this._rpcRequest('getSlotLeader', args); const unsafeRes = await this._rpcRequest('getSlotLeader', args);
const res = create(unsafeRes, jsonRpcResult(string())); const res = create(unsafeRes, jsonRpcResult(string()));
if ('error' in res) { if ('error' in res) {
@ -3105,8 +3261,17 @@ export class Connection {
/** /**
* Fetch the current transaction count of the cluster * Fetch the current transaction count of the cluster
*/ */
async getTransactionCount(commitment?: Commitment): Promise<number> { async getTransactionCount(
const args = this._buildArgs([], commitment); commitmentOrConfig?: Commitment | GetTransactionCountConfig,
): Promise<number> {
const {commitment, config} =
extractCommitmentFromConfig(commitmentOrConfig);
const args = this._buildArgs(
[],
commitment,
undefined /* encoding */,
config,
);
const unsafeRes = await this._rpcRequest('getTransactionCount', args); const unsafeRes = await this._rpcRequest('getTransactionCount', args);
const res = create(unsafeRes, jsonRpcResult(number())); const res = create(unsafeRes, jsonRpcResult(number()));
if ('error' in res) { if ('error' in res) {
@ -3149,14 +3314,17 @@ export class Connection {
async getInflationReward( async getInflationReward(
addresses: PublicKey[], addresses: PublicKey[],
epoch?: number, epoch?: number,
commitment?: Commitment, commitmentOrConfig?: Commitment | GetInflationRewardConfig,
): Promise<(InflationReward | null)[]> { ): Promise<(InflationReward | null)[]> {
const {commitment, config} =
extractCommitmentFromConfig(commitmentOrConfig);
const args = this._buildArgs( const args = this._buildArgs(
[addresses.map(pubkey => pubkey.toBase58())], [addresses.map(pubkey => pubkey.toBase58())],
commitment, commitment,
undefined, undefined /* encoding */,
{ {
epoch, ...config,
epoch: epoch != null ? epoch : config?.epoch,
}, },
); );
const unsafeRes = await this._rpcRequest('getInflationReward', args); const unsafeRes = await this._rpcRequest('getInflationReward', args);
@ -3170,8 +3338,17 @@ export class Connection {
/** /**
* Fetch the Epoch Info parameters * Fetch the Epoch Info parameters
*/ */
async getEpochInfo(commitment?: Commitment): Promise<EpochInfo> { async getEpochInfo(
const args = this._buildArgs([], commitment); commitmentOrConfig?: Commitment | GetEpochInfoConfig,
): Promise<EpochInfo> {
const {commitment, config} =
extractCommitmentFromConfig(commitmentOrConfig);
const args = this._buildArgs(
[],
commitment,
undefined /* encoding */,
config,
);
const unsafeRes = await this._rpcRequest('getEpochInfo', args); const unsafeRes = await this._rpcRequest('getEpochInfo', args);
const res = create(unsafeRes, GetEpochInfoRpcResult); const res = create(unsafeRes, GetEpochInfoRpcResult);
if ('error' in res) { if ('error' in res) {
@ -3344,10 +3521,10 @@ export class Connection {
* @return {Promise<BlockhashWithExpiryBlockHeight>} * @return {Promise<BlockhashWithExpiryBlockHeight>}
*/ */
async getLatestBlockhash( async getLatestBlockhash(
commitment?: Commitment, commitmentOrConfig?: Commitment | GetLatestBlockhashConfig,
): Promise<BlockhashWithExpiryBlockHeight> { ): Promise<BlockhashWithExpiryBlockHeight> {
try { try {
const res = await this.getLatestBlockhashAndContext(commitment); const res = await this.getLatestBlockhashAndContext(commitmentOrConfig);
return res.value; return res.value;
} catch (e) { } catch (e) {
throw new Error('failed to get recent blockhash: ' + e); throw new Error('failed to get recent blockhash: ' + e);
@ -3359,9 +3536,16 @@ export class Connection {
* @return {Promise<BlockhashWithExpiryBlockHeight>} * @return {Promise<BlockhashWithExpiryBlockHeight>}
*/ */
async getLatestBlockhashAndContext( async getLatestBlockhashAndContext(
commitment?: Commitment, commitmentOrConfig?: Commitment | GetLatestBlockhashConfig,
): Promise<RpcResponseAndContext<BlockhashWithExpiryBlockHeight>> { ): Promise<RpcResponseAndContext<BlockhashWithExpiryBlockHeight>> {
const args = this._buildArgs([], commitment); const {commitment, config} =
extractCommitmentFromConfig(commitmentOrConfig);
const args = this._buildArgs(
[],
commitment,
undefined /* encoding */,
config,
);
const unsafeRes = await this._rpcRequest('getLatestBlockhash', args); const unsafeRes = await this._rpcRequest('getLatestBlockhash', args);
const res = create(unsafeRes, GetLatestBlockhashRpcResult); const res = create(unsafeRes, GetLatestBlockhashRpcResult);
if ('error' in res) { if ('error' in res) {
@ -3433,8 +3617,17 @@ export class Connection {
/* /*
* Returns the current block height of the node * Returns the current block height of the node
*/ */
async getBlockHeight(commitment?: Commitment): Promise<number> { async getBlockHeight(
const args = this._buildArgs([], commitment); commitmentOrConfig?: Commitment | GetBlockHeightConfig,
): Promise<number> {
const {commitment, config} =
extractCommitmentFromConfig(commitmentOrConfig);
const args = this._buildArgs(
[],
commitment,
undefined /* encoding */,
config,
);
const unsafeRes = await this._rpcRequest('getBlockHeight', args); const unsafeRes = await this._rpcRequest('getBlockHeight', args);
const res = create(unsafeRes, jsonRpcResult(number())); const res = create(unsafeRes, jsonRpcResult(number()));
if ('error' in res) { if ('error' in res) {
@ -4250,6 +4443,9 @@ export class Connection {
if (options && options.maxRetries) { if (options && options.maxRetries) {
config.maxRetries = options.maxRetries; config.maxRetries = options.maxRetries;
} }
if (options && options.minContextSlot != null) {
config.minContextSlot = options.minContextSlot;
}
if (skipPreflight) { if (skipPreflight) {
config.skipPreflight = skipPreflight; config.skipPreflight = skipPreflight;
} }

View File

@ -68,6 +68,7 @@ export async function sendAndConfirmRawTransaction(
const sendOptions = options && { const sendOptions = options && {
skipPreflight: options.skipPreflight, skipPreflight: options.skipPreflight,
preflightCommitment: options.preflightCommitment || options.commitment, preflightCommitment: options.preflightCommitment || options.commitment,
minContextSlot: options.minContextSlot,
}; };
const signature = await connection.sendRawTransaction( const signature = await connection.sendRawTransaction(

View File

@ -25,6 +25,7 @@ export async function sendAndConfirmTransaction(
skipPreflight: options.skipPreflight, skipPreflight: options.skipPreflight,
preflightCommitment: options.preflightCommitment || options.commitment, preflightCommitment: options.preflightCommitment || options.commitment,
maxRetries: options.maxRetries, maxRetries: options.maxRetries,
minContextSlot: options.minContextSlot,
}; };
const signature = await connection.sendTransaction( const signature = await connection.sendTransaction(