@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.browser.cjs.js
CHANGED
|
@@ -6029,7 +6029,7 @@ class Connection {
|
|
|
6029
6029
|
this._disableBlockhashCaching = false;
|
|
6030
6030
|
this._pollingBlockhash = false;
|
|
6031
6031
|
this._blockhashInfo = {
|
|
6032
|
-
|
|
6032
|
+
latestBlockhash: null,
|
|
6033
6033
|
lastFetch: 0,
|
|
6034
6034
|
transactionSignatures: [],
|
|
6035
6035
|
simulatedSignatures: []
|
|
@@ -6992,7 +6992,7 @@ class Connection {
|
|
|
6992
6992
|
}
|
|
6993
6993
|
/**
|
|
6994
6994
|
* Fetch the latest blockhash from the cluster
|
|
6995
|
-
* @return {Promise<
|
|
6995
|
+
* @return {Promise<BlockhashWithExpiryBlockHeight>}
|
|
6996
6996
|
*/
|
|
6997
6997
|
|
|
6998
6998
|
|
|
@@ -7006,7 +7006,7 @@ class Connection {
|
|
|
7006
7006
|
}
|
|
7007
7007
|
/**
|
|
7008
7008
|
* Fetch the latest blockhash from the cluster
|
|
7009
|
-
* @return {Promise<
|
|
7009
|
+
* @return {Promise<BlockhashWithExpiryBlockHeight>}
|
|
7010
7010
|
*/
|
|
7011
7011
|
|
|
7012
7012
|
|
|
@@ -7589,7 +7589,7 @@ class Connection {
|
|
|
7589
7589
|
*/
|
|
7590
7590
|
|
|
7591
7591
|
|
|
7592
|
-
async
|
|
7592
|
+
async _blockhashWithExpiryBlockHeight(disableCache) {
|
|
7593
7593
|
if (!disableCache) {
|
|
7594
7594
|
// Wait for polling to finish
|
|
7595
7595
|
while (this._pollingBlockhash) {
|
|
@@ -7600,8 +7600,8 @@ class Connection {
|
|
|
7600
7600
|
|
|
7601
7601
|
const expired = timeSinceFetch >= BLOCKHASH_CACHE_TIMEOUT_MS;
|
|
7602
7602
|
|
|
7603
|
-
if (this._blockhashInfo.
|
|
7604
|
-
return this._blockhashInfo.
|
|
7603
|
+
if (this._blockhashInfo.latestBlockhash !== null && !expired) {
|
|
7604
|
+
return this._blockhashInfo.latestBlockhash;
|
|
7605
7605
|
}
|
|
7606
7606
|
}
|
|
7607
7607
|
|
|
@@ -7617,20 +7617,20 @@ class Connection {
|
|
|
7617
7617
|
|
|
7618
7618
|
try {
|
|
7619
7619
|
const startTime = Date.now();
|
|
7620
|
+
const cachedLatestBlockhash = this._blockhashInfo.latestBlockhash;
|
|
7621
|
+
const cachedBlockhash = cachedLatestBlockhash ? cachedLatestBlockhash.blockhash : null;
|
|
7620
7622
|
|
|
7621
7623
|
for (let i = 0; i < 50; i++) {
|
|
7622
|
-
const
|
|
7623
|
-
blockhash
|
|
7624
|
-
} = await this.getRecentBlockhash('finalized');
|
|
7624
|
+
const latestBlockhash = await this.getLatestBlockhash('finalized');
|
|
7625
7625
|
|
|
7626
|
-
if (
|
|
7626
|
+
if (cachedBlockhash !== latestBlockhash.blockhash) {
|
|
7627
7627
|
this._blockhashInfo = {
|
|
7628
|
-
|
|
7628
|
+
latestBlockhash,
|
|
7629
7629
|
lastFetch: Date.now(),
|
|
7630
7630
|
transactionSignatures: [],
|
|
7631
7631
|
simulatedSignatures: []
|
|
7632
7632
|
};
|
|
7633
|
-
return
|
|
7633
|
+
return latestBlockhash;
|
|
7634
7634
|
} // Sleep for approximately half a slot
|
|
7635
7635
|
|
|
7636
7636
|
|
|
@@ -7652,13 +7652,11 @@ class Connection {
|
|
|
7652
7652
|
|
|
7653
7653
|
if (transactionOrMessage instanceof Transaction) {
|
|
7654
7654
|
let originalTx = transactionOrMessage;
|
|
7655
|
-
transaction = new Transaction(
|
|
7656
|
-
|
|
7657
|
-
nonceInfo: originalTx.nonceInfo,
|
|
7658
|
-
feePayer: originalTx.feePayer,
|
|
7659
|
-
signatures: [...originalTx.signatures]
|
|
7660
|
-
});
|
|
7655
|
+
transaction = new Transaction();
|
|
7656
|
+
transaction.feePayer = originalTx.feePayer;
|
|
7661
7657
|
transaction.instructions = transactionOrMessage.instructions;
|
|
7658
|
+
transaction.nonceInfo = originalTx.nonceInfo;
|
|
7659
|
+
transaction.signatures = originalTx.signatures;
|
|
7662
7660
|
} else {
|
|
7663
7661
|
transaction = Transaction.populate(transactionOrMessage); // HACK: this function relies on mutating the populated transaction
|
|
7664
7662
|
|
|
@@ -7671,7 +7669,9 @@ class Connection {
|
|
|
7671
7669
|
let disableCache = this._disableBlockhashCaching;
|
|
7672
7670
|
|
|
7673
7671
|
for (;;) {
|
|
7674
|
-
|
|
7672
|
+
const latestBlockhash = await this._blockhashWithExpiryBlockHeight(disableCache);
|
|
7673
|
+
transaction.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight;
|
|
7674
|
+
transaction.recentBlockhash = latestBlockhash.blockhash;
|
|
7675
7675
|
if (!signers) break;
|
|
7676
7676
|
transaction.sign(...signers);
|
|
7677
7677
|
|
|
@@ -7755,7 +7755,9 @@ class Connection {
|
|
|
7755
7755
|
let disableCache = this._disableBlockhashCaching;
|
|
7756
7756
|
|
|
7757
7757
|
for (;;) {
|
|
7758
|
-
|
|
7758
|
+
const latestBlockhash = await this._blockhashWithExpiryBlockHeight(disableCache);
|
|
7759
|
+
transaction.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight;
|
|
7760
|
+
transaction.recentBlockhash = latestBlockhash.blockhash;
|
|
7759
7761
|
transaction.sign(...signers);
|
|
7760
7762
|
|
|
7761
7763
|
if (!transaction.signature) {
|
|
@@ -10196,16 +10198,36 @@ VoteProgram.space = 3731;
|
|
|
10196
10198
|
*
|
|
10197
10199
|
* @param {Connection} connection
|
|
10198
10200
|
* @param {Buffer} rawTransaction
|
|
10201
|
+
* @param {BlockheightBasedTransactionConfimationStrategy} confirmationStrategy
|
|
10199
10202
|
* @param {ConfirmOptions} [options]
|
|
10200
10203
|
* @returns {Promise<TransactionSignature>}
|
|
10201
10204
|
*/
|
|
10202
|
-
|
|
10205
|
+
|
|
10206
|
+
/**
|
|
10207
|
+
* @deprecated Calling `sendAndConfirmRawTransaction()` without a `confirmationStrategy`
|
|
10208
|
+
* is no longer supported and will be removed in a future version.
|
|
10209
|
+
*/
|
|
10210
|
+
// eslint-disable-next-line no-redeclare
|
|
10211
|
+
// eslint-disable-next-line no-redeclare
|
|
10212
|
+
async function sendAndConfirmRawTransaction(connection, rawTransaction, confirmationStrategyOrConfirmOptions, maybeConfirmOptions) {
|
|
10213
|
+
let confirmationStrategy;
|
|
10214
|
+
let options;
|
|
10215
|
+
|
|
10216
|
+
if (confirmationStrategyOrConfirmOptions && Object.prototype.hasOwnProperty.call(confirmationStrategyOrConfirmOptions, 'lastValidBlockHeight')) {
|
|
10217
|
+
confirmationStrategy = confirmationStrategyOrConfirmOptions;
|
|
10218
|
+
options = maybeConfirmOptions;
|
|
10219
|
+
} else {
|
|
10220
|
+
options = confirmationStrategyOrConfirmOptions;
|
|
10221
|
+
}
|
|
10222
|
+
|
|
10203
10223
|
const sendOptions = options && {
|
|
10204
10224
|
skipPreflight: options.skipPreflight,
|
|
10205
10225
|
preflightCommitment: options.preflightCommitment || options.commitment
|
|
10206
10226
|
};
|
|
10207
10227
|
const signature = await connection.sendRawTransaction(rawTransaction, sendOptions);
|
|
10208
|
-
const
|
|
10228
|
+
const commitment = options && options.commitment;
|
|
10229
|
+
const confirmationPromise = confirmationStrategy ? connection.confirmTransaction(confirmationStrategy, commitment) : connection.confirmTransaction(signature, commitment);
|
|
10230
|
+
const status = (await confirmationPromise).value;
|
|
10209
10231
|
|
|
10210
10232
|
if (status.err) {
|
|
10211
10233
|
throw new Error(`Raw transaction ${signature} failed (${JSON.stringify(status)})`);
|