feat: add preflightCommitment support (#12451)
This commit is contained in:
parent
018cb5035a
commit
720f863937
|
@ -48,11 +48,13 @@ declare module '@solana/web3.js' {
|
|||
|
||||
export type SendOptions = {
|
||||
skipPreflight?: boolean;
|
||||
preflightCommitment?: Commitment;
|
||||
};
|
||||
|
||||
export type ConfirmOptions = {
|
||||
commitment?: Commitment;
|
||||
skipPreflight?: boolean;
|
||||
preflightCommitment?: Commitment;
|
||||
};
|
||||
|
||||
export type ConfirmedSignaturesForAddress2Options = {
|
||||
|
|
|
@ -62,11 +62,13 @@ declare module '@solana/web3.js' {
|
|||
|
||||
declare export type SendOptions = {
|
||||
skipPreflight: ?boolean,
|
||||
preflightCommitment: ?Commitment,
|
||||
};
|
||||
|
||||
declare export type ConfirmOptions = {
|
||||
commitment: ?Commitment,
|
||||
skipPreflight: ?boolean,
|
||||
preflightCommitment: ?Commitment,
|
||||
};
|
||||
|
||||
declare export type ConfirmedSignaturesForAddress2Options = {
|
||||
|
|
|
@ -48,9 +48,11 @@ type Context = {
|
|||
*
|
||||
* @typedef {Object} SendOptions
|
||||
* @property {boolean | undefined} skipPreflight disable transaction verification step
|
||||
* @property {Commitment | undefined} preflightCommitment preflight commitment level
|
||||
*/
|
||||
export type SendOptions = {
|
||||
skipPreflight?: boolean,
|
||||
preflightCommitment?: Commitment,
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -59,10 +61,12 @@ export type SendOptions = {
|
|||
* @typedef {Object} ConfirmOptions
|
||||
* @property {boolean | undefined} skipPreflight disable transaction verification step
|
||||
* @property {Commitment | undefined} commitment desired commitment level
|
||||
* @property {Commitment | undefined} preflightCommitment preflight commitment level
|
||||
*/
|
||||
export type ConfirmOptions = {
|
||||
skipPreflight?: boolean,
|
||||
commitment?: Commitment,
|
||||
preflightCommitment?: Commitment,
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -2755,7 +2759,20 @@ export class Connection {
|
|||
): Promise<TransactionSignature> {
|
||||
const args = [encodedTransaction];
|
||||
const skipPreflight = options && options.skipPreflight;
|
||||
if (skipPreflight) args.push({skipPreflight});
|
||||
const preflightCommitment = options && options.preflightCommitment;
|
||||
|
||||
if (skipPreflight && preflightCommitment) {
|
||||
throw new Error(
|
||||
'cannot set preflightCommitment when skipPreflight is enabled',
|
||||
);
|
||||
}
|
||||
|
||||
if (skipPreflight) {
|
||||
args.push({skipPreflight});
|
||||
} else if (preflightCommitment) {
|
||||
args.push({preflightCommitment});
|
||||
}
|
||||
|
||||
const unsafeRes = await this._rpcRequest('sendTransaction', args);
|
||||
const res = SendTransactionRpcResult(unsafeRes);
|
||||
if (res.error) {
|
||||
|
|
Loading…
Reference in New Issue