@pythnetwork/solana-utils
Advanced tools
Comparing version
@@ -284,38 +284,40 @@ "use strict"; | ||
: tx.signature ?? new Uint8Array()); | ||
try { | ||
const confirmTransactionPromise = connection.confirmTransaction({ | ||
signature: txSignature, | ||
blockhash: blockhashResult.value.blockhash, | ||
lastValidBlockHeight: blockhashResult.value.lastValidBlockHeight, | ||
}, "confirmed"); | ||
confirmedTx = null; | ||
while (!confirmedTx) { | ||
confirmedTx = await Promise.race([ | ||
confirmTransactionPromise, | ||
new Promise((resolve) => setTimeout(() => { | ||
resolve(null); | ||
}, TX_RETRY_INTERVAL)), | ||
]); | ||
if (confirmedTx) { | ||
break; | ||
} | ||
if (maxRetries && maxRetries < retryCount) { | ||
break; | ||
} | ||
console.log("Retrying transaction ", index, " of ", transactions.length - 1, " with signature: ", txSignature, " Retry count: ", retryCount); | ||
retryCount++; | ||
await connection.sendRawTransaction(tx.serialize(), { | ||
// Skipping preflight i.e. tx simulation by RPC as we simulated the tx above | ||
// This allows Triton RPCs to send the transaction through multiple pathways for the fastest delivery | ||
skipPreflight: true, | ||
// Setting max retries to 0 as we are handling retries manually | ||
// Set this manually so that the default is skipped | ||
maxRetries: 0, | ||
preflightCommitment: "confirmed", | ||
minContextSlot: blockhashResult.context.slot, | ||
}); | ||
const confirmTransactionPromise = connection.confirmTransaction({ | ||
signature: txSignature, | ||
blockhash: blockhashResult.value.blockhash, | ||
lastValidBlockHeight: blockhashResult.value.lastValidBlockHeight, | ||
}, "confirmed"); | ||
confirmedTx = null; | ||
while (!confirmedTx) { | ||
confirmedTx = await Promise.race([ | ||
new Promise((resolve) => { | ||
confirmTransactionPromise.then((result) => { | ||
resolve(result.value); | ||
}); | ||
}), | ||
new Promise((resolve) => setTimeout(() => { | ||
resolve(null); | ||
}, TX_RETRY_INTERVAL)), | ||
]); | ||
if (confirmedTx) { | ||
break; | ||
} | ||
if (maxRetries && maxRetries < retryCount) { | ||
break; | ||
} | ||
console.log("Retrying transaction ", index, " of ", transactions.length - 1, " with signature: ", txSignature, " Retry count: ", retryCount); | ||
retryCount++; | ||
await connection.sendRawTransaction(tx.serialize(), { | ||
// Skipping preflight i.e. tx simulation by RPC as we simulated the tx above | ||
// This allows Triton RPCs to send the transaction through multiple pathways for the fastest delivery | ||
skipPreflight: true, | ||
// Setting max retries to 0 as we are handling retries manually | ||
// Set this manually so that the default is skipped | ||
maxRetries: 0, | ||
preflightCommitment: "confirmed", | ||
minContextSlot: blockhashResult.context.slot, | ||
}); | ||
} | ||
catch (error) { | ||
console.error(error); | ||
if (confirmedTx?.err) { | ||
throw new Error(`Transaction ${txSignature} has failed with error: ${JSON.stringify(confirmedTx.err)}`); | ||
} | ||
@@ -322,0 +324,0 @@ if (!confirmedTx) { |
{ | ||
"name": "@pythnetwork/solana-utils", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "Utility functions for Solana", | ||
@@ -50,3 +50,3 @@ "homepage": "https://pyth.network", | ||
}, | ||
"gitHead": "56cbace282dcdce0099a188a637493ce6bf2312c" | ||
"gitHead": "508de7583953af4299143affea71f8dd4633cd32" | ||
} |
Sorry, the diff of this file is not supported yet
31957
0.3%525
0.38%