@solana/web3.js 1.68.1 → 1.70.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/README.md +0 -13
- package/lib/index.browser.cjs.js +47 -9
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +47 -9
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +66 -14
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +247 -234
- package/lib/index.esm.js +65 -13
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +47 -9
- 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 +47 -9
- package/lib/index.native.js.map +1 -1
- package/package.json +6 -5
- package/src/connection.ts +120 -31
- package/src/epoch-schedule.ts +1 -1
- package/src/utils/send-and-confirm-transaction.ts +14 -1
package/lib/index.browser.esm.js
CHANGED
|
@@ -2209,6 +2209,7 @@ async function sendAndConfirmTransaction(connection, transaction, signers, optio
|
|
|
2209
2209
|
|
|
2210
2210
|
if (transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null) {
|
|
2211
2211
|
status = (await connection.confirmTransaction({
|
|
2212
|
+
abortSignal: options === null || options === void 0 ? void 0 : options.abortSignal,
|
|
2212
2213
|
signature: signature,
|
|
2213
2214
|
blockhash: transaction.recentBlockhash,
|
|
2214
2215
|
lastValidBlockHeight: transaction.lastValidBlockHeight
|
|
@@ -2219,12 +2220,17 @@ async function sendAndConfirmTransaction(connection, transaction, signers, optio
|
|
|
2219
2220
|
} = transaction.nonceInfo;
|
|
2220
2221
|
const nonceAccountPubkey = nonceInstruction.keys[0].pubkey;
|
|
2221
2222
|
status = (await connection.confirmTransaction({
|
|
2223
|
+
abortSignal: options === null || options === void 0 ? void 0 : options.abortSignal,
|
|
2222
2224
|
minContextSlot: transaction.minNonceContextSlot,
|
|
2223
2225
|
nonceAccountPubkey,
|
|
2224
2226
|
nonceValue: transaction.nonceInfo.nonce,
|
|
2225
2227
|
signature
|
|
2226
2228
|
}, options && options.commitment)).value;
|
|
2227
2229
|
} else {
|
|
2230
|
+
if ((options === null || options === void 0 ? void 0 : options.abortSignal) != null) {
|
|
2231
|
+
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.');
|
|
2232
|
+
}
|
|
2233
|
+
|
|
2228
2234
|
status = (await connection.confirmTransaction(signature, options && options.commitment)).value;
|
|
2229
2235
|
}
|
|
2230
2236
|
|
|
@@ -3388,7 +3394,7 @@ function nextPowerOfTwo(n) {
|
|
|
3388
3394
|
/**
|
|
3389
3395
|
* Epoch schedule
|
|
3390
3396
|
* (see https://docs.solana.com/terminology#epoch)
|
|
3391
|
-
* Can be retrieved with the {@link
|
|
3397
|
+
* Can be retrieved with the {@link Connection.getEpochSchedule} method
|
|
3392
3398
|
*/
|
|
3393
3399
|
|
|
3394
3400
|
|
|
@@ -3660,13 +3666,10 @@ function extractCommitmentFromConfig(commitmentOrConfig) {
|
|
|
3660
3666
|
};
|
|
3661
3667
|
}
|
|
3662
3668
|
/**
|
|
3663
|
-
*
|
|
3669
|
+
* @internal
|
|
3664
3670
|
*/
|
|
3665
3671
|
|
|
3666
3672
|
|
|
3667
|
-
/**
|
|
3668
|
-
* @internal
|
|
3669
|
-
*/
|
|
3670
3673
|
function createRpcResult(result) {
|
|
3671
3674
|
return union([type({
|
|
3672
3675
|
jsonrpc: literal('2.0'),
|
|
@@ -3858,9 +3861,15 @@ const BlockProductionResponseStruct = jsonRpcResultAndContext(type({
|
|
|
3858
3861
|
* A performance sample
|
|
3859
3862
|
*/
|
|
3860
3863
|
|
|
3861
|
-
function createRpcClient(url, httpHeaders, customFetch, fetchMiddleware, disableRetryOnRateLimit) {
|
|
3864
|
+
function createRpcClient(url, httpHeaders, customFetch, fetchMiddleware, disableRetryOnRateLimit, httpAgent) {
|
|
3862
3865
|
const fetch = customFetch ? customFetch : fetchImpl;
|
|
3863
3866
|
|
|
3867
|
+
{
|
|
3868
|
+
if (httpAgent != null) {
|
|
3869
|
+
console.warn('You have supplied an `httpAgent` when creating a `Connection` in a browser environment.' + 'It has been ignored; `httpAgent` is only used in Node environments.');
|
|
3870
|
+
}
|
|
3871
|
+
}
|
|
3872
|
+
|
|
3864
3873
|
let fetchWithMiddleware;
|
|
3865
3874
|
|
|
3866
3875
|
if (fetchMiddleware) {
|
|
@@ -4767,6 +4776,7 @@ class Connection {
|
|
|
4767
4776
|
let fetch;
|
|
4768
4777
|
let fetchMiddleware;
|
|
4769
4778
|
let disableRetryOnRateLimit;
|
|
4779
|
+
let httpAgent;
|
|
4770
4780
|
|
|
4771
4781
|
if (commitmentOrConfig && typeof commitmentOrConfig === 'string') {
|
|
4772
4782
|
this._commitment = commitmentOrConfig;
|
|
@@ -4778,11 +4788,12 @@ class Connection {
|
|
|
4778
4788
|
fetch = commitmentOrConfig.fetch;
|
|
4779
4789
|
fetchMiddleware = commitmentOrConfig.fetchMiddleware;
|
|
4780
4790
|
disableRetryOnRateLimit = commitmentOrConfig.disableRetryOnRateLimit;
|
|
4791
|
+
httpAgent = commitmentOrConfig.httpAgent;
|
|
4781
4792
|
}
|
|
4782
4793
|
|
|
4783
4794
|
this._rpcEndpoint = assertEndpointUrl(endpoint);
|
|
4784
4795
|
this._rpcWsEndpoint = wsEndpoint || makeWebsocketUrl(endpoint);
|
|
4785
|
-
this._rpcClient = createRpcClient(endpoint, httpHeaders, fetch, fetchMiddleware, disableRetryOnRateLimit);
|
|
4796
|
+
this._rpcClient = createRpcClient(endpoint, httpHeaders, fetch, fetchMiddleware, disableRetryOnRateLimit, httpAgent);
|
|
4786
4797
|
this._rpcRequest = createRpcRequest(this._rpcClient);
|
|
4787
4798
|
this._rpcBatchRequest = createRpcBatchRequest(this._rpcClient);
|
|
4788
4799
|
this._rpcWebSocket = new Client(this._rpcWsEndpoint, {
|
|
@@ -5273,7 +5284,14 @@ class Connection {
|
|
|
5273
5284
|
if (typeof strategy == 'string') {
|
|
5274
5285
|
rawSignature = strategy;
|
|
5275
5286
|
} else {
|
|
5287
|
+
var _config$abortSignal;
|
|
5288
|
+
|
|
5276
5289
|
const config = strategy;
|
|
5290
|
+
|
|
5291
|
+
if ((_config$abortSignal = config.abortSignal) !== null && _config$abortSignal !== void 0 && _config$abortSignal.aborted) {
|
|
5292
|
+
return Promise.reject(config.abortSignal.reason);
|
|
5293
|
+
}
|
|
5294
|
+
|
|
5277
5295
|
rawSignature = config.signature;
|
|
5278
5296
|
}
|
|
5279
5297
|
|
|
@@ -5305,6 +5323,22 @@ class Connection {
|
|
|
5305
5323
|
}
|
|
5306
5324
|
}
|
|
5307
5325
|
|
|
5326
|
+
getCancellationPromise(signal) {
|
|
5327
|
+
return new Promise((_, reject) => {
|
|
5328
|
+
if (signal == null) {
|
|
5329
|
+
return;
|
|
5330
|
+
}
|
|
5331
|
+
|
|
5332
|
+
if (signal.aborted) {
|
|
5333
|
+
reject(signal.reason);
|
|
5334
|
+
} else {
|
|
5335
|
+
signal.addEventListener('abort', () => {
|
|
5336
|
+
reject(signal.reason);
|
|
5337
|
+
});
|
|
5338
|
+
}
|
|
5339
|
+
});
|
|
5340
|
+
}
|
|
5341
|
+
|
|
5308
5342
|
getTransactionConfirmationPromise({
|
|
5309
5343
|
commitment,
|
|
5310
5344
|
signature
|
|
@@ -5423,6 +5457,7 @@ class Connection {
|
|
|
5423
5457
|
async confirmTransactionUsingBlockHeightExceedanceStrategy({
|
|
5424
5458
|
commitment,
|
|
5425
5459
|
strategy: {
|
|
5460
|
+
abortSignal,
|
|
5426
5461
|
lastValidBlockHeight,
|
|
5427
5462
|
signature
|
|
5428
5463
|
}
|
|
@@ -5461,10 +5496,11 @@ class Connection {
|
|
|
5461
5496
|
commitment,
|
|
5462
5497
|
signature
|
|
5463
5498
|
});
|
|
5499
|
+
const cancellationPromise = this.getCancellationPromise(abortSignal);
|
|
5464
5500
|
let result;
|
|
5465
5501
|
|
|
5466
5502
|
try {
|
|
5467
|
-
const outcome = await Promise.race([confirmationPromise, expiryPromise]);
|
|
5503
|
+
const outcome = await Promise.race([cancellationPromise, confirmationPromise, expiryPromise]);
|
|
5468
5504
|
|
|
5469
5505
|
if (outcome.__type === TransactionStatus.PROCESSED) {
|
|
5470
5506
|
result = outcome.response;
|
|
@@ -5482,6 +5518,7 @@ class Connection {
|
|
|
5482
5518
|
async confirmTransactionUsingDurableNonceStrategy({
|
|
5483
5519
|
commitment,
|
|
5484
5520
|
strategy: {
|
|
5521
|
+
abortSignal,
|
|
5485
5522
|
minContextSlot,
|
|
5486
5523
|
nonceAccountPubkey,
|
|
5487
5524
|
nonceValue,
|
|
@@ -5539,10 +5576,11 @@ class Connection {
|
|
|
5539
5576
|
commitment,
|
|
5540
5577
|
signature
|
|
5541
5578
|
});
|
|
5579
|
+
const cancellationPromise = this.getCancellationPromise(abortSignal);
|
|
5542
5580
|
let result;
|
|
5543
5581
|
|
|
5544
5582
|
try {
|
|
5545
|
-
const outcome = await Promise.race([confirmationPromise, expiryPromise]);
|
|
5583
|
+
const outcome = await Promise.race([cancellationPromise, confirmationPromise, expiryPromise]);
|
|
5546
5584
|
|
|
5547
5585
|
if (outcome.__type === TransactionStatus.PROCESSED) {
|
|
5548
5586
|
result = outcome.response;
|