@solana/web3.js 1.41.11 → 1.42.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.browser.cjs.js +44 -22
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +44 -22
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +44 -22
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +24 -15
- package/lib/index.esm.js +44 -22
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +44 -22
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +1 -1
- package/lib/index.iife.min.js.map +1 -1
- package/package.json +1 -1
- package/src/connection.ts +40 -27
- package/src/util/send-and-confirm-raw-transaction.ts +52 -7
package/lib/index.cjs.js
CHANGED
|
@@ -5564,7 +5564,7 @@ class Connection {
|
|
|
5564
5564
|
this._disableBlockhashCaching = false;
|
|
5565
5565
|
this._pollingBlockhash = false;
|
|
5566
5566
|
this._blockhashInfo = {
|
|
5567
|
-
|
|
5567
|
+
latestBlockhash: null,
|
|
5568
5568
|
lastFetch: 0,
|
|
5569
5569
|
transactionSignatures: [],
|
|
5570
5570
|
simulatedSignatures: []
|
|
@@ -6527,7 +6527,7 @@ class Connection {
|
|
|
6527
6527
|
}
|
|
6528
6528
|
/**
|
|
6529
6529
|
* Fetch the latest blockhash from the cluster
|
|
6530
|
-
* @return {Promise<
|
|
6530
|
+
* @return {Promise<BlockhashWithExpiryBlockHeight>}
|
|
6531
6531
|
*/
|
|
6532
6532
|
|
|
6533
6533
|
|
|
@@ -6541,7 +6541,7 @@ class Connection {
|
|
|
6541
6541
|
}
|
|
6542
6542
|
/**
|
|
6543
6543
|
* Fetch the latest blockhash from the cluster
|
|
6544
|
-
* @return {Promise<
|
|
6544
|
+
* @return {Promise<BlockhashWithExpiryBlockHeight>}
|
|
6545
6545
|
*/
|
|
6546
6546
|
|
|
6547
6547
|
|
|
@@ -7124,7 +7124,7 @@ class Connection {
|
|
|
7124
7124
|
*/
|
|
7125
7125
|
|
|
7126
7126
|
|
|
7127
|
-
async
|
|
7127
|
+
async _blockhashWithExpiryBlockHeight(disableCache) {
|
|
7128
7128
|
if (!disableCache) {
|
|
7129
7129
|
// Wait for polling to finish
|
|
7130
7130
|
while (this._pollingBlockhash) {
|
|
@@ -7135,8 +7135,8 @@ class Connection {
|
|
|
7135
7135
|
|
|
7136
7136
|
const expired = timeSinceFetch >= BLOCKHASH_CACHE_TIMEOUT_MS;
|
|
7137
7137
|
|
|
7138
|
-
if (this._blockhashInfo.
|
|
7139
|
-
return this._blockhashInfo.
|
|
7138
|
+
if (this._blockhashInfo.latestBlockhash !== null && !expired) {
|
|
7139
|
+
return this._blockhashInfo.latestBlockhash;
|
|
7140
7140
|
}
|
|
7141
7141
|
}
|
|
7142
7142
|
|
|
@@ -7152,20 +7152,20 @@ class Connection {
|
|
|
7152
7152
|
|
|
7153
7153
|
try {
|
|
7154
7154
|
const startTime = Date.now();
|
|
7155
|
+
const cachedLatestBlockhash = this._blockhashInfo.latestBlockhash;
|
|
7156
|
+
const cachedBlockhash = cachedLatestBlockhash ? cachedLatestBlockhash.blockhash : null;
|
|
7155
7157
|
|
|
7156
7158
|
for (let i = 0; i < 50; i++) {
|
|
7157
|
-
const
|
|
7158
|
-
blockhash
|
|
7159
|
-
} = await this.getRecentBlockhash('finalized');
|
|
7159
|
+
const latestBlockhash = await this.getLatestBlockhash('finalized');
|
|
7160
7160
|
|
|
7161
|
-
if (
|
|
7161
|
+
if (cachedBlockhash !== latestBlockhash.blockhash) {
|
|
7162
7162
|
this._blockhashInfo = {
|
|
7163
|
-
|
|
7163
|
+
latestBlockhash,
|
|
7164
7164
|
lastFetch: Date.now(),
|
|
7165
7165
|
transactionSignatures: [],
|
|
7166
7166
|
simulatedSignatures: []
|
|
7167
7167
|
};
|
|
7168
|
-
return
|
|
7168
|
+
return latestBlockhash;
|
|
7169
7169
|
} // Sleep for approximately half a slot
|
|
7170
7170
|
|
|
7171
7171
|
|
|
@@ -7187,13 +7187,11 @@ class Connection {
|
|
|
7187
7187
|
|
|
7188
7188
|
if (transactionOrMessage instanceof Transaction) {
|
|
7189
7189
|
let originalTx = transactionOrMessage;
|
|
7190
|
-
transaction = new Transaction(
|
|
7191
|
-
|
|
7192
|
-
nonceInfo: originalTx.nonceInfo,
|
|
7193
|
-
feePayer: originalTx.feePayer,
|
|
7194
|
-
signatures: [...originalTx.signatures]
|
|
7195
|
-
});
|
|
7190
|
+
transaction = new Transaction();
|
|
7191
|
+
transaction.feePayer = originalTx.feePayer;
|
|
7196
7192
|
transaction.instructions = transactionOrMessage.instructions;
|
|
7193
|
+
transaction.nonceInfo = originalTx.nonceInfo;
|
|
7194
|
+
transaction.signatures = originalTx.signatures;
|
|
7197
7195
|
} else {
|
|
7198
7196
|
transaction = Transaction.populate(transactionOrMessage); // HACK: this function relies on mutating the populated transaction
|
|
7199
7197
|
|
|
@@ -7206,7 +7204,9 @@ class Connection {
|
|
|
7206
7204
|
let disableCache = this._disableBlockhashCaching;
|
|
7207
7205
|
|
|
7208
7206
|
for (;;) {
|
|
7209
|
-
|
|
7207
|
+
const latestBlockhash = await this._blockhashWithExpiryBlockHeight(disableCache);
|
|
7208
|
+
transaction.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight;
|
|
7209
|
+
transaction.recentBlockhash = latestBlockhash.blockhash;
|
|
7210
7210
|
if (!signers) break;
|
|
7211
7211
|
transaction.sign(...signers);
|
|
7212
7212
|
|
|
@@ -7290,7 +7290,9 @@ class Connection {
|
|
|
7290
7290
|
let disableCache = this._disableBlockhashCaching;
|
|
7291
7291
|
|
|
7292
7292
|
for (;;) {
|
|
7293
|
-
|
|
7293
|
+
const latestBlockhash = await this._blockhashWithExpiryBlockHeight(disableCache);
|
|
7294
|
+
transaction.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight;
|
|
7295
|
+
transaction.recentBlockhash = latestBlockhash.blockhash;
|
|
7294
7296
|
transaction.sign(...signers);
|
|
7295
7297
|
|
|
7296
7298
|
if (!transaction.signature) {
|
|
@@ -9729,16 +9731,36 @@ VoteProgram.space = 3731;
|
|
|
9729
9731
|
*
|
|
9730
9732
|
* @param {Connection} connection
|
|
9731
9733
|
* @param {Buffer} rawTransaction
|
|
9734
|
+
* @param {BlockheightBasedTransactionConfimationStrategy} confirmationStrategy
|
|
9732
9735
|
* @param {ConfirmOptions} [options]
|
|
9733
9736
|
* @returns {Promise<TransactionSignature>}
|
|
9734
9737
|
*/
|
|
9735
|
-
|
|
9738
|
+
|
|
9739
|
+
/**
|
|
9740
|
+
* @deprecated Calling `sendAndConfirmRawTransaction()` without a `confirmationStrategy`
|
|
9741
|
+
* is no longer supported and will be removed in a future version.
|
|
9742
|
+
*/
|
|
9743
|
+
// eslint-disable-next-line no-redeclare
|
|
9744
|
+
// eslint-disable-next-line no-redeclare
|
|
9745
|
+
async function sendAndConfirmRawTransaction(connection, rawTransaction, confirmationStrategyOrConfirmOptions, maybeConfirmOptions) {
|
|
9746
|
+
let confirmationStrategy;
|
|
9747
|
+
let options;
|
|
9748
|
+
|
|
9749
|
+
if (confirmationStrategyOrConfirmOptions && Object.prototype.hasOwnProperty.call(confirmationStrategyOrConfirmOptions, 'lastValidBlockHeight')) {
|
|
9750
|
+
confirmationStrategy = confirmationStrategyOrConfirmOptions;
|
|
9751
|
+
options = maybeConfirmOptions;
|
|
9752
|
+
} else {
|
|
9753
|
+
options = confirmationStrategyOrConfirmOptions;
|
|
9754
|
+
}
|
|
9755
|
+
|
|
9736
9756
|
const sendOptions = options && {
|
|
9737
9757
|
skipPreflight: options.skipPreflight,
|
|
9738
9758
|
preflightCommitment: options.preflightCommitment || options.commitment
|
|
9739
9759
|
};
|
|
9740
9760
|
const signature = await connection.sendRawTransaction(rawTransaction, sendOptions);
|
|
9741
|
-
const
|
|
9761
|
+
const commitment = options && options.commitment;
|
|
9762
|
+
const confirmationPromise = confirmationStrategy ? connection.confirmTransaction(confirmationStrategy, commitment) : connection.confirmTransaction(signature, commitment);
|
|
9763
|
+
const status = (await confirmationPromise).value;
|
|
9742
9764
|
|
|
9743
9765
|
if (status.err) {
|
|
9744
9766
|
throw new Error(`Raw transaction ${signature} failed (${JSON.stringify(status)})`);
|