@solana/web3.js 1.68.1 → 1.70.0-pr-29130
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 +48 -11
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +48 -11
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +2821 -221
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +247 -234
- package/lib/index.esm.js +2814 -219
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +48 -11
- 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 +48 -11
- package/lib/index.native.js.map +1 -1
- package/package.json +7 -5
- package/src/connection.ts +123 -35
- package/src/epoch-schedule.ts +1 -1
- package/src/utils/send-and-confirm-transaction.ts +14 -1
- package/src/agent-manager.ts +0 -44
package/README.md
CHANGED
|
@@ -102,19 +102,6 @@ This library requires a JavaScript runtime that supports [`BigInt`](https://deve
|
|
|
102
102
|
- React Native:
|
|
103
103
|
- \>=0.7.0 using the [Hermes](https://reactnative.dev/blog/2022/07/08/hermes-as-the-default) engine ([integration guide](https://solanacookbook.com/integrations/react-native.html#how-to-use-solana-web3-js-in-a-react-native-app)):
|
|
104
104
|
|
|
105
|
-
## Flow Support (Discontinued)
|
|
106
|
-
|
|
107
|
-
Flow types are no longer supported in new releases. The last release with Flow support is v1.37.2 and its
|
|
108
|
-
[Flow library definition](https://flow.org/en/docs/libdefs/) is provided at
|
|
109
|
-
https://unpkg.com/@solana/web3.js@v1.37.2/module.flow.js.
|
|
110
|
-
Download the file and add the following line under the [libs] section of your project's `.flowconfig` to
|
|
111
|
-
activate it:
|
|
112
|
-
|
|
113
|
-
```ini
|
|
114
|
-
[libs]
|
|
115
|
-
node_modules/@solana/web3.js/module.flow.js
|
|
116
|
-
```
|
|
117
|
-
|
|
118
105
|
## Releases
|
|
119
106
|
|
|
120
107
|
Releases are available on [Github](https://github.com/solana-labs/solana-web3.js/releases)
|
package/lib/index.browser.cjs.js
CHANGED
|
@@ -2239,6 +2239,7 @@ async function sendAndConfirmTransaction(connection, transaction, signers, optio
|
|
|
2239
2239
|
|
|
2240
2240
|
if (transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null) {
|
|
2241
2241
|
status = (await connection.confirmTransaction({
|
|
2242
|
+
abortSignal: options === null || options === void 0 ? void 0 : options.abortSignal,
|
|
2242
2243
|
signature: signature,
|
|
2243
2244
|
blockhash: transaction.recentBlockhash,
|
|
2244
2245
|
lastValidBlockHeight: transaction.lastValidBlockHeight
|
|
@@ -2249,12 +2250,17 @@ async function sendAndConfirmTransaction(connection, transaction, signers, optio
|
|
|
2249
2250
|
} = transaction.nonceInfo;
|
|
2250
2251
|
const nonceAccountPubkey = nonceInstruction.keys[0].pubkey;
|
|
2251
2252
|
status = (await connection.confirmTransaction({
|
|
2253
|
+
abortSignal: options === null || options === void 0 ? void 0 : options.abortSignal,
|
|
2252
2254
|
minContextSlot: transaction.minNonceContextSlot,
|
|
2253
2255
|
nonceAccountPubkey,
|
|
2254
2256
|
nonceValue: transaction.nonceInfo.nonce,
|
|
2255
2257
|
signature
|
|
2256
2258
|
}, options && options.commitment)).value;
|
|
2257
2259
|
} else {
|
|
2260
|
+
if ((options === null || options === void 0 ? void 0 : options.abortSignal) != null) {
|
|
2261
|
+
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.');
|
|
2262
|
+
}
|
|
2263
|
+
|
|
2258
2264
|
status = (await connection.confirmTransaction(signature, options && options.commitment)).value;
|
|
2259
2265
|
}
|
|
2260
2266
|
|
|
@@ -3418,7 +3424,7 @@ function nextPowerOfTwo(n) {
|
|
|
3418
3424
|
/**
|
|
3419
3425
|
* Epoch schedule
|
|
3420
3426
|
* (see https://docs.solana.com/terminology#epoch)
|
|
3421
|
-
* Can be retrieved with the {@link
|
|
3427
|
+
* Can be retrieved with the {@link Connection.getEpochSchedule} method
|
|
3422
3428
|
*/
|
|
3423
3429
|
|
|
3424
3430
|
|
|
@@ -3690,13 +3696,10 @@ function extractCommitmentFromConfig(commitmentOrConfig) {
|
|
|
3690
3696
|
};
|
|
3691
3697
|
}
|
|
3692
3698
|
/**
|
|
3693
|
-
*
|
|
3699
|
+
* @internal
|
|
3694
3700
|
*/
|
|
3695
3701
|
|
|
3696
3702
|
|
|
3697
|
-
/**
|
|
3698
|
-
* @internal
|
|
3699
|
-
*/
|
|
3700
3703
|
function createRpcResult(result) {
|
|
3701
3704
|
return superstruct.union([superstruct.type({
|
|
3702
3705
|
jsonrpc: superstruct.literal('2.0'),
|
|
@@ -3888,8 +3891,15 @@ const BlockProductionResponseStruct = jsonRpcResultAndContext(superstruct.type({
|
|
|
3888
3891
|
* A performance sample
|
|
3889
3892
|
*/
|
|
3890
3893
|
|
|
3891
|
-
function createRpcClient(url, httpHeaders, customFetch, fetchMiddleware, disableRetryOnRateLimit) {
|
|
3894
|
+
function createRpcClient(url, httpHeaders, customFetch, fetchMiddleware, disableRetryOnRateLimit, httpAgent) {
|
|
3892
3895
|
const fetch = customFetch ? customFetch : fetchImpl;
|
|
3896
|
+
let agent;
|
|
3897
|
+
|
|
3898
|
+
{
|
|
3899
|
+
if (httpAgent != null) {
|
|
3900
|
+
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.');
|
|
3901
|
+
}
|
|
3902
|
+
}
|
|
3893
3903
|
|
|
3894
3904
|
let fetchWithMiddleware;
|
|
3895
3905
|
|
|
@@ -3907,7 +3917,6 @@ function createRpcClient(url, httpHeaders, customFetch, fetchMiddleware, disable
|
|
|
3907
3917
|
}
|
|
3908
3918
|
|
|
3909
3919
|
const clientBrowser = new RpcClient__default["default"](async (request, callback) => {
|
|
3910
|
-
const agent = undefined;
|
|
3911
3920
|
const options = {
|
|
3912
3921
|
method: 'POST',
|
|
3913
3922
|
body: request,
|
|
@@ -3959,7 +3968,6 @@ function createRpcClient(url, httpHeaders, customFetch, fetchMiddleware, disable
|
|
|
3959
3968
|
}
|
|
3960
3969
|
} catch (err) {
|
|
3961
3970
|
if (err instanceof Error) callback(err);
|
|
3962
|
-
} finally {
|
|
3963
3971
|
}
|
|
3964
3972
|
}, {});
|
|
3965
3973
|
return clientBrowser;
|
|
@@ -4797,6 +4805,7 @@ class Connection {
|
|
|
4797
4805
|
let fetch;
|
|
4798
4806
|
let fetchMiddleware;
|
|
4799
4807
|
let disableRetryOnRateLimit;
|
|
4808
|
+
let httpAgent;
|
|
4800
4809
|
|
|
4801
4810
|
if (commitmentOrConfig && typeof commitmentOrConfig === 'string') {
|
|
4802
4811
|
this._commitment = commitmentOrConfig;
|
|
@@ -4808,11 +4817,12 @@ class Connection {
|
|
|
4808
4817
|
fetch = commitmentOrConfig.fetch;
|
|
4809
4818
|
fetchMiddleware = commitmentOrConfig.fetchMiddleware;
|
|
4810
4819
|
disableRetryOnRateLimit = commitmentOrConfig.disableRetryOnRateLimit;
|
|
4820
|
+
httpAgent = commitmentOrConfig.httpAgent;
|
|
4811
4821
|
}
|
|
4812
4822
|
|
|
4813
4823
|
this._rpcEndpoint = assertEndpointUrl(endpoint);
|
|
4814
4824
|
this._rpcWsEndpoint = wsEndpoint || makeWebsocketUrl(endpoint);
|
|
4815
|
-
this._rpcClient = createRpcClient(endpoint, httpHeaders, fetch, fetchMiddleware, disableRetryOnRateLimit);
|
|
4825
|
+
this._rpcClient = createRpcClient(endpoint, httpHeaders, fetch, fetchMiddleware, disableRetryOnRateLimit, httpAgent);
|
|
4816
4826
|
this._rpcRequest = createRpcRequest(this._rpcClient);
|
|
4817
4827
|
this._rpcBatchRequest = createRpcBatchRequest(this._rpcClient);
|
|
4818
4828
|
this._rpcWebSocket = new rpcWebsockets.Client(this._rpcWsEndpoint, {
|
|
@@ -5303,7 +5313,14 @@ class Connection {
|
|
|
5303
5313
|
if (typeof strategy == 'string') {
|
|
5304
5314
|
rawSignature = strategy;
|
|
5305
5315
|
} else {
|
|
5316
|
+
var _config$abortSignal;
|
|
5317
|
+
|
|
5306
5318
|
const config = strategy;
|
|
5319
|
+
|
|
5320
|
+
if ((_config$abortSignal = config.abortSignal) !== null && _config$abortSignal !== void 0 && _config$abortSignal.aborted) {
|
|
5321
|
+
return Promise.reject(config.abortSignal.reason);
|
|
5322
|
+
}
|
|
5323
|
+
|
|
5307
5324
|
rawSignature = config.signature;
|
|
5308
5325
|
}
|
|
5309
5326
|
|
|
@@ -5335,6 +5352,22 @@ class Connection {
|
|
|
5335
5352
|
}
|
|
5336
5353
|
}
|
|
5337
5354
|
|
|
5355
|
+
getCancellationPromise(signal) {
|
|
5356
|
+
return new Promise((_, reject) => {
|
|
5357
|
+
if (signal == null) {
|
|
5358
|
+
return;
|
|
5359
|
+
}
|
|
5360
|
+
|
|
5361
|
+
if (signal.aborted) {
|
|
5362
|
+
reject(signal.reason);
|
|
5363
|
+
} else {
|
|
5364
|
+
signal.addEventListener('abort', () => {
|
|
5365
|
+
reject(signal.reason);
|
|
5366
|
+
});
|
|
5367
|
+
}
|
|
5368
|
+
});
|
|
5369
|
+
}
|
|
5370
|
+
|
|
5338
5371
|
getTransactionConfirmationPromise({
|
|
5339
5372
|
commitment,
|
|
5340
5373
|
signature
|
|
@@ -5453,6 +5486,7 @@ class Connection {
|
|
|
5453
5486
|
async confirmTransactionUsingBlockHeightExceedanceStrategy({
|
|
5454
5487
|
commitment,
|
|
5455
5488
|
strategy: {
|
|
5489
|
+
abortSignal,
|
|
5456
5490
|
lastValidBlockHeight,
|
|
5457
5491
|
signature
|
|
5458
5492
|
}
|
|
@@ -5491,10 +5525,11 @@ class Connection {
|
|
|
5491
5525
|
commitment,
|
|
5492
5526
|
signature
|
|
5493
5527
|
});
|
|
5528
|
+
const cancellationPromise = this.getCancellationPromise(abortSignal);
|
|
5494
5529
|
let result;
|
|
5495
5530
|
|
|
5496
5531
|
try {
|
|
5497
|
-
const outcome = await Promise.race([confirmationPromise, expiryPromise]);
|
|
5532
|
+
const outcome = await Promise.race([cancellationPromise, confirmationPromise, expiryPromise]);
|
|
5498
5533
|
|
|
5499
5534
|
if (outcome.__type === exports.TransactionStatus.PROCESSED) {
|
|
5500
5535
|
result = outcome.response;
|
|
@@ -5512,6 +5547,7 @@ class Connection {
|
|
|
5512
5547
|
async confirmTransactionUsingDurableNonceStrategy({
|
|
5513
5548
|
commitment,
|
|
5514
5549
|
strategy: {
|
|
5550
|
+
abortSignal,
|
|
5515
5551
|
minContextSlot,
|
|
5516
5552
|
nonceAccountPubkey,
|
|
5517
5553
|
nonceValue,
|
|
@@ -5569,10 +5605,11 @@ class Connection {
|
|
|
5569
5605
|
commitment,
|
|
5570
5606
|
signature
|
|
5571
5607
|
});
|
|
5608
|
+
const cancellationPromise = this.getCancellationPromise(abortSignal);
|
|
5572
5609
|
let result;
|
|
5573
5610
|
|
|
5574
5611
|
try {
|
|
5575
|
-
const outcome = await Promise.race([confirmationPromise, expiryPromise]);
|
|
5612
|
+
const outcome = await Promise.race([cancellationPromise, confirmationPromise, expiryPromise]);
|
|
5576
5613
|
|
|
5577
5614
|
if (outcome.__type === exports.TransactionStatus.PROCESSED) {
|
|
5578
5615
|
result = outcome.response;
|