@stabbleorg/anchor-contrib
Advanced tools
Comparing version 1.2.4 to 1.3.0
import { Provider } from "@coral-xyz/anchor"; | ||
import { AddressLookupTableAccount, BlockhashWithExpiryBlockHeight, ConfirmOptions, PublicKey, Signer, TokenAccountBalancePair, TransactionInstruction, TransactionSignature, VersionedTransaction } from "@solana/web3.js"; | ||
import { AddressLookupTableAccount, BlockhashWithExpiryBlockHeight, Commitment, PublicKey, SendOptions, Signer, TokenAccountBalancePair, TransactionInstruction, TransactionSignature, VersionedTransaction } from "@solana/web3.js"; | ||
import { PriorityLevel } from "./helius"; | ||
import { AddressWithTransactionInstruction, FloatLike, TransactionWithBlockhash } from "./types"; | ||
export interface UseWalletProvider extends Provider { | ||
sendAndConfirmWithBlockhash(transaction: VersionedTransaction, signers?: Signer[], options?: ConfirmOptions, blockhash?: BlockhashWithExpiryBlockHeight): Promise<TransactionSignature>; | ||
sendAndConfirmWithBlockhash(transaction: VersionedTransaction, signers?: Signer[], sendOptions?: SendOptions, blockhash?: BlockhashWithExpiryBlockHeight): Promise<TransactionSignature>; | ||
} | ||
@@ -18,5 +18,5 @@ export declare class WalletContext<T extends Provider = Provider> { | ||
getTokenBalances(): Promise<TokenAccountBalancePair[]>; | ||
getPriorityFeeEstimate(transaction: VersionedTransaction, priorityLevel?: PriorityLevel): Promise<number>; | ||
createSmartTransaction(instructions: TransactionInstruction[], altAccounts?: AddressLookupTableAccount[], priorityLevel?: PriorityLevel): Promise<TransactionWithBlockhash>; | ||
sendSmartTransaction(instructions: TransactionInstruction[], signers?: Signer[], altAccounts?: AddressLookupTableAccount[], priorityLevel?: PriorityLevel, options?: ConfirmOptions): Promise<TransactionSignature>; | ||
getPriorityFeeEstimate(transaction: VersionedTransaction, priorityLevel: PriorityLevel): Promise<number>; | ||
createSmartTransaction(instructions: TransactionInstruction[], altAccounts: AddressLookupTableAccount[] | undefined, priorityLevel: PriorityLevel): Promise<TransactionWithBlockhash>; | ||
sendSmartTransaction(instructions: TransactionInstruction[], signers?: Signer[], altAccounts?: AddressLookupTableAccount[], priorityLevel?: PriorityLevel, commitment?: Commitment): Promise<TransactionSignature>; | ||
} |
@@ -134,4 +134,4 @@ "use strict"; | ||
} | ||
getPriorityFeeEstimate(transaction_1) { | ||
return __awaiter(this, arguments, void 0, function* (transaction, priorityLevel = "High") { | ||
getPriorityFeeEstimate(transaction, priorityLevel) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
@@ -206,7 +206,12 @@ const response = yield fetch(this.provider.connection.rpcEndpoint, { | ||
sendSmartTransaction(instructions_1) { | ||
return __awaiter(this, arguments, void 0, function* (instructions, signers = [], altAccounts = [], priorityLevel, options) { | ||
return __awaiter(this, arguments, void 0, function* (instructions, signers = [], altAccounts = [], priorityLevel = "High", commitment = "confirmed") { | ||
const { transaction, blockhash, minContextSlot } = yield this.createSmartTransaction(instructions, altAccounts, priorityLevel); | ||
const confirmOptions = Object.assign({ maxRetries: 0, commitment: "confirmed", preflightCommitment: "confirmed", skipPreflight: true, minContextSlot }, options); | ||
const sendOptions = { | ||
maxRetries: 0, | ||
preflightCommitment: commitment, | ||
skipPreflight: true, | ||
minContextSlot, | ||
}; | ||
if ("sendAndConfirmWithBlockhash" in this.provider) { | ||
return this.provider.sendAndConfirmWithBlockhash(transaction, signers, confirmOptions, blockhash); | ||
return this.provider.sendAndConfirmWithBlockhash(transaction, signers, sendOptions, blockhash); | ||
} | ||
@@ -220,5 +225,5 @@ if (this.provider instanceof anchor_1.AnchorProvider) { | ||
try { | ||
const signature = yield this.provider.connection.sendRawTransaction(txBuff, confirmOptions); | ||
const signature = yield this.provider.connection.sendRawTransaction(txBuff, sendOptions); | ||
const abortSignal = AbortSignal.timeout(helius_1.SMART_TRANSACTION_RETRY_TIMEOUT); | ||
yield this.provider.connection.confirmTransaction(Object.assign({ abortSignal, signature }, blockhash), confirmOptions.commitment); | ||
yield this.provider.connection.confirmTransaction(Object.assign({ abortSignal, signature }, blockhash), commitment); | ||
abortSignal.removeEventListener("abort", () => { }); | ||
@@ -225,0 +230,0 @@ return signature; |
{ | ||
"name": "@stabbleorg/anchor-contrib", | ||
"version": "1.2.4", | ||
"version": "1.3.0", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
@@ -19,9 +19,9 @@ import bs58 from "bs58"; | ||
BlockhashWithExpiryBlockHeight, | ||
Commitment, | ||
ComputeBudgetProgram, | ||
ConfirmOptions, | ||
PublicKey, | ||
SendOptions, | ||
Signer, | ||
SystemProgram, | ||
TokenAccountBalancePair, | ||
TransactionExpiredTimeoutError, | ||
TransactionInstruction, | ||
@@ -49,3 +49,3 @@ TransactionMessage, | ||
signers?: Signer[], | ||
options?: ConfirmOptions, | ||
sendOptions?: SendOptions, | ||
blockhash?: BlockhashWithExpiryBlockHeight, | ||
@@ -179,3 +179,3 @@ ): Promise<TransactionSignature>; | ||
transaction: VersionedTransaction, | ||
priorityLevel: PriorityLevel = "High", | ||
priorityLevel: PriorityLevel, | ||
): Promise<number> { | ||
@@ -210,3 +210,3 @@ try { | ||
altAccounts: AddressLookupTableAccount[] = [], | ||
priorityLevel?: PriorityLevel, | ||
priorityLevel: PriorityLevel, | ||
): Promise<TransactionWithBlockhash> { | ||
@@ -279,4 +279,4 @@ const { | ||
altAccounts: AddressLookupTableAccount[] = [], | ||
priorityLevel?: PriorityLevel, | ||
options?: ConfirmOptions, | ||
priorityLevel: PriorityLevel = "High", | ||
commitment: Commitment = "confirmed", | ||
): Promise<TransactionSignature> { | ||
@@ -289,9 +289,7 @@ const { transaction, blockhash, minContextSlot } = await this.createSmartTransaction( | ||
const confirmOptions: ConfirmOptions = { | ||
const sendOptions: SendOptions = { | ||
maxRetries: 0, | ||
commitment: "confirmed", | ||
preflightCommitment: "confirmed", | ||
preflightCommitment: commitment, | ||
skipPreflight: true, | ||
minContextSlot, | ||
...options, | ||
}; | ||
@@ -303,3 +301,3 @@ | ||
signers, | ||
confirmOptions, | ||
sendOptions, | ||
blockhash, | ||
@@ -317,9 +315,6 @@ ); | ||
try { | ||
const signature = await this.provider.connection.sendRawTransaction(txBuff, confirmOptions); | ||
const signature = await this.provider.connection.sendRawTransaction(txBuff, sendOptions); | ||
const abortSignal = AbortSignal.timeout(SMART_TRANSACTION_RETRY_TIMEOUT); | ||
await this.provider.connection.confirmTransaction( | ||
{ abortSignal, signature, ...blockhash }, | ||
confirmOptions.commitment, | ||
); | ||
await this.provider.connection.confirmTransaction({ abortSignal, signature, ...blockhash }, commitment); | ||
abortSignal.removeEventListener("abort", () => {}); | ||
@@ -326,0 +321,0 @@ |
Sorry, the diff of this file is not supported yet
48082