@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.iife.js
CHANGED
|
@@ -25973,7 +25973,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
25973
25973
|
this._disableBlockhashCaching = false;
|
|
25974
25974
|
this._pollingBlockhash = false;
|
|
25975
25975
|
this._blockhashInfo = {
|
|
25976
|
-
|
|
25976
|
+
latestBlockhash: null,
|
|
25977
25977
|
lastFetch: 0,
|
|
25978
25978
|
transactionSignatures: [],
|
|
25979
25979
|
simulatedSignatures: []
|
|
@@ -26936,7 +26936,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
26936
26936
|
}
|
|
26937
26937
|
/**
|
|
26938
26938
|
* Fetch the latest blockhash from the cluster
|
|
26939
|
-
* @return {Promise<
|
|
26939
|
+
* @return {Promise<BlockhashWithExpiryBlockHeight>}
|
|
26940
26940
|
*/
|
|
26941
26941
|
|
|
26942
26942
|
|
|
@@ -26950,7 +26950,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
26950
26950
|
}
|
|
26951
26951
|
/**
|
|
26952
26952
|
* Fetch the latest blockhash from the cluster
|
|
26953
|
-
* @return {Promise<
|
|
26953
|
+
* @return {Promise<BlockhashWithExpiryBlockHeight>}
|
|
26954
26954
|
*/
|
|
26955
26955
|
|
|
26956
26956
|
|
|
@@ -27533,7 +27533,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
27533
27533
|
*/
|
|
27534
27534
|
|
|
27535
27535
|
|
|
27536
|
-
async
|
|
27536
|
+
async _blockhashWithExpiryBlockHeight(disableCache) {
|
|
27537
27537
|
if (!disableCache) {
|
|
27538
27538
|
// Wait for polling to finish
|
|
27539
27539
|
while (this._pollingBlockhash) {
|
|
@@ -27544,8 +27544,8 @@ var solanaWeb3 = (function (exports) {
|
|
|
27544
27544
|
|
|
27545
27545
|
const expired = timeSinceFetch >= BLOCKHASH_CACHE_TIMEOUT_MS;
|
|
27546
27546
|
|
|
27547
|
-
if (this._blockhashInfo.
|
|
27548
|
-
return this._blockhashInfo.
|
|
27547
|
+
if (this._blockhashInfo.latestBlockhash !== null && !expired) {
|
|
27548
|
+
return this._blockhashInfo.latestBlockhash;
|
|
27549
27549
|
}
|
|
27550
27550
|
}
|
|
27551
27551
|
|
|
@@ -27561,20 +27561,20 @@ var solanaWeb3 = (function (exports) {
|
|
|
27561
27561
|
|
|
27562
27562
|
try {
|
|
27563
27563
|
const startTime = Date.now();
|
|
27564
|
+
const cachedLatestBlockhash = this._blockhashInfo.latestBlockhash;
|
|
27565
|
+
const cachedBlockhash = cachedLatestBlockhash ? cachedLatestBlockhash.blockhash : null;
|
|
27564
27566
|
|
|
27565
27567
|
for (let i = 0; i < 50; i++) {
|
|
27566
|
-
const
|
|
27567
|
-
blockhash
|
|
27568
|
-
} = await this.getRecentBlockhash('finalized');
|
|
27568
|
+
const latestBlockhash = await this.getLatestBlockhash('finalized');
|
|
27569
27569
|
|
|
27570
|
-
if (
|
|
27570
|
+
if (cachedBlockhash !== latestBlockhash.blockhash) {
|
|
27571
27571
|
this._blockhashInfo = {
|
|
27572
|
-
|
|
27572
|
+
latestBlockhash,
|
|
27573
27573
|
lastFetch: Date.now(),
|
|
27574
27574
|
transactionSignatures: [],
|
|
27575
27575
|
simulatedSignatures: []
|
|
27576
27576
|
};
|
|
27577
|
-
return
|
|
27577
|
+
return latestBlockhash;
|
|
27578
27578
|
} // Sleep for approximately half a slot
|
|
27579
27579
|
|
|
27580
27580
|
|
|
@@ -27596,13 +27596,11 @@ var solanaWeb3 = (function (exports) {
|
|
|
27596
27596
|
|
|
27597
27597
|
if (transactionOrMessage instanceof Transaction) {
|
|
27598
27598
|
let originalTx = transactionOrMessage;
|
|
27599
|
-
transaction = new Transaction(
|
|
27600
|
-
|
|
27601
|
-
nonceInfo: originalTx.nonceInfo,
|
|
27602
|
-
feePayer: originalTx.feePayer,
|
|
27603
|
-
signatures: [...originalTx.signatures]
|
|
27604
|
-
});
|
|
27599
|
+
transaction = new Transaction();
|
|
27600
|
+
transaction.feePayer = originalTx.feePayer;
|
|
27605
27601
|
transaction.instructions = transactionOrMessage.instructions;
|
|
27602
|
+
transaction.nonceInfo = originalTx.nonceInfo;
|
|
27603
|
+
transaction.signatures = originalTx.signatures;
|
|
27606
27604
|
} else {
|
|
27607
27605
|
transaction = Transaction.populate(transactionOrMessage); // HACK: this function relies on mutating the populated transaction
|
|
27608
27606
|
|
|
@@ -27615,7 +27613,9 @@ var solanaWeb3 = (function (exports) {
|
|
|
27615
27613
|
let disableCache = this._disableBlockhashCaching;
|
|
27616
27614
|
|
|
27617
27615
|
for (;;) {
|
|
27618
|
-
|
|
27616
|
+
const latestBlockhash = await this._blockhashWithExpiryBlockHeight(disableCache);
|
|
27617
|
+
transaction.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight;
|
|
27618
|
+
transaction.recentBlockhash = latestBlockhash.blockhash;
|
|
27619
27619
|
if (!signers) break;
|
|
27620
27620
|
transaction.sign(...signers);
|
|
27621
27621
|
|
|
@@ -27699,7 +27699,9 @@ var solanaWeb3 = (function (exports) {
|
|
|
27699
27699
|
let disableCache = this._disableBlockhashCaching;
|
|
27700
27700
|
|
|
27701
27701
|
for (;;) {
|
|
27702
|
-
|
|
27702
|
+
const latestBlockhash = await this._blockhashWithExpiryBlockHeight(disableCache);
|
|
27703
|
+
transaction.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight;
|
|
27704
|
+
transaction.recentBlockhash = latestBlockhash.blockhash;
|
|
27703
27705
|
transaction.sign(...signers);
|
|
27704
27706
|
|
|
27705
27707
|
if (!transaction.signature) {
|
|
@@ -30140,16 +30142,36 @@ var solanaWeb3 = (function (exports) {
|
|
|
30140
30142
|
*
|
|
30141
30143
|
* @param {Connection} connection
|
|
30142
30144
|
* @param {Buffer} rawTransaction
|
|
30145
|
+
* @param {BlockheightBasedTransactionConfimationStrategy} confirmationStrategy
|
|
30143
30146
|
* @param {ConfirmOptions} [options]
|
|
30144
30147
|
* @returns {Promise<TransactionSignature>}
|
|
30145
30148
|
*/
|
|
30146
|
-
|
|
30149
|
+
|
|
30150
|
+
/**
|
|
30151
|
+
* @deprecated Calling `sendAndConfirmRawTransaction()` without a `confirmationStrategy`
|
|
30152
|
+
* is no longer supported and will be removed in a future version.
|
|
30153
|
+
*/
|
|
30154
|
+
// eslint-disable-next-line no-redeclare
|
|
30155
|
+
// eslint-disable-next-line no-redeclare
|
|
30156
|
+
async function sendAndConfirmRawTransaction(connection, rawTransaction, confirmationStrategyOrConfirmOptions, maybeConfirmOptions) {
|
|
30157
|
+
let confirmationStrategy;
|
|
30158
|
+
let options;
|
|
30159
|
+
|
|
30160
|
+
if (confirmationStrategyOrConfirmOptions && Object.prototype.hasOwnProperty.call(confirmationStrategyOrConfirmOptions, 'lastValidBlockHeight')) {
|
|
30161
|
+
confirmationStrategy = confirmationStrategyOrConfirmOptions;
|
|
30162
|
+
options = maybeConfirmOptions;
|
|
30163
|
+
} else {
|
|
30164
|
+
options = confirmationStrategyOrConfirmOptions;
|
|
30165
|
+
}
|
|
30166
|
+
|
|
30147
30167
|
const sendOptions = options && {
|
|
30148
30168
|
skipPreflight: options.skipPreflight,
|
|
30149
30169
|
preflightCommitment: options.preflightCommitment || options.commitment
|
|
30150
30170
|
};
|
|
30151
30171
|
const signature = await connection.sendRawTransaction(rawTransaction, sendOptions);
|
|
30152
|
-
const
|
|
30172
|
+
const commitment = options && options.commitment;
|
|
30173
|
+
const confirmationPromise = confirmationStrategy ? connection.confirmTransaction(confirmationStrategy, commitment) : connection.confirmTransaction(signature, commitment);
|
|
30174
|
+
const status = (await confirmationPromise).value;
|
|
30153
30175
|
|
|
30154
30176
|
if (status.err) {
|
|
30155
30177
|
throw new Error(`Raw transaction ${signature} failed (${JSON.stringify(status)})`);
|