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