@marinade.finance/web3js-common
Advanced tools
Comparing version 2.3.1 to 2.3.2
{ | ||
"name": "@marinade.finance/web3js-common", | ||
"version": "2.3.1", | ||
"version": "2.3.2", | ||
"description": "Web3 JS reusable utilities", | ||
@@ -24,3 +24,3 @@ "repository": { | ||
"devDependencies": { | ||
"@marinade.finance/ts-common": "2.3.1", | ||
"@marinade.finance/ts-common": "2.3.2", | ||
"@solana/web3.js": "^1.91.1", | ||
@@ -33,3 +33,3 @@ "@solana/buffer-layout": "^4.0.1", | ||
"peerDependencies": { | ||
"@marinade.finance/ts-common": "2.3.1", | ||
"@marinade.finance/ts-common": "2.3.2", | ||
"@solana/web3.js": "^1.91.1", | ||
@@ -36,0 +36,0 @@ "@solana/buffer-layout": "^4.0.1", |
@@ -20,6 +20,7 @@ import { Connection, Transaction, VersionedTransactionResponse, SimulatedTransactionResponse, Keypair, Signer, TransactionInstruction, TransactionResponse, PublicKey, SendOptions, VersionedTransaction, Finality, TransactionSignature } from '@solana/web3.js'; | ||
computeUnitLimit?: number; | ||
confirmWaitTime?: number; | ||
}; | ||
export declare function executeTx({ connection, transaction, signers, errMessage, simulate, printOnly, logger, feePayer, sendOpts, confirmOpts, computeUnitLimit, computeUnitPrice, }: ExecuteTxParams): Promise<VersionedTransactionResponse | SimulatedTransactionResponse | undefined>; | ||
export declare function executeTx({ connection, transaction, signers, errMessage, simulate, printOnly, logger, feePayer, sendOpts, confirmOpts, computeUnitLimit, computeUnitPrice, confirmWaitTime, }: ExecuteTxParams): Promise<VersionedTransactionResponse | SimulatedTransactionResponse | undefined>; | ||
export declare function updateTransactionBlockhash(transaction: Transaction, connection: Connection): Promise<Transaction>; | ||
export declare function confirmTransaction(connection: Connection, txSig: TransactionSignature, confirmOpts?: Finality, logger?: LoggerPlaceholder): Promise<VersionedTransactionResponse | undefined>; | ||
export declare function confirmTransaction(connection: Connection, txSig: TransactionSignature, confirmOpts?: Finality, logger?: LoggerPlaceholder, confirmWaitTime?: number): Promise<VersionedTransactionResponse | undefined>; | ||
export declare function executeTxSimple(connection: Connection, transaction: Transaction, signers?: (Wallet | Keypair | Signer)[], sendOpts?: SendOptions, confirmOpts?: Finality): Promise<VersionedTransactionResponse | SimulatedTransactionResponse | undefined>; | ||
@@ -26,0 +27,0 @@ export declare function executeTxWithExceededBlockhashRetry(txParams: ExecuteTxParams): Promise<VersionedTransactionResponse | SimulatedTransactionResponse | undefined>; |
@@ -31,3 +31,3 @@ "use strict"; | ||
exports.transaction = transaction; | ||
async function executeTx({ connection, transaction, signers = [], errMessage, simulate = false, printOnly = false, logger, feePayer, sendOpts = {}, confirmOpts, computeUnitLimit, computeUnitPrice, }) { | ||
async function executeTx({ connection, transaction, signers = [], errMessage, simulate = false, printOnly = false, logger, feePayer, sendOpts = {}, confirmOpts, computeUnitLimit, computeUnitPrice, confirmWaitTime, }) { | ||
var _a, _b; | ||
@@ -78,3 +78,3 @@ let result = undefined; | ||
// Checking if executed | ||
result = await confirmTransaction(connection, txSig, confirmOpts, logger); | ||
result = await confirmTransaction(connection, txSig, confirmOpts, logger, confirmWaitTime); | ||
} | ||
@@ -119,4 +119,5 @@ } | ||
} | ||
async function confirmTransaction(connection, txSig, confirmOpts, logger) { | ||
async function confirmTransaction(connection, txSig, confirmOpts, logger, confirmWaitTime = 0) { | ||
var _a, _b; | ||
const MAX_WAIT_TIME = 10000; | ||
let confirmFinality = confirmOpts; | ||
@@ -138,4 +139,2 @@ if (confirmFinality === undefined && | ||
const confirmBlockhash = connection.getLatestBlockhash(confirmFinality); | ||
// TODO: waiting time is configured to be reasonable working with public mainnet API | ||
let waitingTime = 3000; | ||
while (txRes === null && | ||
@@ -145,3 +144,9 @@ (await connection.isBlockhashValid((await confirmBlockhash).blockhash, { | ||
})).value) { | ||
await (0, ts_common_1.sleep)(waitingTime < 10000 ? (waitingTime += 1000) : waitingTime); | ||
if (confirmWaitTime > 0) { | ||
confirmWaitTime = | ||
confirmWaitTime < MAX_WAIT_TIME | ||
? (confirmWaitTime += 1000) | ||
: confirmWaitTime; | ||
await (0, ts_common_1.sleep)(confirmWaitTime); | ||
} | ||
try { | ||
@@ -148,0 +153,0 @@ (0, ts_common_1.logDebug)(logger, `Checking outcome of transaction '${txSig}'`); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
117305
1692