@solana/web3.js 1.68.1 → 1.69.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 +37 -7
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +37 -7
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +37 -7
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +239 -234
- package/lib/index.esm.js +37 -7
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +37 -7
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +2 -2
- package/lib/index.iife.min.js.map +1 -1
- package/lib/index.native.js +37 -7
- package/lib/index.native.js.map +1 -1
- package/package.json +5 -4
- package/src/connection.ts +70 -28
- package/src/epoch-schedule.ts +1 -1
- package/src/utils/send-and-confirm-transaction.ts +14 -1
package/lib/index.esm.js
CHANGED
|
@@ -2212,6 +2212,7 @@ async function sendAndConfirmTransaction(connection, transaction, signers, optio
|
|
|
2212
2212
|
|
|
2213
2213
|
if (transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null) {
|
|
2214
2214
|
status = (await connection.confirmTransaction({
|
|
2215
|
+
abortSignal: options === null || options === void 0 ? void 0 : options.abortSignal,
|
|
2215
2216
|
signature: signature,
|
|
2216
2217
|
blockhash: transaction.recentBlockhash,
|
|
2217
2218
|
lastValidBlockHeight: transaction.lastValidBlockHeight
|
|
@@ -2222,12 +2223,17 @@ async function sendAndConfirmTransaction(connection, transaction, signers, optio
|
|
|
2222
2223
|
} = transaction.nonceInfo;
|
|
2223
2224
|
const nonceAccountPubkey = nonceInstruction.keys[0].pubkey;
|
|
2224
2225
|
status = (await connection.confirmTransaction({
|
|
2226
|
+
abortSignal: options === null || options === void 0 ? void 0 : options.abortSignal,
|
|
2225
2227
|
minContextSlot: transaction.minNonceContextSlot,
|
|
2226
2228
|
nonceAccountPubkey,
|
|
2227
2229
|
nonceValue: transaction.nonceInfo.nonce,
|
|
2228
2230
|
signature
|
|
2229
2231
|
}, options && options.commitment)).value;
|
|
2230
2232
|
} else {
|
|
2233
|
+
if ((options === null || options === void 0 ? void 0 : options.abortSignal) != null) {
|
|
2234
|
+
console.warn('sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was ' + 'supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` ' + 'or a combination of `nonceInfo` and `minNonceContextSlot` are abortable.');
|
|
2235
|
+
}
|
|
2236
|
+
|
|
2231
2237
|
status = (await connection.confirmTransaction(signature, options && options.commitment)).value;
|
|
2232
2238
|
}
|
|
2233
2239
|
|
|
@@ -3440,7 +3446,7 @@ function nextPowerOfTwo(n) {
|
|
|
3440
3446
|
/**
|
|
3441
3447
|
* Epoch schedule
|
|
3442
3448
|
* (see https://docs.solana.com/terminology#epoch)
|
|
3443
|
-
* Can be retrieved with the {@link
|
|
3449
|
+
* Can be retrieved with the {@link Connection.getEpochSchedule} method
|
|
3444
3450
|
*/
|
|
3445
3451
|
|
|
3446
3452
|
|
|
@@ -3715,13 +3721,10 @@ function extractCommitmentFromConfig(commitmentOrConfig) {
|
|
|
3715
3721
|
};
|
|
3716
3722
|
}
|
|
3717
3723
|
/**
|
|
3718
|
-
*
|
|
3724
|
+
* @internal
|
|
3719
3725
|
*/
|
|
3720
3726
|
|
|
3721
3727
|
|
|
3722
|
-
/**
|
|
3723
|
-
* @internal
|
|
3724
|
-
*/
|
|
3725
3728
|
function createRpcResult(result) {
|
|
3726
3729
|
return union([type({
|
|
3727
3730
|
jsonrpc: literal('2.0'),
|
|
@@ -5336,7 +5339,14 @@ class Connection {
|
|
|
5336
5339
|
if (typeof strategy == 'string') {
|
|
5337
5340
|
rawSignature = strategy;
|
|
5338
5341
|
} else {
|
|
5342
|
+
var _config$abortSignal;
|
|
5343
|
+
|
|
5339
5344
|
const config = strategy;
|
|
5345
|
+
|
|
5346
|
+
if ((_config$abortSignal = config.abortSignal) !== null && _config$abortSignal !== void 0 && _config$abortSignal.aborted) {
|
|
5347
|
+
return Promise.reject(config.abortSignal.reason);
|
|
5348
|
+
}
|
|
5349
|
+
|
|
5340
5350
|
rawSignature = config.signature;
|
|
5341
5351
|
}
|
|
5342
5352
|
|
|
@@ -5368,6 +5378,22 @@ class Connection {
|
|
|
5368
5378
|
}
|
|
5369
5379
|
}
|
|
5370
5380
|
|
|
5381
|
+
getCancellationPromise(signal) {
|
|
5382
|
+
return new Promise((_, reject) => {
|
|
5383
|
+
if (signal == null) {
|
|
5384
|
+
return;
|
|
5385
|
+
}
|
|
5386
|
+
|
|
5387
|
+
if (signal.aborted) {
|
|
5388
|
+
reject(signal.reason);
|
|
5389
|
+
} else {
|
|
5390
|
+
signal.addEventListener('abort', () => {
|
|
5391
|
+
reject(signal.reason);
|
|
5392
|
+
});
|
|
5393
|
+
}
|
|
5394
|
+
});
|
|
5395
|
+
}
|
|
5396
|
+
|
|
5371
5397
|
getTransactionConfirmationPromise({
|
|
5372
5398
|
commitment,
|
|
5373
5399
|
signature
|
|
@@ -5486,6 +5512,7 @@ class Connection {
|
|
|
5486
5512
|
async confirmTransactionUsingBlockHeightExceedanceStrategy({
|
|
5487
5513
|
commitment,
|
|
5488
5514
|
strategy: {
|
|
5515
|
+
abortSignal,
|
|
5489
5516
|
lastValidBlockHeight,
|
|
5490
5517
|
signature
|
|
5491
5518
|
}
|
|
@@ -5524,10 +5551,11 @@ class Connection {
|
|
|
5524
5551
|
commitment,
|
|
5525
5552
|
signature
|
|
5526
5553
|
});
|
|
5554
|
+
const cancellationPromise = this.getCancellationPromise(abortSignal);
|
|
5527
5555
|
let result;
|
|
5528
5556
|
|
|
5529
5557
|
try {
|
|
5530
|
-
const outcome = await Promise.race([confirmationPromise, expiryPromise]);
|
|
5558
|
+
const outcome = await Promise.race([cancellationPromise, confirmationPromise, expiryPromise]);
|
|
5531
5559
|
|
|
5532
5560
|
if (outcome.__type === TransactionStatus.PROCESSED) {
|
|
5533
5561
|
result = outcome.response;
|
|
@@ -5545,6 +5573,7 @@ class Connection {
|
|
|
5545
5573
|
async confirmTransactionUsingDurableNonceStrategy({
|
|
5546
5574
|
commitment,
|
|
5547
5575
|
strategy: {
|
|
5576
|
+
abortSignal,
|
|
5548
5577
|
minContextSlot,
|
|
5549
5578
|
nonceAccountPubkey,
|
|
5550
5579
|
nonceValue,
|
|
@@ -5602,10 +5631,11 @@ class Connection {
|
|
|
5602
5631
|
commitment,
|
|
5603
5632
|
signature
|
|
5604
5633
|
});
|
|
5634
|
+
const cancellationPromise = this.getCancellationPromise(abortSignal);
|
|
5605
5635
|
let result;
|
|
5606
5636
|
|
|
5607
5637
|
try {
|
|
5608
|
-
const outcome = await Promise.race([confirmationPromise, expiryPromise]);
|
|
5638
|
+
const outcome = await Promise.race([cancellationPromise, confirmationPromise, expiryPromise]);
|
|
5609
5639
|
|
|
5610
5640
|
if (outcome.__type === TransactionStatus.PROCESSED) {
|
|
5611
5641
|
result = outcome.response;
|