@solana/web3.js 1.73.4 → 1.74.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 +36 -25
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +36 -25
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +36 -25
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.esm.js +36 -25
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +36 -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 +36 -25
- package/lib/index.native.js.map +1 -1
- package/package.json +1 -1
- package/src/connection.ts +33 -21
package/lib/index.d.ts
CHANGED
|
@@ -3355,7 +3355,7 @@ export class Connection {
|
|
|
3355
3355
|
getParsedBlock(slot: number, rawConfig: GetVersionedBlockConfig & {
|
|
3356
3356
|
transactionDetails: 'none';
|
|
3357
3357
|
}): Promise<ParsedNoneModeBlockResponse>;
|
|
3358
|
-
getBlockHeight(commitmentOrConfig?: Commitment | GetBlockHeightConfig)
|
|
3358
|
+
getBlockHeight: (commitmentOrConfig?: Commitment | GetBlockHeightConfig) => Promise<number>;
|
|
3359
3359
|
getBlockProduction(configOrCommitment?: GetBlockProductionConfig | Commitment): Promise<RpcResponseAndContext<BlockProduction>>;
|
|
3360
3360
|
/**
|
|
3361
3361
|
* Fetch a confirmed or finalized transaction from the cluster.
|
package/lib/index.esm.js
CHANGED
|
@@ -6977,7 +6977,7 @@ class Connection {
|
|
|
6977
6977
|
* @param endpoint URL to the fullnode JSON RPC endpoint
|
|
6978
6978
|
* @param commitmentOrConfig optional default commitment level or optional ConnectionConfig configuration object
|
|
6979
6979
|
*/
|
|
6980
|
-
constructor(endpoint,
|
|
6980
|
+
constructor(endpoint, _commitmentOrConfig) {
|
|
6981
6981
|
this._commitment = void 0;
|
|
6982
6982
|
this._confirmTransactionInitialTimeout = void 0;
|
|
6983
6983
|
this._rpcEndpoint = void 0;
|
|
@@ -7005,23 +7005,47 @@ class Connection {
|
|
|
7005
7005
|
this._subscriptionCallbacksByServerSubscriptionId = {};
|
|
7006
7006
|
this._subscriptionsByHash = {};
|
|
7007
7007
|
this._subscriptionsAutoDisposedByRpc = new Set();
|
|
7008
|
+
this.getBlockHeight = (() => {
|
|
7009
|
+
const requestPromises = {};
|
|
7010
|
+
return async commitmentOrConfig => {
|
|
7011
|
+
const {
|
|
7012
|
+
commitment,
|
|
7013
|
+
config
|
|
7014
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
7015
|
+
const args = this._buildArgs([], commitment, undefined /* encoding */, config);
|
|
7016
|
+
const requestHash = fastStableStringify$1(args);
|
|
7017
|
+
requestPromises[requestHash] = requestPromises[requestHash] ?? (async () => {
|
|
7018
|
+
try {
|
|
7019
|
+
const unsafeRes = await this._rpcRequest('getBlockHeight', args);
|
|
7020
|
+
const res = create(unsafeRes, jsonRpcResult(number()));
|
|
7021
|
+
if ('error' in res) {
|
|
7022
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get block height information');
|
|
7023
|
+
}
|
|
7024
|
+
return res.result;
|
|
7025
|
+
} finally {
|
|
7026
|
+
delete requestPromises[requestHash];
|
|
7027
|
+
}
|
|
7028
|
+
})();
|
|
7029
|
+
return await requestPromises[requestHash];
|
|
7030
|
+
};
|
|
7031
|
+
})();
|
|
7008
7032
|
let wsEndpoint;
|
|
7009
7033
|
let httpHeaders;
|
|
7010
7034
|
let fetch;
|
|
7011
7035
|
let fetchMiddleware;
|
|
7012
7036
|
let disableRetryOnRateLimit;
|
|
7013
7037
|
let httpAgent;
|
|
7014
|
-
if (
|
|
7015
|
-
this._commitment =
|
|
7016
|
-
} else if (
|
|
7017
|
-
this._commitment =
|
|
7018
|
-
this._confirmTransactionInitialTimeout =
|
|
7019
|
-
wsEndpoint =
|
|
7020
|
-
httpHeaders =
|
|
7021
|
-
fetch =
|
|
7022
|
-
fetchMiddleware =
|
|
7023
|
-
disableRetryOnRateLimit =
|
|
7024
|
-
httpAgent =
|
|
7038
|
+
if (_commitmentOrConfig && typeof _commitmentOrConfig === 'string') {
|
|
7039
|
+
this._commitment = _commitmentOrConfig;
|
|
7040
|
+
} else if (_commitmentOrConfig) {
|
|
7041
|
+
this._commitment = _commitmentOrConfig.commitment;
|
|
7042
|
+
this._confirmTransactionInitialTimeout = _commitmentOrConfig.confirmTransactionInitialTimeout;
|
|
7043
|
+
wsEndpoint = _commitmentOrConfig.wsEndpoint;
|
|
7044
|
+
httpHeaders = _commitmentOrConfig.httpHeaders;
|
|
7045
|
+
fetch = _commitmentOrConfig.fetch;
|
|
7046
|
+
fetchMiddleware = _commitmentOrConfig.fetchMiddleware;
|
|
7047
|
+
disableRetryOnRateLimit = _commitmentOrConfig.disableRetryOnRateLimit;
|
|
7048
|
+
httpAgent = _commitmentOrConfig.httpAgent;
|
|
7025
7049
|
}
|
|
7026
7050
|
this._rpcEndpoint = assertEndpointUrl(endpoint);
|
|
7027
7051
|
this._rpcWsEndpoint = wsEndpoint || makeWebsocketUrl(endpoint);
|
|
@@ -8279,19 +8303,6 @@ class Connection {
|
|
|
8279
8303
|
/*
|
|
8280
8304
|
* Returns the current block height of the node
|
|
8281
8305
|
*/
|
|
8282
|
-
async getBlockHeight(commitmentOrConfig) {
|
|
8283
|
-
const {
|
|
8284
|
-
commitment,
|
|
8285
|
-
config
|
|
8286
|
-
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
8287
|
-
const args = this._buildArgs([], commitment, undefined /* encoding */, config);
|
|
8288
|
-
const unsafeRes = await this._rpcRequest('getBlockHeight', args);
|
|
8289
|
-
const res = create(unsafeRes, jsonRpcResult(number()));
|
|
8290
|
-
if ('error' in res) {
|
|
8291
|
-
throw new SolanaJSONRPCError(res.error, 'failed to get block height information');
|
|
8292
|
-
}
|
|
8293
|
-
return res.result;
|
|
8294
|
-
}
|
|
8295
8306
|
|
|
8296
8307
|
/*
|
|
8297
8308
|
* Returns recent block production information from the current or previous epoch
|