@solana/web3.js 1.41.10 → 1.42.0
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
|
@@ -5535,7 +5535,7 @@ class Connection {
|
|
|
5535
5535
|
this._disableBlockhashCaching = false;
|
|
5536
5536
|
this._pollingBlockhash = false;
|
|
5537
5537
|
this._blockhashInfo = {
|
|
5538
|
-
|
|
5538
|
+
latestBlockhash: null,
|
|
5539
5539
|
lastFetch: 0,
|
|
5540
5540
|
transactionSignatures: [],
|
|
5541
5541
|
simulatedSignatures: []
|
|
@@ -6498,7 +6498,7 @@ class Connection {
|
|
|
6498
6498
|
}
|
|
6499
6499
|
/**
|
|
6500
6500
|
* Fetch the latest blockhash from the cluster
|
|
6501
|
-
* @return {Promise<
|
|
6501
|
+
* @return {Promise<BlockhashWithExpiryBlockHeight>}
|
|
6502
6502
|
*/
|
|
6503
6503
|
|
|
6504
6504
|
|
|
@@ -6512,7 +6512,7 @@ class Connection {
|
|
|
6512
6512
|
}
|
|
6513
6513
|
/**
|
|
6514
6514
|
* Fetch the latest blockhash from the cluster
|
|
6515
|
-
* @return {Promise<
|
|
6515
|
+
* @return {Promise<BlockhashWithExpiryBlockHeight>}
|
|
6516
6516
|
*/
|
|
6517
6517
|
|
|
6518
6518
|
|
|
@@ -7095,7 +7095,7 @@ class Connection {
|
|
|
7095
7095
|
*/
|
|
7096
7096
|
|
|
7097
7097
|
|
|
7098
|
-
async
|
|
7098
|
+
async _blockhashWithExpiryBlockHeight(disableCache) {
|
|
7099
7099
|
if (!disableCache) {
|
|
7100
7100
|
// Wait for polling to finish
|
|
7101
7101
|
while (this._pollingBlockhash) {
|
|
@@ -7106,8 +7106,8 @@ class Connection {
|
|
|
7106
7106
|
|
|
7107
7107
|
const expired = timeSinceFetch >= BLOCKHASH_CACHE_TIMEOUT_MS;
|
|
7108
7108
|
|
|
7109
|
-
if (this._blockhashInfo.
|
|
7110
|
-
return this._blockhashInfo.
|
|
7109
|
+
if (this._blockhashInfo.latestBlockhash !== null && !expired) {
|
|
7110
|
+
return this._blockhashInfo.latestBlockhash;
|
|
7111
7111
|
}
|
|
7112
7112
|
}
|
|
7113
7113
|
|
|
@@ -7123,20 +7123,20 @@ class Connection {
|
|
|
7123
7123
|
|
|
7124
7124
|
try {
|
|
7125
7125
|
const startTime = Date.now();
|
|
7126
|
+
const cachedLatestBlockhash = this._blockhashInfo.latestBlockhash;
|
|
7127
|
+
const cachedBlockhash = cachedLatestBlockhash ? cachedLatestBlockhash.blockhash : null;
|
|
7126
7128
|
|
|
7127
7129
|
for (let i = 0; i < 50; i++) {
|
|
7128
|
-
const
|
|
7129
|
-
blockhash
|
|
7130
|
-
} = await this.getRecentBlockhash('finalized');
|
|
7130
|
+
const latestBlockhash = await this.getLatestBlockhash('finalized');
|
|
7131
7131
|
|
|
7132
|
-
if (
|
|
7132
|
+
if (cachedBlockhash !== latestBlockhash.blockhash) {
|
|
7133
7133
|
this._blockhashInfo = {
|
|
7134
|
-
|
|
7134
|
+
latestBlockhash,
|
|
7135
7135
|
lastFetch: Date.now(),
|
|
7136
7136
|
transactionSignatures: [],
|
|
7137
7137
|
simulatedSignatures: []
|
|
7138
7138
|
};
|
|
7139
|
-
return
|
|
7139
|
+
return latestBlockhash;
|
|
7140
7140
|
} // Sleep for approximately half a slot
|
|
7141
7141
|
|
|
7142
7142
|
|
|
@@ -7158,13 +7158,11 @@ class Connection {
|
|
|
7158
7158
|
|
|
7159
7159
|
if (transactionOrMessage instanceof Transaction) {
|
|
7160
7160
|
let originalTx = transactionOrMessage;
|
|
7161
|
-
transaction = new Transaction(
|
|
7162
|
-
|
|
7163
|
-
nonceInfo: originalTx.nonceInfo,
|
|
7164
|
-
feePayer: originalTx.feePayer,
|
|
7165
|
-
signatures: [...originalTx.signatures]
|
|
7166
|
-
});
|
|
7161
|
+
transaction = new Transaction();
|
|
7162
|
+
transaction.feePayer = originalTx.feePayer;
|
|
7167
7163
|
transaction.instructions = transactionOrMessage.instructions;
|
|
7164
|
+
transaction.nonceInfo = originalTx.nonceInfo;
|
|
7165
|
+
transaction.signatures = originalTx.signatures;
|
|
7168
7166
|
} else {
|
|
7169
7167
|
transaction = Transaction.populate(transactionOrMessage); // HACK: this function relies on mutating the populated transaction
|
|
7170
7168
|
|
|
@@ -7177,7 +7175,9 @@ class Connection {
|
|
|
7177
7175
|
let disableCache = this._disableBlockhashCaching;
|
|
7178
7176
|
|
|
7179
7177
|
for (;;) {
|
|
7180
|
-
|
|
7178
|
+
const latestBlockhash = await this._blockhashWithExpiryBlockHeight(disableCache);
|
|
7179
|
+
transaction.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight;
|
|
7180
|
+
transaction.recentBlockhash = latestBlockhash.blockhash;
|
|
7181
7181
|
if (!signers) break;
|
|
7182
7182
|
transaction.sign(...signers);
|
|
7183
7183
|
|
|
@@ -7261,7 +7261,9 @@ class Connection {
|
|
|
7261
7261
|
let disableCache = this._disableBlockhashCaching;
|
|
7262
7262
|
|
|
7263
7263
|
for (;;) {
|
|
7264
|
-
|
|
7264
|
+
const latestBlockhash = await this._blockhashWithExpiryBlockHeight(disableCache);
|
|
7265
|
+
transaction.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight;
|
|
7266
|
+
transaction.recentBlockhash = latestBlockhash.blockhash;
|
|
7265
7267
|
transaction.sign(...signers);
|
|
7266
7268
|
|
|
7267
7269
|
if (!transaction.signature) {
|
|
@@ -9702,16 +9704,36 @@ VoteProgram.space = 3731;
|
|
|
9702
9704
|
*
|
|
9703
9705
|
* @param {Connection} connection
|
|
9704
9706
|
* @param {Buffer} rawTransaction
|
|
9707
|
+
* @param {BlockheightBasedTransactionConfimationStrategy} confirmationStrategy
|
|
9705
9708
|
* @param {ConfirmOptions} [options]
|
|
9706
9709
|
* @returns {Promise<TransactionSignature>}
|
|
9707
9710
|
*/
|
|
9708
|
-
|
|
9711
|
+
|
|
9712
|
+
/**
|
|
9713
|
+
* @deprecated Calling `sendAndConfirmRawTransaction()` without a `confirmationStrategy`
|
|
9714
|
+
* is no longer supported and will be removed in a future version.
|
|
9715
|
+
*/
|
|
9716
|
+
// eslint-disable-next-line no-redeclare
|
|
9717
|
+
// eslint-disable-next-line no-redeclare
|
|
9718
|
+
async function sendAndConfirmRawTransaction(connection, rawTransaction, confirmationStrategyOrConfirmOptions, maybeConfirmOptions) {
|
|
9719
|
+
let confirmationStrategy;
|
|
9720
|
+
let options;
|
|
9721
|
+
|
|
9722
|
+
if (confirmationStrategyOrConfirmOptions && Object.prototype.hasOwnProperty.call(confirmationStrategyOrConfirmOptions, 'lastValidBlockHeight')) {
|
|
9723
|
+
confirmationStrategy = confirmationStrategyOrConfirmOptions;
|
|
9724
|
+
options = maybeConfirmOptions;
|
|
9725
|
+
} else {
|
|
9726
|
+
options = confirmationStrategyOrConfirmOptions;
|
|
9727
|
+
}
|
|
9728
|
+
|
|
9709
9729
|
const sendOptions = options && {
|
|
9710
9730
|
skipPreflight: options.skipPreflight,
|
|
9711
9731
|
preflightCommitment: options.preflightCommitment || options.commitment
|
|
9712
9732
|
};
|
|
9713
9733
|
const signature = await connection.sendRawTransaction(rawTransaction, sendOptions);
|
|
9714
|
-
const
|
|
9734
|
+
const commitment = options && options.commitment;
|
|
9735
|
+
const confirmationPromise = confirmationStrategy ? connection.confirmTransaction(confirmationStrategy, commitment) : connection.confirmTransaction(signature, commitment);
|
|
9736
|
+
const status = (await confirmationPromise).value;
|
|
9715
9737
|
|
|
9716
9738
|
if (status.err) {
|
|
9717
9739
|
throw new Error(`Raw transaction ${signature} failed (${JSON.stringify(status)})`);
|