@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.cjs.js
CHANGED
|
@@ -6037,6 +6037,13 @@ const GetInflationRewardResult = jsonRpcResult(superstruct.array(superstruct.nul
|
|
|
6037
6037
|
postBalance: superstruct.number(),
|
|
6038
6038
|
commission: superstruct.optional(superstruct.nullable(superstruct.number()))
|
|
6039
6039
|
}))));
|
|
6040
|
+
/**
|
|
6041
|
+
* Expected JSON RPC response for the "getRecentPrioritizationFees" message
|
|
6042
|
+
*/
|
|
6043
|
+
const GetRecentPrioritizationFeesResult = superstruct.array(superstruct.type({
|
|
6044
|
+
slot: superstruct.number(),
|
|
6045
|
+
prioritizationFee: superstruct.number()
|
|
6046
|
+
}));
|
|
6040
6047
|
/**
|
|
6041
6048
|
* Expected JSON RPC response for the "getInflationRate" message
|
|
6042
6049
|
*/
|
|
@@ -6261,6 +6268,11 @@ const GetInflationGovernorRpcResult = jsonRpcResult(GetInflationGovernorResult);
|
|
|
6261
6268
|
*/
|
|
6262
6269
|
const GetInflationRateRpcResult = jsonRpcResult(GetInflationRateResult);
|
|
6263
6270
|
|
|
6271
|
+
/**
|
|
6272
|
+
* Expected JSON RPC response for the "getRecentPrioritizationFees" message
|
|
6273
|
+
*/
|
|
6274
|
+
const GetRecentPrioritizationFeesRpcResult = jsonRpcResult(GetRecentPrioritizationFeesResult);
|
|
6275
|
+
|
|
6264
6276
|
/**
|
|
6265
6277
|
* Expected JSON RPC response for the "getEpochInfo" message
|
|
6266
6278
|
*/
|
|
@@ -7016,7 +7028,7 @@ class Connection {
|
|
|
7016
7028
|
* @param endpoint URL to the fullnode JSON RPC endpoint
|
|
7017
7029
|
* @param commitmentOrConfig optional default commitment level or optional ConnectionConfig configuration object
|
|
7018
7030
|
*/
|
|
7019
|
-
constructor(endpoint,
|
|
7031
|
+
constructor(endpoint, _commitmentOrConfig) {
|
|
7020
7032
|
this._commitment = void 0;
|
|
7021
7033
|
this._confirmTransactionInitialTimeout = void 0;
|
|
7022
7034
|
this._rpcEndpoint = void 0;
|
|
@@ -7044,23 +7056,47 @@ class Connection {
|
|
|
7044
7056
|
this._subscriptionCallbacksByServerSubscriptionId = {};
|
|
7045
7057
|
this._subscriptionsByHash = {};
|
|
7046
7058
|
this._subscriptionsAutoDisposedByRpc = new Set();
|
|
7059
|
+
this.getBlockHeight = (() => {
|
|
7060
|
+
const requestPromises = {};
|
|
7061
|
+
return async commitmentOrConfig => {
|
|
7062
|
+
const {
|
|
7063
|
+
commitment,
|
|
7064
|
+
config
|
|
7065
|
+
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
7066
|
+
const args = this._buildArgs([], commitment, undefined /* encoding */, config);
|
|
7067
|
+
const requestHash = fastStableStringify$1(args);
|
|
7068
|
+
requestPromises[requestHash] = requestPromises[requestHash] ?? (async () => {
|
|
7069
|
+
try {
|
|
7070
|
+
const unsafeRes = await this._rpcRequest('getBlockHeight', args);
|
|
7071
|
+
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
|
|
7072
|
+
if ('error' in res) {
|
|
7073
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get block height information');
|
|
7074
|
+
}
|
|
7075
|
+
return res.result;
|
|
7076
|
+
} finally {
|
|
7077
|
+
delete requestPromises[requestHash];
|
|
7078
|
+
}
|
|
7079
|
+
})();
|
|
7080
|
+
return await requestPromises[requestHash];
|
|
7081
|
+
};
|
|
7082
|
+
})();
|
|
7047
7083
|
let wsEndpoint;
|
|
7048
7084
|
let httpHeaders;
|
|
7049
7085
|
let fetch;
|
|
7050
7086
|
let fetchMiddleware;
|
|
7051
7087
|
let disableRetryOnRateLimit;
|
|
7052
7088
|
let httpAgent;
|
|
7053
|
-
if (
|
|
7054
|
-
this._commitment =
|
|
7055
|
-
} else if (
|
|
7056
|
-
this._commitment =
|
|
7057
|
-
this._confirmTransactionInitialTimeout =
|
|
7058
|
-
wsEndpoint =
|
|
7059
|
-
httpHeaders =
|
|
7060
|
-
fetch =
|
|
7061
|
-
fetchMiddleware =
|
|
7062
|
-
disableRetryOnRateLimit =
|
|
7063
|
-
httpAgent =
|
|
7089
|
+
if (_commitmentOrConfig && typeof _commitmentOrConfig === 'string') {
|
|
7090
|
+
this._commitment = _commitmentOrConfig;
|
|
7091
|
+
} else if (_commitmentOrConfig) {
|
|
7092
|
+
this._commitment = _commitmentOrConfig.commitment;
|
|
7093
|
+
this._confirmTransactionInitialTimeout = _commitmentOrConfig.confirmTransactionInitialTimeout;
|
|
7094
|
+
wsEndpoint = _commitmentOrConfig.wsEndpoint;
|
|
7095
|
+
httpHeaders = _commitmentOrConfig.httpHeaders;
|
|
7096
|
+
fetch = _commitmentOrConfig.fetch;
|
|
7097
|
+
fetchMiddleware = _commitmentOrConfig.fetchMiddleware;
|
|
7098
|
+
disableRetryOnRateLimit = _commitmentOrConfig.disableRetryOnRateLimit;
|
|
7099
|
+
httpAgent = _commitmentOrConfig.httpAgent;
|
|
7064
7100
|
}
|
|
7065
7101
|
this._rpcEndpoint = assertEndpointUrl(endpoint);
|
|
7066
7102
|
this._rpcWsEndpoint = wsEndpoint || makeWebsocketUrl(endpoint);
|
|
@@ -8134,6 +8170,19 @@ class Connection {
|
|
|
8134
8170
|
return res.result;
|
|
8135
8171
|
}
|
|
8136
8172
|
|
|
8173
|
+
/**
|
|
8174
|
+
* Fetch a list of prioritization fees from recent blocks.
|
|
8175
|
+
*/
|
|
8176
|
+
async getRecentPrioritizationFees(config) {
|
|
8177
|
+
const accounts = config?.lockedWritableAccounts?.map(key => key.toBase58());
|
|
8178
|
+
const args = this._buildArgs(accounts?.length ? [accounts] : []);
|
|
8179
|
+
const unsafeRes = await this._rpcRequest('getRecentPrioritizationFees', args);
|
|
8180
|
+
const res = superstruct.create(unsafeRes, GetRecentPrioritizationFeesRpcResult);
|
|
8181
|
+
if ('error' in res) {
|
|
8182
|
+
throw new SolanaJSONRPCError(res.error, 'failed to get recent prioritization fees');
|
|
8183
|
+
}
|
|
8184
|
+
return res.result;
|
|
8185
|
+
}
|
|
8137
8186
|
/**
|
|
8138
8187
|
* Fetch a recent blockhash from the cluster
|
|
8139
8188
|
* @return {Promise<{blockhash: Blockhash, feeCalculator: FeeCalculator}>}
|
|
@@ -8318,19 +8367,6 @@ class Connection {
|
|
|
8318
8367
|
/*
|
|
8319
8368
|
* Returns the current block height of the node
|
|
8320
8369
|
*/
|
|
8321
|
-
async getBlockHeight(commitmentOrConfig) {
|
|
8322
|
-
const {
|
|
8323
|
-
commitment,
|
|
8324
|
-
config
|
|
8325
|
-
} = extractCommitmentFromConfig(commitmentOrConfig);
|
|
8326
|
-
const args = this._buildArgs([], commitment, undefined /* encoding */, config);
|
|
8327
|
-
const unsafeRes = await this._rpcRequest('getBlockHeight', args);
|
|
8328
|
-
const res = superstruct.create(unsafeRes, jsonRpcResult(superstruct.number()));
|
|
8329
|
-
if ('error' in res) {
|
|
8330
|
-
throw new SolanaJSONRPCError(res.error, 'failed to get block height information');
|
|
8331
|
-
}
|
|
8332
|
-
return res.result;
|
|
8333
|
-
}
|
|
8334
8370
|
|
|
8335
8371
|
/*
|
|
8336
8372
|
* Returns recent block production information from the current or previous epoch
|