@solana/web3.js 1.73.4 → 1.75.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 +61 -25
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +61 -25
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +61 -25
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +21 -1
- package/lib/index.esm.js +61 -25
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +61 -25
- 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/lib/index.native.js +61 -25
- package/lib/index.native.js.map +1 -1
- package/package.json +4 -4
- package/src/connection.ts +89 -21
package/lib/index.browser.cjs.js
CHANGED
|
@@ -3536,6 +3536,13 @@ const GetInflationRewardResult = jsonRpcResult(superstruct.array(superstruct.nul
|
|
|
3536
3536
|
postBalance: superstruct.number(),
|
|
3537
3537
|
commission: superstruct.optional(superstruct.nullable(superstruct.number()))
|
|
3538
3538
|
}))));
|
|
3539
|
+
/**
|
|
3540
|
+
* Expected JSON RPC response for the "getRecentPrioritizationFees" message
|
|
3541
|
+
*/
|
|
3542
|
+
const GetRecentPrioritizationFeesResult = superstruct.array(superstruct.type({
|
|
3543
|
+
slot: superstruct.number(),
|
|
3544
|
+
prioritizationFee: superstruct.number()
|
|
3545
|
+
}));
|
|
3539
3546
|
/**
|
|
3540
3547
|
* Expected JSON RPC response for the "getInflationRate" message
|
|
3541
3548
|
*/
|
|
@@ -3737,6 +3744,11 @@ const GetInflationGovernorRpcResult = jsonRpcResult(GetInflationGovernorResult);
|
|
|
3737
3744
|
*/
|
|
3738
3745
|
const GetInflationRateRpcResult = jsonRpcResult(GetInflationRateResult);
|
|
3739
3746
|
|
|
3747
|
+
/**
|
|
3748
|
+
* Expected JSON RPC response for the "getRecentPrioritizationFees" message
|
|
3749
|
+
*/
|
|
3750
|
+
const GetRecentPrioritizationFeesRpcResult = jsonRpcResult(GetRecentPrioritizationFeesResult);
|
|
3751
|
+
|
|
3740
3752
|
/**
|
|
3741
3753
|
* Expected JSON RPC response for the "getEpochInfo" message
|
|
3742
3754
|
*/
|
|
@@ -4492,7 +4504,7 @@ class Connection {
|
|
|
4492
4504
|
* @param endpoint URL to the fullnode JSON RPC endpoint
|
|
4493
4505
|
* @param commitmentOrConfig optional default commitment level or optional ConnectionConfig configuration object
|
|
4494
4506
|
*/
|
|
4495
|
-
constructor(endpoint,
|
|
4507
|
+
constructor(endpoint, _commitmentOrConfig) {
|
|
4496
4508
|
this._commitment = void 0;
|
|
4497
4509
|
this._confirmTransactionInitialTimeout = void 0;
|
|
4498
4510
|
this._rpcEndpoint = void 0;
|
|
@@ -4520,23 +4532,47 @@ class Connection {
|
|
|
4520
4532
|
this._subscriptionCallbacksByServerSubscriptionId = {};
|
|
4521
4533
|
this._subscriptionsByHash = {};
|
|
4522
4534
|
this._subscriptionsAutoDisposedByRpc = new Set();
|
|
4535
|
+
this.getBlockHeight = (() => {
|
|
4536
|
+
const requestPromises = {};
|
|
4537
|
+
return async commitmentOrConfig => {
|
|
4538
|
+
const {
|
|
4539
|
+
commitment,
|
|
4540
|
+
config
|
|
4541
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
4542
|
+
const args = this._buildArgs([], commitment, undefined /* encoding */, config);
|
|
4543
|
+
const requestHash = fastStableStringify$1(args);
|
|
4544
|
+
requestPromises[requestHash] = requestPromises[requestHash] ?? (async () => {
|
|
4545
|
+
try {
|
|
4546
|
+
const unsafeRes = await this._rpcRequest('getBlockHeight', args);
|
|
4547
|
+
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
|
|
4548
|
+
if ('error' in res) {
|
|
4549
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get block height information');
|
|
4550
|
+
}
|
|
4551
|
+
return res.result;
|
|
4552
|
+
} finally {
|
|
4553
|
+
delete requestPromises[requestHash];
|
|
4554
|
+
}
|
|
4555
|
+
})();
|
|
4556
|
+
return await requestPromises[requestHash];
|
|
4557
|
+
};
|
|
4558
|
+
})();
|
|
4523
4559
|
let wsEndpoint;
|
|
4524
4560
|
let httpHeaders;
|
|
4525
4561
|
let fetch;
|
|
4526
4562
|
let fetchMiddleware;
|
|
4527
4563
|
let disableRetryOnRateLimit;
|
|
4528
4564
|
let httpAgent;
|
|
4529
|
-
if (
|
|
4530
|
-
this._commitment =
|
|
4531
|
-
} else if (
|
|
4532
|
-
this._commitment =
|
|
4533
|
-
this._confirmTransactionInitialTimeout =
|
|
4534
|
-
wsEndpoint =
|
|
4535
|
-
httpHeaders =
|
|
4536
|
-
fetch =
|
|
4537
|
-
fetchMiddleware =
|
|
4538
|
-
disableRetryOnRateLimit =
|
|
4539
|
-
httpAgent =
|
|
4565
|
+
if (_commitmentOrConfig && typeof _commitmentOrConfig === 'string') {
|
|
4566
|
+
this._commitment = _commitmentOrConfig;
|
|
4567
|
+
} else if (_commitmentOrConfig) {
|
|
4568
|
+
this._commitment = _commitmentOrConfig.commitment;
|
|
4569
|
+
this._confirmTransactionInitialTimeout = _commitmentOrConfig.confirmTransactionInitialTimeout;
|
|
4570
|
+
wsEndpoint = _commitmentOrConfig.wsEndpoint;
|
|
4571
|
+
httpHeaders = _commitmentOrConfig.httpHeaders;
|
|
4572
|
+
fetch = _commitmentOrConfig.fetch;
|
|
4573
|
+
fetchMiddleware = _commitmentOrConfig.fetchMiddleware;
|
|
4574
|
+
disableRetryOnRateLimit = _commitmentOrConfig.disableRetryOnRateLimit;
|
|
4575
|
+
httpAgent = _commitmentOrConfig.httpAgent;
|
|
4540
4576
|
}
|
|
4541
4577
|
this._rpcEndpoint = assertEndpointUrl(endpoint);
|
|
4542
4578
|
this._rpcWsEndpoint = wsEndpoint || makeWebsocketUrl(endpoint);
|
|
@@ -5610,6 +5646,19 @@ class Connection {
|
|
|
5610
5646
|
return res.result;
|
|
5611
5647
|
}
|
|
5612
5648
|
|
|
5649
|
+
/**
|
|
5650
|
+
* Fetch a list of prioritization fees from recent blocks.
|
|
5651
|
+
*/
|
|
5652
|
+
async getRecentPrioritizationFees(config) {
|
|
5653
|
+
const accounts = config?.lockedWritableAccounts?.map(key => key.toBase58());
|
|
5654
|
+
const args = this._buildArgs(accounts?.length ? [accounts] : []);
|
|
5655
|
+
const unsafeRes = await this._rpcRequest('getRecentPrioritizationFees', args);
|
|
5656
|
+
const res = superstruct.create(unsafeRes, GetRecentPrioritizationFeesRpcResult);
|
|
5657
|
+
if ('error' in res) {
|
|
5658
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get recent prioritization fees');
|
|
5659
|
+
}
|
|
5660
|
+
return res.result;
|
|
5661
|
+
}
|
|
5613
5662
|
/**
|
|
5614
5663
|
* Fetch a recent blockhash from the cluster
|
|
5615
5664
|
* @return {Promise<{blockhash: Blockhash, feeCalculator: FeeCalculator}>}
|
|
@@ -5794,19 +5843,6 @@ class Connection {
|
|
|
5794
5843
|
/*
|
|
5795
5844
|
* Returns the current block height of the node
|
|
5796
5845
|
*/
|
|
5797
|
-
async getBlockHeight(commitmentOrConfig) {
|
|
5798
|
-
const {
|
|
5799
|
-
commitment,
|
|
5800
|
-
config
|
|
5801
|
-
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
5802
|
-
const args = this._buildArgs([], commitment, undefined /* encoding */, config);
|
|
5803
|
-
const unsafeRes = await this._rpcRequest('getBlockHeight', args);
|
|
5804
|
-
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
|
|
5805
|
-
if ('error' in res) {
|
|
5806
|
-
throw new SolanaJSONRPCError(res.error, 'failed to get block height information');
|
|
5807
|
-
}
|
|
5808
|
-
return res.result;
|
|
5809
|
-
}
|
|
5810
5846
|
|
|
5811
5847
|
/*
|
|
5812
5848
|
* Returns recent block production information from the current or previous epoch
|