@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.iife.js
CHANGED
|
@@ -26002,7 +26002,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
26002
26002
|
this._disableBlockhashCaching = false;
|
|
26003
26003
|
this._pollingBlockhash = false;
|
|
26004
26004
|
this._blockhashInfo = {
|
|
26005
|
-
|
|
26005
|
+
latestBlockhash: null,
|
|
26006
26006
|
lastFetch: 0,
|
|
26007
26007
|
transactionSignatures: [],
|
|
26008
26008
|
simulatedSignatures: []
|
|
@@ -26965,7 +26965,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
26965
26965
|
}
|
|
26966
26966
|
/**
|
|
26967
26967
|
* Fetch the latest blockhash from the cluster
|
|
26968
|
-
* @return {Promise<
|
|
26968
|
+
* @return {Promise<BlockhashWithExpiryBlockHeight>}
|
|
26969
26969
|
*/
|
|
26970
26970
|
|
|
26971
26971
|
|
|
@@ -26979,7 +26979,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
26979
26979
|
}
|
|
26980
26980
|
/**
|
|
26981
26981
|
* Fetch the latest blockhash from the cluster
|
|
26982
|
-
* @return {Promise<
|
|
26982
|
+
* @return {Promise<BlockhashWithExpiryBlockHeight>}
|
|
26983
26983
|
*/
|
|
26984
26984
|
|
|
26985
26985
|
|
|
@@ -27562,7 +27562,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
27562
27562
|
*/
|
|
27563
27563
|
|
|
27564
27564
|
|
|
27565
|
-
async
|
|
27565
|
+
async _blockhashWithExpiryBlockHeight(disableCache) {
|
|
27566
27566
|
if (!disableCache) {
|
|
27567
27567
|
// Wait for polling to finish
|
|
27568
27568
|
while (this._pollingBlockhash) {
|
|
@@ -27573,8 +27573,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
27573
27573
|
|
|
27574
27574
|
const expired = timeSinceFetch >= BLOCKHASH_CACHE_TIMEOUT_MS;
|
|
27575
27575
|
|
|
27576
|
-
if (this._blockhashInfo.
|
|
27577
|
-
return this._blockhashInfo.
|
|
27576
|
+
if (this._blockhashInfo.latestBlockhash !== null && !expired) {
|
|
27577
|
+
return this._blockhashInfo.latestBlockhash;
|
|
27578
27578
|
}
|
|
27579
27579
|
}
|
|
27580
27580
|
|
|
@@ -27590,20 +27590,20 @@ var solanaWeb3 = (function (exports) {
|
|
|
27590
27590
|
|
|
27591
27591
|
try {
|
|
27592
27592
|
const startTime = Date.now();
|
|
27593
|
+
const cachedLatestBlockhash = this._blockhashInfo.latestBlockhash;
|
|
27594
|
+
const cachedBlockhash = cachedLatestBlockhash ? cachedLatestBlockhash.blockhash : null;
|
|
27593
27595
|
|
|
27594
27596
|
for (let i = 0; i < 50; i++) {
|
|
27595
|
-
const
|
|
27596
|
-
blockhash
|
|
27597
|
-
} = await this.getRecentBlockhash('finalized');
|
|
27597
|
+
const latestBlockhash = await this.getLatestBlockhash('finalized');
|
|
27598
27598
|
|
|
27599
|
-
if (
|
|
27599
|
+
if (cachedBlockhash !== latestBlockhash.blockhash) {
|
|
27600
27600
|
this._blockhashInfo = {
|
|
27601
|
-
|
|
27601
|
+
latestBlockhash,
|
|
27602
27602
|
lastFetch: Date.now(),
|
|
27603
27603
|
transactionSignatures: [],
|
|
27604
27604
|
simulatedSignatures: []
|
|
27605
27605
|
};
|
|
27606
|
-
return
|
|
27606
|
+
return latestBlockhash;
|
|
27607
27607
|
} // Sleep for approximately half a slot
|
|
27608
27608
|
|
|
27609
27609
|
|
|
@@ -27625,13 +27625,11 @@ var solanaWeb3 = (function (exports) {
|
|
|
27625
27625
|
|
|
27626
27626
|
if (transactionOrMessage instanceof Transaction) {
|
|
27627
27627
|
let originalTx = transactionOrMessage;
|
|
27628
|
-
transaction = new Transaction(
|
|
27629
|
-
|
|
27630
|
-
nonceInfo: originalTx.nonceInfo,
|
|
27631
|
-
feePayer: originalTx.feePayer,
|
|
27632
|
-
signatures: [...originalTx.signatures]
|
|
27633
|
-
});
|
|
27628
|
+
transaction = new Transaction();
|
|
27629
|
+
transaction.feePayer = originalTx.feePayer;
|
|
27634
27630
|
transaction.instructions = transactionOrMessage.instructions;
|
|
27631
|
+
transaction.nonceInfo = originalTx.nonceInfo;
|
|
27632
|
+
transaction.signatures = originalTx.signatures;
|
|
27635
27633
|
} else {
|
|
27636
27634
|
transaction = Transaction.populate(transactionOrMessage); // HACK: this function relies on mutating the populated transaction
|
|
27637
27635
|
|
|
@@ -27644,7 +27642,9 @@ var solanaWeb3 = (function (exports) {
|
|
|
27644
27642
|
let disableCache = this._disableBlockhashCaching;
|
|
27645
27643
|
|
|
27646
27644
|
for (;;) {
|
|
27647
|
-
|
|
27645
|
+
const latestBlockhash = await this._blockhashWithExpiryBlockHeight(disableCache);
|
|
27646
|
+
transaction.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight;
|
|
27647
|
+
transaction.recentBlockhash = latestBlockhash.blockhash;
|
|
27648
27648
|
if (!signers) break;
|
|
27649
27649
|
transaction.sign(...signers);
|
|
27650
27650
|
|
|
@@ -27728,7 +27728,9 @@ var solanaWeb3 = (function (exports) {
|
|
|
27728
27728
|
let disableCache = this._disableBlockhashCaching;
|
|
27729
27729
|
|
|
27730
27730
|
for (;;) {
|
|
27731
|
-
|
|
27731
|
+
const latestBlockhash = await this._blockhashWithExpiryBlockHeight(disableCache);
|
|
27732
|
+
transaction.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight;
|
|
27733
|
+
transaction.recentBlockhash = latestBlockhash.blockhash;
|
|
27732
27734
|
transaction.sign(...signers);
|
|
27733
27735
|
|
|
27734
27736
|
if (!transaction.signature) {
|
|
@@ -30167,16 +30169,36 @@ var solanaWeb3 = (function (exports) {
|
|
|
30167
30169
|
*
|
|
30168
30170
|
* @param {Connection} connection
|
|
30169
30171
|
* @param {Buffer} rawTransaction
|
|
30172
|
+
* @param {BlockheightBasedTransactionConfimationStrategy} confirmationStrategy
|
|
30170
30173
|
* @param {ConfirmOptions} [options]
|
|
30171
30174
|
* @returns {Promise<TransactionSignature>}
|
|
30172
30175
|
*/
|
|
30173
|
-
|
|
30176
|
+
|
|
30177
|
+
/**
|
|
30178
|
+
* @deprecated Calling `sendAndConfirmRawTransaction()` without a `confirmationStrategy`
|
|
30179
|
+
* is no longer supported and will be removed in a future version.
|
|
30180
|
+
*/
|
|
30181
|
+
// eslint-disable-next-line no-redeclare
|
|
30182
|
+
// eslint-disable-next-line no-redeclare
|
|
30183
|
+
async function sendAndConfirmRawTransaction(connection, rawTransaction, confirmationStrategyOrConfirmOptions, maybeConfirmOptions) {
|
|
30184
|
+
let confirmationStrategy;
|
|
30185
|
+
let options;
|
|
30186
|
+
|
|
30187
|
+
if (confirmationStrategyOrConfirmOptions && Object.prototype.hasOwnProperty.call(confirmationStrategyOrConfirmOptions, 'lastValidBlockHeight')) {
|
|
30188
|
+
confirmationStrategy = confirmationStrategyOrConfirmOptions;
|
|
30189
|
+
options = maybeConfirmOptions;
|
|
30190
|
+
} else {
|
|
30191
|
+
options = confirmationStrategyOrConfirmOptions;
|
|
30192
|
+
}
|
|
30193
|
+
|
|
30174
30194
|
const sendOptions = options && {
|
|
30175
30195
|
skipPreflight: options.skipPreflight,
|
|
30176
30196
|
preflightCommitment: options.preflightCommitment || options.commitment
|
|
30177
30197
|
};
|
|
30178
30198
|
const signature = await connection.sendRawTransaction(rawTransaction, sendOptions);
|
|
30179
|
-
const
|
|
30199
|
+
const commitment = options && options.commitment;
|
|
30200
|
+
const confirmationPromise = confirmationStrategy ? connection.confirmTransaction(confirmationStrategy, commitment) : connection.confirmTransaction(signature, commitment);
|
|
30201
|
+
const status = (await confirmationPromise).value;
|
|
30180
30202
|
|
|
30181
30203
|
if (status.err) {
|
|
30182
30204
|
throw new Error(`Raw transaction ${signature} failed (${JSON.stringify(status)})`);
|